From 6c850b789d24e40dcc895ee025f28412feef3eed Mon Sep 17 00:00:00 2001 From: chaxus Date: Sat, 12 Oct 2024 03:20:42 +0000 Subject: [PATCH] deploy: fb155c5315cd8ebe38b9f22bb3590c2b5ebd674a --- 404.html | 10 +- assets/{app.Bz9dt6dC.js => app.CfJxT4ml.js} | 2 +- assets/chunks/framework.CHSXtLMd.js | 18 + assets/chunks/framework.eq-HTtE3.js | 18 - ...DLGTjfcz.js => index-Ba501-HG.BBoApf2J.js} | 2 +- ...DM_Nu_-Q.js => index-Co9E57uv.BtZPXcWW.js} | 2 +- .../{index.CafPLwUV.js => index.MWfHGcqb.js} | 6 +- ...e_vue_type_style_index_0_lang.gqANFo1t.js} | 2 +- ...o.CmQSFM5C.js => pdf-Cx0VWKFo.BKCfi8kk.js} | 2 +- assets/chunks/pwa-install.es.DI7OvJx5.js | 39 + assets/chunks/pwa-install.es.DuMXkPrI.js | 39 - assets/chunks/theme.B08u4faT.js | 20 + assets/chunks/theme.FPvZ3Ede.js | 20 - ...md.2fj_5uQF.js => cn_index.md.0kzgXyFr.js} | 2 +- ...F.lean.js => cn_index.md.0kzgXyFr.lean.js} | 2 +- ...article_astParse_tokenizer.md.Be5lTQKA.js} | 2 +- ...le_astParse_tokenizer.md.Be5lTQKA.lean.js} | 2 +- ...js => cn_src_article_babel.md.rAspsh5G.js} | 2 +- ... cn_src_article_babel.md.rAspsh5G.lean.js} | 2 +- ...s => cn_src_article_bundle.md.65R3DvSm.js} | 2 +- ...cn_src_article_bundle.md.65R3DvSm.lean.js} | 2 +- ... cn_src_article_designMode.md.BqNiAb_Y.js} | 2 +- ...rc_article_designMode.md.BqNiAb_Y.lean.js} | 2 +- ... cn_src_article_docPreview.md.BRrDrIEF.js} | 2 +- ...rc_article_docPreview.md.BRrDrIEF.lean.js} | 2 +- ...icle_functionalProgramming.md.QqkRa617.js} | 2 +- ...functionalProgramming.md.QqkRa617.lean.js} | 2 +- ...=> cn_src_article_imagemin.md.BD51FgwZ.js} | 2 +- ..._src_article_imagemin.md.BD51FgwZ.lean.js} | 2 +- ...article_javascript_domLoad.md.ePyh9ZRf.js} | 2 +- ...le_javascript_domLoad.md.ePyh9ZRf.lean.js} | 2 +- ..._article_sort_bubble_index.md.DhzOSuoL.js} | 2 +- ...cle_sort_bubble_index.md.DhzOSuoL.lean.js} | 2 +- ..._article_sort_bucket_index.md.iKnXhO5A.js} | 2 +- ...cle_sort_bucket_index.md.iKnXhO5A.lean.js} | 2 +- ...c_article_sort_count_index.md.Cl7iYY9W.js} | 2 +- ...icle_sort_count_index.md.Cl7iYY9W.lean.js} | 2 +- ...rc_article_sort_heap_index.md.mL6leDCa.js} | 2 +- ...ticle_sort_heap_index.md.mL6leDCa.lean.js} | 2 +- ... cn_src_article_sort_index.md.08d3P1kH.js} | 2 +- ...rc_article_sort_index.md.08d3P1kH.lean.js} | 2 +- ..._article_sort_insert_index.md.C6siGqvF.js} | 2 +- ...cle_sort_insert_index.md.C6siGqvF.lean.js} | 2 +- ...c_article_sort_merge_index.md.DHgqFsQk.js} | 2 +- ...icle_sort_merge_index.md.DHgqFsQk.lean.js} | 2 +- ...c_article_sort_quick_index.md.nZxAppd6.js} | 2 +- ...icle_sort_quick_index.md.nZxAppd6.lean.js} | 2 +- ...c_article_sort_radix_index.md.WNmlYeAN.js} | 2 +- ...icle_sort_radix_index.md.WNmlYeAN.lean.js} | 2 +- ..._article_sort_select_index.md.gIQln0jl.js} | 2 +- ...cle_sort_select_index.md.gIQln0jl.lean.js} | 2 +- ...c_article_sort_shell_index.md.DBoMnfgs.js} | 2 +- ...icle_sort_shell_index.md.DBoMnfgs.lean.js} | 2 +- ...n_src_article_systemDesign.md.BS7WrgOy.js} | 2 +- ..._article_systemDesign.md.BS7WrgOy.lean.js} | 2 +- ...ticle_typescript_calculate.md.CDNPBSOv.js} | 2 +- ..._typescript_calculate.md.CDNPBSOv.lean.js} | 2 +- ...c_article_typescript_index.md.xhcQzYKG.js} | 2 +- ...icle_typescript_index.md.xhcQzYKG.lean.js} | 2 +- ...article_typescript_pattern.md.Dmc8v8qK.js} | 2 +- ...le_typescript_pattern.md.Dmc8v8qK.lean.js} | 2 +- ..._typescript_reconstruction.md.y0pME8dQ.js} | 2 +- ...script_reconstruction.md.y0pME8dQ.lean.js} | 2 +- ...ticle_typescript_recursion.md.Cbh8DOxI.js} | 2 +- ..._typescript_recursion.md.Cbh8DOxI.lean.js} | 2 +- ...ticle_typescript_unionType.md.DSQmi5Tg.js} | 2 +- ..._typescript_unionType.md.DSQmi5Tg.lean.js} | 2 +- ...js => cn_src_article_video.md.BHOJcjlO.js} | 2 +- ... cn_src_article_video.md.BHOJcjlO.lean.js} | 2 +- ...s => cn_src_article_visual.md.DqgBm0SZ.js} | 2 +- ...cn_src_article_visual.md.DqgBm0SZ.lean.js} | 2 +- ...T.js => cn_src_note_centos.md.Dd37Ex5S.js} | 2 +- ...=> cn_src_note_centos.md.Dd37Ex5S.lean.js} | 2 +- ...Q.js => cn_src_note_docker.md.DBlFO17f.js} | 2 +- ...=> cn_src_note_docker.md.DBlFO17f.lean.js} | 2 +- ..._src_note_libreoffice2wasm.md.DQRPQED0.js} | 2 +- ...note_libreoffice2wasm.md.DQRPQED0.lean.js} | 2 +- ...t.js => cn_src_note_ubuntu.md.OMrqGjGg.js} | 2 +- ...=> cn_src_note_ubuntu.md.OMrqGjGg.lean.js} | 2 +- ... cn_src_ranui_button_index.md.BDcjlPmF.js} | 2 +- ...rc_ranui_button_index.md.BDcjlPmF.lean.js} | 2 +- ...n_src_ranui_checkbox_index.md.BYpHGGn8.js} | 2 +- ..._ranui_checkbox_index.md.BYpHGGn8.lean.js} | 2 +- ...=> cn_src_ranui_icon_index.md.B1V9PRxj.js} | 2 +- ..._src_ranui_icon_index.md.B1V9PRxj.lean.js} | 2 +- ...> cn_src_ranui_image_index.md.5jpZJsQ-.js} | 2 +- ...src_ranui_image_index.md.5jpZJsQ-.lean.js} | 2 +- ...5.js => cn_src_ranui_index.md.O6NeSIto.js} | 2 +- ...=> cn_src_ranui_index.md.O6NeSIto.lean.js} | 2 +- ...> cn_src_ranui_input_index.md.N5yg7is0.js} | 2 +- ...src_ranui_input_index.md.N5yg7is0.lean.js} | 2 +- ...cn_src_ranui_loading_index.md.D4K746FX.js} | 2 +- ...c_ranui_loading_index.md.D4K746FX.lean.js} | 2 +- ...=> cn_src_ranui_math_index.md.CIJlviae.js} | 2 +- ..._src_ranui_math_index.md.CIJlviae.lean.js} | 2 +- ...cn_src_ranui_message_index.md.wVjYP45A.js} | 2 +- ...c_ranui_message_index.md.wVjYP45A.lean.js} | 2 +- ...> cn_src_ranui_modal_index.md.BuDHHn2M.js} | 2 +- ...src_ranui_modal_index.md.BuDHHn2M.lean.js} | 2 +- ... cn_src_ranui_player_index.md.qcI6qb8P.js} | 2 +- ...rc_ranui_player_index.md.qcI6qb8P.lean.js} | 2 +- ...cn_src_ranui_popover_index.md.BYbffMAB.js} | 2 +- ...c_ranui_popover_index.md.BYbffMAB.lean.js} | 2 +- ...cn_src_ranui_preview_index.md.CyAUjykp.js} | 2 +- ...c_ranui_preview_index.md.CyAUjykp.lean.js} | 2 +- ...n_src_ranui_progress_index.md.B5qyrqdM.js} | 2 +- ..._ranui_progress_index.md.B5qyrqdM.lean.js} | 2 +- ...> cn_src_ranui_radar_index.md.CdnZK7Pb.js} | 2 +- ...src_ranui_radar_index.md.CdnZK7Pb.lean.js} | 2 +- ... cn_src_ranui_select_index.md.DaJPr9cC.js} | 2 +- ...rc_ranui_select_index.md.DaJPr9cC.lean.js} | 2 +- ...n_src_ranui_skeleton_index.md.CFMGgnwG.js} | 2 +- ..._ranui_skeleton_index.md.CFMGgnwG.lean.js} | 2 +- ... => cn_src_ranui_tab_index.md.CY1b1u1V.js} | 2 +- ...n_src_ranui_tab_index.md.CY1b1u1V.lean.js} | 2 +- ...=> cn_src_ranui_tabs_index.md.CpWMVttn.js} | 2 +- ..._src_ranui_tabs_index.md.CpWMVttn.lean.js} | 2 +- ...rc_ranuts_binaryTree_index.md.Cv4oga8R.js} | 2 +- ...nuts_binaryTree_index.md.Cv4oga8R.lean.js} | 2 +- ...n_src_ranuts_bundler_index.md.alHSjuA6.js} | 2 +- ..._ranuts_bundler_index.md.alHSjuA6.lean.js} | 2 +- ...src_ranuts_file_appendFile.md.B1djr2WE.js} | 2 +- ...anuts_file_appendFile.md.B1djr2WE.lean.js} | 2 +- ...n_src_ranuts_file_fileInfo.md.QR_sWfs6.js} | 2 +- ..._ranuts_file_fileInfo.md.QR_sWfs6.lean.js} | 2 +- ...cn_src_ranuts_file_readDir.md.DFB7FVlj.js} | 2 +- ...c_ranuts_file_readDir.md.DFB7FVlj.lean.js} | 2 +- ...n_src_ranuts_file_readFile.md.B89kbS8J.js} | 2 +- ..._ranuts_file_readFile.md.B89kbS8J.lean.js} | 2 +- ..._src_ranuts_file_watchFile.md.BAjI-OaD.js} | 2 +- ...ranuts_file_watchFile.md.BAjI-OaD.lean.js} | 2 +- ..._src_ranuts_file_writeFile.md.DWkSsJv9.js} | 2 +- ...ranuts_file_writeFile.md.DWkSsJv9.lean.js} | 2 +- ....js => cn_src_ranuts_index.md.BA8cILpe.js} | 2 +- ...> cn_src_ranuts_index.md.BA8cILpe.lean.js} | 2 +- ...c_ranuts_mimeType_mimeType.md.CmQXZWG3.js} | 2 +- ...uts_mimeType_mimeType.md.CmQXZWG3.lean.js} | 2 +- ..._src_ranuts_mode_subscribe.md.NMm6FNO3.js} | 2 +- ...ranuts_mode_subscribe.md.NMm6FNO3.lean.js} | 2 +- ...utils_convertImageToBase64.md.CQ_RoAmb.js} | 2 +- ..._convertImageToBase64.md.CQ_RoAmb.lean.js} | 2 +- ...src_ranuts_utils_filterObj.md.BqJRLgq8.js} | 2 +- ...anuts_utils_filterObj.md.BqJRLgq8.lean.js} | 2 +- ...rc_ranuts_utils_formatJson.md.Bh24FNd_.js} | 2 +- ...nuts_utils_formatJson.md.Bh24FNd_.lean.js} | 2 +- ...src_ranuts_utils_getCookie.md.DxXBdlVr.js} | 2 +- ...anuts_utils_getCookie.md.DxXBdlVr.lean.js} | 2 +- ...=> cn_src_ranuts_utils_ocr.md.B4yUe53w.js} | 2 +- ..._src_ranuts_utils_ocr.md.B4yUe53w.lean.js} | 2 +- ...n_src_ranuts_utils_str2xml.md.BaFKZ-2M.js} | 2 +- ..._ranuts_utils_str2xml.md.BaFKZ-2M.lean.js} | 2 +- ...> cn_src_ranuts_utils_task.md.CDbscsJ2.js} | 2 +- ...src_ranuts_utils_task.md.CDbscsJ2.lean.js} | 2 +- ...TS\347\261\273\345\236\213.md.8-URD2RM.js" | 2 +- ...7\261\273\345\236\213.md.8-URD2RM.lean.js" | 2 +- ...17\345\214\271\351\205\215.md.-Hg913qX.js" | 2 +- ...5\214\271\351\205\215.md.-Hg913qX.lean.js" | 2 +- ...13\350\277\220\347\256\227.md.DPzhEpck.js" | 2 +- ...0\277\220\347\256\227.md.DPzhEpck.lean.js" | 2 +- ...47\347\261\273\345\236\213.md.BQ0iDGrX.js" | 2 +- ...7\261\273\345\236\213.md.BQ0iDGrX.lean.js" | 2 +- ...ex.md.BZLM9Chw.js => index.md.DJiM3g0O.js} | 2 +- ...9Chw.lean.js => index.md.DJiM3g0O.lean.js} | 2 +- ...article_astParse_tokenizer.md.CJgdOmtY.js} | 2 +- ...le_astParse_tokenizer.md.CJgdOmtY.lean.js} | 2 +- ...sU.js => src_article_babel.md.CA-cRcF6.js} | 2 +- ... => src_article_babel.md.CA-cRcF6.lean.js} | 2 +- ...N.js => src_article_bundle.md.pJHPU684.js} | 2 +- ...=> src_article_bundle.md.pJHPU684.lean.js} | 2 +- ... => src_article_designMode.md.CQjOH8Aq.js} | 2 +- ...rc_article_designMode.md.CQjOH8Aq.lean.js} | 2 +- ...icle_functionalProgramming.md.Cmp2qFRI.js} | 2 +- ...functionalProgramming.md.Cmp2qFRI.lean.js} | 2 +- ...js => src_article_imagemin.md.C47x7cUg.js} | 2 +- ... src_article_imagemin.md.C47x7cUg.lean.js} | 2 +- ...article_javascript_domLoad.md.E9g_n3_p.js} | 2 +- ...le_javascript_domLoad.md.E9g_n3_p.lean.js} | 2 +- ..._article_sort_bubble_index.md.Uyukvvj_.js} | 2 +- ...cle_sort_bubble_index.md.Uyukvvj_.lean.js} | 2 +- ..._article_sort_bucket_index.md.qqF6Sj4P.js} | 2 +- ...cle_sort_bucket_index.md.qqF6Sj4P.lean.js} | 2 +- ...c_article_sort_count_index.md.C7C1FNVH.js} | 2 +- ...icle_sort_count_index.md.C7C1FNVH.lean.js} | 2 +- ...rc_article_sort_heap_index.md.D4Xl3ax4.js} | 2 +- ...ticle_sort_heap_index.md.D4Xl3ax4.lean.js} | 2 +- ... => src_article_sort_index.md.BpYLVrl8.js} | 2 +- ...rc_article_sort_index.md.BpYLVrl8.lean.js} | 2 +- ..._article_sort_insert_index.md.DVHTMM7z.js} | 2 +- ...cle_sort_insert_index.md.DVHTMM7z.lean.js} | 2 +- ...c_article_sort_merge_index.md.SwAYr2r5.js} | 2 +- ...icle_sort_merge_index.md.SwAYr2r5.lean.js} | 2 +- ...c_article_sort_quick_index.md.DC_bDmFO.js} | 2 +- ...icle_sort_quick_index.md.DC_bDmFO.lean.js} | 2 +- ...c_article_sort_radix_index.md.DOCQJ1JY.js} | 2 +- ...icle_sort_radix_index.md.DOCQJ1JY.lean.js} | 2 +- ..._article_sort_select_index.md.Be1rqYIJ.js} | 2 +- ...cle_sort_select_index.md.Be1rqYIJ.lean.js} | 2 +- ...c_article_sort_shell_index.md.DKh6PE9d.js} | 2 +- ...icle_sort_shell_index.md.DKh6PE9d.lean.js} | 2 +- ...ticle_typescript_calculate.md.CRWKCA-P.js} | 2 +- ..._typescript_calculate.md.CRWKCA-P.lean.js} | 2 +- ...c_article_typescript_index.md.wjDn-lKs.js} | 2 +- ...icle_typescript_index.md.wjDn-lKs.lean.js} | 2 +- ...article_typescript_pattern.md.Ez6YuvlL.js} | 2 +- ...le_typescript_pattern.md.Ez6YuvlL.lean.js} | 2 +- ..._typescript_reconstruction.md.DExhBwDE.js} | 2 +- ...script_reconstruction.md.DExhBwDE.lean.js} | 2 +- ...ticle_typescript_recursion.md.DDZSliPb.js} | 2 +- ..._typescript_recursion.md.DDZSliPb.lean.js} | 2 +- ...ticle_typescript_unionType.md.BQhAt8mB.js} | 2 +- ..._typescript_unionType.md.BQhAt8mB.lean.js} | 2 +- ... => src_ranui_button_index.md.knupWQOc.js} | 2 +- ...rc_ranui_button_index.md.knupWQOc.lean.js} | 2 +- ...> src_ranui_checkbox_index.md.CmEyFQLb.js} | 2 +- ..._ranui_checkbox_index.md.CmEyFQLb.lean.js} | 2 +- ...js => src_ranui_icon_index.md.DWZ8pJQu.js} | 2 +- ... src_ranui_icon_index.md.DWZ8pJQu.lean.js} | 2 +- ...s => src_ranui_image_index.md.C76U51KM.js} | 2 +- ...src_ranui_image_index.md.C76U51KM.lean.js} | 2 +- ...5dZO.js => src_ranui_index.md.VveRY0aV.js} | 2 +- ...js => src_ranui_index.md.VveRY0aV.lean.js} | 2 +- ...s => src_ranui_input_index.md.BAWJIBJZ.js} | 2 +- ...src_ranui_input_index.md.BAWJIBJZ.lean.js} | 2 +- ...=> src_ranui_loading_index.md.CxCc5xD8.js} | 2 +- ...c_ranui_loading_index.md.CxCc5xD8.lean.js} | 2 +- ...js => src_ranui_math_index.md.IY83GwaQ.js} | 2 +- ... src_ranui_math_index.md.IY83GwaQ.lean.js} | 2 +- ...=> src_ranui_message_index.md.CBIOZrnU.js} | 2 +- ...c_ranui_message_index.md.CBIOZrnU.lean.js} | 2 +- ...s => src_ranui_modal_index.md.humdf-kN.js} | 2 +- ...src_ranui_modal_index.md.humdf-kN.lean.js} | 2 +- ... => src_ranui_player_index.md.BhELSses.js} | 2 +- ...rc_ranui_player_index.md.BhELSses.lean.js} | 2 +- ...=> src_ranui_popover_index.md.Bl1nd44O.js} | 2 +- ...c_ranui_popover_index.md.Bl1nd44O.lean.js} | 2 +- ...=> src_ranui_preview_index.md.BF58Mgx1.js} | 2 +- ...c_ranui_preview_index.md.BF58Mgx1.lean.js} | 2 +- ...> src_ranui_progress_index.md.CoMblFHd.js} | 2 +- ..._ranui_progress_index.md.CoMblFHd.lean.js} | 2 +- ...s => src_ranui_radar_index.md.RgzR_NYQ.js} | 2 +- ...src_ranui_radar_index.md.RgzR_NYQ.lean.js} | 2 +- ... => src_ranui_select_index.md.BKakZMxv.js} | 2 +- ...rc_ranui_select_index.md.BKakZMxv.lean.js} | 2 +- ...> src_ranui_skeleton_index.md.DuejSthu.js} | 2 +- ..._ranui_skeleton_index.md.DuejSthu.lean.js} | 2 +- ....js => src_ranui_tab_index.md.DFpJEDjU.js} | 2 +- ...> src_ranui_tab_index.md.DFpJEDjU.lean.js} | 2 +- ...js => src_ranui_tabs_index.md.BP5Dd9UX.js} | 2 +- ... src_ranui_tabs_index.md.BP5Dd9UX.lean.js} | 2 +- ...rc_ranuts_binaryTree_index.md.Bo5xKeFC.js} | 2 +- ...nuts_binaryTree_index.md.Bo5xKeFC.lean.js} | 2 +- ...> src_ranuts_bundler_index.md.CsAuaeoq.js} | 2 +- ..._ranuts_bundler_index.md.CsAuaeoq.lean.js} | 2 +- ...src_ranuts_file_appendFile.md.DN1hyzGA.js} | 2 +- ...anuts_file_appendFile.md.DN1hyzGA.lean.js} | 2 +- ...> src_ranuts_file_fileInfo.md.BTEg4x1A.js} | 2 +- ..._ranuts_file_fileInfo.md.BTEg4x1A.lean.js} | 2 +- ...=> src_ranuts_file_readDir.md.DfAKb-lm.js} | 2 +- ...c_ranuts_file_readDir.md.DfAKb-lm.lean.js} | 2 +- ...> src_ranuts_file_readFile.md.CdwZqNwc.js} | 2 +- ..._ranuts_file_readFile.md.CdwZqNwc.lean.js} | 2 +- ... src_ranuts_file_watchFile.md.2m1MF-uY.js} | 2 +- ...ranuts_file_watchFile.md.2m1MF-uY.lean.js} | 2 +- ... src_ranuts_file_writeFile.md.BBdQ8aK5.js} | 2 +- ...ranuts_file_writeFile.md.BBdQ8aK5.lean.js} | 2 +- ...91o.js => src_ranuts_index.md.CB2Cn65i.js} | 2 +- ...s => src_ranuts_index.md.CB2Cn65i.lean.js} | 2 +- ...c_ranuts_mimeType_mimeType.md.DSadqbmv.js} | 2 +- ...uts_mimeType_mimeType.md.DSadqbmv.lean.js} | 2 +- ... src_ranuts_mode_subscribe.md.CHshxehY.js} | 2 +- ...ranuts_mode_subscribe.md.CHshxehY.lean.js} | 2 +- ...utils_convertImageToBase64.md.B5TUIzAZ.js} | 2 +- ..._convertImageToBase64.md.B5TUIzAZ.lean.js} | 2 +- ...src_ranuts_utils_filterObj.md.Qc3cdyIl.js} | 2 +- ...anuts_utils_filterObj.md.Qc3cdyIl.lean.js} | 2 +- ...rc_ranuts_utils_formatJson.md.Baw5Xjrg.js} | 2 +- ...nuts_utils_formatJson.md.Baw5Xjrg.lean.js} | 2 +- ...src_ranuts_utils_getCookie.md.BNIeea85.js} | 2 +- ...anuts_utils_getCookie.md.BNIeea85.lean.js} | 2 +- ...js => src_ranuts_utils_ocr.md.CTguy2Qx.js} | 2 +- ... src_ranuts_utils_ocr.md.CTguy2Qx.lean.js} | 2 +- ...> src_ranuts_utils_str2xml.md.DnO7V1a3.js} | 2 +- ..._ranuts_utils_str2xml.md.DnO7V1a3.lean.js} | 2 +- ...s => src_ranuts_utils_task.md.BAX7uuWT.js} | 2 +- ...src_ranuts_utils_task.md.BAX7uuWT.lean.js} | 2 +- ...TS\347\261\273\345\236\213.md.CNyAaj8V.js" | 2 +- ...7\261\273\345\236\213.md.CNyAaj8V.lean.js" | 2 +- ...17\345\214\271\351\205\215.md.BM98mia7.js" | 2 +- ...5\214\271\351\205\215.md.BM98mia7.lean.js" | 2 +- ...13\350\277\220\347\256\227.md.BFtIIh3X.js" | 2 +- ...0\277\220\347\256\227.md.BFtIIh3X.lean.js" | 2 +- ...47\347\261\273\345\236\213.md.CJMDsdZH.js" | 2 +- ...7\261\273\345\236\213.md.CJMDsdZH.lean.js" | 2 +- ...{style.D7_Ytddv.css => style.E9dKQyFQ.css} | 2 +- cn/index.html | 18 +- cn/src/article/astParse/tokenizer.html | 20 +- cn/src/article/babel.html | 18 +- cn/src/article/bundle.html | 18 +- cn/src/article/designMode.html | 20 +- cn/src/article/docPreview.html | 20 +- cn/src/article/functionalProgramming.html | 20 +- cn/src/article/imagemin.html | 18 +- cn/src/article/javascript/domLoad.html | 20 +- cn/src/article/sort/bubble/index.html | 20 +- cn/src/article/sort/bucket/index.html | 20 +- cn/src/article/sort/count/index.html | 20 +- cn/src/article/sort/heap/index.html | 20 +- cn/src/article/sort/index.html | 18 +- cn/src/article/sort/insert/index.html | 20 +- cn/src/article/sort/merge/index.html | 20 +- cn/src/article/sort/quick/index.html | 20 +- cn/src/article/sort/radix/index.html | 20 +- cn/src/article/sort/select/index.html | 20 +- cn/src/article/sort/shell/index.html | 20 +- cn/src/article/systemDesign.html | 18 +- cn/src/article/typescript/calculate.html | 20 +- cn/src/article/typescript/index.html | 20 +- cn/src/article/typescript/pattern.html | 20 +- cn/src/article/typescript/reconstruction.html | 20 +- cn/src/article/typescript/recursion.html | 20 +- cn/src/article/typescript/unionType.html | 20 +- cn/src/article/video.html | 20 +- cn/src/article/visual.html | 20 +- cn/src/note/centos.html | 20 +- cn/src/note/docker.html | 20 +- cn/src/note/libreoffice2wasm.html | 20 +- cn/src/note/ubuntu.html | 20 +- cn/src/ranui/button/index.html | 20 +- cn/src/ranui/checkbox/index.html | 20 +- cn/src/ranui/icon/index.html | 20 +- cn/src/ranui/image/index.html | 18 +- cn/src/ranui/index.html | 20 +- cn/src/ranui/input/index.html | 20 +- cn/src/ranui/loading/index.html | 24 +- cn/src/ranui/math/index.html | 18 +- cn/src/ranui/message/index.html | 20 +- cn/src/ranui/modal/index.html | 18 +- cn/src/ranui/player/index.html | 18 +- cn/src/ranui/popover/index.html | 20 +- cn/src/ranui/preview/index.html | 20 +- cn/src/ranui/progress/index.html | 20 +- cn/src/ranui/radar/index.html | 20 +- cn/src/ranui/select/index.html | 20 +- cn/src/ranui/skeleton/index.html | 18 +- cn/src/ranui/tab/index.html | 20 +- cn/src/ranui/tabs/index.html | 20 +- cn/src/ranuts/binaryTree/index.html | 18 +- cn/src/ranuts/bundler/index.html | 20 +- cn/src/ranuts/file/appendFile.html | 18 +- cn/src/ranuts/file/fileInfo.html | 18 +- cn/src/ranuts/file/readDir.html | 18 +- cn/src/ranuts/file/readFile.html | 18 +- cn/src/ranuts/file/watchFile.html | 18 +- cn/src/ranuts/file/writeFile.html | 18 +- cn/src/ranuts/index.html | 18 +- cn/src/ranuts/mimeType/mimeType.html | 20 +- cn/src/ranuts/mode/subscribe.html | 20 +- cn/src/ranuts/utils/convertImageToBase64.html | 20 +- cn/src/ranuts/utils/filterObj.html | 20 +- cn/src/ranuts/utils/formatJson.html | 20 +- cn/src/ranuts/utils/getCookie.html | 20 +- cn/src/ranuts/utils/ocr.html | 20 +- cn/src/ranuts/utils/str2xml.html | 20 +- cn/src/ranuts/utils/task.html | 20 +- .../types/TS\347\261\273\345\236\213.html" | 20 +- ...\345\274\217\345\214\271\351\205\215.html" | 20 +- ...\345\236\213\350\277\220\347\256\227.html" | 20 +- ...\347\272\247\347\261\273\345\236\213.html" | 18 +- hashmap.json | 2 +- index.html | 18 +- pagefind/fragment/en_1d2a8f7.pf_fragment | Bin 1883 -> 0 bytes pagefind/fragment/en_2942c3c.pf_fragment | Bin 1037 -> 0 bytes pagefind/fragment/en_30709d8.pf_fragment | Bin 0 -> 1028 bytes pagefind/fragment/en_31bb7a6.pf_fragment | Bin 1230 -> 0 bytes pagefind/fragment/en_38d8359.pf_fragment | Bin 0 -> 357 bytes pagefind/fragment/en_3df5c5f.pf_fragment | Bin 0 -> 933 bytes ...811.pf_fragment => en_449b12a.pf_fragment} | Bin 6599 -> 6602 bytes pagefind/fragment/en_4873c44.pf_fragment | Bin 935 -> 0 bytes pagefind/fragment/en_5094588.pf_fragment | Bin 0 -> 1884 bytes pagefind/fragment/en_51f248e.pf_fragment | Bin 965 -> 0 bytes pagefind/fragment/en_5861ab4.pf_fragment | Bin 0 -> 751 bytes pagefind/fragment/en_5eef384.pf_fragment | Bin 0 -> 962 bytes pagefind/fragment/en_5f9a7eb.pf_fragment | Bin 714 -> 0 bytes pagefind/fragment/en_63cffab.pf_fragment | Bin 0 -> 1057 bytes pagefind/fragment/en_6a9915b.pf_fragment | Bin 0 -> 1227 bytes pagefind/fragment/en_7118fbe.pf_fragment | Bin 0 -> 718 bytes pagefind/fragment/en_75d5dcb.pf_fragment | Bin 1030 -> 0 bytes pagefind/fragment/en_7a4ca4f.pf_fragment | Bin 1158 -> 0 bytes pagefind/fragment/en_815cbc8.pf_fragment | Bin 0 -> 1034 bytes pagefind/fragment/en_a9c2374.pf_fragment | Bin 3133 -> 0 bytes pagefind/fragment/en_b110a5b.pf_fragment | Bin 0 -> 1155 bytes ...10c.pf_fragment => en_b24f7ef.pf_fragment} | Bin 1149 -> 1145 bytes pagefind/fragment/en_b7c8c16.pf_fragment | Bin 0 -> 3133 bytes ...17f.pf_fragment => en_c2412d4.pf_fragment} | Bin 1213 -> 1214 bytes pagefind/fragment/en_c84c5e7.pf_fragment | Bin 355 -> 0 bytes pagefind/fragment/en_c9c7c59.pf_fragment | Bin 1058 -> 0 bytes pagefind/fragment/en_d792b8c.pf_fragment | Bin 753 -> 0 bytes ...5aa.pf_fragment => en_ee9f170.pf_fragment} | Bin 27389 -> 27391 bytes ....pf_fragment => zh-cn_0ea6667.pf_fragment} | Bin 3609 -> 3610 bytes pagefind/fragment/zh-cn_154849c.pf_fragment | Bin 0 -> 797 bytes ....pf_fragment => zh-cn_27c99c4.pf_fragment} | Bin 1537 -> 1538 bytes pagefind/fragment/zh-cn_2ab4b75.pf_fragment | Bin 796 -> 0 bytes pagefind/fragment/zh-cn_2c21dbd.pf_fragment | Bin 0 -> 1179 bytes pagefind/fragment/zh-cn_2e8f3b4.pf_fragment | Bin 1261 -> 0 bytes ....pf_fragment => zh-cn_39da2fe.pf_fragment} | Bin 11147 -> 11147 bytes pagefind/fragment/zh-cn_3aa282b.pf_fragment | Bin 982 -> 0 bytes pagefind/fragment/zh-cn_51bdb63.pf_fragment | Bin 0 -> 983 bytes pagefind/fragment/zh-cn_5584627.pf_fragment | Bin 0 -> 1439 bytes ....pf_fragment => zh-cn_565fd27.pf_fragment} | Bin 7424 -> 7428 bytes pagefind/fragment/zh-cn_592cc95.pf_fragment | Bin 1438 -> 0 bytes pagefind/fragment/zh-cn_5ab33e7.pf_fragment | Bin 0 -> 1230 bytes pagefind/fragment/zh-cn_5b71249.pf_fragment | Bin 1443 -> 0 bytes pagefind/fragment/zh-cn_68b3659.pf_fragment | Bin 0 -> 403 bytes ....pf_fragment => zh-cn_6df03b5.pf_fragment} | Bin 31669 -> 31673 bytes pagefind/fragment/zh-cn_8338621.pf_fragment | Bin 1179 -> 0 bytes pagefind/fragment/zh-cn_8998463.pf_fragment | Bin 0 -> 1444 bytes pagefind/fragment/zh-cn_8d53abb.pf_fragment | Bin 401 -> 0 bytes pagefind/fragment/zh-cn_9879172.pf_fragment | Bin 0 -> 1261 bytes ....pf_fragment => zh-cn_c5d845d.pf_fragment} | Bin 1319 -> 1320 bytes pagefind/fragment/zh-cn_d388141.pf_fragment | Bin 0 -> 1410 bytes ....pf_fragment => zh-cn_e6dde39.pf_fragment} | Bin 16317 -> 16319 bytes ....pf_fragment => zh-cn_e831ca8.pf_fragment} | Bin 2116 -> 2117 bytes pagefind/fragment/zh-cn_edddd73.pf_fragment | Bin 1229 -> 0 bytes pagefind/fragment/zh-cn_ee19938.pf_fragment | Bin 1409 -> 0 bytes ....pf_fragment => zh-cn_f2527de.pf_fragment} | Bin 1476 -> 1478 bytes pagefind/index/en_318ec34.pf_index | Bin 0 -> 59453 bytes pagefind/index/en_396d347.pf_index | Bin 0 -> 43925 bytes pagefind/index/en_58c6189.pf_index | Bin 0 -> 45040 bytes pagefind/index/en_bc39585.pf_index | Bin 59297 -> 0 bytes pagefind/index/en_d22f299.pf_index | Bin 44888 -> 0 bytes pagefind/index/en_e8e8597.pf_index | Bin 43780 -> 0 bytes pagefind/index/zh-cn_16af6ef.pf_index | Bin 0 -> 41860 bytes pagefind/index/zh-cn_181dded.pf_index | Bin 0 -> 43206 bytes pagefind/index/zh-cn_4f900ab.pf_index | Bin 0 -> 42299 bytes pagefind/index/zh-cn_5d1d145.pf_index | Bin 0 -> 32341 bytes pagefind/index/zh-cn_64ecbb3.pf_index | Bin 41225 -> 0 bytes pagefind/index/zh-cn_88a2748.pf_index | Bin 41698 -> 0 bytes pagefind/index/zh-cn_8d4814d.pf_index | Bin 43091 -> 0 bytes pagefind/index/zh-cn_933a426.pf_index | Bin 32228 -> 0 bytes pagefind/index/zh-cn_9bacfc2.pf_index | Bin 42128 -> 0 bytes pagefind/index/zh-cn_bb272b7.pf_index | Bin 0 -> 41402 bytes pagefind/pagefind-entry.json | 2 +- pagefind/pagefind.en_4e5413cee9.pf_meta | Bin 0 -> 596 bytes pagefind/pagefind.en_5eb6d54e34.pf_meta | Bin 600 -> 0 bytes pagefind/pagefind.zh-cn_25295ac6fc508.pf_meta | Bin 754 -> 0 bytes pagefind/pagefind.zh-cn_94eef15fae60c.pf_meta | Bin 0 -> 740 bytes src/article/astParse/tokenizer.html | 20 +- src/article/babel.html | 18 +- src/article/bundle.html | 18 +- src/article/designMode.html | 20 +- src/article/functionalProgramming.html | 20 +- src/article/imagemin.html | 18 +- src/article/javascript/domLoad.html | 20 +- src/article/sort/bubble/index.html | 20 +- src/article/sort/bucket/index.html | 20 +- src/article/sort/count/index.html | 20 +- src/article/sort/heap/index.html | 20 +- src/article/sort/index.html | 18 +- src/article/sort/insert/index.html | 20 +- src/article/sort/merge/index.html | 20 +- src/article/sort/quick/index.html | 20 +- src/article/sort/radix/index.html | 20 +- src/article/sort/select/index.html | 20 +- src/article/sort/shell/index.html | 20 +- src/article/typescript/calculate.html | 20 +- src/article/typescript/index.html | 20 +- src/article/typescript/pattern.html | 20 +- src/article/typescript/reconstruction.html | 20 +- src/article/typescript/recursion.html | 20 +- src/article/typescript/unionType.html | 20 +- src/ranui/button/index.html | 20 +- src/ranui/checkbox/index.html | 20 +- src/ranui/icon/index.html | 20 +- src/ranui/image/index.html | 18 +- src/ranui/index.html | 20 +- src/ranui/input/index.html | 20 +- src/ranui/loading/index.html | 24 +- src/ranui/math/index.html | 18 +- src/ranui/message/index.html | 20 +- src/ranui/modal/index.html | 18 +- src/ranui/player/index.html | 18 +- src/ranui/popover/index.html | 20 +- src/ranui/preview/index.html | 20 +- src/ranui/progress/index.html | 20 +- src/ranui/radar/index.html | 20 +- src/ranui/select/index.html | 20 +- src/ranui/skeleton/index.html | 18 +- src/ranui/tab/index.html | 20 +- src/ranui/tabs/index.html | 20 +- src/ranuts/binaryTree/index.html | 18 +- src/ranuts/bundler/index.html | 20 +- src/ranuts/file/appendFile.html | 18 +- src/ranuts/file/fileInfo.html | 18 +- src/ranuts/file/readDir.html | 18 +- src/ranuts/file/readFile.html | 18 +- src/ranuts/file/watchFile.html | 18 +- src/ranuts/file/writeFile.html | 18 +- src/ranuts/index.html | 18 +- src/ranuts/mimeType/mimeType.html | 20 +- src/ranuts/mode/subscribe.html | 20 +- src/ranuts/utils/convertImageToBase64.html | 20 +- src/ranuts/utils/filterObj.html | 20 +- src/ranuts/utils/formatJson.html | 20 +- src/ranuts/utils/getCookie.html | 20 +- src/ranuts/utils/ocr.html | 20 +- src/ranuts/utils/str2xml.html | 20 +- src/ranuts/utils/task.html | 20 +- "src/types/TS\347\261\273\345\236\213.html" | 20 +- ...\345\274\217\345\214\271\351\205\215.html" | 20 +- ...\345\236\213\350\277\220\347\256\227.html" | 20 +- ...\347\272\247\347\261\273\345\236\213.html" | 18 +- sw1728206030.js => sw1728703195.js | 1406 ++++++++--------- 512 files changed, 2441 insertions(+), 2441 deletions(-) rename assets/{app.Bz9dt6dC.js => app.CfJxT4ml.js} (90%) create mode 100644 assets/chunks/framework.CHSXtLMd.js delete mode 100644 assets/chunks/framework.eq-HTtE3.js rename assets/chunks/{index-Ba501-HG.DLGTjfcz.js => index-Ba501-HG.BBoApf2J.js} (99%) rename assets/chunks/{index-Co9E57uv.DM_Nu_-Q.js => index-Co9E57uv.BtZPXcWW.js} (99%) rename assets/chunks/{index.CafPLwUV.js => index.MWfHGcqb.js} (99%) rename assets/chunks/{loading.vue_vue_type_style_index_0_lang.Byf79MII.js => loading.vue_vue_type_style_index_0_lang.gqANFo1t.js} (84%) rename assets/chunks/{pdf-Cx0VWKFo.CmQSFM5C.js => pdf-Cx0VWKFo.BKCfi8kk.js} (99%) create mode 100644 assets/chunks/pwa-install.es.DI7OvJx5.js delete mode 100644 assets/chunks/pwa-install.es.DuMXkPrI.js create mode 100644 assets/chunks/theme.B08u4faT.js delete mode 100644 assets/chunks/theme.FPvZ3Ede.js rename assets/{cn_index.md.2fj_5uQF.js => cn_index.md.0kzgXyFr.js} (87%) rename assets/{cn_index.md.2fj_5uQF.lean.js => cn_index.md.0kzgXyFr.lean.js} (87%) rename assets/{cn_src_article_astParse_tokenizer.md.C-WQQige.js => cn_src_article_astParse_tokenizer.md.Be5lTQKA.js} (99%) rename assets/{cn_src_article_astParse_tokenizer.md.C-WQQige.lean.js => cn_src_article_astParse_tokenizer.md.Be5lTQKA.lean.js} (99%) rename assets/{cn_src_article_babel.md.xL16z9Xt.js => cn_src_article_babel.md.rAspsh5G.js} (82%) rename assets/{cn_src_article_babel.md.xL16z9Xt.lean.js => cn_src_article_babel.md.rAspsh5G.lean.js} (82%) rename assets/{cn_src_article_bundle.md.DBdY72dw.js => cn_src_article_bundle.md.65R3DvSm.js} (88%) rename assets/{cn_src_article_bundle.md.DBdY72dw.lean.js => cn_src_article_bundle.md.65R3DvSm.lean.js} (88%) rename assets/{cn_src_article_designMode.md.BtsBYMyP.js => cn_src_article_designMode.md.BqNiAb_Y.js} (99%) rename assets/{cn_src_article_designMode.md.BtsBYMyP.lean.js => cn_src_article_designMode.md.BqNiAb_Y.lean.js} (99%) rename assets/{cn_src_article_docPreview.md.M0JJQDka.js => cn_src_article_docPreview.md.BRrDrIEF.js} (99%) rename assets/{cn_src_article_docPreview.md.M0JJQDka.lean.js => cn_src_article_docPreview.md.BRrDrIEF.lean.js} (99%) rename assets/{cn_src_article_functionalProgramming.md.DlSKPz3z.js => cn_src_article_functionalProgramming.md.QqkRa617.js} (99%) rename assets/{cn_src_article_functionalProgramming.md.DlSKPz3z.lean.js => cn_src_article_functionalProgramming.md.QqkRa617.lean.js} (99%) rename assets/{cn_src_article_imagemin.md.BVBSzSq_.js => cn_src_article_imagemin.md.BD51FgwZ.js} (82%) rename assets/{cn_src_article_imagemin.md.BVBSzSq_.lean.js => cn_src_article_imagemin.md.BD51FgwZ.lean.js} (82%) rename assets/{cn_src_article_javascript_domLoad.md.f9CTuyiF.js => cn_src_article_javascript_domLoad.md.ePyh9ZRf.js} (93%) rename assets/{cn_src_article_javascript_domLoad.md.f9CTuyiF.lean.js => cn_src_article_javascript_domLoad.md.ePyh9ZRf.lean.js} (93%) rename assets/{cn_src_article_sort_bubble_index.md.CpVYyZep.js => cn_src_article_sort_bubble_index.md.DhzOSuoL.js} (98%) rename assets/{cn_src_article_sort_bubble_index.md.CpVYyZep.lean.js => cn_src_article_sort_bubble_index.md.DhzOSuoL.lean.js} (98%) rename assets/{cn_src_article_sort_bucket_index.md.LaYyZzsR.js => cn_src_article_sort_bucket_index.md.iKnXhO5A.js} (99%) rename assets/{cn_src_article_sort_bucket_index.md.LaYyZzsR.lean.js => cn_src_article_sort_bucket_index.md.iKnXhO5A.lean.js} (99%) rename assets/{cn_src_article_sort_count_index.md.NZRFyarg.js => cn_src_article_sort_count_index.md.Cl7iYY9W.js} (99%) rename assets/{cn_src_article_sort_count_index.md.NZRFyarg.lean.js => cn_src_article_sort_count_index.md.Cl7iYY9W.lean.js} (99%) rename assets/{cn_src_article_sort_heap_index.md.CkwR8CzF.js => cn_src_article_sort_heap_index.md.mL6leDCa.js} (99%) rename assets/{cn_src_article_sort_heap_index.md.CkwR8CzF.lean.js => cn_src_article_sort_heap_index.md.mL6leDCa.lean.js} (99%) rename assets/{cn_src_article_sort_index.md.BbPWuLn7.js => cn_src_article_sort_index.md.08d3P1kH.js} (93%) rename assets/{cn_src_article_sort_index.md.BbPWuLn7.lean.js => cn_src_article_sort_index.md.08d3P1kH.lean.js} (93%) rename assets/{cn_src_article_sort_insert_index.md.eohhlC_9.js => cn_src_article_sort_insert_index.md.C6siGqvF.js} (98%) rename assets/{cn_src_article_sort_insert_index.md.eohhlC_9.lean.js => cn_src_article_sort_insert_index.md.C6siGqvF.lean.js} (98%) rename assets/{cn_src_article_sort_merge_index.md.BCheUYDq.js => cn_src_article_sort_merge_index.md.DHgqFsQk.js} (99%) rename assets/{cn_src_article_sort_merge_index.md.BCheUYDq.lean.js => cn_src_article_sort_merge_index.md.DHgqFsQk.lean.js} (99%) rename assets/{cn_src_article_sort_quick_index.md.BlvODCUG.js => cn_src_article_sort_quick_index.md.nZxAppd6.js} (99%) rename assets/{cn_src_article_sort_quick_index.md.BlvODCUG.lean.js => cn_src_article_sort_quick_index.md.nZxAppd6.lean.js} (99%) rename assets/{cn_src_article_sort_radix_index.md.BpfTWeN-.js => cn_src_article_sort_radix_index.md.WNmlYeAN.js} (99%) rename assets/{cn_src_article_sort_radix_index.md.BpfTWeN-.lean.js => cn_src_article_sort_radix_index.md.WNmlYeAN.lean.js} (99%) rename assets/{cn_src_article_sort_select_index.md.DDSMK22b.js => cn_src_article_sort_select_index.md.gIQln0jl.js} (98%) rename assets/{cn_src_article_sort_select_index.md.DDSMK22b.lean.js => cn_src_article_sort_select_index.md.gIQln0jl.lean.js} (98%) rename assets/{cn_src_article_sort_shell_index.md.CH3b01-9.js => cn_src_article_sort_shell_index.md.DBoMnfgs.js} (98%) rename assets/{cn_src_article_sort_shell_index.md.CH3b01-9.lean.js => cn_src_article_sort_shell_index.md.DBoMnfgs.lean.js} (98%) rename assets/{cn_src_article_systemDesign.md.09pIylq7.js => cn_src_article_systemDesign.md.BS7WrgOy.js} (93%) rename assets/{cn_src_article_systemDesign.md.09pIylq7.lean.js => cn_src_article_systemDesign.md.BS7WrgOy.lean.js} (93%) rename assets/{cn_src_article_typescript_calculate.md.DE1WitAK.js => cn_src_article_typescript_calculate.md.CDNPBSOv.js} (99%) rename assets/{cn_src_article_typescript_calculate.md.DE1WitAK.lean.js => cn_src_article_typescript_calculate.md.CDNPBSOv.lean.js} (99%) rename assets/{cn_src_article_typescript_index.md.DyT8Zi-G.js => cn_src_article_typescript_index.md.xhcQzYKG.js} (99%) rename assets/{cn_src_article_typescript_index.md.DyT8Zi-G.lean.js => cn_src_article_typescript_index.md.xhcQzYKG.lean.js} (99%) rename assets/{cn_src_article_typescript_pattern.md.9O2AZ8pn.js => cn_src_article_typescript_pattern.md.Dmc8v8qK.js} (99%) rename assets/{cn_src_article_typescript_pattern.md.9O2AZ8pn.lean.js => cn_src_article_typescript_pattern.md.Dmc8v8qK.lean.js} (99%) rename assets/{cn_src_article_typescript_reconstruction.md.CQvppcmc.js => cn_src_article_typescript_reconstruction.md.y0pME8dQ.js} (99%) rename assets/{cn_src_article_typescript_reconstruction.md.CQvppcmc.lean.js => cn_src_article_typescript_reconstruction.md.y0pME8dQ.lean.js} (99%) rename assets/{cn_src_article_typescript_recursion.md.CM_teb7b.js => cn_src_article_typescript_recursion.md.Cbh8DOxI.js} (99%) rename assets/{cn_src_article_typescript_recursion.md.CM_teb7b.lean.js => cn_src_article_typescript_recursion.md.Cbh8DOxI.lean.js} (99%) rename assets/{cn_src_article_typescript_unionType.md.sgwIQe9O.js => cn_src_article_typescript_unionType.md.DSQmi5Tg.js} (99%) rename assets/{cn_src_article_typescript_unionType.md.sgwIQe9O.lean.js => cn_src_article_typescript_unionType.md.DSQmi5Tg.lean.js} (99%) rename assets/{cn_src_article_video.md.B93QLRnX.js => cn_src_article_video.md.BHOJcjlO.js} (99%) rename assets/{cn_src_article_video.md.B93QLRnX.lean.js => cn_src_article_video.md.BHOJcjlO.lean.js} (99%) rename assets/{cn_src_article_visual.md.B3gz4QSG.js => cn_src_article_visual.md.DqgBm0SZ.js} (99%) rename assets/{cn_src_article_visual.md.B3gz4QSG.lean.js => cn_src_article_visual.md.DqgBm0SZ.lean.js} (99%) rename assets/{cn_src_note_centos.md.CU-schbT.js => cn_src_note_centos.md.Dd37Ex5S.js} (97%) rename assets/{cn_src_note_centos.md.CU-schbT.lean.js => cn_src_note_centos.md.Dd37Ex5S.lean.js} (97%) rename assets/{cn_src_note_docker.md.MMD7sGKQ.js => cn_src_note_docker.md.DBlFO17f.js} (99%) rename assets/{cn_src_note_docker.md.MMD7sGKQ.lean.js => cn_src_note_docker.md.DBlFO17f.lean.js} (99%) rename assets/{cn_src_note_libreoffice2wasm.md.Cz5uvgFp.js => cn_src_note_libreoffice2wasm.md.DQRPQED0.js} (99%) rename assets/{cn_src_note_libreoffice2wasm.md.Cz5uvgFp.lean.js => cn_src_note_libreoffice2wasm.md.DQRPQED0.lean.js} (99%) rename assets/{cn_src_note_ubuntu.md.BewNf33t.js => cn_src_note_ubuntu.md.OMrqGjGg.js} (95%) rename assets/{cn_src_note_ubuntu.md.BewNf33t.lean.js => cn_src_note_ubuntu.md.OMrqGjGg.lean.js} (95%) rename assets/{cn_src_ranui_button_index.md.BTsF5_xn.js => cn_src_ranui_button_index.md.BDcjlPmF.js} (99%) rename assets/{cn_src_ranui_button_index.md.BTsF5_xn.lean.js => cn_src_ranui_button_index.md.BDcjlPmF.lean.js} (99%) rename assets/{cn_src_ranui_checkbox_index.md.64tQAHz0.js => cn_src_ranui_checkbox_index.md.BYpHGGn8.js} (98%) rename assets/{cn_src_ranui_checkbox_index.md.64tQAHz0.lean.js => cn_src_ranui_checkbox_index.md.BYpHGGn8.lean.js} (98%) rename assets/{cn_src_ranui_icon_index.md.Bryk074c.js => cn_src_ranui_icon_index.md.B1V9PRxj.js} (99%) rename assets/{cn_src_ranui_icon_index.md.Bryk074c.lean.js => cn_src_ranui_icon_index.md.B1V9PRxj.lean.js} (99%) rename assets/{cn_src_ranui_image_index.md.DPIPyUFH.js => cn_src_ranui_image_index.md.5jpZJsQ-.js} (97%) rename assets/{cn_src_ranui_image_index.md.DPIPyUFH.lean.js => cn_src_ranui_image_index.md.5jpZJsQ-.lean.js} (97%) rename assets/{cn_src_ranui_index.md.C6TkvKZ5.js => cn_src_ranui_index.md.O6NeSIto.js} (99%) rename assets/{cn_src_ranui_index.md.C6TkvKZ5.lean.js => cn_src_ranui_index.md.O6NeSIto.lean.js} (99%) rename assets/{cn_src_ranui_input_index.md.C_uTd0oA.js => cn_src_ranui_input_index.md.N5yg7is0.js} (99%) rename assets/{cn_src_ranui_input_index.md.C_uTd0oA.lean.js => cn_src_ranui_input_index.md.N5yg7is0.lean.js} (99%) rename assets/{cn_src_ranui_loading_index.md.g5IL69Vn.js => cn_src_ranui_loading_index.md.D4K746FX.js} (95%) rename assets/{cn_src_ranui_loading_index.md.g5IL69Vn.lean.js => cn_src_ranui_loading_index.md.D4K746FX.lean.js} (95%) rename assets/{cn_src_ranui_math_index.md.CjCDE9Oj.js => cn_src_ranui_math_index.md.CIJlviae.js} (95%) rename assets/{cn_src_ranui_math_index.md.CjCDE9Oj.lean.js => cn_src_ranui_math_index.md.CIJlviae.lean.js} (95%) rename assets/{cn_src_ranui_message_index.md.Dl1UUk4M.js => cn_src_ranui_message_index.md.wVjYP45A.js} (98%) rename assets/{cn_src_ranui_message_index.md.Dl1UUk4M.lean.js => cn_src_ranui_message_index.md.wVjYP45A.lean.js} (98%) rename assets/{cn_src_ranui_modal_index.md.ROhgbVya.js => cn_src_ranui_modal_index.md.BuDHHn2M.js} (68%) rename assets/{cn_src_ranui_modal_index.md.ROhgbVya.lean.js => cn_src_ranui_modal_index.md.BuDHHn2M.lean.js} (68%) rename assets/{cn_src_ranui_player_index.md.C5_Slj29.js => cn_src_ranui_player_index.md.qcI6qb8P.js} (97%) rename assets/{cn_src_ranui_player_index.md.C5_Slj29.lean.js => cn_src_ranui_player_index.md.qcI6qb8P.lean.js} (97%) rename assets/{cn_src_ranui_popover_index.md.BZnwkTfa.js => cn_src_ranui_popover_index.md.BYbffMAB.js} (99%) rename assets/{cn_src_ranui_popover_index.md.BZnwkTfa.lean.js => cn_src_ranui_popover_index.md.BYbffMAB.lean.js} (99%) rename assets/{cn_src_ranui_preview_index.md.D8PW9V7b.js => cn_src_ranui_preview_index.md.CyAUjykp.js} (98%) rename assets/{cn_src_ranui_preview_index.md.D8PW9V7b.lean.js => cn_src_ranui_preview_index.md.CyAUjykp.lean.js} (98%) rename assets/{cn_src_ranui_progress_index.md.B-SPlDpn.js => cn_src_ranui_progress_index.md.B5qyrqdM.js} (99%) rename assets/{cn_src_ranui_progress_index.md.B-SPlDpn.lean.js => cn_src_ranui_progress_index.md.B5qyrqdM.lean.js} (99%) rename assets/{cn_src_ranui_radar_index.md.BVW8avVs.js => cn_src_ranui_radar_index.md.CdnZK7Pb.js} (99%) rename assets/{cn_src_ranui_radar_index.md.BVW8avVs.lean.js => cn_src_ranui_radar_index.md.CdnZK7Pb.lean.js} (99%) rename assets/{cn_src_ranui_select_index.md.DTgZFp_f.js => cn_src_ranui_select_index.md.DaJPr9cC.js} (99%) rename assets/{cn_src_ranui_select_index.md.DTgZFp_f.lean.js => cn_src_ranui_select_index.md.DaJPr9cC.lean.js} (99%) rename assets/{cn_src_ranui_skeleton_index.md.Bo8P6it2.js => cn_src_ranui_skeleton_index.md.CFMGgnwG.js} (89%) rename assets/{cn_src_ranui_skeleton_index.md.Bo8P6it2.lean.js => cn_src_ranui_skeleton_index.md.CFMGgnwG.lean.js} (89%) rename assets/{cn_src_ranui_tab_index.md.CK7MDF2U.js => cn_src_ranui_tab_index.md.CY1b1u1V.js} (99%) rename assets/{cn_src_ranui_tab_index.md.CK7MDF2U.lean.js => cn_src_ranui_tab_index.md.CY1b1u1V.lean.js} (99%) rename assets/{cn_src_ranui_tabs_index.md.BUakYUQI.js => cn_src_ranui_tabs_index.md.CpWMVttn.js} (99%) rename assets/{cn_src_ranui_tabs_index.md.BUakYUQI.lean.js => cn_src_ranui_tabs_index.md.CpWMVttn.lean.js} (99%) rename assets/{cn_src_ranuts_binaryTree_index.md.IdNAat6o.js => cn_src_ranuts_binaryTree_index.md.Cv4oga8R.js} (98%) rename assets/{cn_src_ranuts_binaryTree_index.md.IdNAat6o.lean.js => cn_src_ranuts_binaryTree_index.md.Cv4oga8R.lean.js} (98%) rename assets/{cn_src_ranuts_bundler_index.md.BYnXw-1l.js => cn_src_ranuts_bundler_index.md.alHSjuA6.js} (88%) rename assets/{cn_src_ranuts_bundler_index.md.BYnXw-1l.lean.js => cn_src_ranuts_bundler_index.md.alHSjuA6.lean.js} (88%) rename assets/{cn_src_ranuts_file_appendFile.md.K8GN9NYw.js => cn_src_ranuts_file_appendFile.md.B1djr2WE.js} (90%) rename assets/{cn_src_ranuts_file_appendFile.md.K8GN9NYw.lean.js => cn_src_ranuts_file_appendFile.md.B1djr2WE.lean.js} (90%) rename assets/{cn_src_ranuts_file_fileInfo.md.DMvZ6n_5.js => cn_src_ranuts_file_fileInfo.md.QR_sWfs6.js} (90%) rename assets/{cn_src_ranuts_file_fileInfo.md.DMvZ6n_5.lean.js => cn_src_ranuts_file_fileInfo.md.QR_sWfs6.lean.js} (90%) rename assets/{cn_src_ranuts_file_readDir.md.DoILvF6h.js => cn_src_ranuts_file_readDir.md.DFB7FVlj.js} (93%) rename assets/{cn_src_ranuts_file_readDir.md.DoILvF6h.lean.js => cn_src_ranuts_file_readDir.md.DFB7FVlj.lean.js} (93%) rename assets/{cn_src_ranuts_file_readFile.md.JXaeq4Af.js => cn_src_ranuts_file_readFile.md.B89kbS8J.js} (89%) rename assets/{cn_src_ranuts_file_readFile.md.JXaeq4Af.lean.js => cn_src_ranuts_file_readFile.md.B89kbS8J.lean.js} (89%) rename assets/{cn_src_ranuts_file_watchFile.md.BJ0t93Mv.js => cn_src_ranuts_file_watchFile.md.BAjI-OaD.js} (88%) rename assets/{cn_src_ranuts_file_watchFile.md.BJ0t93Mv.lean.js => cn_src_ranuts_file_watchFile.md.BAjI-OaD.lean.js} (88%) rename assets/{cn_src_ranuts_file_writeFile.md.CMe-VzGw.js => cn_src_ranuts_file_writeFile.md.DWkSsJv9.js} (89%) rename assets/{cn_src_ranuts_file_writeFile.md.CMe-VzGw.lean.js => cn_src_ranuts_file_writeFile.md.DWkSsJv9.lean.js} (89%) rename assets/{cn_src_ranuts_index.md.0mHndMC0.js => cn_src_ranuts_index.md.BA8cILpe.js} (94%) rename assets/{cn_src_ranuts_index.md.0mHndMC0.lean.js => cn_src_ranuts_index.md.BA8cILpe.lean.js} (94%) rename assets/{cn_src_ranuts_mimeType_mimeType.md.BZYF7luN.js => cn_src_ranuts_mimeType_mimeType.md.CmQXZWG3.js} (95%) rename assets/{cn_src_ranuts_mimeType_mimeType.md.BZYF7luN.lean.js => cn_src_ranuts_mimeType_mimeType.md.CmQXZWG3.lean.js} (95%) rename assets/{cn_src_ranuts_mode_subscribe.md.wq3k5Yjy.js => cn_src_ranuts_mode_subscribe.md.NMm6FNO3.js} (98%) rename assets/{cn_src_ranuts_mode_subscribe.md.wq3k5Yjy.lean.js => cn_src_ranuts_mode_subscribe.md.NMm6FNO3.lean.js} (98%) rename assets/{cn_src_ranuts_utils_convertImageToBase64.md.DGSoctCe.js => cn_src_ranuts_utils_convertImageToBase64.md.CQ_RoAmb.js} (94%) rename assets/{cn_src_ranuts_utils_convertImageToBase64.md.DGSoctCe.lean.js => cn_src_ranuts_utils_convertImageToBase64.md.CQ_RoAmb.lean.js} (94%) rename assets/{cn_src_ranuts_utils_filterObj.md.YgICEvQ2.js => cn_src_ranuts_utils_filterObj.md.BqJRLgq8.js} (95%) rename assets/{cn_src_ranuts_utils_filterObj.md.YgICEvQ2.lean.js => cn_src_ranuts_utils_filterObj.md.BqJRLgq8.lean.js} (95%) rename assets/{cn_src_ranuts_utils_formatJson.md.BDAAwEzn.js => cn_src_ranuts_utils_formatJson.md.Bh24FNd_.js} (95%) rename assets/{cn_src_ranuts_utils_formatJson.md.BDAAwEzn.lean.js => cn_src_ranuts_utils_formatJson.md.Bh24FNd_.lean.js} (95%) rename assets/{cn_src_ranuts_utils_getCookie.md.DDH9qH__.js => cn_src_ranuts_utils_getCookie.md.DxXBdlVr.js} (94%) rename assets/{cn_src_ranuts_utils_getCookie.md.DDH9qH__.lean.js => cn_src_ranuts_utils_getCookie.md.DxXBdlVr.lean.js} (94%) rename assets/{cn_src_ranuts_utils_ocr.md.Dypkbs3Z.js => cn_src_ranuts_utils_ocr.md.B4yUe53w.js} (98%) rename assets/{cn_src_ranuts_utils_ocr.md.Dypkbs3Z.lean.js => cn_src_ranuts_utils_ocr.md.B4yUe53w.lean.js} (98%) rename assets/{cn_src_ranuts_utils_str2xml.md.eRlIqRbm.js => cn_src_ranuts_utils_str2xml.md.BaFKZ-2M.js} (96%) rename assets/{cn_src_ranuts_utils_str2xml.md.eRlIqRbm.lean.js => cn_src_ranuts_utils_str2xml.md.BaFKZ-2M.lean.js} (96%) rename assets/{cn_src_ranuts_utils_task.md.CqL7840a.js => cn_src_ranuts_utils_task.md.CDbscsJ2.js} (97%) rename assets/{cn_src_ranuts_utils_task.md.CqL7840a.lean.js => cn_src_ranuts_utils_task.md.CDbscsJ2.lean.js} (97%) rename "assets/cn_src_types_TS\347\261\273\345\236\213.md.SadT65z1.js" => "assets/cn_src_types_TS\347\261\273\345\236\213.md.8-URD2RM.js" (99%) rename "assets/cn_src_types_TS\347\261\273\345\236\213.md.SadT65z1.lean.js" => "assets/cn_src_types_TS\347\261\273\345\236\213.md.8-URD2RM.lean.js" (99%) rename "assets/cn_src_types_\346\250\241\345\274\217\345\214\271\351\205\215.md.D84CR-S3.js" => "assets/cn_src_types_\346\250\241\345\274\217\345\214\271\351\205\215.md.-Hg913qX.js" (99%) rename "assets/cn_src_types_\346\250\241\345\274\217\345\214\271\351\205\215.md.D84CR-S3.lean.js" => "assets/cn_src_types_\346\250\241\345\274\217\345\214\271\351\205\215.md.-Hg913qX.lean.js" (99%) rename "assets/cn_src_types_\347\261\273\345\236\213\350\277\220\347\256\227.md.tyGWinyV.js" => "assets/cn_src_types_\347\261\273\345\236\213\350\277\220\347\256\227.md.DPzhEpck.js" (99%) rename "assets/cn_src_types_\347\261\273\345\236\213\350\277\220\347\256\227.md.tyGWinyV.lean.js" => "assets/cn_src_types_\347\261\273\345\236\213\350\277\220\347\256\227.md.DPzhEpck.lean.js" (99%) rename "assets/cn_src_types_\351\253\230\347\272\247\347\261\273\345\236\213.md.CB6Aa-fQ.js" => "assets/cn_src_types_\351\253\230\347\272\247\347\261\273\345\236\213.md.BQ0iDGrX.js" (96%) rename "assets/cn_src_types_\351\253\230\347\272\247\347\261\273\345\236\213.md.CB6Aa-fQ.lean.js" => "assets/cn_src_types_\351\253\230\347\272\247\347\261\273\345\236\213.md.BQ0iDGrX.lean.js" (96%) rename assets/{index.md.BZLM9Chw.js => index.md.DJiM3g0O.js} (87%) rename assets/{index.md.BZLM9Chw.lean.js => index.md.DJiM3g0O.lean.js} (87%) rename assets/{src_article_astParse_tokenizer.md.Car-pAMT.js => src_article_astParse_tokenizer.md.CJgdOmtY.js} (99%) rename assets/{src_article_astParse_tokenizer.md.Car-pAMT.lean.js => src_article_astParse_tokenizer.md.CJgdOmtY.lean.js} (99%) rename assets/{src_article_babel.md.xaxyHusU.js => src_article_babel.md.CA-cRcF6.js} (87%) rename assets/{src_article_babel.md.xaxyHusU.lean.js => src_article_babel.md.CA-cRcF6.lean.js} (87%) rename assets/{src_article_bundle.md.BJTDBmRN.js => src_article_bundle.md.pJHPU684.js} (87%) rename assets/{src_article_bundle.md.BJTDBmRN.lean.js => src_article_bundle.md.pJHPU684.lean.js} (87%) rename assets/{src_article_designMode.md.BVyuKZfy.js => src_article_designMode.md.CQjOH8Aq.js} (99%) rename assets/{src_article_designMode.md.BVyuKZfy.lean.js => src_article_designMode.md.CQjOH8Aq.lean.js} (99%) rename assets/{src_article_functionalProgramming.md.CVkTjNep.js => src_article_functionalProgramming.md.Cmp2qFRI.js} (99%) rename assets/{src_article_functionalProgramming.md.CVkTjNep.lean.js => src_article_functionalProgramming.md.Cmp2qFRI.lean.js} (99%) rename assets/{src_article_imagemin.md.Ck9ficKK.js => src_article_imagemin.md.C47x7cUg.js} (82%) rename assets/{src_article_imagemin.md.Ck9ficKK.lean.js => src_article_imagemin.md.C47x7cUg.lean.js} (82%) rename assets/{src_article_javascript_domLoad.md.Jm-CCFhD.js => src_article_javascript_domLoad.md.E9g_n3_p.js} (93%) rename assets/{src_article_javascript_domLoad.md.Jm-CCFhD.lean.js => src_article_javascript_domLoad.md.E9g_n3_p.lean.js} (93%) rename assets/{src_article_sort_bubble_index.md.DfD0B21f.js => src_article_sort_bubble_index.md.Uyukvvj_.js} (98%) rename assets/{src_article_sort_bubble_index.md.DfD0B21f.lean.js => src_article_sort_bubble_index.md.Uyukvvj_.lean.js} (98%) rename assets/{src_article_sort_bucket_index.md.r1f6mQDV.js => src_article_sort_bucket_index.md.qqF6Sj4P.js} (99%) rename assets/{src_article_sort_bucket_index.md.r1f6mQDV.lean.js => src_article_sort_bucket_index.md.qqF6Sj4P.lean.js} (99%) rename assets/{src_article_sort_count_index.md.D-lG8j-V.js => src_article_sort_count_index.md.C7C1FNVH.js} (99%) rename assets/{src_article_sort_count_index.md.D-lG8j-V.lean.js => src_article_sort_count_index.md.C7C1FNVH.lean.js} (99%) rename assets/{src_article_sort_heap_index.md.DGIzMQ7N.js => src_article_sort_heap_index.md.D4Xl3ax4.js} (99%) rename assets/{src_article_sort_heap_index.md.DGIzMQ7N.lean.js => src_article_sort_heap_index.md.D4Xl3ax4.lean.js} (99%) rename assets/{src_article_sort_index.md.BmzSFd6J.js => src_article_sort_index.md.BpYLVrl8.js} (94%) rename assets/{src_article_sort_index.md.BmzSFd6J.lean.js => src_article_sort_index.md.BpYLVrl8.lean.js} (94%) rename assets/{src_article_sort_insert_index.md.DfwnUGyP.js => src_article_sort_insert_index.md.DVHTMM7z.js} (98%) rename assets/{src_article_sort_insert_index.md.DfwnUGyP.lean.js => src_article_sort_insert_index.md.DVHTMM7z.lean.js} (98%) rename assets/{src_article_sort_merge_index.md.Di5Zqr25.js => src_article_sort_merge_index.md.SwAYr2r5.js} (99%) rename assets/{src_article_sort_merge_index.md.Di5Zqr25.lean.js => src_article_sort_merge_index.md.SwAYr2r5.lean.js} (99%) rename assets/{src_article_sort_quick_index.md.CdZNzudF.js => src_article_sort_quick_index.md.DC_bDmFO.js} (99%) rename assets/{src_article_sort_quick_index.md.CdZNzudF.lean.js => src_article_sort_quick_index.md.DC_bDmFO.lean.js} (99%) rename assets/{src_article_sort_radix_index.md.COn47ChC.js => src_article_sort_radix_index.md.DOCQJ1JY.js} (99%) rename assets/{src_article_sort_radix_index.md.COn47ChC.lean.js => src_article_sort_radix_index.md.DOCQJ1JY.lean.js} (99%) rename assets/{src_article_sort_select_index.md.D08HIyUD.js => src_article_sort_select_index.md.Be1rqYIJ.js} (98%) rename assets/{src_article_sort_select_index.md.D08HIyUD.lean.js => src_article_sort_select_index.md.Be1rqYIJ.lean.js} (98%) rename assets/{src_article_sort_shell_index.md.B-t4RyGV.js => src_article_sort_shell_index.md.DKh6PE9d.js} (98%) rename assets/{src_article_sort_shell_index.md.B-t4RyGV.lean.js => src_article_sort_shell_index.md.DKh6PE9d.lean.js} (98%) rename assets/{src_article_typescript_calculate.md.BhVfR7oM.js => src_article_typescript_calculate.md.CRWKCA-P.js} (99%) rename assets/{src_article_typescript_calculate.md.BhVfR7oM.lean.js => src_article_typescript_calculate.md.CRWKCA-P.lean.js} (99%) rename assets/{src_article_typescript_index.md.DnIyuKM2.js => src_article_typescript_index.md.wjDn-lKs.js} (99%) rename assets/{src_article_typescript_index.md.DnIyuKM2.lean.js => src_article_typescript_index.md.wjDn-lKs.lean.js} (99%) rename assets/{src_article_typescript_pattern.md.CLm0w2ze.js => src_article_typescript_pattern.md.Ez6YuvlL.js} (99%) rename assets/{src_article_typescript_pattern.md.CLm0w2ze.lean.js => src_article_typescript_pattern.md.Ez6YuvlL.lean.js} (99%) rename assets/{src_article_typescript_reconstruction.md.CB-miSsQ.js => src_article_typescript_reconstruction.md.DExhBwDE.js} (99%) rename assets/{src_article_typescript_reconstruction.md.CB-miSsQ.lean.js => src_article_typescript_reconstruction.md.DExhBwDE.lean.js} (99%) rename assets/{src_article_typescript_recursion.md.B4cwxN_H.js => src_article_typescript_recursion.md.DDZSliPb.js} (99%) rename assets/{src_article_typescript_recursion.md.B4cwxN_H.lean.js => src_article_typescript_recursion.md.DDZSliPb.lean.js} (99%) rename assets/{src_article_typescript_unionType.md.DOlhRVtQ.js => src_article_typescript_unionType.md.BQhAt8mB.js} (99%) rename assets/{src_article_typescript_unionType.md.DOlhRVtQ.lean.js => src_article_typescript_unionType.md.BQhAt8mB.lean.js} (99%) rename assets/{src_ranui_button_index.md.BaUgyz1X.js => src_ranui_button_index.md.knupWQOc.js} (99%) rename assets/{src_ranui_button_index.md.BaUgyz1X.lean.js => src_ranui_button_index.md.knupWQOc.lean.js} (99%) rename assets/{src_ranui_checkbox_index.md.DybUso6k.js => src_ranui_checkbox_index.md.CmEyFQLb.js} (98%) rename assets/{src_ranui_checkbox_index.md.DybUso6k.lean.js => src_ranui_checkbox_index.md.CmEyFQLb.lean.js} (98%) rename assets/{src_ranui_icon_index.md.Bvj_eNS6.js => src_ranui_icon_index.md.DWZ8pJQu.js} (99%) rename assets/{src_ranui_icon_index.md.Bvj_eNS6.lean.js => src_ranui_icon_index.md.DWZ8pJQu.lean.js} (99%) rename assets/{src_ranui_image_index.md.ByPb9XPk.js => src_ranui_image_index.md.C76U51KM.js} (97%) rename assets/{src_ranui_image_index.md.ByPb9XPk.lean.js => src_ranui_image_index.md.C76U51KM.lean.js} (97%) rename assets/{src_ranui_index.md.DaW35dZO.js => src_ranui_index.md.VveRY0aV.js} (99%) rename assets/{src_ranui_index.md.DaW35dZO.lean.js => src_ranui_index.md.VveRY0aV.lean.js} (99%) rename assets/{src_ranui_input_index.md.D_iWTNWU.js => src_ranui_input_index.md.BAWJIBJZ.js} (99%) rename assets/{src_ranui_input_index.md.D_iWTNWU.lean.js => src_ranui_input_index.md.BAWJIBJZ.lean.js} (99%) rename assets/{src_ranui_loading_index.md.C0IwCYQJ.js => src_ranui_loading_index.md.CxCc5xD8.js} (96%) rename assets/{src_ranui_loading_index.md.C0IwCYQJ.lean.js => src_ranui_loading_index.md.CxCc5xD8.lean.js} (96%) rename assets/{src_ranui_math_index.md.BftjvSU7.js => src_ranui_math_index.md.IY83GwaQ.js} (95%) rename assets/{src_ranui_math_index.md.BftjvSU7.lean.js => src_ranui_math_index.md.IY83GwaQ.lean.js} (95%) rename assets/{src_ranui_message_index.md.BUJ4qKWa.js => src_ranui_message_index.md.CBIOZrnU.js} (98%) rename assets/{src_ranui_message_index.md.BUJ4qKWa.lean.js => src_ranui_message_index.md.CBIOZrnU.lean.js} (98%) rename assets/{src_ranui_modal_index.md.DlMLUKFB.js => src_ranui_modal_index.md.humdf-kN.js} (68%) rename assets/{src_ranui_modal_index.md.DlMLUKFB.lean.js => src_ranui_modal_index.md.humdf-kN.lean.js} (68%) rename assets/{src_ranui_player_index.md.Bd3V6uX9.js => src_ranui_player_index.md.BhELSses.js} (97%) rename assets/{src_ranui_player_index.md.Bd3V6uX9.lean.js => src_ranui_player_index.md.BhELSses.lean.js} (97%) rename assets/{src_ranui_popover_index.md.CJywCOk7.js => src_ranui_popover_index.md.Bl1nd44O.js} (99%) rename assets/{src_ranui_popover_index.md.CJywCOk7.lean.js => src_ranui_popover_index.md.Bl1nd44O.lean.js} (99%) rename assets/{src_ranui_preview_index.md.BerPxqap.js => src_ranui_preview_index.md.BF58Mgx1.js} (98%) rename assets/{src_ranui_preview_index.md.BerPxqap.lean.js => src_ranui_preview_index.md.BF58Mgx1.lean.js} (98%) rename assets/{src_ranui_progress_index.md.BU24n0CS.js => src_ranui_progress_index.md.CoMblFHd.js} (99%) rename assets/{src_ranui_progress_index.md.BU24n0CS.lean.js => src_ranui_progress_index.md.CoMblFHd.lean.js} (99%) rename assets/{src_ranui_radar_index.md.jEmkm03a.js => src_ranui_radar_index.md.RgzR_NYQ.js} (99%) rename assets/{src_ranui_radar_index.md.jEmkm03a.lean.js => src_ranui_radar_index.md.RgzR_NYQ.lean.js} (99%) rename assets/{src_ranui_select_index.md.C9AWoPzE.js => src_ranui_select_index.md.BKakZMxv.js} (99%) rename assets/{src_ranui_select_index.md.C9AWoPzE.lean.js => src_ranui_select_index.md.BKakZMxv.lean.js} (99%) rename assets/{src_ranui_skeleton_index.md.CvCkfz55.js => src_ranui_skeleton_index.md.DuejSthu.js} (89%) rename assets/{src_ranui_skeleton_index.md.CvCkfz55.lean.js => src_ranui_skeleton_index.md.DuejSthu.lean.js} (89%) rename assets/{src_ranui_tab_index.md.DYSeU5SX.js => src_ranui_tab_index.md.DFpJEDjU.js} (99%) rename assets/{src_ranui_tab_index.md.DYSeU5SX.lean.js => src_ranui_tab_index.md.DFpJEDjU.lean.js} (99%) rename assets/{src_ranui_tabs_index.md.Bjpl0LRi.js => src_ranui_tabs_index.md.BP5Dd9UX.js} (99%) rename assets/{src_ranui_tabs_index.md.Bjpl0LRi.lean.js => src_ranui_tabs_index.md.BP5Dd9UX.lean.js} (99%) rename assets/{src_ranuts_binaryTree_index.md.BFnGWlo8.js => src_ranuts_binaryTree_index.md.Bo5xKeFC.js} (98%) rename assets/{src_ranuts_binaryTree_index.md.BFnGWlo8.lean.js => src_ranuts_binaryTree_index.md.Bo5xKeFC.lean.js} (98%) rename assets/{src_ranuts_bundler_index.md.BjmgKj3T.js => src_ranuts_bundler_index.md.CsAuaeoq.js} (92%) rename assets/{src_ranuts_bundler_index.md.BjmgKj3T.lean.js => src_ranuts_bundler_index.md.CsAuaeoq.lean.js} (92%) rename assets/{src_ranuts_file_appendFile.md.hfXTImhm.js => src_ranuts_file_appendFile.md.DN1hyzGA.js} (90%) rename assets/{src_ranuts_file_appendFile.md.hfXTImhm.lean.js => src_ranuts_file_appendFile.md.DN1hyzGA.lean.js} (90%) rename assets/{src_ranuts_file_fileInfo.md.DVvOqvMC.js => src_ranuts_file_fileInfo.md.BTEg4x1A.js} (90%) rename assets/{src_ranuts_file_fileInfo.md.DVvOqvMC.lean.js => src_ranuts_file_fileInfo.md.BTEg4x1A.lean.js} (90%) rename assets/{src_ranuts_file_readDir.md.DKqPkSiB.js => src_ranuts_file_readDir.md.DfAKb-lm.js} (93%) rename assets/{src_ranuts_file_readDir.md.DKqPkSiB.lean.js => src_ranuts_file_readDir.md.DfAKb-lm.lean.js} (93%) rename assets/{src_ranuts_file_readFile.md.DIBYZzGf.js => src_ranuts_file_readFile.md.CdwZqNwc.js} (89%) rename assets/{src_ranuts_file_readFile.md.DIBYZzGf.lean.js => src_ranuts_file_readFile.md.CdwZqNwc.lean.js} (89%) rename assets/{src_ranuts_file_watchFile.md.C834AKpV.js => src_ranuts_file_watchFile.md.2m1MF-uY.js} (88%) rename assets/{src_ranuts_file_watchFile.md.C834AKpV.lean.js => src_ranuts_file_watchFile.md.2m1MF-uY.lean.js} (88%) rename assets/{src_ranuts_file_writeFile.md.DwvidFHw.js => src_ranuts_file_writeFile.md.BBdQ8aK5.js} (89%) rename assets/{src_ranuts_file_writeFile.md.DwvidFHw.lean.js => src_ranuts_file_writeFile.md.BBdQ8aK5.lean.js} (89%) rename assets/{src_ranuts_index.md.vgnne91o.js => src_ranuts_index.md.CB2Cn65i.js} (94%) rename assets/{src_ranuts_index.md.vgnne91o.lean.js => src_ranuts_index.md.CB2Cn65i.lean.js} (94%) rename assets/{src_ranuts_mimeType_mimeType.md.3GwZTr-n.js => src_ranuts_mimeType_mimeType.md.DSadqbmv.js} (95%) rename assets/{src_ranuts_mimeType_mimeType.md.3GwZTr-n.lean.js => src_ranuts_mimeType_mimeType.md.DSadqbmv.lean.js} (95%) rename assets/{src_ranuts_mode_subscribe.md.yZp3GoEd.js => src_ranuts_mode_subscribe.md.CHshxehY.js} (98%) rename assets/{src_ranuts_mode_subscribe.md.yZp3GoEd.lean.js => src_ranuts_mode_subscribe.md.CHshxehY.lean.js} (98%) rename assets/{src_ranuts_utils_convertImageToBase64.md.hhkc5g8R.js => src_ranuts_utils_convertImageToBase64.md.B5TUIzAZ.js} (94%) rename assets/{src_ranuts_utils_convertImageToBase64.md.hhkc5g8R.lean.js => src_ranuts_utils_convertImageToBase64.md.B5TUIzAZ.lean.js} (94%) rename assets/{src_ranuts_utils_filterObj.md.Co3Jeapx.js => src_ranuts_utils_filterObj.md.Qc3cdyIl.js} (95%) rename assets/{src_ranuts_utils_filterObj.md.Co3Jeapx.lean.js => src_ranuts_utils_filterObj.md.Qc3cdyIl.lean.js} (95%) rename assets/{src_ranuts_utils_formatJson.md.DMpLzTqZ.js => src_ranuts_utils_formatJson.md.Baw5Xjrg.js} (95%) rename assets/{src_ranuts_utils_formatJson.md.DMpLzTqZ.lean.js => src_ranuts_utils_formatJson.md.Baw5Xjrg.lean.js} (95%) rename assets/{src_ranuts_utils_getCookie.md.D9hAw1Ai.js => src_ranuts_utils_getCookie.md.BNIeea85.js} (94%) rename assets/{src_ranuts_utils_getCookie.md.D9hAw1Ai.lean.js => src_ranuts_utils_getCookie.md.BNIeea85.lean.js} (94%) rename assets/{src_ranuts_utils_ocr.md.DhQDcBDd.js => src_ranuts_utils_ocr.md.CTguy2Qx.js} (97%) rename assets/{src_ranuts_utils_ocr.md.DhQDcBDd.lean.js => src_ranuts_utils_ocr.md.CTguy2Qx.lean.js} (97%) rename assets/{src_ranuts_utils_str2xml.md.B5vdQXxS.js => src_ranuts_utils_str2xml.md.DnO7V1a3.js} (96%) rename assets/{src_ranuts_utils_str2xml.md.B5vdQXxS.lean.js => src_ranuts_utils_str2xml.md.DnO7V1a3.lean.js} (96%) rename assets/{src_ranuts_utils_task.md.DkXOQ0Pm.js => src_ranuts_utils_task.md.BAX7uuWT.js} (97%) rename assets/{src_ranuts_utils_task.md.DkXOQ0Pm.lean.js => src_ranuts_utils_task.md.BAX7uuWT.lean.js} (97%) rename "assets/src_types_TS\347\261\273\345\236\213.md.lT0VsYJX.js" => "assets/src_types_TS\347\261\273\345\236\213.md.CNyAaj8V.js" (99%) rename "assets/src_types_TS\347\261\273\345\236\213.md.lT0VsYJX.lean.js" => "assets/src_types_TS\347\261\273\345\236\213.md.CNyAaj8V.lean.js" (99%) rename "assets/src_types_\346\250\241\345\274\217\345\214\271\351\205\215.md.aW8hDFrm.js" => "assets/src_types_\346\250\241\345\274\217\345\214\271\351\205\215.md.BM98mia7.js" (99%) rename "assets/src_types_\346\250\241\345\274\217\345\214\271\351\205\215.md.aW8hDFrm.lean.js" => "assets/src_types_\346\250\241\345\274\217\345\214\271\351\205\215.md.BM98mia7.lean.js" (99%) rename "assets/src_types_\347\261\273\345\236\213\350\277\220\347\256\227.md.BJCnK19u.js" => "assets/src_types_\347\261\273\345\236\213\350\277\220\347\256\227.md.BFtIIh3X.js" (99%) rename "assets/src_types_\347\261\273\345\236\213\350\277\220\347\256\227.md.BJCnK19u.lean.js" => "assets/src_types_\347\261\273\345\236\213\350\277\220\347\256\227.md.BFtIIh3X.lean.js" (99%) rename "assets/src_types_\351\253\230\347\272\247\347\261\273\345\236\213.md.ObRwkLSw.js" => "assets/src_types_\351\253\230\347\272\247\347\261\273\345\236\213.md.CJMDsdZH.js" (96%) rename "assets/src_types_\351\253\230\347\272\247\347\261\273\345\236\213.md.ObRwkLSw.lean.js" => "assets/src_types_\351\253\230\347\272\247\347\261\273\345\236\213.md.CJMDsdZH.lean.js" (96%) rename assets/{style.D7_Ytddv.css => style.E9dKQyFQ.css} (91%) delete mode 100644 pagefind/fragment/en_1d2a8f7.pf_fragment delete mode 100644 pagefind/fragment/en_2942c3c.pf_fragment create mode 100644 pagefind/fragment/en_30709d8.pf_fragment delete mode 100644 pagefind/fragment/en_31bb7a6.pf_fragment create mode 100644 pagefind/fragment/en_38d8359.pf_fragment create mode 100644 pagefind/fragment/en_3df5c5f.pf_fragment rename pagefind/fragment/{en_901e811.pf_fragment => en_449b12a.pf_fragment} (93%) delete mode 100644 pagefind/fragment/en_4873c44.pf_fragment create mode 100644 pagefind/fragment/en_5094588.pf_fragment delete mode 100644 pagefind/fragment/en_51f248e.pf_fragment create mode 100644 pagefind/fragment/en_5861ab4.pf_fragment create mode 100644 pagefind/fragment/en_5eef384.pf_fragment delete mode 100644 pagefind/fragment/en_5f9a7eb.pf_fragment create mode 100644 pagefind/fragment/en_63cffab.pf_fragment create mode 100644 pagefind/fragment/en_6a9915b.pf_fragment create mode 100644 pagefind/fragment/en_7118fbe.pf_fragment delete mode 100644 pagefind/fragment/en_75d5dcb.pf_fragment delete mode 100644 pagefind/fragment/en_7a4ca4f.pf_fragment create mode 100644 pagefind/fragment/en_815cbc8.pf_fragment delete mode 100644 pagefind/fragment/en_a9c2374.pf_fragment create mode 100644 pagefind/fragment/en_b110a5b.pf_fragment rename pagefind/fragment/{en_216410c.pf_fragment => en_b24f7ef.pf_fragment} (88%) create mode 100644 pagefind/fragment/en_b7c8c16.pf_fragment rename pagefind/fragment/{en_8e7817f.pf_fragment => en_c2412d4.pf_fragment} (76%) delete mode 100644 pagefind/fragment/en_c84c5e7.pf_fragment delete mode 100644 pagefind/fragment/en_c9c7c59.pf_fragment delete mode 100644 pagefind/fragment/en_d792b8c.pf_fragment rename pagefind/fragment/{en_4cca5aa.pf_fragment => en_ee9f170.pf_fragment} (98%) rename pagefind/fragment/{zh-cn_caddc62.pf_fragment => zh-cn_0ea6667.pf_fragment} (88%) create mode 100644 pagefind/fragment/zh-cn_154849c.pf_fragment rename pagefind/fragment/{zh-cn_a47bf58.pf_fragment => zh-cn_27c99c4.pf_fragment} (88%) delete mode 100644 pagefind/fragment/zh-cn_2ab4b75.pf_fragment create mode 100644 pagefind/fragment/zh-cn_2c21dbd.pf_fragment delete mode 100644 pagefind/fragment/zh-cn_2e8f3b4.pf_fragment rename pagefind/fragment/{zh-cn_c11a8a7.pf_fragment => zh-cn_39da2fe.pf_fragment} (93%) delete mode 100644 pagefind/fragment/zh-cn_3aa282b.pf_fragment create mode 100644 pagefind/fragment/zh-cn_51bdb63.pf_fragment create mode 100644 pagefind/fragment/zh-cn_5584627.pf_fragment rename pagefind/fragment/{zh-cn_25694d5.pf_fragment => zh-cn_565fd27.pf_fragment} (92%) delete mode 100644 pagefind/fragment/zh-cn_592cc95.pf_fragment create mode 100644 pagefind/fragment/zh-cn_5ab33e7.pf_fragment delete mode 100644 pagefind/fragment/zh-cn_5b71249.pf_fragment create mode 100644 pagefind/fragment/zh-cn_68b3659.pf_fragment rename pagefind/fragment/{zh-cn_aa1f32d.pf_fragment => zh-cn_6df03b5.pf_fragment} (96%) delete mode 100644 pagefind/fragment/zh-cn_8338621.pf_fragment create mode 100644 pagefind/fragment/zh-cn_8998463.pf_fragment delete mode 100644 pagefind/fragment/zh-cn_8d53abb.pf_fragment create mode 100644 pagefind/fragment/zh-cn_9879172.pf_fragment rename pagefind/fragment/{zh-cn_707d8fd.pf_fragment => zh-cn_c5d845d.pf_fragment} (85%) create mode 100644 pagefind/fragment/zh-cn_d388141.pf_fragment rename pagefind/fragment/{zh-cn_e7c7085.pf_fragment => zh-cn_e6dde39.pf_fragment} (95%) rename pagefind/fragment/{zh-cn_61c34a2.pf_fragment => zh-cn_e831ca8.pf_fragment} (82%) delete mode 100644 pagefind/fragment/zh-cn_edddd73.pf_fragment delete mode 100644 pagefind/fragment/zh-cn_ee19938.pf_fragment rename pagefind/fragment/{zh-cn_d04ce0b.pf_fragment => zh-cn_f2527de.pf_fragment} (78%) create mode 100644 pagefind/index/en_318ec34.pf_index create mode 100644 pagefind/index/en_396d347.pf_index create mode 100644 pagefind/index/en_58c6189.pf_index delete mode 100644 pagefind/index/en_bc39585.pf_index delete mode 100644 pagefind/index/en_d22f299.pf_index delete mode 100644 pagefind/index/en_e8e8597.pf_index create mode 100644 pagefind/index/zh-cn_16af6ef.pf_index create mode 100644 pagefind/index/zh-cn_181dded.pf_index create mode 100644 pagefind/index/zh-cn_4f900ab.pf_index create mode 100644 pagefind/index/zh-cn_5d1d145.pf_index delete mode 100644 pagefind/index/zh-cn_64ecbb3.pf_index delete mode 100644 pagefind/index/zh-cn_88a2748.pf_index delete mode 100644 pagefind/index/zh-cn_8d4814d.pf_index delete mode 100644 pagefind/index/zh-cn_933a426.pf_index delete mode 100644 pagefind/index/zh-cn_9bacfc2.pf_index create mode 100644 pagefind/index/zh-cn_bb272b7.pf_index create mode 100644 pagefind/pagefind.en_4e5413cee9.pf_meta delete mode 100644 pagefind/pagefind.en_5eb6d54e34.pf_meta delete mode 100644 pagefind/pagefind.zh-cn_25295ac6fc508.pf_meta create mode 100644 pagefind/pagefind.zh-cn_94eef15fae60c.pf_meta rename sw1728206030.js => sw1728703195.js (55%) diff --git a/404.html b/404.html index 6870b024af..6334043d76 100644 --- a/404.html +++ b/404.html @@ -5,10 +5,10 @@ 404 | ran - - + + - + @@ -33,14 +33,14 @@ - +
- + \ No newline at end of file diff --git a/assets/app.Bz9dt6dC.js b/assets/app.CfJxT4ml.js similarity index 90% rename from assets/app.Bz9dt6dC.js rename to assets/app.CfJxT4ml.js index e3f2021600..ecbbdaa487 100644 --- a/assets/app.Bz9dt6dC.js +++ b/assets/app.CfJxT4ml.js @@ -1 +1 @@ -import{R as i}from"./chunks/theme.FPvZ3Ede.js";import{R as o,ah as u,ai as l,aj as c,ak as f,al as d,am as m,an as h,ao as g,ap as A,aq as v,d as P,u as R,v as w,s as y,ar as C,as as b,at as E,a0 as S}from"./chunks/framework.eq-HTtE3.js";function p(e){if(e.extends){const a=p(e.extends);return{...a,...e,async enhanceApp(t){a.enhanceApp&&await a.enhanceApp(t),e.enhanceApp&&await e.enhanceApp(t)}}}return e}const s=p(i),T=P({name:"VitePressApp",setup(){const{site:e,lang:a,dir:t}=R();return w(()=>{y(()=>{document.documentElement.lang=a.value,document.documentElement.dir=t.value})}),e.value.router.prefetchLinks&&C(),b(),E(),s.setup&&s.setup(),()=>S(s.Layout)}});async function j(){globalThis.__VITEPRESS__=!0;const e=_(),a=D();a.provide(l,e);const t=c(e.route);return a.provide(f,t),a.component("Content",d),a.component("ClientOnly",m),Object.defineProperties(a.config.globalProperties,{$frontmatter:{get(){return t.frontmatter.value}},$params:{get(){return t.page.value.params}}}),s.enhanceApp&&await s.enhanceApp({app:a,router:e,siteData:h}),{app:a,router:e,data:t}}function D(){return g(T)}function _(){let e=o,a;return A(t=>{let n=v(t),r=null;return n&&(e&&(a=n),(e||a===n)&&(n=n.replace(/\.js$/,".lean.js")),r=import(n)),o&&(e=!1),r},s.NotFound)}o&&j().then(({app:e,router:a,data:t})=>{a.go().then(()=>{u(a.route,t.site),e.mount("#app")})});export{j as createApp}; +import{R as i}from"./chunks/theme.B08u4faT.js";import{R as o,ah as u,ai as l,aj as c,ak as f,al as d,am as m,an as h,ao as g,ap as A,aq as v,d as P,u as R,v as w,s as y,ar as C,as as b,at as E,a0 as S}from"./chunks/framework.CHSXtLMd.js";function p(e){if(e.extends){const a=p(e.extends);return{...a,...e,async enhanceApp(t){a.enhanceApp&&await a.enhanceApp(t),e.enhanceApp&&await e.enhanceApp(t)}}}return e}const s=p(i),T=P({name:"VitePressApp",setup(){const{site:e,lang:a,dir:t}=R();return w(()=>{y(()=>{document.documentElement.lang=a.value,document.documentElement.dir=t.value})}),e.value.router.prefetchLinks&&C(),b(),E(),s.setup&&s.setup(),()=>S(s.Layout)}});async function j(){globalThis.__VITEPRESS__=!0;const e=_(),a=D();a.provide(l,e);const t=c(e.route);return a.provide(f,t),a.component("Content",d),a.component("ClientOnly",m),Object.defineProperties(a.config.globalProperties,{$frontmatter:{get(){return t.frontmatter.value}},$params:{get(){return t.page.value.params}}}),s.enhanceApp&&await s.enhanceApp({app:a,router:e,siteData:h}),{app:a,router:e,data:t}}function D(){return g(T)}function _(){let e=o,a;return A(t=>{let n=v(t),r=null;return n&&(e&&(a=n),(e||a===n)&&(n=n.replace(/\.js$/,".lean.js")),r=import(n)),o&&(e=!1),r},s.NotFound)}o&&j().then(({app:e,router:a,data:t})=>{a.go().then(()=>{u(a.route,t.site),e.mount("#app")})});export{j as createApp}; diff --git a/assets/chunks/framework.CHSXtLMd.js b/assets/chunks/framework.CHSXtLMd.js new file mode 100644 index 0000000000..e227e40786 --- /dev/null +++ b/assets/chunks/framework.CHSXtLMd.js @@ -0,0 +1,18 @@ +/** +* @vue/shared v3.5.12 +* (c) 2018-present Yuxi (Evan) You and Vue contributors +* @license MIT +**//*! #__NO_SIDE_EFFECTS__ */function Ps(e){const t=Object.create(null);for(const n of e.split(","))t[n]=1;return n=>n in t}const Z={},St=[],ke=()=>{},Io=()=>!1,Jt=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),Ls=e=>e.startsWith("onUpdate:"),oe=Object.assign,Is=(e,t)=>{const n=e.indexOf(t);n>-1&&e.splice(n,1)},No=Object.prototype.hasOwnProperty,z=(e,t)=>No.call(e,t),U=Array.isArray,xt=e=>On(e)==="[object Map]",Kr=e=>On(e)==="[object Set]",q=e=>typeof e=="function",re=e=>typeof e=="string",Ge=e=>typeof e=="symbol",ne=e=>e!==null&&typeof e=="object",qr=e=>(ne(e)||q(e))&&q(e.then)&&q(e.catch),Gr=Object.prototype.toString,On=e=>Gr.call(e),Fo=e=>On(e).slice(8,-1),Yr=e=>On(e)==="[object Object]",Ns=e=>re(e)&&e!=="NaN"&&e[0]!=="-"&&""+parseInt(e,10)===e,Et=Ps(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),Mn=e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))},Ho=/-(\w)/g,Le=Mn(e=>e.replace(Ho,(t,n)=>n?n.toUpperCase():"")),Do=/\B([A-Z])/g,st=Mn(e=>e.replace(Do,"-$1").toLowerCase()),Pn=Mn(e=>e.charAt(0).toUpperCase()+e.slice(1)),pn=Mn(e=>e?`on${Pn(e)}`:""),et=(e,t)=>!Object.is(e,t),Xn=(e,...t)=>{for(let n=0;n{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:s,value:n})},$o=e=>{const t=parseFloat(e);return isNaN(t)?e:t},jo=e=>{const t=re(e)?Number(e):NaN;return isNaN(t)?e:t};let er;const Ln=()=>er||(er=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function Fs(e){if(U(e)){const t={};for(let n=0;n{if(n){const s=n.split(ko);s.length>1&&(t[s[0].trim()]=s[1].trim())}}),t}function Hs(e){let t="";if(re(e))t=e;else if(U(e))for(let n=0;n!!(e&&e.__v_isRef===!0),qo=e=>re(e)?e:e==null?"":U(e)||ne(e)&&(e.toString===Gr||!q(e.toString))?zr(e)?qo(e.value):JSON.stringify(e,Qr,2):String(e),Qr=(e,t)=>zr(t)?Qr(e,t.value):xt(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((n,[s,r],i)=>(n[Jn(s,i)+" =>"]=r,n),{})}:Kr(t)?{[`Set(${t.size})`]:[...t.values()].map(n=>Jn(n))}:Ge(t)?Jn(t):ne(t)&&!U(t)&&!Yr(t)?String(t):t,Jn=(e,t="")=>{var n;return Ge(e)?`Symbol(${(n=e.description)!=null?n:t})`:e};/** +* @vue/reactivity v3.5.12 +* (c) 2018-present Yuxi (Evan) You and Vue contributors +* @license MIT +**/let ve;class Zr{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this._isPaused=!1,this.parent=ve,!t&&ve&&(this.index=(ve.scopes||(ve.scopes=[])).push(this)-1)}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let t,n;if(this.scopes)for(t=0,n=this.scopes.length;t0)return;if(Dt){let t=Dt;for(Dt=void 0;t;){const n=t.next;t.next=void 0,t.flags&=-9,t=n}}let e;for(;Ht;){let t=Ht;for(Ht=void 0;t;){const n=t.next;if(t.next=void 0,t.flags&=-9,t.flags&1)try{t.trigger()}catch(s){e||(e=s)}t=n}}if(e)throw e}function ri(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function ii(e){let t,n=e.depsTail,s=n;for(;s;){const r=s.prevDep;s.version===-1?(s===n&&(n=r),js(s),Yo(s)):t=s,s.dep.activeLink=s.prevActiveLink,s.prevActiveLink=void 0,s=r}e.deps=t,e.depsTail=n}function ms(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(oi(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function oi(e){if(e.flags&4&&!(e.flags&16)||(e.flags&=-17,e.globalVersion===Ut))return;e.globalVersion=Ut;const t=e.dep;if(e.flags|=2,t.version>0&&!e.isSSR&&e.deps&&!ms(e)){e.flags&=-3;return}const n=te,s=Ne;te=e,Ne=!0;try{ri(e);const r=e.fn(e._value);(t.version===0||et(r,e._value))&&(e._value=r,t.version++)}catch(r){throw t.version++,r}finally{te=n,Ne=s,ii(e),e.flags&=-3}}function js(e,t=!1){const{dep:n,prevSub:s,nextSub:r}=e;if(s&&(s.nextSub=r,e.prevSub=void 0),r&&(r.prevSub=s,e.nextSub=void 0),n.subs===e&&(n.subs=s,!s&&n.computed)){n.computed.flags&=-5;for(let i=n.computed.deps;i;i=i.nextDep)js(i,!0)}!t&&!--n.sc&&n.map&&n.map.delete(n.key)}function Yo(e){const{prevDep:t,nextDep:n}=e;t&&(t.nextDep=n,e.prevDep=void 0),n&&(n.prevDep=t,e.nextDep=void 0)}let Ne=!0;const li=[];function rt(){li.push(Ne),Ne=!1}function it(){const e=li.pop();Ne=e===void 0?!0:e}function tr(e){const{cleanup:t}=e;if(e.cleanup=void 0,t){const n=te;te=void 0;try{t()}finally{te=n}}}let Ut=0;class Xo{constructor(t,n){this.sub=t,this.dep=n,this.version=n.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class In{constructor(t){this.computed=t,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0}track(t){if(!te||!Ne||te===this.computed)return;let n=this.activeLink;if(n===void 0||n.sub!==te)n=this.activeLink=new Xo(te,this),te.deps?(n.prevDep=te.depsTail,te.depsTail.nextDep=n,te.depsTail=n):te.deps=te.depsTail=n,ci(n);else if(n.version===-1&&(n.version=this.version,n.nextDep)){const s=n.nextDep;s.prevDep=n.prevDep,n.prevDep&&(n.prevDep.nextDep=s),n.prevDep=te.depsTail,n.nextDep=void 0,te.depsTail.nextDep=n,te.depsTail=n,te.deps===n&&(te.deps=s)}return n}trigger(t){this.version++,Ut++,this.notify(t)}notify(t){Ds();try{for(let n=this.subs;n;n=n.prevSub)n.sub.notify()&&n.sub.dep.notify()}finally{$s()}}}function ci(e){if(e.dep.sc++,e.sub.flags&4){const t=e.dep.computed;if(t&&!e.dep.subs){t.flags|=20;for(let s=t.deps;s;s=s.nextDep)ci(s)}const n=e.dep.subs;n!==e&&(e.prevSub=n,n&&(n.nextSub=e)),e.dep.subs=e}}const vn=new WeakMap,dt=Symbol(""),ys=Symbol(""),Bt=Symbol("");function me(e,t,n){if(Ne&&te){let s=vn.get(e);s||vn.set(e,s=new Map);let r=s.get(n);r||(s.set(n,r=new In),r.map=s,r.key=n),r.track()}}function We(e,t,n,s,r,i){const o=vn.get(e);if(!o){Ut++;return}const l=c=>{c&&c.trigger()};if(Ds(),t==="clear")o.forEach(l);else{const c=U(e),u=c&&Ns(n);if(c&&n==="length"){const a=Number(s);o.forEach((h,y)=>{(y==="length"||y===Bt||!Ge(y)&&y>=a)&&l(h)})}else switch((n!==void 0||o.has(void 0))&&l(o.get(n)),u&&l(o.get(Bt)),t){case"add":c?u&&l(o.get("length")):(l(o.get(dt)),xt(e)&&l(o.get(ys)));break;case"delete":c||(l(o.get(dt)),xt(e)&&l(o.get(ys)));break;case"set":xt(e)&&l(o.get(dt));break}}$s()}function Jo(e,t){const n=vn.get(e);return n&&n.get(t)}function bt(e){const t=J(e);return t===e?t:(me(t,"iterate",Bt),Pe(e)?t:t.map(ye))}function Nn(e){return me(e=J(e),"iterate",Bt),e}const zo={__proto__:null,[Symbol.iterator](){return Qn(this,Symbol.iterator,ye)},concat(...e){return bt(this).concat(...e.map(t=>U(t)?bt(t):t))},entries(){return Qn(this,"entries",e=>(e[1]=ye(e[1]),e))},every(e,t){return Ue(this,"every",e,t,void 0,arguments)},filter(e,t){return Ue(this,"filter",e,t,n=>n.map(ye),arguments)},find(e,t){return Ue(this,"find",e,t,ye,arguments)},findIndex(e,t){return Ue(this,"findIndex",e,t,void 0,arguments)},findLast(e,t){return Ue(this,"findLast",e,t,ye,arguments)},findLastIndex(e,t){return Ue(this,"findLastIndex",e,t,void 0,arguments)},forEach(e,t){return Ue(this,"forEach",e,t,void 0,arguments)},includes(...e){return Zn(this,"includes",e)},indexOf(...e){return Zn(this,"indexOf",e)},join(e){return bt(this).join(e)},lastIndexOf(...e){return Zn(this,"lastIndexOf",e)},map(e,t){return Ue(this,"map",e,t,void 0,arguments)},pop(){return Lt(this,"pop")},push(...e){return Lt(this,"push",e)},reduce(e,...t){return nr(this,"reduce",e,t)},reduceRight(e,...t){return nr(this,"reduceRight",e,t)},shift(){return Lt(this,"shift")},some(e,t){return Ue(this,"some",e,t,void 0,arguments)},splice(...e){return Lt(this,"splice",e)},toReversed(){return bt(this).toReversed()},toSorted(e){return bt(this).toSorted(e)},toSpliced(...e){return bt(this).toSpliced(...e)},unshift(...e){return Lt(this,"unshift",e)},values(){return Qn(this,"values",ye)}};function Qn(e,t,n){const s=Nn(e),r=s[t]();return s!==e&&!Pe(e)&&(r._next=r.next,r.next=()=>{const i=r._next();return i.value&&(i.value=n(i.value)),i}),r}const Qo=Array.prototype;function Ue(e,t,n,s,r,i){const o=Nn(e),l=o!==e&&!Pe(e),c=o[t];if(c!==Qo[t]){const h=c.apply(e,i);return l?ye(h):h}let u=n;o!==e&&(l?u=function(h,y){return n.call(this,ye(h),y,e)}:n.length>2&&(u=function(h,y){return n.call(this,h,y,e)}));const a=c.call(o,u,s);return l&&r?r(a):a}function nr(e,t,n,s){const r=Nn(e);let i=n;return r!==e&&(Pe(e)?n.length>3&&(i=function(o,l,c){return n.call(this,o,l,c,e)}):i=function(o,l,c){return n.call(this,o,ye(l),c,e)}),r[t](i,...s)}function Zn(e,t,n){const s=J(e);me(s,"iterate",Bt);const r=s[t](...n);return(r===-1||r===!1)&&Us(n[0])?(n[0]=J(n[0]),s[t](...n)):r}function Lt(e,t,n=[]){rt(),Ds();const s=J(e)[t].apply(e,n);return $s(),it(),s}const Zo=Ps("__proto__,__v_isRef,__isVue"),ai=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!=="arguments"&&e!=="caller").map(e=>Symbol[e]).filter(Ge));function el(e){Ge(e)||(e=String(e));const t=J(this);return me(t,"has",e),t.hasOwnProperty(e)}class fi{constructor(t=!1,n=!1){this._isReadonly=t,this._isShallow=n}get(t,n,s){const r=this._isReadonly,i=this._isShallow;if(n==="__v_isReactive")return!r;if(n==="__v_isReadonly")return r;if(n==="__v_isShallow")return i;if(n==="__v_raw")return s===(r?i?fl:pi:i?hi:di).get(t)||Object.getPrototypeOf(t)===Object.getPrototypeOf(s)?t:void 0;const o=U(t);if(!r){let c;if(o&&(c=zo[n]))return c;if(n==="hasOwnProperty")return el}const l=Reflect.get(t,n,ae(t)?t:s);return(Ge(n)?ai.has(n):Zo(n))||(r||me(t,"get",n),i)?l:ae(l)?o&&Ns(n)?l:l.value:ne(l)?r?Hn(l):Fn(l):l}}class ui extends fi{constructor(t=!1){super(!1,t)}set(t,n,s,r){let i=t[n];if(!this._isShallow){const c=yt(i);if(!Pe(s)&&!yt(s)&&(i=J(i),s=J(s)),!U(t)&&ae(i)&&!ae(s))return c?!1:(i.value=s,!0)}const o=U(t)&&Ns(n)?Number(n)e,tn=e=>Reflect.getPrototypeOf(e);function il(e,t,n){return function(...s){const r=this.__v_raw,i=J(r),o=xt(i),l=e==="entries"||e===Symbol.iterator&&o,c=e==="keys"&&o,u=r[e](...s),a=n?_s:t?bs:ye;return!t&&me(i,"iterate",c?ys:dt),{next(){const{value:h,done:y}=u.next();return y?{value:h,done:y}:{value:l?[a(h[0]),a(h[1])]:a(h),done:y}},[Symbol.iterator](){return this}}}}function nn(e){return function(...t){return e==="delete"?!1:e==="clear"?void 0:this}}function ol(e,t){const n={get(r){const i=this.__v_raw,o=J(i),l=J(r);e||(et(r,l)&&me(o,"get",r),me(o,"get",l));const{has:c}=tn(o),u=t?_s:e?bs:ye;if(c.call(o,r))return u(i.get(r));if(c.call(o,l))return u(i.get(l));i!==o&&i.get(r)},get size(){const r=this.__v_raw;return!e&&me(J(r),"iterate",dt),Reflect.get(r,"size",r)},has(r){const i=this.__v_raw,o=J(i),l=J(r);return e||(et(r,l)&&me(o,"has",r),me(o,"has",l)),r===l?i.has(r):i.has(r)||i.has(l)},forEach(r,i){const o=this,l=o.__v_raw,c=J(l),u=t?_s:e?bs:ye;return!e&&me(c,"iterate",dt),l.forEach((a,h)=>r.call(i,u(a),u(h),o))}};return oe(n,e?{add:nn("add"),set:nn("set"),delete:nn("delete"),clear:nn("clear")}:{add(r){!t&&!Pe(r)&&!yt(r)&&(r=J(r));const i=J(this);return tn(i).has.call(i,r)||(i.add(r),We(i,"add",r,r)),this},set(r,i){!t&&!Pe(i)&&!yt(i)&&(i=J(i));const o=J(this),{has:l,get:c}=tn(o);let u=l.call(o,r);u||(r=J(r),u=l.call(o,r));const a=c.call(o,r);return o.set(r,i),u?et(i,a)&&We(o,"set",r,i):We(o,"add",r,i),this},delete(r){const i=J(this),{has:o,get:l}=tn(i);let c=o.call(i,r);c||(r=J(r),c=o.call(i,r)),l&&l.call(i,r);const u=i.delete(r);return c&&We(i,"delete",r,void 0),u},clear(){const r=J(this),i=r.size!==0,o=r.clear();return i&&We(r,"clear",void 0,void 0),o}}),["keys","values","entries",Symbol.iterator].forEach(r=>{n[r]=il(r,e,t)}),n}function Vs(e,t){const n=ol(e,t);return(s,r,i)=>r==="__v_isReactive"?!e:r==="__v_isReadonly"?e:r==="__v_raw"?s:Reflect.get(z(n,r)&&r in s?n:s,r,i)}const ll={get:Vs(!1,!1)},cl={get:Vs(!1,!0)},al={get:Vs(!0,!1)};const di=new WeakMap,hi=new WeakMap,pi=new WeakMap,fl=new WeakMap;function ul(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function dl(e){return e.__v_skip||!Object.isExtensible(e)?0:ul(Fo(e))}function Fn(e){return yt(e)?e:ks(e,!1,nl,ll,di)}function hl(e){return ks(e,!1,rl,cl,hi)}function Hn(e){return ks(e,!0,sl,al,pi)}function ks(e,t,n,s,r){if(!ne(e)||e.__v_raw&&!(t&&e.__v_isReactive))return e;const i=r.get(e);if(i)return i;const o=dl(e);if(o===0)return e;const l=new Proxy(e,o===2?s:n);return r.set(e,l),l}function ht(e){return yt(e)?ht(e.__v_raw):!!(e&&e.__v_isReactive)}function yt(e){return!!(e&&e.__v_isReadonly)}function Pe(e){return!!(e&&e.__v_isShallow)}function Us(e){return e?!!e.__v_raw:!1}function J(e){const t=e&&e.__v_raw;return t?J(t):e}function gn(e){return!z(e,"__v_skip")&&Object.isExtensible(e)&&Xr(e,"__v_skip",!0),e}const ye=e=>ne(e)?Fn(e):e,bs=e=>ne(e)?Hn(e):e;function ae(e){return e?e.__v_isRef===!0:!1}function de(e){return mi(e,!1)}function gi(e){return mi(e,!0)}function mi(e,t){return ae(e)?e:new pl(e,t)}class pl{constructor(t,n){this.dep=new In,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=n?t:J(t),this._value=n?t:ye(t),this.__v_isShallow=n}get value(){return this.dep.track(),this._value}set value(t){const n=this._rawValue,s=this.__v_isShallow||Pe(t)||yt(t);t=s?t:J(t),et(t,n)&&(this._rawValue=t,this._value=s?t:ye(t),this.dep.trigger())}}function yi(e){return ae(e)?e.value:e}const gl={get:(e,t,n)=>t==="__v_raw"?e:yi(Reflect.get(e,t,n)),set:(e,t,n,s)=>{const r=e[t];return ae(r)&&!ae(n)?(r.value=n,!0):Reflect.set(e,t,n,s)}};function _i(e){return ht(e)?e:new Proxy(e,gl)}class ml{constructor(t){this.__v_isRef=!0,this._value=void 0;const n=this.dep=new In,{get:s,set:r}=t(n.track.bind(n),n.trigger.bind(n));this._get=s,this._set=r}get value(){return this._value=this._get()}set value(t){this._set(t)}}function yl(e){return new ml(e)}function df(e){const t=U(e)?new Array(e.length):{};for(const n in e)t[n]=bi(e,n);return t}class _l{constructor(t,n,s){this._object=t,this._key=n,this._defaultValue=s,this.__v_isRef=!0,this._value=void 0}get value(){const t=this._object[this._key];return this._value=t===void 0?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return Jo(J(this._object),this._key)}}class bl{constructor(t){this._getter=t,this.__v_isRef=!0,this.__v_isReadonly=!0,this._value=void 0}get value(){return this._value=this._getter()}}function vl(e,t,n){return ae(e)?e:q(e)?new bl(e):ne(e)&&arguments.length>1?bi(e,t,n):de(e)}function bi(e,t,n){const s=e[t];return ae(s)?s:new _l(e,t,n)}class wl{constructor(t,n,s){this.fn=t,this.setter=n,this._value=void 0,this.dep=new In(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=Ut-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!n,this.isSSR=s}notify(){if(this.flags|=16,!(this.flags&8)&&te!==this)return si(this,!0),!0}get value(){const t=this.dep.track();return oi(this),t&&(t.version=this.dep.version),this._value}set value(t){this.setter&&this.setter(t)}}function Sl(e,t,n=!1){let s,r;return q(e)?s=e:(s=e.get,r=e.set),new wl(s,r,n)}const sn={},wn=new WeakMap;let ft;function xl(e,t=!1,n=ft){if(n){let s=wn.get(n);s||wn.set(n,s=[]),s.push(e)}}function El(e,t,n=Z){const{immediate:s,deep:r,once:i,scheduler:o,augmentJob:l,call:c}=n,u=p=>r?p:Pe(p)||r===!1||r===0?Ke(p,1):Ke(p);let a,h,y,_,R=!1,T=!1;if(ae(e)?(h=()=>e.value,R=Pe(e)):ht(e)?(h=()=>u(e),R=!0):U(e)?(T=!0,R=e.some(p=>ht(p)||Pe(p)),h=()=>e.map(p=>{if(ae(p))return p.value;if(ht(p))return u(p);if(q(p))return c?c(p,2):p()})):q(e)?t?h=c?()=>c(e,2):e:h=()=>{if(y){rt();try{y()}finally{it()}}const p=ft;ft=a;try{return c?c(e,3,[_]):e(_)}finally{ft=p}}:h=ke,t&&r){const p=h,M=r===!0?1/0:r;h=()=>Ke(p(),M)}const G=ei(),$=()=>{a.stop(),G&&Is(G.effects,a)};if(i&&t){const p=t;t=(...M)=>{p(...M),$()}}let W=T?new Array(e.length).fill(sn):sn;const g=p=>{if(!(!(a.flags&1)||!a.dirty&&!p))if(t){const M=a.run();if(r||R||(T?M.some((N,H)=>et(N,W[H])):et(M,W))){y&&y();const N=ft;ft=a;try{const H=[M,W===sn?void 0:T&&W[0]===sn?[]:W,_];c?c(t,3,H):t(...H),W=M}finally{ft=N}}}else a.run()};return l&&l(g),a=new ti(h),a.scheduler=o?()=>o(g,!1):g,_=p=>xl(p,!1,a),y=a.onStop=()=>{const p=wn.get(a);if(p){if(c)c(p,4);else for(const M of p)M();wn.delete(a)}},t?s?g(!0):W=a.run():o?o(g.bind(null,!0),!0):a.run(),$.pause=a.pause.bind(a),$.resume=a.resume.bind(a),$.stop=$,$}function Ke(e,t=1/0,n){if(t<=0||!ne(e)||e.__v_skip||(n=n||new Set,n.has(e)))return e;if(n.add(e),t--,ae(e))Ke(e.value,t,n);else if(U(e))for(let s=0;s{Ke(s,t,n)});else if(Yr(e)){for(const s in e)Ke(e[s],t,n);for(const s of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,s)&&Ke(e[s],t,n)}return e}/** +* @vue/runtime-core v3.5.12 +* (c) 2018-present Yuxi (Evan) You and Vue contributors +* @license MIT +**/function zt(e,t,n,s){try{return s?e(...s):e()}catch(r){Dn(r,t,n)}}function He(e,t,n,s){if(q(e)){const r=zt(e,t,n,s);return r&&qr(r)&&r.catch(i=>{Dn(i,t,n)}),r}if(U(e)){const r=[];for(let i=0;i>>1,r=we[s],i=Wt(r);i=Wt(n)?we.push(e):we.splice(Cl(t),0,e),e.flags|=1,wi()}}function wi(){Sn||(Sn=vi.then(Si))}function Al(e){U(e)?Tt.push(...e):ze&&e.id===-1?ze.splice(wt+1,0,e):e.flags&1||(Tt.push(e),e.flags|=1),wi()}function sr(e,t,n=je+1){for(;nWt(n)-Wt(s));if(Tt.length=0,ze){ze.push(...t);return}for(ze=t,wt=0;wte.id==null?e.flags&2?-1:1/0:e.id;function Si(e){try{for(je=0;je{s._d&&yr(-1);const i=En(t);let o;try{o=e(...r)}finally{En(i),s._d&&yr(1)}return o};return s._n=!0,s._c=!0,s._d=!0,s}function hf(e,t){if(ce===null)return e;const n=Kn(ce),s=e.dirs||(e.dirs=[]);for(let r=0;re.__isTeleport,$t=e=>e&&(e.disabled||e.disabled===""),Ol=e=>e&&(e.defer||e.defer===""),rr=e=>typeof SVGElement<"u"&&e instanceof SVGElement,ir=e=>typeof MathMLElement=="function"&&e instanceof MathMLElement,vs=(e,t)=>{const n=e&&e.to;return re(n)?t?t(n):null:n},Ml={name:"Teleport",__isTeleport:!0,process(e,t,n,s,r,i,o,l,c,u){const{mc:a,pc:h,pbc:y,o:{insert:_,querySelector:R,createText:T,createComment:G}}=u,$=$t(t.props);let{shapeFlag:W,children:g,dynamicChildren:p}=t;if(e==null){const M=t.el=T(""),N=t.anchor=T("");_(M,n,s),_(N,n,s);const H=(A,b)=>{W&16&&(r&&r.isCE&&(r.ce._teleportTarget=A),a(g,A,b,r,i,o,l,c))},j=()=>{const A=t.target=vs(t.props,R),b=Ci(A,t,T,_);A&&(o!=="svg"&&rr(A)?o="svg":o!=="mathml"&&ir(A)&&(o="mathml"),$||(H(A,b),mn(t,!1)))};$&&(H(n,N),mn(t,!0)),Ol(t.props)?xe(j,i):j()}else{t.el=e.el,t.targetStart=e.targetStart;const M=t.anchor=e.anchor,N=t.target=e.target,H=t.targetAnchor=e.targetAnchor,j=$t(e.props),A=j?n:N,b=j?M:H;if(o==="svg"||rr(N)?o="svg":(o==="mathml"||ir(N))&&(o="mathml"),p?(y(e.dynamicChildren,p,A,r,i,o,l),qs(e,t,!0)):c||h(e,t,A,b,r,i,o,l,!1),$)j?t.props&&e.props&&t.props.to!==e.props.to&&(t.props.to=e.props.to):rn(t,n,M,u,1);else if((t.props&&t.props.to)!==(e.props&&e.props.to)){const I=t.target=vs(t.props,R);I&&rn(t,I,null,u,0)}else j&&rn(t,N,H,u,1);mn(t,$)}},remove(e,t,n,{um:s,o:{remove:r}},i){const{shapeFlag:o,children:l,anchor:c,targetStart:u,targetAnchor:a,target:h,props:y}=e;if(h&&(r(u),r(a)),i&&r(c),o&16){const _=i||!$t(y);for(let R=0;R{e.isMounted=!0}),Fi(()=>{e.isUnmounting=!0}),e}const Re=[Function,Array],Ai={mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:Re,onEnter:Re,onAfterEnter:Re,onEnterCancelled:Re,onBeforeLeave:Re,onLeave:Re,onAfterLeave:Re,onLeaveCancelled:Re,onBeforeAppear:Re,onAppear:Re,onAfterAppear:Re,onAppearCancelled:Re},Ri=e=>{const t=e.subTree;return t.component?Ri(t.component):t},Il={name:"BaseTransition",props:Ai,setup(e,{slots:t}){const n=Wn(),s=Ll();return()=>{const r=t.default&&Pi(t.default(),!0);if(!r||!r.length)return;const i=Oi(r),o=J(e),{mode:l}=o;if(s.isLeaving)return es(i);const c=or(i);if(!c)return es(i);let u=ws(c,o,s,n,y=>u=y);c.type!==_e&&Kt(c,u);const a=n.subTree,h=a&&or(a);if(h&&h.type!==_e&&!ut(c,h)&&Ri(n).type!==_e){const y=ws(h,o,s,n);if(Kt(h,y),l==="out-in"&&c.type!==_e)return s.isLeaving=!0,y.afterLeave=()=>{s.isLeaving=!1,n.job.flags&8||n.update(),delete y.afterLeave},es(i);l==="in-out"&&c.type!==_e&&(y.delayLeave=(_,R,T)=>{const G=Mi(s,h);G[String(h.key)]=h,_[Qe]=()=>{R(),_[Qe]=void 0,delete u.delayedLeave},u.delayedLeave=T})}return i}}};function Oi(e){let t=e[0];if(e.length>1){for(const n of e)if(n.type!==_e){t=n;break}}return t}const Nl=Il;function Mi(e,t){const{leavingVNodes:n}=e;let s=n.get(t.type);return s||(s=Object.create(null),n.set(t.type,s)),s}function ws(e,t,n,s,r){const{appear:i,mode:o,persisted:l=!1,onBeforeEnter:c,onEnter:u,onAfterEnter:a,onEnterCancelled:h,onBeforeLeave:y,onLeave:_,onAfterLeave:R,onLeaveCancelled:T,onBeforeAppear:G,onAppear:$,onAfterAppear:W,onAppearCancelled:g}=t,p=String(e.key),M=Mi(n,e),N=(A,b)=>{A&&He(A,s,9,b)},H=(A,b)=>{const I=b[1];N(A,b),U(A)?A.every(S=>S.length<=1)&&I():A.length<=1&&I()},j={mode:o,persisted:l,beforeEnter(A){let b=c;if(!n.isMounted)if(i)b=G||c;else return;A[Qe]&&A[Qe](!0);const I=M[p];I&&ut(e,I)&&I.el[Qe]&&I.el[Qe](),N(b,[A])},enter(A){let b=u,I=a,S=h;if(!n.isMounted)if(i)b=$||u,I=W||a,S=g||h;else return;let B=!1;const se=A[on]=le=>{B||(B=!0,le?N(S,[A]):N(I,[A]),j.delayedLeave&&j.delayedLeave(),A[on]=void 0)};b?H(b,[A,se]):se()},leave(A,b){const I=String(e.key);if(A[on]&&A[on](!0),n.isUnmounting)return b();N(y,[A]);let S=!1;const B=A[Qe]=se=>{S||(S=!0,b(),se?N(T,[A]):N(R,[A]),A[Qe]=void 0,M[I]===e&&delete M[I])};M[I]=e,_?H(_,[A,B]):B()},clone(A){const b=ws(A,t,n,s,r);return r&&r(b),b}};return j}function es(e){if(jn(e))return e=nt(e),e.children=null,e}function or(e){if(!jn(e))return Ti(e.type)&&e.children?Oi(e.children):e;const{shapeFlag:t,children:n}=e;if(n){if(t&16)return n[0];if(t&32&&q(n.default))return n.default()}}function Kt(e,t){e.shapeFlag&6&&e.component?(e.transition=t,Kt(e.component.subTree,t)):e.shapeFlag&128?(e.ssContent.transition=t.clone(e.ssContent),e.ssFallback.transition=t.clone(e.ssFallback)):e.transition=t}function Pi(e,t=!1,n){let s=[],r=0;for(let i=0;i1)for(let i=0;iTn(R,t&&(U(t)?t[T]:t),n,s,r));return}if(pt(s)&&!r)return;const i=s.shapeFlag&4?Kn(s.component):s.el,o=r?null:i,{i:l,r:c}=e,u=t&&t.r,a=l.refs===Z?l.refs={}:l.refs,h=l.setupState,y=J(h),_=h===Z?()=>!1:R=>z(y,R);if(u!=null&&u!==c&&(re(u)?(a[u]=null,_(u)&&(h[u]=null)):ae(u)&&(u.value=null)),q(c))zt(c,l,12,[o,a]);else{const R=re(c),T=ae(c);if(R||T){const G=()=>{if(e.f){const $=R?_(c)?h[c]:a[c]:c.value;r?U($)&&Is($,i):U($)?$.includes(i)||$.push(i):R?(a[c]=[i],_(c)&&(h[c]=a[c])):(c.value=[i],e.k&&(a[e.k]=c.value))}else R?(a[c]=o,_(c)&&(h[c]=o)):T&&(c.value=o,e.k&&(a[e.k]=o))};o?(G.id=-1,xe(G,n)):G()}}}let lr=!1;const vt=()=>{lr||(console.error("Hydration completed but contains mismatches."),lr=!0)},Fl=e=>e.namespaceURI.includes("svg")&&e.tagName!=="foreignObject",Hl=e=>e.namespaceURI.includes("MathML"),ln=e=>{if(e.nodeType===1){if(Fl(e))return"svg";if(Hl(e))return"mathml"}},cn=e=>e.nodeType===8;function Dl(e){const{mt:t,p:n,o:{patchProp:s,createText:r,nextSibling:i,parentNode:o,remove:l,insert:c,createComment:u}}=e,a=(g,p)=>{if(!p.hasChildNodes()){n(null,g,p),xn(),p._vnode=g;return}h(p.firstChild,g,null,null,null),xn(),p._vnode=g},h=(g,p,M,N,H,j=!1)=>{j=j||!!p.dynamicChildren;const A=cn(g)&&g.data==="[",b=()=>T(g,p,M,N,H,A),{type:I,ref:S,shapeFlag:B,patchFlag:se}=p;let le=g.nodeType;p.el=g,se===-2&&(j=!1,p.dynamicChildren=null);let V=null;switch(I){case gt:le!==3?p.children===""?(c(p.el=r(""),o(g),g),V=g):V=b():(g.data!==p.children&&(vt(),g.data=p.children),V=i(g));break;case _e:W(g)?(V=i(g),$(p.el=g.content.firstChild,g,M)):le!==8||A?V=b():V=i(g);break;case Vt:if(A&&(g=i(g),le=g.nodeType),le===1||le===3){V=g;const Y=!p.children.length;for(let D=0;D{j=j||!!p.dynamicChildren;const{type:A,props:b,patchFlag:I,shapeFlag:S,dirs:B,transition:se}=p,le=A==="input"||A==="option";if(le||I!==-1){B&&Ve(p,null,M,"created");let V=!1;if(W(g)){V=zi(null,se)&&M&&M.vnode.props&&M.vnode.props.appear;const D=g.content.firstChild;V&&se.beforeEnter(D),$(D,g,M),p.el=g=D}if(S&16&&!(b&&(b.innerHTML||b.textContent))){let D=_(g.firstChild,p,g,M,N,H,j);for(;D;){an(g,1)||vt();const fe=D;D=D.nextSibling,l(fe)}}else if(S&8){let D=p.children;D[0]===` +`&&(g.tagName==="PRE"||g.tagName==="TEXTAREA")&&(D=D.slice(1)),g.textContent!==D&&(an(g,0)||vt(),g.textContent=p.children)}if(b){if(le||!j||I&48){const D=g.tagName.includes("-");for(const fe in b)(le&&(fe.endsWith("value")||fe==="indeterminate")||Jt(fe)&&!Et(fe)||fe[0]==="."||D)&&s(g,fe,null,b[fe],void 0,M)}else if(b.onClick)s(g,"onClick",null,b.onClick,void 0,M);else if(I&4&&ht(b.style))for(const D in b.style)b.style[D]}let Y;(Y=b&&b.onVnodeBeforeMount)&&Oe(Y,M,p),B&&Ve(p,null,M,"beforeMount"),((Y=b&&b.onVnodeMounted)||B||V)&&so(()=>{Y&&Oe(Y,M,p),V&&se.enter(g),B&&Ve(p,null,M,"mounted")},N)}return g.nextSibling},_=(g,p,M,N,H,j,A)=>{A=A||!!p.dynamicChildren;const b=p.children,I=b.length;for(let S=0;S{const{slotScopeIds:A}=p;A&&(H=H?H.concat(A):A);const b=o(g),I=_(i(g),p,b,M,N,H,j);return I&&cn(I)&&I.data==="]"?i(p.anchor=I):(vt(),c(p.anchor=u("]"),b,I),I)},T=(g,p,M,N,H,j)=>{if(an(g.parentElement,1)||vt(),p.el=null,j){const I=G(g);for(;;){const S=i(g);if(S&&S!==I)l(S);else break}}const A=i(g),b=o(g);return l(g),n(null,p,b,A,M,N,ln(b),H),A},G=(g,p="[",M="]")=>{let N=0;for(;g;)if(g=i(g),g&&cn(g)&&(g.data===p&&N++,g.data===M)){if(N===0)return i(g);N--}return g},$=(g,p,M)=>{const N=p.parentNode;N&&N.replaceChild(g,p);let H=M;for(;H;)H.vnode.el===p&&(H.vnode.el=H.subTree.el=g),H=H.parent},W=g=>g.nodeType===1&&g.tagName==="TEMPLATE";return[a,h]}const cr="data-allow-mismatch",$l={0:"text",1:"children",2:"class",3:"style",4:"attribute"};function an(e,t){if(t===0||t===1)for(;e&&!e.hasAttribute(cr);)e=e.parentElement;const n=e&&e.getAttribute(cr);if(n==null)return!1;if(n==="")return!0;{const s=n.split(",");return t===0&&s.includes("children")?!0:n.split(",").includes($l[t])}}Ln().requestIdleCallback;Ln().cancelIdleCallback;const pt=e=>!!e.type.__asyncLoader,jn=e=>e.type.__isKeepAlive;function jl(e,t){Ni(e,"a",t)}function Vl(e,t){Ni(e,"da",t)}function Ni(e,t,n=ue){const s=e.__wdc||(e.__wdc=()=>{let r=n;for(;r;){if(r.isDeactivated)return;r=r.parent}return e()});if(Vn(t,s,n),n){let r=n.parent;for(;r&&r.parent;)jn(r.parent.vnode)&&kl(s,t,n,r),r=r.parent}}function kl(e,t,n,s){const r=Vn(t,e,s,!0);kn(()=>{Is(s[t],r)},n)}function Vn(e,t,n=ue,s=!1){if(n){const r=n[e]||(n[e]=[]),i=t.__weh||(t.__weh=(...o)=>{rt();const l=Qt(n),c=He(t,n,e,o);return l(),it(),c});return s?r.unshift(i):r.push(i),i}}const Ye=e=>(t,n=ue)=>{(!Yt||e==="sp")&&Vn(e,(...s)=>t(...s),n)},Ul=Ye("bm"),Ot=Ye("m"),Bl=Ye("bu"),Wl=Ye("u"),Fi=Ye("bum"),kn=Ye("um"),Kl=Ye("sp"),ql=Ye("rtg"),Gl=Ye("rtc");function Yl(e,t=ue){Vn("ec",e,t)}const Hi="components";function gf(e,t){return $i(Hi,e,!0,t)||e}const Di=Symbol.for("v-ndc");function mf(e){return re(e)?$i(Hi,e,!1)||e:e||Di}function $i(e,t,n=!0,s=!1){const r=ce||ue;if(r){const i=r.type;{const l=Ic(i,!1);if(l&&(l===t||l===Le(t)||l===Pn(Le(t))))return i}const o=ar(r[e]||i[e],t)||ar(r.appContext[e],t);return!o&&s?i:o}}function ar(e,t){return e&&(e[t]||e[Le(t)]||e[Pn(Le(t))])}function yf(e,t,n,s){let r;const i=n,o=U(e);if(o||re(e)){const l=o&&ht(e);let c=!1;l&&(c=!Pe(e),e=Nn(e)),r=new Array(e.length);for(let u=0,a=e.length;ut(l,c,void 0,i));else{const l=Object.keys(e);r=new Array(l.length);for(let c=0,u=l.length;c{const i=s.fn(...r);return i&&(i.key=s.key),i}:s.fn)}return e}function bf(e,t,n={},s,r){if(ce.ce||ce.parent&&pt(ce.parent)&&ce.parent.ce)return t!=="default"&&(n.name=t),Cs(),As(Se,null,[he("slot",n,s&&s())],64);let i=e[t];i&&i._c&&(i._d=!1),Cs();const o=i&&ji(i(n)),l=n.key||o&&o.key,c=As(Se,{key:(l&&!Ge(l)?l:`_${t}`)+(!o&&s?"_fb":"")},o||(s?s():[]),o&&e._===1?64:-2);return!r&&c.scopeId&&(c.slotScopeIds=[c.scopeId+"-s"]),i&&i._c&&(i._d=!0),c}function ji(e){return e.some(t=>Gt(t)?!(t.type===_e||t.type===Se&&!ji(t.children)):!0)?e:null}function vf(e,t){const n={};for(const s in e)n[/[A-Z]/.test(s)?`on:${s}`:pn(s)]=e[s];return n}const Ss=e=>e?co(e)?Kn(e):Ss(e.parent):null,jt=oe(Object.create(null),{$:e=>e,$el:e=>e.vnode.el,$data:e=>e.data,$props:e=>e.props,$attrs:e=>e.attrs,$slots:e=>e.slots,$refs:e=>e.refs,$parent:e=>Ss(e.parent),$root:e=>Ss(e.root),$host:e=>e.ce,$emit:e=>e.emit,$options:e=>Ws(e),$forceUpdate:e=>e.f||(e.f=()=>{Bs(e.update)}),$nextTick:e=>e.n||(e.n=$n.bind(e.proxy)),$watch:e=>mc.bind(e)}),ts=(e,t)=>e!==Z&&!e.__isScriptSetup&&z(e,t),Xl={get({_:e},t){if(t==="__v_skip")return!0;const{ctx:n,setupState:s,data:r,props:i,accessCache:o,type:l,appContext:c}=e;let u;if(t[0]!=="$"){const _=o[t];if(_!==void 0)switch(_){case 1:return s[t];case 2:return r[t];case 4:return n[t];case 3:return i[t]}else{if(ts(s,t))return o[t]=1,s[t];if(r!==Z&&z(r,t))return o[t]=2,r[t];if((u=e.propsOptions[0])&&z(u,t))return o[t]=3,i[t];if(n!==Z&&z(n,t))return o[t]=4,n[t];xs&&(o[t]=0)}}const a=jt[t];let h,y;if(a)return t==="$attrs"&&me(e.attrs,"get",""),a(e);if((h=l.__cssModules)&&(h=h[t]))return h;if(n!==Z&&z(n,t))return o[t]=4,n[t];if(y=c.config.globalProperties,z(y,t))return y[t]},set({_:e},t,n){const{data:s,setupState:r,ctx:i}=e;return ts(r,t)?(r[t]=n,!0):s!==Z&&z(s,t)?(s[t]=n,!0):z(e.props,t)||t[0]==="$"&&t.slice(1)in e?!1:(i[t]=n,!0)},has({_:{data:e,setupState:t,accessCache:n,ctx:s,appContext:r,propsOptions:i}},o){let l;return!!n[o]||e!==Z&&z(e,o)||ts(t,o)||(l=i[0])&&z(l,o)||z(s,o)||z(jt,o)||z(r.config.globalProperties,o)},defineProperty(e,t,n){return n.get!=null?e._.accessCache[t]=0:z(n,"value")&&this.set(e,t,n.value,null),Reflect.defineProperty(e,t,n)}};function wf(){return Jl().slots}function Jl(){const e=Wn();return e.setupContext||(e.setupContext=fo(e))}function fr(e){return U(e)?e.reduce((t,n)=>(t[n]=null,t),{}):e}let xs=!0;function zl(e){const t=Ws(e),n=e.proxy,s=e.ctx;xs=!1,t.beforeCreate&&ur(t.beforeCreate,e,"bc");const{data:r,computed:i,methods:o,watch:l,provide:c,inject:u,created:a,beforeMount:h,mounted:y,beforeUpdate:_,updated:R,activated:T,deactivated:G,beforeDestroy:$,beforeUnmount:W,destroyed:g,unmounted:p,render:M,renderTracked:N,renderTriggered:H,errorCaptured:j,serverPrefetch:A,expose:b,inheritAttrs:I,components:S,directives:B,filters:se}=t;if(u&&Ql(u,s,null),o)for(const Y in o){const D=o[Y];q(D)&&(s[Y]=D.bind(n))}if(r){const Y=r.call(n,n);ne(Y)&&(e.data=Fn(Y))}if(xs=!0,i)for(const Y in i){const D=i[Y],fe=q(D)?D.bind(n,n):q(D.get)?D.get.bind(n,n):ke,Zt=!q(D)&&q(D.set)?D.set.bind(n):ke,ot=ie({get:fe,set:Zt});Object.defineProperty(s,Y,{enumerable:!0,configurable:!0,get:()=>ot.value,set:De=>ot.value=De})}if(l)for(const Y in l)Vi(l[Y],s,n,Y);if(c){const Y=q(c)?c.call(n):c;Reflect.ownKeys(Y).forEach(D=>{rc(D,Y[D])})}a&&ur(a,e,"c");function V(Y,D){U(D)?D.forEach(fe=>Y(fe.bind(n))):D&&Y(D.bind(n))}if(V(Ul,h),V(Ot,y),V(Bl,_),V(Wl,R),V(jl,T),V(Vl,G),V(Yl,j),V(Gl,N),V(ql,H),V(Fi,W),V(kn,p),V(Kl,A),U(b))if(b.length){const Y=e.exposed||(e.exposed={});b.forEach(D=>{Object.defineProperty(Y,D,{get:()=>n[D],set:fe=>n[D]=fe})})}else e.exposed||(e.exposed={});M&&e.render===ke&&(e.render=M),I!=null&&(e.inheritAttrs=I),S&&(e.components=S),B&&(e.directives=B),A&&Ii(e)}function Ql(e,t,n=ke){U(e)&&(e=Es(e));for(const s in e){const r=e[s];let i;ne(r)?"default"in r?i=At(r.from||s,r.default,!0):i=At(r.from||s):i=At(r),ae(i)?Object.defineProperty(t,s,{enumerable:!0,configurable:!0,get:()=>i.value,set:o=>i.value=o}):t[s]=i}}function ur(e,t,n){He(U(e)?e.map(s=>s.bind(t.proxy)):e.bind(t.proxy),t,n)}function Vi(e,t,n,s){let r=s.includes(".")?eo(n,s):()=>n[s];if(re(e)){const i=t[e];q(i)&&Fe(r,i)}else if(q(e))Fe(r,e.bind(n));else if(ne(e))if(U(e))e.forEach(i=>Vi(i,t,n,s));else{const i=q(e.handler)?e.handler.bind(n):t[e.handler];q(i)&&Fe(r,i,e)}}function Ws(e){const t=e.type,{mixins:n,extends:s}=t,{mixins:r,optionsCache:i,config:{optionMergeStrategies:o}}=e.appContext,l=i.get(t);let c;return l?c=l:!r.length&&!n&&!s?c=t:(c={},r.length&&r.forEach(u=>Cn(c,u,o,!0)),Cn(c,t,o)),ne(t)&&i.set(t,c),c}function Cn(e,t,n,s=!1){const{mixins:r,extends:i}=t;i&&Cn(e,i,n,!0),r&&r.forEach(o=>Cn(e,o,n,!0));for(const o in t)if(!(s&&o==="expose")){const l=Zl[o]||n&&n[o];e[o]=l?l(e[o],t[o]):t[o]}return e}const Zl={data:dr,props:hr,emits:hr,methods:Ft,computed:Ft,beforeCreate:be,created:be,beforeMount:be,mounted:be,beforeUpdate:be,updated:be,beforeDestroy:be,beforeUnmount:be,destroyed:be,unmounted:be,activated:be,deactivated:be,errorCaptured:be,serverPrefetch:be,components:Ft,directives:Ft,watch:tc,provide:dr,inject:ec};function dr(e,t){return t?e?function(){return oe(q(e)?e.call(this,this):e,q(t)?t.call(this,this):t)}:t:e}function ec(e,t){return Ft(Es(e),Es(t))}function Es(e){if(U(e)){const t={};for(let n=0;n1)return n&&q(t)?t.call(s&&s.proxy):t}}const Ui={},Bi=()=>Object.create(Ui),Wi=e=>Object.getPrototypeOf(e)===Ui;function ic(e,t,n,s=!1){const r={},i=Bi();e.propsDefaults=Object.create(null),Ki(e,t,r,i);for(const o in e.propsOptions[0])o in r||(r[o]=void 0);n?e.props=s?r:hl(r):e.type.props?e.props=r:e.props=i,e.attrs=i}function oc(e,t,n,s){const{props:r,attrs:i,vnode:{patchFlag:o}}=e,l=J(r),[c]=e.propsOptions;let u=!1;if((s||o>0)&&!(o&16)){if(o&8){const a=e.vnode.dynamicProps;for(let h=0;h{c=!0;const[y,_]=qi(h,t,!0);oe(o,y),_&&l.push(..._)};!n&&t.mixins.length&&t.mixins.forEach(a),e.extends&&a(e.extends),e.mixins&&e.mixins.forEach(a)}if(!i&&!c)return ne(e)&&s.set(e,St),St;if(U(i))for(let a=0;ae[0]==="_"||e==="$stable",Ks=e=>U(e)?e.map(Me):[Me(e)],cc=(e,t,n)=>{if(t._n)return t;const s=Rl((...r)=>Ks(t(...r)),n);return s._c=!1,s},Yi=(e,t,n)=>{const s=e._ctx;for(const r in e){if(Gi(r))continue;const i=e[r];if(q(i))t[r]=cc(r,i,s);else if(i!=null){const o=Ks(i);t[r]=()=>o}}},Xi=(e,t)=>{const n=Ks(t);e.slots.default=()=>n},Ji=(e,t,n)=>{for(const s in t)(n||s!=="_")&&(e[s]=t[s])},ac=(e,t,n)=>{const s=e.slots=Bi();if(e.vnode.shapeFlag&32){const r=t._;r?(Ji(s,t,n),n&&Xr(s,"_",r,!0)):Yi(t,s)}else t&&Xi(e,t)},fc=(e,t,n)=>{const{vnode:s,slots:r}=e;let i=!0,o=Z;if(s.shapeFlag&32){const l=t._;l?n&&l===1?i=!1:Ji(r,t,n):(i=!t.$stable,Yi(t,r)),o=t}else t&&(Xi(e,t),o={default:1});if(i)for(const l in r)!Gi(l)&&o[l]==null&&delete r[l]},xe=so;function uc(e){return dc(e,Dl)}function dc(e,t){const n=Ln();n.__VUE__=!0;const{insert:s,remove:r,patchProp:i,createElement:o,createText:l,createComment:c,setText:u,setElementText:a,parentNode:h,nextSibling:y,setScopeId:_=ke,insertStaticContent:R}=e,T=(f,d,m,x=null,v=null,w=null,P=void 0,O=null,C=!!d.dynamicChildren)=>{if(f===d)return;f&&!ut(f,d)&&(x=en(f),De(f,v,w,!0),f=null),d.patchFlag===-2&&(C=!1,d.dynamicChildren=null);const{type:E,ref:k,shapeFlag:L}=d;switch(E){case gt:G(f,d,m,x);break;case _e:$(f,d,m,x);break;case Vt:f==null&&W(d,m,x,P);break;case Se:S(f,d,m,x,v,w,P,O,C);break;default:L&1?M(f,d,m,x,v,w,P,O,C):L&6?B(f,d,m,x,v,w,P,O,C):(L&64||L&128)&&E.process(f,d,m,x,v,w,P,O,C,_t)}k!=null&&v&&Tn(k,f&&f.ref,w,d||f,!d)},G=(f,d,m,x)=>{if(f==null)s(d.el=l(d.children),m,x);else{const v=d.el=f.el;d.children!==f.children&&u(v,d.children)}},$=(f,d,m,x)=>{f==null?s(d.el=c(d.children||""),m,x):d.el=f.el},W=(f,d,m,x)=>{[f.el,f.anchor]=R(f.children,d,m,x,f.el,f.anchor)},g=({el:f,anchor:d},m,x)=>{let v;for(;f&&f!==d;)v=y(f),s(f,m,x),f=v;s(d,m,x)},p=({el:f,anchor:d})=>{let m;for(;f&&f!==d;)m=y(f),r(f),f=m;r(d)},M=(f,d,m,x,v,w,P,O,C)=>{d.type==="svg"?P="svg":d.type==="math"&&(P="mathml"),f==null?N(d,m,x,v,w,P,O,C):A(f,d,v,w,P,O,C)},N=(f,d,m,x,v,w,P,O)=>{let C,E;const{props:k,shapeFlag:L,transition:F,dirs:K}=f;if(C=f.el=o(f.type,w,k&&k.is,k),L&8?a(C,f.children):L&16&&j(f.children,C,null,x,v,ns(f,w),P,O),K&&Ve(f,null,x,"created"),H(C,f,f.scopeId,P,x),k){for(const ee in k)ee!=="value"&&!Et(ee)&&i(C,ee,null,k[ee],w,x);"value"in k&&i(C,"value",null,k.value,w),(E=k.onVnodeBeforeMount)&&Oe(E,x,f)}K&&Ve(f,null,x,"beforeMount");const X=zi(v,F);X&&F.beforeEnter(C),s(C,d,m),((E=k&&k.onVnodeMounted)||X||K)&&xe(()=>{E&&Oe(E,x,f),X&&F.enter(C),K&&Ve(f,null,x,"mounted")},v)},H=(f,d,m,x,v)=>{if(m&&_(f,m),x)for(let w=0;w{for(let E=C;E{const O=d.el=f.el;let{patchFlag:C,dynamicChildren:E,dirs:k}=d;C|=f.patchFlag&16;const L=f.props||Z,F=d.props||Z;let K;if(m&<(m,!1),(K=F.onVnodeBeforeUpdate)&&Oe(K,m,d,f),k&&Ve(d,f,m,"beforeUpdate"),m&<(m,!0),(L.innerHTML&&F.innerHTML==null||L.textContent&&F.textContent==null)&&a(O,""),E?b(f.dynamicChildren,E,O,m,x,ns(d,v),w):P||D(f,d,O,null,m,x,ns(d,v),w,!1),C>0){if(C&16)I(O,L,F,m,v);else if(C&2&&L.class!==F.class&&i(O,"class",null,F.class,v),C&4&&i(O,"style",L.style,F.style,v),C&8){const X=d.dynamicProps;for(let ee=0;ee{K&&Oe(K,m,d,f),k&&Ve(d,f,m,"updated")},x)},b=(f,d,m,x,v,w,P)=>{for(let O=0;O{if(d!==m){if(d!==Z)for(const w in d)!Et(w)&&!(w in m)&&i(f,w,d[w],null,v,x);for(const w in m){if(Et(w))continue;const P=m[w],O=d[w];P!==O&&w!=="value"&&i(f,w,O,P,v,x)}"value"in m&&i(f,"value",d.value,m.value,v)}},S=(f,d,m,x,v,w,P,O,C)=>{const E=d.el=f?f.el:l(""),k=d.anchor=f?f.anchor:l("");let{patchFlag:L,dynamicChildren:F,slotScopeIds:K}=d;K&&(O=O?O.concat(K):K),f==null?(s(E,m,x),s(k,m,x),j(d.children||[],m,k,v,w,P,O,C)):L>0&&L&64&&F&&f.dynamicChildren?(b(f.dynamicChildren,F,m,v,w,P,O),(d.key!=null||v&&d===v.subTree)&&qs(f,d,!0)):D(f,d,m,k,v,w,P,O,C)},B=(f,d,m,x,v,w,P,O,C)=>{d.slotScopeIds=O,f==null?d.shapeFlag&512?v.ctx.activate(d,m,x,P,C):se(d,m,x,v,w,P,C):le(f,d,C)},se=(f,d,m,x,v,w,P)=>{const O=f.component=Oc(f,x,v);if(jn(f)&&(O.ctx.renderer=_t),Mc(O,!1,P),O.asyncDep){if(v&&v.registerDep(O,V,P),!f.el){const C=O.subTree=he(_e);$(null,C,d,m)}}else V(O,f,d,m,v,w,P)},le=(f,d,m)=>{const x=d.component=f.component;if(wc(f,d,m))if(x.asyncDep&&!x.asyncResolved){Y(x,d,m);return}else x.next=d,x.update();else d.el=f.el,x.vnode=d},V=(f,d,m,x,v,w,P)=>{const O=()=>{if(f.isMounted){let{next:L,bu:F,u:K,parent:X,vnode:ee}=f;{const Te=Qi(f);if(Te){L&&(L.el=ee.el,Y(f,L,P)),Te.asyncDep.then(()=>{f.isUnmounted||O()});return}}let Q=L,Ee;lt(f,!1),L?(L.el=ee.el,Y(f,L,P)):L=ee,F&&Xn(F),(Ee=L.props&&L.props.onVnodeBeforeUpdate)&&Oe(Ee,X,L,ee),lt(f,!0);const pe=ss(f),Ie=f.subTree;f.subTree=pe,T(Ie,pe,h(Ie.el),en(Ie),f,v,w),L.el=pe.el,Q===null&&Sc(f,pe.el),K&&xe(K,v),(Ee=L.props&&L.props.onVnodeUpdated)&&xe(()=>Oe(Ee,X,L,ee),v)}else{let L;const{el:F,props:K}=d,{bm:X,m:ee,parent:Q,root:Ee,type:pe}=f,Ie=pt(d);if(lt(f,!1),X&&Xn(X),!Ie&&(L=K&&K.onVnodeBeforeMount)&&Oe(L,Q,d),lt(f,!0),F&&Yn){const Te=()=>{f.subTree=ss(f),Yn(F,f.subTree,f,v,null)};Ie&&pe.__asyncHydrate?pe.__asyncHydrate(F,f,Te):Te()}else{Ee.ce&&Ee.ce._injectChildStyle(pe);const Te=f.subTree=ss(f);T(null,Te,m,x,f,v,w),d.el=Te.el}if(ee&&xe(ee,v),!Ie&&(L=K&&K.onVnodeMounted)){const Te=d;xe(()=>Oe(L,Q,Te),v)}(d.shapeFlag&256||Q&&pt(Q.vnode)&&Q.vnode.shapeFlag&256)&&f.a&&xe(f.a,v),f.isMounted=!0,d=m=x=null}};f.scope.on();const C=f.effect=new ti(O);f.scope.off();const E=f.update=C.run.bind(C),k=f.job=C.runIfDirty.bind(C);k.i=f,k.id=f.uid,C.scheduler=()=>Bs(k),lt(f,!0),E()},Y=(f,d,m)=>{d.component=f;const x=f.vnode.props;f.vnode=d,f.next=null,oc(f,d.props,x,m),fc(f,d.children,m),rt(),sr(f),it()},D=(f,d,m,x,v,w,P,O,C=!1)=>{const E=f&&f.children,k=f?f.shapeFlag:0,L=d.children,{patchFlag:F,shapeFlag:K}=d;if(F>0){if(F&128){Zt(E,L,m,x,v,w,P,O,C);return}else if(F&256){fe(E,L,m,x,v,w,P,O,C);return}}K&8?(k&16&&Mt(E,v,w),L!==E&&a(m,L)):k&16?K&16?Zt(E,L,m,x,v,w,P,O,C):Mt(E,v,w,!0):(k&8&&a(m,""),K&16&&j(L,m,x,v,w,P,O,C))},fe=(f,d,m,x,v,w,P,O,C)=>{f=f||St,d=d||St;const E=f.length,k=d.length,L=Math.min(E,k);let F;for(F=0;Fk?Mt(f,v,w,!0,!1,L):j(d,m,x,v,w,P,O,C,L)},Zt=(f,d,m,x,v,w,P,O,C)=>{let E=0;const k=d.length;let L=f.length-1,F=k-1;for(;E<=L&&E<=F;){const K=f[E],X=d[E]=C?Ze(d[E]):Me(d[E]);if(ut(K,X))T(K,X,m,null,v,w,P,O,C);else break;E++}for(;E<=L&&E<=F;){const K=f[L],X=d[F]=C?Ze(d[F]):Me(d[F]);if(ut(K,X))T(K,X,m,null,v,w,P,O,C);else break;L--,F--}if(E>L){if(E<=F){const K=F+1,X=KF)for(;E<=L;)De(f[E],v,w,!0),E++;else{const K=E,X=E,ee=new Map;for(E=X;E<=F;E++){const Ce=d[E]=C?Ze(d[E]):Me(d[E]);Ce.key!=null&&ee.set(Ce.key,E)}let Q,Ee=0;const pe=F-X+1;let Ie=!1,Te=0;const Pt=new Array(pe);for(E=0;E=pe){De(Ce,v,w,!0);continue}let $e;if(Ce.key!=null)$e=ee.get(Ce.key);else for(Q=X;Q<=F;Q++)if(Pt[Q-X]===0&&ut(Ce,d[Q])){$e=Q;break}$e===void 0?De(Ce,v,w,!0):(Pt[$e-X]=E+1,$e>=Te?Te=$e:Ie=!0,T(Ce,d[$e],m,null,v,w,P,O,C),Ee++)}const Qs=Ie?hc(Pt):St;for(Q=Qs.length-1,E=pe-1;E>=0;E--){const Ce=X+E,$e=d[Ce],Zs=Ce+1{const{el:w,type:P,transition:O,children:C,shapeFlag:E}=f;if(E&6){ot(f.component.subTree,d,m,x);return}if(E&128){f.suspense.move(d,m,x);return}if(E&64){P.move(f,d,m,_t);return}if(P===Se){s(w,d,m);for(let L=0;LO.enter(w),v);else{const{leave:L,delayLeave:F,afterLeave:K}=O,X=()=>s(w,d,m),ee=()=>{L(w,()=>{X(),K&&K()})};F?F(w,X,ee):ee()}else s(w,d,m)},De=(f,d,m,x=!1,v=!1)=>{const{type:w,props:P,ref:O,children:C,dynamicChildren:E,shapeFlag:k,patchFlag:L,dirs:F,cacheIndex:K}=f;if(L===-2&&(v=!1),O!=null&&Tn(O,null,m,f,!0),K!=null&&(d.renderCache[K]=void 0),k&256){d.ctx.deactivate(f);return}const X=k&1&&F,ee=!pt(f);let Q;if(ee&&(Q=P&&P.onVnodeBeforeUnmount)&&Oe(Q,d,f),k&6)Lo(f.component,m,x);else{if(k&128){f.suspense.unmount(m,x);return}X&&Ve(f,null,d,"beforeUnmount"),k&64?f.type.remove(f,d,m,_t,x):E&&!E.hasOnce&&(w!==Se||L>0&&L&64)?Mt(E,d,m,!1,!0):(w===Se&&L&384||!v&&k&16)&&Mt(C,d,m),x&&Js(f)}(ee&&(Q=P&&P.onVnodeUnmounted)||X)&&xe(()=>{Q&&Oe(Q,d,f),X&&Ve(f,null,d,"unmounted")},m)},Js=f=>{const{type:d,el:m,anchor:x,transition:v}=f;if(d===Se){Po(m,x);return}if(d===Vt){p(f);return}const w=()=>{r(m),v&&!v.persisted&&v.afterLeave&&v.afterLeave()};if(f.shapeFlag&1&&v&&!v.persisted){const{leave:P,delayLeave:O}=v,C=()=>P(m,w);O?O(f.el,w,C):C()}else w()},Po=(f,d)=>{let m;for(;f!==d;)m=y(f),r(f),f=m;r(d)},Lo=(f,d,m)=>{const{bum:x,scope:v,job:w,subTree:P,um:O,m:C,a:E}=f;gr(C),gr(E),x&&Xn(x),v.stop(),w&&(w.flags|=8,De(P,f,d,m)),O&&xe(O,d),xe(()=>{f.isUnmounted=!0},d),d&&d.pendingBranch&&!d.isUnmounted&&f.asyncDep&&!f.asyncResolved&&f.suspenseId===d.pendingId&&(d.deps--,d.deps===0&&d.resolve())},Mt=(f,d,m,x=!1,v=!1,w=0)=>{for(let P=w;P{if(f.shapeFlag&6)return en(f.component.subTree);if(f.shapeFlag&128)return f.suspense.next();const d=y(f.anchor||f.el),m=d&&d[Ei];return m?y(m):d};let qn=!1;const zs=(f,d,m)=>{f==null?d._vnode&&De(d._vnode,null,null,!0):T(d._vnode||null,f,d,null,null,null,m),d._vnode=f,qn||(qn=!0,sr(),xn(),qn=!1)},_t={p:T,um:De,m:ot,r:Js,mt:se,mc:j,pc:D,pbc:b,n:en,o:e};let Gn,Yn;return t&&([Gn,Yn]=t(_t)),{render:zs,hydrate:Gn,createApp:sc(zs,Gn)}}function ns({type:e,props:t},n){return n==="svg"&&e==="foreignObject"||n==="mathml"&&e==="annotation-xml"&&t&&t.encoding&&t.encoding.includes("html")?void 0:n}function lt({effect:e,job:t},n){n?(e.flags|=32,t.flags|=4):(e.flags&=-33,t.flags&=-5)}function zi(e,t){return(!e||e&&!e.pendingBranch)&&t&&!t.persisted}function qs(e,t,n=!1){const s=e.children,r=t.children;if(U(s)&&U(r))for(let i=0;i>1,e[n[l]]0&&(t[s]=n[i-1]),n[i]=s)}}for(i=n.length,o=n[i-1];i-- >0;)n[i]=o,o=t[o];return n}function Qi(e){const t=e.subTree.component;if(t)return t.asyncDep&&!t.asyncResolved?t:Qi(t)}function gr(e){if(e)for(let t=0;tAt(pc);function Zi(e,t){return Un(e,null,t)}function Sf(e,t){return Un(e,null,{flush:"post"})}function Fe(e,t,n){return Un(e,t,n)}function Un(e,t,n=Z){const{immediate:s,deep:r,flush:i,once:o}=n,l=oe({},n),c=t&&s||!t&&i!=="post";let u;if(Yt){if(i==="sync"){const _=gc();u=_.__watcherHandles||(_.__watcherHandles=[])}else if(!c){const _=()=>{};return _.stop=ke,_.resume=ke,_.pause=ke,_}}const a=ue;l.call=(_,R,T)=>He(_,a,R,T);let h=!1;i==="post"?l.scheduler=_=>{xe(_,a&&a.suspense)}:i!=="sync"&&(h=!0,l.scheduler=(_,R)=>{R?_():Bs(_)}),l.augmentJob=_=>{t&&(_.flags|=4),h&&(_.flags|=2,a&&(_.id=a.uid,_.i=a))};const y=El(e,t,l);return Yt&&(u?u.push(y):c&&y()),y}function mc(e,t,n){const s=this.proxy,r=re(e)?e.includes(".")?eo(s,e):()=>s[e]:e.bind(s,s);let i;q(t)?i=t:(i=t.handler,n=t);const o=Qt(this),l=Un(r,i.bind(s),n);return o(),l}function eo(e,t){const n=t.split(".");return()=>{let s=e;for(let r=0;rt==="modelValue"||t==="model-value"?e.modelModifiers:e[`${t}Modifiers`]||e[`${Le(t)}Modifiers`]||e[`${st(t)}Modifiers`];function _c(e,t,...n){if(e.isUnmounted)return;const s=e.vnode.props||Z;let r=n;const i=t.startsWith("update:"),o=i&&yc(s,t.slice(7));o&&(o.trim&&(r=n.map(a=>re(a)?a.trim():a)),o.number&&(r=n.map($o)));let l,c=s[l=pn(t)]||s[l=pn(Le(t))];!c&&i&&(c=s[l=pn(st(t))]),c&&He(c,e,6,r);const u=s[l+"Once"];if(u){if(!e.emitted)e.emitted={};else if(e.emitted[l])return;e.emitted[l]=!0,He(u,e,6,r)}}function to(e,t,n=!1){const s=t.emitsCache,r=s.get(e);if(r!==void 0)return r;const i=e.emits;let o={},l=!1;if(!q(e)){const c=u=>{const a=to(u,t,!0);a&&(l=!0,oe(o,a))};!n&&t.mixins.length&&t.mixins.forEach(c),e.extends&&c(e.extends),e.mixins&&e.mixins.forEach(c)}return!i&&!l?(ne(e)&&s.set(e,null),null):(U(i)?i.forEach(c=>o[c]=null):oe(o,i),ne(e)&&s.set(e,o),o)}function Bn(e,t){return!e||!Jt(t)?!1:(t=t.slice(2).replace(/Once$/,""),z(e,t[0].toLowerCase()+t.slice(1))||z(e,st(t))||z(e,t))}function ss(e){const{type:t,vnode:n,proxy:s,withProxy:r,propsOptions:[i],slots:o,attrs:l,emit:c,render:u,renderCache:a,props:h,data:y,setupState:_,ctx:R,inheritAttrs:T}=e,G=En(e);let $,W;try{if(n.shapeFlag&4){const p=r||s,M=p;$=Me(u.call(M,p,a,h,_,y,R)),W=l}else{const p=t;$=Me(p.length>1?p(h,{attrs:l,slots:o,emit:c}):p(h,null)),W=t.props?l:bc(l)}}catch(p){kt.length=0,Dn(p,e,1),$=he(_e)}let g=$;if(W&&T!==!1){const p=Object.keys(W),{shapeFlag:M}=g;p.length&&M&7&&(i&&p.some(Ls)&&(W=vc(W,i)),g=nt(g,W,!1,!0))}return n.dirs&&(g=nt(g,null,!1,!0),g.dirs=g.dirs?g.dirs.concat(n.dirs):n.dirs),n.transition&&Kt(g,n.transition),$=g,En(G),$}const bc=e=>{let t;for(const n in e)(n==="class"||n==="style"||Jt(n))&&((t||(t={}))[n]=e[n]);return t},vc=(e,t)=>{const n={};for(const s in e)(!Ls(s)||!(s.slice(9)in t))&&(n[s]=e[s]);return n};function wc(e,t,n){const{props:s,children:r,component:i}=e,{props:o,children:l,patchFlag:c}=t,u=i.emitsOptions;if(t.dirs||t.transition)return!0;if(n&&c>=0){if(c&1024)return!0;if(c&16)return s?mr(s,o,u):!!o;if(c&8){const a=t.dynamicProps;for(let h=0;he.__isSuspense;function so(e,t){t&&t.pendingBranch?U(e)?t.effects.push(...e):t.effects.push(e):Al(e)}const Se=Symbol.for("v-fgt"),gt=Symbol.for("v-txt"),_e=Symbol.for("v-cmt"),Vt=Symbol.for("v-stc"),kt=[];let Ae=null;function Cs(e=!1){kt.push(Ae=e?null:[])}function xc(){kt.pop(),Ae=kt[kt.length-1]||null}let qt=1;function yr(e){qt+=e,e<0&&Ae&&(Ae.hasOnce=!0)}function ro(e){return e.dynamicChildren=qt>0?Ae||St:null,xc(),qt>0&&Ae&&Ae.push(e),e}function xf(e,t,n,s,r,i){return ro(oo(e,t,n,s,r,i,!0))}function As(e,t,n,s,r){return ro(he(e,t,n,s,r,!0))}function Gt(e){return e?e.__v_isVNode===!0:!1}function ut(e,t){return e.type===t.type&&e.key===t.key}const io=({key:e})=>e??null,yn=({ref:e,ref_key:t,ref_for:n})=>(typeof e=="number"&&(e=""+e),e!=null?re(e)||ae(e)||q(e)?{i:ce,r:e,k:t,f:!!n}:e:null);function oo(e,t=null,n=null,s=0,r=null,i=e===Se?0:1,o=!1,l=!1){const c={__v_isVNode:!0,__v_skip:!0,type:e,props:t,key:t&&io(t),ref:t&&yn(t),scopeId:xi,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:i,patchFlag:s,dynamicProps:r,dynamicChildren:null,appContext:null,ctx:ce};return l?(Gs(c,n),i&128&&e.normalize(c)):n&&(c.shapeFlag|=re(n)?8:16),qt>0&&!o&&Ae&&(c.patchFlag>0||i&6)&&c.patchFlag!==32&&Ae.push(c),c}const he=Ec;function Ec(e,t=null,n=null,s=0,r=null,i=!1){if((!e||e===Di)&&(e=_e),Gt(e)){const l=nt(e,t,!0);return n&&Gs(l,n),qt>0&&!i&&Ae&&(l.shapeFlag&6?Ae[Ae.indexOf(e)]=l:Ae.push(l)),l.patchFlag=-2,l}if(Nc(e)&&(e=e.__vccOpts),t){t=Tc(t);let{class:l,style:c}=t;l&&!re(l)&&(t.class=Hs(l)),ne(c)&&(Us(c)&&!U(c)&&(c=oe({},c)),t.style=Fs(c))}const o=re(e)?1:no(e)?128:Ti(e)?64:ne(e)?4:q(e)?2:0;return oo(e,t,n,s,r,o,i,!0)}function Tc(e){return e?Us(e)||Wi(e)?oe({},e):e:null}function nt(e,t,n=!1,s=!1){const{props:r,ref:i,patchFlag:o,children:l,transition:c}=e,u=t?Cc(r||{},t):r,a={__v_isVNode:!0,__v_skip:!0,type:e.type,props:u,key:u&&io(u),ref:t&&t.ref?n&&i?U(i)?i.concat(yn(t)):[i,yn(t)]:yn(t):i,scopeId:e.scopeId,slotScopeIds:e.slotScopeIds,children:l,target:e.target,targetStart:e.targetStart,targetAnchor:e.targetAnchor,staticCount:e.staticCount,shapeFlag:e.shapeFlag,patchFlag:t&&e.type!==Se?o===-1?16:o|16:o,dynamicProps:e.dynamicProps,dynamicChildren:e.dynamicChildren,appContext:e.appContext,dirs:e.dirs,transition:c,component:e.component,suspense:e.suspense,ssContent:e.ssContent&&nt(e.ssContent),ssFallback:e.ssFallback&&nt(e.ssFallback),el:e.el,anchor:e.anchor,ctx:e.ctx,ce:e.ce};return c&&s&&Kt(a,c.clone(a)),a}function lo(e=" ",t=0){return he(gt,null,e,t)}function Ef(e,t){const n=he(Vt,null,e);return n.staticCount=t,n}function Tf(e="",t=!1){return t?(Cs(),As(_e,null,e)):he(_e,null,e)}function Me(e){return e==null||typeof e=="boolean"?he(_e):U(e)?he(Se,null,e.slice()):Gt(e)?Ze(e):he(gt,null,String(e))}function Ze(e){return e.el===null&&e.patchFlag!==-1||e.memo?e:nt(e)}function Gs(e,t){let n=0;const{shapeFlag:s}=e;if(t==null)t=null;else if(U(t))n=16;else if(typeof t=="object")if(s&65){const r=t.default;r&&(r._c&&(r._d=!1),Gs(e,r()),r._c&&(r._d=!0));return}else{n=32;const r=t._;!r&&!Wi(t)?t._ctx=ce:r===3&&ce&&(ce.slots._===1?t._=1:(t._=2,e.patchFlag|=1024))}else q(t)?(t={default:t,_ctx:ce},n=32):(t=String(t),s&64?(n=16,t=[lo(t)]):n=8);e.children=t,e.shapeFlag|=n}function Cc(...e){const t={};for(let n=0;nue||ce;let An,Rs;{const e=Ln(),t=(n,s)=>{let r;return(r=e[n])||(r=e[n]=[]),r.push(s),i=>{r.length>1?r.forEach(o=>o(i)):r[0](i)}};An=t("__VUE_INSTANCE_SETTERS__",n=>ue=n),Rs=t("__VUE_SSR_SETTERS__",n=>Yt=n)}const Qt=e=>{const t=ue;return An(e),e.scope.on(),()=>{e.scope.off(),An(t)}},_r=()=>{ue&&ue.scope.off(),An(null)};function co(e){return e.vnode.shapeFlag&4}let Yt=!1;function Mc(e,t=!1,n=!1){t&&Rs(t);const{props:s,children:r}=e.vnode,i=co(e);ic(e,s,i,t),ac(e,r,n);const o=i?Pc(e,t):void 0;return t&&Rs(!1),o}function Pc(e,t){const n=e.type;e.accessCache=Object.create(null),e.proxy=new Proxy(e.ctx,Xl);const{setup:s}=n;if(s){rt();const r=e.setupContext=s.length>1?fo(e):null,i=Qt(e),o=zt(s,e,0,[e.props,r]),l=qr(o);if(it(),i(),(l||e.sp)&&!pt(e)&&Ii(e),l){if(o.then(_r,_r),t)return o.then(c=>{br(e,c,t)}).catch(c=>{Dn(c,e,0)});e.asyncDep=o}else br(e,o,t)}else ao(e,t)}function br(e,t,n){q(t)?e.type.__ssrInlineRender?e.ssrRender=t:e.render=t:ne(t)&&(e.setupState=_i(t)),ao(e,n)}let vr;function ao(e,t,n){const s=e.type;if(!e.render){if(!t&&vr&&!s.render){const r=s.template||Ws(e).template;if(r){const{isCustomElement:i,compilerOptions:o}=e.appContext.config,{delimiters:l,compilerOptions:c}=s,u=oe(oe({isCustomElement:i,delimiters:l},o),c);s.render=vr(r,u)}}e.render=s.render||ke}{const r=Qt(e);rt();try{zl(e)}finally{it(),r()}}}const Lc={get(e,t){return me(e,"get",""),e[t]}};function fo(e){const t=n=>{e.exposed=n||{}};return{attrs:new Proxy(e.attrs,Lc),slots:e.slots,emit:e.emit,expose:t}}function Kn(e){return e.exposed?e.exposeProxy||(e.exposeProxy=new Proxy(_i(gn(e.exposed)),{get(t,n){if(n in t)return t[n];if(n in jt)return jt[n](e)},has(t,n){return n in t||n in jt}})):e.proxy}function Ic(e,t=!0){return q(e)?e.displayName||e.name:e.name||t&&e.__name}function Nc(e){return q(e)&&"__vccOpts"in e}const ie=(e,t)=>Sl(e,t,Yt);function Os(e,t,n){const s=arguments.length;return s===2?ne(t)&&!U(t)?Gt(t)?he(e,null,[t]):he(e,t):he(e,null,t):(s>3?n=Array.prototype.slice.call(arguments,2):s===3&&Gt(n)&&(n=[n]),he(e,t,n))}const Fc="3.5.12";/** +* @vue/runtime-dom v3.5.12 +* (c) 2018-present Yuxi (Evan) You and Vue contributors +* @license MIT +**/let Ms;const wr=typeof window<"u"&&window.trustedTypes;if(wr)try{Ms=wr.createPolicy("vue",{createHTML:e=>e})}catch{}const uo=Ms?e=>Ms.createHTML(e):e=>e,Hc="http://www.w3.org/2000/svg",Dc="http://www.w3.org/1998/Math/MathML",Be=typeof document<"u"?document:null,Sr=Be&&Be.createElement("template"),$c={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,s)=>{const r=t==="svg"?Be.createElementNS(Hc,e):t==="mathml"?Be.createElementNS(Dc,e):n?Be.createElement(e,{is:n}):Be.createElement(e);return e==="select"&&s&&s.multiple!=null&&r.setAttribute("multiple",s.multiple),r},createText:e=>Be.createTextNode(e),createComment:e=>Be.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>Be.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,s,r,i){const o=n?n.previousSibling:t.lastChild;if(r&&(r===i||r.nextSibling))for(;t.insertBefore(r.cloneNode(!0),n),!(r===i||!(r=r.nextSibling)););else{Sr.innerHTML=uo(s==="svg"?`${e}`:s==="mathml"?`${e}`:e);const l=Sr.content;if(s==="svg"||s==="mathml"){const c=l.firstChild;for(;c.firstChild;)l.appendChild(c.firstChild);l.removeChild(c)}t.insertBefore(l,n)}return[o?o.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},Xe="transition",It="animation",Xt=Symbol("_vtc"),ho={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},jc=oe({},Ai,ho),Vc=e=>(e.displayName="Transition",e.props=jc,e),Cf=Vc((e,{slots:t})=>Os(Nl,kc(e),t)),ct=(e,t=[])=>{U(e)?e.forEach(n=>n(...t)):e&&e(...t)},xr=e=>e?U(e)?e.some(t=>t.length>1):e.length>1:!1;function kc(e){const t={};for(const S in e)S in ho||(t[S]=e[S]);if(e.css===!1)return t;const{name:n="v",type:s,duration:r,enterFromClass:i=`${n}-enter-from`,enterActiveClass:o=`${n}-enter-active`,enterToClass:l=`${n}-enter-to`,appearFromClass:c=i,appearActiveClass:u=o,appearToClass:a=l,leaveFromClass:h=`${n}-leave-from`,leaveActiveClass:y=`${n}-leave-active`,leaveToClass:_=`${n}-leave-to`}=e,R=Uc(r),T=R&&R[0],G=R&&R[1],{onBeforeEnter:$,onEnter:W,onEnterCancelled:g,onLeave:p,onLeaveCancelled:M,onBeforeAppear:N=$,onAppear:H=W,onAppearCancelled:j=g}=t,A=(S,B,se)=>{at(S,B?a:l),at(S,B?u:o),se&&se()},b=(S,B)=>{S._isLeaving=!1,at(S,h),at(S,_),at(S,y),B&&B()},I=S=>(B,se)=>{const le=S?H:W,V=()=>A(B,S,se);ct(le,[B,V]),Er(()=>{at(B,S?c:i),Je(B,S?a:l),xr(le)||Tr(B,s,T,V)})};return oe(t,{onBeforeEnter(S){ct($,[S]),Je(S,i),Je(S,o)},onBeforeAppear(S){ct(N,[S]),Je(S,c),Je(S,u)},onEnter:I(!1),onAppear:I(!0),onLeave(S,B){S._isLeaving=!0;const se=()=>b(S,B);Je(S,h),Je(S,y),Kc(),Er(()=>{S._isLeaving&&(at(S,h),Je(S,_),xr(p)||Tr(S,s,G,se))}),ct(p,[S,se])},onEnterCancelled(S){A(S,!1),ct(g,[S])},onAppearCancelled(S){A(S,!0),ct(j,[S])},onLeaveCancelled(S){b(S),ct(M,[S])}})}function Uc(e){if(e==null)return null;if(ne(e))return[rs(e.enter),rs(e.leave)];{const t=rs(e);return[t,t]}}function rs(e){return jo(e)}function Je(e,t){t.split(/\s+/).forEach(n=>n&&e.classList.add(n)),(e[Xt]||(e[Xt]=new Set)).add(t)}function at(e,t){t.split(/\s+/).forEach(s=>s&&e.classList.remove(s));const n=e[Xt];n&&(n.delete(t),n.size||(e[Xt]=void 0))}function Er(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}let Bc=0;function Tr(e,t,n,s){const r=e._endId=++Bc,i=()=>{r===e._endId&&s()};if(n!=null)return setTimeout(i,n);const{type:o,timeout:l,propCount:c}=Wc(e,t);if(!o)return s();const u=o+"end";let a=0;const h=()=>{e.removeEventListener(u,y),i()},y=_=>{_.target===e&&++a>=c&&h()};setTimeout(()=>{a(n[R]||"").split(", "),r=s(`${Xe}Delay`),i=s(`${Xe}Duration`),o=Cr(r,i),l=s(`${It}Delay`),c=s(`${It}Duration`),u=Cr(l,c);let a=null,h=0,y=0;t===Xe?o>0&&(a=Xe,h=o,y=i.length):t===It?u>0&&(a=It,h=u,y=c.length):(h=Math.max(o,u),a=h>0?o>u?Xe:It:null,y=a?a===Xe?i.length:c.length:0);const _=a===Xe&&/\b(transform|all)(,|$)/.test(s(`${Xe}Property`).toString());return{type:a,timeout:h,propCount:y,hasTransform:_}}function Cr(e,t){for(;e.lengthAr(n)+Ar(e[s])))}function Ar(e){return e==="auto"?0:Number(e.slice(0,-1).replace(",","."))*1e3}function Kc(){return document.body.offsetHeight}function qc(e,t,n){const s=e[Xt];s&&(t=(t?[t,...s]:[...s]).join(" ")),t==null?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}const Rn=Symbol("_vod"),po=Symbol("_vsh"),Af={beforeMount(e,{value:t},{transition:n}){e[Rn]=e.style.display==="none"?"":e.style.display,n&&t?n.beforeEnter(e):Nt(e,t)},mounted(e,{value:t},{transition:n}){n&&t&&n.enter(e)},updated(e,{value:t,oldValue:n},{transition:s}){!t!=!n&&(s?t?(s.beforeEnter(e),Nt(e,!0),s.enter(e)):s.leave(e,()=>{Nt(e,!1)}):Nt(e,t))},beforeUnmount(e,{value:t}){Nt(e,t)}};function Nt(e,t){e.style.display=t?e[Rn]:"none",e[po]=!t}const Gc=Symbol(""),Yc=/(^|;)\s*display\s*:/;function Xc(e,t,n){const s=e.style,r=re(n);let i=!1;if(n&&!r){if(t)if(re(t))for(const o of t.split(";")){const l=o.slice(0,o.indexOf(":")).trim();n[l]==null&&_n(s,l,"")}else for(const o in t)n[o]==null&&_n(s,o,"");for(const o in n)o==="display"&&(i=!0),_n(s,o,n[o])}else if(r){if(t!==n){const o=s[Gc];o&&(n+=";"+o),s.cssText=n,i=Yc.test(n)}}else t&&e.removeAttribute("style");Rn in e&&(e[Rn]=i?s.display:"",e[po]&&(s.display="none"))}const Rr=/\s*!important$/;function _n(e,t,n){if(U(n))n.forEach(s=>_n(e,t,s));else if(n==null&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{const s=Jc(e,t);Rr.test(n)?e.setProperty(st(s),n.replace(Rr,""),"important"):e[s]=n}}const Or=["Webkit","Moz","ms"],is={};function Jc(e,t){const n=is[t];if(n)return n;let s=Le(t);if(s!=="filter"&&s in e)return is[t]=s;s=Pn(s);for(let r=0;ros||(ta.then(()=>os=0),os=Date.now());function sa(e,t){const n=s=>{if(!s._vts)s._vts=Date.now();else if(s._vts<=n.attached)return;He(ra(s,n.value),t,5,[s])};return n.value=e,n.attached=na(),n}function ra(e,t){if(U(t)){const n=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0},t.map(s=>r=>!r._stopped&&s&&s(r))}else return t}const Fr=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,ia=(e,t,n,s,r,i)=>{const o=r==="svg";t==="class"?qc(e,s,o):t==="style"?Xc(e,n,s):Jt(t)?Ls(t)||Zc(e,t,n,s,i):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):oa(e,t,s,o))?(Lr(e,t,s),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&Pr(e,t,s,o,i,t!=="value")):e._isVueCE&&(/[A-Z]/.test(t)||!re(s))?Lr(e,Le(t),s,i,t):(t==="true-value"?e._trueValue=s:t==="false-value"&&(e._falseValue=s),Pr(e,t,s,o))};function oa(e,t,n,s){if(s)return!!(t==="innerHTML"||t==="textContent"||t in e&&Fr(t)&&q(n));if(t==="spellcheck"||t==="draggable"||t==="translate"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA")return!1;if(t==="width"||t==="height"){const r=e.tagName;if(r==="IMG"||r==="VIDEO"||r==="CANVAS"||r==="SOURCE")return!1}return Fr(t)&&re(n)?!1:t in e}const la=["ctrl","shift","alt","meta"],ca={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&e.button!==0,middle:e=>"button"in e&&e.button!==1,right:e=>"button"in e&&e.button!==2,exact:(e,t)=>la.some(n=>e[`${n}Key`]&&!t.includes(n))},Rf=(e,t)=>{const n=e._withMods||(e._withMods={}),s=t.join(".");return n[s]||(n[s]=(r,...i)=>{for(let o=0;o{const n=e._withKeys||(e._withKeys={}),s=t.join(".");return n[s]||(n[s]=r=>{if(!("key"in r))return;const i=st(r.key);if(t.some(o=>o===i||aa[o]===i))return e(r)})},fa=oe({patchProp:ia},$c);let ls,Hr=!1;function ua(){return ls=Hr?ls:uc(fa),Hr=!0,ls}const Mf=(...e)=>{const t=ua().createApp(...e),{mount:n}=t;return t.mount=s=>{const r=ha(s);if(r)return n(r,!0,da(r))},t};function da(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function ha(e){return re(e)?document.querySelector(e):e}const Pf=(e,t)=>{const n=e.__vccOpts||e;for(const[s,r]of t)n[s]=r;return n},pa="modulepreload",ga=function(e){return"/ran/"+e},Dr={},Lf=function(t,n,s){let r=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));r=Promise.allSettled(n.map(c=>{if(c=ga(c),c in Dr)return;Dr[c]=!0;const u=c.endsWith(".css"),a=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${a}`))return;const h=document.createElement("link");if(h.rel=u?"stylesheet":pa,u||(h.as="script"),h.crossOrigin="",h.href=c,l&&h.setAttribute("nonce",l),document.head.appendChild(h),u)return new Promise((y,_)=>{h.addEventListener("load",y),h.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return r.then(o=>{for(const l of o||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})},ma=window.__VP_SITE_DATA__;function Ys(e){return ei()?(Go(e),!0):!1}function tt(e){return typeof e=="function"?e():yi(e)}const go=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const ya=Object.prototype.toString,_a=e=>ya.call(e)==="[object Object]",mo=()=>{},$r=ba();function ba(){var e,t;return go&&((e=window==null?void 0:window.navigator)==null?void 0:e.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((t=window==null?void 0:window.navigator)==null?void 0:t.maxTouchPoints)>2&&/iPad|Macintosh/.test(window==null?void 0:window.navigator.userAgent))}function va(e,t){function n(...s){return new Promise((r,i)=>{Promise.resolve(e(()=>t.apply(this,s),{fn:t,thisArg:this,args:s})).then(r).catch(i)})}return n}const yo=e=>e();function wa(e=yo){const t=de(!0);function n(){t.value=!1}function s(){t.value=!0}const r=(...i)=>{t.value&&e(...i)};return{isActive:Hn(t),pause:n,resume:s,eventFilter:r}}function Sa(e){return Wn()}function _o(...e){if(e.length!==1)return vl(...e);const t=e[0];return typeof t=="function"?Hn(yl(()=>({get:t,set:mo}))):de(t)}function xa(e,t,n={}){const{eventFilter:s=yo,...r}=n;return Fe(e,va(s,t),r)}function Ea(e,t,n={}){const{eventFilter:s,...r}=n,{eventFilter:i,pause:o,resume:l,isActive:c}=wa(s);return{stop:xa(e,t,{...r,eventFilter:i}),pause:o,resume:l,isActive:c}}function Xs(e,t=!0,n){Sa()?Ot(e,n):t?e():$n(e)}const qe=go?window:void 0;function bo(e){var t;const n=tt(e);return(t=n==null?void 0:n.$el)!=null?t:n}function Rt(...e){let t,n,s,r;if(typeof e[0]=="string"||Array.isArray(e[0])?([n,s,r]=e,t=qe):[t,n,s,r]=e,!t)return mo;Array.isArray(n)||(n=[n]),Array.isArray(s)||(s=[s]);const i=[],o=()=>{i.forEach(a=>a()),i.length=0},l=(a,h,y,_)=>(a.addEventListener(h,y,_),()=>a.removeEventListener(h,y,_)),c=Fe(()=>[bo(t),tt(r)],([a,h])=>{if(o(),!a)return;const y=_a(h)?{...h}:h;i.push(...n.flatMap(_=>s.map(R=>l(a,_,R,y))))},{immediate:!0,flush:"post"}),u=()=>{c(),o()};return Ys(u),u}function Ta(e){return typeof e=="function"?e:typeof e=="string"?t=>t.key===e:Array.isArray(e)?t=>e.includes(t.key):()=>!0}function If(...e){let t,n,s={};e.length===3?(t=e[0],n=e[1],s=e[2]):e.length===2?typeof e[1]=="object"?(t=!0,n=e[0],s=e[1]):(t=e[0],n=e[1]):(t=!0,n=e[0]);const{target:r=qe,eventName:i="keydown",passive:o=!1,dedupe:l=!1}=s,c=Ta(t);return Rt(r,i,a=>{a.repeat&&tt(l)||c(a)&&n(a)},o)}function Ca(){const e=de(!1),t=Wn();return t&&Ot(()=>{e.value=!0},t),e}function Aa(e){const t=Ca();return ie(()=>(t.value,!!e()))}function vo(e,t={}){const{window:n=qe}=t,s=Aa(()=>n&&"matchMedia"in n&&typeof n.matchMedia=="function");let r;const i=de(!1),o=u=>{i.value=u.matches},l=()=>{r&&("removeEventListener"in r?r.removeEventListener("change",o):r.removeListener(o))},c=Zi(()=>{s.value&&(l(),r=n.matchMedia(tt(e)),"addEventListener"in r?r.addEventListener("change",o):r.addListener(o),i.value=r.matches)});return Ys(()=>{c(),l(),r=void 0}),i}const fn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},un="__vueuse_ssr_handlers__",Ra=Oa();function Oa(){return un in fn||(fn[un]=fn[un]||{}),fn[un]}function wo(e,t){return Ra[e]||t}function So(e){return vo("(prefers-color-scheme: dark)",e)}function Ma(e){return e==null?"any":e instanceof Set?"set":e instanceof Map?"map":e instanceof Date?"date":typeof e=="boolean"?"boolean":typeof e=="string"?"string":typeof e=="object"?"object":Number.isNaN(e)?"any":"number"}const Pa={boolean:{read:e=>e==="true",write:e=>String(e)},object:{read:e=>JSON.parse(e),write:e=>JSON.stringify(e)},number:{read:e=>Number.parseFloat(e),write:e=>String(e)},any:{read:e=>e,write:e=>String(e)},string:{read:e=>e,write:e=>String(e)},map:{read:e=>new Map(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e.entries()))},set:{read:e=>new Set(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e))},date:{read:e=>new Date(e),write:e=>e.toISOString()}},jr="vueuse-storage";function La(e,t,n,s={}){var r;const{flush:i="pre",deep:o=!0,listenToStorageChanges:l=!0,writeDefaults:c=!0,mergeDefaults:u=!1,shallow:a,window:h=qe,eventFilter:y,onError:_=b=>{console.error(b)},initOnMounted:R}=s,T=(a?gi:de)(typeof t=="function"?t():t);if(!n)try{n=wo("getDefaultStorage",()=>{var b;return(b=qe)==null?void 0:b.localStorage})()}catch(b){_(b)}if(!n)return T;const G=tt(t),$=Ma(G),W=(r=s.serializer)!=null?r:Pa[$],{pause:g,resume:p}=Ea(T,()=>N(T.value),{flush:i,deep:o,eventFilter:y});h&&l&&Xs(()=>{n instanceof Storage?Rt(h,"storage",j):Rt(h,jr,A),R&&j()}),R||j();function M(b,I){if(h){const S={key:e,oldValue:b,newValue:I,storageArea:n};h.dispatchEvent(n instanceof Storage?new StorageEvent("storage",S):new CustomEvent(jr,{detail:S}))}}function N(b){try{const I=n.getItem(e);if(b==null)M(I,null),n.removeItem(e);else{const S=W.write(b);I!==S&&(n.setItem(e,S),M(I,S))}}catch(I){_(I)}}function H(b){const I=b?b.newValue:n.getItem(e);if(I==null)return c&&G!=null&&n.setItem(e,W.write(G)),G;if(!b&&u){const S=W.read(I);return typeof u=="function"?u(S,G):$==="object"&&!Array.isArray(S)?{...G,...S}:S}else return typeof I!="string"?I:W.read(I)}function j(b){if(!(b&&b.storageArea!==n)){if(b&&b.key==null){T.value=G;return}if(!(b&&b.key!==e)){g();try{(b==null?void 0:b.newValue)!==W.write(T.value)&&(T.value=H(b))}catch(I){_(I)}finally{b?$n(p):p()}}}}function A(b){j(b.detail)}return T}const Ia="*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}";function Na(e={}){const{selector:t="html",attribute:n="class",initialValue:s="auto",window:r=qe,storage:i,storageKey:o="vueuse-color-scheme",listenToStorageChanges:l=!0,storageRef:c,emitAuto:u,disableTransition:a=!0}=e,h={auto:"",light:"light",dark:"dark",...e.modes||{}},y=So({window:r}),_=ie(()=>y.value?"dark":"light"),R=c||(o==null?_o(s):La(o,s,i,{window:r,listenToStorageChanges:l})),T=ie(()=>R.value==="auto"?_.value:R.value),G=wo("updateHTMLAttrs",(p,M,N)=>{const H=typeof p=="string"?r==null?void 0:r.document.querySelector(p):bo(p);if(!H)return;const j=new Set,A=new Set;let b=null;if(M==="class"){const S=N.split(/\s/g);Object.values(h).flatMap(B=>(B||"").split(/\s/g)).filter(Boolean).forEach(B=>{S.includes(B)?j.add(B):A.add(B)})}else b={key:M,value:N};if(j.size===0&&A.size===0&&b===null)return;let I;a&&(I=r.document.createElement("style"),I.appendChild(document.createTextNode(Ia)),r.document.head.appendChild(I));for(const S of j)H.classList.add(S);for(const S of A)H.classList.remove(S);b&&H.setAttribute(b.key,b.value),a&&(r.getComputedStyle(I).opacity,document.head.removeChild(I))});function $(p){var M;G(t,n,(M=h[p])!=null?M:p)}function W(p){e.onChanged?e.onChanged(p,$):$(p)}Fe(T,W,{flush:"post",immediate:!0}),Xs(()=>W(T.value));const g=ie({get(){return u?R.value:T.value},set(p){R.value=p}});try{return Object.assign(g,{store:R,system:_,state:T})}catch{return g}}function Fa(e={}){const{valueDark:t="dark",valueLight:n="",window:s=qe}=e,r=Na({...e,onChanged:(l,c)=>{var u;e.onChanged?(u=e.onChanged)==null||u.call(e,l==="dark",c,l):c(l)},modes:{dark:t,light:n}}),i=ie(()=>r.system?r.system.value:So({window:s}).value?"dark":"light");return ie({get(){return r.value==="dark"},set(l){const c=l?"dark":"light";i.value===c?r.value="auto":r.value=c}})}function cs(e){return typeof Window<"u"&&e instanceof Window?e.document.documentElement:typeof Document<"u"&&e instanceof Document?e.documentElement:e}function xo(e){const t=window.getComputedStyle(e);if(t.overflowX==="scroll"||t.overflowY==="scroll"||t.overflowX==="auto"&&e.clientWidth1?!0:(t.preventDefault&&t.preventDefault(),!1)}const as=new WeakMap;function Nf(e,t=!1){const n=de(t);let s=null,r="";Fe(_o(e),l=>{const c=cs(tt(l));if(c){const u=c;if(as.get(u)||as.set(u,u.style.overflow),u.style.overflow!=="hidden"&&(r=u.style.overflow),u.style.overflow==="hidden")return n.value=!0;if(n.value)return u.style.overflow="hidden"}},{immediate:!0});const i=()=>{const l=cs(tt(e));!l||n.value||($r&&(s=Rt(l,"touchmove",c=>{Ha(c)},{passive:!1})),l.style.overflow="hidden",n.value=!0)},o=()=>{const l=cs(tt(e));!l||!n.value||($r&&(s==null||s()),l.style.overflow=r,as.delete(l),n.value=!1)};return Ys(o),ie({get(){return n.value},set(l){l?i():o()}})}function Ff(e={}){const{window:t=qe,behavior:n="auto"}=e;if(!t)return{x:de(0),y:de(0)};const s=de(t.scrollX),r=de(t.scrollY),i=ie({get(){return s.value},set(l){scrollTo({left:l,behavior:n})}}),o=ie({get(){return r.value},set(l){scrollTo({top:l,behavior:n})}});return Rt(t,"scroll",()=>{s.value=t.scrollX,r.value=t.scrollY},{capture:!1,passive:!0}),{x:i,y:o}}function Hf(e={}){const{window:t=qe,initialWidth:n=Number.POSITIVE_INFINITY,initialHeight:s=Number.POSITIVE_INFINITY,listenOrientation:r=!0,includeScrollbar:i=!0,type:o="inner"}=e,l=de(n),c=de(s),u=()=>{t&&(o==="outer"?(l.value=t.outerWidth,c.value=t.outerHeight):i?(l.value=t.innerWidth,c.value=t.innerHeight):(l.value=t.document.documentElement.clientWidth,c.value=t.document.documentElement.clientHeight))};if(u(),Xs(u),Rt("resize",u,{passive:!0}),r){const a=vo("(orientation: portrait)");Fe(a,()=>u())}return{width:l,height:c}}const fs={BASE_URL:"/ran/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};var us={};const Eo=/^(?:[a-z]+:|\/\/)/i,Da="vitepress-theme-appearance",$a=/#.*$/,ja=/[?#].*$/,Va=/(?:(^|\/)index)?\.(?:md|html)$/,ge=typeof document<"u",To={relativePath:"404.md",filePath:"",title:"404",description:"Not Found",headers:[],frontmatter:{sidebar:!1,layout:"page"},lastUpdated:0,isNotFound:!0};function ka(e,t,n=!1){if(t===void 0)return!1;if(e=Vr(`/${e}`),n)return new RegExp(t).test(e);if(Vr(t)!==e)return!1;const s=t.match($a);return s?(ge?location.hash:"")===s[0]:!0}function Vr(e){return decodeURI(e).replace(ja,"").replace(Va,"$1")}function Ua(e){return Eo.test(e)}function Ba(e,t){return Object.keys((e==null?void 0:e.locales)||{}).find(n=>n!=="root"&&!Ua(n)&&ka(t,`/${n}/`,!0))||"root"}function Wa(e,t){var s,r,i,o,l,c,u;const n=Ba(e,t);return Object.assign({},e,{localeIndex:n,lang:((s=e.locales[n])==null?void 0:s.lang)??e.lang,dir:((r=e.locales[n])==null?void 0:r.dir)??e.dir,title:((i=e.locales[n])==null?void 0:i.title)??e.title,titleTemplate:((o=e.locales[n])==null?void 0:o.titleTemplate)??e.titleTemplate,description:((l=e.locales[n])==null?void 0:l.description)??e.description,head:Ao(e.head,((c=e.locales[n])==null?void 0:c.head)??[]),themeConfig:{...e.themeConfig,...(u=e.locales[n])==null?void 0:u.themeConfig}})}function Co(e,t){const n=t.title||e.title,s=t.titleTemplate??e.titleTemplate;if(typeof s=="string"&&s.includes(":title"))return s.replace(/:title/g,n);const r=Ka(e.title,s);return n===r.slice(3)?n:`${n}${r}`}function Ka(e,t){return t===!1?"":t===!0||t===void 0?` | ${e}`:e===t?"":` | ${t}`}function qa(e,t){const[n,s]=t;if(n!=="meta")return!1;const r=Object.entries(s)[0];return r==null?!1:e.some(([i,o])=>i===n&&o[r[0]]===r[1])}function Ao(e,t){return[...e.filter(n=>!qa(t,n)),...t]}const Ga=/[\u0000-\u001F"#$&*+,:;<=>?[\]^`{|}\u007F]/g,Ya=/^[a-z]:/i;function kr(e){const t=Ya.exec(e),n=t?t[0]:"";return n+e.slice(n.length).replace(Ga,"_").replace(/(^|\/)_+(?=[^/]*$)/,"$1")}const ds=new Set;function Xa(e){if(ds.size===0){const n=typeof process=="object"&&(us==null?void 0:us.VITE_EXTRA_EXTENSIONS)||(fs==null?void 0:fs.VITE_EXTRA_EXTENSIONS)||"";("3g2,3gp,aac,ai,apng,au,avif,bin,bmp,cer,class,conf,crl,css,csv,dll,doc,eps,epub,exe,gif,gz,ics,ief,jar,jpe,jpeg,jpg,js,json,jsonld,m4a,man,mid,midi,mjs,mov,mp2,mp3,mp4,mpe,mpeg,mpg,mpp,oga,ogg,ogv,ogx,opus,otf,p10,p7c,p7m,p7s,pdf,png,ps,qt,roff,rtf,rtx,ser,svg,t,tif,tiff,tr,ts,tsv,ttf,txt,vtt,wav,weba,webm,webp,woff,woff2,xhtml,xml,yaml,yml,zip"+(n&&typeof n=="string"?","+n:"")).split(",").forEach(s=>ds.add(s))}const t=e.split(".").pop();return t==null||!ds.has(t.toLowerCase())}const Ja=Symbol(),mt=gi(ma);function Df(e){const t=ie(()=>Wa(mt.value,e.data.relativePath)),n=t.value.appearance,s=n==="force-dark"?de(!0):n?Fa({storageKey:Da,initialValue:()=>n==="dark"?"dark":"auto",...typeof n=="object"?n:{}}):de(!1),r=de(ge?location.hash:"");return ge&&window.addEventListener("hashchange",()=>{r.value=location.hash}),Fe(()=>e.data,()=>{r.value=ge?location.hash:""}),{site:t,theme:ie(()=>t.value.themeConfig),page:ie(()=>e.data),frontmatter:ie(()=>e.data.frontmatter),params:ie(()=>e.data.params),lang:ie(()=>t.value.lang),dir:ie(()=>e.data.frontmatter.dir||t.value.dir),localeIndex:ie(()=>t.value.localeIndex||"root"),title:ie(()=>Co(t.value,e.data)),description:ie(()=>e.data.description||t.value.description),isDark:s,hash:ie(()=>r.value)}}function za(){const e=At(Ja);if(!e)throw new Error("vitepress data not properly injected in app");return e}function Qa(e,t){return`${e}${t}`.replace(/\/+/g,"/")}function Ur(e){return Eo.test(e)||!e.startsWith("/")?e:Qa(mt.value.base,e)}function Za(e){let t=e.replace(/\.html$/,"");if(t=decodeURIComponent(t),t=t.replace(/\/$/,"/index"),ge){const n="/ran/";t=kr(t.slice(n.length).replace(/\//g,"_")||"index")+".md";let s=__VP_HASH_MAP__[t.toLowerCase()];if(s||(t=t.endsWith("_index.md")?t.slice(0,-9)+".md":t.slice(0,-3)+"_index.md",s=__VP_HASH_MAP__[t.toLowerCase()]),!s)return null;t=`${n}assets/${t}.${s}.js`}else t=`./${kr(t.slice(1).replace(/\//g,"_"))}.md.js`;return t}let bn=[];function $f(e){bn.push(e),kn(()=>{bn=bn.filter(t=>t!==e)})}function ef(){let e=mt.value.scrollOffset,t=0,n=24;if(typeof e=="object"&&"padding"in e&&(n=e.padding,e=e.selector),typeof e=="number")t=e;else if(typeof e=="string")t=Br(e,n);else if(Array.isArray(e))for(const s of e){const r=Br(s,n);if(r){t=r;break}}return t}function Br(e,t){const n=document.querySelector(e);if(!n)return 0;const s=n.getBoundingClientRect().bottom;return s<0?0:s+t}const tf=Symbol(),Ro="http://a.com",nf=()=>({path:"/",component:null,data:To});function jf(e,t){const n=Fn(nf()),s={route:n,go:r};async function r(l=ge?location.href:"/"){var c,u;l=hs(l),await((c=s.onBeforeRouteChange)==null?void 0:c.call(s,l))!==!1&&(ge&&l!==hs(location.href)&&(history.replaceState({scrollPosition:window.scrollY},""),history.pushState({},"",l)),await o(l),await((u=s.onAfterRouteChanged)==null?void 0:u.call(s,l)))}let i=null;async function o(l,c=0,u=!1){var y,_;if(await((y=s.onBeforePageLoad)==null?void 0:y.call(s,l))===!1)return;const a=new URL(l,Ro),h=i=a.pathname;try{let R=await e(h);if(!R)throw new Error(`Page not found: ${h}`);if(i===h){i=null;const{default:T,__pageData:G}=R;if(!T)throw new Error(`Invalid route component: ${T}`);await((_=s.onAfterPageLoad)==null?void 0:_.call(s,l)),n.path=ge?h:Ur(h),n.component=gn(T),n.data=gn(G),ge&&$n(()=>{let $=mt.value.base+G.relativePath.replace(/(?:(^|\/)index)?\.md$/,"$1");if(!mt.value.cleanUrls&&!$.endsWith("/")&&($+=".html"),$!==a.pathname&&(a.pathname=$,l=$+a.search+a.hash,history.replaceState({},"",l)),a.hash&&!c){let W=null;try{W=document.getElementById(decodeURIComponent(a.hash).slice(1))}catch(g){console.warn(g)}if(W){Wr(W,a.hash);return}}window.scrollTo(0,c)})}}catch(R){if(!/fetch|Page not found/.test(R.message)&&!/^\/404(\.html|\/)?$/.test(l)&&console.error(R),!u)try{const T=await fetch(mt.value.base+"hashmap.json");window.__VP_HASH_MAP__=await T.json(),await o(l,c,!0);return}catch{}if(i===h){i=null,n.path=ge?h:Ur(h),n.component=t?gn(t):null;const T=ge?h.replace(/(^|\/)$/,"$1index").replace(/(\.html)?$/,".md").replace(/^\//,""):"404.md";n.data={...To,relativePath:T}}}}return ge&&(history.state===null&&history.replaceState({},""),window.addEventListener("click",l=>{if(l.defaultPrevented||!(l.target instanceof Element)||l.target.closest("button")||l.button!==0||l.ctrlKey||l.shiftKey||l.altKey||l.metaKey)return;const c=l.target.closest("a");if(!c||c.closest(".vp-raw")||c.hasAttribute("download")||c.hasAttribute("target"))return;const u=c.getAttribute("href")??(c instanceof SVGAElement?c.getAttribute("xlink:href"):null);if(u==null)return;const{href:a,origin:h,pathname:y,hash:_,search:R}=new URL(u,c.baseURI),T=new URL(location.href);h===T.origin&&Xa(y)&&(l.preventDefault(),y===T.pathname&&R===T.search?(_!==T.hash&&(history.pushState({},"",a),window.dispatchEvent(new HashChangeEvent("hashchange",{oldURL:T.href,newURL:a}))),_?Wr(c,_,c.classList.contains("header-anchor")):window.scrollTo(0,0)):r(a))},{capture:!0}),window.addEventListener("popstate",async l=>{var c;l.state!==null&&(await o(hs(location.href),l.state&&l.state.scrollPosition||0),(c=s.onAfterRouteChanged)==null||c.call(s,location.href))}),window.addEventListener("hashchange",l=>{l.preventDefault()})),s}function sf(){const e=At(tf);if(!e)throw new Error("useRouter() is called without provider.");return e}function Oo(){return sf().route}function Wr(e,t,n=!1){let s=null;try{s=e.classList.contains("header-anchor")?e:document.getElementById(decodeURIComponent(t).slice(1))}catch(r){console.warn(r)}if(s){let r=function(){!n||Math.abs(o-window.scrollY)>window.innerHeight?window.scrollTo(0,o):window.scrollTo({left:0,top:o,behavior:"smooth"})};const i=parseInt(window.getComputedStyle(s).paddingTop,10),o=window.scrollY+s.getBoundingClientRect().top-ef()+i;requestAnimationFrame(r)}}function hs(e){const t=new URL(e,Ro);return t.pathname=t.pathname.replace(/(^|\/)index(\.html)?$/,"$1"),mt.value.cleanUrls?t.pathname=t.pathname.replace(/\.html$/,""):!t.pathname.endsWith("/")&&!t.pathname.endsWith(".html")&&(t.pathname+=".html"),t.pathname+t.search+t.hash}const dn=()=>bn.forEach(e=>e()),Vf=Li({name:"VitePressContent",props:{as:{type:[Object,String],default:"div"}},setup(e){const t=Oo(),{frontmatter:n,site:s}=za();return Fe(n,dn,{deep:!0,flush:"post"}),()=>Os(e.as,s.value.contentProps??{style:{position:"relative"}},[t.component?Os(t.component,{onVnodeMounted:dn,onVnodeUpdated:dn,onVnodeUnmounted:dn}):"404 Page Not Found"])}}),kf=(e,t,n)=>{const s=e[t];return s?typeof s=="function"?s():Promise.resolve(s):new Promise((r,i)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(i.bind(null,new Error("Unknown variable dynamic import: "+t+(t.split("/").length!==n?". Note that variables only represent file names one level deep.":""))))})},Uf=Li({setup(e,{slots:t}){const n=de(!1);return Ot(()=>{n.value=!0}),()=>n.value&&t.default?t.default():null}});function Bf(){ge&&window.addEventListener("click",e=>{var n;const t=e.target;if(t.matches(".vp-code-group input")){const s=(n=t.parentElement)==null?void 0:n.parentElement;if(!s)return;const r=Array.from(s.querySelectorAll("input")).indexOf(t);if(r<0)return;const i=s.querySelector(".blocks");if(!i)return;const o=Array.from(i.children).find(u=>u.classList.contains("active"));if(!o)return;const l=i.children[r];if(!l||o===l)return;o.classList.remove("active"),l.classList.add("active");const c=s==null?void 0:s.querySelector(`label[for="${t.id}"]`);c==null||c.scrollIntoView({block:"nearest"})}})}function Wf(){if(ge){const e=new WeakMap;window.addEventListener("click",t=>{var s;const n=t.target;if(n.matches('div[class*="language-"] > button.copy')){const r=n.parentElement,i=(s=n.nextElementSibling)==null?void 0:s.nextElementSibling;if(!r||!i)return;const o=/language-(shellscript|shell|bash|sh|zsh)/.test(r.className),l=[".vp-copy-ignore",".diff.remove"],c=i.cloneNode(!0);c.querySelectorAll(l.join(",")).forEach(a=>a.remove());let u=c.textContent||"";o&&(u=u.replace(/^ *(\$|>) /gm,"").trim()),rf(u).then(()=>{n.classList.add("copied"),clearTimeout(e.get(n));const a=setTimeout(()=>{n.classList.remove("copied"),n.blur(),e.delete(n)},2e3);e.set(n,a)})}})}}async function rf(e){try{return navigator.clipboard.writeText(e)}catch{const t=document.createElement("textarea"),n=document.activeElement;t.value=e,t.setAttribute("readonly",""),t.style.contain="strict",t.style.position="absolute",t.style.left="-9999px",t.style.fontSize="12pt";const s=document.getSelection(),r=s?s.rangeCount>0&&s.getRangeAt(0):null;document.body.appendChild(t),t.select(),t.selectionStart=0,t.selectionEnd=e.length,document.execCommand("copy"),document.body.removeChild(t),r&&(s.removeAllRanges(),s.addRange(r)),n&&n.focus()}}function Kf(e,t){let n=!0,s=[];const r=i=>{if(n){n=!1,i.forEach(l=>{const c=ps(l);for(const u of document.head.children)if(u.isEqualNode(c)){s.push(u);return}});return}const o=i.map(ps);s.forEach((l,c)=>{const u=o.findIndex(a=>a==null?void 0:a.isEqualNode(l??null));u!==-1?delete o[u]:(l==null||l.remove(),delete s[c])}),o.forEach(l=>l&&document.head.appendChild(l)),s=[...s,...o].filter(Boolean)};Zi(()=>{const i=e.data,o=t.value,l=i&&i.description,c=i&&i.frontmatter.head||[],u=Co(o,i);u!==document.title&&(document.title=u);const a=l||o.description;let h=document.querySelector("meta[name=description]");h?h.getAttribute("content")!==a&&h.setAttribute("content",a):ps(["meta",{name:"description",content:a}]),r(Ao(o.head,lf(c)))})}function ps([e,t,n]){const s=document.createElement(e);for(const r in t)s.setAttribute(r,t[r]);return n&&(s.innerHTML=n),e==="script"&&!t.async&&(s.async=!1),s}function of(e){return e[0]==="meta"&&e[1]&&e[1].name==="description"}function lf(e){return e.filter(t=>!of(t))}const gs=new Set,Mo=()=>document.createElement("link"),cf=e=>{const t=Mo();t.rel="prefetch",t.href=e,document.head.appendChild(t)},af=e=>{const t=new XMLHttpRequest;t.open("GET",e,t.withCredentials=!0),t.send()};let hn;const ff=ge&&(hn=Mo())&&hn.relList&&hn.relList.supports&&hn.relList.supports("prefetch")?cf:af;function qf(){if(!ge||!window.IntersectionObserver)return;let e;if((e=navigator.connection)&&(e.saveData||/2g/.test(e.effectiveType)))return;const t=window.requestIdleCallback||setTimeout;let n=null;const s=()=>{n&&n.disconnect(),n=new IntersectionObserver(i=>{i.forEach(o=>{if(o.isIntersecting){const l=o.target;n.unobserve(l);const{pathname:c}=l;if(!gs.has(c)){gs.add(c);const u=Za(c);u&&ff(u)}}})}),t(()=>{document.querySelectorAll("#app a").forEach(i=>{const{hostname:o,pathname:l}=new URL(i.href instanceof SVGAnimatedString?i.href.animVal:i.href,i.baseURI),c=l.match(/\.\w+$/);c&&c[0]!==".html"||i.target!=="_blank"&&o===location.hostname&&(l!==location.pathname?n.observe(i):gs.add(l))})})};Ot(s);const r=Oo();Fe(()=>r.path,s),kn(()=>{n&&n.disconnect()})}export{df as $,ef as A,gf as B,yf as C,gi as D,$f as E,Se as F,he as G,Eo as H,mf as I,Oo as J,Cc as K,At as L,Hf as M,Fs as N,If as O,$n as P,Ff as Q,ge as R,Hn as S,Cf as T,Fn as U,rc as V,Fi as W,pf as X,hf as Y,Af as Z,Pf as _,lo as a,Os as a0,ei as a1,Go as a2,Ef as a3,sf as a4,_f as a5,Nf as a6,vf as a7,Of as a8,Rf as a9,wf as aa,uf as ab,ae as ac,Wn as ad,gt as ae,kf as af,Lf as ag,Kf as ah,tf as ai,Df as aj,Ja as ak,Vf as al,Uf as am,mt as an,Mf as ao,jf as ap,Za as aq,qf as ar,Wf as as,Bf as at,As as b,xf as c,Li as d,Tf as e,Xa as f,Ur as g,ie as h,Ua as i,oo as j,yi as k,ka as l,vo as m,Hs as n,Cs as o,de as p,Fe as q,bf as r,Zi as s,qo as t,za as u,Ot as v,Rl as w,kn as x,Sf as y,Wl as z}; diff --git a/assets/chunks/framework.eq-HTtE3.js b/assets/chunks/framework.eq-HTtE3.js deleted file mode 100644 index 83aaa52258..0000000000 --- a/assets/chunks/framework.eq-HTtE3.js +++ /dev/null @@ -1,18 +0,0 @@ -/** -* @vue/shared v3.5.11 -* (c) 2018-present Yuxi (Evan) You and Vue contributors -* @license MIT -**//*! #__NO_SIDE_EFFECTS__ */function Ls(e){const t=Object.create(null);for(const n of e.split(","))t[n]=1;return n=>n in t}const Z={},Et=[],Ve=()=>{},Uo=()=>!1,Jt=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),Ns=e=>e.startsWith("onUpdate:"),le=Object.assign,Fs=(e,t)=>{const n=e.indexOf(t);n>-1&&e.splice(n,1)},Bo=Object.prototype.hasOwnProperty,z=(e,t)=>Bo.call(e,t),U=Array.isArray,xt=e=>In(e)==="[object Map]",Zr=e=>In(e)==="[object Set]",q=e=>typeof e=="function",re=e=>typeof e=="string",st=e=>typeof e=="symbol",ne=e=>e!==null&&typeof e=="object",ei=e=>(ne(e)||q(e))&&q(e.then)&&q(e.catch),ti=Object.prototype.toString,In=e=>ti.call(e),Wo=e=>In(e).slice(8,-1),ni=e=>In(e)==="[object Object]",Hs=e=>re(e)&&e!=="NaN"&&e[0]!=="-"&&""+parseInt(e,10)===e,Tt=Ls(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),Pn=e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))},Ko=/-(\w)/g,Pe=Pn(e=>e.replace(Ko,(t,n)=>n?n.toUpperCase():"")),qo=/\B([A-Z])/g,rt=Pn(e=>e.replace(qo,"-$1").toLowerCase()),Ln=Pn(e=>e.charAt(0).toUpperCase()+e.slice(1)),mn=Pn(e=>e?`on${Ln(e)}`:""),tt=(e,t)=>!Object.is(e,t),Qn=(e,...t)=>{for(let n=0;n{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:s,value:n})},Go=e=>{const t=parseFloat(e);return isNaN(t)?e:t},Yo=e=>{const t=re(e)?Number(e):NaN;return isNaN(t)?e:t};let rr;const ri=()=>rr||(rr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function Ds(e){if(U(e)){const t={};for(let n=0;n{if(n){const s=n.split(Jo);s.length>1&&(t[s[0].trim()]=s[1].trim())}}),t}function $s(e){let t="";if(re(e))t=e;else if(U(e))for(let n=0;n!!(e&&e.__v_isRef===!0),tl=e=>re(e)?e:e==null?"":U(e)||ne(e)&&(e.toString===ti||!q(e.toString))?oi(e)?tl(e.value):JSON.stringify(e,li,2):String(e),li=(e,t)=>oi(t)?li(e,t.value):xt(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((n,[s,r],i)=>(n[Zn(s,i)+" =>"]=r,n),{})}:Zr(t)?{[`Set(${t.size})`]:[...t.values()].map(n=>Zn(n))}:st(t)?Zn(t):ne(t)&&!U(t)&&!ni(t)?String(t):t,Zn=(e,t="")=>{var n;return st(e)?`Symbol(${(n=e.description)!=null?n:t})`:e};/** -* @vue/reactivity v3.5.11 -* (c) 2018-present Yuxi (Evan) You and Vue contributors -* @license MIT -**/let ve;class ci{constructor(t=!1){this.detached=t,this._active=!0,this.effects=[],this.cleanups=[],this._isPaused=!1,this.parent=ve,!t&&ve&&(this.index=(ve.scopes||(ve.scopes=[])).push(this)-1)}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let t,n;if(this.scopes)for(t=0,n=this.scopes.length;t0)return;if($t){let t=$t;for($t=void 0;t;){const n=t.next;t.next=void 0,t.flags&=-9,t=n}}let e;for(;Dt;){let t=Dt;for(Dt=void 0;t;){const n=t.next;if(t.next=void 0,t.flags&=-9,t.flags&1)try{t.trigger()}catch(s){e||(e=s)}t=n}}if(e)throw e}function hi(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function pi(e){let t,n=e.depsTail,s=n;for(;s;){const r=s.prevDep;s.version===-1?(s===n&&(n=r),ks(s),sl(s)):t=s,s.dep.activeLink=s.prevActiveLink,s.prevActiveLink=void 0,s=r}e.deps=t,e.depsTail=n}function vs(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(gi(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function gi(e){if(e.flags&4&&!(e.flags&16)||(e.flags&=-17,e.globalVersion===Bt))return;e.globalVersion=Bt;const t=e.dep;if(e.flags|=2,t.version>0&&!e.isSSR&&e.deps&&!vs(e)){e.flags&=-3;return}const n=te,s=Ne;te=e,Ne=!0;try{hi(e);const r=e.fn(e._value);(t.version===0||tt(r,e._value))&&(e._value=r,t.version++)}catch(r){throw t.version++,r}finally{te=n,Ne=s,pi(e),e.flags&=-3}}function ks(e,t=!1){const{dep:n,prevSub:s,nextSub:r}=e;if(s&&(s.nextSub=r,e.prevSub=void 0),r&&(r.prevSub=s,e.nextSub=void 0),n.subs===e&&(n.subs=s),!n.subs&&n.computed){n.computed.flags&=-5;for(let i=n.computed.deps;i;i=i.nextDep)ks(i,!0)}!t&&!--n.sc&&n.map&&n.map.delete(n.key)}function sl(e){const{prevDep:t,nextDep:n}=e;t&&(t.nextDep=n,e.prevDep=void 0),n&&(n.prevDep=t,e.nextDep=void 0)}let Ne=!0;const mi=[];function it(){mi.push(Ne),Ne=!1}function ot(){const e=mi.pop();Ne=e===void 0?!0:e}function ir(e){const{cleanup:t}=e;if(e.cleanup=void 0,t){const n=te;te=void 0;try{t()}finally{te=n}}}let Bt=0;class rl{constructor(t,n){this.sub=t,this.dep=n,this.version=n.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class Nn{constructor(t){this.computed=t,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0}track(t){if(!te||!Ne||te===this.computed)return;let n=this.activeLink;if(n===void 0||n.sub!==te)n=this.activeLink=new rl(te,this),te.deps?(n.prevDep=te.depsTail,te.depsTail.nextDep=n,te.depsTail=n):te.deps=te.depsTail=n,yi(n);else if(n.version===-1&&(n.version=this.version,n.nextDep)){const s=n.nextDep;s.prevDep=n.prevDep,n.prevDep&&(n.prevDep.nextDep=s),n.prevDep=te.depsTail,n.nextDep=void 0,te.depsTail.nextDep=n,te.depsTail=n,te.deps===n&&(te.deps=s)}return n}trigger(t){this.version++,Bt++,this.notify(t)}notify(t){js();try{for(let n=this.subs;n;n=n.prevSub)n.sub.notify()&&n.sub.dep.notify()}finally{Vs()}}}function yi(e){if(e.dep.sc++,e.sub.flags&4){const t=e.dep.computed;if(t&&!e.dep.subs){t.flags|=20;for(let s=t.deps;s;s=s.nextDep)yi(s)}const n=e.dep.subs;n!==e&&(e.prevSub=n,n&&(n.nextSub=e)),e.dep.subs=e}}const Sn=new WeakMap,ht=Symbol(""),ws=Symbol(""),Wt=Symbol("");function _e(e,t,n){if(Ne&&te){let s=Sn.get(e);s||Sn.set(e,s=new Map);let r=s.get(n);r||(s.set(n,r=new Nn),r.map=s,r.key=n),r.track()}}function Ke(e,t,n,s,r,i){const o=Sn.get(e);if(!o){Bt++;return}const l=c=>{c&&c.trigger()};if(js(),t==="clear")o.forEach(l);else{const c=U(e),u=c&&Hs(n);if(c&&n==="length"){const f=Number(s);o.forEach((h,p)=>{(p==="length"||p===Wt||!st(p)&&p>=f)&&l(h)})}else switch(n!==void 0&&l(o.get(n)),u&&l(o.get(Wt)),t){case"add":c?u&&l(o.get("length")):(l(o.get(ht)),xt(e)&&l(o.get(ws)));break;case"delete":c||(l(o.get(ht)),xt(e)&&l(o.get(ws)));break;case"set":xt(e)&&l(o.get(ht));break}}Vs()}function il(e,t){const n=Sn.get(e);return n&&n.get(t)}function vt(e){const t=J(e);return t===e?t:(_e(t,"iterate",Wt),Ie(e)?t:t.map(me))}function Fn(e){return _e(e=J(e),"iterate",Wt),e}const ol={__proto__:null,[Symbol.iterator](){return ts(this,Symbol.iterator,me)},concat(...e){return vt(this).concat(...e.map(t=>U(t)?vt(t):t))},entries(){return ts(this,"entries",e=>(e[1]=me(e[1]),e))},every(e,t){return Ue(this,"every",e,t,void 0,arguments)},filter(e,t){return Ue(this,"filter",e,t,n=>n.map(me),arguments)},find(e,t){return Ue(this,"find",e,t,me,arguments)},findIndex(e,t){return Ue(this,"findIndex",e,t,void 0,arguments)},findLast(e,t){return Ue(this,"findLast",e,t,me,arguments)},findLastIndex(e,t){return Ue(this,"findLastIndex",e,t,void 0,arguments)},forEach(e,t){return Ue(this,"forEach",e,t,void 0,arguments)},includes(...e){return ns(this,"includes",e)},indexOf(...e){return ns(this,"indexOf",e)},join(e){return vt(this).join(e)},lastIndexOf(...e){return ns(this,"lastIndexOf",e)},map(e,t){return Ue(this,"map",e,t,void 0,arguments)},pop(){return Lt(this,"pop")},push(...e){return Lt(this,"push",e)},reduce(e,...t){return or(this,"reduce",e,t)},reduceRight(e,...t){return or(this,"reduceRight",e,t)},shift(){return Lt(this,"shift")},some(e,t){return Ue(this,"some",e,t,void 0,arguments)},splice(...e){return Lt(this,"splice",e)},toReversed(){return vt(this).toReversed()},toSorted(e){return vt(this).toSorted(e)},toSpliced(...e){return vt(this).toSpliced(...e)},unshift(...e){return Lt(this,"unshift",e)},values(){return ts(this,"values",me)}};function ts(e,t,n){const s=Fn(e),r=s[t]();return s!==e&&!Ie(e)&&(r._next=r.next,r.next=()=>{const i=r._next();return i.value&&(i.value=n(i.value)),i}),r}const ll=Array.prototype;function Ue(e,t,n,s,r,i){const o=Fn(e),l=o!==e&&!Ie(e),c=o[t];if(c!==ll[t]){const h=c.apply(e,i);return l?me(h):h}let u=n;o!==e&&(l?u=function(h,p){return n.call(this,me(h),p,e)}:n.length>2&&(u=function(h,p){return n.call(this,h,p,e)}));const f=c.call(o,u,s);return l&&r?r(f):f}function or(e,t,n,s){const r=Fn(e);let i=n;return r!==e&&(Ie(e)?n.length>3&&(i=function(o,l,c){return n.call(this,o,l,c,e)}):i=function(o,l,c){return n.call(this,o,me(l),c,e)}),r[t](i,...s)}function ns(e,t,n){const s=J(e);_e(s,"iterate",Wt);const r=s[t](...n);return(r===-1||r===!1)&&Ks(n[0])?(n[0]=J(n[0]),s[t](...n)):r}function Lt(e,t,n=[]){it(),js();const s=J(e)[t].apply(e,n);return Vs(),ot(),s}const cl=Ls("__proto__,__v_isRef,__isVue"),_i=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!=="arguments"&&e!=="caller").map(e=>Symbol[e]).filter(st));function al(e){st(e)||(e=String(e));const t=J(this);return _e(t,"has",e),t.hasOwnProperty(e)}class bi{constructor(t=!1,n=!1){this._isReadonly=t,this._isShallow=n}get(t,n,s){const r=this._isReadonly,i=this._isShallow;if(n==="__v_isReactive")return!r;if(n==="__v_isReadonly")return r;if(n==="__v_isShallow")return i;if(n==="__v_raw")return s===(r?i?Sl:Ei:i?Si:wi).get(t)||Object.getPrototypeOf(t)===Object.getPrototypeOf(s)?t:void 0;const o=U(t);if(!r){let c;if(o&&(c=ol[n]))return c;if(n==="hasOwnProperty")return al}const l=Reflect.get(t,n,ae(t)?t:s);return(st(n)?_i.has(n):cl(n))||(r||_e(t,"get",n),i)?l:ae(l)?o&&Hs(n)?l:l.value:ne(l)?r?$n(l):Dn(l):l}}class vi extends bi{constructor(t=!1){super(!1,t)}set(t,n,s,r){let i=t[n];if(!this._isShallow){const c=_t(i);if(!Ie(s)&&!_t(s)&&(i=J(i),s=J(s)),!U(t)&&ae(i)&&!ae(s))return c?!1:(i.value=s,!0)}const o=U(t)&&Hs(n)?Number(n)e,Hn=e=>Reflect.getPrototypeOf(e);function tn(e,t,n=!1,s=!1){e=e.__v_raw;const r=J(e),i=J(t);n||(tt(t,i)&&_e(r,"get",t),_e(r,"get",i));const{has:o}=Hn(r),l=s?Us:n?qs:me;if(o.call(r,t))return l(e.get(t));if(o.call(r,i))return l(e.get(i));e!==r&&e.get(t)}function nn(e,t=!1){const n=this.__v_raw,s=J(n),r=J(e);return t||(tt(e,r)&&_e(s,"has",e),_e(s,"has",r)),e===r?n.has(e):n.has(e)||n.has(r)}function sn(e,t=!1){return e=e.__v_raw,!t&&_e(J(e),"iterate",ht),Reflect.get(e,"size",e)}function lr(e,t=!1){!t&&!Ie(e)&&!_t(e)&&(e=J(e));const n=J(this);return Hn(n).has.call(n,e)||(n.add(e),Ke(n,"add",e,e)),this}function cr(e,t,n=!1){!n&&!Ie(t)&&!_t(t)&&(t=J(t));const s=J(this),{has:r,get:i}=Hn(s);let o=r.call(s,e);o||(e=J(e),o=r.call(s,e));const l=i.call(s,e);return s.set(e,t),o?tt(t,l)&&Ke(s,"set",e,t):Ke(s,"add",e,t),this}function ar(e){const t=J(this),{has:n,get:s}=Hn(t);let r=n.call(t,e);r||(e=J(e),r=n.call(t,e)),s&&s.call(t,e);const i=t.delete(e);return r&&Ke(t,"delete",e,void 0),i}function fr(){const e=J(this),t=e.size!==0,n=e.clear();return t&&Ke(e,"clear",void 0,void 0),n}function rn(e,t){return function(s,r){const i=this,o=i.__v_raw,l=J(o),c=t?Us:e?qs:me;return!e&&_e(l,"iterate",ht),o.forEach((u,f)=>s.call(r,c(u),c(f),i))}}function on(e,t,n){return function(...s){const r=this.__v_raw,i=J(r),o=xt(i),l=e==="entries"||e===Symbol.iterator&&o,c=e==="keys"&&o,u=r[e](...s),f=n?Us:t?qs:me;return!t&&_e(i,"iterate",c?ws:ht),{next(){const{value:h,done:p}=u.next();return p?{value:h,done:p}:{value:l?[f(h[0]),f(h[1])]:f(h),done:p}},[Symbol.iterator](){return this}}}}function Ye(e){return function(...t){return e==="delete"?!1:e==="clear"?void 0:this}}function pl(){const e={get(i){return tn(this,i)},get size(){return sn(this)},has:nn,add:lr,set:cr,delete:ar,clear:fr,forEach:rn(!1,!1)},t={get(i){return tn(this,i,!1,!0)},get size(){return sn(this)},has:nn,add(i){return lr.call(this,i,!0)},set(i,o){return cr.call(this,i,o,!0)},delete:ar,clear:fr,forEach:rn(!1,!0)},n={get(i){return tn(this,i,!0)},get size(){return sn(this,!0)},has(i){return nn.call(this,i,!0)},add:Ye("add"),set:Ye("set"),delete:Ye("delete"),clear:Ye("clear"),forEach:rn(!0,!1)},s={get(i){return tn(this,i,!0,!0)},get size(){return sn(this,!0)},has(i){return nn.call(this,i,!0)},add:Ye("add"),set:Ye("set"),delete:Ye("delete"),clear:Ye("clear"),forEach:rn(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(i=>{e[i]=on(i,!1,!1),n[i]=on(i,!0,!1),t[i]=on(i,!1,!0),s[i]=on(i,!0,!0)}),[e,n,t,s]}const[gl,ml,yl,_l]=pl();function Bs(e,t){const n=t?e?_l:yl:e?ml:gl;return(s,r,i)=>r==="__v_isReactive"?!e:r==="__v_isReadonly"?e:r==="__v_raw"?s:Reflect.get(z(n,r)&&r in s?n:s,r,i)}const bl={get:Bs(!1,!1)},vl={get:Bs(!1,!0)},wl={get:Bs(!0,!1)};const wi=new WeakMap,Si=new WeakMap,Ei=new WeakMap,Sl=new WeakMap;function El(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function xl(e){return e.__v_skip||!Object.isExtensible(e)?0:El(Wo(e))}function Dn(e){return _t(e)?e:Ws(e,!1,ul,bl,wi)}function Tl(e){return Ws(e,!1,hl,vl,Si)}function $n(e){return Ws(e,!0,dl,wl,Ei)}function Ws(e,t,n,s,r){if(!ne(e)||e.__v_raw&&!(t&&e.__v_isReactive))return e;const i=r.get(e);if(i)return i;const o=xl(e);if(o===0)return e;const l=new Proxy(e,o===2?s:n);return r.set(e,l),l}function pt(e){return _t(e)?pt(e.__v_raw):!!(e&&e.__v_isReactive)}function _t(e){return!!(e&&e.__v_isReadonly)}function Ie(e){return!!(e&&e.__v_isShallow)}function Ks(e){return e?!!e.__v_raw:!1}function J(e){const t=e&&e.__v_raw;return t?J(t):e}function yn(e){return!z(e,"__v_skip")&&Object.isExtensible(e)&&si(e,"__v_skip",!0),e}const me=e=>ne(e)?Dn(e):e,qs=e=>ne(e)?$n(e):e;function ae(e){return e?e.__v_isRef===!0:!1}function de(e){return Ti(e,!1)}function xi(e){return Ti(e,!0)}function Ti(e,t){return ae(e)?e:new Cl(e,t)}class Cl{constructor(t,n){this.dep=new Nn,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=n?t:J(t),this._value=n?t:me(t),this.__v_isShallow=n}get value(){return this.dep.track(),this._value}set value(t){const n=this._rawValue,s=this.__v_isShallow||Ie(t)||_t(t);t=s?t:J(t),tt(t,n)&&(this._rawValue=t,this._value=s?t:me(t),this.dep.trigger())}}function Ci(e){return ae(e)?e.value:e}const Al={get:(e,t,n)=>t==="__v_raw"?e:Ci(Reflect.get(e,t,n)),set:(e,t,n,s)=>{const r=e[t];return ae(r)&&!ae(n)?(r.value=n,!0):Reflect.set(e,t,n,s)}};function Ai(e){return pt(e)?e:new Proxy(e,Al)}class Rl{constructor(t){this.__v_isRef=!0,this._value=void 0;const n=this.dep=new Nn,{get:s,set:r}=t(n.track.bind(n),n.trigger.bind(n));this._get=s,this._set=r}get value(){return this._value=this._get()}set value(t){this._set(t)}}function Ol(e){return new Rl(e)}function xf(e){const t=U(e)?new Array(e.length):{};for(const n in e)t[n]=Ri(e,n);return t}class Ml{constructor(t,n,s){this._object=t,this._key=n,this._defaultValue=s,this.__v_isRef=!0,this._value=void 0}get value(){const t=this._object[this._key];return this._value=t===void 0?this._defaultValue:t}set value(t){this._object[this._key]=t}get dep(){return il(J(this._object),this._key)}}class Il{constructor(t){this._getter=t,this.__v_isRef=!0,this.__v_isReadonly=!0,this._value=void 0}get value(){return this._value=this._getter()}}function Pl(e,t,n){return ae(e)?e:q(e)?new Il(e):ne(e)&&arguments.length>1?Ri(e,t,n):de(e)}function Ri(e,t,n){const s=e[t];return ae(s)?s:new Ml(e,t,n)}class Ll{constructor(t,n,s){this.fn=t,this.setter=n,this._value=void 0,this.dep=new Nn(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=Bt-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!n,this.isSSR=s}notify(){if(this.flags|=16,!(this.flags&8)&&te!==this)return di(this,!0),!0}get value(){const t=this.dep.track();return gi(this),t&&(t.version=this.dep.version),this._value}set value(t){this.setter&&this.setter(t)}}function Nl(e,t,n=!1){let s,r;return q(e)?s=e:(s=e.get,r=e.set),new Ll(s,r,n)}const ln={},En=new WeakMap;let ut;function Fl(e,t=!1,n=ut){if(n){let s=En.get(n);s||En.set(n,s=[]),s.push(e)}}function Hl(e,t,n=Z){const{immediate:s,deep:r,once:i,scheduler:o,augmentJob:l,call:c}=n,u=g=>r?g:Ie(g)||r===!1||r===0?We(g,1):We(g);let f,h,p,v,T=!1,P=!1;if(ae(e)?(h=()=>e.value,T=Ie(e)):pt(e)?(h=()=>u(e),T=!0):U(e)?(P=!0,T=e.some(g=>pt(g)||Ie(g)),h=()=>e.map(g=>{if(ae(g))return g.value;if(pt(g))return u(g);if(q(g))return c?c(g,2):g()})):q(e)?t?h=c?()=>c(e,2):e:h=()=>{if(p){it();try{p()}finally{ot()}}const g=ut;ut=f;try{return c?c(e,3,[v]):e(v)}finally{ut=g}}:h=Ve,t&&r){const g=h,O=r===!0?1/0:r;h=()=>We(g(),O)}const G=ai(),V=()=>{f.stop(),G&&Fs(G.effects,f)};if(i&&t){const g=t;t=(...O)=>{g(...O),V()}}let K=P?new Array(e.length).fill(ln):ln;const m=g=>{if(!(!(f.flags&1)||!f.dirty&&!g))if(t){const O=f.run();if(r||T||(P?O.some((N,H)=>tt(N,K[H])):tt(O,K))){p&&p();const N=ut;ut=f;try{const H=[O,K===ln?void 0:P&&K[0]===ln?[]:K,v];c?c(t,3,H):t(...H),K=O}finally{ut=N}}}else f.run()};return l&&l(m),f=new fi(h),f.scheduler=o?()=>o(m,!1):m,v=g=>Fl(g,!1,f),p=f.onStop=()=>{const g=En.get(f);if(g){if(c)c(g,4);else for(const O of g)O();En.delete(f)}},t?s?m(!0):K=f.run():o?o(m.bind(null,!0),!0):f.run(),V.pause=f.pause.bind(f),V.resume=f.resume.bind(f),V.stop=V,V}function We(e,t=1/0,n){if(t<=0||!ne(e)||e.__v_skip||(n=n||new Set,n.has(e)))return e;if(n.add(e),t--,ae(e))We(e.value,t,n);else if(U(e))for(let s=0;s{We(s,t,n)});else if(ni(e)){for(const s in e)We(e[s],t,n);for(const s of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,s)&&We(e[s],t,n)}return e}/** -* @vue/runtime-core v3.5.11 -* (c) 2018-present Yuxi (Evan) You and Vue contributors -* @license MIT -**/function zt(e,t,n,s){try{return s?e(...s):e()}catch(r){jn(r,t,n)}}function Fe(e,t,n,s){if(q(e)){const r=zt(e,t,n,s);return r&&ei(r)&&r.catch(i=>{jn(i,t,n)}),r}if(U(e)){const r=[];for(let i=0;i>>1,r=we[s],i=Kt(r);i=Kt(n)?we.push(e):we.splice($l(t),0,e),e.flags|=1,Mi()}}function Mi(){xn||(xn=Oi.then(Ii))}function jl(e){U(e)?Ct.push(...e):ze&&e.id===-1?ze.splice(St+1,0,e):e.flags&1||(Ct.push(e),e.flags|=1),Mi()}function ur(e,t,n=$e+1){for(;nKt(n)-Kt(s));if(Ct.length=0,ze){ze.push(...t);return}for(ze=t,St=0;Ste.id==null?e.flags&2?-1:1/0:e.id;function Ii(e){try{for($e=0;$e{s._d&&Tr(-1);const i=Cn(t);let o;try{o=e(...r)}finally{Cn(i),s._d&&Tr(1)}return o};return s._n=!0,s._c=!0,s._d=!0,s}function Tf(e,t){if(ce===null)return e;const n=Yn(ce),s=e.dirs||(e.dirs=[]);for(let r=0;re.__isTeleport,jt=e=>e&&(e.disabled||e.disabled===""),kl=e=>e&&(e.defer||e.defer===""),dr=e=>typeof SVGElement<"u"&&e instanceof SVGElement,hr=e=>typeof MathMLElement=="function"&&e instanceof MathMLElement,Ss=(e,t)=>{const n=e&&e.to;return re(n)?t?t(n):null:n},Ul={name:"Teleport",__isTeleport:!0,process(e,t,n,s,r,i,o,l,c,u){const{mc:f,pc:h,pbc:p,o:{insert:v,querySelector:T,createText:P,createComment:G}}=u,V=jt(t.props);let{shapeFlag:K,children:m,dynamicChildren:g}=t;if(e==null){const O=t.el=P(""),N=t.anchor=P("");v(O,n,s),v(N,n,s);const H=(A,_)=>{K&16&&(r&&r.isCE&&(r.ce._teleportTarget=A),f(m,A,_,r,i,o,l,c))},$=()=>{const A=t.target=Ss(t.props,T),_=Fi(A,t,P,v);A&&(o!=="svg"&&dr(A)?o="svg":o!=="mathml"&&hr(A)&&(o="mathml"),V||(H(A,_),_n(t)))};V&&(H(n,N),_n(t)),kl(t.props)?Ee($,i):$()}else{t.el=e.el,t.targetStart=e.targetStart;const O=t.anchor=e.anchor,N=t.target=e.target,H=t.targetAnchor=e.targetAnchor,$=jt(e.props),A=$?n:N,_=$?O:H;if(o==="svg"||dr(N)?o="svg":(o==="mathml"||hr(N))&&(o="mathml"),g?(p(e.dynamicChildren,g,A,r,i,o,l),Js(e,t,!0)):c||h(e,t,A,_,r,i,o,l,!1),V)$?t.props&&e.props&&t.props.to!==e.props.to&&(t.props.to=e.props.to):cn(t,n,O,u,1);else if((t.props&&t.props.to)!==(e.props&&e.props.to)){const L=t.target=Ss(t.props,T);L&&cn(t,L,null,u,0)}else $&&cn(t,N,H,u,1);_n(t)}},remove(e,t,n,{um:s,o:{remove:r}},i){const{shapeFlag:o,children:l,anchor:c,targetStart:u,targetAnchor:f,target:h,props:p}=e;if(h&&(r(u),r(f)),i&&r(c),o&16){const v=i||!jt(p);for(let T=0;T{e.isMounted=!0}),Wi(()=>{e.isUnmounting=!0}),e}const Re=[Function,Array],Hi={mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:Re,onEnter:Re,onAfterEnter:Re,onEnterCancelled:Re,onBeforeLeave:Re,onLeave:Re,onAfterLeave:Re,onLeaveCancelled:Re,onBeforeAppear:Re,onAppear:Re,onAfterAppear:Re,onAppearCancelled:Re},Di=e=>{const t=e.subTree;return t.component?Di(t.component):t},Kl={name:"BaseTransition",props:Hi,setup(e,{slots:t}){const n=qn(),s=Wl();return()=>{const r=t.default&&Vi(t.default(),!0);if(!r||!r.length)return;const i=$i(r),o=J(e),{mode:l}=o;if(s.isLeaving)return ss(i);const c=pr(i);if(!c)return ss(i);let u=Es(c,o,s,n,p=>u=p);c.type!==ye&&qt(c,u);const f=n.subTree,h=f&&pr(f);if(h&&h.type!==ye&&!dt(c,h)&&Di(n).type!==ye){const p=Es(h,o,s,n);if(qt(h,p),l==="out-in"&&c.type!==ye)return s.isLeaving=!0,p.afterLeave=()=>{s.isLeaving=!1,n.job.flags&8||n.update(),delete p.afterLeave},ss(i);l==="in-out"&&c.type!==ye&&(p.delayLeave=(v,T,P)=>{const G=ji(s,h);G[String(h.key)]=h,v[Qe]=()=>{T(),v[Qe]=void 0,delete u.delayedLeave},u.delayedLeave=P})}return i}}};function $i(e){let t=e[0];if(e.length>1){for(const n of e)if(n.type!==ye){t=n;break}}return t}const ql=Kl;function ji(e,t){const{leavingVNodes:n}=e;let s=n.get(t.type);return s||(s=Object.create(null),n.set(t.type,s)),s}function Es(e,t,n,s,r){const{appear:i,mode:o,persisted:l=!1,onBeforeEnter:c,onEnter:u,onAfterEnter:f,onEnterCancelled:h,onBeforeLeave:p,onLeave:v,onAfterLeave:T,onLeaveCancelled:P,onBeforeAppear:G,onAppear:V,onAfterAppear:K,onAppearCancelled:m}=t,g=String(e.key),O=ji(n,e),N=(A,_)=>{A&&Fe(A,s,9,_)},H=(A,_)=>{const L=_[1];N(A,_),U(A)?A.every(S=>S.length<=1)&&L():A.length<=1&&L()},$={mode:o,persisted:l,beforeEnter(A){let _=c;if(!n.isMounted)if(i)_=G||c;else return;A[Qe]&&A[Qe](!0);const L=O[g];L&&dt(e,L)&&L.el[Qe]&&L.el[Qe](),N(_,[A])},enter(A){let _=u,L=f,S=h;if(!n.isMounted)if(i)_=V||u,L=K||f,S=m||h;else return;let B=!1;const se=A[an]=oe=>{B||(B=!0,oe?N(S,[A]):N(L,[A]),$.delayedLeave&&$.delayedLeave(),A[an]=void 0)};_?H(_,[A,se]):se()},leave(A,_){const L=String(e.key);if(A[an]&&A[an](!0),n.isUnmounting)return _();N(p,[A]);let S=!1;const B=A[Qe]=se=>{S||(S=!0,_(),se?N(P,[A]):N(T,[A]),A[Qe]=void 0,O[L]===e&&delete O[L])};O[L]=e,v?H(v,[A,B]):B()},clone(A){const _=Es(A,t,n,s,r);return r&&r(_),_}};return $}function ss(e){if(kn(e))return e=nt(e),e.children=null,e}function pr(e){if(!kn(e))return Ni(e.type)&&e.children?$i(e.children):e;const{shapeFlag:t,children:n}=e;if(n){if(t&16)return n[0];if(t&32&&q(n.default))return n.default()}}function qt(e,t){e.shapeFlag&6&&e.component?(e.transition=t,qt(e.component.subTree,t)):e.shapeFlag&128?(e.ssContent.transition=t.clone(e.ssContent),e.ssFallback.transition=t.clone(e.ssFallback)):e.transition=t}function Vi(e,t=!1,n){let s=[],r=0;for(let i=0;i1)for(let i=0;iAn(T,t&&(U(t)?t[P]:t),n,s,r));return}if(gt(s)&&!r)return;const i=s.shapeFlag&4?Yn(s.component):s.el,o=r?null:i,{i:l,r:c}=e,u=t&&t.r,f=l.refs===Z?l.refs={}:l.refs,h=l.setupState,p=J(h),v=h===Z?()=>!1:T=>z(p,T);if(u!=null&&u!==c&&(re(u)?(f[u]=null,v(u)&&(h[u]=null)):ae(u)&&(u.value=null)),q(c))zt(c,l,12,[o,f]);else{const T=re(c),P=ae(c);if(T||P){const G=()=>{if(e.f){const V=T?v(c)?h[c]:f[c]:c.value;r?U(V)&&Fs(V,i):U(V)?V.includes(i)||V.push(i):T?(f[c]=[i],v(c)&&(h[c]=f[c])):(c.value=[i],e.k&&(f[e.k]=c.value))}else T?(f[c]=o,v(c)&&(h[c]=o)):P&&(c.value=o,e.k&&(f[e.k]=o))};o?(G.id=-1,Ee(G,n)):G()}}}let gr=!1;const wt=()=>{gr||(console.error("Hydration completed but contains mismatches."),gr=!0)},Gl=e=>e.namespaceURI.includes("svg")&&e.tagName!=="foreignObject",Yl=e=>e.namespaceURI.includes("MathML"),fn=e=>{if(e.nodeType===1){if(Gl(e))return"svg";if(Yl(e))return"mathml"}},un=e=>e.nodeType===8;function Xl(e){const{mt:t,p:n,o:{patchProp:s,createText:r,nextSibling:i,parentNode:o,remove:l,insert:c,createComment:u}}=e,f=(m,g)=>{if(!g.hasChildNodes()){n(null,m,g),Tn(),g._vnode=m;return}h(g.firstChild,m,null,null,null),Tn(),g._vnode=m},h=(m,g,O,N,H,$=!1)=>{$=$||!!g.dynamicChildren;const A=un(m)&&m.data==="[",_=()=>P(m,g,O,N,H,A),{type:L,ref:S,shapeFlag:B,patchFlag:se}=g;let oe=m.nodeType;g.el=m,se===-2&&($=!1,g.dynamicChildren=null);let j=null;switch(L){case mt:oe!==3?g.children===""?(c(g.el=r(""),o(m),m),j=m):j=_():(m.data!==g.children&&(wt(),m.data=g.children),j=i(m));break;case ye:K(m)?(j=i(m),V(g.el=m.content.firstChild,m,O)):oe!==8||A?j=_():j=i(m);break;case kt:if(A&&(m=i(m),oe=m.nodeType),oe===1||oe===3){j=m;const Y=!g.children.length;for(let D=0;D{$=$||!!g.dynamicChildren;const{type:A,props:_,patchFlag:L,shapeFlag:S,dirs:B,transition:se}=g,oe=A==="input"||A==="option";if(oe||L!==-1){B&&je(g,null,O,"created");let j=!1;if(K(m)){j=oo(N,se)&&O&&O.vnode.props&&O.vnode.props.appear;const D=m.content.firstChild;j&&se.beforeEnter(D),V(D,m,O),g.el=m=D}if(S&16&&!(_&&(_.innerHTML||_.textContent))){let D=v(m.firstChild,g,m,O,N,H,$);for(;D;){dn(m,1)||wt();const fe=D;D=D.nextSibling,l(fe)}}else if(S&8){let D=g.children;D[0]===` -`&&(m.tagName==="PRE"||m.tagName==="TEXTAREA")&&(D=D.slice(1)),m.textContent!==D&&(dn(m,0)||wt(),m.textContent=g.children)}if(_){if(oe||!$||L&48){const D=m.tagName.includes("-");for(const fe in _)(oe&&(fe.endsWith("value")||fe==="indeterminate")||Jt(fe)&&!Tt(fe)||fe[0]==="."||D)&&s(m,fe,null,_[fe],void 0,O)}else if(_.onClick)s(m,"onClick",null,_.onClick,void 0,O);else if(L&4&&pt(_.style))for(const D in _.style)_.style[D]}let Y;(Y=_&&_.onVnodeBeforeMount)&&Oe(Y,O,g),B&&je(g,null,O,"beforeMount"),((Y=_&&_.onVnodeMounted)||B||j)&&ho(()=>{Y&&Oe(Y,O,g),j&&se.enter(m),B&&je(g,null,O,"mounted")},N)}return m.nextSibling},v=(m,g,O,N,H,$,A)=>{A=A||!!g.dynamicChildren;const _=g.children,L=_.length;for(let S=0;S{const{slotScopeIds:A}=g;A&&(H=H?H.concat(A):A);const _=o(m),L=v(i(m),g,_,O,N,H,$);return L&&un(L)&&L.data==="]"?i(g.anchor=L):(wt(),c(g.anchor=u("]"),_,L),L)},P=(m,g,O,N,H,$)=>{if(dn(m.parentElement,1)||wt(),g.el=null,$){const L=G(m);for(;;){const S=i(m);if(S&&S!==L)l(S);else break}}const A=i(m),_=o(m);return l(m),n(null,g,_,A,O,N,fn(_),H),A},G=(m,g="[",O="]")=>{let N=0;for(;m;)if(m=i(m),m&&un(m)&&(m.data===g&&N++,m.data===O)){if(N===0)return i(m);N--}return m},V=(m,g,O)=>{const N=g.parentNode;N&&N.replaceChild(m,g);let H=O;for(;H;)H.vnode.el===g&&(H.vnode.el=H.subTree.el=m),H=H.parent},K=m=>m.nodeType===1&&m.tagName==="TEMPLATE";return[f,h]}const mr="data-allow-mismatch",Jl={0:"text",1:"children",2:"class",3:"style",4:"attribute"};function dn(e,t){if(t===0||t===1)for(;e&&!e.hasAttribute(mr);)e=e.parentElement;const n=e&&e.getAttribute(mr);if(n==null)return!1;if(n==="")return!0;{const s=n.split(",");return t===0&&s.includes("children")?!0:n.split(",").includes(Jl[t])}}const gt=e=>!!e.type.__asyncLoader,kn=e=>e.type.__isKeepAlive;function zl(e,t){Bi(e,"a",t)}function Ql(e,t){Bi(e,"da",t)}function Bi(e,t,n=ue){const s=e.__wdc||(e.__wdc=()=>{let r=n;for(;r;){if(r.isDeactivated)return;r=r.parent}return e()});if(Un(t,s,n),n){let r=n.parent;for(;r&&r.parent;)kn(r.parent.vnode)&&Zl(s,t,n,r),r=r.parent}}function Zl(e,t,n,s){const r=Un(t,e,s,!0);Bn(()=>{Fs(s[t],r)},n)}function Un(e,t,n=ue,s=!1){if(n){const r=n[e]||(n[e]=[]),i=t.__weh||(t.__weh=(...o)=>{it();const l=Qt(n),c=Fe(t,n,e,o);return l(),ot(),c});return s?r.unshift(i):r.push(i),i}}const Ge=e=>(t,n=ue)=>{(!Gn||e==="sp")&&Un(e,(...s)=>t(...s),n)},ec=Ge("bm"),Mt=Ge("m"),tc=Ge("bu"),nc=Ge("u"),Wi=Ge("bum"),Bn=Ge("um"),sc=Ge("sp"),rc=Ge("rtg"),ic=Ge("rtc");function oc(e,t=ue){Un("ec",e,t)}const Ki="components";function Af(e,t){return Gi(Ki,e,!0,t)||e}const qi=Symbol.for("v-ndc");function Rf(e){return re(e)?Gi(Ki,e,!1)||e:e||qi}function Gi(e,t,n=!0,s=!1){const r=ce||ue;if(r){const i=r.type;{const l=Kc(i,!1);if(l&&(l===t||l===Pe(t)||l===Ln(Pe(t))))return i}const o=yr(r[e]||i[e],t)||yr(r.appContext[e],t);return!o&&s?i:o}}function yr(e,t){return e&&(e[t]||e[Pe(t)]||e[Ln(Pe(t))])}function Of(e,t,n,s){let r;const i=n,o=U(e);if(o||re(e)){const l=o&&pt(e);let c=!1;l&&(c=!Ie(e),e=Fn(e)),r=new Array(e.length);for(let u=0,f=e.length;ut(l,c,void 0,i));else{const l=Object.keys(e);r=new Array(l.length);for(let c=0,u=l.length;c{const i=s.fn(...r);return i&&(i.key=s.key),i}:s.fn)}return e}function If(e,t,n={},s,r){if(ce.ce||ce.parent&>(ce.parent)&&ce.parent.ce)return t!=="default"&&(n.name=t),Rs(),Os(Se,null,[he("slot",n,s&&s())],64);let i=e[t];i&&i._c&&(i._d=!1),Rs();const o=i&&Yi(i(n)),l=Os(Se,{key:(n.key||o&&o.key||`_${t}`)+(!o&&s?"_fb":"")},o||(s?s():[]),o&&e._===1?64:-2);return!r&&l.scopeId&&(l.slotScopeIds=[l.scopeId+"-s"]),i&&i._c&&(i._d=!0),l}function Yi(e){return e.some(t=>Yt(t)?!(t.type===ye||t.type===Se&&!Yi(t.children)):!0)?e:null}function Pf(e,t){const n={};for(const s in e)n[/[A-Z]/.test(s)?`on:${s}`:mn(s)]=e[s];return n}const xs=e=>e?_o(e)?Yn(e):xs(e.parent):null,Vt=le(Object.create(null),{$:e=>e,$el:e=>e.vnode.el,$data:e=>e.data,$props:e=>e.props,$attrs:e=>e.attrs,$slots:e=>e.slots,$refs:e=>e.refs,$parent:e=>xs(e.parent),$root:e=>xs(e.root),$host:e=>e.ce,$emit:e=>e.emit,$options:e=>Ys(e),$forceUpdate:e=>e.f||(e.f=()=>{Gs(e.update)}),$nextTick:e=>e.n||(e.n=Vn.bind(e.proxy)),$watch:e=>Rc.bind(e)}),rs=(e,t)=>e!==Z&&!e.__isScriptSetup&&z(e,t),lc={get({_:e},t){if(t==="__v_skip")return!0;const{ctx:n,setupState:s,data:r,props:i,accessCache:o,type:l,appContext:c}=e;let u;if(t[0]!=="$"){const v=o[t];if(v!==void 0)switch(v){case 1:return s[t];case 2:return r[t];case 4:return n[t];case 3:return i[t]}else{if(rs(s,t))return o[t]=1,s[t];if(r!==Z&&z(r,t))return o[t]=2,r[t];if((u=e.propsOptions[0])&&z(u,t))return o[t]=3,i[t];if(n!==Z&&z(n,t))return o[t]=4,n[t];Ts&&(o[t]=0)}}const f=Vt[t];let h,p;if(f)return t==="$attrs"&&_e(e.attrs,"get",""),f(e);if((h=l.__cssModules)&&(h=h[t]))return h;if(n!==Z&&z(n,t))return o[t]=4,n[t];if(p=c.config.globalProperties,z(p,t))return p[t]},set({_:e},t,n){const{data:s,setupState:r,ctx:i}=e;return rs(r,t)?(r[t]=n,!0):s!==Z&&z(s,t)?(s[t]=n,!0):z(e.props,t)||t[0]==="$"&&t.slice(1)in e?!1:(i[t]=n,!0)},has({_:{data:e,setupState:t,accessCache:n,ctx:s,appContext:r,propsOptions:i}},o){let l;return!!n[o]||e!==Z&&z(e,o)||rs(t,o)||(l=i[0])&&z(l,o)||z(s,o)||z(Vt,o)||z(r.config.globalProperties,o)},defineProperty(e,t,n){return n.get!=null?e._.accessCache[t]=0:z(n,"value")&&this.set(e,t,n.value,null),Reflect.defineProperty(e,t,n)}};function Lf(){return cc().slots}function cc(){const e=qn();return e.setupContext||(e.setupContext=vo(e))}function _r(e){return U(e)?e.reduce((t,n)=>(t[n]=null,t),{}):e}let Ts=!0;function ac(e){const t=Ys(e),n=e.proxy,s=e.ctx;Ts=!1,t.beforeCreate&&br(t.beforeCreate,e,"bc");const{data:r,computed:i,methods:o,watch:l,provide:c,inject:u,created:f,beforeMount:h,mounted:p,beforeUpdate:v,updated:T,activated:P,deactivated:G,beforeDestroy:V,beforeUnmount:K,destroyed:m,unmounted:g,render:O,renderTracked:N,renderTriggered:H,errorCaptured:$,serverPrefetch:A,expose:_,inheritAttrs:L,components:S,directives:B,filters:se}=t;if(u&&fc(u,s,null),o)for(const Y in o){const D=o[Y];q(D)&&(s[Y]=D.bind(n))}if(r){const Y=r.call(n,n);ne(Y)&&(e.data=Dn(Y))}if(Ts=!0,i)for(const Y in i){const D=i[Y],fe=q(D)?D.bind(n,n):q(D.get)?D.get.bind(n,n):Ve,Zt=!q(D)&&q(D.set)?D.set.bind(n):Ve,lt=ie({get:fe,set:Zt});Object.defineProperty(s,Y,{enumerable:!0,configurable:!0,get:()=>lt.value,set:He=>lt.value=He})}if(l)for(const Y in l)Xi(l[Y],s,n,Y);if(c){const Y=q(c)?c.call(n):c;Reflect.ownKeys(Y).forEach(D=>{mc(D,Y[D])})}f&&br(f,e,"c");function j(Y,D){U(D)?D.forEach(fe=>Y(fe.bind(n))):D&&Y(D.bind(n))}if(j(ec,h),j(Mt,p),j(tc,v),j(nc,T),j(zl,P),j(Ql,G),j(oc,$),j(ic,N),j(rc,H),j(Wi,K),j(Bn,g),j(sc,A),U(_))if(_.length){const Y=e.exposed||(e.exposed={});_.forEach(D=>{Object.defineProperty(Y,D,{get:()=>n[D],set:fe=>n[D]=fe})})}else e.exposed||(e.exposed={});O&&e.render===Ve&&(e.render=O),L!=null&&(e.inheritAttrs=L),S&&(e.components=S),B&&(e.directives=B),A&&Ui(e)}function fc(e,t,n=Ve){U(e)&&(e=Cs(e));for(const s in e){const r=e[s];let i;ne(r)?"default"in r?i=Rt(r.from||s,r.default,!0):i=Rt(r.from||s):i=Rt(r),ae(i)?Object.defineProperty(t,s,{enumerable:!0,configurable:!0,get:()=>i.value,set:o=>i.value=o}):t[s]=i}}function br(e,t,n){Fe(U(e)?e.map(s=>s.bind(t.proxy)):e.bind(t.proxy),t,n)}function Xi(e,t,n,s){let r=s.includes(".")?ao(n,s):()=>n[s];if(re(e)){const i=t[e];q(i)&&ke(r,i)}else if(q(e))ke(r,e.bind(n));else if(ne(e))if(U(e))e.forEach(i=>Xi(i,t,n,s));else{const i=q(e.handler)?e.handler.bind(n):t[e.handler];q(i)&&ke(r,i,e)}}function Ys(e){const t=e.type,{mixins:n,extends:s}=t,{mixins:r,optionsCache:i,config:{optionMergeStrategies:o}}=e.appContext,l=i.get(t);let c;return l?c=l:!r.length&&!n&&!s?c=t:(c={},r.length&&r.forEach(u=>Rn(c,u,o,!0)),Rn(c,t,o)),ne(t)&&i.set(t,c),c}function Rn(e,t,n,s=!1){const{mixins:r,extends:i}=t;i&&Rn(e,i,n,!0),r&&r.forEach(o=>Rn(e,o,n,!0));for(const o in t)if(!(s&&o==="expose")){const l=uc[o]||n&&n[o];e[o]=l?l(e[o],t[o]):t[o]}return e}const uc={data:vr,props:wr,emits:wr,methods:Ht,computed:Ht,beforeCreate:be,created:be,beforeMount:be,mounted:be,beforeUpdate:be,updated:be,beforeDestroy:be,beforeUnmount:be,destroyed:be,unmounted:be,activated:be,deactivated:be,errorCaptured:be,serverPrefetch:be,components:Ht,directives:Ht,watch:hc,provide:vr,inject:dc};function vr(e,t){return t?e?function(){return le(q(e)?e.call(this,this):e,q(t)?t.call(this,this):t)}:t:e}function dc(e,t){return Ht(Cs(e),Cs(t))}function Cs(e){if(U(e)){const t={};for(let n=0;n1)return n&&q(t)?t.call(s&&s.proxy):t}}const zi={},Qi=()=>Object.create(zi),Zi=e=>Object.getPrototypeOf(e)===zi;function yc(e,t,n,s=!1){const r={},i=Qi();e.propsDefaults=Object.create(null),eo(e,t,r,i);for(const o in e.propsOptions[0])o in r||(r[o]=void 0);n?e.props=s?r:Tl(r):e.type.props?e.props=r:e.props=i,e.attrs=i}function _c(e,t,n,s){const{props:r,attrs:i,vnode:{patchFlag:o}}=e,l=J(r),[c]=e.propsOptions;let u=!1;if((s||o>0)&&!(o&16)){if(o&8){const f=e.vnode.dynamicProps;for(let h=0;h{c=!0;const[p,v]=to(h,t,!0);le(o,p),v&&l.push(...v)};!n&&t.mixins.length&&t.mixins.forEach(f),e.extends&&f(e.extends),e.mixins&&e.mixins.forEach(f)}if(!i&&!c)return ne(e)&&s.set(e,Et),Et;if(U(i))for(let f=0;fe[0]==="_"||e==="$stable",Xs=e=>U(e)?e.map(Me):[Me(e)],vc=(e,t,n)=>{if(t._n)return t;const s=Vl((...r)=>Xs(t(...r)),n);return s._c=!1,s},so=(e,t,n)=>{const s=e._ctx;for(const r in e){if(no(r))continue;const i=e[r];if(q(i))t[r]=vc(r,i,s);else if(i!=null){const o=Xs(i);t[r]=()=>o}}},ro=(e,t)=>{const n=Xs(t);e.slots.default=()=>n},io=(e,t,n)=>{for(const s in t)(n||s!=="_")&&(e[s]=t[s])},wc=(e,t,n)=>{const s=e.slots=Qi();if(e.vnode.shapeFlag&32){const r=t._;r?(io(s,t,n),n&&si(s,"_",r,!0)):so(t,s)}else t&&ro(e,t)},Sc=(e,t,n)=>{const{vnode:s,slots:r}=e;let i=!0,o=Z;if(s.shapeFlag&32){const l=t._;l?n&&l===1?i=!1:io(r,t,n):(i=!t.$stable,so(t,r)),o=t}else t&&(ro(e,t),o={default:1});if(i)for(const l in r)!no(l)&&o[l]==null&&delete r[l]},Ee=ho;function Ec(e){return xc(e,Xl)}function xc(e,t){const n=ri();n.__VUE__=!0;const{insert:s,remove:r,patchProp:i,createElement:o,createText:l,createComment:c,setText:u,setElementText:f,parentNode:h,nextSibling:p,setScopeId:v=Ve,insertStaticContent:T}=e,P=(a,d,y,E=null,b=null,w=null,M=void 0,R=null,C=!!d.dynamicChildren)=>{if(a===d)return;a&&!dt(a,d)&&(E=en(a),He(a,b,w,!0),a=null),d.patchFlag===-2&&(C=!1,d.dynamicChildren=null);const{type:x,ref:k,shapeFlag:I}=d;switch(x){case mt:G(a,d,y,E);break;case ye:V(a,d,y,E);break;case kt:a==null&&K(d,y,E,M);break;case Se:S(a,d,y,E,b,w,M,R,C);break;default:I&1?O(a,d,y,E,b,w,M,R,C):I&6?B(a,d,y,E,b,w,M,R,C):(I&64||I&128)&&x.process(a,d,y,E,b,w,M,R,C,bt)}k!=null&&b&&An(k,a&&a.ref,w,d||a,!d)},G=(a,d,y,E)=>{if(a==null)s(d.el=l(d.children),y,E);else{const b=d.el=a.el;d.children!==a.children&&u(b,d.children)}},V=(a,d,y,E)=>{a==null?s(d.el=c(d.children||""),y,E):d.el=a.el},K=(a,d,y,E)=>{[a.el,a.anchor]=T(a.children,d,y,E,a.el,a.anchor)},m=({el:a,anchor:d},y,E)=>{let b;for(;a&&a!==d;)b=p(a),s(a,y,E),a=b;s(d,y,E)},g=({el:a,anchor:d})=>{let y;for(;a&&a!==d;)y=p(a),r(a),a=y;r(d)},O=(a,d,y,E,b,w,M,R,C)=>{d.type==="svg"?M="svg":d.type==="math"&&(M="mathml"),a==null?N(d,y,E,b,w,M,R,C):A(a,d,b,w,M,R,C)},N=(a,d,y,E,b,w,M,R)=>{let C,x;const{props:k,shapeFlag:I,transition:F,dirs:W}=a;if(C=a.el=o(a.type,w,k&&k.is,k),I&8?f(C,a.children):I&16&&$(a.children,C,null,E,b,is(a,w),M,R),W&&je(a,null,E,"created"),H(C,a,a.scopeId,M,E),k){for(const ee in k)ee!=="value"&&!Tt(ee)&&i(C,ee,null,k[ee],w,E);"value"in k&&i(C,"value",null,k.value,w),(x=k.onVnodeBeforeMount)&&Oe(x,E,a)}W&&je(a,null,E,"beforeMount");const X=oo(b,F);X&&F.beforeEnter(C),s(C,d,y),((x=k&&k.onVnodeMounted)||X||W)&&Ee(()=>{x&&Oe(x,E,a),X&&F.enter(C),W&&je(a,null,E,"mounted")},b)},H=(a,d,y,E,b)=>{if(y&&v(a,y),E)for(let w=0;w{for(let x=C;x{const R=d.el=a.el;let{patchFlag:C,dynamicChildren:x,dirs:k}=d;C|=a.patchFlag&16;const I=a.props||Z,F=d.props||Z;let W;if(y&&ct(y,!1),(W=F.onVnodeBeforeUpdate)&&Oe(W,y,d,a),k&&je(d,a,y,"beforeUpdate"),y&&ct(y,!0),(I.innerHTML&&F.innerHTML==null||I.textContent&&F.textContent==null)&&f(R,""),x?_(a.dynamicChildren,x,R,y,E,is(d,b),w):M||D(a,d,R,null,y,E,is(d,b),w,!1),C>0){if(C&16)L(R,I,F,y,b);else if(C&2&&I.class!==F.class&&i(R,"class",null,F.class,b),C&4&&i(R,"style",I.style,F.style,b),C&8){const X=d.dynamicProps;for(let ee=0;ee{W&&Oe(W,y,d,a),k&&je(d,a,y,"updated")},E)},_=(a,d,y,E,b,w,M)=>{for(let R=0;R{if(d!==y){if(d!==Z)for(const w in d)!Tt(w)&&!(w in y)&&i(a,w,d[w],null,b,E);for(const w in y){if(Tt(w))continue;const M=y[w],R=d[w];M!==R&&w!=="value"&&i(a,w,R,M,b,E)}"value"in y&&i(a,"value",d.value,y.value,b)}},S=(a,d,y,E,b,w,M,R,C)=>{const x=d.el=a?a.el:l(""),k=d.anchor=a?a.anchor:l("");let{patchFlag:I,dynamicChildren:F,slotScopeIds:W}=d;W&&(R=R?R.concat(W):W),a==null?(s(x,y,E),s(k,y,E),$(d.children||[],y,k,b,w,M,R,C)):I>0&&I&64&&F&&a.dynamicChildren?(_(a.dynamicChildren,F,y,b,w,M,R),(d.key!=null||b&&d===b.subTree)&&Js(a,d,!0)):D(a,d,y,k,b,w,M,R,C)},B=(a,d,y,E,b,w,M,R,C)=>{d.slotScopeIds=R,a==null?d.shapeFlag&512?b.ctx.activate(d,y,E,M,C):se(d,y,E,b,w,M,C):oe(a,d,C)},se=(a,d,y,E,b,w,M)=>{const R=a.component=kc(a,E,b);if(kn(a)&&(R.ctx.renderer=bt),Uc(R,!1,M),R.asyncDep){if(b&&b.registerDep(R,j,M),!a.el){const C=R.subTree=he(ye);V(null,C,d,y)}}else j(R,a,d,y,b,w,M)},oe=(a,d,y)=>{const E=d.component=a.component;if(Lc(a,d,y))if(E.asyncDep&&!E.asyncResolved){Y(E,d,y);return}else E.next=d,E.update();else d.el=a.el,E.vnode=d},j=(a,d,y,E,b,w,M)=>{const R=()=>{if(a.isMounted){let{next:I,bu:F,u:W,parent:X,vnode:ee}=a;{const Te=lo(a);if(Te){I&&(I.el=ee.el,Y(a,I,M)),Te.asyncDep.then(()=>{a.isUnmounted||R()});return}}let Q=I,xe;ct(a,!1),I?(I.el=ee.el,Y(a,I,M)):I=ee,F&&Qn(F),(xe=I.props&&I.props.onVnodeBeforeUpdate)&&Oe(xe,X,I,ee),ct(a,!0);const pe=os(a),Le=a.subTree;a.subTree=pe,P(Le,pe,h(Le.el),en(Le),a,b,w),I.el=pe.el,Q===null&&Nc(a,pe.el),W&&Ee(W,b),(xe=I.props&&I.props.onVnodeUpdated)&&Ee(()=>Oe(xe,X,I,ee),b)}else{let I;const{el:F,props:W}=d,{bm:X,m:ee,parent:Q,root:xe,type:pe}=a,Le=gt(d);if(ct(a,!1),X&&Qn(X),!Le&&(I=W&&W.onVnodeBeforeMount)&&Oe(I,Q,d),ct(a,!0),F&&zn){const Te=()=>{a.subTree=os(a),zn(F,a.subTree,a,b,null)};Le&&pe.__asyncHydrate?pe.__asyncHydrate(F,a,Te):Te()}else{xe.ce&&xe.ce._injectChildStyle(pe);const Te=a.subTree=os(a);P(null,Te,y,E,a,b,w),d.el=Te.el}if(ee&&Ee(ee,b),!Le&&(I=W&&W.onVnodeMounted)){const Te=d;Ee(()=>Oe(I,Q,Te),b)}(d.shapeFlag&256||Q&>(Q.vnode)&&Q.vnode.shapeFlag&256)&&a.a&&Ee(a.a,b),a.isMounted=!0,d=y=E=null}};a.scope.on();const C=a.effect=new fi(R);a.scope.off();const x=a.update=C.run.bind(C),k=a.job=C.runIfDirty.bind(C);k.i=a,k.id=a.uid,C.scheduler=()=>Gs(k),ct(a,!0),x()},Y=(a,d,y)=>{d.component=a;const E=a.vnode.props;a.vnode=d,a.next=null,_c(a,d.props,E,y),Sc(a,d.children,y),it(),ur(a),ot()},D=(a,d,y,E,b,w,M,R,C=!1)=>{const x=a&&a.children,k=a?a.shapeFlag:0,I=d.children,{patchFlag:F,shapeFlag:W}=d;if(F>0){if(F&128){Zt(x,I,y,E,b,w,M,R,C);return}else if(F&256){fe(x,I,y,E,b,w,M,R,C);return}}W&8?(k&16&&It(x,b,w),I!==x&&f(y,I)):k&16?W&16?Zt(x,I,y,E,b,w,M,R,C):It(x,b,w,!0):(k&8&&f(y,""),W&16&&$(I,y,E,b,w,M,R,C))},fe=(a,d,y,E,b,w,M,R,C)=>{a=a||Et,d=d||Et;const x=a.length,k=d.length,I=Math.min(x,k);let F;for(F=0;Fk?It(a,b,w,!0,!1,I):$(d,y,E,b,w,M,R,C,I)},Zt=(a,d,y,E,b,w,M,R,C)=>{let x=0;const k=d.length;let I=a.length-1,F=k-1;for(;x<=I&&x<=F;){const W=a[x],X=d[x]=C?Ze(d[x]):Me(d[x]);if(dt(W,X))P(W,X,y,null,b,w,M,R,C);else break;x++}for(;x<=I&&x<=F;){const W=a[I],X=d[F]=C?Ze(d[F]):Me(d[F]);if(dt(W,X))P(W,X,y,null,b,w,M,R,C);else break;I--,F--}if(x>I){if(x<=F){const W=F+1,X=WF)for(;x<=I;)He(a[x],b,w,!0),x++;else{const W=x,X=x,ee=new Map;for(x=X;x<=F;x++){const Ce=d[x]=C?Ze(d[x]):Me(d[x]);Ce.key!=null&&ee.set(Ce.key,x)}let Q,xe=0;const pe=F-X+1;let Le=!1,Te=0;const Pt=new Array(pe);for(x=0;x=pe){He(Ce,b,w,!0);continue}let De;if(Ce.key!=null)De=ee.get(Ce.key);else for(Q=X;Q<=F;Q++)if(Pt[Q-X]===0&&dt(Ce,d[Q])){De=Q;break}De===void 0?He(Ce,b,w,!0):(Pt[De-X]=x+1,De>=Te?Te=De:Le=!0,P(Ce,d[De],y,null,b,w,M,R,C),xe++)}const nr=Le?Tc(Pt):Et;for(Q=nr.length-1,x=pe-1;x>=0;x--){const Ce=X+x,De=d[Ce],sr=Ce+1{const{el:w,type:M,transition:R,children:C,shapeFlag:x}=a;if(x&6){lt(a.component.subTree,d,y,E);return}if(x&128){a.suspense.move(d,y,E);return}if(x&64){M.move(a,d,y,bt);return}if(M===Se){s(w,d,y);for(let I=0;IR.enter(w),b);else{const{leave:I,delayLeave:F,afterLeave:W}=R,X=()=>s(w,d,y),ee=()=>{I(w,()=>{X(),W&&W()})};F?F(w,X,ee):ee()}else s(w,d,y)},He=(a,d,y,E=!1,b=!1)=>{const{type:w,props:M,ref:R,children:C,dynamicChildren:x,shapeFlag:k,patchFlag:I,dirs:F,cacheIndex:W}=a;if(I===-2&&(b=!1),R!=null&&An(R,null,y,a,!0),W!=null&&(d.renderCache[W]=void 0),k&256){d.ctx.deactivate(a);return}const X=k&1&&F,ee=!gt(a);let Q;if(ee&&(Q=M&&M.onVnodeBeforeUnmount)&&Oe(Q,d,a),k&6)ko(a.component,y,E);else{if(k&128){a.suspense.unmount(y,E);return}X&&je(a,null,d,"beforeUnmount"),k&64?a.type.remove(a,d,y,bt,E):x&&!x.hasOnce&&(w!==Se||I>0&&I&64)?It(x,d,y,!1,!0):(w===Se&&I&384||!b&&k&16)&&It(C,d,y),E&&er(a)}(ee&&(Q=M&&M.onVnodeUnmounted)||X)&&Ee(()=>{Q&&Oe(Q,d,a),X&&je(a,null,d,"unmounted")},y)},er=a=>{const{type:d,el:y,anchor:E,transition:b}=a;if(d===Se){Vo(y,E);return}if(d===kt){g(a);return}const w=()=>{r(y),b&&!b.persisted&&b.afterLeave&&b.afterLeave()};if(a.shapeFlag&1&&b&&!b.persisted){const{leave:M,delayLeave:R}=b,C=()=>M(y,w);R?R(a.el,w,C):C()}else w()},Vo=(a,d)=>{let y;for(;a!==d;)y=p(a),r(a),a=y;r(d)},ko=(a,d,y)=>{const{bum:E,scope:b,job:w,subTree:M,um:R,m:C,a:x}=a;Er(C),Er(x),E&&Qn(E),b.stop(),w&&(w.flags|=8,He(M,a,d,y)),R&&Ee(R,d),Ee(()=>{a.isUnmounted=!0},d),d&&d.pendingBranch&&!d.isUnmounted&&a.asyncDep&&!a.asyncResolved&&a.suspenseId===d.pendingId&&(d.deps--,d.deps===0&&d.resolve())},It=(a,d,y,E=!1,b=!1,w=0)=>{for(let M=w;M{if(a.shapeFlag&6)return en(a.component.subTree);if(a.shapeFlag&128)return a.suspense.next();const d=p(a.anchor||a.el),y=d&&d[Li];return y?p(y):d};let Xn=!1;const tr=(a,d,y)=>{a==null?d._vnode&&He(d._vnode,null,null,!0):P(d._vnode||null,a,d,null,null,null,y),d._vnode=a,Xn||(Xn=!0,ur(),Tn(),Xn=!1)},bt={p:P,um:He,m:lt,r:er,mt:se,mc:$,pc:D,pbc:_,n:en,o:e};let Jn,zn;return t&&([Jn,zn]=t(bt)),{render:tr,hydrate:Jn,createApp:gc(tr,Jn)}}function is({type:e,props:t},n){return n==="svg"&&e==="foreignObject"||n==="mathml"&&e==="annotation-xml"&&t&&t.encoding&&t.encoding.includes("html")?void 0:n}function ct({effect:e,job:t},n){n?(e.flags|=32,t.flags|=4):(e.flags&=-33,t.flags&=-5)}function oo(e,t){return(!e||e&&!e.pendingBranch)&&t&&!t.persisted}function Js(e,t,n=!1){const s=e.children,r=t.children;if(U(s)&&U(r))for(let i=0;i>1,e[n[l]]0&&(t[s]=n[i-1]),n[i]=s)}}for(i=n.length,o=n[i-1];i-- >0;)n[i]=o,o=t[o];return n}function lo(e){const t=e.subTree.component;if(t)return t.asyncDep&&!t.asyncResolved?t:lo(t)}function Er(e){if(e)for(let t=0;tRt(Cc);function co(e,t){return Wn(e,null,t)}function Nf(e,t){return Wn(e,null,{flush:"post"})}function ke(e,t,n){return Wn(e,t,n)}function Wn(e,t,n=Z){const{immediate:s,deep:r,flush:i,once:o}=n,l=le({},n);let c;if(Gn)if(i==="sync"){const p=Ac();c=p.__watcherHandles||(p.__watcherHandles=[])}else if(!t||s)l.once=!0;else{const p=()=>{};return p.stop=Ve,p.resume=Ve,p.pause=Ve,p}const u=ue;l.call=(p,v,T)=>Fe(p,u,v,T);let f=!1;i==="post"?l.scheduler=p=>{Ee(p,u&&u.suspense)}:i!=="sync"&&(f=!0,l.scheduler=(p,v)=>{v?p():Gs(p)}),l.augmentJob=p=>{t&&(p.flags|=4),f&&(p.flags|=2,u&&(p.id=u.uid,p.i=u))};const h=Hl(e,t,l);return c&&c.push(h),h}function Rc(e,t,n){const s=this.proxy,r=re(e)?e.includes(".")?ao(s,e):()=>s[e]:e.bind(s,s);let i;q(t)?i=t:(i=t.handler,n=t);const o=Qt(this),l=Wn(r,i.bind(s),n);return o(),l}function ao(e,t){const n=t.split(".");return()=>{let s=e;for(let r=0;rt==="modelValue"||t==="model-value"?e.modelModifiers:e[`${t}Modifiers`]||e[`${Pe(t)}Modifiers`]||e[`${rt(t)}Modifiers`];function Mc(e,t,...n){if(e.isUnmounted)return;const s=e.vnode.props||Z;let r=n;const i=t.startsWith("update:"),o=i&&Oc(s,t.slice(7));o&&(o.trim&&(r=n.map(f=>re(f)?f.trim():f)),o.number&&(r=n.map(Go)));let l,c=s[l=mn(t)]||s[l=mn(Pe(t))];!c&&i&&(c=s[l=mn(rt(t))]),c&&Fe(c,e,6,r);const u=s[l+"Once"];if(u){if(!e.emitted)e.emitted={};else if(e.emitted[l])return;e.emitted[l]=!0,Fe(u,e,6,r)}}function fo(e,t,n=!1){const s=t.emitsCache,r=s.get(e);if(r!==void 0)return r;const i=e.emits;let o={},l=!1;if(!q(e)){const c=u=>{const f=fo(u,t,!0);f&&(l=!0,le(o,f))};!n&&t.mixins.length&&t.mixins.forEach(c),e.extends&&c(e.extends),e.mixins&&e.mixins.forEach(c)}return!i&&!l?(ne(e)&&s.set(e,null),null):(U(i)?i.forEach(c=>o[c]=null):le(o,i),ne(e)&&s.set(e,o),o)}function Kn(e,t){return!e||!Jt(t)?!1:(t=t.slice(2).replace(/Once$/,""),z(e,t[0].toLowerCase()+t.slice(1))||z(e,rt(t))||z(e,t))}function os(e){const{type:t,vnode:n,proxy:s,withProxy:r,propsOptions:[i],slots:o,attrs:l,emit:c,render:u,renderCache:f,props:h,data:p,setupState:v,ctx:T,inheritAttrs:P}=e,G=Cn(e);let V,K;try{if(n.shapeFlag&4){const g=r||s,O=g;V=Me(u.call(O,g,f,h,v,p,T)),K=l}else{const g=t;V=Me(g.length>1?g(h,{attrs:l,slots:o,emit:c}):g(h,null)),K=t.props?l:Ic(l)}}catch(g){Ut.length=0,jn(g,e,1),V=he(ye)}let m=V;if(K&&P!==!1){const g=Object.keys(K),{shapeFlag:O}=m;g.length&&O&7&&(i&&g.some(Ns)&&(K=Pc(K,i)),m=nt(m,K,!1,!0))}return n.dirs&&(m=nt(m,null,!1,!0),m.dirs=m.dirs?m.dirs.concat(n.dirs):n.dirs),n.transition&&qt(m,n.transition),V=m,Cn(G),V}const Ic=e=>{let t;for(const n in e)(n==="class"||n==="style"||Jt(n))&&((t||(t={}))[n]=e[n]);return t},Pc=(e,t)=>{const n={};for(const s in e)(!Ns(s)||!(s.slice(9)in t))&&(n[s]=e[s]);return n};function Lc(e,t,n){const{props:s,children:r,component:i}=e,{props:o,children:l,patchFlag:c}=t,u=i.emitsOptions;if(t.dirs||t.transition)return!0;if(n&&c>=0){if(c&1024)return!0;if(c&16)return s?xr(s,o,u):!!o;if(c&8){const f=t.dynamicProps;for(let h=0;he.__isSuspense;function ho(e,t){t&&t.pendingBranch?U(e)?t.effects.push(...e):t.effects.push(e):jl(e)}const Se=Symbol.for("v-fgt"),mt=Symbol.for("v-txt"),ye=Symbol.for("v-cmt"),kt=Symbol.for("v-stc"),Ut=[];let Ae=null;function Rs(e=!1){Ut.push(Ae=e?null:[])}function Fc(){Ut.pop(),Ae=Ut[Ut.length-1]||null}let Gt=1;function Tr(e){Gt+=e,e<0&&Ae&&(Ae.hasOnce=!0)}function po(e){return e.dynamicChildren=Gt>0?Ae||Et:null,Fc(),Gt>0&&Ae&&Ae.push(e),e}function Ff(e,t,n,s,r,i){return po(mo(e,t,n,s,r,i,!0))}function Os(e,t,n,s,r){return po(he(e,t,n,s,r,!0))}function Yt(e){return e?e.__v_isVNode===!0:!1}function dt(e,t){return e.type===t.type&&e.key===t.key}const go=({key:e})=>e??null,bn=({ref:e,ref_key:t,ref_for:n})=>(typeof e=="number"&&(e=""+e),e!=null?re(e)||ae(e)||q(e)?{i:ce,r:e,k:t,f:!!n}:e:null);function mo(e,t=null,n=null,s=0,r=null,i=e===Se?0:1,o=!1,l=!1){const c={__v_isVNode:!0,__v_skip:!0,type:e,props:t,key:t&&go(t),ref:t&&bn(t),scopeId:Pi,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:i,patchFlag:s,dynamicProps:r,dynamicChildren:null,appContext:null,ctx:ce};return l?(zs(c,n),i&128&&e.normalize(c)):n&&(c.shapeFlag|=re(n)?8:16),Gt>0&&!o&&Ae&&(c.patchFlag>0||i&6)&&c.patchFlag!==32&&Ae.push(c),c}const he=Hc;function Hc(e,t=null,n=null,s=0,r=null,i=!1){if((!e||e===qi)&&(e=ye),Yt(e)){const l=nt(e,t,!0);return n&&zs(l,n),Gt>0&&!i&&Ae&&(l.shapeFlag&6?Ae[Ae.indexOf(e)]=l:Ae.push(l)),l.patchFlag=-2,l}if(qc(e)&&(e=e.__vccOpts),t){t=Dc(t);let{class:l,style:c}=t;l&&!re(l)&&(t.class=$s(l)),ne(c)&&(Ks(c)&&!U(c)&&(c=le({},c)),t.style=Ds(c))}const o=re(e)?1:uo(e)?128:Ni(e)?64:ne(e)?4:q(e)?2:0;return mo(e,t,n,s,r,o,i,!0)}function Dc(e){return e?Ks(e)||Zi(e)?le({},e):e:null}function nt(e,t,n=!1,s=!1){const{props:r,ref:i,patchFlag:o,children:l,transition:c}=e,u=t?$c(r||{},t):r,f={__v_isVNode:!0,__v_skip:!0,type:e.type,props:u,key:u&&go(u),ref:t&&t.ref?n&&i?U(i)?i.concat(bn(t)):[i,bn(t)]:bn(t):i,scopeId:e.scopeId,slotScopeIds:e.slotScopeIds,children:l,target:e.target,targetStart:e.targetStart,targetAnchor:e.targetAnchor,staticCount:e.staticCount,shapeFlag:e.shapeFlag,patchFlag:t&&e.type!==Se?o===-1?16:o|16:o,dynamicProps:e.dynamicProps,dynamicChildren:e.dynamicChildren,appContext:e.appContext,dirs:e.dirs,transition:c,component:e.component,suspense:e.suspense,ssContent:e.ssContent&&nt(e.ssContent),ssFallback:e.ssFallback&&nt(e.ssFallback),el:e.el,anchor:e.anchor,ctx:e.ctx,ce:e.ce};return c&&s&&qt(f,c.clone(f)),f}function yo(e=" ",t=0){return he(mt,null,e,t)}function Hf(e,t){const n=he(kt,null,e);return n.staticCount=t,n}function Df(e="",t=!1){return t?(Rs(),Os(ye,null,e)):he(ye,null,e)}function Me(e){return e==null||typeof e=="boolean"?he(ye):U(e)?he(Se,null,e.slice()):Yt(e)?Ze(e):he(mt,null,String(e))}function Ze(e){return e.el===null&&e.patchFlag!==-1||e.memo?e:nt(e)}function zs(e,t){let n=0;const{shapeFlag:s}=e;if(t==null)t=null;else if(U(t))n=16;else if(typeof t=="object")if(s&65){const r=t.default;r&&(r._c&&(r._d=!1),zs(e,r()),r._c&&(r._d=!0));return}else{n=32;const r=t._;!r&&!Zi(t)?t._ctx=ce:r===3&&ce&&(ce.slots._===1?t._=1:(t._=2,e.patchFlag|=1024))}else q(t)?(t={default:t,_ctx:ce},n=32):(t=String(t),s&64?(n=16,t=[yo(t)]):n=8);e.children=t,e.shapeFlag|=n}function $c(...e){const t={};for(let n=0;nue||ce;let On,Ms;{const e=ri(),t=(n,s)=>{let r;return(r=e[n])||(r=e[n]=[]),r.push(s),i=>{r.length>1?r.forEach(o=>o(i)):r[0](i)}};On=t("__VUE_INSTANCE_SETTERS__",n=>ue=n),Ms=t("__VUE_SSR_SETTERS__",n=>Gn=n)}const Qt=e=>{const t=ue;return On(e),e.scope.on(),()=>{e.scope.off(),On(t)}},Cr=()=>{ue&&ue.scope.off(),On(null)};function _o(e){return e.vnode.shapeFlag&4}let Gn=!1;function Uc(e,t=!1,n=!1){t&&Ms(t);const{props:s,children:r}=e.vnode,i=_o(e);yc(e,s,i,t),wc(e,r,n);const o=i?Bc(e,t):void 0;return t&&Ms(!1),o}function Bc(e,t){const n=e.type;e.accessCache=Object.create(null),e.proxy=new Proxy(e.ctx,lc);const{setup:s}=n;if(s){const r=e.setupContext=s.length>1?vo(e):null,i=Qt(e);it();const o=zt(s,e,0,[e.props,r]);if(ot(),i(),ei(o)){if(gt(e)||Ui(e),o.then(Cr,Cr),t)return o.then(l=>{Ar(e,l,t)}).catch(l=>{jn(l,e,0)});e.asyncDep=o}else Ar(e,o,t)}else bo(e,t)}function Ar(e,t,n){q(t)?e.type.__ssrInlineRender?e.ssrRender=t:e.render=t:ne(t)&&(e.setupState=Ai(t)),bo(e,n)}let Rr;function bo(e,t,n){const s=e.type;if(!e.render){if(!t&&Rr&&!s.render){const r=s.template||Ys(e).template;if(r){const{isCustomElement:i,compilerOptions:o}=e.appContext.config,{delimiters:l,compilerOptions:c}=s,u=le(le({isCustomElement:i,delimiters:l},o),c);s.render=Rr(r,u)}}e.render=s.render||Ve}{const r=Qt(e);it();try{ac(e)}finally{ot(),r()}}}const Wc={get(e,t){return _e(e,"get",""),e[t]}};function vo(e){const t=n=>{e.exposed=n||{}};return{attrs:new Proxy(e.attrs,Wc),slots:e.slots,emit:e.emit,expose:t}}function Yn(e){return e.exposed?e.exposeProxy||(e.exposeProxy=new Proxy(Ai(yn(e.exposed)),{get(t,n){if(n in t)return t[n];if(n in Vt)return Vt[n](e)},has(t,n){return n in t||n in Vt}})):e.proxy}function Kc(e,t=!0){return q(e)?e.displayName||e.name:e.name||t&&e.__name}function qc(e){return q(e)&&"__vccOpts"in e}const ie=(e,t)=>Nl(e,t,Gn);function Is(e,t,n){const s=arguments.length;return s===2?ne(t)&&!U(t)?Yt(t)?he(e,null,[t]):he(e,t):he(e,null,t):(s>3?n=Array.prototype.slice.call(arguments,2):s===3&&Yt(n)&&(n=[n]),he(e,t,n))}const Gc="3.5.11";/** -* @vue/runtime-dom v3.5.11 -* (c) 2018-present Yuxi (Evan) You and Vue contributors -* @license MIT -**/let Ps;const Or=typeof window<"u"&&window.trustedTypes;if(Or)try{Ps=Or.createPolicy("vue",{createHTML:e=>e})}catch{}const wo=Ps?e=>Ps.createHTML(e):e=>e,Yc="http://www.w3.org/2000/svg",Xc="http://www.w3.org/1998/Math/MathML",Be=typeof document<"u"?document:null,Mr=Be&&Be.createElement("template"),Jc={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,s)=>{const r=t==="svg"?Be.createElementNS(Yc,e):t==="mathml"?Be.createElementNS(Xc,e):n?Be.createElement(e,{is:n}):Be.createElement(e);return e==="select"&&s&&s.multiple!=null&&r.setAttribute("multiple",s.multiple),r},createText:e=>Be.createTextNode(e),createComment:e=>Be.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>Be.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,s,r,i){const o=n?n.previousSibling:t.lastChild;if(r&&(r===i||r.nextSibling))for(;t.insertBefore(r.cloneNode(!0),n),!(r===i||!(r=r.nextSibling)););else{Mr.innerHTML=wo(s==="svg"?`${e}`:s==="mathml"?`${e}`:e);const l=Mr.content;if(s==="svg"||s==="mathml"){const c=l.firstChild;for(;c.firstChild;)l.appendChild(c.firstChild);l.removeChild(c)}t.insertBefore(l,n)}return[o?o.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},Xe="transition",Nt="animation",Xt=Symbol("_vtc"),So={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},zc=le({},Hi,So),Qc=e=>(e.displayName="Transition",e.props=zc,e),$f=Qc((e,{slots:t})=>Is(ql,Zc(e),t)),at=(e,t=[])=>{U(e)?e.forEach(n=>n(...t)):e&&e(...t)},Ir=e=>e?U(e)?e.some(t=>t.length>1):e.length>1:!1;function Zc(e){const t={};for(const S in e)S in So||(t[S]=e[S]);if(e.css===!1)return t;const{name:n="v",type:s,duration:r,enterFromClass:i=`${n}-enter-from`,enterActiveClass:o=`${n}-enter-active`,enterToClass:l=`${n}-enter-to`,appearFromClass:c=i,appearActiveClass:u=o,appearToClass:f=l,leaveFromClass:h=`${n}-leave-from`,leaveActiveClass:p=`${n}-leave-active`,leaveToClass:v=`${n}-leave-to`}=e,T=ea(r),P=T&&T[0],G=T&&T[1],{onBeforeEnter:V,onEnter:K,onEnterCancelled:m,onLeave:g,onLeaveCancelled:O,onBeforeAppear:N=V,onAppear:H=K,onAppearCancelled:$=m}=t,A=(S,B,se)=>{ft(S,B?f:l),ft(S,B?u:o),se&&se()},_=(S,B)=>{S._isLeaving=!1,ft(S,h),ft(S,v),ft(S,p),B&&B()},L=S=>(B,se)=>{const oe=S?H:K,j=()=>A(B,S,se);at(oe,[B,j]),Pr(()=>{ft(B,S?c:i),Je(B,S?f:l),Ir(oe)||Lr(B,s,P,j)})};return le(t,{onBeforeEnter(S){at(V,[S]),Je(S,i),Je(S,o)},onBeforeAppear(S){at(N,[S]),Je(S,c),Je(S,u)},onEnter:L(!1),onAppear:L(!0),onLeave(S,B){S._isLeaving=!0;const se=()=>_(S,B);Je(S,h),Je(S,p),sa(),Pr(()=>{S._isLeaving&&(ft(S,h),Je(S,v),Ir(g)||Lr(S,s,G,se))}),at(g,[S,se])},onEnterCancelled(S){A(S,!1),at(m,[S])},onAppearCancelled(S){A(S,!0),at($,[S])},onLeaveCancelled(S){_(S),at(O,[S])}})}function ea(e){if(e==null)return null;if(ne(e))return[ls(e.enter),ls(e.leave)];{const t=ls(e);return[t,t]}}function ls(e){return Yo(e)}function Je(e,t){t.split(/\s+/).forEach(n=>n&&e.classList.add(n)),(e[Xt]||(e[Xt]=new Set)).add(t)}function ft(e,t){t.split(/\s+/).forEach(s=>s&&e.classList.remove(s));const n=e[Xt];n&&(n.delete(t),n.size||(e[Xt]=void 0))}function Pr(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}let ta=0;function Lr(e,t,n,s){const r=e._endId=++ta,i=()=>{r===e._endId&&s()};if(n!=null)return setTimeout(i,n);const{type:o,timeout:l,propCount:c}=na(e,t);if(!o)return s();const u=o+"end";let f=0;const h=()=>{e.removeEventListener(u,p),i()},p=v=>{v.target===e&&++f>=c&&h()};setTimeout(()=>{f(n[T]||"").split(", "),r=s(`${Xe}Delay`),i=s(`${Xe}Duration`),o=Nr(r,i),l=s(`${Nt}Delay`),c=s(`${Nt}Duration`),u=Nr(l,c);let f=null,h=0,p=0;t===Xe?o>0&&(f=Xe,h=o,p=i.length):t===Nt?u>0&&(f=Nt,h=u,p=c.length):(h=Math.max(o,u),f=h>0?o>u?Xe:Nt:null,p=f?f===Xe?i.length:c.length:0);const v=f===Xe&&/\b(transform|all)(,|$)/.test(s(`${Xe}Property`).toString());return{type:f,timeout:h,propCount:p,hasTransform:v}}function Nr(e,t){for(;e.lengthFr(n)+Fr(e[s])))}function Fr(e){return e==="auto"?0:Number(e.slice(0,-1).replace(",","."))*1e3}function sa(){return document.body.offsetHeight}function ra(e,t,n){const s=e[Xt];s&&(t=(t?[t,...s]:[...s]).join(" ")),t==null?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}const Mn=Symbol("_vod"),Eo=Symbol("_vsh"),jf={beforeMount(e,{value:t},{transition:n}){e[Mn]=e.style.display==="none"?"":e.style.display,n&&t?n.beforeEnter(e):Ft(e,t)},mounted(e,{value:t},{transition:n}){n&&t&&n.enter(e)},updated(e,{value:t,oldValue:n},{transition:s}){!t!=!n&&(s?t?(s.beforeEnter(e),Ft(e,!0),s.enter(e)):s.leave(e,()=>{Ft(e,!1)}):Ft(e,t))},beforeUnmount(e,{value:t}){Ft(e,t)}};function Ft(e,t){e.style.display=t?e[Mn]:"none",e[Eo]=!t}const ia=Symbol(""),oa=/(^|;)\s*display\s*:/;function la(e,t,n){const s=e.style,r=re(n);let i=!1;if(n&&!r){if(t)if(re(t))for(const o of t.split(";")){const l=o.slice(0,o.indexOf(":")).trim();n[l]==null&&vn(s,l,"")}else for(const o in t)n[o]==null&&vn(s,o,"");for(const o in n)o==="display"&&(i=!0),vn(s,o,n[o])}else if(r){if(t!==n){const o=s[ia];o&&(n+=";"+o),s.cssText=n,i=oa.test(n)}}else t&&e.removeAttribute("style");Mn in e&&(e[Mn]=i?s.display:"",e[Eo]&&(s.display="none"))}const Hr=/\s*!important$/;function vn(e,t,n){if(U(n))n.forEach(s=>vn(e,t,s));else if(n==null&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{const s=ca(e,t);Hr.test(n)?e.setProperty(rt(s),n.replace(Hr,""),"important"):e[s]=n}}const Dr=["Webkit","Moz","ms"],cs={};function ca(e,t){const n=cs[t];if(n)return n;let s=Pe(t);if(s!=="filter"&&s in e)return cs[t]=s;s=Ln(s);for(let r=0;ras||(ha.then(()=>as=0),as=Date.now());function ga(e,t){const n=s=>{if(!s._vts)s._vts=Date.now();else if(s._vts<=n.attached)return;Fe(ma(s,n.value),t,5,[s])};return n.value=e,n.attached=pa(),n}function ma(e,t){if(U(t)){const n=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0},t.map(s=>r=>!r._stopped&&s&&s(r))}else return t}const Br=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,ya=(e,t,n,s,r,i)=>{const o=r==="svg";t==="class"?ra(e,s,o):t==="style"?la(e,n,s):Jt(t)?Ns(t)||ua(e,t,n,s,i):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):_a(e,t,s,o))?(Vr(e,t,s),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&jr(e,t,s,o,i,t!=="value")):e._isVueCE&&(/[A-Z]/.test(t)||!re(s))?Vr(e,Pe(t),s):(t==="true-value"?e._trueValue=s:t==="false-value"&&(e._falseValue=s),jr(e,t,s,o))};function _a(e,t,n,s){if(s)return!!(t==="innerHTML"||t==="textContent"||t in e&&Br(t)&&q(n));if(t==="spellcheck"||t==="draggable"||t==="translate"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA")return!1;if(t==="width"||t==="height"){const r=e.tagName;if(r==="IMG"||r==="VIDEO"||r==="CANVAS"||r==="SOURCE")return!1}return Br(t)&&re(n)?!1:t in e}const ba=["ctrl","shift","alt","meta"],va={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&e.button!==0,middle:e=>"button"in e&&e.button!==1,right:e=>"button"in e&&e.button!==2,exact:(e,t)=>ba.some(n=>e[`${n}Key`]&&!t.includes(n))},Vf=(e,t)=>{const n=e._withMods||(e._withMods={}),s=t.join(".");return n[s]||(n[s]=(r,...i)=>{for(let o=0;o{const n=e._withKeys||(e._withKeys={}),s=t.join(".");return n[s]||(n[s]=r=>{if(!("key"in r))return;const i=rt(r.key);if(t.some(o=>o===i||wa[o]===i))return e(r)})},Sa=le({patchProp:ya},Jc);let fs,Wr=!1;function Ea(){return fs=Wr?fs:Ec(Sa),Wr=!0,fs}const Uf=(...e)=>{const t=Ea().createApp(...e),{mount:n}=t;return t.mount=s=>{const r=Ta(s);if(r)return n(r,!0,xa(r))},t};function xa(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function Ta(e){return re(e)?document.querySelector(e):e}const Bf=(e,t)=>{const n=e.__vccOpts||e;for(const[s,r]of t)n[s]=r;return n},Ca="modulepreload",Aa=function(e){return"/ran/"+e},Kr={},Wf=function(t,n,s){let r=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));r=Promise.allSettled(n.map(c=>{if(c=Aa(c),c in Kr)return;Kr[c]=!0;const u=c.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${f}`))return;const h=document.createElement("link");if(h.rel=u?"stylesheet":Ca,u||(h.as="script"),h.crossOrigin="",h.href=c,l&&h.setAttribute("nonce",l),document.head.appendChild(h),u)return new Promise((p,v)=>{h.addEventListener("load",p),h.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return r.then(o=>{for(const l of o||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})},Ra=window.__VP_SITE_DATA__;function Qs(e){return ai()?(nl(e),!0):!1}function et(e){return typeof e=="function"?e():Ci(e)}const xo=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Oa=Object.prototype.toString,Ma=e=>Oa.call(e)==="[object Object]",To=()=>{},qr=Ia();function Ia(){var e,t;return xo&&((e=window==null?void 0:window.navigator)==null?void 0:e.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((t=window==null?void 0:window.navigator)==null?void 0:t.maxTouchPoints)>2&&/iPad|Macintosh/.test(window==null?void 0:window.navigator.userAgent))}function Pa(e,t){function n(...s){return new Promise((r,i)=>{Promise.resolve(e(()=>t.apply(this,s),{fn:t,thisArg:this,args:s})).then(r).catch(i)})}return n}const Co=e=>e();function La(e=Co){const t=de(!0);function n(){t.value=!1}function s(){t.value=!0}const r=(...i)=>{t.value&&e(...i)};return{isActive:$n(t),pause:n,resume:s,eventFilter:r}}function Na(e){return qn()}function Ao(...e){if(e.length!==1)return Pl(...e);const t=e[0];return typeof t=="function"?$n(Ol(()=>({get:t,set:To}))):de(t)}function Fa(e,t,n={}){const{eventFilter:s=Co,...r}=n;return ke(e,Pa(s,t),r)}function Ha(e,t,n={}){const{eventFilter:s,...r}=n,{eventFilter:i,pause:o,resume:l,isActive:c}=La(s);return{stop:Fa(e,t,{...r,eventFilter:i}),pause:o,resume:l,isActive:c}}function Zs(e,t=!0,n){Na()?Mt(e,n):t?e():Vn(e)}const qe=xo?window:void 0;function Ro(e){var t;const n=et(e);return(t=n==null?void 0:n.$el)!=null?t:n}function Ot(...e){let t,n,s,r;if(typeof e[0]=="string"||Array.isArray(e[0])?([n,s,r]=e,t=qe):[t,n,s,r]=e,!t)return To;Array.isArray(n)||(n=[n]),Array.isArray(s)||(s=[s]);const i=[],o=()=>{i.forEach(f=>f()),i.length=0},l=(f,h,p,v)=>(f.addEventListener(h,p,v),()=>f.removeEventListener(h,p,v)),c=ke(()=>[Ro(t),et(r)],([f,h])=>{if(o(),!f)return;const p=Ma(h)?{...h}:h;i.push(...n.flatMap(v=>s.map(T=>l(f,v,T,p))))},{immediate:!0,flush:"post"}),u=()=>{c(),o()};return Qs(u),u}function Da(e){return typeof e=="function"?e:typeof e=="string"?t=>t.key===e:Array.isArray(e)?t=>e.includes(t.key):()=>!0}function Kf(...e){let t,n,s={};e.length===3?(t=e[0],n=e[1],s=e[2]):e.length===2?typeof e[1]=="object"?(t=!0,n=e[0],s=e[1]):(t=e[0],n=e[1]):(t=!0,n=e[0]);const{target:r=qe,eventName:i="keydown",passive:o=!1,dedupe:l=!1}=s,c=Da(t);return Ot(r,i,f=>{f.repeat&&et(l)||c(f)&&n(f)},o)}function $a(){const e=de(!1),t=qn();return t&&Mt(()=>{e.value=!0},t),e}function ja(e){const t=$a();return ie(()=>(t.value,!!e()))}function Oo(e,t={}){const{window:n=qe}=t,s=ja(()=>n&&"matchMedia"in n&&typeof n.matchMedia=="function");let r;const i=de(!1),o=u=>{i.value=u.matches},l=()=>{r&&("removeEventListener"in r?r.removeEventListener("change",o):r.removeListener(o))},c=co(()=>{s.value&&(l(),r=n.matchMedia(et(e)),"addEventListener"in r?r.addEventListener("change",o):r.addListener(o),i.value=r.matches)});return Qs(()=>{c(),l(),r=void 0}),i}const hn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},pn="__vueuse_ssr_handlers__",Va=ka();function ka(){return pn in hn||(hn[pn]=hn[pn]||{}),hn[pn]}function Mo(e,t){return Va[e]||t}function Io(e){return Oo("(prefers-color-scheme: dark)",e)}function Ua(e){return e==null?"any":e instanceof Set?"set":e instanceof Map?"map":e instanceof Date?"date":typeof e=="boolean"?"boolean":typeof e=="string"?"string":typeof e=="object"?"object":Number.isNaN(e)?"any":"number"}const Ba={boolean:{read:e=>e==="true",write:e=>String(e)},object:{read:e=>JSON.parse(e),write:e=>JSON.stringify(e)},number:{read:e=>Number.parseFloat(e),write:e=>String(e)},any:{read:e=>e,write:e=>String(e)},string:{read:e=>e,write:e=>String(e)},map:{read:e=>new Map(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e.entries()))},set:{read:e=>new Set(JSON.parse(e)),write:e=>JSON.stringify(Array.from(e))},date:{read:e=>new Date(e),write:e=>e.toISOString()}},Gr="vueuse-storage";function Wa(e,t,n,s={}){var r;const{flush:i="pre",deep:o=!0,listenToStorageChanges:l=!0,writeDefaults:c=!0,mergeDefaults:u=!1,shallow:f,window:h=qe,eventFilter:p,onError:v=_=>{console.error(_)},initOnMounted:T}=s,P=(f?xi:de)(typeof t=="function"?t():t);if(!n)try{n=Mo("getDefaultStorage",()=>{var _;return(_=qe)==null?void 0:_.localStorage})()}catch(_){v(_)}if(!n)return P;const G=et(t),V=Ua(G),K=(r=s.serializer)!=null?r:Ba[V],{pause:m,resume:g}=Ha(P,()=>N(P.value),{flush:i,deep:o,eventFilter:p});h&&l&&Zs(()=>{n instanceof Storage?Ot(h,"storage",$):Ot(h,Gr,A),T&&$()}),T||$();function O(_,L){if(h){const S={key:e,oldValue:_,newValue:L,storageArea:n};h.dispatchEvent(n instanceof Storage?new StorageEvent("storage",S):new CustomEvent(Gr,{detail:S}))}}function N(_){try{const L=n.getItem(e);if(_==null)O(L,null),n.removeItem(e);else{const S=K.write(_);L!==S&&(n.setItem(e,S),O(L,S))}}catch(L){v(L)}}function H(_){const L=_?_.newValue:n.getItem(e);if(L==null)return c&&G!=null&&n.setItem(e,K.write(G)),G;if(!_&&u){const S=K.read(L);return typeof u=="function"?u(S,G):V==="object"&&!Array.isArray(S)?{...G,...S}:S}else return typeof L!="string"?L:K.read(L)}function $(_){if(!(_&&_.storageArea!==n)){if(_&&_.key==null){P.value=G;return}if(!(_&&_.key!==e)){m();try{(_==null?void 0:_.newValue)!==K.write(P.value)&&(P.value=H(_))}catch(L){v(L)}finally{_?Vn(g):g()}}}}function A(_){$(_.detail)}return P}const Ka="*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}";function qa(e={}){const{selector:t="html",attribute:n="class",initialValue:s="auto",window:r=qe,storage:i,storageKey:o="vueuse-color-scheme",listenToStorageChanges:l=!0,storageRef:c,emitAuto:u,disableTransition:f=!0}=e,h={auto:"",light:"light",dark:"dark",...e.modes||{}},p=Io({window:r}),v=ie(()=>p.value?"dark":"light"),T=c||(o==null?Ao(s):Wa(o,s,i,{window:r,listenToStorageChanges:l})),P=ie(()=>T.value==="auto"?v.value:T.value),G=Mo("updateHTMLAttrs",(g,O,N)=>{const H=typeof g=="string"?r==null?void 0:r.document.querySelector(g):Ro(g);if(!H)return;const $=new Set,A=new Set;let _=null;if(O==="class"){const S=N.split(/\s/g);Object.values(h).flatMap(B=>(B||"").split(/\s/g)).filter(Boolean).forEach(B=>{S.includes(B)?$.add(B):A.add(B)})}else _={key:O,value:N};if($.size===0&&A.size===0&&_===null)return;let L;f&&(L=r.document.createElement("style"),L.appendChild(document.createTextNode(Ka)),r.document.head.appendChild(L));for(const S of $)H.classList.add(S);for(const S of A)H.classList.remove(S);_&&H.setAttribute(_.key,_.value),f&&(r.getComputedStyle(L).opacity,document.head.removeChild(L))});function V(g){var O;G(t,n,(O=h[g])!=null?O:g)}function K(g){e.onChanged?e.onChanged(g,V):V(g)}ke(P,K,{flush:"post",immediate:!0}),Zs(()=>K(P.value));const m=ie({get(){return u?T.value:P.value},set(g){T.value=g}});try{return Object.assign(m,{store:T,system:v,state:P})}catch{return m}}function Ga(e={}){const{valueDark:t="dark",valueLight:n="",window:s=qe}=e,r=qa({...e,onChanged:(l,c)=>{var u;e.onChanged?(u=e.onChanged)==null||u.call(e,l==="dark",c,l):c(l)},modes:{dark:t,light:n}}),i=ie(()=>r.system?r.system.value:Io({window:s}).value?"dark":"light");return ie({get(){return r.value==="dark"},set(l){const c=l?"dark":"light";i.value===c?r.value="auto":r.value=c}})}function us(e){return typeof Window<"u"&&e instanceof Window?e.document.documentElement:typeof Document<"u"&&e instanceof Document?e.documentElement:e}function Po(e){const t=window.getComputedStyle(e);if(t.overflowX==="scroll"||t.overflowY==="scroll"||t.overflowX==="auto"&&e.clientWidth1?!0:(t.preventDefault&&t.preventDefault(),!1)}const ds=new WeakMap;function qf(e,t=!1){const n=de(t);let s=null,r="";ke(Ao(e),l=>{const c=us(et(l));if(c){const u=c;if(ds.get(u)||ds.set(u,u.style.overflow),u.style.overflow!=="hidden"&&(r=u.style.overflow),u.style.overflow==="hidden")return n.value=!0;if(n.value)return u.style.overflow="hidden"}},{immediate:!0});const i=()=>{const l=us(et(e));!l||n.value||(qr&&(s=Ot(l,"touchmove",c=>{Ya(c)},{passive:!1})),l.style.overflow="hidden",n.value=!0)},o=()=>{const l=us(et(e));!l||!n.value||(qr&&(s==null||s()),l.style.overflow=r,ds.delete(l),n.value=!1)};return Qs(o),ie({get(){return n.value},set(l){l?i():o()}})}function Gf(e={}){const{window:t=qe,behavior:n="auto"}=e;if(!t)return{x:de(0),y:de(0)};const s=de(t.scrollX),r=de(t.scrollY),i=ie({get(){return s.value},set(l){scrollTo({left:l,behavior:n})}}),o=ie({get(){return r.value},set(l){scrollTo({top:l,behavior:n})}});return Ot(t,"scroll",()=>{s.value=t.scrollX,r.value=t.scrollY},{capture:!1,passive:!0}),{x:i,y:o}}function Yf(e={}){const{window:t=qe,initialWidth:n=Number.POSITIVE_INFINITY,initialHeight:s=Number.POSITIVE_INFINITY,listenOrientation:r=!0,includeScrollbar:i=!0,type:o="inner"}=e,l=de(n),c=de(s),u=()=>{t&&(o==="outer"?(l.value=t.outerWidth,c.value=t.outerHeight):i?(l.value=t.innerWidth,c.value=t.innerHeight):(l.value=t.document.documentElement.clientWidth,c.value=t.document.documentElement.clientHeight))};if(u(),Zs(u),Ot("resize",u,{passive:!0}),r){const f=Oo("(orientation: portrait)");ke(f,()=>u())}return{width:l,height:c}}const hs={BASE_URL:"/ran/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};var ps={};const Lo=/^(?:[a-z]+:|\/\/)/i,Xa="vitepress-theme-appearance",Ja=/#.*$/,za=/[?#].*$/,Qa=/(?:(^|\/)index)?\.(?:md|html)$/,ge=typeof document<"u",No={relativePath:"404.md",filePath:"",title:"404",description:"Not Found",headers:[],frontmatter:{sidebar:!1,layout:"page"},lastUpdated:0,isNotFound:!0};function Za(e,t,n=!1){if(t===void 0)return!1;if(e=Yr(`/${e}`),n)return new RegExp(t).test(e);if(Yr(t)!==e)return!1;const s=t.match(Ja);return s?(ge?location.hash:"")===s[0]:!0}function Yr(e){return decodeURI(e).replace(za,"").replace(Qa,"$1")}function ef(e){return Lo.test(e)}function tf(e,t){return Object.keys((e==null?void 0:e.locales)||{}).find(n=>n!=="root"&&!ef(n)&&Za(t,`/${n}/`,!0))||"root"}function nf(e,t){var s,r,i,o,l,c,u;const n=tf(e,t);return Object.assign({},e,{localeIndex:n,lang:((s=e.locales[n])==null?void 0:s.lang)??e.lang,dir:((r=e.locales[n])==null?void 0:r.dir)??e.dir,title:((i=e.locales[n])==null?void 0:i.title)??e.title,titleTemplate:((o=e.locales[n])==null?void 0:o.titleTemplate)??e.titleTemplate,description:((l=e.locales[n])==null?void 0:l.description)??e.description,head:Ho(e.head,((c=e.locales[n])==null?void 0:c.head)??[]),themeConfig:{...e.themeConfig,...(u=e.locales[n])==null?void 0:u.themeConfig}})}function Fo(e,t){const n=t.title||e.title,s=t.titleTemplate??e.titleTemplate;if(typeof s=="string"&&s.includes(":title"))return s.replace(/:title/g,n);const r=sf(e.title,s);return n===r.slice(3)?n:`${n}${r}`}function sf(e,t){return t===!1?"":t===!0||t===void 0?` | ${e}`:e===t?"":` | ${t}`}function rf(e,t){const[n,s]=t;if(n!=="meta")return!1;const r=Object.entries(s)[0];return r==null?!1:e.some(([i,o])=>i===n&&o[r[0]]===r[1])}function Ho(e,t){return[...e.filter(n=>!rf(t,n)),...t]}const of=/[\u0000-\u001F"#$&*+,:;<=>?[\]^`{|}\u007F]/g,lf=/^[a-z]:/i;function Xr(e){const t=lf.exec(e),n=t?t[0]:"";return n+e.slice(n.length).replace(of,"_").replace(/(^|\/)_+(?=[^/]*$)/,"$1")}const gs=new Set;function cf(e){if(gs.size===0){const n=typeof process=="object"&&(ps==null?void 0:ps.VITE_EXTRA_EXTENSIONS)||(hs==null?void 0:hs.VITE_EXTRA_EXTENSIONS)||"";("3g2,3gp,aac,ai,apng,au,avif,bin,bmp,cer,class,conf,crl,css,csv,dll,doc,eps,epub,exe,gif,gz,ics,ief,jar,jpe,jpeg,jpg,js,json,jsonld,m4a,man,mid,midi,mjs,mov,mp2,mp3,mp4,mpe,mpeg,mpg,mpp,oga,ogg,ogv,ogx,opus,otf,p10,p7c,p7m,p7s,pdf,png,ps,qt,roff,rtf,rtx,ser,svg,t,tif,tiff,tr,ts,tsv,ttf,txt,vtt,wav,weba,webm,webp,woff,woff2,xhtml,xml,yaml,yml,zip"+(n&&typeof n=="string"?","+n:"")).split(",").forEach(s=>gs.add(s))}const t=e.split(".").pop();return t==null||!gs.has(t.toLowerCase())}const af=Symbol(),yt=xi(Ra);function Xf(e){const t=ie(()=>nf(yt.value,e.data.relativePath)),n=t.value.appearance,s=n==="force-dark"?de(!0):n?Ga({storageKey:Xa,initialValue:()=>n==="dark"?"dark":"auto",...typeof n=="object"?n:{}}):de(!1),r=de(ge?location.hash:"");return ge&&window.addEventListener("hashchange",()=>{r.value=location.hash}),ke(()=>e.data,()=>{r.value=ge?location.hash:""}),{site:t,theme:ie(()=>t.value.themeConfig),page:ie(()=>e.data),frontmatter:ie(()=>e.data.frontmatter),params:ie(()=>e.data.params),lang:ie(()=>t.value.lang),dir:ie(()=>e.data.frontmatter.dir||t.value.dir),localeIndex:ie(()=>t.value.localeIndex||"root"),title:ie(()=>Fo(t.value,e.data)),description:ie(()=>e.data.description||t.value.description),isDark:s,hash:ie(()=>r.value)}}function ff(){const e=Rt(af);if(!e)throw new Error("vitepress data not properly injected in app");return e}function uf(e,t){return`${e}${t}`.replace(/\/+/g,"/")}function Jr(e){return Lo.test(e)||!e.startsWith("/")?e:uf(yt.value.base,e)}function df(e){let t=e.replace(/\.html$/,"");if(t=decodeURIComponent(t),t=t.replace(/\/$/,"/index"),ge){const n="/ran/";t=Xr(t.slice(n.length).replace(/\//g,"_")||"index")+".md";let s=__VP_HASH_MAP__[t.toLowerCase()];if(s||(t=t.endsWith("_index.md")?t.slice(0,-9)+".md":t.slice(0,-3)+"_index.md",s=__VP_HASH_MAP__[t.toLowerCase()]),!s)return null;t=`${n}assets/${t}.${s}.js`}else t=`./${Xr(t.slice(1).replace(/\//g,"_"))}.md.js`;return t}let wn=[];function Jf(e){wn.push(e),Bn(()=>{wn=wn.filter(t=>t!==e)})}function hf(){let e=yt.value.scrollOffset,t=0,n=24;if(typeof e=="object"&&"padding"in e&&(n=e.padding,e=e.selector),typeof e=="number")t=e;else if(typeof e=="string")t=zr(e,n);else if(Array.isArray(e))for(const s of e){const r=zr(s,n);if(r){t=r;break}}return t}function zr(e,t){const n=document.querySelector(e);if(!n)return 0;const s=n.getBoundingClientRect().bottom;return s<0?0:s+t}const pf=Symbol(),Do="http://a.com",gf=()=>({path:"/",component:null,data:No});function zf(e,t){const n=Dn(gf()),s={route:n,go:r};async function r(l=ge?location.href:"/"){var c,u;l=ms(l),await((c=s.onBeforeRouteChange)==null?void 0:c.call(s,l))!==!1&&(ge&&l!==ms(location.href)&&(history.replaceState({scrollPosition:window.scrollY},""),history.pushState({},"",l)),await o(l),await((u=s.onAfterRouteChanged)==null?void 0:u.call(s,l)))}let i=null;async function o(l,c=0,u=!1){var p;if(await((p=s.onBeforePageLoad)==null?void 0:p.call(s,l))===!1)return;const f=new URL(l,Do),h=i=f.pathname;try{let v=await e(h);if(!v)throw new Error(`Page not found: ${h}`);if(i===h){i=null;const{default:T,__pageData:P}=v;if(!T)throw new Error(`Invalid route component: ${T}`);n.path=ge?h:Jr(h),n.component=yn(T),n.data=yn(P),ge&&Vn(()=>{let G=yt.value.base+P.relativePath.replace(/(?:(^|\/)index)?\.md$/,"$1");if(!yt.value.cleanUrls&&!G.endsWith("/")&&(G+=".html"),G!==f.pathname&&(f.pathname=G,l=G+f.search+f.hash,history.replaceState({},"",l)),f.hash&&!c){let V=null;try{V=document.getElementById(decodeURIComponent(f.hash).slice(1))}catch(K){console.warn(K)}if(V){Qr(V,f.hash);return}}window.scrollTo(0,c)})}}catch(v){if(!/fetch|Page not found/.test(v.message)&&!/^\/404(\.html|\/)?$/.test(l)&&console.error(v),!u)try{const T=await fetch(yt.value.base+"hashmap.json");window.__VP_HASH_MAP__=await T.json(),await o(l,c,!0);return}catch{}if(i===h){i=null,n.path=ge?h:Jr(h),n.component=t?yn(t):null;const T=ge?h.replace(/(^|\/)$/,"$1index").replace(/(\.html)?$/,".md").replace(/^\//,""):"404.md";n.data={...No,relativePath:T}}}}return ge&&(history.state===null&&history.replaceState({},""),window.addEventListener("click",l=>{if(l.defaultPrevented||!(l.target instanceof Element)||l.target.closest("button")||l.button!==0||l.ctrlKey||l.shiftKey||l.altKey||l.metaKey)return;const c=l.target.closest("a");if(!c||c.closest(".vp-raw")||c.hasAttribute("download")||c.hasAttribute("target"))return;const u=c.getAttribute("href")??(c instanceof SVGAElement?c.getAttribute("xlink:href"):null);if(u==null)return;const{href:f,origin:h,pathname:p,hash:v,search:T}=new URL(u,c.baseURI),P=new URL(location.href);h===P.origin&&cf(p)&&(l.preventDefault(),p===P.pathname&&T===P.search?(v!==P.hash&&(history.pushState({},"",f),window.dispatchEvent(new HashChangeEvent("hashchange",{oldURL:P.href,newURL:f}))),v?Qr(c,v,c.classList.contains("header-anchor")):window.scrollTo(0,0)):r(f))},{capture:!0}),window.addEventListener("popstate",async l=>{var c;l.state!==null&&(await o(ms(location.href),l.state&&l.state.scrollPosition||0),(c=s.onAfterRouteChanged)==null||c.call(s,location.href))}),window.addEventListener("hashchange",l=>{l.preventDefault()})),s}function mf(){const e=Rt(pf);if(!e)throw new Error("useRouter() is called without provider.");return e}function $o(){return mf().route}function Qr(e,t,n=!1){let s=null;try{s=e.classList.contains("header-anchor")?e:document.getElementById(decodeURIComponent(t).slice(1))}catch(r){console.warn(r)}if(s){let r=function(){!n||Math.abs(o-window.scrollY)>window.innerHeight?window.scrollTo(0,o):window.scrollTo({left:0,top:o,behavior:"smooth"})};const i=parseInt(window.getComputedStyle(s).paddingTop,10),o=window.scrollY+s.getBoundingClientRect().top-hf()+i;requestAnimationFrame(r)}}function ms(e){const t=new URL(e,Do);return t.pathname=t.pathname.replace(/(^|\/)index(\.html)?$/,"$1"),yt.value.cleanUrls?t.pathname=t.pathname.replace(/\.html$/,""):!t.pathname.endsWith("/")&&!t.pathname.endsWith(".html")&&(t.pathname+=".html"),t.pathname+t.search+t.hash}const ys=()=>wn.forEach(e=>e()),Qf=ki({name:"VitePressContent",props:{as:{type:[Object,String],default:"div"}},setup(e){const t=$o(),{site:n}=ff();return()=>Is(e.as,n.value.contentProps??{style:{position:"relative"}},[t.component?Is(t.component,{onVnodeMounted:ys,onVnodeUpdated:ys,onVnodeUnmounted:ys}):"404 Page Not Found"])}}),Zf=(e,t,n)=>{const s=e[t];return s?typeof s=="function"?s():Promise.resolve(s):new Promise((r,i)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(i.bind(null,new Error("Unknown variable dynamic import: "+t+(t.split("/").length!==n?". Note that variables only represent file names one level deep.":""))))})},eu=ki({setup(e,{slots:t}){const n=de(!1);return Mt(()=>{n.value=!0}),()=>n.value&&t.default?t.default():null}});function tu(){ge&&window.addEventListener("click",e=>{var n;const t=e.target;if(t.matches(".vp-code-group input")){const s=(n=t.parentElement)==null?void 0:n.parentElement;if(!s)return;const r=Array.from(s.querySelectorAll("input")).indexOf(t);if(r<0)return;const i=s.querySelector(".blocks");if(!i)return;const o=Array.from(i.children).find(u=>u.classList.contains("active"));if(!o)return;const l=i.children[r];if(!l||o===l)return;o.classList.remove("active"),l.classList.add("active");const c=s==null?void 0:s.querySelector(`label[for="${t.id}"]`);c==null||c.scrollIntoView({block:"nearest"})}})}function nu(){if(ge){const e=new WeakMap;window.addEventListener("click",t=>{var s;const n=t.target;if(n.matches('div[class*="language-"] > button.copy')){const r=n.parentElement,i=(s=n.nextElementSibling)==null?void 0:s.nextElementSibling;if(!r||!i)return;const o=/language-(shellscript|shell|bash|sh|zsh)/.test(r.className),l=[".vp-copy-ignore",".diff.remove"],c=i.cloneNode(!0);c.querySelectorAll(l.join(",")).forEach(f=>f.remove());let u=c.textContent||"";o&&(u=u.replace(/^ *(\$|>) /gm,"").trim()),yf(u).then(()=>{n.classList.add("copied"),clearTimeout(e.get(n));const f=setTimeout(()=>{n.classList.remove("copied"),n.blur(),e.delete(n)},2e3);e.set(n,f)})}})}}async function yf(e){try{return navigator.clipboard.writeText(e)}catch{const t=document.createElement("textarea"),n=document.activeElement;t.value=e,t.setAttribute("readonly",""),t.style.contain="strict",t.style.position="absolute",t.style.left="-9999px",t.style.fontSize="12pt";const s=document.getSelection(),r=s?s.rangeCount>0&&s.getRangeAt(0):null;document.body.appendChild(t),t.select(),t.selectionStart=0,t.selectionEnd=e.length,document.execCommand("copy"),document.body.removeChild(t),r&&(s.removeAllRanges(),s.addRange(r)),n&&n.focus()}}function su(e,t){let n=!0,s=[];const r=i=>{if(n){n=!1,i.forEach(l=>{const c=_s(l);for(const u of document.head.children)if(u.isEqualNode(c)){s.push(u);return}});return}const o=i.map(_s);s.forEach((l,c)=>{const u=o.findIndex(f=>f==null?void 0:f.isEqualNode(l??null));u!==-1?delete o[u]:(l==null||l.remove(),delete s[c])}),o.forEach(l=>l&&document.head.appendChild(l)),s=[...s,...o].filter(Boolean)};co(()=>{const i=e.data,o=t.value,l=i&&i.description,c=i&&i.frontmatter.head||[],u=Fo(o,i);u!==document.title&&(document.title=u);const f=l||o.description;let h=document.querySelector("meta[name=description]");h?h.getAttribute("content")!==f&&h.setAttribute("content",f):_s(["meta",{name:"description",content:f}]),r(Ho(o.head,bf(c)))})}function _s([e,t,n]){const s=document.createElement(e);for(const r in t)s.setAttribute(r,t[r]);return n&&(s.innerHTML=n),e==="script"&&!t.async&&(s.async=!1),s}function _f(e){return e[0]==="meta"&&e[1]&&e[1].name==="description"}function bf(e){return e.filter(t=>!_f(t))}const bs=new Set,jo=()=>document.createElement("link"),vf=e=>{const t=jo();t.rel="prefetch",t.href=e,document.head.appendChild(t)},wf=e=>{const t=new XMLHttpRequest;t.open("GET",e,t.withCredentials=!0),t.send()};let gn;const Sf=ge&&(gn=jo())&&gn.relList&&gn.relList.supports&&gn.relList.supports("prefetch")?vf:wf;function ru(){if(!ge||!window.IntersectionObserver)return;let e;if((e=navigator.connection)&&(e.saveData||/2g/.test(e.effectiveType)))return;const t=window.requestIdleCallback||setTimeout;let n=null;const s=()=>{n&&n.disconnect(),n=new IntersectionObserver(i=>{i.forEach(o=>{if(o.isIntersecting){const l=o.target;n.unobserve(l);const{pathname:c}=l;if(!bs.has(c)){bs.add(c);const u=df(c);u&&Sf(u)}}})}),t(()=>{document.querySelectorAll("#app a").forEach(i=>{const{hostname:o,pathname:l}=new URL(i.href instanceof SVGAnimatedString?i.href.animVal:i.href,i.baseURI),c=l.match(/\.\w+$/);c&&c[0]!==".html"||i.target!=="_blank"&&o===location.hostname&&(l!==location.pathname?n.observe(i):bs.add(l))})})};Mt(s);const r=$o();ke(()=>r.path,s),Bn(()=>{n&&n.disconnect()})}export{xf as $,hf as A,Af as B,Of as C,xi as D,Jf as E,Se as F,he as G,Lo as H,Rf as I,$o as J,$c as K,Rt as L,Yf as M,Ds as N,Kf as O,Vn as P,Gf as Q,ge as R,$n as S,$f as T,Dn as U,mc as V,Wi as W,Cf as X,Tf as Y,jf as Z,Bf as _,yo as a,Is as a0,ai as a1,nl as a2,Hf as a3,mf as a4,Mf as a5,qf as a6,Pf as a7,kf as a8,Vf as a9,Lf as aa,Ef as ab,ae as ac,qn as ad,mt as ae,Zf as af,Wf as ag,su as ah,pf as ai,Xf as aj,af as ak,Qf as al,eu as am,yt as an,Uf as ao,zf as ap,df as aq,ru as ar,nu as as,tu as at,Os as b,Ff as c,ki as d,Df as e,cf as f,Jr as g,ie as h,ef as i,mo as j,Ci as k,Za as l,Oo as m,$s as n,Rs as o,de as p,ke as q,If as r,co as s,tl as t,ff as u,Mt as v,Vl as w,Bn as x,Nf as y,nc as z}; diff --git a/assets/chunks/index-Ba501-HG.DLGTjfcz.js b/assets/chunks/index-Ba501-HG.BBoApf2J.js similarity index 99% rename from assets/chunks/index-Ba501-HG.DLGTjfcz.js rename to assets/chunks/index-Ba501-HG.BBoApf2J.js index f50c22f220..aa0a59782e 100644 --- a/assets/chunks/index-Ba501-HG.DLGTjfcz.js +++ b/assets/chunks/index-Ba501-HG.BBoApf2J.js @@ -1,4 +1,4 @@ -import{c as Dt,a as Oa}from"./commonjs-dynamic-modules-DLbDWi6a.CRNIONdy.js";import{t as hs}from"./index.CafPLwUV.js";import{g as eg,a as tg}from"./colz-DJZvo_8B.DBiU5Tau.js";import"./framework.eq-HTtE3.js";var rg=Object.defineProperty,ig=(B,v,e)=>v in B?rg(B,v,{enumerable:!0,configurable:!0,writable:!0,value:e}):B[v]=e,Si=(B,v,e)=>ig(B,typeof v!="symbol"?v+"":v,e),Wa={exports:{}};/** +import{c as Dt,a as Oa}from"./commonjs-dynamic-modules-DLbDWi6a.CRNIONdy.js";import{t as hs}from"./index.MWfHGcqb.js";import{g as eg,a as tg}from"./colz-DJZvo_8B.DBiU5Tau.js";import"./framework.CHSXtLMd.js";var rg=Object.defineProperty,ig=(B,v,e)=>v in B?rg(B,v,{enumerable:!0,configurable:!0,writable:!0,value:e}):B[v]=e,Si=(B,v,e)=>ig(B,typeof v!="symbol"?v+"":v,e),Wa={exports:{}};/** * @license * Lodash * Copyright OpenJS Foundation and other contributors diff --git a/assets/chunks/index-Co9E57uv.DM_Nu_-Q.js b/assets/chunks/index-Co9E57uv.BtZPXcWW.js similarity index 99% rename from assets/chunks/index-Co9E57uv.DM_Nu_-Q.js rename to assets/chunks/index-Co9E57uv.BtZPXcWW.js index dbd2620ae0..ce8df0ceeb 100644 --- a/assets/chunks/index-Co9E57uv.DM_Nu_-Q.js +++ b/assets/chunks/index-Co9E57uv.BtZPXcWW.js @@ -1,5 +1,5 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/chunks/jszip.min-BIf20mgf.BsDI-Ugu.js","assets/chunks/commonjs-dynamic-modules-DLbDWi6a.CRNIONdy.js"])))=>i.map(i=>d[i]); -import{ag as gc}from"./framework.eq-HTtE3.js";import{C as da}from"./colz-DJZvo_8B.DBiU5Tau.js";window.E0DD32CBDCB63F=function(){var o={version:"3.5.9"},h=[].slice,w=function(t){return h.call(t)},v=this.document;function z(t){return t&&(t.ownerDocument||t.document||t).documentElement}function B(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}if(v)try{w(v.documentElement.childNodes)[0].nodeType}catch{w=function(e){for(var n=e.length,r=new Array(n);n--;)r[n]=e[n];return r}}if(Date.now||(Date.now=function(){return+new Date}),v)try{v.createElement("DIV").style.setProperty("opacity",0,"")}catch{var T=this.Element.prototype,D=T.setAttribute,R=T.setAttributeNS,M=this.CSSStyleDeclaration.prototype,I=M.setProperty;T.setAttribute=function(e,n){D.call(this,e,n+"")},T.setAttributeNS=function(e,n,r){R.call(this,e,n,r+"")},M.setProperty=function(e,n,r){I.call(this,e,n+"",r)}}o.ascending=k;function k(t,e){return te?1:t>=e?0:NaN}o.descending=function(t,e){return et?1:e>=t?0:NaN},o.min=function(t,e){var n=-1,r=t.length,i,a;if(arguments.length===1){for(;++n=a){i=a;break}for(;++na&&(i=a)}else{for(;++n=a){i=a;break}for(;++na&&(i=a)}return i},o.max=function(t,e){var n=-1,r=t.length,i,a;if(arguments.length===1){for(;++n=a){i=a;break}for(;++ni&&(i=a)}else{for(;++n=a){i=a;break}for(;++ni&&(i=a)}return i},o.extent=function(t,e){var n=-1,r=t.length,i,a,l;if(arguments.length===1){for(;++n=a){i=l=a;break}for(;++na&&(i=a),l=a){i=l=a;break}for(;++na&&(i=a),l1)return l/(u-1)},o.deviation=function(){var t=o.variance.apply(this,arguments);return t&&Math.sqrt(t)};function q(t){return{left:function(e,n,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=e.length);r>>1;t(e[a],n)<0?r=a+1:i=a}return r},right:function(e,n,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=e.length);r>>1;t(e[a],n)>0?i=a:r=a+1}return r}}}var G=q(k);o.bisectLeft=G.left,o.bisect=o.bisectRight=G.right,o.bisector=function(t){return q(t.length===1?function(e,n){return k(t(e),n)}:t)},o.shuffle=function(t,e,n){(r=arguments.length)<3&&(n=t.length,r<2&&(e=0));for(var r=n-e,i,a;r;)a=Math.random()*r--|0,i=t[r+e],t[r+e]=t[a+e],t[a+e]=i;return t},o.permute=function(t,e){for(var n=e.length,r=new Array(n);n--;)r[n]=t[e[n]];return r},o.pairs=function(t){for(var e=0,n=t.length-1,r=t[0],i=new Array(n<0?0:n);e=0;)for(l=t[e],n=l.length;--n>=0;)a[--i]=l[n];return a};var rt=Math.abs;o.range=function(t,e,n){if(arguments.length<3&&(n=1,arguments.length<2&&(e=t,t=0)),(e-t)/n===1/0)throw new Error("infinite range");var r=[],i=vt(rt(n)),a=-1,l;if(t*=i,e*=i,n*=i,n<0)for(;(l=t+n*++a)>e;)r.push(l/i);else for(;(l=t+n*++a)=e.length)return i?i.call(t,u):r?u.sort(r):u;for(var f=-1,g=u.length,d=e[c++],x,A,m,_=new dt,y;++f=e.length)return s;var c=[],f=n[u++];return s.forEach(function(g,d){c.push({key:g,values:l(d,u)})}),f?c.sort(function(g,d){return f(g.key,d.key)}):c}return t.map=function(s,u){return a(u,s,0)},t.entries=function(s){return l(a(o.map,s,0),0)},t.key=function(s){return e.push(s),t},t.sortKeys=function(s){return n[e.length-1]=s,t},t.sortValues=function(s){return r=s,t},t.rollup=function(s){return i=s,t},t},o.set=function(t){var e=new le;if(t)for(var n=0,r=t.length;n=0&&(r=t.slice(n+1),t=t.slice(0,n)),t)return arguments.length<2?this[t].on(r):this[t].on(r,e);if(arguments.length===2){if(e==null)for(t in this)this.hasOwnProperty(t)&&this[t].on(r,null);return this}};function ae(t){var e=[],n=new dt;function r(){for(var i=e,a=-1,l=i.length,s;++a=0&&(n=t.slice(0,e))!=="xmlns"&&(t=t.slice(e+1)),Pe.hasOwnProperty(n)?{space:Pe[n],local:t}:t}},Ot.attr=function(t,e){if(arguments.length<2){if(typeof t=="string"){var n=this.node();return t=o.ns.qualify(t),t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}for(e in t)this.each(mn(e,t[e]));return this}return this.each(mn(t,e))};function mn(t,e){t=o.ns.qualify(t);function n(){this.removeAttribute(t)}function r(){this.removeAttributeNS(t.space,t.local)}function i(){this.setAttribute(t,e)}function a(){this.setAttributeNS(t.space,t.local,e)}function l(){var u=e.apply(this,arguments);u==null?this.removeAttribute(t):this.setAttribute(t,u)}function s(){var u=e.apply(this,arguments);u==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,u)}return e==null?t.local?r:n:typeof e=="function"?t.local?s:l:t.local?a:i}function un(t){return t.trim().replace(/\s+/g," ")}Ot.classed=function(t,e){if(arguments.length<2){if(typeof t=="string"){var n=this.node(),r=(t=Se(t)).length,i=-1;if(e=n.classList){for(;++i=0;)(a=n[r])&&(i&&i!==a.nextSibling&&i.parentNode.insertBefore(a,i),i=a);return this},Ot.sort=function(t){t=di.apply(this,arguments);for(var e=-1,n=this.length;++e=e&&(e=i+1);!(u=l[e])&&++e0&&(t=t.slice(0,i));var l=E.get(t);l&&(t=l,a=U);function s(){var f=this[r];f&&(this.removeEventListener(t,f,f.$),delete this[r])}function u(){var f=a(e,w(arguments));s.call(this),this.addEventListener(t,this[r]=f,f.$=n),f._=e}function c(){var f=new RegExp("^__on([^.]+)"+o.requote(t)+"$"),g;for(var d in this)if(g=d.match(f)){var x=this[d];this.removeEventListener(g[1],x,x.$),delete this[d]}}return i?e?u:s:e?ue:c}var E=o.map({mouseenter:"mouseover",mouseleave:"mouseout"});v&&E.forEach(function(t){"on"+t in v&&E.remove(t)});function j(t,e){return function(n){var r=o.event;o.event=n,e[0]=this.__data__;try{t.apply(this,e)}finally{o.event=r}}}function U(t,e){var n=j(t,e);return function(r){var i=this,a=r.relatedTarget;(!a||a!==i&&!(a.compareDocumentPosition(i)&8))&&n.call(i,r)}}var J,at=0;function lt(t){var e=".dragsuppress-"+ ++at,n="click"+e,r=o.select(B(t)).on("touchmove"+e,Qt).on("dragstart"+e,Qt).on("selectstart"+e,Qt);if(J==null&&(J="onselectstart"in t?!1:ge(t.style,"userSelect")),J){var i=z(t).style,a=i[J];i[J]="none"}return function(l){if(r.on(e,null),J&&(i[J]=a),l){var s=function(){r.on(n,null)};r.on(n,function(){Qt(),s()},!0),setTimeout(s,0)}}}o.mouse=function(t){return ct(t,me())};var ot=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;function ct(t,e){e.changedTouches&&(e=e.changedTouches[0]);var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();if(ot<0){var i=B(t);if(i.scrollX||i.scrollY){n=o.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var a=n[0][0].getScreenCTM();ot=!(a.f||a.e),n.remove()}}return ot?(r.x=e.pageX,r.y=e.pageY):(r.x=e.clientX,r.y=e.clientY),r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}var l=t.getBoundingClientRect();return[e.clientX-l.left-t.clientLeft,e.clientY-l.top-t.clientTop]}o.touch=function(t,e,n){if(arguments.length<3&&(n=e,e=me().changedTouches),e){for(var r=0,i=e.length,a;r0?1:t<0?-1:0}function X(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}function ht(t){return t>1?0:t<-1?it:Math.acos(t)}function Yt(t){return t>1?bt:t<-1?-bt:Math.asin(t)}function Wt(t){return((t=Math.exp(t))-1/t)/2}function Xt(t){return((t=Math.exp(t))+1/t)/2}function Jt(t){return((t=Math.exp(2*t))-1)/(t+1)}function te(t){return(t=Math.sin(t/2))*t}var Tt=Math.SQRT2,Rt=2,Bt=4;o.interpolateZoom=function(t,e){var n=t[0],r=t[1],i=t[2],a=e[0],l=e[1],s=e[2],u=a-n,c=l-r,f=u*u+c*c,g,d;if(f0&&(nt=nt.transition().duration(l)),nt.call(b.event)}function st(){_&&_.domain(m.range().map(function(nt){return(nt-t.x)/t.k}).map(m.invert)),F&&F.domain(y.range().map(function(nt){return(nt-t.y)/t.k}).map(y.invert))}function gt(nt){s++||nt({type:"zoomstart"})}function At(nt){st(),nt({type:"zoom",scale:t.k,translate:[t.x,t.y]})}function xt(nt){--s||(nt({type:"zoomend"}),n=null)}function Ct(){var nt=this,mt=A.of(nt,arguments),Dt=0,Ht=o.select(B(nt)).on(c,pe).on(f,Ee),Zt=P(o.mouse(nt)),se=lt(nt);si.call(nt),gt(mt);function pe(){Dt=1,H(o.mouse(nt),Zt),At(mt)}function Ee(){Ht.on(c,null).on(f,null),se(Dt),xt(mt)}}function tt(){var nt=this,mt=A.of(nt,arguments),Dt={},Ht=0,Zt,se=".zoom-"+o.event.changedTouches[0].identifier,pe="touchmove"+se,Ee="touchend"+se,Ie=[],Be=o.select(nt),Re=lt(nt);Oe(),gt(mt),Be.on(u,null).on(d,Oe);function Te(){var tn=o.touches(nt);return Zt=t.k,tn.forEach(function(Fe){Fe.identifier in Dt&&(Dt[Fe.identifier]=P(Fe))}),tn}function Oe(){var tn=o.event.target;o.select(tn).on(pe,In).on(Ee,hc),Ie.push(tn);for(var Fe=o.event.changedTouches,Xe=0,ln=Fe.length;Xe1){var zn=We[0],kn=We[1],fi=zn[0]-kn[0],ws=zn[1]-kn[1];Ht=fi*fi+ws*ws}}function In(){var tn=o.touches(nt),Fe,Xe,ln,We;si.call(nt);for(var Qn=0,zn=tn.length;Qn1?1:e,n=n<0?0:n>1?1:n,i=n<=.5?n*(1+e):n+e-n*e,r=2*n-i;function a(s){return s>360?s-=360:s<0&&(s+=360),s<60?r+(i-r)*s/60:s<180?i:s<240?r+(i-r)*(240-s)/60:r}function l(s){return Math.round(a(s)*255)}return new ze(l(t+120),l(t),l(t-120))}o.hcl=ke;function ke(t,e,n){return this instanceof ke?(this.h=+t,this.c=+e,void(this.l=+n)):arguments.length<2?t instanceof ke?new ke(t.h,t.c,t.l):t instanceof xe?yr(t.l,t.a,t.b):yr((t=va((t=o.rgb(t)).r,t.g,t.b)).l,t.a,t.b):new ke(t,e,n)}var Ne=ke.prototype=new Kt;Ne.brighter=function(t){return new ke(this.h,this.c,Math.min(100,this.l+rn*(arguments.length?t:1)))},Ne.darker=function(t){return new ke(this.h,this.c,Math.max(0,this.l-rn*(arguments.length?t:1)))},Ne.rgb=function(){return Ge(this.h,this.c,this.l).rgb()};function Ge(t,e,n){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new xe(n,Math.cos(t*=_t)*e,Math.sin(t)*e)}o.lab=xe;function xe(t,e,n){return this instanceof xe?(this.l=+t,this.a=+e,void(this.b=+n)):arguments.length<2?t instanceof xe?new xe(t.l,t.a,t.b):t instanceof ke?Ge(t.h,t.c,t.l):va((t=ze(t)).r,t.g,t.b):new xe(t,e,n)}var rn=18,Ve=.95047,an=1,Ue=1.08883,fn=xe.prototype=new Kt;fn.brighter=function(t){return new xe(Math.min(100,this.l+rn*(arguments.length?t:1)),this.a,this.b)},fn.darker=function(t){return new xe(Math.max(0,this.l-rn*(arguments.length?t:1)),this.a,this.b)},fn.rgb=function(){return jn(this.l,this.a,this.b)};function jn(t,e,n){var r=(t+16)/116,i=r+e/500,a=r-n/200;return i=tr(i)*Ve,r=tr(r)*an,a=tr(a)*Ue,new ze(mi(3.2404542*i-1.5371385*r-.4985314*a),mi(-.969266*i+1.8760108*r+.041556*a),mi(.0556434*i-.2040259*r+1.0572252*a))}function yr(t,e,n){return t>0?new ke(Math.atan2(n,e)*zt,Math.sqrt(e*e+n*n),t):new ke(NaN,NaN,t)}function tr(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function pi(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function mi(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}o.rgb=ze;function ze(t,e,n){return this instanceof ze?(this.r=~~t,this.g=~~e,void(this.b=~~n)):arguments.length<2?t instanceof ze?new ze(t.r,t.g,t.b):_a(""+t,ze,Mn):new ze(t,e,n)}function ma(t){return new ze(t>>16,t>>8&255,t&255)}function vr(t){return ma(t)+""}var xr=ze.prototype=new Kt;xr.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,n=this.g,r=this.b,i=30;return!e&&!n&&!r?new ze(i,i,i):(e&&e>4,r=r>>4|r,i=u&240,i=i>>4|i,a=u&15,a=a<<4|a):t.length===7&&(r=(u&16711680)>>16,i=(u&65280)>>8,a=u&255)),e(r,i,a))}function ya(t,e,n){var r=Math.min(t/=255,e/=255,n/=255),i=Math.max(t,e,n),a=i-r,l,s,u=(i+r)/2;return a?(s=u<.5?a/(i+r):a/(2-i-r),t==i?l=(e-n)/a+(e0&&u<1?0:l),new he(l,s,u)}function va(t,e,n){t=_i(t),e=_i(e),n=_i(n);var r=pi((.4124564*t+.3575761*e+.1804375*n)/Ve),i=pi((.2126729*t+.7151522*e+.072175*n)/an),a=pi((.0193339*t+.119192*e+.9503041*n)/Ue);return xe(116*i-16,500*(r-i),200*(i-a))}function _i(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function yi(t){var e=parseFloat(t);return t.charAt(t.length-1)==="%"?Math.round(e*2.55):e}var br=o.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});br.forEach(function(t,e){br.set(t,ma(e))});function de(t){return typeof t=="function"?t:function(){return t}}o.functor=de,o.xhr=vi(ie);function vi(t){return function(e,n,r){return arguments.length===2&&typeof n=="function"&&(r=n,n=null),wr(e,n,t,r)}}function wr(t,e,n,r){var i={},a=o.dispatch("beforesend","progress","load","error"),l={},s=new XMLHttpRequest,u=null;this.XDomainRequest&&!("withCredentials"in s)&&/^(http(s)?:)?\/\//.test(t)&&(s=new XDomainRequest),"onload"in s?s.onload=s.onerror=c:s.onreadystatechange=function(){s.readyState>3&&c()};function c(){var f=s.status,g;if(!f&&Ms(s)||f>=200&&f<300||f===304){try{g=n.call(i,s)}catch(d){a.error.call(i,d);return}a.load.call(i,g)}else a.error.call(i,s)}return s.onprogress=function(f){var g=o.event;o.event=f;try{a.progress.call(i,s)}finally{o.event=g}},i.header=function(f,g){return f=(f+"").toLowerCase(),arguments.length<2?l[f]:(g==null?delete l[f]:l[f]=g+"",i)},i.mimeType=function(f){return arguments.length?(e=f==null?null:f+"",i):e},i.responseType=function(f){return arguments.length?(u=f,i):u},i.response=function(f){return n=f,i},["get","post"].forEach(function(f){i[f]=function(){return i.send.apply(i,[f].concat(w(arguments)))}}),i.send=function(f,g,d){if(arguments.length===2&&typeof g=="function"&&(d=g,g=null),s.open(f,t,!0),e!=null&&!("accept"in l)&&(l.accept=e+",*/*"),s.setRequestHeader)for(var x in l)s.setRequestHeader(x,l[x]);return e!=null&&s.overrideMimeType&&s.overrideMimeType(e),u!=null&&(s.responseType=u),d!=null&&i.on("error",d).on("load",function(A){d(null,A)}),a.beforesend.call(i,s),s.send(g??null),i},i.abort=function(){return s.abort(),i},o.rebind(i,a,"on"),r==null?i:i.get(Cs(r))}function Cs(t){return t.length===1?function(e,n){t(e==null?n:null)}:t}function Ms(t){var e=t.responseType;return e&&e!=="text"?t.response:t.responseText}o.dsv=function(t,e){var n=new RegExp('["'+t+` +import{ag as gc}from"./framework.CHSXtLMd.js";import{C as da}from"./colz-DJZvo_8B.DBiU5Tau.js";window.E0DD32CBDCB63F=function(){var o={version:"3.5.9"},h=[].slice,w=function(t){return h.call(t)},v=this.document;function z(t){return t&&(t.ownerDocument||t.document||t).documentElement}function B(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}if(v)try{w(v.documentElement.childNodes)[0].nodeType}catch{w=function(e){for(var n=e.length,r=new Array(n);n--;)r[n]=e[n];return r}}if(Date.now||(Date.now=function(){return+new Date}),v)try{v.createElement("DIV").style.setProperty("opacity",0,"")}catch{var T=this.Element.prototype,D=T.setAttribute,R=T.setAttributeNS,M=this.CSSStyleDeclaration.prototype,I=M.setProperty;T.setAttribute=function(e,n){D.call(this,e,n+"")},T.setAttributeNS=function(e,n,r){R.call(this,e,n,r+"")},M.setProperty=function(e,n,r){I.call(this,e,n+"",r)}}o.ascending=k;function k(t,e){return te?1:t>=e?0:NaN}o.descending=function(t,e){return et?1:e>=t?0:NaN},o.min=function(t,e){var n=-1,r=t.length,i,a;if(arguments.length===1){for(;++n=a){i=a;break}for(;++na&&(i=a)}else{for(;++n=a){i=a;break}for(;++na&&(i=a)}return i},o.max=function(t,e){var n=-1,r=t.length,i,a;if(arguments.length===1){for(;++n=a){i=a;break}for(;++ni&&(i=a)}else{for(;++n=a){i=a;break}for(;++ni&&(i=a)}return i},o.extent=function(t,e){var n=-1,r=t.length,i,a,l;if(arguments.length===1){for(;++n=a){i=l=a;break}for(;++na&&(i=a),l=a){i=l=a;break}for(;++na&&(i=a),l1)return l/(u-1)},o.deviation=function(){var t=o.variance.apply(this,arguments);return t&&Math.sqrt(t)};function q(t){return{left:function(e,n,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=e.length);r>>1;t(e[a],n)<0?r=a+1:i=a}return r},right:function(e,n,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=e.length);r>>1;t(e[a],n)>0?i=a:r=a+1}return r}}}var G=q(k);o.bisectLeft=G.left,o.bisect=o.bisectRight=G.right,o.bisector=function(t){return q(t.length===1?function(e,n){return k(t(e),n)}:t)},o.shuffle=function(t,e,n){(r=arguments.length)<3&&(n=t.length,r<2&&(e=0));for(var r=n-e,i,a;r;)a=Math.random()*r--|0,i=t[r+e],t[r+e]=t[a+e],t[a+e]=i;return t},o.permute=function(t,e){for(var n=e.length,r=new Array(n);n--;)r[n]=t[e[n]];return r},o.pairs=function(t){for(var e=0,n=t.length-1,r=t[0],i=new Array(n<0?0:n);e=0;)for(l=t[e],n=l.length;--n>=0;)a[--i]=l[n];return a};var rt=Math.abs;o.range=function(t,e,n){if(arguments.length<3&&(n=1,arguments.length<2&&(e=t,t=0)),(e-t)/n===1/0)throw new Error("infinite range");var r=[],i=vt(rt(n)),a=-1,l;if(t*=i,e*=i,n*=i,n<0)for(;(l=t+n*++a)>e;)r.push(l/i);else for(;(l=t+n*++a)=e.length)return i?i.call(t,u):r?u.sort(r):u;for(var f=-1,g=u.length,d=e[c++],x,A,m,_=new dt,y;++f=e.length)return s;var c=[],f=n[u++];return s.forEach(function(g,d){c.push({key:g,values:l(d,u)})}),f?c.sort(function(g,d){return f(g.key,d.key)}):c}return t.map=function(s,u){return a(u,s,0)},t.entries=function(s){return l(a(o.map,s,0),0)},t.key=function(s){return e.push(s),t},t.sortKeys=function(s){return n[e.length-1]=s,t},t.sortValues=function(s){return r=s,t},t.rollup=function(s){return i=s,t},t},o.set=function(t){var e=new le;if(t)for(var n=0,r=t.length;n=0&&(r=t.slice(n+1),t=t.slice(0,n)),t)return arguments.length<2?this[t].on(r):this[t].on(r,e);if(arguments.length===2){if(e==null)for(t in this)this.hasOwnProperty(t)&&this[t].on(r,null);return this}};function ae(t){var e=[],n=new dt;function r(){for(var i=e,a=-1,l=i.length,s;++a=0&&(n=t.slice(0,e))!=="xmlns"&&(t=t.slice(e+1)),Pe.hasOwnProperty(n)?{space:Pe[n],local:t}:t}},Ot.attr=function(t,e){if(arguments.length<2){if(typeof t=="string"){var n=this.node();return t=o.ns.qualify(t),t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}for(e in t)this.each(mn(e,t[e]));return this}return this.each(mn(t,e))};function mn(t,e){t=o.ns.qualify(t);function n(){this.removeAttribute(t)}function r(){this.removeAttributeNS(t.space,t.local)}function i(){this.setAttribute(t,e)}function a(){this.setAttributeNS(t.space,t.local,e)}function l(){var u=e.apply(this,arguments);u==null?this.removeAttribute(t):this.setAttribute(t,u)}function s(){var u=e.apply(this,arguments);u==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,u)}return e==null?t.local?r:n:typeof e=="function"?t.local?s:l:t.local?a:i}function un(t){return t.trim().replace(/\s+/g," ")}Ot.classed=function(t,e){if(arguments.length<2){if(typeof t=="string"){var n=this.node(),r=(t=Se(t)).length,i=-1;if(e=n.classList){for(;++i=0;)(a=n[r])&&(i&&i!==a.nextSibling&&i.parentNode.insertBefore(a,i),i=a);return this},Ot.sort=function(t){t=di.apply(this,arguments);for(var e=-1,n=this.length;++e=e&&(e=i+1);!(u=l[e])&&++e0&&(t=t.slice(0,i));var l=E.get(t);l&&(t=l,a=U);function s(){var f=this[r];f&&(this.removeEventListener(t,f,f.$),delete this[r])}function u(){var f=a(e,w(arguments));s.call(this),this.addEventListener(t,this[r]=f,f.$=n),f._=e}function c(){var f=new RegExp("^__on([^.]+)"+o.requote(t)+"$"),g;for(var d in this)if(g=d.match(f)){var x=this[d];this.removeEventListener(g[1],x,x.$),delete this[d]}}return i?e?u:s:e?ue:c}var E=o.map({mouseenter:"mouseover",mouseleave:"mouseout"});v&&E.forEach(function(t){"on"+t in v&&E.remove(t)});function j(t,e){return function(n){var r=o.event;o.event=n,e[0]=this.__data__;try{t.apply(this,e)}finally{o.event=r}}}function U(t,e){var n=j(t,e);return function(r){var i=this,a=r.relatedTarget;(!a||a!==i&&!(a.compareDocumentPosition(i)&8))&&n.call(i,r)}}var J,at=0;function lt(t){var e=".dragsuppress-"+ ++at,n="click"+e,r=o.select(B(t)).on("touchmove"+e,Qt).on("dragstart"+e,Qt).on("selectstart"+e,Qt);if(J==null&&(J="onselectstart"in t?!1:ge(t.style,"userSelect")),J){var i=z(t).style,a=i[J];i[J]="none"}return function(l){if(r.on(e,null),J&&(i[J]=a),l){var s=function(){r.on(n,null)};r.on(n,function(){Qt(),s()},!0),setTimeout(s,0)}}}o.mouse=function(t){return ct(t,me())};var ot=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;function ct(t,e){e.changedTouches&&(e=e.changedTouches[0]);var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();if(ot<0){var i=B(t);if(i.scrollX||i.scrollY){n=o.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var a=n[0][0].getScreenCTM();ot=!(a.f||a.e),n.remove()}}return ot?(r.x=e.pageX,r.y=e.pageY):(r.x=e.clientX,r.y=e.clientY),r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}var l=t.getBoundingClientRect();return[e.clientX-l.left-t.clientLeft,e.clientY-l.top-t.clientTop]}o.touch=function(t,e,n){if(arguments.length<3&&(n=e,e=me().changedTouches),e){for(var r=0,i=e.length,a;r0?1:t<0?-1:0}function X(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}function ht(t){return t>1?0:t<-1?it:Math.acos(t)}function Yt(t){return t>1?bt:t<-1?-bt:Math.asin(t)}function Wt(t){return((t=Math.exp(t))-1/t)/2}function Xt(t){return((t=Math.exp(t))+1/t)/2}function Jt(t){return((t=Math.exp(2*t))-1)/(t+1)}function te(t){return(t=Math.sin(t/2))*t}var Tt=Math.SQRT2,Rt=2,Bt=4;o.interpolateZoom=function(t,e){var n=t[0],r=t[1],i=t[2],a=e[0],l=e[1],s=e[2],u=a-n,c=l-r,f=u*u+c*c,g,d;if(f0&&(nt=nt.transition().duration(l)),nt.call(b.event)}function st(){_&&_.domain(m.range().map(function(nt){return(nt-t.x)/t.k}).map(m.invert)),F&&F.domain(y.range().map(function(nt){return(nt-t.y)/t.k}).map(y.invert))}function gt(nt){s++||nt({type:"zoomstart"})}function At(nt){st(),nt({type:"zoom",scale:t.k,translate:[t.x,t.y]})}function xt(nt){--s||(nt({type:"zoomend"}),n=null)}function Ct(){var nt=this,mt=A.of(nt,arguments),Dt=0,Ht=o.select(B(nt)).on(c,pe).on(f,Ee),Zt=P(o.mouse(nt)),se=lt(nt);si.call(nt),gt(mt);function pe(){Dt=1,H(o.mouse(nt),Zt),At(mt)}function Ee(){Ht.on(c,null).on(f,null),se(Dt),xt(mt)}}function tt(){var nt=this,mt=A.of(nt,arguments),Dt={},Ht=0,Zt,se=".zoom-"+o.event.changedTouches[0].identifier,pe="touchmove"+se,Ee="touchend"+se,Ie=[],Be=o.select(nt),Re=lt(nt);Oe(),gt(mt),Be.on(u,null).on(d,Oe);function Te(){var tn=o.touches(nt);return Zt=t.k,tn.forEach(function(Fe){Fe.identifier in Dt&&(Dt[Fe.identifier]=P(Fe))}),tn}function Oe(){var tn=o.event.target;o.select(tn).on(pe,In).on(Ee,hc),Ie.push(tn);for(var Fe=o.event.changedTouches,Xe=0,ln=Fe.length;Xe1){var zn=We[0],kn=We[1],fi=zn[0]-kn[0],ws=zn[1]-kn[1];Ht=fi*fi+ws*ws}}function In(){var tn=o.touches(nt),Fe,Xe,ln,We;si.call(nt);for(var Qn=0,zn=tn.length;Qn1?1:e,n=n<0?0:n>1?1:n,i=n<=.5?n*(1+e):n+e-n*e,r=2*n-i;function a(s){return s>360?s-=360:s<0&&(s+=360),s<60?r+(i-r)*s/60:s<180?i:s<240?r+(i-r)*(240-s)/60:r}function l(s){return Math.round(a(s)*255)}return new ze(l(t+120),l(t),l(t-120))}o.hcl=ke;function ke(t,e,n){return this instanceof ke?(this.h=+t,this.c=+e,void(this.l=+n)):arguments.length<2?t instanceof ke?new ke(t.h,t.c,t.l):t instanceof xe?yr(t.l,t.a,t.b):yr((t=va((t=o.rgb(t)).r,t.g,t.b)).l,t.a,t.b):new ke(t,e,n)}var Ne=ke.prototype=new Kt;Ne.brighter=function(t){return new ke(this.h,this.c,Math.min(100,this.l+rn*(arguments.length?t:1)))},Ne.darker=function(t){return new ke(this.h,this.c,Math.max(0,this.l-rn*(arguments.length?t:1)))},Ne.rgb=function(){return Ge(this.h,this.c,this.l).rgb()};function Ge(t,e,n){return isNaN(t)&&(t=0),isNaN(e)&&(e=0),new xe(n,Math.cos(t*=_t)*e,Math.sin(t)*e)}o.lab=xe;function xe(t,e,n){return this instanceof xe?(this.l=+t,this.a=+e,void(this.b=+n)):arguments.length<2?t instanceof xe?new xe(t.l,t.a,t.b):t instanceof ke?Ge(t.h,t.c,t.l):va((t=ze(t)).r,t.g,t.b):new xe(t,e,n)}var rn=18,Ve=.95047,an=1,Ue=1.08883,fn=xe.prototype=new Kt;fn.brighter=function(t){return new xe(Math.min(100,this.l+rn*(arguments.length?t:1)),this.a,this.b)},fn.darker=function(t){return new xe(Math.max(0,this.l-rn*(arguments.length?t:1)),this.a,this.b)},fn.rgb=function(){return jn(this.l,this.a,this.b)};function jn(t,e,n){var r=(t+16)/116,i=r+e/500,a=r-n/200;return i=tr(i)*Ve,r=tr(r)*an,a=tr(a)*Ue,new ze(mi(3.2404542*i-1.5371385*r-.4985314*a),mi(-.969266*i+1.8760108*r+.041556*a),mi(.0556434*i-.2040259*r+1.0572252*a))}function yr(t,e,n){return t>0?new ke(Math.atan2(n,e)*zt,Math.sqrt(e*e+n*n),t):new ke(NaN,NaN,t)}function tr(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function pi(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function mi(t){return Math.round(255*(t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}o.rgb=ze;function ze(t,e,n){return this instanceof ze?(this.r=~~t,this.g=~~e,void(this.b=~~n)):arguments.length<2?t instanceof ze?new ze(t.r,t.g,t.b):_a(""+t,ze,Mn):new ze(t,e,n)}function ma(t){return new ze(t>>16,t>>8&255,t&255)}function vr(t){return ma(t)+""}var xr=ze.prototype=new Kt;xr.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,n=this.g,r=this.b,i=30;return!e&&!n&&!r?new ze(i,i,i):(e&&e>4,r=r>>4|r,i=u&240,i=i>>4|i,a=u&15,a=a<<4|a):t.length===7&&(r=(u&16711680)>>16,i=(u&65280)>>8,a=u&255)),e(r,i,a))}function ya(t,e,n){var r=Math.min(t/=255,e/=255,n/=255),i=Math.max(t,e,n),a=i-r,l,s,u=(i+r)/2;return a?(s=u<.5?a/(i+r):a/(2-i-r),t==i?l=(e-n)/a+(e0&&u<1?0:l),new he(l,s,u)}function va(t,e,n){t=_i(t),e=_i(e),n=_i(n);var r=pi((.4124564*t+.3575761*e+.1804375*n)/Ve),i=pi((.2126729*t+.7151522*e+.072175*n)/an),a=pi((.0193339*t+.119192*e+.9503041*n)/Ue);return xe(116*i-16,500*(r-i),200*(i-a))}function _i(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function yi(t){var e=parseFloat(t);return t.charAt(t.length-1)==="%"?Math.round(e*2.55):e}var br=o.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});br.forEach(function(t,e){br.set(t,ma(e))});function de(t){return typeof t=="function"?t:function(){return t}}o.functor=de,o.xhr=vi(ie);function vi(t){return function(e,n,r){return arguments.length===2&&typeof n=="function"&&(r=n,n=null),wr(e,n,t,r)}}function wr(t,e,n,r){var i={},a=o.dispatch("beforesend","progress","load","error"),l={},s=new XMLHttpRequest,u=null;this.XDomainRequest&&!("withCredentials"in s)&&/^(http(s)?:)?\/\//.test(t)&&(s=new XDomainRequest),"onload"in s?s.onload=s.onerror=c:s.onreadystatechange=function(){s.readyState>3&&c()};function c(){var f=s.status,g;if(!f&&Ms(s)||f>=200&&f<300||f===304){try{g=n.call(i,s)}catch(d){a.error.call(i,d);return}a.load.call(i,g)}else a.error.call(i,s)}return s.onprogress=function(f){var g=o.event;o.event=f;try{a.progress.call(i,s)}finally{o.event=g}},i.header=function(f,g){return f=(f+"").toLowerCase(),arguments.length<2?l[f]:(g==null?delete l[f]:l[f]=g+"",i)},i.mimeType=function(f){return arguments.length?(e=f==null?null:f+"",i):e},i.responseType=function(f){return arguments.length?(u=f,i):u},i.response=function(f){return n=f,i},["get","post"].forEach(function(f){i[f]=function(){return i.send.apply(i,[f].concat(w(arguments)))}}),i.send=function(f,g,d){if(arguments.length===2&&typeof g=="function"&&(d=g,g=null),s.open(f,t,!0),e!=null&&!("accept"in l)&&(l.accept=e+",*/*"),s.setRequestHeader)for(var x in l)s.setRequestHeader(x,l[x]);return e!=null&&s.overrideMimeType&&s.overrideMimeType(e),u!=null&&(s.responseType=u),d!=null&&i.on("error",d).on("load",function(A){d(null,A)}),a.beforesend.call(i,s),s.send(g??null),i},i.abort=function(){return s.abort(),i},o.rebind(i,a,"on"),r==null?i:i.get(Cs(r))}function Cs(t){return t.length===1?function(e,n){t(e==null?n:null)}:t}function Ms(t){var e=t.responseType;return e&&e!=="text"?t.response:t.responseText}o.dsv=function(t,e){var n=new RegExp('["'+t+` ]`),r=t.charCodeAt(0);function i(c,f,g){arguments.length<3&&(g=f,f=null);var d=wr(c,e,f==null?a:l(f),g);return d.row=function(x){return arguments.length?d.response((f=x)==null?a:l(x)):f},d}function a(c){return i.parse(c.responseText)}function l(c){return function(f){return i.parse(f.responseText,c)}}i.parse=function(c,f){var g;return i.parseRows(c,function(d,x){if(g)return g(d,x-1);var A=new Function("d","return {"+d.map(function(m,_){return JSON.stringify(m)+": d["+_+"]"}).join(",")+"}");g=f?function(m,_){return f(A(m),_)}:A})},i.parseRows=function(c,f){var g={},d={},x=[],A=c.length,m=0,_=0,y,F;function b(){if(m>=A)return d;if(F)return F=!1,g;var W=m;if(c.charCodeAt(W)===34){for(var Y=W;Y++24?(isFinite(e)&&(clearTimeout(Sr),Sr=setTimeout(xi,e)),Mr=0):(Mr=1,xa(xi))}o.timer.flush=function(){ba(),wa()};function ba(){for(var t=Date.now(),e=kr;e;)t>=e.t&&e.c(t-e.t)&&(e.c=null),e=e.n;return t}function wa(){for(var t,e=kr,n=1/0;e;)e.c?(e.t8?function(r){return r/n}:function(r){return r*n},symbol:t}}function As(t){var e=t.decimal,n=t.thousands,r=t.grouping,i=t.currency,a=r&&n?function(l,s){for(var u=l.length,c=[],f=0,g=r[0],d=0;u>0&&g>0&&(d+g+1>s&&(g=Math.max(1,s-d)),c.push(l.substring(u-=g,u+g)),!((d+=g+1)>s));)g=r[f=(f+1)%r.length];return c.reverse().join(n)}:ie;return function(l){var s=ka.exec(l),u=s[1]||" ",c=s[2]||">",f=s[3]||"-",g=s[4]||"",d=s[5],x=+s[6],A=s[7],m=s[8],_=s[9],y=1,F="",b="",P=!1,W=!0;switch(m&&(m=+m.substring(1)),(d||u==="0"&&c==="=")&&(d=u="0",c="="),_){case"n":A=!0,_="g";break;case"%":y=100,b="%",_="f";break;case"p":y=100,b="%",_="r";break;case"b":case"o":case"x":case"X":g==="#"&&(F="0"+_.toLowerCase());case"c":W=!1;case"d":P=!0,m=0;break;case"s":y=-1,_="r";break}g==="$"&&(F=i[0],b=i[1]),_=="r"&&!m&&(_="g"),m!=null&&(_=="g"?m=Math.max(1,Math.min(21,m)):(_=="e"||_=="f")&&(m=Math.max(0,Math.min(20,m)))),_=Fs.get(_)||Ls;var Y=d&&A;return function(H){var V=b;if(P&&H%1)return"";var st=H<0||H===0&&1/H<0?(H=-H,"-"):f==="-"?"":f;if(y<0){var gt=o.formatPrefix(H,m);H=gt.scale(H),V=gt.symbol+b}else H*=y;H=_(H,m);var At=H.lastIndexOf("."),xt,Ct;if(At<0){var tt=W?H.lastIndexOf("e"):-1;tt<0?(xt=H,Ct=""):(xt=H.substring(0,tt),Ct=H.substring(tt))}else xt=H.substring(0,At),Ct=e+H.substring(At+1);!d&&A&&(xt=a(xt,1/0));var ft=F.length+xt.length+Ct.length+(Y?0:st.length),yt=ft"?yt+st+H:c==="^"?yt.substring(0,ft>>=1)+st+H+yt.substring(ft):st+(Y?H:yt+H))+V}}}var ka=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Fs=o.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(t,e){return(t=o.round(t,bi(t,e))).toFixed(Math.max(0,Math.min(20,bi(t*(1+1e-15),e))))}});function Ls(t){return t+""}var It=o.time={},Le=Date;function hn(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}hn.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){gn.setUTCDate.apply(this._,arguments)},setDay:function(){gn.setUTCDay.apply(this._,arguments)},setFullYear:function(){gn.setUTCFullYear.apply(this._,arguments)},setHours:function(){gn.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){gn.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){gn.setUTCMinutes.apply(this._,arguments)},setMonth:function(){gn.setUTCMonth.apply(this._,arguments)},setSeconds:function(){gn.setUTCSeconds.apply(this._,arguments)},setTime:function(){gn.setTime.apply(this._,arguments)}};var gn=Date.prototype;function Sn(t,e,n){function r(c){var f=t(c),g=a(f,1);return c-f1)for(;d=pe)return-1;if(mt=ft.charCodeAt(Zt++),mt===37){if(Ht=ft.charAt(Zt++),Dt=W[Ht in Ca?ft.charAt(Zt++):Ht],!Dt||(nt=Dt(tt,yt,nt))<0)return-1}else if(mt!=yt.charCodeAt(nt++))return-1}return nt}c.utc=function(tt){var ft=c(tt);function yt(nt){try{Le=hn;var mt=new Le;return mt._=nt,ft(mt)}finally{Le=Date}}return yt.parse=function(nt){try{Le=hn;var mt=ft.parse(nt);return mt&&mt._}finally{Le=Date}},yt.toString=ft.toString,yt},c.multi=c.utc.multi=Ys;var g=o.map(),d=Fr(a),x=Lr(a),A=Fr(l),m=Lr(l),_=Fr(s),y=Lr(s),F=Fr(u),b=Lr(u);i.forEach(function(tt,ft){g.set(tt.toLowerCase(),ft)});var P={a:function(tt){return l[tt.getDay()]},A:function(tt){return a[tt.getDay()]},b:function(tt){return u[tt.getMonth()]},B:function(tt){return s[tt.getMonth()]},c:c(e),d:function(tt,ft){return De(tt.getDate(),ft,2)},e:function(tt,ft){return De(tt.getDate(),ft,2)},H:function(tt,ft){return De(tt.getHours(),ft,2)},I:function(tt,ft){return De(tt.getHours()%12||12,ft,2)},j:function(tt,ft){return De(1+It.dayOfYear(tt),ft,3)},L:function(tt,ft){return De(tt.getMilliseconds(),ft,3)},m:function(tt,ft){return De(tt.getMonth()+1,ft,2)},M:function(tt,ft){return De(tt.getMinutes(),ft,2)},p:function(tt){return i[+(tt.getHours()>=12)]},S:function(tt,ft){return De(tt.getSeconds(),ft,2)},U:function(tt,ft){return De(It.sundayOfYear(tt),ft,2)},w:function(tt){return tt.getDay()},W:function(tt,ft){return De(It.mondayOfYear(tt),ft,2)},x:c(n),X:c(r),y:function(tt,ft){return De(tt.getFullYear()%100,ft,2)},Y:function(tt,ft){return De(tt.getFullYear()%1e4,ft,4)},Z:Hs,"%":function(){return"%"}},W={a:Y,A:H,b:V,B:st,c:gt,d:Sa,e:Sa,H:Pa,I:Pa,j:js,L:qs,m:Os,M:Gs,p:Ct,S:Vs,U:Es,w:Ns,W:Bs,x:At,X:xt,y:Is,Y:Ds,Z:zs,"%":Us};function Y(tt,ft,yt){A.lastIndex=0;var nt=A.exec(ft.slice(yt));return nt?(tt.w=m.get(nt[0].toLowerCase()),yt+nt[0].length):-1}function H(tt,ft,yt){d.lastIndex=0;var nt=d.exec(ft.slice(yt));return nt?(tt.w=x.get(nt[0].toLowerCase()),yt+nt[0].length):-1}function V(tt,ft,yt){F.lastIndex=0;var nt=F.exec(ft.slice(yt));return nt?(tt.m=b.get(nt[0].toLowerCase()),yt+nt[0].length):-1}function st(tt,ft,yt){_.lastIndex=0;var nt=_.exec(ft.slice(yt));return nt?(tt.m=y.get(nt[0].toLowerCase()),yt+nt[0].length):-1}function gt(tt,ft,yt){return f(tt,P.c.toString(),ft,yt)}function At(tt,ft,yt){return f(tt,P.x.toString(),ft,yt)}function xt(tt,ft,yt){return f(tt,P.X.toString(),ft,yt)}function Ct(tt,ft,yt){var nt=g.get(ft.slice(yt,yt+=2).toLowerCase());return nt==null?-1:(tt.p=nt,yt)}return c}var Ca={"-":"",_:" ",0:"0"},we=/^\s*\d+/,Ma=/^%/;function De(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",a=i.length;return r+(a68?1900:2e3)}function Os(t,e,n){we.lastIndex=0;var r=we.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function Sa(t,e,n){we.lastIndex=0;var r=we.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function js(t,e,n){we.lastIndex=0;var r=we.exec(e.slice(n,n+3));return r?(t.j=+r[0],n+r[0].length):-1}function Pa(t,e,n){we.lastIndex=0;var r=we.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Gs(t,e,n){we.lastIndex=0;var r=we.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Vs(t,e,n){we.lastIndex=0;var r=we.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function qs(t,e,n){we.lastIndex=0;var r=we.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Hs(t){var e=t.getTimezoneOffset(),n=e>0?"-":"+",r=rt(e)/60|0,i=rt(e)%60;return n+De(r,"0",2)+De(i,"0",2)}function Us(t,e,n){Ma.lastIndex=0;var r=Ma.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Ys(t){for(var e=t.length,n=-1;++n=0?1:-1,f=c*u,g=Math.cos(s),d=Math.sin(s),x=i*d,A=r*g+x*Math.cos(f),m=x*c*Math.sin(f);Pn.add(Math.atan2(m,A)),n=l,r=g,i=d}qe.lineEnd=function(){a(t,e)}}function An(t){var e=t[0],n=t[1],r=Math.cos(n);return[r*Math.cos(e),r*Math.sin(e),Math.sin(n)]}function Br(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Vn(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function Ci(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function Dr(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Ir(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function zr(t){return[Math.atan2(t[1],t[0]),Yt(t[2])]}function Rr(t,e){return rt(t[0]-e[0])Q?r=90:u<-Q&&(e=-90),f[0]=t,f[1]=n}};function d(Y,H){c.push(f=[t=Y,n=Y]),Hr&&(r=H)}function x(Y,H){var V=An([Y*_t,H*_t]);if(s){var st=Vn(s,V),gt=[st[1],-st[0],0],At=Vn(gt,st);Ir(At),At=zr(At);var xt=Y-i,Ct=xt>0?1:-1,tt=At[0]*zt*Ct,ft=rt(xt)>180;if(ft^(Ct*ir&&(r=yt)}else if(tt=(tt+360)%360-180,ft^(Ct*ir&&(r=H);ft?Yb(t,n)&&(n=Y):b(Y,n)>b(t,n)&&(t=Y):n>=t?(Yn&&(n=Y)):Y>i?b(t,Y)>b(t,n)&&(n=Y):b(Y,n)>b(t,n)&&(t=Y)}else d(Y,H);s=V,i=Y}function A(){g.point=x}function m(){f[0]=t,f[1]=n,g.point=d,s=null}function _(Y,H){if(s){var V=Y-i;u+=rt(V)>180?V+(V>0?360:-360):V}else a=Y,l=H;qe.point(Y,H),x(Y,H)}function y(){qe.lineStart()}function F(){_(a,l),qe.lineEnd(),rt(u)>Q&&(t=-(n=180)),f[0]=t,f[1]=n,s=null}function b(Y,H){return(H-=Y)<0?H+360:H}function P(Y,H){return Y[0]-H[0]}function W(Y,H){return H[0]<=H[1]?H[0]<=Y&&Y<=H[1]:Yb(st[0],st[1])&&(st[1]=gt[1]),b(gt[0],st[1])>b(st[0],st[1])&&(st[0]=gt[0])):At.push(st=gt);for(var xt=-1/0,Ct,H=At.length-1,V=0,st=At[H],gt;V<=H;st=gt,++V)gt=At[V],(Ct=b(st[1],gt[0]))>xt&&(xt=Ct,t=gt[0],n=st[1])}return c=f=null,t===1/0||e===1/0?[[NaN,NaN],[NaN,NaN]]:[[t,e],[n,r]]}}(),o.geo.centroid=function(t){er=Or=Fn=Ln=dn=_n=yn=on=qn=Hn=vn=0,o.geo.stream(t,Ke);var e=qn,n=Hn,r=vn,i=e*e+n*n+r*r;return i=0;--s)i.point((d=g[s])[0],d[1])}else r(x.x,x.p.x,-1,i);x=x.p}x=x.o,g=x.z,A=!A}while(!x.v);i.lineEnd()}}}function za(t){if(e=t.length){for(var e,n=0,r=t[0],i;++n0){for(_||(a.polygonStart(),_=!0),a.lineStart();++gt1&&Y&2&&H.push(H.pop().concat(H.shift())),x.push(H.filter(Zs))}}return u}}function Zs(t){return t.length>1}function Oa(){var t=[],e;return{lineStart:function(){t.push(e=[])},point:function(n,r){e.push([n,r])},lineEnd:ue,buffer:function(){var n=t;return t=[],e=null,n},rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))}}}function $s(t,e){return((t=t.x)[0]<0?t[1]-bt-Q:bt-t[1])-((e=e.x)[0]<0?e[1]-bt-Q:bt-e[1])}var ja=Ra(rr,Ks,Qs,[-it,-it/2]);function Ks(t){var e=NaN,n=NaN,r=NaN,i;return{lineStart:function(){t.lineStart(),i=1},point:function(a,l){var s=a>0?it:-it,u=rt(a-e);rt(u-it)0?bt:-bt),t.point(r,n),t.lineEnd(),t.lineStart(),t.point(s,n),t.point(a,n),i=0):r!==s&&u>=it&&(rt(e-r)Q?Math.atan((Math.sin(e)*(a=Math.cos(r))*Math.sin(n)-Math.sin(r)*(i=Math.cos(e))*Math.sin(t))/(i*a*l)):(e+r)/2}function Qs(t,e,n,r){var i;if(t==null)i=n*bt,r.point(-it,i),r.point(0,i),r.point(it,i),r.point(it,0),r.point(it,-i),r.point(0,-i),r.point(-it,-i),r.point(-it,0),r.point(-it,i);else if(rt(t[0]-e[0])>Q){var a=t[0]=0?1:-1,H=Y*W,V=H>it,st=A*b;if(Pn.add(Math.atan2(st*Y*Math.sin(H),m*P+st*Math.cos(H))),a+=V?W+Y*K:W,V^d>=n^y>=n){var gt=Vn(An(g),An(t));Ir(gt);var At=Vn(i,gt);Ir(At);var xt=(V^W>=0?-1:1)*Yt(At[2]);(r>xt||r===xt&&(gt[0]||gt[1]))&&(l+=V^W>=0?1:-1)}if(!_++)break;d=y,A=b,m=P,g=t}}return(a<-Q||a0,r=rt(e)>Q,i=Ti(t,6*_t);return Ra(a,l,i,n?[0,-t]:[-it,t-it]);function a(c,f){return Math.cos(c)*Math.cos(f)>e}function l(c){var f,g,d,x,A;return{lineStart:function(){x=d=!1,A=1},point:function(m,_){var y=[m,_],F,b=a(m,_),P=n?b?0:u(m,_):b?u(m+(m<0?it:-it),_):0;if(!f&&(x=d=b)&&c.lineStart(),b!==d&&(F=s(f,y),(Rr(f,F)||Rr(y,F))&&(y[0]+=Q,y[1]+=Q,b=a(y[0],y[1]))),b!==d)A=0,b?(c.lineStart(),F=s(y,f),c.point(F[0],F[1])):(F=s(f,y),c.point(F[0],F[1]),c.lineEnd()),f=F;else if(r&&f&&n^b){var W;!(P&g)&&(W=s(y,f,!0))&&(A=0,n?(c.lineStart(),c.point(W[0][0],W[0][1]),c.point(W[1][0],W[1][1]),c.lineEnd()):(c.point(W[1][0],W[1][1]),c.lineEnd(),c.lineStart(),c.point(W[0][0],W[0][1])))}b&&(!f||!Rr(f,y))&&c.point(y[0],y[1]),f=y,d=b,g=P},lineEnd:function(){d&&c.lineEnd(),f=null},clean:function(){return A|(x&&d)<<1}}}function s(c,f,g){var d=An(c),x=An(f),A=[1,0,0],m=Vn(d,x),_=Br(m,m),y=m[0],F=_-y*y;if(!F)return!g&&c;var b=e*_/F,P=-e*y/F,W=Vn(A,m),Y=Dr(A,b),H=Dr(m,P);Ci(Y,H);var V=W,st=Br(Y,V),gt=Br(V,V),At=st*st-gt*(Br(Y,Y)-1);if(!(At<0)){var xt=Math.sqrt(At),Ct=Dr(V,(-st-xt)/gt);if(Ci(Ct,Y),Ct=zr(Ct),!g)return Ct;var tt=c[0],ft=f[0],yt=c[1],nt=f[1],mt;ft0^Ct[1]<(rt(Ct[0]-tt)it^(tt<=Ct[0]&&Ct[0]<=ft)){var se=Dr(V,(-st+xt)/gt);return Ci(se,Y),[Ct,zr(se)]}}}function u(c,f){var g=n?t:it-t,d=0;return c<-g?d|=1:c>g&&(d|=2),f<-g?d|=4:f>g&&(d|=8),d}}function Ga(t,e,n,r){return function(i){var a=i.a,l=i.b,s=a.x,u=a.y,c=l.x,f=l.y,g=0,d=1,x=c-s,A=f-u,m;if(m=t-s,!(!x&&m>0)){if(m/=x,x<0){if(m0){if(m>d)return;m>g&&(g=m)}if(m=n-s,!(!x&&m<0)){if(m/=x,x<0){if(m>d)return;m>g&&(g=m)}else if(x>0){if(m0)){if(m/=A,A<0){if(m0){if(m>d)return;m>g&&(g=m)}if(m=r-u,!(!A&&m<0)){if(m/=A,A<0){if(m>d)return;m>g&&(g=m)}else if(A>0){if(m0&&(i.a={x:s+g*x,y:u+g*A}),d<1&&(i.b={x:s+d*x,y:u+d*A}),i}}}}}}var Gr=1e9;o.geo.clipExtent=function(){var t,e,n,r,i,a,l={stream:function(s){return i&&(i.valid=!1),i=a(s),i.valid=!0,i},extent:function(s){return arguments.length?(a=Va(t=+s[0][0],e=+s[0][1],n=+s[1][0],r=+s[1][1]),i&&(i.valid=!1,i=null),l):[[t,e],[n,r]]}};return l.extent([[0,0],[960,500]])};function Va(t,e,n,r){return function(s){var u=s,c=Oa(),f=Ga(t,e,n,r),g,d,x,A={point:F,lineStart:At,lineEnd:xt,polygonStart:function(){s=c,g=[],d=[],gt=!0},polygonEnd:function(){s=u,g=o.merge(g);var tt=m([t,r]),ft=gt&&tt,yt=g.length;(ft||yt)&&(s.polygonStart(),ft&&(s.lineStart(),_(null,null,1,s),s.lineEnd()),yt&&Ia(g,a,tt,_,s),s.polygonEnd()),g=d=x=null}};function m(tt){for(var ft=0,yt=d.length,nt=tt[1],mt=0;mtnt&&X(se,pe,tt)>0&&++ft:pe[1]<=nt&&X(se,pe,tt)<0&&--ft,se=pe;return ft!==0}function _(tt,ft,yt,nt){var mt=0,Dt=0;if(tt==null||(mt=i(tt,yt))!==(Dt=i(ft,yt))||l(tt,ft)<0^yt>0)do nt.point(mt===0||mt===3?t:n,mt>1?r:e);while((mt=(mt+yt+4)%4)!==Dt);else nt.point(ft[0],ft[1])}function y(tt,ft){return t<=tt&&tt<=n&&e<=ft&&ft<=r}function F(tt,ft){y(tt,ft)&&s.point(tt,ft)}var b,P,W,Y,H,V,st,gt;function At(){A.point=Ct,d&&d.push(x=[]),st=!0,V=!1,Y=H=NaN}function xt(){g&&(Ct(b,P),W&&V&&c.rejoin(),g.push(c.buffer())),A.point=F,V&&s.lineEnd()}function Ct(tt,ft){tt=Math.max(-Gr,Math.min(Gr,tt)),ft=Math.max(-Gr,Math.min(Gr,ft));var yt=y(tt,ft);if(d&&x.push([tt,ft]),st)b=tt,P=ft,W=yt,st=!1,yt&&(s.lineStart(),s.point(tt,ft));else if(yt&&V)s.point(tt,ft);else{var nt={a:{x:Y,y:H},b:{x:tt,y:ft}};f(nt)?(V||(s.lineStart(),s.point(nt.a.x,nt.a.y)),s.point(nt.b.x,nt.b.y),yt||s.lineEnd(),gt=!1):yt&&(s.lineStart(),s.point(tt,ft),gt=!1)}Y=tt,H=ft,V=yt}return A};function i(s,u){return rt(s[0]-t)0?0:3:rt(s[0]-n)0?2:1:rt(s[1]-e)0?1:0:u>0?3:2}function a(s,u){return l(s.x,u.x)}function l(s,u){var c=i(s,1),f=i(u,1);return c!==f?c-f:c===0?u[1]-s[1]:c===1?s[0]-u[0]:c===2?s[1]-u[1]:u[0]-s[0]}}function Si(t){var e=0,n=it/3,r=Fi(t),i=r(e,n);return i.parallels=function(a){return arguments.length?r(e=a[0]*it/180,n=a[1]*it/180):[e/it*180,n/it*180]},i}function qa(t,e){var n=Math.sin(t),r=(n+Math.sin(e))/2,i=1+n*(2*r-n),a=Math.sqrt(i)/r;function l(s,u){var c=Math.sqrt(i-2*r*Math.sin(u))/r;return[c*Math.sin(s*=r),a-c*Math.cos(s)]}return l.invert=function(s,u){var c=a-u;return[Math.atan2(s,c)/r,Yt((i-(s*s+c*c)*r*r)/(2*r))]},l}(o.geo.conicEqualArea=function(){return Si(qa)}).raw=qa,o.geo.albers=function(){return o.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},o.geo.albersUsa=function(){var t=o.geo.albers(),e=o.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),n=o.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),r,i={point:function(c,f){r=[c,f]}},a,l,s;function u(c){var f=c[0],g=c[1];return r=null,a(f,g),r||(l(f,g),r)||s(f,g),r}return u.invert=function(c){var f=t.scale(),g=t.translate(),d=(c[0]-g[0])/f,x=(c[1]-g[1])/f;return(x>=.12&&x<.234&&d>=-.425&&d<-.214?e:x>=.166&&x<.234&&d>=-.214&&d<-.115?n:t).invert(c)},u.stream=function(c){var f=t.stream(c),g=e.stream(c),d=n.stream(c);return{point:function(x,A){f.point(x,A),g.point(x,A),d.point(x,A)},sphere:function(){f.sphere(),g.sphere(),d.sphere()},lineStart:function(){f.lineStart(),g.lineStart(),d.lineStart()},lineEnd:function(){f.lineEnd(),g.lineEnd(),d.lineEnd()},polygonStart:function(){f.polygonStart(),g.polygonStart(),d.polygonStart()},polygonEnd:function(){f.polygonEnd(),g.polygonEnd(),d.polygonEnd()}}},u.precision=function(c){return arguments.length?(t.precision(c),e.precision(c),n.precision(c),u):t.precision()},u.scale=function(c){return arguments.length?(t.scale(c),e.scale(c*.35),n.scale(c),u.translate(t.translate())):t.scale()},u.translate=function(c){if(!arguments.length)return t.translate();var f=t.scale(),g=+c[0],d=+c[1];return a=t.translate(c).clipExtent([[g-.455*f,d-.238*f],[g+.455*f,d+.238*f]]).stream(i).point,l=e.translate([g-.307*f,d+.201*f]).clipExtent([[g-.425*f+Q,d+.12*f+Q],[g-.214*f-Q,d+.234*f-Q]]).stream(i).point,s=n.translate([g-.205*f,d+.212*f]).clipExtent([[g-.214*f+Q,d+.166*f+Q],[g-.115*f-Q,d+.234*f-Q]]).stream(i).point,u},u.scale(1070)};var Pi,Ai,xn={point:ue,lineStart:ue,lineEnd:ue,polygonStart:function(){Ai=0,xn.lineStart=nl},polygonEnd:function(){xn.lineStart=xn.lineEnd=xn.point=ue,Pi+=rt(Ai/2)}};function nl(){var t,e,n,r;xn.point=function(a,l){xn.point=i,t=n=a,e=r=l};function i(a,l){Ai+=r*a-n*l,n=a,r=l}xn.lineEnd=function(){i(t,e)}}var Vr,qr,Hr,Ur,rl={point:il,lineStart:ue,lineEnd:ue,polygonStart:ue,polygonEnd:ue};function il(t,e){tHr&&(Hr=t),eUr&&(Ur=e)}function al(){var t=Ha(4.5),e=[],n={point:r,lineStart:function(){n.point=i},lineEnd:l,polygonStart:function(){n.lineEnd=s},polygonEnd:function(){n.lineEnd=l,n.point=r},pointRadius:function(u){return t=Ha(u),n},result:function(){if(e.length){var u=e.join("");return e=[],u}}};function r(u,c){e.push("M",u,",",c,t)}function i(u,c){e.push("M",u,",",c),n.point=a}function a(u,c){e.push("L",u,",",c)}function l(){n.point=r}function s(){e.push("Z")}return n}function Ha(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}var Je={point:Tn,lineStart:Ua,lineEnd:Ya,polygonStart:function(){Je.lineStart=ol},polygonEnd:function(){Je.point=Tn,Je.lineStart=Ua,Je.lineEnd=Ya}};function Tn(t,e){Fn+=t,Ln+=e,++dn}function Ua(){var t,e;Je.point=function(r,i){Je.point=n,Tn(t=r,e=i)};function n(r,i){var a=r-t,l=i-e,s=Math.sqrt(a*a+l*l);_n+=s*(t+r)/2,yn+=s*(e+i)/2,on+=s,Tn(t=r,e=i)}}function Ya(){Je.point=Tn}function ol(){var t,e,n,r;Je.point=function(a,l){Je.point=i,Tn(t=n=a,e=r=l)};function i(a,l){var s=a-n,u=l-r,c=Math.sqrt(s*s+u*u);_n+=c*(n+a)/2,yn+=c*(r+l)/2,on+=c,c=r*a-n*l,qn+=c*(n+a),Hn+=c*(r+l),vn+=c*3,Tn(n=a,r=l)}Je.lineEnd=function(){i(t,e)}}function sl(t){var e=4.5,n={point:r,lineStart:function(){n.point=i},lineEnd:l,polygonStart:function(){n.lineEnd=s},polygonEnd:function(){n.lineEnd=l,n.point=r},pointRadius:function(u){return e=u,n},result:ue};function r(u,c){t.moveTo(u+e,c),t.arc(u,c,e,0,K)}function i(u,c){t.moveTo(u,c),n.point=a}function a(u,c){t.lineTo(u,c)}function l(){n.point=r}function s(){t.closePath()}return n}function Xa(t){var e=.5,n=Math.cos(30*_t),r=16;function i(u){return(r?l:a)(u)}function a(u){return Za(u,function(c,f){c=t(c,f),u.point(c[0],c[1])})}function l(u){var c,f,g,d,x,A,m,_,y,F,b,P,W={point:Y,lineStart:H,lineEnd:st,polygonStart:function(){u.polygonStart(),W.lineStart=gt},polygonEnd:function(){u.polygonEnd(),W.lineStart=H}};function Y(Ct,tt){Ct=t(Ct,tt),u.point(Ct[0],Ct[1])}function H(){_=NaN,W.point=V,u.lineStart()}function V(Ct,tt){var ft=An([Ct,tt]),yt=t(Ct,tt);s(_,y,m,F,b,P,_=yt[0],y=yt[1],m=Ct,F=ft[0],b=ft[1],P=ft[2],r,u),u.point(_,y)}function st(){W.point=Y,u.lineEnd()}function gt(){H(),W.point=At,W.lineEnd=xt}function At(Ct,tt){V(c=Ct,tt),f=_,g=y,d=F,x=b,A=P,W.point=V}function xt(){s(_,y,m,F,b,P,f,g,c,d,x,A,r,u),W.lineEnd=st,st()}return W}function s(u,c,f,g,d,x,A,m,_,y,F,b,P,W){var Y=A-u,H=m-c,V=Y*Y+H*H;if(V>4*e&&P--){var st=g+y,gt=d+F,At=x+b,xt=Math.sqrt(st*st+gt*gt+At*At),Ct=Math.asin(At/=xt),tt=rt(rt(At)-1)e||rt((Y*mt+H*Dt)/V-.5)>.3||g*y+d*F+x*b0&&16,i):Math.sqrt(e)},i}o.geo.path=function(){var t=4.5,e,n,r,i,a;function l(u){return u&&(typeof t=="function"&&i.pointRadius(+t.apply(this,arguments)),(!a||!a.valid)&&(a=r(i)),o.geo.stream(u,a)),i.result()}l.area=function(u){return Pi=0,o.geo.stream(u,r(xn)),Pi},l.centroid=function(u){return Fn=Ln=dn=_n=yn=on=qn=Hn=vn=0,o.geo.stream(u,r(Je)),vn?[qn/vn,Hn/vn]:on?[_n/on,yn/on]:dn?[Fn/dn,Ln/dn]:[NaN,NaN]},l.bounds=function(u){return Hr=Ur=-(Vr=qr=1/0),o.geo.stream(u,r(rl)),[[Vr,qr],[Hr,Ur]]},l.projection=function(u){return arguments.length?(r=(e=u)?u.stream||ll(u):ie,s()):e},l.context=function(u){return arguments.length?(i=(n=u)==null?new al:new sl(u),typeof t!="function"&&i.pointRadius(t),s()):n},l.pointRadius=function(u){return arguments.length?(t=typeof u=="function"?u:(i.pointRadius(+u),+u),l):t};function s(){return a=null,l}return l.projection(o.geo.albersUsa()).context(null)};function ll(t){var e=Xa(function(n,r){return t([n*zt,r*zt])});return function(n){return $a(e(n))}}o.geo.transform=function(t){return{stream:function(e){var n=new Wa(e);for(var r in t)n[r]=t[r];return n}}};function Wa(t){this.stream=t}Wa.prototype={point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function Za(t,e){return{point:e,sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}o.geo.projection=bn,o.geo.projectionMutator=Fi;function bn(t){return Fi(function(){return t})()}function Fi(t){var e,n,r,i=Xa(function(V,st){return V=e(V,st),[V[0]*a+x,A-V[1]*a]}),a=150,l=480,s=250,u=0,c=0,f=0,g=0,d=0,x,A,m=ja,_=ie,y=null,F=null,b;function P(V){return V=r(V[0]*_t,V[1]*_t),[V[0]*a+x,A-V[1]*a]}function W(V){return V=r.invert((V[0]-x)/a,(A-V[1])/a),V&&[V[0]*zt,V[1]*zt]}P.stream=function(V){return b&&(b.valid=!1),b=$a(m(n,i(_(V)))),b.valid=!0,b},P.clipAngle=function(V){return arguments.length?(m=V==null?(y=V,ja):el((y=+V)*_t),H()):y},P.clipExtent=function(V){return arguments.length?(F=V,_=V?Va(V[0][0],V[0][1],V[1][0],V[1][1]):ie,H()):F},P.scale=function(V){return arguments.length?(a=+V,Y()):a},P.translate=function(V){return arguments.length?(l=+V[0],s=+V[1],Y()):[l,s]},P.center=function(V){return arguments.length?(u=V[0]%360*_t,c=V[1]%360*_t,Y()):[u*zt,c*zt]},P.rotate=function(V){return arguments.length?(f=V[0]%360*_t,g=V[1]%360*_t,d=V.length>2?V[2]%360*_t:0,Y()):[f*zt,g*zt,d*zt]},o.rebind(P,i,"precision");function Y(){r=Da(n=Li(f,g,d),e);var V=e(u,c);return x=l-V[0]*a,A=s+V[1]*a,H()}function H(){return b&&(b.valid=!1,b=null),P}return function(){return e=t.apply(this,arguments),P.invert=e.invert&&W,Y()}}function $a(t){return Za(t,function(e,n){t.point(e*_t,n*_t)})}function ir(t,e){return[t,e]}(o.geo.equirectangular=function(){return bn(ir)}).raw=ir.invert=ir,o.geo.rotation=function(t){t=Li(t[0]%360*_t,t[1]*_t,t.length>2?t[2]*_t:0);function e(n){return n=t(n[0]*_t,n[1]*_t),n[0]*=zt,n[1]*=zt,n}return e.invert=function(n){return n=t.invert(n[0]*_t,n[1]*_t),n[0]*=zt,n[1]*=zt,n},e};function Ka(t,e){return[t>it?t-K:t<-it?t+K:t,e]}Ka.invert=ir;function Li(t,e,n){return t?e||n?Da(Qa(t),to(e,n)):Qa(t):e||n?to(e,n):Ka}function Ja(t){return function(e,n){return e+=t,[e>it?e-K:e<-it?e+K:e,n]}}function Qa(t){var e=Ja(t);return e.invert=Ja(-t),e}function to(t,e){var n=Math.cos(t),r=Math.sin(t),i=Math.cos(e),a=Math.sin(e);function l(s,u){var c=Math.cos(u),f=Math.cos(s)*c,g=Math.sin(s)*c,d=Math.sin(u),x=d*n+f*r;return[Math.atan2(g*i-x*a,f*n-d*r),Yt(x*i+g*a)]}return l.invert=function(s,u){var c=Math.cos(u),f=Math.cos(s)*c,g=Math.sin(s)*c,d=Math.sin(u),x=d*i-g*a;return[Math.atan2(g*i+d*a,f*n+x*r),Yt(x*n-f*r)]},l}o.geo.circle=function(){var t=[0,0],e,n=6,r;function i(){var a=typeof t=="function"?t.apply(this,arguments):t,l=Li(-a[0]*_t,-a[1]*_t,0).invert,s=[];return r(null,null,1,{point:function(u,c){s.push(u=l(u,c)),u[0]*=zt,u[1]*=zt}}),{type:"Polygon",coordinates:[s]}}return i.origin=function(a){return arguments.length?(t=a,i):t},i.angle=function(a){return arguments.length?(r=Ti((e=+a)*_t,n*_t),i):e},i.precision=function(a){return arguments.length?(r=Ti(e*_t,(n=+a)*_t),i):n},i.angle(90)};function Ti(t,e){var n=Math.cos(t),r=Math.sin(t);return function(i,a,l,s){var u=l*e;i!=null?(i=eo(n,i),a=eo(n,a),(l>0?ia)&&(i+=l*K)):(i=t+l*K,a=t-.5*u);for(var c,f=i;l>0?f>a:fQ}).map(d)).concat(o.range(Math.ceil(a/c)*c,i,c).filter(function(b){return rt(b%g)>Q}).map(x))}return y.lines=function(){return F().map(function(b){return{type:"LineString",coordinates:b}})},y.outline=function(){return{type:"Polygon",coordinates:[A(r).concat(m(l).slice(1),A(n).reverse().slice(1),m(s).reverse().slice(1))]}},y.extent=function(b){return arguments.length?y.majorExtent(b).minorExtent(b):y.minorExtent()},y.majorExtent=function(b){return arguments.length?(r=+b[0][0],n=+b[1][0],s=+b[0][1],l=+b[1][1],r>n&&(b=r,r=n,n=b),s>l&&(b=s,s=l,l=b),y.precision(_)):[[r,s],[n,l]]},y.minorExtent=function(b){return arguments.length?(e=+b[0][0],t=+b[1][0],a=+b[0][1],i=+b[1][1],e>t&&(b=e,e=t,t=b),a>i&&(b=a,a=i,i=b),y.precision(_)):[[e,a],[t,i]]},y.step=function(b){return arguments.length?y.majorStep(b).minorStep(b):y.minorStep()},y.majorStep=function(b){return arguments.length?(f=+b[0],g=+b[1],y):[f,g]},y.minorStep=function(b){return arguments.length?(u=+b[0],c=+b[1],y):[u,c]},y.precision=function(b){return arguments.length?(_=+b,d=no(a,i,90),x=ro(e,t,_),A=no(s,l,90),m=ro(r,n,_),y):_},y.majorExtent([[-180,-90+Q],[180,90-Q]]).minorExtent([[-180,-80-Q],[180,80+Q]])};function no(t,e,n){var r=o.range(t,e-Q,n).concat(e);return function(i){return r.map(function(a){return[i,a]})}}function ro(t,e,n){var r=o.range(t,e-Q,n).concat(e);return function(i){return r.map(function(a){return[a,i]})}}function Ni(t){return t.source}function Ei(t){return t.target}o.geo.greatArc=function(){var t=Ni,e,n=Ei,r;function i(){return{type:"LineString",coordinates:[e||t.apply(this,arguments),r||n.apply(this,arguments)]}}return i.distance=function(){return o.geo.distance(e||t.apply(this,arguments),r||n.apply(this,arguments))},i.source=function(a){return arguments.length?(t=a,e=typeof a=="function"?null:a,i):t},i.target=function(a){return arguments.length?(n=a,r=typeof a=="function"?null:a,i):n},i.precision=function(){return arguments.length?i:0},i},o.geo.interpolate=function(t,e){return ul(t[0]*_t,t[1]*_t,e[0]*_t,e[1]*_t)};function ul(t,e,n,r){var i=Math.cos(e),a=Math.sin(e),l=Math.cos(r),s=Math.sin(r),u=i*Math.cos(t),c=i*Math.sin(t),f=l*Math.cos(n),g=l*Math.sin(n),d=2*Math.asin(Math.sqrt(te(r-e)+i*l*te(n-t))),x=1/Math.sin(d),A=d?function(m){var _=Math.sin(m*=d)*x,y=Math.sin(d-m)*x,F=y*u+_*f,b=y*c+_*g,P=y*a+_*s;return[Math.atan2(b,F)*zt,Math.atan2(P,Math.sqrt(F*F+b*b))*zt]}:function(){return[t*zt,e*zt]};return A.distance=d,A}o.geo.length=function(t){return Bi=0,o.geo.stream(t,Un),Bi};var Bi,Un={sphere:ue,point:ue,lineStart:cl,lineEnd:ue,polygonStart:ue,polygonEnd:ue};function cl(){var t,e,n;Un.point=function(i,a){t=i*_t,e=Math.sin(a*=_t),n=Math.cos(a),Un.point=r},Un.lineEnd=function(){Un.point=Un.lineEnd=ue};function r(i,a){var l=Math.sin(a*=_t),s=Math.cos(a),u=rt((i*=_t)-t),c=Math.cos(u);Bi+=Math.atan2(Math.sqrt((u=s*Math.sin(u))*u+(u=n*l-e*s*c)*u),e*l+n*s*c),t=i,e=l,n=s}}function ar(t,e){function n(r,i){var a=Math.cos(r),l=Math.cos(i),s=t(a*l);return[s*l*Math.sin(r),s*Math.sin(i)]}return n.invert=function(r,i){var a=Math.sqrt(r*r+i*i),l=e(a),s=Math.sin(l),u=Math.cos(l);return[Math.atan2(r*s,a*u),Math.asin(a&&i*s/a)]},n}var io=ar(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(o.geo.azimuthalEqualArea=function(){return bn(io)}).raw=io;var ao=ar(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},ie);(o.geo.azimuthalEquidistant=function(){return bn(ao)}).raw=ao;function oo(t,e){var n=Math.cos(t),r=function(s){return Math.tan(it/4+s/2)},i=t===e?Math.sin(t):Math.log(n/Math.cos(e))/Math.log(r(e)/r(t)),a=n*Math.pow(r(t),i)/i;if(!i)return Yr;function l(s,u){a>0?u<-bt+Q&&(u=-bt+Q):u>bt-Q&&(u=bt-Q);var c=a/Math.pow(r(u),i);return[c*Math.sin(i*s),a-c*Math.cos(i*s)]}return l.invert=function(s,u){var c=a-u,f=$(i)*Math.sqrt(s*s+c*c);return[Math.atan2(s,c)/i,2*Math.atan(Math.pow(a/f,1/i))-bt]},l}(o.geo.conicConformal=function(){return Si(oo)}).raw=oo;function so(t,e){var n=Math.cos(t),r=t===e?Math.sin(t):(n-Math.cos(e))/(e-t),i=n/r+t;if(rt(r)2?r[2]+90:90]):(r=n(),[r[0],r[1],r[2]-90])},n([0,0,90])}).raw=Di,o.geom={};function Yn(t){return t[0]}function or(t){return t[1]}o.geom.hull=function(t){var e=Yn,n=or;if(arguments.length)return r(t);function r(i){if(i.length<3)return[];var a=de(e),l=de(n),s,u=i.length,c=[],f=[];for(s=0;s=0;--s)m.push(i[c[g[s]][2]]);for(s=+x;s1&&X(t[n[r-2]],t[n[r-1]],t[i])<=0;)--r;n[r++]=i}return n.slice(0,r)}function fl(t,e){return t[0]-e[0]||t[1]-e[1]}o.geom.polygon=function(t){return _e(t,Xr),t};var Xr=o.geom.polygon.prototype=[];Xr.area=function(){for(var t=-1,e=this.length,n,r=this[e-1],i=0;++tQ)s=s.L;else if(l=e-pl(s,n),l>Q){if(!s.R){r=s;break}s=s.R}else{a>-Q?(r=s.P,i=s):l>-Q?(r=s,i=s.N):r=i=s;break}var u=_o(t);if(Wn.insert(r,u),!(!r&&!i)){if(r===i){$n(r),i=_o(r.site),Wn.insert(u,i),u.edge=i.edge=lr(r.site,u.site),Zn(r),Zn(i);return}if(!i){u.edge=lr(r.site,u.site);return}$n(r),$n(i);var c=r.site,f=c.x,g=c.y,d=t.x-f,x=t.y-g,A=i.site,m=A.x-f,_=A.y-g,y=2*(d*_-x*m),F=d*d+x*x,b=m*m+_*_,P={x:(_*F-x*b)/y+f,y:(d*b-m*F)/y+g};Wr(i.edge,c,A,P),u.edge=lr(c,t,null,P),i.edge=lr(t,A,null,P),Zn(r),Zn(i)}}function yo(t,e){var n=t.site,r=n.x,i=n.y,a=i-e;if(!a)return r;var l=t.P;if(!l)return-1/0;n=l.site;var s=n.x,u=n.y,c=u-e;if(!c)return s;var f=s-r,g=1/a-1/c,d=f/c;return g?(-d+Math.sqrt(d*d-2*g*(f*f/(-2*c)-u+c/2+i-a/2)))/g+r:(r+s)/2}function pl(t,e){var n=t.N;if(n)return yo(n,e);var r=t.site;return r.y===e?r.x:1/0}function vo(t){this.site=t,this.edges=[]}vo.prototype.prepare=function(){for(var t=this.edges,e=t.length,n;e--;)n=t[e].edge,(!n.b||!n.a)&&t.splice(e,1);return t.sort(xo),t.length};function ml(t){for(var e=t[0][0],n=t[1][0],r=t[0][1],i=t[1][1],a,l,s,u,c=Nn,f=c.length,g,d,x,A,m,_;f--;)if(g=c[f],!(!g||!g.prepare()))for(x=g.edges,A=x.length,d=0;dQ||rt(u-l)>Q)&&(x.splice(d,0,new Zr(xl(g.site,_,rt(s-e)Q?{x:e,y:rt(a-e)Q?{x:rt(l-i)Q?{x:n,y:rt(a-n)Q?{x:rt(l-r)=-jt)){var d=u*u+c*c,x=f*f+_*_,A=(_*d-c*x)/g,m=(u*x-f*d)/g,_=m+s,y=mo.pop()||new _l;y.arc=t,y.site=i,y.x=A+l,y.y=_+Math.sqrt(A*A+m*m),y.cy=_,t.circle=y;for(var F=null,b=sr._;b;)if(y.y=a)return;if(f>d){if(!r)r={x:A,y:l};else if(r.y>=s)return;n={x:A,y:s}}else{if(!r)r={x:A,y:s};else if(r.y1)if(f>d){if(!r)r={x:(l-y)/_,y:l};else if(r.y>=s)return;n={x:(s-y)/_,y:s}}else{if(!r)r={x:(s-y)/_,y:s};else if(r.y=a)return;n={x:a,y:_*a+y}}else{if(!r)r={x:a,y:_*a+y};else if(r.x=f&&y.x<=d&&y.y>=g&&y.y<=x?[[f,x],[d,x],[d,g],[f,g]]:[];F.point=u[m]}),c}function s(u){return u.map(function(c,f){return{x:Math.round(r(c,f)/Q)*Q,y:Math.round(i(c,f)/Q)*Q,i:f}})}return l.links=function(u){return Gi(s(u)).edges.filter(function(c){return c.l&&c.r}).map(function(c){return{source:u[c.l.i],target:u[c.r.i]}})},l.triangles=function(u){var c=[];return Gi(s(u)).cells.forEach(function(f,g){for(var d=f.site,x=f.edges.sort(xo),A=-1,m=x.length,_,y=x[m-1].edge,F=y.l===d?y.r:y.l;++Ab&&(b=f.x),f.y>P&&(P=f.y),x.push(f.x),A.push(f.y);else for(m=0;m<_;++m){var W=+g(f=c[m],m),Y=+d(f,m);Wb&&(b=W),Y>P&&(P=Y),x.push(W),A.push(Y)}var H=b-y,V=P-F;H>V?P=F+H:b=y+V;function st(xt,Ct,tt,ft,yt,nt,mt,Dt){if(!(isNaN(tt)||isNaN(ft)))if(xt.leaf){var Ht=xt.x,Zt=xt.y;if(Ht!=null)if(rt(Ht-tt)+rt(Zt-ft)<.01)gt(xt,Ct,tt,ft,yt,nt,mt,Dt);else{var se=xt.point;xt.x=xt.y=xt.point=null,gt(xt,se,Ht,Zt,yt,nt,mt,Dt),gt(xt,Ct,tt,ft,yt,nt,mt,Dt)}else xt.x=tt,xt.y=ft,xt.point=Ct}else gt(xt,Ct,tt,ft,yt,nt,mt,Dt)}function gt(xt,Ct,tt,ft,yt,nt,mt,Dt){var Ht=(yt+mt)*.5,Zt=(nt+Dt)*.5,se=tt>=Ht,pe=ft>=Zt,Ee=pe<<1|se;xt.leaf=!1,xt=xt.nodes[Ee]||(xt.nodes[Ee]=ko()),se?yt=Ht:mt=Ht,pe?nt=Zt:Dt=Zt,st(xt,Ct,tt,ft,yt,nt,mt,Dt)}var At=ko();if(At.add=function(xt){st(At,xt,+g(xt,++m),+d(xt,m),y,F,b,P)},At.visit=function(xt){fr(xt,At,y,F,b,P)},At.find=function(xt){return Ml(At,xt[0],xt[1],y,F,b,P)},m=-1,e==null){for(;++m<_;)st(At,c[m],x[m],A[m],y,F,b,P);--m}else c.forEach(At.add);return x=A=c=f=null,At}return u.x=function(c){return arguments.length?(a=c,u):a},u.y=function(c){return arguments.length?(l=c,u):l},u.extent=function(c){return arguments.length?(c==null?e=n=r=i=null:(e=+c[0][0],n=+c[0][1],r=+c[1][0],i=+c[1][1]),u):e==null?null:[[e,n],[r,i]]},u.size=function(c){return arguments.length?(c==null?e=n=r=i=null:(e=n=0,r=+c[0],i=+c[1]),u):e==null?null:[r-e,i-n]},u};function kl(t){return t.x}function Cl(t){return t.y}function ko(){return{leaf:!0,nodes:[],point:null,x:null,y:null}}function fr(t,e,n,r,i,a){if(!t(e,n,r,i,a)){var l=(n+i)*.5,s=(r+a)*.5,u=e.nodes;u[0]&&fr(t,u[0],n,r,l,s),u[1]&&fr(t,u[1],l,r,i,s),u[2]&&fr(t,u[2],n,s,l,a),u[3]&&fr(t,u[3],l,s,i,a)}}function Ml(t,e,n,r,i,a,l){var s=1/0,u;return function c(f,g,d,x,A){if(!(g>a||d>l||x=W,V=n>=Y,st=V<<1|H,gt=st+4;stn&&(a=e.slice(n,a),s[l]?s[l]+=a:s[++l]=a),(r=r[0])===(i=i[0])?s[l]?s[l]+=i:s[++l]=i:(s[++l]=null,u.push({i:l,x:pn(r,i)})),n=Hi.lastIndex;return n=0&&!(r=o.interpolators[n](t,e)););return r}o.interpolators=[function(t,e){var n=typeof e;return(n==="string"?br.has(e.toLowerCase())||/^(#|rgb\(|hsl\()/i.test(e)?Vi:Mo:e instanceof Kt?Vi:Array.isArray(e)?Jr:n==="object"&&isNaN(e)?Co:pn)(t,e)}],o.interpolateArray=Jr;function Jr(t,e){var n=[],r=[],i=t.length,a=e.length,l=Math.min(t.length,e.length),s;for(s=0;s=0?t.slice(0,e):t,r=e>=0?t.slice(e+1):"in";return n=Sl.get(n)||So,r=Pl.get(r)||ie,Al(r(n.apply(null,h.call(arguments,1))))};function Al(t){return function(e){return e<=0?0:e>=1?1:t(e)}}function Po(t){return function(e){return 1-t(1-e)}}function Ao(t){return function(e){return .5*(e<.5?t(2*e):2-t(2-2*e))}}function Fl(t){return t*t}function Ll(t){return t*t*t}function Tl(t){if(t<=0)return 0;if(t>=1)return 1;var e=t*t,n=e*t;return 4*(t<.5?n:3*(t-e)+n-.75)}function Nl(t){return function(e){return Math.pow(e,t)}}function El(t){return 1-Math.cos(t*bt)}function Bl(t){return Math.pow(2,10*(t-1))}function Dl(t){return 1-Math.sqrt(1-t*t)}function Il(t,e){var n;return arguments.length<2&&(e=.45),arguments.length?n=e/K*Math.asin(1/t):(t=1,n=e/4),function(r){return 1+t*Math.pow(2,-10*r)*Math.sin((r-n)*K/e)}}function zl(t){return t||(t=1.70158),function(e){return e*e*((t+1)*e-t)}}function Rl(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}o.interpolateHcl=Ol;function Ol(t,e){t=o.hcl(t),e=o.hcl(e);var n=t.h,r=t.c,i=t.l,a=e.h-n,l=e.c-r,s=e.l-i;return isNaN(l)&&(l=0,r=isNaN(r)?e.c:r),isNaN(a)?(a=0,n=isNaN(n)?e.h:n):a>180?a-=360:a<-180&&(a+=360),function(u){return Ge(n+a*u,r+l*u,i+s*u)+""}}o.interpolateHsl=jl;function jl(t,e){t=o.hsl(t),e=o.hsl(e);var n=t.h,r=t.s,i=t.l,a=e.h-n,l=e.s-r,s=e.l-i;return isNaN(l)&&(l=0,r=isNaN(r)?e.s:r),isNaN(a)?(a=0,n=isNaN(n)?e.h:n):a>180?a-=360:a<-180&&(a+=360),function(u){return Mn(n+a*u,r+l*u,i+s*u)+""}}o.interpolateLab=Gl;function Gl(t,e){t=o.lab(t),e=o.lab(e);var n=t.l,r=t.a,i=t.b,a=e.l-n,l=e.a-r,s=e.b-i;return function(u){return jn(n+a*u,r+l*u,i+s*u)+""}}o.interpolateRound=Fo;function Fo(t,e){return e-=t,function(n){return Math.round(t+e*n)}}o.transform=function(t){var e=v.createElementNS(o.ns.prefix.svg,"g");return(o.transform=function(n){if(n!=null){e.setAttribute("transform",n);var r=e.transform.baseVal.consolidate()}return new Lo(r?r.matrix:ql)})(t)};function Lo(t){var e=[t.a,t.b],n=[t.c,t.d],r=No(e),i=To(e,n),a=No(Vl(n,e,-i))||0;e[0]*n[1]180?e+=360:e-t>180&&(t+=360),r.push({i:n.push(Kn(n)+"rotate(",null,")")-2,x:pn(t,e)})):e&&n.push(Kn(n)+"rotate("+e+")")}function Yl(t,e,n,r){t!==e?r.push({i:n.push(Kn(n)+"skewX(",null,")")-2,x:pn(t,e)}):e&&n.push(Kn(n)+"skewX("+e+")")}function Xl(t,e,n,r){if(t[0]!==e[0]||t[1]!==e[1]){var i=n.push(Kn(n)+"scale(",null,",",null,")");r.push({i:i-4,x:pn(t[0],e[0])},{i:i-2,x:pn(t[1],e[1])})}else(e[0]!==1||e[1]!==1)&&n.push(Kn(n)+"scale("+e+")")}function Eo(t,e){var n=[],r=[];return t=o.transform(t),e=o.transform(e),Hl(t.translate,e.translate,n,r),Ul(t.rotate,e.rotate,n,r),Yl(t.skew,e.skew,n,r),Xl(t.scale,e.scale,n,r),t=e=null,function(i){for(var a=-1,l=r.length,s;++a0?a=P:(n.c=null,n.t=NaN,n=null,e.start({type:"end",alpha:a=0})):P>0&&(e.start({type:"start",alpha:a=P}),n=Pr(t.tick)),t):a},t.start=function(){var P,W=x.length,Y=A.length,H=r[0],V=r[1],st,gt;for(P=0;P=0;)a.push(f=c[u]),f.parent=s,f.depth=s.depth+1;n&&(s.value=0),s.children=c}else n&&(s.value=+n.call(r,s,s.depth)||0),delete s.children;return sn(i,function(g){var d,x;t&&(d=g.children)&&d.sort(t),n&&(x=g.parent)&&(x.value+=g.value)}),l}return r.sort=function(i){return arguments.length?(t=i,r):t},r.children=function(i){return arguments.length?(e=i,r):e},r.value=function(i){return arguments.length?(n=i,r):n},r.revalue=function(i){return n&&(gr(i,function(a){a.children&&(a.value=0)}),sn(i,function(a){var l;a.children||(a.value=+n.call(r,a,a.depth)||0),(l=a.parent)&&(l.value+=a.value)})),i},r};function hr(t,e){return o.rebind(t,e,"sort","children","value"),t.nodes=t,t.links=lu,t}function gr(t,e){for(var n=[t];(t=n.pop())!=null;)if(e(t),(i=t.children)&&(r=i.length))for(var r,i;--r>=0;)n.push(i[r])}function sn(t,e){for(var n=[t],r=[];(t=n.pop())!=null;)if(r.push(t),(l=t.children)&&(a=l.length))for(var i=-1,a,l;++ii&&(i=s),r.push(s)}for(l=0;lr&&(n=e,r=i);return n}function pu(t){return t.reduce(mu,0)}function mu(t,e){return t+e[1]}o.layout.histogram=function(){var t=!0,e=Number,n=yu,r=_u;function i(a,d){for(var s=[],u=a.map(e,this),c=n.call(this,u,d),f=r.call(this,c,u,d),g,d=-1,x=u.length,A=f.length-1,m=t?1:1/x,_;++d0)for(d=-1;++d=c[0]&&_<=c[1]&&(g=s[o.bisect(f,_,1,A)-1],g.y+=m,g.push(a[d]));return s}return i.value=function(a){return arguments.length?(e=a,i):e},i.range=function(a){return arguments.length?(n=de(a),i):n},i.bins=function(a){return arguments.length?(r=typeof a=="number"?function(l){return zo(l,a)}:de(a),i):r},i.frequency=function(a){return arguments.length?(t=!!a,i):t},i};function _u(t,e){return zo(t,Math.ceil(Math.log(e.length)/Math.LN2+1))}function zo(t,e){for(var n=-1,r=+t[0],i=(t[1]-r)/e,a=[];++n<=e;)a[n]=i*n+r;return a}function yu(t){return[o.min(t),o.max(t)]}o.layout.pack=function(){var t=o.layout.hierarchy().sort(vu),e=0,n=[1,1],r;function i(a,l){var s=t.call(this,a,l),u=s[0],c=n[0],f=n[1],g=r==null?Math.sqrt:typeof r=="function"?r:function(){return r};if(u.x=u.y=0,sn(u,function(x){x.r=+g(x.value)}),sn(u,jo),e){var d=e*(r?1:Math.max(2*u.r/c,2*u.r/f))/2;sn(u,function(x){x.r+=d}),sn(u,jo),sn(u,function(x){x.r-=d})}return Go(u,c/2,f/2,r?1:1/Math.max(2*u.r/c,2*u.r/f)),s}return i.size=function(a){return arguments.length?(n=a,i):n},i.radius=function(a){return arguments.length?(r=a==null||typeof a=="function"?a:+a,i):r},i.padding=function(a){return arguments.length?(e=+a,i):e},hr(i,t)};function vu(t,e){return t.value-e.value}function Xi(t,e){var n=t._pack_next;t._pack_next=e,e._pack_prev=t,e._pack_next=n,n._pack_prev=e}function Ro(t,e){t._pack_next=e,e._pack_prev=t}function Oo(t,e){var n=e.x-t.x,r=e.y-t.y,i=t.r+e.r;return .999*i*i>n*n+r*r}function jo(t){if(!(e=t.children)||!(d=e.length))return;var e,n=1/0,r=-1/0,i=1/0,a=-1/0,l,s,u,c,f,g,d;function x(P){n=Math.min(P.x-P.r,n),r=Math.max(P.x+P.r,r),i=Math.min(P.y-P.r,i),a=Math.max(P.y+P.r,a)}if(e.forEach(xu),l=e[0],l.x=-l.r,l.y=0,x(l),d>1&&(s=e[1],s.x=s.r,s.y=0,x(s),d>2))for(u=e[2],Vo(l,s,u),x(u),Xi(l,u),l._pack_prev=u,Xi(u,s),s=l._pack_next,c=3;c_.x&&(_=W),W.depth>y.depth&&(y=W)});var F=e(m,_)/2-m.x,b=n[0]/(_.x+e(_,m)/2+F),P=n[1]/(y.depth||1);gr(x,function(W){W.x=(W.x+F)*b,W.y=W.depth*P})}return d}function a(f){for(var g={A:null,children:[f]},d=[g],x;(x=d.pop())!=null;)for(var A=x.children,m,_=0,y=A.length;_0&&(wu(Cu(m,f,d),f,W),y+=W,F+=W),b+=m.m,y+=x.m,P+=_.m,F+=A.m;m&&!Zi(A)&&(A.t=m,A.m+=b-F),x&&!Wi(_)&&(_.t=x,_.m+=y-P,d=f)}return d}function c(f){f.x*=n[0],f.y=f.depth*n[1]}return i.separation=function(f){return arguments.length?(e=f,i):e},i.size=function(f){return arguments.length?(r=(n=f)==null?c:null,i):r?null:n},i.nodeSize=function(f){return arguments.length?(r=(n=f)==null?null:c,i):r?n:null},hr(i,t)};function qo(t,e){return t.parent==e.parent?1:2}function Wi(t){var e=t.children;return e.length?e[0]:t.t}function Zi(t){var e=t.children,n;return(n=e.length)?e[n-1]:t.t}function wu(t,e,n){var r=n/(e.i-t.i);e.c-=r,e.s+=n,t.c+=r,e.z+=n,e.m+=n}function ku(t){for(var e=0,n=0,r=t.children,i=r.length,a;--i>=0;)a=r[i],a.z+=e,a.m+=e,e+=a.s+(n+=a.c)}function Cu(t,e,n){return t.a.parent===e.parent?t.a:n}o.layout.cluster=function(){var t=o.layout.hierarchy().sort(null).value(null),e=qo,n=[1,1],r=!1;function i(a,l){var s=t.call(this,a,l),u=s[0],c,f=0;sn(u,function(m){var _=m.children;_&&_.length?(m.x=Su(_),m.y=Mu(_)):(m.x=c?f+=e(m,c):0,m.y=0,c=m)});var g=Ho(u),d=Uo(u),x=g.x-e(g,d)/2,A=d.x+e(d,g)/2;return sn(u,r?function(m){m.x=(m.x-u.x)*n[0],m.y=(u.y-m.y)*n[1]}:function(m){m.x=(m.x-x)/(A-x)*n[0],m.y=(1-(u.y?m.y/u.y:1))*n[1]}),s}return i.separation=function(a){return arguments.length?(e=a,i):e},i.size=function(a){return arguments.length?(r=(n=a)==null,i):r?null:n},i.nodeSize=function(a){return arguments.length?(r=(n=a)!=null,i):r?n:null},hr(i,t)};function Mu(t){return 1+o.max(t,function(e){return e.y})}function Su(t){return t.reduce(function(e,n){return e+n.x},0)/t.length}function Ho(t){var e=t.children;return e&&e.length?Ho(e[0]):t}function Uo(t){var e=t.children,n;return e&&(n=e.length)?Uo(e[n-1]):t}o.layout.treemap=function(){var t=o.layout.hierarchy(),e=Math.round,n=[1,1],r=null,i=$i,a=!1,l,s="squarify",u=.5*(1+Math.sqrt(5));function c(m,_){for(var y=-1,F=m.length,b,P;++y0;)F.push(P=b[V-1]),F.area+=P.area,s!=="squarify"||(Y=d(F,H))<=W?(b.pop(),W=Y):(F.area-=F.pop().area,x(F,H,y,!1),H=Math.min(y.dx,y.dy),F.length=F.area=0,W=1/0);F.length&&(x(F,H,y,!0),F.length=F.area=0),_.forEach(f)}}function g(m){var _=m.children;if(_&&_.length){var y=i(m),F=_.slice(),b,P=[];for(c(F,y.dx*y.dy/m.value),P.area=0;b=F.pop();)P.push(b),P.area+=b.area,b.z!=null&&(x(P,b.z?y.dx:y.dy,y,!F.length),P.length=P.area=0);_.forEach(g)}}function d(m,_){for(var y=m.area,F,b=0,P=1/0,W=-1,Y=m.length;++Wb&&(b=F));return y*=y,_*=_,y?Math.max(_*b*u/y,y/(_*P*u)):1/0}function x(m,_,y,F){var b=-1,P=m.length,W=y.x,Y=y.y,H=_?e(m.area/_):0,V;if(_==y.dx){for((F||H>y.dy)&&(H=y.dy);++by.dx)&&(H=y.dx);++b1);return t+e*r*Math.sqrt(-2*Math.log(a)/a)}},logNormal:function(){var t=o.random.normal.apply(o,arguments);return function(){return Math.exp(t())}},bates:function(t){var e=o.random.irwinHall(t);return function(){return e()/t}},irwinHall:function(t){return function(){for(var e=0,n=0;n2?Lu:Pu,c=r?Zl:Wl;return i=u(t,e,c,n),a=u(e,t,c,En),s}function s(u){return i(u)}return s.invert=function(u){return a(u)},s.domain=function(u){return arguments.length?(t=u.map(Number),l()):t},s.range=function(u){return arguments.length?(e=u,l()):e},s.rangeRound=function(u){return s.range(u).interpolate(Fo)},s.clamp=function(u){return arguments.length?(r=u,l()):r},s.interpolate=function(u){return arguments.length?(n=u,l()):n},s.ticks=function(u){return Qi(t,u)},s.tickFormat=function(u,c){return ta(t,u,c)},s.nice=function(u){return Wo(t,u),l()},s.copy=function(){return Xo(t,e,n,r)},l()}function Ji(t,e){return o.rebind(t,e,"range","rangeRound","interpolate","clamp")}function Wo(t,e){return Ki(t,Au(dr(t,e)[2]))}function dr(t,e){e==null&&(e=10);var n=Jn(t),r=n[1]-n[0],i=Math.pow(10,Math.floor(Math.log(r/e)/Math.LN10)),a=e/r*i;return a<=.15?i*=10:a<=.35?i*=5:a<=.75&&(i*=2),n[0]=Math.ceil(n[0]/i)*i,n[1]=Math.floor(n[1]/i)*i+i*.5,n[2]=i,n}function Qi(t,e){return o.range.apply(o,dr(t,e))}function ta(t,e,n){var r=dr(t,e);if(n){var i=ka.exec(n);if(i.shift(),i[8]==="s"){var a=o.formatPrefix(Math.max(rt(r[0]),rt(r[1])));return i[7]||(i[7]="."+ti(a.scale(r[2]))),i[8]="f",n=o.format(i.join("")),function(l){return n(a.scale(l))+a.symbol}}i[7]||(i[7]="."+Nu(i[8],r)),n=i.join("")}else n=",."+ti(r[2])+"f";return o.format(n)}var Tu={s:1,g:1,p:1,r:1,e:1};function ti(t){return-Math.floor(Math.log(t)/Math.LN10+.01)}function Nu(t,e){var n=ti(e[2]);return t in Tu?Math.abs(n-ti(Math.max(rt(e[0]),rt(e[1]))))+ +(t!=="e"):n-(t==="%")*2}o.scale.log=function(){return Zo(o.scale.linear().domain([0,1]),10,!0,[1,10])};function Zo(t,e,n,r){function i(s){return(n?Math.log(s<0?0:s):-Math.log(s>0?0:-s))/Math.log(e)}function a(s){return n?Math.pow(e,s):-Math.pow(e,-s)}function l(s){return t(i(s))}return l.invert=function(s){return a(t.invert(s))},l.domain=function(s){return arguments.length?(n=s[0]>=0,t.domain((r=s.map(Number)).map(i)),l):r},l.base=function(s){return arguments.length?(e=+s,t.domain(r.map(i)),l):e},l.nice=function(){var s=Ki(r.map(i),n?Math:Eu);return t.domain(s),r=s.map(a),l},l.ticks=function(){var s=Jn(r),u=[],c=s[0],f=s[1],g=Math.floor(i(c)),d=Math.ceil(i(f)),x=e%1?2:e;if(isFinite(d-g)){if(n){for(;g0;A--)u.push(a(g)*A);for(g=0;u[g]f;d--);u=u.slice(g,d)}return u},l.tickFormat=function(s,u){if(!arguments.length)return $o;arguments.length<2?u=$o:typeof u!="function"&&(u=o.format(u));var c=Math.max(.1,s/l.ticks().length),f=n?(g=1e-12,Math.ceil):(g=-1e-12,Math.floor),g;return function(d){return d/a(f(i(d)+g))<=c?u(d):""}},l.copy=function(){return Zo(t.copy(),e,n,r)},Ji(l,t)}var $o=o.format(".0e"),Eu={floor:function(t){return-Math.ceil(-t)},ceil:function(t){return-Math.floor(-t)}};o.scale.pow=function(){return Ko(o.scale.linear(),1,[0,1])};function Ko(t,e,n){var r=ei(e),i=ei(1/e);function a(l){return t(r(l))}return a.invert=function(l){return i(t.invert(l))},a.domain=function(l){return arguments.length?(t.domain((n=l.map(Number)).map(r)),a):n},a.ticks=function(l){return Qi(n,l)},a.tickFormat=function(l,s){return ta(n,l,s)},a.nice=function(l){return a.domain(Wo(n,l))},a.exponent=function(l){return arguments.length?(r=ei(e=l),i=ei(1/e),t.domain(n.map(r)),a):e},a.copy=function(){return Ko(t.copy(),e,n)},Ji(a,t)}function ei(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}o.scale.sqrt=function(){return o.scale.pow().exponent(.5)},o.scale.ordinal=function(){return Jo([],{t:"range",a:[[]]})};function Jo(t,e){var n,r,i;function a(s){return r[((n.get(s)||(e.t==="range"?n.set(s,t.push(s)):NaN))-1)%r.length]}function l(s,u){return o.range(t.length).map(function(c){return s+u*c})}return a.domain=function(s){if(!arguments.length)return t;t=[],n=new dt;for(var u=-1,c=s.length,f;++u0?n[a-1]:t[0],ad?0:1;if(f=Lt)return u(f,A)+(c?u(c,1-A):"")+"Z";var m,_,y,F,b=0,P=0,W,Y,H,V,st,gt,At,xt,Ct=[];if((F=(+l.apply(this,arguments)||0)/2)&&(y=r===ni?Math.sqrt(c*c+f*f):+r.apply(this,arguments),A||(P*=-1),f&&(P=Yt(y/f*Math.sin(F))),c&&(b=Yt(y/c*Math.sin(F)))),f){W=f*Math.cos(g+P),Y=f*Math.sin(g+P),H=f*Math.cos(d-P),V=f*Math.sin(d-P);var tt=Math.abs(d-g-2*P)<=it?0:1;if(P&&ri(W,Y,H,V)===A^tt){var ft=(g+d)/2;W=f*Math.cos(ft),Y=f*Math.sin(ft),H=V=null}}else W=Y=0;if(c){st=c*Math.cos(d-b),gt=c*Math.sin(d-b),At=c*Math.cos(g+b),xt=c*Math.sin(g+b);var yt=Math.abs(g-d+2*b)<=it?0:1;if(b&&ri(st,gt,At,xt)===1-A^yt){var nt=(g+d)/2;st=c*Math.cos(nt),gt=c*Math.sin(nt),At=xt=null}}else st=gt=0;if(x>Q&&(m=Math.min(Math.abs(f-c)/2,+n.apply(this,arguments)))>.001){_=c0?0:1}function ii(t,e,n,r,i){var a=t[0]-e[0],l=t[1]-e[1],s=(i?r:-r)/Math.sqrt(a*a+l*l),u=s*l,c=-s*a,f=t[0]+u,g=t[1]+c,d=e[0]+u,x=e[1]+c,A=(f+d)/2,m=(g+x)/2,_=d-f,y=x-g,F=_*_+y*y,b=n-r,P=f*x-d*g,W=(y<0?-1:1)*Math.sqrt(Math.max(0,b*b*F-P*P)),Y=(P*y-_*W)/F,H=(-P*_-y*W)/F,V=(P*y+_*W)/F,st=(-P*_+y*W)/F,gt=Y-A,At=H-m,xt=V-A,Ct=st-m;return gt*gt+At*At>xt*xt+Ct*Ct&&(Y=V,H=st),[[Y-u,H-c],[Y*n/b,H*n/b]]}function as(t){var e=Yn,n=or,r=rr,i=Qe,a=i.key,l=.7;function s(u){var c=[],f=[],g=-1,d=u.length,x,A=de(e),m=de(n);function _(){c.push("M",i(t(f),l))}for(;++g1?t.join("L"):t+"Z"}function os(t){return t.join("L")+"Z"}function Vu(t){for(var e=0,n=t.length,r=t[0],i=[r[0],",",r[1]];++e1&&i.push("H",r[0]),i.join("")}function na(t){for(var e=0,n=t.length,r=t[0],i=[r[0],",",r[1]];++e1){s=e[1],a=t[u],u++,r+="C"+(i[0]+l[0])+","+(i[1]+l[1])+","+(a[0]-s[0])+","+(a[1]-s[1])+","+a[0]+","+a[1];for(var c=2;c9&&(a=n*3/Math.sqrt(a),l[s]=a*r,l[s+1]=a*i));for(s=-1;++s<=u;)a=(t[Math.min(u,s+1)][0]-t[Math.max(0,s-1)][0])/(6*(1+l[s]*l[s])),e.push([a||0,l[s]*a||0]);return e}function Ku(t){return t.length<3?Qe(t):t[0]+ai(t,$u(t))}o.svg.line.radial=function(){var t=as(cs);return t.radius=t.x,delete t.x,t.angle=t.y,delete t.y,t};function cs(t){for(var e,n=-1,r=t.length,i,a;++nit)+",1 "+g}function c(f,g,d,x){return"Q 0,0 "+x}return a.radius=function(f){return arguments.length?(n=de(f),a):n},a.source=function(f){return arguments.length?(t=de(f),a):t},a.target=function(f){return arguments.length?(e=de(f),a):e},a.startAngle=function(f){return arguments.length?(r=de(f),a):r},a.endAngle=function(f){return arguments.length?(i=de(f),a):i},a};function Ju(t){return t.radius}o.svg.diagonal=function(){var t=Ni,e=Ei,n=hs;function r(i,a){var l=t.call(this,i,a),s=e.call(this,i,a),u=(l.y+s.y)/2,c=[l,{x:l.x,y:u},{x:s.x,y:u},s];return c=c.map(n),"M"+c[0]+"C"+c[1]+" "+c[2]+" "+c[3]}return r.source=function(i){return arguments.length?(t=de(i),r):t},r.target=function(i){return arguments.length?(e=de(i),r):e},r.projection=function(i){return arguments.length?(n=i,r):n},r};function hs(t){return[t.x,t.y]}o.svg.diagonal.radial=function(){var t=o.svg.diagonal(),e=hs,n=t.projection;return t.projection=function(r){return arguments.length?n(Qu(e=r)):e},t};function Qu(t){return function(){var e=t.apply(this,arguments),n=e[0],r=e[1]-bt;return[n*Math.cos(r),n*Math.sin(r)]}}o.svg.symbol=function(){var t=ec,e=tc;function n(r,i){return(ds.get(t.call(this,r,i))||gs)(e.call(this,r,i))}return n.type=function(r){return arguments.length?(t=de(r),n):t},n.size=function(r){return arguments.length?(e=de(r),n):e},n};function tc(){return 64}function ec(){return"circle"}function gs(t){var e=Math.sqrt(t/it);return"M0,"+e+"A"+e+","+e+" 0 1,1 0,"+-e+"A"+e+","+e+" 0 1,1 0,"+e+"Z"}var ds=o.map({circle:gs,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*ps)),n=e*ps;return"M0,"+-e+"L"+n+",0 0,"+e+" "+-n+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/oi),n=e*oi/2;return"M0,"+n+"L"+e+","+-n+" "+-e+","+-n+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/oi),n=e*oi/2;return"M0,"+-n+"L"+e+","+n+" "+-e+","+n+"Z"}});o.svg.symbolTypes=ds.keys();var oi=Math.sqrt(3),ps=Math.tan(30*_t);Ot.transition=function(t){for(var e=Bn||++_s,n=la(t),r=[],i,a,l=li||{time:Date.now(),ease:Tl,delay:0,duration:250},s=-1,u=this.length;++s0;)g[--F].call(t,y);if(_>=1)return l.event&&l.event.end.call(t,t.__data__,e),--a.count?delete a[r]:delete t[n],1}l||(s=i.time,u=Pr(d,0,s),l=a[r]={tween:new dt,time:s,timer:u,delay:i.delay,duration:i.duration,ease:i.ease,index:e},i=null,++a.count)}o.svg.axis=function(){var t=o.scale.linear(),e=ys,n=6,r=6,i=3,a=[10],l=null,s;function u(c){c.each(function(){var f=o.select(this),g=this.__chart__||t,d=this.__chart__=t.copy(),x=l??(d.ticks?d.ticks.apply(d,a):d.domain()),A=s??(d.tickFormat?d.tickFormat.apply(d,a):ie),m=f.selectAll(".tick").data(x,d),_=m.enter().insert("g",".domain").attr("class","tick").style("opacity",Q),y=o.transition(m.exit()).style("opacity",Q).remove(),F=o.transition(m.order()).style("opacity",1),b=Math.max(n,0)+i,P,W=Qr(d),Y=f.selectAll(".domain").data([0]),H=(Y.enter().append("path").attr("class","domain"),o.transition(Y));_.append("line"),_.append("text");var V=_.select("line"),st=F.select("line"),gt=m.select("text").text(A),At=_.select("text"),xt=F.select("text"),Ct=e==="top"||e==="left"?-1:1,tt,ft,yt,nt;if(e==="bottom"||e==="top"?(P=ic,tt="x",yt="y",ft="x2",nt="y2",gt.attr("dy",Ct<0?"0em":".71em").style("text-anchor","middle"),H.attr("d","M"+W[0]+","+Ct*r+"V0H"+W[1]+"V"+Ct*r)):(P=ac,tt="y",yt="x",ft="y2",nt="x2",gt.attr("dy",".32em").style("text-anchor",Ct<0?"end":"start"),H.attr("d","M"+Ct*r+","+W[0]+"H0V"+W[1]+"H"+Ct*r)),V.attr(nt,Ct*n),At.attr(yt,Ct*b),st.attr(ft,0).attr(nt,Ct*n),xt.attr(tt,0).attr(yt,Ct*b),d.rangeBand){var mt=d,Dt=mt.rangeBand()/2;g=d=function(Ht){return mt(Ht)+Dt}}else g.rangeBand?g=d:y.call(P,d,g);_.call(P,g,d),F.call(P,d,d)})}return u.scale=function(c){return arguments.length?(t=c,u):t},u.orient=function(c){return arguments.length?(e=c in rc?c+"":ys,u):e},u.ticks=function(){return arguments.length?(a=w(arguments),u):a},u.tickValues=function(c){return arguments.length?(l=c,u):l},u.tickFormat=function(c){return arguments.length?(s=c,u):s},u.tickSize=function(c){var f=arguments.length;return f?(n=+c,r=+arguments[f-1],u):n},u.innerTickSize=function(c){return arguments.length?(n=+c,u):n},u.outerTickSize=function(c){return arguments.length?(r=+c,u):r},u.tickPadding=function(c){return arguments.length?(i=+c,u):i},u.tickSubdivide=function(){return arguments.length&&u},u};var ys="bottom",rc={top:1,right:1,bottom:1,left:1};function ic(t,e,n){t.attr("transform",function(r){var i=e(r);return"translate("+(isFinite(i)?i:n(r))+",0)"})}function ac(t,e,n){t.attr("transform",function(r){var i=e(r);return"translate(0,"+(isFinite(i)?i:n(r))+")"})}o.svg.brush=function(){var t=Ce(f,"brushstart","brush","brushend"),e=null,n=null,r=[0,0],i=[0,0],a,l,s=!0,u=!0,c=ua[0];function f(m){m.each(function(){var _=o.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",A).on("touchstart.brush",A),y=_.selectAll(".background").data([0]);y.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),_.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var F=_.selectAll(".resize").data(c,ie);F.exit().remove(),F.enter().append("g").attr("class",function(Y){return"resize "+Y}).style("cursor",function(Y){return oc[Y]}).append("rect").attr("x",function(Y){return/[ew]$/.test(Y)?-3:null}).attr("y",function(Y){return/^[ns]/.test(Y)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),F.style("display",f.empty()?"none":null);var b=o.transition(_),P=o.transition(y),W;e&&(W=Qr(e),P.attr("x",W[0]).attr("width",W[1]-W[0]),d(b)),n&&(W=Qr(n),P.attr("y",W[0]).attr("height",W[1]-W[0]),x(b)),g(b)})}f.event=function(m){m.each(function(){var _=t.of(this,arguments),y={x:r,y:i,i:a,j:l},F=this.__chart__||y;this.__chart__=y,Bn?o.select(this).transition().each("start.brush",function(){a=F.i,l=F.j,r=F.x,i=F.y,_({type:"brushstart"})}).tween("brush:brush",function(){var b=Jr(r,y.x),P=Jr(i,y.y);return a=l=null,function(W){r=y.x=b(W),i=y.y=P(W),_({type:"brush",mode:"resize"})}}).each("end.brush",function(){a=y.i,l=y.j,_({type:"brush",mode:"resize"}),_({type:"brushend"})}):(_({type:"brushstart"}),_({type:"brush",mode:"resize"}),_({type:"brushend"}))})};function g(m){m.selectAll(".resize").attr("transform",function(_){return"translate("+r[+/e$/.test(_)]+","+i[+/^s/.test(_)]+")"})}function d(m){m.select(".extent").attr("x",r[0]),m.selectAll(".extent,.n>rect,.s>rect").attr("width",r[1]-r[0])}function x(m){m.select(".extent").attr("y",i[0]),m.selectAll(".extent,.e>rect,.w>rect").attr("height",i[1]-i[0])}function A(){var m=this,_=o.select(o.event.target),y=t.of(m,arguments),F=o.select(m),b=_.datum(),P=!/^(n|s)$/.test(b)&&e,W=!/^(e|w)$/.test(b)&&n,Y=_.classed("extent"),H=lt(m),V,st=o.mouse(m),gt,At=o.select(B(m)).on("keydown.brush",tt).on("keyup.brush",ft);if(o.event.changedTouches?At.on("touchmove.brush",yt).on("touchend.brush",mt):At.on("mousemove.brush",yt).on("mouseup.brush",mt),F.interrupt().selectAll("*").interrupt(),Y)st[0]=r[0]-st[0],st[1]=i[0]-st[1];else if(b){var xt=+/w$/.test(b),Ct=+/^n/.test(b);gt=[r[1-xt]-st[0],i[1-Ct]-st[1]],st[0]=r[xt],st[1]=i[Ct]}else o.event.altKey&&(V=st.slice());F.style("pointer-events","none").selectAll(".resize").style("display",null),o.select("body").style("cursor",_.style("cursor")),y({type:"brushstart"}),yt();function tt(){o.event.keyCode==32&&(Y||(V=null,st[0]-=r[1],st[1]-=i[1],Y=2),Qt())}function ft(){o.event.keyCode==32&&Y==2&&(st[0]+=r[1],st[1]+=i[1],Y=0,Qt())}function yt(){var Dt=o.mouse(m),Ht=!1;gt&&(Dt[0]+=gt[0],Dt[1]+=gt[1]),Y||(o.event.altKey?(V||(V=[(r[0]+r[1])/2,(i[0]+i[1])/2]),st[0]=r[+(Dt[0]1?{floor:function(g){for(;f(g=a.floor(g));)g=Dn(g-1);return g},ceil:function(g){for(;f(g=a.ceil(g));)g=Dn(+g+1);return g}}:a))},r.ticks=function(a,l){var s=Jn(r.domain()),u=a==null?i(s,10):typeof a=="number"?i(s,a):!a.range&&[{range:a},l];return u&&(a=u[0],l=u[1]),a.range(s[0],Dn(+s[1]+1),l<1?1:l)},r.tickFormat=function(){return n},r.copy=function(){return ha(t.copy(),e,n)},Ji(r,t)}function Dn(t){return new Date(t)}var ci=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],ga=[[It.second,1],[It.second,5],[It.second,15],[It.second,30],[It.minute,1],[It.minute,5],[It.minute,15],[It.minute,30],[It.hour,1],[It.hour,3],[It.hour,6],[It.hour,12],[It.day,1],[It.day,2],[It.week,1],[It.month,1],[It.month,3],[It.year,1]],sc=ca.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&t.getDate()!=1}],["%b %d",function(t){return t.getDate()!=1}],["%B",function(t){return t.getMonth()}],["%Y",rr]]),lc={range:function(t,e,n){return o.range(Math.ceil(t/n)*n,+e,n).map(Dn)},floor:ie,ceil:ie};ga.year=It.year,It.scale=function(){return ha(o.scale.linear(),ga,sc)};var bs=ga.map(function(t){return[t[0].utc,t[1]]}),uc=vs.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&t.getUTCDate()!=1}],["%b %d",function(t){return t.getUTCDate()!=1}],["%B",function(t){return t.getUTCMonth()}],["%Y",rr]]);bs.year=It.year.utc,It.scale.utc=function(){return ha(o.scale.linear(),bs,uc)},o.text=vi(function(t){return t.responseText}),o.json=function(t,e){return wr(t,"application/json",cc,e)};function cc(t){return JSON.parse(t.responseText)}o.html=function(t,e){return wr(t,"text/html",fc,e)};function fc(t){var e=v.createRange();return e.selectNode(v.body),e.createContextualFragment(t.responseText)}return o.xml=vi(function(t){return t.responseXML}),o};const pt=window.E0DD32CBDCB63F();let gi=1;function dc(p){const o="<",w=">",I=`\r diff --git a/assets/chunks/index.CafPLwUV.js b/assets/chunks/index.MWfHGcqb.js similarity index 99% rename from assets/chunks/index.CafPLwUV.js rename to assets/chunks/index.MWfHGcqb.js index 6b9a8df74f..a00e630839 100644 --- a/assets/chunks/index.CafPLwUV.js +++ b/assets/chunks/index.MWfHGcqb.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/chunks/index-Co9E57uv.DM_Nu_-Q.js","assets/chunks/framework.eq-HTtE3.js","assets/chunks/colz-DJZvo_8B.DBiU5Tau.js","assets/chunks/docx-VUApAnRr.Cl4GUa7G.js","assets/chunks/jszip.min-BIf20mgf.BsDI-Ugu.js","assets/chunks/commonjs-dynamic-modules-DLbDWi6a.CRNIONdy.js","assets/chunks/pdf-Cx0VWKFo.CmQSFM5C.js","assets/chunks/index-Ba501-HG.DLGTjfcz.js"])))=>i.map(i=>d[i]); -import{ag as V}from"./framework.eq-HTtE3.js";var ed=Object.defineProperty,td=(k,h,p)=>h in k?ed(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,be=(k,h,p)=>td(k,typeof h!="symbol"?h+"":h,p);const Yo=()=>{},dn=()=>{if(typeof window<"u"){const k=navigator.userAgent.toLowerCase();return/ipad|ipod/.test(k)?"ipad":/android/.test(k)?"android":/iphone/.test(k)?"iphone":"pc"}return"pc"},jo=typeof window<"u",_t=()=>{if(!jo)return!1;const k=window.navigator.userAgent;return!!/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(k)},$=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];class U{constructor(h,p){be(this,"highOrder"),be(this,"lowOrder"),this.highOrder=h,this.lowOrder=p}}new U($[0],3609767458),new U($[1],602891725),new U($[2],3964484399),new U($[3],2173295548),new U($[4],4081628472),new U($[5],3053834265),new U($[6],2937671579),new U($[7],3664609560),new U($[8],2734883394),new U($[9],1164996542),new U($[10],1323610764),new U($[11],3590304994),new U($[12],4068182383),new U($[13],991336113),new U($[14],633803317),new U($[15],3479774868),new U($[16],2666613458),new U($[17],944711139),new U($[18],2341262773),new U($[19],2007800933),new U($[20],1495990901),new U($[21],1856431235),new U($[22],3175218132),new U($[23],2198950837),new U($[24],3999719339),new U($[25],766784016),new U($[26],2566594879),new U($[27],3203337956),new U($[28],1034457026),new U($[29],2466948901),new U($[30],3758326383),new U($[31],168717936),new U($[32],1188179964),new U($[33],1546045734),new U($[34],1522805485),new U($[35],2643833823),new U($[36],2343527390),new U($[37],1014477480),new U($[38],1206759142),new U($[39],344077627),new U($[40],1290863460),new U($[41],3158454273),new U($[42],3505952657),new U($[43],106217008),new U($[44],3606008344),new U($[45],1432725776),new U($[46],1467031594),new U($[47],851169720),new U($[48],3100823752),new U($[49],1363258195),new U($[50],3750685593),new U($[51],3785050280),new U($[52],3318307427),new U($[53],3812723403),new U($[54],2003034995),new U($[55],3602036899),new U($[56],1575990012),new U($[57],1125592928),new U($[58],2716904306),new U($[59],442776044),new U($[60],593698344),new U($[61],3733110249),new U($[62],2999351573),new U($[63],3815920427),new U(3391569614,3928383900),new U(3515267271,566280711),new U(3940187606,3454069534),new U(4118630271,4000239992),new U(116418474,1914138554),new U(174292421,2731055270),new U(289380356,3203993006),new U(460393269,320620315),new U(685471733,587496836),new U(852142971,1086792851),new U(1017036298,365543100),new U(1126000580,2618297676),new U(1288033470,3409855158),new U(1501505948,4234509866),new U(1607167915,987167468),new U(1816402316,1246189591);new U(0,1),new U(0,32898),new U(2147483648,32906),new U(2147483648,2147516416),new U(0,32907),new U(0,2147483649),new U(2147483648,2147516545),new U(2147483648,32777),new U(0,138),new U(0,136),new U(0,2147516425),new U(0,2147483658),new U(0,2147516555),new U(2147483648,139),new U(2147483648,32905),new U(2147483648,32771),new U(2147483648,32770),new U(2147483648,128),new U(0,32778),new U(2147483648,2147483658),new U(2147483648,2147516545),new U(2147483648,32896),new U(0,2147483649),new U(2147483648,2147516424);function Et(k){return k<10?`0${k}`:k}function id(k){let h=new Date;return k&&(h=new Date(k)),h.format=(p="YYYY-MM-DD HH:mm:ss")=>{const f=h.getFullYear(),w=Et(h.getMonth()+1),x=Et(h.getDate()),T=Et(h.getHours()),D=Et(h.getMinutes()),G=Et(h.getSeconds());return p.replace(/Y+/gi,`${f}`).replace(/M+/g,`${w}`).replace(/D+/gi,`${x}`).replace(/H+/gi,`${T}`).replace(/m+/g,`${D}`).replace(/S+/gi,`${G}`)},h}const vi=k=>{if(k===0)return"00:00";if(!k)return"";const h=Math.trunc(k/3600),p=Math.trunc(k%3600/60),f=Et(Math.trunc(k-h*3600-p*60));return h===0?`${Et(p)}:${f}`:`${Et(h)}:${Et(p)}:${f}`},Zt=k=>{const h=k.backingStorePixelRatio||k.webkitBackingStorePixelRatio||k.mozBackingStorePixelRatio||k.msBackingStorePixelRatio||k.oBackingStorePixelRatio||1;return(jo&&window.devicePixelRatio||1)/h},Re=(k,h)=>{if(typeof document>"u")return;const p=k.classList;p.contains(h)||p.add(h)},Ve=(k,h)=>{if(typeof document>"u")return;const p=k.classList;p.contains(h)&&p.remove(h)},rt=k=>{if(typeof document>"u")return;const h=document.createDocumentFragment();return k.forEach(p=>h.appendChild(p)),h},rd="http://www.w3.org/2000/svg",nd=["svg","path","g","circle","rect","line","polyline","polygon","ellipse","text","tspan","textPath","defs","marker","radialGradient","stop","linearGradient","clipPath","mask","pattern","image","use","symbol","foreignObject","feGaussianBlur","feColorMatrix"];class An{constructor(h,p){be(this,"listener"),be(this,"element"),be(this,"create",(f,w)=>nd.includes(f)?document.createElementNS(rd,f,w):document.createElement(f,w)),be(this,"setAttribute",(f,w)=>(this.element.setAttribute(f,w),this)),be(this,"removeAttribute",f=>(this.element.removeAttribute(f),this)),be(this,"append",f=>(this.element.appendChild(f),this)),be(this,"remove",f=>(this.element.removeChild(f),this)),be(this,"setTextContent",f=>(this.element.textContent=f,this)),be(this,"setStyle",(f,w)=>(this.element.style.setProperty(f,w),this)),be(this,"addElementByType",(f,w)=>{f instanceof An&&w.appendChild(f.element),f instanceof HTMLElement&&w.appendChild(f)}),be(this,"addChild",f=>{if(Array.isArray(f)){const w=document.createDocumentFragment();f.forEach(x=>{this.addElementByType(x,w)}),this.element.appendChild(w)}else this.addElementByType(f,this.element);return this}),be(this,"listen",(f,w,x)=>{let T=this.listener.get(f);T||(T=new Map,this.listener.set(f,T));const D=T.get(w.name);return D===w&&console.warn(`${D.name} listener has been added to ${f} event, please remove it first.`),this.element.addEventListener(f,w,x),T.set(w.name,w),this}),be(this,"clearListener",(f,w,x)=>{this.element.removeEventListener(f,w,x);const T=this.listener.get(f);return T?T.delete(w.name):console.warn(`No ${f} event listener has been added.`),this}),be(this,"clearAllListener",()=>{for(const[f,w]of this.listener){for(const[x,T]of w)this.element.removeEventListener(f,T),w.delete(x);this.listener.delete(f)}return this}),this.element=this.create(h,p),this.listener=new Map}}const z=(k,h)=>new An(k,h),Zi=()=>{let k;return function(h,p=300){return function(...f){k&&(clearTimeout(k),k=void 0);const w=this;k||(k=setTimeout(()=>{h.apply(w,f),clearTimeout(k),k=void 0},p))}}},on=new Map([[100,"Continue"],[101,"Switching Protocols"],[102,"Processing"],[103,"Early Hints"],[200,"OK"],[201,"Created"],[202,"Accepted"],[203,"Non-Authoritative Information"],[204,"No Content"],[205,"Reset Content"],[206,"Partial Content"],[207,"Multi-Status"],[208,"Already Reported"],[226,"IM Used"],[300,"Multiple Choices"],[301,"Moved Permanently"],[302,"Found"],[303,"See Other"],[304,"Not Modified"],[305,"Use Proxy"],[307,"Temporary Redirect"],[308,"Permanent Redirect"],[400,"Bad Request"],[401,"Unauthorized"],[402,"Payment Required"],[403,"Forbidden"],[404,"Not Found"],[405,"Method Not Allowed"],[406,"Not Acceptable"],[407,"Proxy Authentication Required"],[408,"Request Timeout"],[409,"Conflict"],[410,"Gone"],[411,"Length Required"],[412,"Precondition Failed"],[413,"Payload Too Large"],[414,"URI Too Long"],[415,"Unsupported Media Type"],[416,"Range Not Satisfiable"],[417,"Expectation Failed"],[418,"I'm a Teapot"],[421,"Misdirected Request"],[422,"Unprocessable Entity"],[423,"Locked"],[424,"Failed Dependency"],[425,"Too Early"],[426,"Upgrade Required"],[428,"Precondition Required"],[429,"Too Many Requests"],[431,"Request Header Fields Too Large"],[451,"Unavailable For Legal Reasons"],[500,"Internal Server Error"],[501,"Not Implemented"],[502,"Bad Gateway"],[503,"Service Unavailable"],[504,"Gateway Timeout"],[505,"HTTP Version Not Supported"],[506,"Variant Also Negotiates"],[507,"Insufficient Storage"],[508,"Loop Detected"],[509,"Bandwidth Limit Exceeded"],[510,"Not Extended"],[511,"Network Authentication Required"]]);ad(on),od(on);function ad(k){const h=new Map;for(const[p,f]of k)h.set(f.toLowerCase(),p);return h}function od(k){const h=[];for(const[p,f]of k)h.push(p);return h}const Qi=(k="")=>{if(k.length===0)return 0;if(k.endsWith("%")){const h=Number(k.replace("%",""));return h>1?h/100:h}else return Number(k)},At=(k,h=0,p=1)=>Math.min(p,Math.max(h,k)),ft=class{constructor(){be(this,"getDecimalLength",h=>{const[p,f]=h.toString().split(".");return f?f.length:0}),be(this,"amend",(h,p=15)=>parseFloat(Number(h).toPrecision(p))),be(this,"power",(h,p)=>Math.pow(10,Math.max(this.getDecimalLength(h),this.getDecimalLength(p))))}};be(ft,"handleMethod",(k,h)=>{const p=new ft,{power:f,amend:w}=p,x=f(k,h),T=w(k*x),D=w(h*x);return G=>{switch(G){case"+":return(T+D)/x;case"-":return(T-D)/x;case"*":return T*D/(x*x);case"/":return T/D}}});be(ft,"add",(k,h)=>ft.handleMethod(k,h)("+"));be(ft,"divide",(k,h)=>ft.handleMethod(k,h)("/"));be(ft,"multiply",(k,h)=>ft.handleMethod(k,h)("*"));be(ft,"subtract",(k,h)=>ft.handleMethod(k,h)("-"));const wo="NEW_LISTENER";class qo{constructor(){be(this,"_events"),be(this,"tap",(h,p)=>{this._events[h]&&h!==Symbol.for(wo)&&this.call(Symbol.for(wo),h);const f=this._events[h]||[];return typeof p=="function"?f.push({name:h,callback:p}):f.push(p),this._events[h]=f,this}),be(this,"call",(h,...p)=>{(this._events[h]||[]).forEach(w=>{const{callback:x}=w;x(...p)})}),be(this,"callSync",async(h,...p)=>{const f=this._events[h]||[];for(const w of f){const{callback:x}=w;await x(...p)}}),be(this,"once",(h,p)=>{let f;if(typeof p=="function")f={name:h,callback:(...w)=>{p(...w),this.off(h,f)},initialCallback:p};else{const{callback:w}=p;f={name:h,callback:(...x)=>{w(...x),this.off(h,f)},initialCallback:w}}return this.tap(h,f),this}),be(this,"off",(h,p)=>{const w=(this._events[h]||[]).filter(x=>{if(typeof p=="function")return x.callback!==p&&x.initialCallback!==p;{const{callback:T}=p;return x.callback!==T&&x.initialCallback!==T}});return this._events[h]=w,this}),this._events={}}}const sd={success:!0,_identification:!0,data:`i.map(i=>d[i]); +import{ag as V}from"./framework.CHSXtLMd.js";var ed=Object.defineProperty,td=(k,h,p)=>h in k?ed(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,be=(k,h,p)=>td(k,typeof h!="symbol"?h+"":h,p);const Yo=()=>{},dn=()=>{if(typeof window<"u"){const k=navigator.userAgent.toLowerCase();return/ipad|ipod/.test(k)?"ipad":/android/.test(k)?"android":/iphone/.test(k)?"iphone":"pc"}return"pc"},jo=typeof window<"u",_t=()=>{if(!jo)return!1;const k=window.navigator.userAgent;return!!/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(k)},$=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];class U{constructor(h,p){be(this,"highOrder"),be(this,"lowOrder"),this.highOrder=h,this.lowOrder=p}}new U($[0],3609767458),new U($[1],602891725),new U($[2],3964484399),new U($[3],2173295548),new U($[4],4081628472),new U($[5],3053834265),new U($[6],2937671579),new U($[7],3664609560),new U($[8],2734883394),new U($[9],1164996542),new U($[10],1323610764),new U($[11],3590304994),new U($[12],4068182383),new U($[13],991336113),new U($[14],633803317),new U($[15],3479774868),new U($[16],2666613458),new U($[17],944711139),new U($[18],2341262773),new U($[19],2007800933),new U($[20],1495990901),new U($[21],1856431235),new U($[22],3175218132),new U($[23],2198950837),new U($[24],3999719339),new U($[25],766784016),new U($[26],2566594879),new U($[27],3203337956),new U($[28],1034457026),new U($[29],2466948901),new U($[30],3758326383),new U($[31],168717936),new U($[32],1188179964),new U($[33],1546045734),new U($[34],1522805485),new U($[35],2643833823),new U($[36],2343527390),new U($[37],1014477480),new U($[38],1206759142),new U($[39],344077627),new U($[40],1290863460),new U($[41],3158454273),new U($[42],3505952657),new U($[43],106217008),new U($[44],3606008344),new U($[45],1432725776),new U($[46],1467031594),new U($[47],851169720),new U($[48],3100823752),new U($[49],1363258195),new U($[50],3750685593),new U($[51],3785050280),new U($[52],3318307427),new U($[53],3812723403),new U($[54],2003034995),new U($[55],3602036899),new U($[56],1575990012),new U($[57],1125592928),new U($[58],2716904306),new U($[59],442776044),new U($[60],593698344),new U($[61],3733110249),new U($[62],2999351573),new U($[63],3815920427),new U(3391569614,3928383900),new U(3515267271,566280711),new U(3940187606,3454069534),new U(4118630271,4000239992),new U(116418474,1914138554),new U(174292421,2731055270),new U(289380356,3203993006),new U(460393269,320620315),new U(685471733,587496836),new U(852142971,1086792851),new U(1017036298,365543100),new U(1126000580,2618297676),new U(1288033470,3409855158),new U(1501505948,4234509866),new U(1607167915,987167468),new U(1816402316,1246189591);new U(0,1),new U(0,32898),new U(2147483648,32906),new U(2147483648,2147516416),new U(0,32907),new U(0,2147483649),new U(2147483648,2147516545),new U(2147483648,32777),new U(0,138),new U(0,136),new U(0,2147516425),new U(0,2147483658),new U(0,2147516555),new U(2147483648,139),new U(2147483648,32905),new U(2147483648,32771),new U(2147483648,32770),new U(2147483648,128),new U(0,32778),new U(2147483648,2147483658),new U(2147483648,2147516545),new U(2147483648,32896),new U(0,2147483649),new U(2147483648,2147516424);function Et(k){return k<10?`0${k}`:k}function id(k){let h=new Date;return k&&(h=new Date(k)),h.format=(p="YYYY-MM-DD HH:mm:ss")=>{const f=h.getFullYear(),w=Et(h.getMonth()+1),x=Et(h.getDate()),T=Et(h.getHours()),D=Et(h.getMinutes()),G=Et(h.getSeconds());return p.replace(/Y+/gi,`${f}`).replace(/M+/g,`${w}`).replace(/D+/gi,`${x}`).replace(/H+/gi,`${T}`).replace(/m+/g,`${D}`).replace(/S+/gi,`${G}`)},h}const vi=k=>{if(k===0)return"00:00";if(!k)return"";const h=Math.trunc(k/3600),p=Math.trunc(k%3600/60),f=Et(Math.trunc(k-h*3600-p*60));return h===0?`${Et(p)}:${f}`:`${Et(h)}:${Et(p)}:${f}`},Zt=k=>{const h=k.backingStorePixelRatio||k.webkitBackingStorePixelRatio||k.mozBackingStorePixelRatio||k.msBackingStorePixelRatio||k.oBackingStorePixelRatio||1;return(jo&&window.devicePixelRatio||1)/h},Re=(k,h)=>{if(typeof document>"u")return;const p=k.classList;p.contains(h)||p.add(h)},Ve=(k,h)=>{if(typeof document>"u")return;const p=k.classList;p.contains(h)&&p.remove(h)},rt=k=>{if(typeof document>"u")return;const h=document.createDocumentFragment();return k.forEach(p=>h.appendChild(p)),h},rd="http://www.w3.org/2000/svg",nd=["svg","path","g","circle","rect","line","polyline","polygon","ellipse","text","tspan","textPath","defs","marker","radialGradient","stop","linearGradient","clipPath","mask","pattern","image","use","symbol","foreignObject","feGaussianBlur","feColorMatrix"];class An{constructor(h,p){be(this,"listener"),be(this,"element"),be(this,"create",(f,w)=>nd.includes(f)?document.createElementNS(rd,f,w):document.createElement(f,w)),be(this,"setAttribute",(f,w)=>(this.element.setAttribute(f,w),this)),be(this,"removeAttribute",f=>(this.element.removeAttribute(f),this)),be(this,"append",f=>(this.element.appendChild(f),this)),be(this,"remove",f=>(this.element.removeChild(f),this)),be(this,"setTextContent",f=>(this.element.textContent=f,this)),be(this,"setStyle",(f,w)=>(this.element.style.setProperty(f,w),this)),be(this,"addElementByType",(f,w)=>{f instanceof An&&w.appendChild(f.element),f instanceof HTMLElement&&w.appendChild(f)}),be(this,"addChild",f=>{if(Array.isArray(f)){const w=document.createDocumentFragment();f.forEach(x=>{this.addElementByType(x,w)}),this.element.appendChild(w)}else this.addElementByType(f,this.element);return this}),be(this,"listen",(f,w,x)=>{let T=this.listener.get(f);T||(T=new Map,this.listener.set(f,T));const D=T.get(w.name);return D===w&&console.warn(`${D.name} listener has been added to ${f} event, please remove it first.`),this.element.addEventListener(f,w,x),T.set(w.name,w),this}),be(this,"clearListener",(f,w,x)=>{this.element.removeEventListener(f,w,x);const T=this.listener.get(f);return T?T.delete(w.name):console.warn(`No ${f} event listener has been added.`),this}),be(this,"clearAllListener",()=>{for(const[f,w]of this.listener){for(const[x,T]of w)this.element.removeEventListener(f,T),w.delete(x);this.listener.delete(f)}return this}),this.element=this.create(h,p),this.listener=new Map}}const z=(k,h)=>new An(k,h),Zi=()=>{let k;return function(h,p=300){return function(...f){k&&(clearTimeout(k),k=void 0);const w=this;k||(k=setTimeout(()=>{h.apply(w,f),clearTimeout(k),k=void 0},p))}}},on=new Map([[100,"Continue"],[101,"Switching Protocols"],[102,"Processing"],[103,"Early Hints"],[200,"OK"],[201,"Created"],[202,"Accepted"],[203,"Non-Authoritative Information"],[204,"No Content"],[205,"Reset Content"],[206,"Partial Content"],[207,"Multi-Status"],[208,"Already Reported"],[226,"IM Used"],[300,"Multiple Choices"],[301,"Moved Permanently"],[302,"Found"],[303,"See Other"],[304,"Not Modified"],[305,"Use Proxy"],[307,"Temporary Redirect"],[308,"Permanent Redirect"],[400,"Bad Request"],[401,"Unauthorized"],[402,"Payment Required"],[403,"Forbidden"],[404,"Not Found"],[405,"Method Not Allowed"],[406,"Not Acceptable"],[407,"Proxy Authentication Required"],[408,"Request Timeout"],[409,"Conflict"],[410,"Gone"],[411,"Length Required"],[412,"Precondition Failed"],[413,"Payload Too Large"],[414,"URI Too Long"],[415,"Unsupported Media Type"],[416,"Range Not Satisfiable"],[417,"Expectation Failed"],[418,"I'm a Teapot"],[421,"Misdirected Request"],[422,"Unprocessable Entity"],[423,"Locked"],[424,"Failed Dependency"],[425,"Too Early"],[426,"Upgrade Required"],[428,"Precondition Required"],[429,"Too Many Requests"],[431,"Request Header Fields Too Large"],[451,"Unavailable For Legal Reasons"],[500,"Internal Server Error"],[501,"Not Implemented"],[502,"Bad Gateway"],[503,"Service Unavailable"],[504,"Gateway Timeout"],[505,"HTTP Version Not Supported"],[506,"Variant Also Negotiates"],[507,"Insufficient Storage"],[508,"Loop Detected"],[509,"Bandwidth Limit Exceeded"],[510,"Not Extended"],[511,"Network Authentication Required"]]);ad(on),od(on);function ad(k){const h=new Map;for(const[p,f]of k)h.set(f.toLowerCase(),p);return h}function od(k){const h=[];for(const[p,f]of k)h.push(p);return h}const Qi=(k="")=>{if(k.length===0)return 0;if(k.endsWith("%")){const h=Number(k.replace("%",""));return h>1?h/100:h}else return Number(k)},At=(k,h=0,p=1)=>Math.min(p,Math.max(h,k)),ft=class{constructor(){be(this,"getDecimalLength",h=>{const[p,f]=h.toString().split(".");return f?f.length:0}),be(this,"amend",(h,p=15)=>parseFloat(Number(h).toPrecision(p))),be(this,"power",(h,p)=>Math.pow(10,Math.max(this.getDecimalLength(h),this.getDecimalLength(p))))}};be(ft,"handleMethod",(k,h)=>{const p=new ft,{power:f,amend:w}=p,x=f(k,h),T=w(k*x),D=w(h*x);return G=>{switch(G){case"+":return(T+D)/x;case"-":return(T-D)/x;case"*":return T*D/(x*x);case"/":return T/D}}});be(ft,"add",(k,h)=>ft.handleMethod(k,h)("+"));be(ft,"divide",(k,h)=>ft.handleMethod(k,h)("/"));be(ft,"multiply",(k,h)=>ft.handleMethod(k,h)("*"));be(ft,"subtract",(k,h)=>ft.handleMethod(k,h)("-"));const wo="NEW_LISTENER";class qo{constructor(){be(this,"_events"),be(this,"tap",(h,p)=>{this._events[h]&&h!==Symbol.for(wo)&&this.call(Symbol.for(wo),h);const f=this._events[h]||[];return typeof p=="function"?f.push({name:h,callback:p}):f.push(p),this._events[h]=f,this}),be(this,"call",(h,...p)=>{(this._events[h]||[]).forEach(w=>{const{callback:x}=w;x(...p)})}),be(this,"callSync",async(h,...p)=>{const f=this._events[h]||[];for(const w of f){const{callback:x}=w;await x(...p)}}),be(this,"once",(h,p)=>{let f;if(typeof p=="function")f={name:h,callback:(...w)=>{p(...w),this.off(h,f)},initialCallback:p};else{const{callback:w}=p;f={name:h,callback:(...x)=>{w(...x),this.off(h,f)},initialCallback:w}}return this.tap(h,f),this}),be(this,"off",(h,p)=>{const w=(this._events[h]||[]).filter(x=>{if(typeof p=="function")return x.callback!==p&&x.initialCallback!==p;{const{callback:T}=p;return x.callback!==T&&x.initialCallback!==T}});return this._events[h]=w,this}),this._events={}}}const sd={success:!0,_identification:!0,data:` @@ -13,7 +13,7 @@ import{ag as V}from"./framework.eq-HTtE3.js";var ed=Object.defineProperty,td=(k, couldn't be loaded by r-icon, message: ${this.name} icon is undefined`)}).catch(T=>{this.loadNs()})})),Oe(this,"loadNs",()=>{this._icon&&this._div&&this._div.removeChild(this._icon),this._icon=document.createElement("svg"),this._icon.setAttribute("class","icon"),this._icon.setAttribute("viewBox","0 0 1024 1024"),this._icon.setAttribute("width","100"),this._icon.setAttribute("height","100");const w=document.createElementNS(ji,"use");w.setAttributeNS(ji,Eo,`../../assets/iconfont/icon.svg#icon-${this.name}`),this._icon.appendChild(w),this._div.appendChild(this._icon)}),Oe(this,"setIcon",async()=>{this.name&&this.loadLocal()}),Oe(this,"setSize",()=>{this._icon&&this.size&&(this._icon.setAttribute("width",this.size),this._icon.setAttribute("height",this.size))}),Oe(this,"setColor",()=>{this._icon&&(this.color?this._icon.setAttribute("fill",this.color):this._icon.setAttribute("fill","currentColor"))}),Oe(this,"setSpin",()=>{this.spin&&this.style.setProperty("animation-duration",`${this.spin}s`)}),this._div=document.createElement("div"),this._div.setAttribute("class","ran-icon"),this._div.setAttribute("part","ran-icon");const p=this.attachShadow({mode:"closed"}),f=document.createElement("style");f.textContent=_d,p.appendChild(f),p.appendChild(this._div)}static get observedAttributes(){return["name","size","color","spin"]}get name(){return this.getAttribute("name")}set name(p){p&&this.setAttribute("name",p)}get size(){return this.getAttribute("size")}set size(p){p&&this.setAttribute("size",p)}get color(){return this.getAttribute("color")}set color(p){p&&this.setAttribute("color",p)}get spin(){return this.getAttribute("spin")}set spin(p){p!=null&&this.setAttribute("spin",p)}connectedCallback(){this.setIcon()}attributeChangedCallback(p,f,w){w!==f&&(p==="name"&&this.setIcon(),p==="size"&&this.setSize(),p==="color"&&this.setColor(),p==="spin"&&this.setSpin())}}customElements.define("r-icon",k)}if(typeof window<"u"&&!customElements.get("ra-icon")){class k extends HTMLElement{constructor(){super(),Oe(this,"_icon"),Oe(this,"_div"),Oe(this,"loadLocal",()=>new Promise((p,f)=>{Ji(Object.assign({"../../assets/icons/add-user.svg":()=>V(()=>import("./add-user-BN1JlY7e.D6YNNzf8.js"),[]),"../../assets/icons/arrow-down.svg":()=>V(()=>Promise.resolve().then(()=>cn),void 0).then(w=>w.j),"../../assets/icons/book.svg":()=>V(()=>import("./book-nTEFXU2x.DPEdiL1I.js"),[]),"../../assets/icons/check-circle-fill.svg":()=>V(()=>import("./check-circle-fill-B_pd8ZSs.Dxgzakn4.js"),[]),"../../assets/icons/check-circle.svg":()=>V(()=>import("./check-circle-szyAJiap.CM_vbBX5.js"),[]),"../../assets/icons/close-circle-fill.svg":()=>V(()=>import("./close-circle-fill-jSqPPw9i.BsLXh5-a.js"),[]),"../../assets/icons/close-circle.svg":()=>V(()=>import("./close-circle-CwmuN2C6.D612j4KD.js"),[]),"../../assets/icons/close.svg":()=>V(()=>import("./close-CFnkhudp.IMqD2L1-.js"),[]),"../../assets/icons/drop.svg":()=>V(()=>Promise.resolve().then(()=>un),void 0).then(w=>w.d),"../../assets/icons/eye-close.svg":()=>V(()=>import("./eye-close-BVr3NJtg.DsdsDDgX.js"),[]),"../../assets/icons/eye.svg":()=>V(()=>import("./eye-D_mEt17f.DJFa_ttF.js"),[]),"../../assets/icons/home.svg":()=>V(()=>import("./home-BUQ4USMk.BqTharGj.js"),[]),"../../assets/icons/info-circle-fill.svg":()=>V(()=>import("./info-circle-fill-CFeVMdci.CUxFtRNn.js"),[]),"../../assets/icons/info-circle.svg":()=>V(()=>import("./info-circle-COnL5bTJ.B9YJorcw.js"),[]),"../../assets/icons/loading-scene.svg":()=>V(()=>import("./loading-scene-BMc2wqKm.Di19NrRU.js"),[]),"../../assets/icons/loading.svg":()=>V(()=>import("./loading-Dcc5RApI.D3l74EUI.js"),[]),"../../assets/icons/lock.svg":()=>V(()=>import("./lock-Cr7BnmWN.0WfYXC2j.js"),[]),"../../assets/icons/message.svg":()=>V(()=>import("./message-D36_Zo2l.CR8K3LhI.js"),[]),"../../assets/icons/power-off.svg":()=>V(()=>import("./power-off-lQRbiBak.r13EH4bb.js"),[]),"../../assets/icons/preview.svg":()=>V(()=>import("./preview-CJbz9GjO.C8N16-9H.js"),[]),"../../assets/icons/setting.svg":()=>V(()=>import("./setting-DemlgzVC.DkD4YPwp.js"),[]),"../../assets/icons/sprite.svg":()=>V(()=>import("./sprite-CH2zLtZy.Djo3sTkk.js"),[]),"../../assets/icons/team.svg":()=>V(()=>import("./team-tl4NJXPC.D7881a1v.js"),[]),"../../assets/icons/unlock.svg":()=>V(()=>import("./unlock-CeU74z9n.58atcEuH.js"),[]),"../../assets/icons/user.svg":()=>V(()=>import("./user-B-eVXwuk.DyoYYAjs.js"),[]),"../../assets/icons/warning-circle-fill.svg":()=>V(()=>import("./warning-circle-fill-lODUKz0i.7RyGfSeR.js"),[]),"../../assets/icons/warning-circle.svg":()=>V(()=>import("./warning-circle-DDUgEDIv.1BX6MOiy.js"),[])}),`../../assets/icons/${this.name}.svg`,5).then(w=>{if(w&&w.default&&w.default._identification){const{data:x}=w.default;this._icon&&this._div.removeChild(this._icon),this._icon=Xi(x,"image/svg+xml"),this._icon&&(this._div.appendChild(this._icon),this.setSize(),this.setColor(),p())}else this.loadNs(),f(` couldn't be loaded by r-icon, message: ${this.name} icon is undefined`)}).catch(w=>{this.loadNs()})})),Oe(this,"loadNs",()=>{this._icon&&this._div&&this._div.removeChild(this._icon),this._icon=document.createElement("svg"),this._icon.setAttribute("class","icon"),this._icon.setAttribute("viewBox","0 0 1024 1024"),this._icon.setAttribute("width","100"),this._icon.setAttribute("height","100");const p=document.createElementNS(ji,"use");p.setAttributeNS(ji,Eo,`../../assets/iconfont/icon.svg#icon-${this.name}`),this._icon.appendChild(p),this._div.appendChild(this._icon)}),Oe(this,"setIcon",async()=>{this.name&&this.loadLocal()}),Oe(this,"setSize",()=>{this._icon&&this.size&&(this._icon.setAttribute("width",this.size),this._icon.setAttribute("height",this.size))}),Oe(this,"setColor",()=>{this._icon&&(this.color?this._icon.setAttribute("fill",this.color):this._icon.setAttribute("fill","currentColor"))}),Oe(this,"setSpin",()=>{this.spin&&this.style.setProperty("animation-duration",`${this.spin}s`)}),this._div=document.createElement("div"),this._div.setAttribute("class","ran-icon"),this._div.setAttribute("part","ran-icon")}static get observedAttributes(){return["name","size","color","spin"]}get name(){return this.getAttribute("name")}set name(p){p&&this.setAttribute("name",p)}get size(){return this.getAttribute("size")}set size(p){p&&this.setAttribute("size",p)}get color(){return this.getAttribute("color")}set color(p){p&&this.setAttribute("color",p)}get spin(){return this.getAttribute("spin")}set spin(p){p!=null&&this.setAttribute("spin",p)}connectedCallback(){this.appendChild(this._div),this.setIcon()}attributeChangedCallback(p,f,w){w!==f&&(p==="name"&&this.setIcon(),p==="size"&&this.setSize(),p==="color"&&this.setColor(),p==="spin"&&this.setSpin())}}customElements.define("ra-icon",k)}}const xd=kd(),Td=Object.freeze(Object.defineProperty({__proto__:null,default:xd},Symbol.toStringTag,{value:"Module"}));var Cd=Object.defineProperty,Sd=(k,h,p)=>h in k?Cd(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,Ao=(k,h,p)=>Sd(k,typeof h!="symbol"?h+"":h,p);const Ld=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}",Dd=` data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6UAAABRWlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGASSSwoyGFhYGDIzSspCnJ3UoiIjFJgf8LAwSDCIMogwMCcmFxc4BgQ4ANUwgCjUcG3awyMIPqyLsis7PPOq3QdDFcvjV3jOD1boQVTPQrgSkktTgbSf4A4LbmgqISBgTEFyFYuLykAsTuAbJEioKOA7DkgdjqEvQHEToKwj4DVhAQ5A9k3gGyB5IxEoBmML4BsnSQk8XQkNtReEOBxcfXxUQg1Mjc0dyHgXNJBSWpFCYh2zi+oLMpMzyhRcASGUqqCZ16yno6CkYGRAQMDKMwhqj/fAIcloxgHQqxAjIHBEugw5sUIsSQpBobtQPdLciLEVJYzMPBHMDBsayhILEqEO4DxG0txmrERhM29nYGBddr//5/DGRjYNRkY/l7////39v///y4Dmn+LgeHANwDrkl1AuO+pmgAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAwqADAAQAAAABAAAAwwAAAAD9b/HnAAAHlklEQVR4Ae3dP3PTWB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xDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiECRCjUbEPNCRAhZ6NSiAARCjXbUHMCRMjZqBQiQIRCzTbUnAARcjYqhQgQoVCzDTUnQIScjUohAkQo1GxDzQkQIWejUogAEQo121BzAkTI2agUIkCEQs021JwAEXI2KoUIEKFQsw01J0CEnI1KIQJEKNRsQ80JECFno1KIABEKNdtQcwJEyNmoFCJAhELNNtScABFyNiqFCBChULMNNSdAhJyNSiEC/wGgKKC4YMA4TAAAAABJRU5ErkJggg== -`;function Rd(){if(typeof window<"u"&&!customElements.get("r-img")){class k extends HTMLElement{constructor(){super(),Ao(this,"_image"),Ao(this,"_container"),this._container=document.createElement("div"),this._container.setAttribute("class","ran-image");const p=this.attachShadow({mode:"closed"}),f=document.createElement("style");f.textContent=Ld,p.appendChild(f),p.appendChild(this._container)}static get observedAttributes(){return["fallback"]}get fallback(){return this.getAttribute("fallback")||Dd}set fallback(p){p?this.setAttribute("fallback",p):this.removeAttribute("fallback")}listenFallback(p,f){p==="fallback"&&this._image&&(f?this._image.setAttribute("fallback",f):this._image.removeAttribute("fallback"))}connectedCallback(){const p=this.getAttribute("src")||"";this._image=new Image,this._image.src=p,this._image.addEventListener("error",()=>{this._image&&this.fallback&&(this._image.src=this.fallback)}),this._image.addEventListener("load",()=>{this._image&&this._container.appendChild(this._image)})}attributeChangedCallback(p,f,w){this.listenFallback(p,w)}}customElements.define("r-img",k)}}const Id=Rd(),Pd=Object.freeze(Object.defineProperty({__proto__:null,default:Id},Symbol.toStringTag,{value:"Module"}));var Od=Object.defineProperty,Md=(k,h,p)=>h in k?Od(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,He=(k,h,p)=>Md(k,typeof h!="symbol"?h+"":h,p);const Fd='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-input{position:var(--ran-input-position, relative);display:var(--ran-input-display, flex);width:var(--ran-input-width, calc(100% - 16px) );height:var(--ran-input-height, calc(100% - 4px) );min-width:0;padding:var(--ran-input-padding, 2px 8px);color:#000000d9;font-size:var(--ran-input-font-size, 12px);line-height:var(--ran-input-line-height, 1.5715);background-color:var(--ran-input-background-color, #fff);background-image:var(--ran-input-background-image, none);border:var(--ran-input-border, 1px solid #d9d9d9);border-radius:var(--ran-input-border-radius, 2px);transition:var(--ran-input-transition, all .3s)}.ran-input .ran-icon{display:var(--ran-input-icon-display, flex);align-items:var(--ran-input-icon-align-items, center);justify-content:var(--ran-input-icon-justify-content, center)}.ran-input:active{border-color:var(--ran-input-active-border-color, #40a9ff);box-shadow:var(--ran-input-active-box-shadow, 0 0 0 2px rgba(24, 144, 255, .2));border-right-width:var(--ran-input-active-border-right-width, 1px);outline:var(--ran-input-active-outline, 0)}.ran-input:hover{border-color:var(--ran-input-hover-border-color, #40a9ff);border-right-width:var(--ran-input-hover-border-right-width, 1px)}.ran-input>.ran-input-content:hover~.ran-input-label{color:var(--ran-input-label-hover-color, #40a9ff)}.ran-input[value]>.ran-input-label{transform:var(--ran-input-label-value-transform, translateY( calc(-50% - .43em) ) scale(.8));color:var(--ran-input-label-value-color, #00000040)}.ran-input[status=error]{border-color:var(--ran-input-status-error-border-color, #ff4d4f)}.ran-input[status=error]>.ran-input-content~.ran-input-label{color:var(--ran-input-label-status-error-color, #ff4d4f)}.ran-input[status=warning]{border-color:var(--ran-input-status-warning-border-color, #ff7875)}.ran-input[status=warning]>.ran-input-content~.ran-input-label{color:var(--ran-input-label-status-warning-color, #ff7875)}.ran-input[disabled]{color:var(--ran-input-disabled-color, #00000040);background-color:var(--ran-input-disabled-background-color, #f5f5f5);border-color:var(--ran-input-disabled-border-color, #d9d9d9);box-shadow:var(--ran-input-disabled-box-shadow, none);cursor:var(--ran-input-disabled-cursor, not-allowed);opacity:var(--ran-input-disabled-opacity, 1)}.ran-input[disabled]>.ran-input-content{color:var(--ran-input-content-disabled-color, #00000040);background-color:var(--ran-input-content-disabled-background-color, #f5f5f5);border-color:var(--ran-input-content-disabled-border-color, #d9d9d9);box-shadow:var(--ran-input-content-disabled-box-shadow, none);cursor:var(--ran-input-content-disabled-cursor, not-allowed);opacity:var(--ran-input-content-disabled-opacity, 1)}.ran-input[disabled]>.ran-input-content~.ran-input-label{color:var(--ran-input-label-disabled-color, #00000040);background-color:var(--ran-input-label-disabled-background-color, #f5f5f5)}.ran-input[disabled]>.ran-input-label{color:#999;border-color:var(--ran-input-label-disabled-border-color, #d9d9d9);box-shadow:var(--ran-input-label-disabled-box-shadow, none);cursor:var(--ran-input-label-disabled-cursor, not-allowed)}.ran-input-content{writing-mode:var(--ran-input-content-writing-mode, horizontal-tb);text-rendering:var(--ran-input-content-text-rendering, auto);letter-spacing:var(--ran-input-content-letter-spacing, normal);word-spacing:var(--ran-input-content-word-spacing, normal);text-transform:var(--ran-input-content-text-transform, none);text-indent:var(--ran-input-content-text-indent, 0px);text-shadow:var(--ran-input-content-text-shadow, none);text-align:var(--ran-input-content-text-align, start);cursor:var(--ran-input-content-cursor, text);touch-action:var(--ran-input-content-touch-action, manipulation);-webkit-appearance:var(--ran-input-content--webkit-appearance, none);text-overflow:var(--ran-input-content-text-overflow, ellipsis);box-sizing:var(--ran-input-content-box-sizing, border-box);margin:var(--ran-input-content-margin, 0);font-variant:var(--ran-input-content-font-variant, tabular-nums);list-style:var(--ran-input-content-list-style, none);font-feature-settings:var(--ran-input-content-font-feature-settings, "tnum");position:var(--ran-input-content-position, relative);border:var(--ran-input-content-border, none);width:var(--ran-input-content-width, 100%);min-width:var(--ran-input-content-min-width, 0);color:var(--ran-input-content-color, #000000d9);font-size:var(--ran-input-content-font-size, 14px);line-height:var(--ran-input-content-line-height, 1.48);background-color:var(--ran-input-content-background-color, #fff);background-image:var(--ran-input-content-background-image, none);transition:var(--ran-input-content-transition, all .3s);outline:var(--ran-input-content-outline, none)}.ran-input-content:focus,.ran-input-content:hover{border:var(--ran-input-content-hover-border, none);outline:var(--ran-input-content-hover-outline, 0)}.ran-input-content::placeholder{color:var(--ran-input-content-placeholder-color, #999)}.ran-input-content:placeholder-shown~.ran-input-label{transform:var(--ran-input-content-placeholder-label-transform, translateY( calc(-50% - .43em) ) scale(.8))}.ran-input-content:focus~.ran-input-label{transform:var(--ran-input-content-focus-label-transform, translateY( calc(-50% - .43em) ) scale(.8))}.ran-input-content::-webkit-search-cancel-button{display:none;-webkit-appearance:none}.ran-input-label{pointer-events:var(--ran-input-label-pointer-events, none);position:var(--ran-input-label-position, absolute);font-size:var(--ran-input-label-font-size, 14px);left:var(--ran-input-label-left, 8px);transition:var(--ran-input-label-transition, transform .3s, color .3s, background-color .3s, backdrop-filter .3s);transform-origin:var(--ran-input-label-transform-origin, left);padding:var(--ran-input-label-padding, 0 .2em);color:var(--ran-input-label-color, #999);background:var(--ran-input-label-background, #fff);opacity:var(--ran-input-label-opacity, .9)}';let fn=class extends Fe(){constructor(){super(),He(this,"_input"),He(this,"_label"),He(this,"_inputContent"),He(this,"_icon"),He(this,"customInput",f=>{f.stopPropagation(),f.preventDefault();const{target:w,data:x=""}=f;this.value=(w==null?void 0:w.value)||x||"",this.customChange(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.value}}))}),He(this,"customChange",()=>{this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value}}))}),He(this,"listenPlaceholder",(f,w)=>{f==="placeholder"&&this._inputContent&&(w!=null?this._inputContent.setAttribute("placeholder",w):this._inputContent.removeAttribute("placeholder"))}),He(this,"listenLabel",(f,w)=>{f==="label"&&this._inputContent&&(w!=null?this._label?this._label.innerHTML=w:(this._label=document.createElement("label"),this._label.innerHTML=w,this._label.setAttribute("class","ran-input-label"),this._label.setAttribute("part","ran-input-label"),this._input.appendChild(this._label)):(this._input.removeAttribute("label"),this._label&&(this._input.removeChild(this._label),this._label=void 0)))}),He(this,"listenType",(f,w)=>{f==="type"&&this._inputContent&&(w?this._inputContent.setAttribute("type",w):(this._inputContent.removeAttribute("type"),this._inputContent.removeAttribute("min"),this._inputContent.removeAttribute("max"),this._inputContent.removeAttribute("step")))}),He(this,"listenStatus",(f,w)=>{f==="status"&&this._input&&(w?this._input.setAttribute("status",w):this._input.removeAttribute("status"))}),He(this,"listenDisabled",(f,w)=>{f==="disabled"&&this._input&&(nt.includes(w)?this._input.removeAttribute("disabled"):(this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled","")))}),He(this,"listenIcon",(f,w,x)=>{f==="icon"&&w&&w!==x&&(this.removeAttribute("label"),this.setAttribute("icon",w),this.dealIcon())}),He(this,"dealIcon",()=>{if(!this._icon){this._icon=document.createElement("ra-icon");const{width:f,height:w}=this._inputContent.getBoundingClientRect(),x=Math.min(f,w);this._icon.setAttribute("size",`${x}`),this._inputContent.insertAdjacentElement("beforebegin",this._icon)}this.icon&&this._icon.setAttribute("name",this.icon)}),He(this,"listenEvent",(f,w,x)=>{this.listenPlaceholder(f,x),this.listenLabel(f,x),this.listenStatus(f,x),this.listenDisabled(f,x),this.listenIcon(f,x,w),f==="value"&&w!==x&&(this._inputContent.value=x,this._input.setAttribute("value",x))});const h=this.attachShadow({mode:"closed"}),p=document.createElement("style");p.textContent=Fd,h.appendChild(p),this._input=document.createElement("div"),this._input.setAttribute("class","ran-input"),this._input.setAttribute("part","ran-input"),this._inputContent=document.createElement("input"),this._inputContent.setAttribute("class","ran-input-content"),this._inputContent.setAttribute("part","ran-input-content"),this._input.appendChild(this._inputContent),h.appendChild(this._input)}static get observedAttributes(){return["label","disabled","name","placeholder","type","icon","value","status","prefix","suffix","allowclear","count","maxlength","showcount","onPressEnter","variant","minrows","maxrows"]}get value(){return this.getAttribute("value")||""}set value(h){!Ce(this)&&h?(this.setAttribute("value",h),this._input.setAttribute("value",h)):(this.removeAttribute("value"),this._input.removeAttribute("value"))}get placeholder(){return this.getAttribute("placeholder")||""}set placeholder(h){h?this.setAttribute("placeholder",h):this.removeAttribute("placeholder")}get required(){return this.getAttribute("required")||""}set required(h){!h||h==="false"?this.removeAttribute("required"):this.setAttribute("required","")}get disabled(){return`${Ce(this)}`}set disabled(h){nt.includes(h)?(this.removeAttribute("disabled"),this._input.removeAttribute("disabled"),this._inputContent.removeAttribute("disabled")):(this.setAttribute("disabled",""),this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled",""))}get label(){return this.getAttribute("label")||""}set label(h){this.setAttribute("label",h)}get status(){return this.getAttribute("status")||""}set status(h){h?(this.setAttribute("status",h),this._input.setAttribute("status",h)):(this.removeAttribute("status"),this._input.removeAttribute("status"))}get name(){return this.getAttribute("name")||""}set name(h){this.setAttribute("name",h)}get min(){return this.getAttribute("min")||""}set min(h){this.type==="number"&&this.setAttribute("min",h)}get max(){return this.getAttribute("max")||""}set max(h){this.type==="number"&&this.setAttribute("max",h)}get step(){return this.getAttribute("step")||""}set step(h){this.type==="number"&&this.setAttribute("step",h)}get icon(){return this.getAttribute("icon")||""}set icon(h){h?this.setAttribute("icon",h):this.removeAttribute("icon")}get prefix(){return this.getAttribute("prefix")||""}set prefix(h){h?this.setAttribute("prefix",h):this.removeAttribute("prefix")}get suffix(){return this.getAttribute("suffix")||""}set suffix(h){h?this.setAttribute("suffix",h):this.removeAttribute("suffix")}get type(){return this.getAttribute("type")||""}set type(h){h?this.setAttribute("type",h):this.removeAttribute("type")}connectedCallback(){this.value&&(this._inputContent.value=this.value,this._input.setAttribute("value",this.value)),this.status&&this._input.setAttribute("status",this.status),Ce(this)&&(this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled","")),this.type&&this._inputContent.setAttribute("type",this.type),this._inputContent.addEventListener("input",this.customInput),document.readyState==="complete"&&this.dealIcon()}disconnectCallback(){this._inputContent.removeEventListener("input",this.customInput)}attributeChangedCallback(h,p,f){this.listenEvent(h,p,f)}};function Bd(){return typeof window<"u"&&!customElements.get("r-input")?(customElements.define("r-input",fn),fn):Ie("document is undefined or r-input is exist")}const Nd=Bd(),Ud=Object.freeze(Object.defineProperty({__proto__:null,Input:fn,default:Nd},Symbol.toStringTag,{value:"Module"}));var Gd=Object.defineProperty,Hd=(k,h,p)=>h in k?Gd(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,Ct=(k,h,p)=>Hd(k,typeof h!="symbol"?h+"":h,p);const _o='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host([type="toast"]) .ran-message-notice{padding:8px;text-align:center;max-width:90%;margin:0 auto;word-break:break-all}:host([type="toast"]) .ran-message-notice-content{display:inline-block;padding:10px 16px;background:#000000b3;border-radius:7px;pointer-events:all}:host([type="toast"]) .ran-message-notice-content-info{align-items:center;display:flex}:host([type="toast"]) .ran-message-notice-content-info span{margin:0;padding:0;font-size:14px;font-variant:tabular-nums;list-style:none;font-feature-settings:"tnum";z-index:1010;width:100%;pointer-events:none;color:#fff}.ran-message-notice{padding:var(--ran-message-notice-padding, 8px);text-align:var(--ran-message-notice-text-align, center);max-width:var(--ran-message-notice-max-width, 90%);margin:var(--ran-message-notice-margin, 0 auto);word-break:var(--ran-message-notice-word-break, break-all)}.ran-message-notice-content{display:var(--ran-message-notice-content-display, inline-block);padding:var(--ran-message-notice-content-padding, 10px 16px);background:var(--ran-message-notice-content-background, #fff);border-radius:var(--ran-message-notice-content-border-radius, 8px);box-shadow:var(--ran-message-notice-content-box-shadow, 0 3px 6px -4px #0000001f, 0 6px 16px #00000014, 0 9px 28px 8px #0000000d);pointer-events:var(--ran-message-notice-content-pointer-events, all)}.ran-message-notice-content-info{align-items:var(--ran-message-notice-content-info-align-items, center);display:var(--ran-message-notice-content-info-display, flex)}.ran-message-notice-content-info span{margin:var(--ran-message-notice-content-info-span-margin, 0);padding:var(--ran-message-notice-content-info-span-padding, 0);color:var(--ran-message-notice-content-info-span-color, #000000d9);font-size:var(--ran-message-notice-content-info-span-font-size, 14px);font-variant:var(--ran-message-notice-content-info-span-font-variant, tabular-nums);list-style:var(--ran-message-notice-content-info-span-list-style, none);font-feature-settings:var(--ran-message-notice-content-info-span-font-feature-settings, "tnum");z-index:var(--ran-message-notice-content-info-span-z-index, 1010);width:var(--ran-message-notice-content-info-span-width, 100%);pointer-events:var(--ran-message-notice-content-info-span-pointer-events, none)}@keyframes rotate{to{transform:rotate(360deg)}}@keyframes MessageMoveIn{0%{padding:0;transform:translateY(-100%);opacity:0}to{padding:8px;transform:translateY(0);opacity:1}}@keyframes MessageMoveOut{0%{max-height:150px;padding:8px;opacity:1}to{max-height:0;padding:0;opacity:0}}.ranui-message{box-sizing:var(--ran-message-box-sizing, border-box);margin:var(--ran-message-margin, 0);padding:var(--ran-message-padding, 0);color:var(--ran-message-color, #000000d9);font-size:var(--ran-message-font-size, 14px);font-variant:var(--ran-message-font-variant, tabular-nums);line-height:var(--ran-message-line-height, 1.5715);list-style:var(--ran-message-ist-style, none);font-feature-settings:var(--ran-message-font-feature-settings, "tnum");position:var(--ran-message-position, fixed);top:var(--ran-message-top, 8px);left:var(--ran-message-left, 0);z-index:var(--ran-message-z-index, 1010);width:var(--ran-message-width, 100%);pointer-events:var(--ran-message-pointer-events, none)}.ranui-message .message-in{animation-name:var(--ran-message-in-animation-name, MessageMoveIn);animation-duration:var(--ran-message-in-animation-duration, .3s);animation-timing-function:var(--ran-message-in-animation-timing-function, cubic-bezier(.78, .14, .15, .86))}.ranui-message .message-leave{animation-name:var(--ran-message-leave-animation-name, MessageMoveOut);animation-duration:var(--ran-message-leave-animation-duration, .3s);animation-timing-function:var(--ran-message-leave-animation-timing-function, cubic-bezier(.78, .14, .15, .86))}',ko=300,xo=3e3,Kd=new Map([["success","check-circle-fill"],["warning","warning-circle-fill"],["error","close-circle-fill"],["info","info-circle-fill"],["toast",null]]),Vd=new Map([["success","#52c41a"],["warning","#faad14"],["error","#ff4d4f"],["info","#1890ff"],["toast","rgba(0, 0, 0, 0.7)"]]);function zd(){if(typeof window<"u"&&!customElements.get("r-message")){class k extends HTMLElement{constructor(){super(),Ct(this,"_info"),Ct(this,"_notice"),Ct(this,"_content"),Ct(this,"_icon"),Ct(this,"_span"),Ct(this,"timeId"),Ct(this,"close"),Ct(this,"setIcon",G=>{var F,q,j,de;const te=Kd.get(G),le=Vd.get(G);te&&((F=this._icon)==null||F.setAttribute("name",te),(q=this._icon)==null||q.style.setProperty("margin-right","8px"),(j=this._icon)==null||j.setAttribute("size","18"),le&&((de=this._icon)==null||de.setAttribute("color",le)))}),this._notice=document.createElement("div"),this._notice.setAttribute("class","ran-message-notice"),this._content=document.createElement("div"),this._content.setAttribute("class","ran-message-notice-content"),this._info=document.createElement("div"),this._info.setAttribute("class","ran-message-notice-content-info"),this._icon=document.createElement("r-icon"),this._span=document.createElement("span"),this._info.appendChild(this._icon),this._info.appendChild(this._span),this._content.appendChild(this._info),this._notice.appendChild(this._content);const T=this.attachShadow({mode:"closed"}),D=document.createElement("style");D.textContent=_o,T.appendChild(D),T.appendChild(this._notice)}static get observedAttributes(){return["type","content"]}get type(){return this.getAttribute("type")}set type(T){T&&this.setAttribute("type",T)}get content(){return this.getAttribute("content")}set content(T){T&&this.setAttribute("content",T)}attributeChangedCallback(T,D,G){T==="content"&&D!==G&&(this._span.textContent=G),T==="type"&&D!==G&&this.setIcon(G)}}customElements.define("r-message",k);const h=document.createElement("div"),p=z("style").setTextContent(_o),f=document.createElement("div");f.setAttribute("class","ranui-message"),document.body.appendChild(h),h.appendChild(p.element),h.appendChild(f);const w=x=>T=>{const D=new k;D.setAttribute("class","message"),D.timeId&&clearTimeout(D.timeId),D.setAttribute("type",x);let G=xo,F;if(!T)return;typeof T=="string"?D.setAttribute("content",T):(D.setAttribute("content",T.content),F=T.close,G=T.duration||xo);const q=setTimeout(()=>{D.classList.remove("message-in"),D.classList.add("message-leave"),clearTimeout(q)},G-ko);D.timeId=setTimeout(()=>{D.classList.remove("message-leave"),f.removeChild(D),F&&F()},G),f.appendChild(D),D.classList.add("message-in"),setTimeout(()=>{D.classList.remove("message-in")},ko)};return{info:w("info"),success:w("success"),error:w("error"),warning:w("warning"),toast:w("toast")}}return null}const bi=zd();typeof window<"u"&&bi&&(window.message=bi,window.ranui||(window.ranui={}),window.ranui.message=bi);const Yd=Object.freeze(Object.defineProperty({__proto__:null,default:bi},Symbol.toStringTag,{value:"Module"}));var jd=Object.defineProperty,qd=(k,h,p)=>h in k?jd(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,je=(k,h,p)=>qd(k,typeof h!="symbol"?h+"":h,p);const To='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.r-preview-slot{display:block}:host{cursor:pointer}.r-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;font-size:16px}.r-preview-mask .r-preview-options{width:100%;pointer-events:auto;display:flex;flex-flow:row-reverse nowrap;align-items:center;justify-content:space-between}.r-preview-mask .r-preview-options-close{margin:14px;border:none;cursor:pointer;transition:all .3s;-webkit-user-select:none;user-select:none}.r-preview-mask .r-preview-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items:center;overflow:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main{width:100%;height:100%;margin-bottom:10px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet{font-size:13px;line-height:normal;-webkit-user-select:none;user-select:none;-moz-user-select:none;font-family:Lato,Source Sans Pro,Roboto,Helvetica,Arial,sans-serif;box-sizing:content-box;background:#fff;-webkit-font-smoothing:antialiased}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet textarea{font:400 13px Arial,Lato,Source Sans Pro,Roboto,Helvetica,sans-serif}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-sheet{position:relative;overflow:hidden}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-table{vertical-align:bottom}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-tooltip{font-family:inherit;position:absolute;padding:5px 10px;color:#fff;border-radius:1px;background:#000;font-size:12px;z-index:201}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-tooltip:before{pointer-events:none;position:absolute;left:calc(50% - 4px);top:-4px;content:"";width:8px;height:8px;background:inherit;-webkit-transform:rotate(45deg);transform:rotate(45deg);z-index:1;box-shadow:1px 1px 3px -1px #0000004d}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette{padding:5px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette table{margin:0;padding:0;border-collapse:separate;border-spacing:2;background:#fff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette table td{margin:0;cursor:pointer;border:1px solid transparent}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette table td:hover{border-color:#ddd}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette table td .x-spreadsheet-color-palette-cell{width:16px;height:16px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette{padding:6px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette table{margin:0;padding:0;border-collapse:separate;border-spacing:0;background:#fff;table-layout:fixed}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette table td{margin:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left{border-right:1px solid #eee;padding-right:6px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell{width:30px;height:30px;cursor:pointer;text-align:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell:hover{background-color:#eee}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-right{padding-left:6px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-right .x-spreadsheet-line-type{position:relative;left:0;top:-3px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown{position:relative}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown .x-spreadsheet-dropdown-content{position:absolute;z-index:200;background:#fff;box-shadow:1px 2px 5px 2px #33333326}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown.bottom-left .x-spreadsheet-dropdown-content{top:calc(100% + 5px);left:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown.bottom-right .x-spreadsheet-dropdown-content{top:calc(100% + 5px);right:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown.top-left .x-spreadsheet-dropdown-content{bottom:calc(100% + 5px);left:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown.top-right .x-spreadsheet-dropdown-content{bottom:calc(100% + 5px);right:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown .x-spreadsheet-dropdown-title{padding:0 5px;display:inline-block}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer{position:absolute;z-index:11}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer .x-spreadsheet-resizer-hover{background-color:#4b89ff40}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer .x-spreadsheet-resizer-line{position:absolute}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer.horizontal{cursor:row-resize}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer.horizontal .x-spreadsheet-resizer-line{border-bottom:2px dashed #4b89ff;left:0;bottom:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer.vertical{cursor:col-resize}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer.vertical .x-spreadsheet-resizer-line{border-right:2px dashed #4b89ff;top:0;right:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar{position:absolute;bottom:0;right:0;background-color:#f4f5f8;opacity:.9;z-index:12}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar.horizontal{right:15px;overflow-x:scroll;overflow-y:hidden}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar.horizontal>div{height:1px;background:#ddd}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar.vertical{bottom:15px;overflow-x:hidden;overflow-y:scroll}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar.vertical>div{width:1px;background:#ddd}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-overlayer{position:absolute;left:0;top:0;z-index:10}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-overlayer .x-spreadsheet-overlayer-content{position:absolute;overflow:hidden;pointer-events:none;width:100%;height:100%}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector{box-sizing:content-box;position:absolute;overflow:hidden;pointer-events:none;top:0;left:0;width:100%;height:100%}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .hide-input{position:absolute;z-index:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .hide-input input{padding:0;width:0;border:none!important}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-area{position:absolute;border:2px solid #4b89ff;background:#4b89ff1a;z-index:5}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-clipboard,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-autofill{position:absolute;background:transparent;z-index:100}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-clipboard{border:2px dashed #4b89ff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-autofill{border:1px dashed rgba(0,0,0,.45)}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-corner{pointer-events:auto;position:absolute;cursor:crosshair;font-size:0;height:5px;width:5px;right:-5px;bottom:-5px;border:2px solid #ffffff;background:#4b89ff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor{z-index:20}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor .x-spreadsheet-editor-area{position:absolute;text-align:left;border:2px solid #4b89ff;line-height:0;z-index:100;pointer-events:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor .x-spreadsheet-editor-area textarea{box-sizing:content-box;border:none;padding:0 3px;outline:none;resize:none;text-align:start;overflow-y:hidden;font:400 13px Arial,Lato,Source Sans Pro,Roboto,Helvetica,sans-serif;color:inherit;white-space:normal;word-wrap:break-word;line-height:22px;margin:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor .x-spreadsheet-editor-area .textline{overflow:hidden;visibility:hidden;position:fixed;top:0;left:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item{-webkit-user-select:none;user-select:none;background:0;border:1px solid transparent;outline:none;height:26px;color:#000000e6;line-height:26px;list-style:none;padding:2px 10px;cursor:default;text-align:left;overflow:hidden}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.disabled{pointer-events:none;opacity:.5}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item:hover,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.active{background:#0000000d}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.divider{height:0;padding:0;margin:5px 0;border:none;border-bottom:1px solid rgba(0,0,0,.1)}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item .label{float:right;opacity:.65;font-size:1em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.state,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-header.state{padding-left:35px!important;position:relative}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.state:before,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-header.state:before{content:"";position:absolute;width:10px;height:10px;left:12px;top:calc(50% - 5px);background:#00000014;border-radius:2px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.state.checked:before,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-header.state.checked:before{background:#4b89ff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-checkbox{position:relative;display:inline-block;backface-visibility:hidden;outline:0;vertical-align:baseline;font-style:normal;font-size:1rem;line-height:1em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-checkbox>input{position:absolute;top:0;left:0;opacity:0!important;outline:0;z-index:-1}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-suggest,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-contextmenu,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-sort-filter{position:absolute;box-shadow:1px 2px 5px 2px #33333326;background:#fff;z-index:100;width:260px;pointer-events:auto;overflow:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-suggest{width:200px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-filter{border:1px solid #e9e9e9;font-size:12px;margin:10px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-filter .x-spreadsheet-header{padding:.5em .75em;background:#f8f8f9;border-bottom:1px solid #e9e9e9;border-left:1px solid transparent}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-filter .x-spreadsheet-body{height:200px;overflow-y:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-filter .x-spreadsheet-body .x-spreadsheet-item{height:20px;line-height:20px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-sort-filter .x-spreadsheet-buttons{margin:10px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-bottombar{height:40px;padding:0 30px;text-align:left;background:#f5f6f7;display:flex}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-bottombar{position:relative;border-top:1px solid #e0e2e4}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-bottombar .x-spreadsheet-menu>li{line-height:40px;height:40px;padding-top:0;padding-bottom:0;vertical-align:middle;border-right:1px solid #e8eaed}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu{list-style:none;margin:0;padding:0;-webkit-user-select:none;user-select:none}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu>li{float:left;line-height:1.25em;padding:.785em 1em;margin:0;vertical-align:middle;text-align:left;font-weight:400;color:#80868b;white-space:nowrap;cursor:pointer;transition:all .3s;font-weight:700}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu>li.active{background-color:#fff;color:#000000a6}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu>li .x-spreadsheet-dropdown{display:inline-block}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print{position:absolute;left:0;top:0;z-index:100;width:100%;height:100%;display:flex;flex-direction:column}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-bar{background:#424242;height:60px;line-height:60px;padding:0 30px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-bar .-title{color:#fff;font-weight:700;font-size:1.2em;float:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-bar .-right{float:right;margin-top:12px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-content{display:flex;flex:auto;flex-direction:row;background:#d0d0d0;height:calc(100% - 60px)}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-content .-sider{flex:0 0 300px;width:300px;border-left:2px solid #ccc;background:#fff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-content .-content{flex:auto;overflow-x:auto;overflow-y:scroll;height:100%}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-canvas-card-wraper{margin:40px 20px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-canvas-card{background:#fff;margin:auto;page-break-before:auto;page-break-after:always;box-shadow:0 8px 10px 1px #00000024,0 3px 14px 3px #0000001f,0 4px 5px #0003}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar{color:#000000a6;background:#fff;-webkit-user-select:none;user-select:none}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header{font-weight:700;line-height:30px;text-align:center;width:100%;float:left;background:#f9fafb}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header .calendar-header-left{padding-left:5px;float:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header .calendar-header-right{float:right}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header .calendar-header-right a{padding:3px 0;margin-right:2px;border-radius:2px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header .calendar-header-right a:hover{background:#00000014}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body{border-collapse:collapse;border-spacing:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body th,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td{width:14.28571429%;min-width:32px;text-align:center;font-weight:700;line-height:30px;padding:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td>.cell:hover{background:#ecf6fd}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td>.cell.active,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td>.cell.active:hover{background:#ecf6fd;color:#2185d0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td>.cell.disabled{pointer-events:none;opacity:.5}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-datepicker{box-shadow:2px 2px 5px #0003;position:absolute;left:0;top:calc(100% + 5px);z-index:10;width:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-buttons{display:flex;justify-content:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-buttons .x-spreadsheet-button{margin-left:8px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button{display:inline-block;border-radius:3px;line-height:1em;min-height:1em;white-space:nowrap;text-align:center;cursor:pointer;font-size:1em;font-weight:700;padding:.75em 1em;color:#0009;background:#e0e1e2;text-decoration:none;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;outline:none;vertical-align:baseline;zoom:1;-webkit-user-select:none;user-select:none;transition:all .1s linear}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button.active,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button:hover{background-color:#c0c1c2;color:#000c}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button.primary{color:#fff;background-color:#2185d0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button.primary:hover,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button.primary.active{color:#fff;background-color:#1678c2}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-input{font-size:1em;position:relative;font-weight:400;display:inline-flex;color:#000000de}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-input input{z-index:1;margin:0;max-width:100%;flex:1 0 auto;outline:0;-webkit-tap-highlight-color:rgba(255,255,255,0);text-align:left;line-height:30px;height:30px;padding:0 8px;background:#fff;border:1px solid #e9e9e9;border-radius:3px;transition:box-shadow .1s ease,border-color .1s ease;box-shadow:inset 0 1px 2px #0a0a0a0f}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-input input:focus{border-color:#4b89ff;box-shadow:inset 0 1px 2px #4b89ff33}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-select{position:relative;display:inline-block;background:#fff;border:1px solid #e9e9e9;border-radius:2px;cursor:pointer;color:#000000de;-webkit-user-select:none;user-select:none;box-shadow:inset 0 1px 2px #0a0a0a0f}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-select .input-text{text-overflow:ellipsis;white-space:nowrap;min-width:60px;width:auto;height:30px;line-height:30px;padding:0 8px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-fields{display:flex;flex-direction:row;flex-wrap:wrap}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-fields .x-spreadsheet-form-field{flex:0 1 auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-fields .x-spreadsheet-form-field .label{display:inline-block;margin:0 10px 0 0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field{display:block;vertical-align:middle;margin-left:10px;margin-bottom:10px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field:first-child{margin-left:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field.error .x-spreadsheet-form-select,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field.error input{border-color:#f04134}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field .tip{color:#f04134;font-size:.9em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dimmer{display:none;position:absolute;top:0!important;left:0!important;width:100%;height:100%;text-align:center;vertical-align:middle;background-color:#0009;opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:.5s;animation-duration:.5s;transition:background-color .5s linear;-webkit-user-select:none;user-select:none;z-index:1000}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dimmer.active{display:block;opacity:1}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main form fieldset{border:none}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main form fieldset label{display:block;margin-bottom:.5em;font-size:1em;color:#666}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main form fieldset select{font-size:1.1em;width:100%;background-color:#fff;border:none;border-bottom:2px solid #ddd;padding:.5em .85em;border-radius:2px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast{font-size:13px;position:fixed;z-index:1001;text-align:left;line-height:1.25em;min-width:360px;color:#000000de;font-family:Lato,Source Sans Pro,Roboto,Helvetica,Arial,sans-serif;border-radius:4px;border:1px solid rgba(0,0,0,.1);background-color:#fff;background-clip:padding-box;box-shadow:#0003 0 2px 8px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast{background-color:#ffffffd9}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal-header,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast-header{font-weight:600;background-clip:padding-box;background-color:#ffffffd9;border-bottom:1px solid rgba(0,0,0,.05);border-radius:4px 4px 0 0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast-header{color:#f2711c}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal-header{border-bottom:1px solid #e0e2e4;background:#00000014;font-size:1.0785em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal-header,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal-content,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast-header,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast-content{padding:.75em 1em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu li:first-child{display:none}.r-preview-mask .r-preview-contain .r-preview-context .docx-wrapper{background:none}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section{width:100%;height:690px;position:relative;border:1px solid #333;background-color:#efefef;text-align:center;border-radius:10px;box-shadow:1px 1px 3px #aaa;overflow:hidden}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.block{position:absolute;top:0;left:0;width:100%}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.content{display:flex;flex-direction:column}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.v-up{justify-content:flex-start}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.v-mid{justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.v-down{justify-content:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.h-left{align-items:flex-start;text-align:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.h-mid{align-items:center;text-align:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.h-right{align-items:flex-end;text-align:right}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.up-left{justify-content:flex-start;align-items:flex-start;text-align:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.up-center{justify-content:flex-start;align-items:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.up-right{justify-content:flex-start;align-items:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.center-left{justify-content:center;align-items:flex-start;text-align:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.center-center{justify-content:center;align-items:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.center-right{justify-content:center;align-items:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.down-left{justify-content:flex-end;align-items:flex-start;text-align:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.down-center{justify-content:flex-end;align-items:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.down-right{justify-content:flex-end;align-items:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main li.slide{margin:10px 0;font-size:18px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main div.footer{text-align:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section table{position:absolute}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section table,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section th,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section td{border:1px solid black}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section svg.drawing{position:absolute;overflow:visible}',$d="application/vnd.openxmlformats-officedocument.presentationml.presentation",Qd="application/pdf",Wd="application/vnd.openxmlformats-officedocument.wordprocessingml.document",Co="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",So="application/vnd.ms-excel";async function Xd(){if(typeof document<"u"&&!customElements.get("r-preview")){const{warning:k=Yo}=bi,{renderPptx:h}=await V(async()=>{const{renderPptx:q}=await import("./index-Co9E57uv.DM_Nu_-Q.js");return{renderPptx:q}},__vite__mapDeps([0,1,2])),{renderDocx:p}=await V(async()=>{const{renderDocx:q}=await import("./docx-VUApAnRr.Cl4GUa7G.js");return{renderDocx:q}},__vite__mapDeps([3,4,5])),{renderPdf:f}=await V(async()=>{const{renderPdf:q}=await import("./pdf-Cx0VWKFo.CmQSFM5C.js");return{renderPdf:q}},__vite__mapDeps([6,1])),{renderExcel:w}=await V(async()=>{const{renderExcel:q}=await import("./index-Ba501-HG.DLGTjfcz.js");return{renderExcel:q}},__vite__mapDeps([7,5,2,1])),x=(q,j)=>{if(typeof XMLHttpRequest>"u")throw new Error("XMLHttpRequest is not defined");return typeof document>"u"?Promise.reject("document is not defined"):new Promise(function(de,te){const le=new XMLHttpRequest;le.open(j.method||"GET",q,!0),le.responseType=j.responseType||"arraybuffer",le.onload=function(){if(le.status===200){const ce={success:!0,data:le.response,message:""};j.onLoad&&j.onLoad(ce),de(ce)}else{const ce={success:!1,data:le.status,message:`The request status is${le.status}`};j.onError&&j.onError(ce),te(ce)}},le.onerror=function(ce){const Pe={success:!1,data:ce,message:""};j.onError&&j.onError(Pe),te(Pe)},le.onprogress=ce=>{j.onProgress&&j.onProgress(ce)},le.withCredentials=j.withCredentials||!1,j.headers&&Object.keys(j.headers).forEach(function(ce){j!=null&&j.headers&&le.setRequestHeader(ce,j.headers[ce])}),le.send(j.body)})},T=(q,j)=>{const{dom:de,onError:te,onLoad:le}=j;return new Promise((ce,Pe)=>{const ze=new FileReader;ze.readAsArrayBuffer(q),ze.onload=()=>{var qe;if(ze.result&&de){const ei={pptx:ze.result,resultElement:de,onError:te,onLoad:le};(qe=h(ei))==null||qe.then(()=>{ce()})}},ze.onerror=qe=>{Pe(qe)},ze.onabort=qe=>{Pe(qe)}})},D=(q,j)=>{const{dom:de,onError:te,onLoad:le}=j;return Promise.resolve().then(()=>p({buffer:q,bodyContainer:de})).then(()=>{le&&le({success:!0,message:""})}).catch(ce=>{te&&te({success:!0,data:ce,message:""})})},G=new Map([[Qd,f],[$d,T],[Wd,D],[Co,w],[So,w]]);class F extends HTMLElement{constructor(){super(),je(this,"_loadingText"),je(this,"preview"),je(this,"previewContext"),je(this,"_slot"),je(this,"_div"),je(this,"_loadingElement"),je(this,"createLoading",()=>{this._loadingElement=document.createElement("div"),this._loadingElement.setAttribute("class","r-preview-loading");const te=document.createElement("r-icon");return te.setAttribute("name","loading"),te.setAttribute("size","100"),te.setAttribute("color","#1E90FF"),te.setAttribute("spin",""),this._loadingText=document.createElement("div"),this._loadingElement.appendChild(te),this._loadingText.setAttribute("class","r-preview-loading-text"),this._loadingElement.appendChild(this._loadingText),this._loadingElement}),je(this,"onProgress",te=>{const le=te.loaded/te.total*100,ce=Math.min(99,le).toFixed(2)+"%";this._loadingText&&this._loadingElement&&(this._loadingText.innerText=`Loading ${ce}`,le>=100&&setTimeout(()=>{this._loadingText.innerText="Loading..."},300))}),je(this,"onError",()=>{var te;(te=this.preview)==null||te.removeChild(this._loadingElement)}),je(this,"onLoad",()=>{var te;(te=this.preview)==null||te.removeChild(this._loadingElement)}),je(this,"handleFile",async te=>{try{if(typeof te=="string"){const{success:le,data:ce,message:Pe}=await x(te,{onProgress:this.onProgress,onError:this.onError,responseType:"blob"});if(le&&ce){te=new File([ce],ce.name,{type:ce.type});const{type:ze}=te,qe=G.get(ze);if(qe&&this.previewContext){ze===Co||ze===So?this.previewContext.style.setProperty("width","100%"):this.previewContext.style.setProperty("width","100%");const ei={dom:this.previewContext,onError:this.onError,onLoad:this.onLoad};qe(te,ei)}}else k(Pe)}}catch{}}),je(this,"closePreview",()=>{this.preview&&(document.body.removeChild(this.preview),this.preview=void 0)}),je(this,"showPreview",()=>{var te;if(this.src){if(this.preview)this.preview.style.display="block";else{this.preview=document.createElement("div"),this.preview.setAttribute("class","r-preview-mask"),this.preview.setAttribute("id","r-preview-mask");const le=document.createElement("div");if(le.setAttribute("class","r-preview-options"),this.closeable!=="false"){const Pe=document.createElement("r-icon");Pe.setAttribute("class","r-preview-options-close"),Pe.setAttribute("name","close-circle-fill"),Pe.setAttribute("size","40"),Pe.addEventListener("click",this.closePreview),le.appendChild(Pe)}const ce=document.createElement("div");ce.setAttribute("class","r-preview-contain"),this.previewContext=document.createElement("div"),this.previewContext.setAttribute("class","r-preview-context"),ce.appendChild(this.previewContext),this.preview.appendChild(le),(te=this.preview)==null||te.appendChild(ce),this._loadingElement=this.createLoading(),this.preview.appendChild(this._loadingElement),document.body.appendChild(this.preview)}this.handleFile(this.src)}}),this._div=document.createElement("div"),this.preview=document.getElementById("r-preview-mask"),this._slot=document.createElement("slot"),this._div.appendChild(this._slot),this._slot.setAttribute("class","r-preview-slot"),this._div.setAttribute("class","r-preview");const j=this.attachShadow({mode:"closed"}),de=document.createElement("style");de.textContent=To,j.appendChild(de),j.appendChild(this._div)}static get observedAttributes(){return["src","closeable"]}get label(){return this.getAttribute("label")}set label(j){j&&this.setAttribute("label",j)}get src(){return this.getAttribute("src")}set src(j){j&&this.setAttribute("src",j)}get closeable(){return this.getAttribute("closeable")}set closeable(j){j&&this.setAttribute("closeable",j)}connectedCallback(){this.preview=document.getElementById("r-preview-mask"),this.addEventListener("click",this.showPreview)}disconnectedCallback(){this.removeEventListener("click",this.showPreview)}attributeChangedCallback(j,de,te){te!==de&&j==="src"&&te&&(this.setAttribute("src",te),this.showPreview())}}if(typeof document<"u"&&!customElements.get("r-preview")){customElements.define("r-preview",F);const q=z("style").setTextContent(To);document.body.appendChild(q.element)}}}const Jd=Xd(),Zd=Object.freeze(Object.defineProperty({__proto__:null,default:Jd},Symbol.toStringTag,{value:"Module"}));var ec=Object.defineProperty,tc=(k,h,p)=>h in k?ec(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,ic=(k,h,p)=>tc(k,h+"",p);const rc='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}@keyframes skeleton{0%{transform:translate(-37.5%)}to{transform:translate(37.5%)}}.ran-skeleton{position:relative;z-index:0;overflow:hidden;background:0 0;width:100%;height:16px;background:#0000000f;border-radius:4px}.ran-skeleton:after{position:absolute;top:0;inset-inline-end:-150%;bottom:0;inset-inline-start:-150%;background:linear-gradient(90deg,#0000000f 25%,#00000026 37%,#0000000f 63%);animation-name:skeleton;animation-duration:1.4s;animation-timing-function:ease;animation-iteration-count:infinite;content:""}';function nc(){if(typeof window<"u"&&!customElements.get("r-skeleton")){class k extends HTMLElement{constructor(){super(),ic(this,"_div"),this._div=document.createElement("div"),this._div.setAttribute("class","ran-skeleton");const p=this.attachShadow({mode:"closed"}),f=document.createElement("style");f.textContent=rc,p.appendChild(f),p.appendChild(this._div)}static get observedAttributes(){return["disabled"]}connectedCallback(){}disconnectCallback(){}attributeChangedCallback(p,f,w){}}window.customElements.define("r-skeleton",k)}}const ac=nc(),oc=Object.freeze(Object.defineProperty({__proto__:null,default:ac},Symbol.toStringTag,{value:"Module"}));var sc=Object.defineProperty,lc=(k,h,p)=>h in k?sc(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,sn=(k,h,p)=>lc(k,typeof h!="symbol"?h+"":h,p);const dc=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}";function cc(){if(typeof window<"u"&&!customElements.get("r-tab")){class k extends HTMLElement{constructor(){super(),sn(this,"_div"),sn(this,"parent"),sn(this,"initAttribute",()=>{var w,x,T;this.parent=this.parentNode,this.key&&((w=this.parent)==null||w.updateAttribute(this.key,"icon",this.icon)),this.key&&((x=this.parent)==null||x.updateAttribute(this.key,"iconSize",this.iconSize)),this.key&&((T=this.parent)==null||T.updateAttribute(this.key,"effect",this.effect))}),this._div=document.createElement("slot");const p=this.attachShadow({mode:"closed"}),f=document.createElement("style");f.textContent=dc,p.appendChild(f),p.appendChild(this._div)}static get observedAttributes(){return["label","key","disabled","icon","effect","iconSize"]}get label(){return this.getAttribute("label")||""}set label(p){this.setAttribute("label",p)}get icon(){return this.getAttribute("icon")}set icon(p){!p||p==="false"?this.removeAttribute("icon"):this.setAttribute("icon",p)}get iconSize(){return this.getAttribute("iconSize")}set iconSize(p){!p||p==="false"?this.removeAttribute("iconSize"):this.setAttribute("iconSize",p)}get key(){return this.getAttribute("r-key")}set key(p){p?this.setAttribute("r-key",p):this.removeAttribute("r-key")}get disabled(){return this.getAttribute("disabled")}set disabled(p){!p||p==="false"?this.removeAttribute("disabled"):this.setAttribute("disabled",p)}get effect(){return this.getAttribute("effect")}set effect(p){!p||p==="false"?this.removeAttribute("effect"):this.setAttribute("effect",p)}onClick(p){}connectedCallback(){this._div.addEventListener("click",this.onClick),document.addEventListener("DOMContentLoaded",this.initAttribute)}disconnectCallback(){document.removeEventListener("DOMContentLoaded",this.initAttribute)}attributeChangedCallback(p,f,w){var x,T,D,G,F;f!==w&&this.key&&((x=this.parent)!=null&&x.updateAttribute)&&(p==="icon"&&((T=this.parent)==null||T.updateAttribute(this.key,"icon",w)),p==="iconSize"&&((D=this.parent)==null||D.updateAttribute(this.key,"iconSize",w)),p==="effect"&&((G=this.parent)==null||G.updateAttribute(this.key,"effect",w)),p==="disabled"&&((F=this.parent)==null||F.updateAttribute(this.key,"disabled",w)))}}return customElements.define("r-tab",k),k}}const hc=cc(),uc=Object.freeze(Object.defineProperty({__proto__:null,default:hc},Symbol.toStringTag,{value:"Module"}));var fc=Object.defineProperty,pc=(k,h,p)=>h in k?fc(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,Te=(k,h,p)=>pc(k,typeof h!="symbol"?h+"":h,p);const gc='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-tab ::slotted(r-tab){box-sizing:border-box;width:100%;height:100%;padding:10px;flex-shrink:0;overflow:auto;text-align:start}.ran-tab-header{position:relative;overflow:hidden;scroll-behavior:smooth}.ran-tab-header-nav{display:flex;flex-flow:row nowrap;justify-content:flex-start;align-items:center}.ran-tab-header-nav::-webkit-scrollbar{display:none}.ran-tab-header-nav-item{flex-shrink:0}.ran-tab-header-nav .active{color:var(--active-color, #1890ff)}.ran-tab-header-line{position:absolute;width:0;margin-top:-2px;height:2px;border-radius:2px;background:var(--line-color, #1890ff);transition:.2s}.ran-tab-content{overflow:hidden}.ran-tab-content-wrap{display:flex;width:100%;height:100%;transition:.2s}:host([type="line"]) .ran-tab-header-nav-item{border:solid 1px transparent}:host([type="line"]) .ran-tab-header-nav .active{color:var(--line-color, #1890ff);border:solid 1px transparent;border-color:var(--border-color, rgba(0, 0, 0, .2)) var(--border-color, rgba(0, 0, 0, .2)) transparent;border-radius:var(--border-radius, .25em) var(--border-radius, .25em) 0 0}:host([type="line"]) .ran-tab-header-line{transition:none;visibility:hidden}:host([type="line"]) .ran-tab-header-line:after,:host([type="line"]) .ran-tab-header-line:before{content:"";position:absolute;visibility:visible;width:9999px;height:1px;bottom:0;background:var(--border-color, rgba(0, 0, 0, .2))}:host([type="line"]) .ran-tab-header-line:after{left:100%}:host([type="line"]) .ran-tab-header-line:before{right:100%}:host([align="center"]) .ran-tab-header-nav{justify-content:center}:host([align="center"]) .ran-tab-header-line{left:50%}:host([align="end"]) .ran-tab-header-nav{justify-content:flex-end}';function mc(){if(typeof window<"u"&&!customElements.get("r-tabs")){class k extends HTMLElement{constructor(){super(),Te(this,"_container"),Te(this,"_header"),Te(this,"_nav"),Te(this,"_line"),Te(this,"_content"),Te(this,"_wrap"),Te(this,"_slot"),Te(this,"tabHeaderKeyMapIndex"),Te(this,"initTabHeaderKeyMapIndex",(w,x)=>{if(this.tabHeaderKeyMapIndex[w])throw new Error("tab 组件的 key 值存在重复,或者某个 tab 组件缺少 key 属性");this.tabHeaderKeyMapIndex[w]=x}),Te(this,"initTabLineAlignCenter",()=>{const{length:w}=this._nav.children;let x=0;for(let T=0;T{const{length:w}=this._nav.children;let x=0;for(let T=0;T{if(w){const x=this.tabHeaderKeyMapIndex[w],T=this._nav.children[x],{width:D=0}=T.getBoundingClientRect();this._line.style.setProperty("width",`${D}px`);let G=0;for(let F=0;F{if(w){const x=this.tabHeaderKeyMapIndex[w];this._wrap.style.setProperty("transform",`translateX(${x*-100}%)`)}}),Te(this,"clickTabHead",w=>{const x=w.target,T=x.getAttribute("r-key");!Ce(x)&&T&&(this.setAttribute("active",T),this.setTabLine(T),this.setTabContent(T),ud(this._nav,"active"),Re(x,"active"))}),Te(this,"updateAttribute",(w,x,T="")=>{var D,G;const F=this.tabHeaderKeyMapIndex[w];w&&T&&this._nav.children[F]?(D=this._nav.children[F])==null||D.setAttribute(x,T):(G=this._nav.children[F])==null||G.removeAttribute(x)}),Te(this,"initActive",()=>{const w=[...this._nav.children],x=w.filter(F=>!Ce(F));let T;if(this.active!=null&&(T=x.find(F=>F.getAttribute("r-key")===this.active),T==null||T.setAttribute("r-key",this.active)),T||(T=x.shift()),!T)return;const D=w.findIndex(F=>F===T),G=(T==null?void 0:T.getAttribute("r-key"))||`${D}`;G!=null&&(this.setAttribute("active",`${G}`),Re(T,"active"),this.setTabContent(G),setTimeout(()=>{this.setTabLine(G)},200))}),Te(this,"listenSlotChange",()=>{this._slot.assignedElements().forEach((x,T)=>{const D=this.createTabHeader(x,T);this._nav.appendChild(D),D.addEventListener("click",this.clickTabHead)}),this.initActive(),this.align&&(this.align==="center"&&this.initTabLineAlignCenter(),this.align==="end"&&this.initTabLineAlignEnd())}),Te(this,"initTab",()=>{this._slot.addEventListener("slotchange",this.listenSlotChange)}),Te(this,"unloadTab",()=>{this._slot.removeEventListener("slotchange",this.listenSlotChange)}),this._container=document.createElement("div"),this._container.setAttribute("class","ran-tab"),this._header=document.createElement("div"),this._header.setAttribute("class","ran-tab-header"),this._nav=document.createElement("div"),this._nav.setAttribute("class","ran-tab-header-nav"),this._line=document.createElement("div"),this._line.setAttribute("class","ran-tab-header-line"),this._content=document.createElement("div"),this._content.setAttribute("class","ran-tab-content"),this._wrap=document.createElement("div"),this._wrap.setAttribute("class","ran-tab-content-wrap"),this._slot=document.createElement("slot"),this._wrap.appendChild(this._slot),this._content.appendChild(this._wrap),this._header.appendChild(rt([this._nav,this._line])),this._container.appendChild(rt([this._header,this._content])),this.tabHeaderKeyMapIndex={};const p=this.attachShadow({mode:"closed"}),f=document.createElement("style");f.textContent=gc,p.appendChild(f),p.appendChild(this._container)}static get observedAttributes(){return["active","forceRender","type","align","effect"]}get align(){return this.getAttribute("align")||"start"}set align(p){this.setAttribute("align",p)}set type(p){this.setAttribute("type",p)}get type(){return this.getAttribute("type")||"flat"}get active(){return this.getAttribute("active")}set active(p){p?(this.setAttribute("active",p),this.setTabLine(p),this.setTabContent(p)):this.removeAttribute("active")}get effect(){return this.getAttribute("effect")}set effect(p){!p||p==="false"?this.removeAttribute("effect"):this.setAttribute("effect",p)}createTabHeader(p,f){const w=p.getAttribute("label")||"",x=p.getAttribute("icon")||"",T=p.getAttribute("iconSize")||"",D=p.getAttribute("r-key")||`${f}`,G=p.getAttribute("type")||"text";this.initTabHeaderKeyMapIndex(D,f);const F=document.createElement("r-button");return F.setAttribute("class","tab-header-nav-item"),F.setAttribute("type",G),x&&F.setAttribute("icon",x),T&&F.setAttribute("iconSize",T),Ce(p)&&F.setAttribute("disabled",""),F.setAttribute("r-key",D),this.effect&&(p.setAttribute("effect",this.effect),this._line.style.setProperty("display","none")),p.setAttribute("r-key",D),F.innerHTML=w,F}connectedCallback(){this.initTab()}disconnectCallback(){this.unloadTab()}attributeChangedCallback(p,f,w){f!==w&&(this.dispatchEvent(new CustomEvent("change",{detail:{active:this.active}})),p==="align"&&(w==="center"&&this.initTabLineAlignCenter(),w==="end"&&this.initTabLineAlignEnd()),p==="effect"&&[...this._nav.children].forEach(T=>{!this.effect||this.effect==="false"?T.removeAttribute("effect"):T.setAttribute("effect",w)}),p==="active"&&this.setAttribute(p,w))}}return customElements.define("r-tabs",k),k}}const vc=mc(),bc=Object.freeze(Object.defineProperty({__proto__:null,default:vc},Symbol.toStringTag,{value:"Module"}));var yc=Object.defineProperty,wc=(k,h,p)=>h in k?yc(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,ht=(k,h,p)=>wc(k,typeof h!="symbol"?h+"":h,p);const Ec=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-radar{position:var(--ran-radar-position, relative);width:var(--ran-radar-width, 100%);height:var(--ran-radar-height, 100%);display:var(--ran-radar-display, block)}",Ac="rgba(0,0,0,0)",_c="rgba(0,0,0,1)",Lo="#e6e6e6",Do="#e6e6e6",kc="黑体",Ro="rgba(255,121,35,0.60)",Io="rgba(255,121,35,0.60)";function xc(){if(typeof document<"u"&&!customElements.get("r-radar")){class k extends HTMLElement{constructor(){super(),ht(this,"mData"),ht(this,"mCount"),ht(this,"mW"),ht(this,"mCenter"),ht(this,"mRadius"),ht(this,"mAngle"),ht(this,"abilityRadarChartContainer"),ht(this,"abilityRadarChart"),ht(this,"_iconElement"),ht(this,"_shadowDom"),this.abilityRadarChartContainer=document.createElement("div"),this.abilityRadarChartContainer.setAttribute("class","ran-radar"),this.abilityRadarChart=document.createElement("canvas"),this.abilityRadarChart.style.setProperty("width","100%"),this.abilityRadarChart.style.setProperty("height","100%"),this.abilityRadarChartContainer.appendChild(this.abilityRadarChart);const p=this.attachShadow({mode:"closed"}),f=document.createElement("style");f.textContent=Ec,p.appendChild(f),this._shadowDom=p,p.appendChild(this.abilityRadarChartContainer)}static get observedAttributes(){return["abilitys","colorPolygon","colorLine","fillColor","strokeColor"]}get abilitys(){const p=this.getAttribute("abilitys");if(typeof p=="string")try{return JSON.parse(p)}catch{return p}return p}set abilitys(p){typeof p=="string"?this.setAttribute("abilitys",p||""):this.setAttribute("abilitys",JSON.stringify(p)||"")}get colorPolygon(){return this.getAttribute("colorPolygon")||Lo}set colorPolygon(p){this.setAttribute("colorPolygon",p||Lo)}get colorLine(){return this.getAttribute("colorLine")||Do}set colorLine(p){this.setAttribute("colorLine",p||Do)}get fillColor(){return this.getAttribute("fillColor")||Ro}set fillColor(p){this.setAttribute("fillColor",p||Ro)}get strokeColor(){return this.getAttribute("strokeColor")||Io}set strokeColor(p){this.setAttribute("strokeColor",p||Io)}refreshData(){var p;const f=this.abilityRadarChart.getContext("2d");if(!this.abilityRadarChartContainer||!f)return;const w=Zt(f),x=this.abilityRadarChartContainer.clientWidth*w,T=this.abilityRadarChartContainer.clientHeight*w;this.abilityRadarChart.width=x,this.abilityRadarChart.height=T,this.mW=x,this.mData=this.abilitys,this.mCount=((p=this.mData)==null?void 0:p.length)||1,this.mCenter=this.mW/2,this.mRadius=this.mCenter-50*w,this.mAngle=Math.PI*2/this.mCount,this.drawPolygon(f),this.drawSide(f),this.drawLines(f),this.drawText(f),this.drawRegion(f),this.drawCircle(f)}drawSide(p){if(!this.mRadius||!this.mCount||!this.mCenter||!this.mAngle)return;p.save(),p.strokeStyle=this.colorLine;const f=this.mRadius;for(let w=0;w=0&&this.mAngle*F=Math.PI/2&&this.mAngle*F=Math.PI&&this.mAngle*Fh in k?Sc(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,St=(k,h,p)=>Lc(k,typeof h!="symbol"?h+"":h,p);const Dc='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}@keyframes ranui-dropdown-down-in{0%{transform:scaleY(.8);transform-origin:100% 100%;opacity:0}to{transform:scaleY(1);transform-origin:100% 100%;opacity:1}}@keyframes ranui-dropdown-down-out{0%{transform:scaleY(1);transform-origin:100% 100%;opacity:1}to{transform:scaleY(.8);transform-origin:100% 100%;opacity:0}}@keyframes ranui-dropdown-up-in{0%{transform:scaleY(.8);transform-origin:0% 0%;opacity:0}to{transform:scaleY(1);transform-origin:0% 0%;opacity:1}}@keyframes ranui-dropdown-up-out{0%{transform:scaleY(1);transform-origin:0% 0%;opacity:1}to{transform:scaleY(.8);transform-origin:0% 0%;opacity:0}}.ran-dropdown-down-in{animation:ranui-dropdown-up-in .2s;animation-fill-mode:forwards}.ran-dropdown-down-out{animation:ranui-dropdown-up-out .2s;animation-fill-mode:forwards}.ran-dropdown-up-in{animation:ranui-dropdown-down-in .2s;animation-fill-mode:forwards}.ran-dropdown-up-out{animation:ranui-dropdown-down-out .2s;animation-fill-mode:forwards}:host{text-align:var(--ran-dropdown-host-text-align, left);z-index:10}.ranui-dropdown{transform-origin:var(--ran-x, 50%) var(--ran-y, 50%);box-sizing:var(--ran-dropdown-box-sizing, border-box);margin:var(--ran-dropdown-margin, 0);padding:var(--ran-dropdown-padding, 4px);color:var(--ran-dropdown-color, rgba(0, 0, 0, .88));font-size:var(--ran-dropdown-font-size, 14px);list-style:var(--ran-dropdown-list-style, none);font-family:var(--ran-dropdown-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");z-index:var(--ran-dropdown-z-index, 1050);overflow:var(--ran-dropdown-overflow, hidden);font-variant:var(--ran-dropdown-font-variant, initial);background:var(--ran-dropdown-background, #ffffff);border-radius:var(--ran-dropdown-border-radius, 8px);outline:var(--ran-dropdown-outline, none);box-shadow:var(--ran-dropdown-box-shadow, 0 6px 16px 0 rgba(0, 0, 0, .08), 0 3px 6px -4px rgba(0, 0, 0, .12), 0 9px 28px 8px rgba(0, 0, 0, .05));cursor:var(--ran-dropdown-cursor, pointer);width:var(--ran-dropdown-width, 100%)}.ranui-dropdown-container{position:var(--ran-dropdown-container-position, relative);display:var(--ran-dropdown-container-display, inline-block);width:var(--ran-dropdown-container-width, 100%);min-width:var(--ran-popover-width)}.ranui-dropdown-container .top{transform:translate(calc(var(--ran-popover-width) / 2 - 8px)) translateY(-16px) rotate(0);top:0}.ranui-dropdown-container .bottom{transform:translate(calc(var(--ran-popover-width) / 2 - 8px)) translateY(0) rotate(180deg);top:calc(var(--ran-popover-height) - 4px,0px)}.ranui-dropdown-arrow{position:var(--ran-dropdown-arrow-position, absolute);z-index:var(--ran-dropdown-arrow-z-index, 1);display:var(--ran-dropdown-arrow-display, block);pointer-events:var(--ran-dropdown-arrow-pointer-events, none);width:var(--ran-dropdown-arrow-width, 16px);height:var(--ran-dropdown-arrow-height, 16px);overflow:var(--ran-dropdown-arrow-overflow, hidden)}.ranui-dropdown-arrow:before{background:var(--ran-dropdown-arrow-before-background, #fff);position:var(--ran-dropdown-arrow-before-position, absolute);bottom:var(--ran-dropdown-arrow-before-bottom, 0);inset-inline-start:0;width:var(--ran-dropdown-arrow-before-width, 16px);height:var(--ran-dropdown-arrow-before-height, 8px );clip-path:path("M 0 8 A 4 4 0 0 0 2.82842712474619 6.82842712474619 L 6.585786437626905 3.0710678118654755 A 2 2 0 0 1 9.414213562373096 3.0710678118654755 L 13.17157287525381 6.82842712474619 A 4 4 0 0 0 16 8 Z");content:var(--ran-dropdown-arrow-before-content, "")}.ranui-dropdown-arrow:after{content:var(--ran-dropdown-arrow-after-content, "");position:var(--ran-dropdown-arrow-after-position, absolute);width:var(--ran-dropdown-arrow-after-width, 9px);height:var(--ran-dropdown-arrow-after-height, 9px);bottom:var(--ran-dropdown-arrow-after-bottom, 0);inset-inline:0;margin:var(--ran-dropdown-arrow-after-margin, auto);border-radius:var(--ran-dropdown-arrow-after-border-radius, 0 0 2px 0);transform:var(--ran-dropdown-arrow-after-transform, translateY(50%) rotate(-135deg));box-shadow:var(--ran-dropdown-arrow-after-box-shadow, 2px 2px 5px rgba(0, 0, 0, .05));z-index:var(--ran-dropdown-arrow-after-z-index, 0);background:var(--ran-dropdown-arrow-after-background, transparent)}',Po=300;class Oo extends Fe(){constructor(){super(),St(this,"dropdown"),St(this,"_slot"),St(this,"_shadowDom"),St(this,"arrowIcon"),St(this,"container"),St(this,"handlerTransit",()=>{this.transit&&(Re(this.dropdown.element,this.transit),setTimeout(()=>{Ve(this.dropdown.element,this.transit)},Po))}),St(this,"handlerArrow",()=>{this.arrow&&(this.arrowIcon||(this.arrowIcon=z("div").setAttribute("class",`ranui-dropdown-arrow ${this.arrow}`),this.container.addChild([this.arrowIcon])))}),St(this,"stopPropagation",f=>{f.stopPropagation()}),this._slot=z("slot").setAttribute("class","slot"),this.dropdown=z("div").setStyle("-webkit-tap-highlight-color","transparent").setStyle("outline","0").setAttribute("class","ranui-dropdown").setAttribute("part","ranui-dropdown").addChild([this._slot]),this.container=z("div").setAttribute("class","ranui-dropdown-container").addChild([this.dropdown]);const h=this.attachShadow({mode:"closed"}),p=document.createElement("style");p.textContent=Dc,h.appendChild(p),this._shadowDom=h,h.appendChild(this.container.element)}static get observedAttributes(){return["transit","arrow"]}get transit(){return this.getAttribute("transit")||""}set transit(h){h?this.setAttribute("transit",h):this.removeAttribute("transit")}get arrow(){return this.getAttribute("arrow")||""}set arrow(h){h?this.setAttribute("arrow",h):this.removeAttribute("arrow")}get show(){return this.getAttribute("show")||""}set show(h){h?this.setAttribute("show",h):this.removeAttribute("show")}connectedCallback(){this.handlerTransit(),this.handlerArrow()}disconnectedCallback(){}attributeChangedCallback(h,p,f){h==="transit"&&f&&(Re(this.dropdown.element,this.transit),setTimeout(()=>{Ve(this.dropdown.element,this.transit)},Po)),h==="arrow"&&this.handlerArrow()}}function Rc(){return typeof document<"u"&&!customElements.get("r-dropdown")?(customElements.define("r-dropdown",Oo),Oo):Ie("document is undefined or r-dropdown is exist")}Rc();var Ic=Object.defineProperty,Pc=(k,h,p)=>h in k?Ic(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,se=(k,h,p)=>Pc(k,typeof h!="symbol"?h+"":h,p);const Oc='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}r-select{position:var(--ran-select, relative);width:var(--ran-select, 120px);height:var(--ran-select, 40px)}:host{position:var(--ran-select-host, relative);display:var(--ran-select-host, inline-block);cursor:var(--ran-select-host, pointer);height:var(--ran-select-host, 32px);outline:var(--ran-select-host, 0);-webkit-tap-highlight-color:var(--ran-select-host-highlight-color, transparent)}:host,:host(:focus),:host(:active){outline:var(--ran-select-host-focus-outline, 0);-webkit-tap-highlight-color:transparent}:host ::slotted(r-option){display:none}:host([disabled]){cursor:var(--ran-select-host-disabled-cursor, not-allowed);pointer-events:var(--ran-select-host-disabled-pointer-events, all);opacity:var(--ran-select-host-disabled-opacity, .6)}:host([type="text"])::part(selection){border:none}:host([type="text"])::part(icon){display:none}:host(:not([disabled]):hover) .select{cursor:var(--ran-select-host-hover-cursor, pointer)}:host(:not([disabled]):hover) .selection{border:var(--ran-select-host-selection-border, 1px solid #1890ff)}:host(:not([disabled]):hover) .selection-search{cursor:var(--ran-select-host-selection-search-cursor, pointer)}:host(:not([disabled]):hover) .selection-item{cursor:var(--ran-select-host-selection-item-cursor, pointer);color:var(--ran-select-host-selection-item-color, #bfbfbf)}:host(:not([disabled]):focus) .selection{border:var(--ran-select-host-selection-focus-border, 1px solid #1890ff)}:host(:not([disabled]):focus) .selection-search{cursor:var(--ran-select-host-selection-focus-search-cursor, pointer)}:host(:not([disabled]):focus) .selection-item{cursor:var(--ran-select-host-selection-focus-item-cursor, pointer);color:var(--ran-select-host-selection-focus-item-color, #bfbfbf)}:host .selection-search{display:var(--ran-select-host-selection-search-display, none)}:host([showSearch]:not([disabled])) .selection-search{cursor:var(--ran-select-host-showSearch-selection-search-cursor, text);display:var(--ran-select-host-showSearch-selection-search-display, block)}:host([showSearch]:not([disabled])) .selection-item{cursor:var(--ran-select-host-showSearch-selection-item-cursor, pointer)}:host([showSearch]:not([disabled]):focus) .selection-search{display:var(--ran-select-host-showSearch-selection-search-display, block);cursor:var(--ran-select-host-showSearch-selection-search-cursor, text);opacity:var(--ran-select-host-showSearch-selection-search-opacity, 1)}.ran-select{width:var(--ran-select-width, 100%);height:var(--ran-select-width, 100%);font-size:var(--ran-select-font-size, 14px);box-sizing:var(--ran-select-box-sizing, border-box);margin:var(--ran-select-margin, 0);padding:var(--ran-select-padding, 0);color:var(--ran-select-color, rgba(0, 0, 0, .88));line-height:var(--ran-select-line-height, 1.57142857);list-style:var(--ran-select-list-style, none);font-family:var(--ran-select-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");position:var(--ran-select-position, relative);display:var(--ran-select-display, inline-block)}.ran-select .selection{position:var(--ran-select-selection-position, relative);background-color:var(--ran-select-selection-background-color, #ffffff);border:var(--ran-select-selection-border, 1px solid #d9d9d9);transition:var(--ran-select-selection-transition, all .2s cubic-bezier(.645, .045, .355, 1));width:var(--ran-select-selection-width, 100%);height:var(--ran-select-selection-height, 100%);padding:var(--ran-select-selection-padding, 0 11px);box-sizing:var(--ran-select-selection-box-sizing, border-box);margin:var(--ran-select-selection-margin, 0);color:var(--ran-select-selection-color, rgba(0, 0, 0, .88));font-size:var(--ran-select-selection-font-size, 14px);line-height:var(--ran-select-selection-line-height, 1.57142857);list-style:var(--ran-select-selection-list-style, none);font-family:var(--ran-select-selection-font-family, inherit);display:var(--ran-select-selection-display, flex);border-radius:var(--ran-select-selection-border-radius, 6px)}.ran-select .selection-search{position:var(--ran-select-selection-search-position, absolute);opacity:var(--ran-select-selection-search-opacity, 0);top:var(--ran-select-selection-search-top, 0);left:var(--ran-select-selection-search-left, 0);height:var(--ran-select-selection-search-height, 100%);inset-inline-start:var(--ran-select-selection-search-inset-inline-start, 11px);inset-inline-end:var(--ran-select-selection-search-inset-inline-end, 11px);margin:var(--ran-select-selection-search-margin, 0);padding:var(--ran-select-selection-search-padding, 0);background:var(--ran-select-selection-search-background, transparent);border:var(--ran-select-selection-search-border, none);outline:var(--ran-select-selection-search-outline, none);-webkit-appearance:var(--ran-select-selection-search-appearance, none);-moz-appearance:var(--ran-select-selection-search-appearance, none);appearance:var(--ran-select-selection-search-appearance, none);font-family:var(--ran-select-selection-search-font-family, inherit);cursor:var(--ran-select-selection-search-cursor, not-allowed)}.ran-select .selection-search::-webkit-search-cancel-button{display:none;-webkit-appearance:none}.ran-select .selection-search::part(ran-input){border:none;padding:0;height:100%;outline:none}.ran-select .selection-search::part(ran-input):active{border:none;padding:0;height:100%;outline:none;border-color:transparent;box-shadow:none;border-right-width:0px}.ran-select .selection-item{position:var(--ran-select-selection-item-position, absolute);top:var(--ran-select-selection-item-top, 0);left:var(--ran-select-selection-item-left, 12px);margin:var(--ran-select-selection-item-margin, 0);padding:var(--ran-select-selection-item-padding, 0);background:var(--ran-select-selection-item-background, transparent);border:var(--ran-select-selection-item-border, none);outline:var(--ran-select-selection-item-outline, none);-webkit-appearance:var(--ran-select-selection-item-appearance, none);-moz-appearance:var(--ran-select-selection-item-appearance, none);appearance:var(--ran-select-selection-item-appearance, none);font-family:var(--ran-select-selection-item-font-family, inherit);height:var(--ran-select-selection-item-height, 100%);-webkit-user-select:var(--ran-select-selection-item-user-select, none);user-select:var(--ran-select-selection-item-user-select, none);overflow:var(--ran-select-selection-item-overflow, hidden);white-space:var(--ran-select-selection-item-white-space, nowrap);text-overflow:var(--ran-select-selection-item-text-overflow, ellipsis);cursor:var(--ran-select-selection-item-cursor, pointer)}.ran-select .selection-select{color:var(--ran-select-selection-select-color, rgba(0, 0, 0, .25))}.ran-select .selection .icon{display:var(--ran-select-selection-icon-display, flex);align-items:var(--ran-select-selection-icon-align-items, center);color:var(--ran-select-selection-icon-color, rgba(0, 0, 0, .25));font-style:var(--ran-select-selection-icon-font-style, normal);text-align:var(--ran-select-selection-icon-text-align, center);text-transform:var(--ran-select-selection-icon-text-transform, none);text-rendering:var(--ran-select-selection-icon-text-rendering, optimizeLegibility);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;position:var(--ran-select-selection-icon-position, absolute);top:var(--ran-select-selection-icon-top, 50%);inset-inline-start:var(--ran-select-selection-icon-inset-inline-start, auto);inset-inline-end:var(--ran-select-selection-icon-inset-inline-end, 8px);height:var(--ran-select-selection-icon-height, 12px);margin-top:var(--ran-select-selection-icon-margin-top, -3px);font-size:var(--ran-select-selection-icon-font-size, 12px);pointer-events:var(--ran-select-selection-icon-color, pointer-events)}';function Mc(){if(typeof document<"u"&&!customElements.get("r-option")){class k extends HTMLElement{constructor(){super(),se(this,"_option"),se(this,"_optionContent"),se(this,"_shadowDom"),se(this,"_slot"),this._slot=document.createElement("slot"),this._option=document.createElement("div"),this._option.setAttribute("class","ran-option"),this._optionContent=document.createElement("div"),this._optionContent.setAttribute("class","ran-option-content"),this._optionContent.appendChild(this._slot),this._option.appendChild(this._optionContent);const p=this.attachShadow({mode:"closed"});this._shadowDom=p,p.appendChild(this._option)}static get observedAttributes(){return["disabled","sheet","value"]}get value(){return this.getAttribute("value")}set value(p){this.setAttribute("value",p||"")}get sheet(){return this.getAttribute("sheet")}set sheet(p){this.setAttribute("sheet",p||"")}get disabled(){return Ce(this)}set disabled(p){!p||p==="false"?this.removeAttribute("disabled"):this.setAttribute("disabled","")}handlerExternalCss(){if(this.sheet)try{const p=new CSSStyleSheet;p.insertRule(this.sheet),this._shadowDom.adoptedStyleSheets=[p]}catch{console.error(`Failed to parse the rule in CSSStyleSheet: ${this.sheet}`)}}connectedCallback(){}disconnectCallback(){}attributeChangedCallback(p,f,w){p==="disabled"&&this._option&&(!w||w==="false"?this._option.setAttribute("disabled",""):this._option.removeAttribute("disabled")),p==="sheet"&&this._shadowDom&&f!==w&&this.handlerExternalCss()}}return k}else return Ie("document is undefined or r-option is exist")}Mc();const Fc='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ranui-dropdown-option-item{position:var(--ran-dropdown-option-item-position, relative);display:var(--ran-dropdown-option-item-display, block);padding:var(--ran-dropdown-option-item-padding, 5px 12px);color:var(--ran-dropdown-option-item-color, rgba(0, 0, 0, .88));font-weight:var(--ran-dropdown-option-item-font-weight, normal);font-size:var(--ran-dropdown-option-item-font-size, 14px);transition:var(--ran-dropdown-option-item-transition, background .3s ease);border-radius:var(--ran-dropdown-option-item-border-radius, 4px)}.ranui-dropdown-option-item:hover{background-color:var(--ran-dropdown-option-item-hover-background-color, rgba(0, 0, 0, .04))}.ranui-dropdown-option-item-content{text-align:var(--ran-dropdown-content-text-align, left);overflow:var(--ran-dropdown-content-overflow, hidden);white-space:var(--ran-dropdown-content-white-space, nowrap);text-overflow:var(--ran-dropdown-content-text-overflow, ellipsis);color:var(--ran-dropdown-content-color, rgba(0, 0, 0, .88));font-size:var(--ran-dropdown-content-font-size, 14px);line-height:var(--ran-dropdown-content-line-height, 1.57142857);box-sizing:var(--ran-dropdown-content-box-sizing, border-box);list-style:var(--ran-dropdown-content-list-style, none);font-family:var(--ran-dropdown-content-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-variant:var(--ran-dropdown-content-font-variant, initial)}.ranui-dropdown-option-active{background-color:var(--ran-dropdown-option-active-background-color, #e6f7ff);font-weight:var(--ran-dropdown-option-active-font-weight, bold)}.ranui-dropdown-option-active:hover{background-color:var(--ran-dropdown-option-active-hover-background-color, #e6f7ff)}';class Mo extends Fe(){constructor(){super(),se(this,"ionDropdownItem"),se(this,"_slot"),se(this,"_shadowDom"),se(this,"ionDropdownItemContent"),this._slot=z("slot").setAttribute("class","slot"),this.ionDropdownItemContent=z("div").setAttribute("class","ranui-dropdown-option-item-content").setAttribute("part","ranui-dropdown-option-item-content").addChild(this._slot),this.ionDropdownItem=z("div").setAttribute("class","ranui-dropdown-option-item").setAttribute("part","ranui-dropdown-option-item").addChild([this.ionDropdownItemContent]);const h=this.attachShadow({mode:"closed"});this._shadowDom=h;const p=z("style").setTextContent(Fc);h.appendChild(p.element),h.appendChild(this.ionDropdownItem.element)}static get observedAttributes(){return["active","value","title"]}get value(){return this.getAttribute("value")||""}set value(h){!Ce(this)&&h?this.setAttribute("value",h):this.removeAttribute("value")}get active(){return this.getAttribute("active")||""}set active(h){h?this.setAttribute("active",h):this.removeAttribute("active")}get title(){return this.getAttribute("title")||""}set title(h){h?this.setAttribute("title",h):this.removeAttribute("title")}connectedCallback(){this.active&&Re(this.ionDropdownItem.element,"ranui-dropdown-option-active")}attributeChangedCallback(h,p,f){h==="active"&&f?Re(this.ionDropdownItem.element,"ranui-dropdown-option-active"):Ve(this.ionDropdownItem.element,"ranui-dropdown-option-active")}}function Bc(){return typeof document<"u"&&!customElements.get("r-dropdown-item")?(customElements.define("r-dropdown-item",Mo),Mo):Ie("document is undefined or r-dropdown-item is exist")}Bc();const Fo={bottom:{add:"ran-dropdown-down-in",remove:"ran-dropdown-down-out"},top:{add:"ran-dropdown-up-in",remove:"ran-dropdown-up-out"}},Nc=Zi(),Bo=300;let pn=class extends Fe(){constructor(){super(),se(this,"removeTimeId"),se(this,"_slot"),se(this,"_shadowDom"),se(this,"_select"),se(this,"_selection"),se(this,"_search"),se(this,"_icon"),se(this,"_selectDropdown"),se(this,"_selectionDropdown"),se(this,"_selectDropDownInTimeId"),se(this,"_selectDropDownOutTimeId"),se(this,"_optionList"),se(this,"_optionLabelMapValue"),se(this,"_optionValueMapLabel"),se(this,"_activeOption"),se(this,"_text"),se(this,"_selector"),se(this,"onSearch"),se(this,"setSelectDropdownDisplayNone",()=>{this._selectDropDownOutTimeId||this._selectionDropdown&&this._selectionDropdown.style.display!=="none"&&(this._selectionDropdown.setAttribute("transit",Fo[this.placement].remove),this._selectDropDownOutTimeId=setTimeout(()=>{var f;(f=this._selectionDropdown)==null||f.style.setProperty("display","none"),this._selectionDropdown&&this._selectionDropdown.removeAttribute("transit"),clearTimeout(this._selectDropDownOutTimeId),this._selectDropDownOutTimeId=void 0},Bo))}),se(this,"setSelectDropdownDisplayBlock",()=>{var f;this._selectDropDownInTimeId||this._selectionDropdown&&this._selectionDropdown.style.display!=="block"&&(this._selectionDropdown.setAttribute("transit",Fo[this.placement].add),(f=this._selectionDropdown)==null||f.style.setProperty("display","block"),this._selectDropDownInTimeId=setTimeout(()=>{this._selectionDropdown&&this._selectionDropdown.removeAttribute("transit"),clearTimeout(this._selectDropDownInTimeId),this._selectDropDownInTimeId=void 0},Bo))}),se(this,"placementPosition",()=>{if(!this._selectionDropdown||!this._selectDropdown)return;const f=this.getBoundingClientRect(),{top:w,left:x,bottom:T,width:D,height:G,x:F,y:q,right:j}=f,de=document.getElementById(this.getPopupContainerId);this._selectionDropdown.style.setProperty("position","absolute"),this._selectionDropdown.style.setProperty("--ran-x",`${w+window.scrollX}`),this._selectionDropdown.style.setProperty("--ran-y",`${x+window.scrollY}`);let te=T+window.scrollY,le=x+window.scrollX;if(this._selectionDropdown.style.setProperty("width",`${D}px`),this.placement==="top"&&(te=w+window.scrollY-this._selectionDropdown.clientHeight),this.getPopupContainerId&&de){const ce=de.getBoundingClientRect();le=x-ce.left,this.placement==="top"?te=w-de.getBoundingClientRect().top-this._selectionDropdown.clientHeight:te=de.getBoundingClientRect().height}this._selectionDropdown.style.setProperty("inset",`${te}px auto auto ${le}px`)}),se(this,"selectMouseDown",f=>{f.stopPropagation(),!Ce(this)&&(this.removeDropDownTimeId(f),this.setSelectDropdownDisplayNone(),this.setSelectDropdownDisplayBlock(),this.placementPosition())}),se(this,"removeDropDownTimeId",f=>{f.stopPropagation(),this._search.setAttribute("value",""),this.trigger.includes("hover")&&!_t()&&(clearTimeout(this.removeTimeId),this.removeTimeId=void 0)}),se(this,"selectBlur",f=>{f.stopPropagation(),this.removeTimeId&&this.removeDropDownTimeId(f),this.removeTimeId=setTimeout(()=>{this.removeDropDownTimeId(f),this.setSelectDropdownDisplayNone()},300)}),se(this,"clickOption",f=>{f.stopPropagation();const w=f.target,x=w.innerHTML,T=this._optionLabelMapValue.get(x);T&&(this.setAttribute("value",T),this._text.innerHTML=x,this._text.setAttribute("title",x),this._search.setAttribute("placeholder",x));const D=this.getBoundingClientRect(),{height:G}=D;this._text.style.setProperty("line-height",`${G}px`),this._activeOption&&this._activeOption.removeAttribute("active"),this._activeOption=w,this._activeOption&&this._activeOption.setAttribute("active",T||""),this.setSelectDropdownDisplayNone(),this.dispatchEvent(new CustomEvent("change",{detail:{value:T,label:x}})),this.removeDropDownTimeId(f)}),se(this,"createOption",()=>{if(!this._selectDropdown){const f=document.getElementById(this.getPopupContainerId)||document.body;this._selectDropdown=document.createElement("div"),this._selectDropdown.style.setProperty("-webkit-tap-highlight-color","transparent"),this._selectDropdown.style.setProperty("outline","0"),this._selectDropdown.addEventListener("click",this.clickOption),this._selectionDropdown=document.createElement("r-dropdown"),this.dropdownclass&&this._selectionDropdown.setAttribute("class",this.dropdownclass),this.trigger.includes("hover")&&!_t()&&(this._selectDropdown.addEventListener("mouseleave",this.selectBlur),this._selectDropdown.addEventListener("mouseenter",this.removeDropDownTimeId)),this._selectDropdown.appendChild(this._selectionDropdown),this._selectionDropdown.style.setProperty("display","none"),f.appendChild(this._selectDropdown)}}),se(this,"removeSelectDropdown",()=>{try{this._selectDropdown&&(document.getElementById(this.getPopupContainerId)||document.body).removeChild(this._selectDropdown)}catch{}}),se(this,"addOptionToSlot",()=>{this._slot.assignedElements().forEach(w=>{var x;if(w.tagName!=="R-OPTION")return;const T=w.innerHTML,D=w.getAttribute("value")||"";(x=this._optionList)==null||x.push({label:T,value:D}),this._optionLabelMapValue.get(T)&&console.warn(`${T} is repeat option`),this._optionValueMapLabel.get(D)&&console.warn(`${D} is repeat option`),this._optionLabelMapValue.set(T,D),this._optionValueMapLabel.set(D,T)}),this.createSelectDropdownContent(this._optionList)}),se(this,"createSelectDropdownContent",(f=[])=>{var w,x;f.length===0?(w=this._selectDropdown)==null||w.style.setProperty("display","none"):(x=this._selectDropdown)==null||x.style.setProperty("display","block"),f.forEach(T=>{if(this._selectionDropdown){const{label:D,value:G}=T,F=document.createElement("r-dropdown-item");(this.getAttribute("defaultValue")||this.getAttribute("value"))===G?(F.setAttribute("active",G),this._activeOption=F):F.removeAttribute("active"),F.innerHTML=`${D}`,F.setAttribute("value",`${G}`),F.setAttribute("title",`${D}`),this._selectionDropdown.appendChild(F)}}),this.setDefaultValue()}),se(this,"setDefaultValue",()=>{const f=this.getAttribute("defaultValue")||this.getAttribute("value");if(!f)return;const w=this._optionValueMapLabel.get(f);if(!w)return;this.setAttribute("value",f);const x=this.getBoundingClientRect(),{height:T}=x;this._text.style.setProperty("line-height",`${T}px`),this._text.innerHTML=w,this._text.setAttribute("title",w)}),se(this,"changeSearch",f=>{const w=f.detail.value||"";if(this.dispatchEvent(new CustomEvent("search",{detail:{value:w}})),this._selectionDropdown&&(this._selectionDropdown.innerHTML=""),w.length>0){const x=this._optionList.map(T=>{const{label:D}=T;if(`${D}`.toLowerCase().includes(w))return{label:D,value:T.value}}).filter(T=>T);this.createSelectDropdownContent(x)}else this.createSelectDropdownContent(this._optionList)}),se(this,"setShowSearch",()=>{this.onSearch=Nc(this.changeSearch),this.onSearch&&this._search.addEventListener("change",this.onSearch),this.onSearch&&this._search.addEventListener("click",this.onSearch)}),se(this,"removeShowSearch",()=>{this.onSearch&&this._search.removeEventListener("change",this.onSearch),this.onSearch&&this._search.removeEventListener("click",this.onSearch)}),se(this,"listenSlotChange",()=>{this._slot.addEventListener("slotchange",this.addOptionToSlot)}),se(this,"removeListenSlotChange",()=>{this._slot.removeEventListener("slotchange",this.addOptionToSlot)}),se(this,"listenActionEvent",()=>{this.removeEventListener("mouseenter",this.selectMouseDown),this.removeEventListener("mouseleave",this.selectBlur),this.removeEventListener("click",this.selectMouseDown),this.removeEventListener("blur",this.selectBlur),this.trigger.includes("hover")&&!_t()&&(this.addEventListener("mouseenter",this.selectMouseDown),this.addEventListener("mouseleave",this.selectBlur)),this.trigger.includes("click")&&(this.addEventListener("click",this.selectMouseDown),this.addEventListener("blur",this.selectBlur))}),se(this,"clickRemoveSelect",f=>{f.stopPropagation(),this.setSelectDropdownDisplayNone()}),this._slot=document.createElement("slot"),this._select=document.createElement("div"),this._select.setAttribute("class","ran-select"),this._select.setAttribute("part","select"),this._selection=document.createElement("div"),this._selection.setAttribute("class","selection"),this._selection.setAttribute("part","selection"),this._selector=document.createElement("div"),this._search=document.createElement("r-input"),this._search.setAttribute("class","selection-search"),this._search.setAttribute("part","search"),this._search.setAttribute("type","search"),this._search.setAttribute("autocomplete","off"),this._text=document.createElement("span"),this._text.setAttribute("class","selection-item"),this._text.setAttribute("part","selection-item"),this._icon=document.createElement("ra-icon"),this._icon.setAttribute("class","icon"),this._icon.setAttribute("part","icon"),this._icon.setAttribute("name","arrow-down"),this._icon.setAttribute("color","#d9d9d9"),this._icon.setAttribute("size","16"),this._selector.appendChild(this._text),this._selector.appendChild(this._search),this._selection.appendChild(this._icon),this._selection.appendChild(this._selector),this._slot.setAttribute("class","slot"),this._select.appendChild(this._selection),this._select.appendChild(this._slot),this._optionList=[],this._optionLabelMapValue=new Map,this._optionValueMapLabel=new Map;const h=this.attachShadow({mode:"closed"}),p=document.createElement("style");p.textContent=Oc,h.appendChild(p),this._shadowDom=h,this._shadowDom.appendChild(this._select)}static get observedAttributes(){return["disabled","sheet","clear","type","defaultValue","showSearch","placement","getPopupContainerId","dropdownclass","trigger"]}get value(){return this.getAttribute("value")||""}set value(h){!Ce(this)&&h?this.setAttribute("value",h):this.removeAttribute("value")}get defaultValue(){return this.getAttribute("defaultValue")||""}set defaultValue(h){this.setAttribute("defaultValue",h||"")}get showSearch(){return this.getAttribute("showSearch")||""}set showSearch(h){this.setAttribute("showSearch",h||"")}get type(){return this.getAttribute("type")||""}set type(h){this.setAttribute("type",h||"")}get placement(){return this.getAttribute("placement")||"bottom"}set placement(h){this.setAttribute("placement",h||"")}get sheet(){return this.getAttribute("sheet")||""}set sheet(h){this.setAttribute("sheet",h||"")}get getPopupContainerId(){return this.getAttribute("getPopupContainerId")||""}set getPopupContainerId(h){this.setAttribute("getPopupContainerId",h||"")}get dropdownclass(){return this.getAttribute("dropdownclass")||""}set dropdownclass(h){this.setAttribute("dropdownclass",h||"")}get trigger(){return this.getAttribute("trigger")||"click"}set trigger(h){this.setAttribute("trigger",h||"")}get disabled(){return Ce(this)}set disabled(h){!h||h==="false"?(this.removeAttribute("disabled"),this._selection.removeAttribute("disabled")):(this.setAttribute("disabled",""),this._selection.setAttribute("disabled",""))}handlerExternalCss(){if(this.sheet)try{const h=new CSSStyleSheet;h.insertRule(this.sheet),this._shadowDom.adoptedStyleSheets=[h]}catch{console.error(`Failed to parse the rule in CSSStyleSheet: ${this.sheet}`)}}connectedCallback(){this.handlerExternalCss(),this.createOption(),this.listenActionEvent(),this.listenSlotChange(),this.setShowSearch(),document.addEventListener("click",this.clickRemoveSelect)}disconnectCallback(){var h;this.removeEventListener("mouseenter",this.selectMouseDown),this.removeEventListener("mouseleave",this.selectBlur),this.removeEventListener("click",this.selectMouseDown),this.removeEventListener("blur",this.selectBlur),this.removeSelectDropdown(),(h=this._selectDropdown)==null||h.removeEventListener("click",this.clickOption),this.removeListenSlotChange(),document.removeEventListener("click",this.clickRemoveSelect)}attributeChangedCallback(h,p,f){h==="disabled"&&this._select&&(!f||f==="false"?(this._select.setAttribute("disabled",""),this._selection.setAttribute("disabled","")):(this._select.removeAttribute("disabled"),this._selection.removeAttribute("disabled"))),h==="sheet"&&this._shadowDom&&p!==f&&this.handlerExternalCss()}};function Uc(){return typeof document<"u"&&!customElements.get("r-select")?(customElements.define("r-select",pn),pn):Ie("document is undefined or r-select is exist")}const Gc=Uc(),Hc=Object.freeze(Object.defineProperty({__proto__:null,Select:pn,default:Gc},Symbol.toStringTag,{value:"Module"}));var Kc=Object.defineProperty,Vc=(k,h,p)=>h in k?Kc(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,H=(k,h,p)=>Vc(k,typeof h!="symbol"?h+"":h,p);(function k(h){var p,f;p=this,f=function(){function w(o,n){var e=Object.keys(o);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);n&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(o,i).enumerable})),e.push.apply(e,t)}return e}function x(o){for(var n=1;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function le(o,n,e){return le=te()?Reflect.construct.bind():function(t,i,r){var a=[null];a.push.apply(a,i);var s=new(Function.bind.apply(t,a));return r&&de(s,r.prototype),s},le.apply(null,arguments)}function ce(o){var n=typeof Map=="function"?new Map:void 0;return ce=function(e){if(e===null||(t=e,Function.toString.call(t).indexOf("[native code]")===-1))return e;var t;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(n!==void 0){if(n.has(e))return n.get(e);n.set(e,i)}function i(){return le(e,arguments,j(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),de(i,e)},ce(o)}function Pe(o,n){(n==null||n>o.length)&&(n=o.length);for(var e=0,t=new Array(n);e=o.length?{done:!0}:{done:!1,value:o[t++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. +`;function Rd(){if(typeof window<"u"&&!customElements.get("r-img")){class k extends HTMLElement{constructor(){super(),Ao(this,"_image"),Ao(this,"_container"),this._container=document.createElement("div"),this._container.setAttribute("class","ran-image");const p=this.attachShadow({mode:"closed"}),f=document.createElement("style");f.textContent=Ld,p.appendChild(f),p.appendChild(this._container)}static get observedAttributes(){return["fallback"]}get fallback(){return this.getAttribute("fallback")||Dd}set fallback(p){p?this.setAttribute("fallback",p):this.removeAttribute("fallback")}listenFallback(p,f){p==="fallback"&&this._image&&(f?this._image.setAttribute("fallback",f):this._image.removeAttribute("fallback"))}connectedCallback(){const p=this.getAttribute("src")||"";this._image=new Image,this._image.src=p,this._image.addEventListener("error",()=>{this._image&&this.fallback&&(this._image.src=this.fallback)}),this._image.addEventListener("load",()=>{this._image&&this._container.appendChild(this._image)})}attributeChangedCallback(p,f,w){this.listenFallback(p,w)}}customElements.define("r-img",k)}}const Id=Rd(),Pd=Object.freeze(Object.defineProperty({__proto__:null,default:Id},Symbol.toStringTag,{value:"Module"}));var Od=Object.defineProperty,Md=(k,h,p)=>h in k?Od(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,He=(k,h,p)=>Md(k,typeof h!="symbol"?h+"":h,p);const Fd='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-input{position:var(--ran-input-position, relative);display:var(--ran-input-display, flex);width:var(--ran-input-width, calc(100% - 16px) );height:var(--ran-input-height, calc(100% - 4px) );min-width:0;padding:var(--ran-input-padding, 2px 8px);color:#000000d9;font-size:var(--ran-input-font-size, 12px);line-height:var(--ran-input-line-height, 1.5715);background-color:var(--ran-input-background-color, #fff);background-image:var(--ran-input-background-image, none);border:var(--ran-input-border, 1px solid #d9d9d9);border-radius:var(--ran-input-border-radius, 2px);transition:var(--ran-input-transition, all .3s)}.ran-input .ran-icon{display:var(--ran-input-icon-display, flex);align-items:var(--ran-input-icon-align-items, center);justify-content:var(--ran-input-icon-justify-content, center)}.ran-input:active{border-color:var(--ran-input-active-border-color, #40a9ff);box-shadow:var(--ran-input-active-box-shadow, 0 0 0 2px rgba(24, 144, 255, .2));border-right-width:var(--ran-input-active-border-right-width, 1px);outline:var(--ran-input-active-outline, 0)}.ran-input:hover{border-color:var(--ran-input-hover-border-color, #40a9ff);border-right-width:var(--ran-input-hover-border-right-width, 1px)}.ran-input>.ran-input-content:hover~.ran-input-label{color:var(--ran-input-label-hover-color, #40a9ff)}.ran-input[value]>.ran-input-label{transform:var(--ran-input-label-value-transform, translateY( calc(-50% - .43em) ) scale(.8));color:var(--ran-input-label-value-color, #00000040)}.ran-input[status=error]{border-color:var(--ran-input-status-error-border-color, #ff4d4f)}.ran-input[status=error]>.ran-input-content~.ran-input-label{color:var(--ran-input-label-status-error-color, #ff4d4f)}.ran-input[status=warning]{border-color:var(--ran-input-status-warning-border-color, #ff7875)}.ran-input[status=warning]>.ran-input-content~.ran-input-label{color:var(--ran-input-label-status-warning-color, #ff7875)}.ran-input[disabled]{color:var(--ran-input-disabled-color, #00000040);background-color:var(--ran-input-disabled-background-color, #f5f5f5);border-color:var(--ran-input-disabled-border-color, #d9d9d9);box-shadow:var(--ran-input-disabled-box-shadow, none);cursor:var(--ran-input-disabled-cursor, not-allowed);opacity:var(--ran-input-disabled-opacity, 1)}.ran-input[disabled]>.ran-input-content{color:var(--ran-input-content-disabled-color, #00000040);background-color:var(--ran-input-content-disabled-background-color, #f5f5f5);border-color:var(--ran-input-content-disabled-border-color, #d9d9d9);box-shadow:var(--ran-input-content-disabled-box-shadow, none);cursor:var(--ran-input-content-disabled-cursor, not-allowed);opacity:var(--ran-input-content-disabled-opacity, 1)}.ran-input[disabled]>.ran-input-content~.ran-input-label{color:var(--ran-input-label-disabled-color, #00000040);background-color:var(--ran-input-label-disabled-background-color, #f5f5f5)}.ran-input[disabled]>.ran-input-label{color:#999;border-color:var(--ran-input-label-disabled-border-color, #d9d9d9);box-shadow:var(--ran-input-label-disabled-box-shadow, none);cursor:var(--ran-input-label-disabled-cursor, not-allowed)}.ran-input-content{writing-mode:var(--ran-input-content-writing-mode, horizontal-tb);text-rendering:var(--ran-input-content-text-rendering, auto);letter-spacing:var(--ran-input-content-letter-spacing, normal);word-spacing:var(--ran-input-content-word-spacing, normal);text-transform:var(--ran-input-content-text-transform, none);text-indent:var(--ran-input-content-text-indent, 0px);text-shadow:var(--ran-input-content-text-shadow, none);text-align:var(--ran-input-content-text-align, start);cursor:var(--ran-input-content-cursor, text);touch-action:var(--ran-input-content-touch-action, manipulation);-webkit-appearance:var(--ran-input-content--webkit-appearance, none);text-overflow:var(--ran-input-content-text-overflow, ellipsis);box-sizing:var(--ran-input-content-box-sizing, border-box);margin:var(--ran-input-content-margin, 0);font-variant:var(--ran-input-content-font-variant, tabular-nums);list-style:var(--ran-input-content-list-style, none);font-feature-settings:var(--ran-input-content-font-feature-settings, "tnum");position:var(--ran-input-content-position, relative);border:var(--ran-input-content-border, none);width:var(--ran-input-content-width, 100%);min-width:var(--ran-input-content-min-width, 0);color:var(--ran-input-content-color, #000000d9);font-size:var(--ran-input-content-font-size, 14px);line-height:var(--ran-input-content-line-height, 1.48);background-color:var(--ran-input-content-background-color, #fff);background-image:var(--ran-input-content-background-image, none);transition:var(--ran-input-content-transition, all .3s);outline:var(--ran-input-content-outline, none)}.ran-input-content:focus,.ran-input-content:hover{border:var(--ran-input-content-hover-border, none);outline:var(--ran-input-content-hover-outline, 0)}.ran-input-content::placeholder{color:var(--ran-input-content-placeholder-color, #999)}.ran-input-content:placeholder-shown~.ran-input-label{transform:var(--ran-input-content-placeholder-label-transform, translateY( calc(-50% - .43em) ) scale(.8))}.ran-input-content:focus~.ran-input-label{transform:var(--ran-input-content-focus-label-transform, translateY( calc(-50% - .43em) ) scale(.8))}.ran-input-content::-webkit-search-cancel-button{display:none;-webkit-appearance:none}.ran-input-label{pointer-events:var(--ran-input-label-pointer-events, none);position:var(--ran-input-label-position, absolute);font-size:var(--ran-input-label-font-size, 14px);left:var(--ran-input-label-left, 8px);transition:var(--ran-input-label-transition, transform .3s, color .3s, background-color .3s, backdrop-filter .3s);transform-origin:var(--ran-input-label-transform-origin, left);padding:var(--ran-input-label-padding, 0 .2em);color:var(--ran-input-label-color, #999);background:var(--ran-input-label-background, #fff);opacity:var(--ran-input-label-opacity, .9)}';let fn=class extends Fe(){constructor(){super(),He(this,"_input"),He(this,"_label"),He(this,"_inputContent"),He(this,"_icon"),He(this,"customInput",f=>{f.stopPropagation(),f.preventDefault();const{target:w,data:x=""}=f;this.value=(w==null?void 0:w.value)||x||"",this.customChange(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.value}}))}),He(this,"customChange",()=>{this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value}}))}),He(this,"listenPlaceholder",(f,w)=>{f==="placeholder"&&this._inputContent&&(w!=null?this._inputContent.setAttribute("placeholder",w):this._inputContent.removeAttribute("placeholder"))}),He(this,"listenLabel",(f,w)=>{f==="label"&&this._inputContent&&(w!=null?this._label?this._label.innerHTML=w:(this._label=document.createElement("label"),this._label.innerHTML=w,this._label.setAttribute("class","ran-input-label"),this._label.setAttribute("part","ran-input-label"),this._input.appendChild(this._label)):(this._input.removeAttribute("label"),this._label&&(this._input.removeChild(this._label),this._label=void 0)))}),He(this,"listenType",(f,w)=>{f==="type"&&this._inputContent&&(w?this._inputContent.setAttribute("type",w):(this._inputContent.removeAttribute("type"),this._inputContent.removeAttribute("min"),this._inputContent.removeAttribute("max"),this._inputContent.removeAttribute("step")))}),He(this,"listenStatus",(f,w)=>{f==="status"&&this._input&&(w?this._input.setAttribute("status",w):this._input.removeAttribute("status"))}),He(this,"listenDisabled",(f,w)=>{f==="disabled"&&this._input&&(nt.includes(w)?this._input.removeAttribute("disabled"):(this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled","")))}),He(this,"listenIcon",(f,w,x)=>{f==="icon"&&w&&w!==x&&(this.removeAttribute("label"),this.setAttribute("icon",w),this.dealIcon())}),He(this,"dealIcon",()=>{if(!this._icon){this._icon=document.createElement("ra-icon");const{width:f,height:w}=this._inputContent.getBoundingClientRect(),x=Math.min(f,w);this._icon.setAttribute("size",`${x}`),this._inputContent.insertAdjacentElement("beforebegin",this._icon)}this.icon&&this._icon.setAttribute("name",this.icon)}),He(this,"listenEvent",(f,w,x)=>{this.listenPlaceholder(f,x),this.listenLabel(f,x),this.listenStatus(f,x),this.listenDisabled(f,x),this.listenIcon(f,x,w),f==="value"&&w!==x&&(this._inputContent.value=x,this._input.setAttribute("value",x))});const h=this.attachShadow({mode:"closed"}),p=document.createElement("style");p.textContent=Fd,h.appendChild(p),this._input=document.createElement("div"),this._input.setAttribute("class","ran-input"),this._input.setAttribute("part","ran-input"),this._inputContent=document.createElement("input"),this._inputContent.setAttribute("class","ran-input-content"),this._inputContent.setAttribute("part","ran-input-content"),this._input.appendChild(this._inputContent),h.appendChild(this._input)}static get observedAttributes(){return["label","disabled","name","placeholder","type","icon","value","status","prefix","suffix","allowclear","count","maxlength","showcount","onPressEnter","variant","minrows","maxrows"]}get value(){return this.getAttribute("value")||""}set value(h){!Ce(this)&&h?(this.setAttribute("value",h),this._input.setAttribute("value",h)):(this.removeAttribute("value"),this._input.removeAttribute("value"))}get placeholder(){return this.getAttribute("placeholder")||""}set placeholder(h){h?this.setAttribute("placeholder",h):this.removeAttribute("placeholder")}get required(){return this.getAttribute("required")||""}set required(h){!h||h==="false"?this.removeAttribute("required"):this.setAttribute("required","")}get disabled(){return`${Ce(this)}`}set disabled(h){nt.includes(h)?(this.removeAttribute("disabled"),this._input.removeAttribute("disabled"),this._inputContent.removeAttribute("disabled")):(this.setAttribute("disabled",""),this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled",""))}get label(){return this.getAttribute("label")||""}set label(h){this.setAttribute("label",h)}get status(){return this.getAttribute("status")||""}set status(h){h?(this.setAttribute("status",h),this._input.setAttribute("status",h)):(this.removeAttribute("status"),this._input.removeAttribute("status"))}get name(){return this.getAttribute("name")||""}set name(h){this.setAttribute("name",h)}get min(){return this.getAttribute("min")||""}set min(h){this.type==="number"&&this.setAttribute("min",h)}get max(){return this.getAttribute("max")||""}set max(h){this.type==="number"&&this.setAttribute("max",h)}get step(){return this.getAttribute("step")||""}set step(h){this.type==="number"&&this.setAttribute("step",h)}get icon(){return this.getAttribute("icon")||""}set icon(h){h?this.setAttribute("icon",h):this.removeAttribute("icon")}get prefix(){return this.getAttribute("prefix")||""}set prefix(h){h?this.setAttribute("prefix",h):this.removeAttribute("prefix")}get suffix(){return this.getAttribute("suffix")||""}set suffix(h){h?this.setAttribute("suffix",h):this.removeAttribute("suffix")}get type(){return this.getAttribute("type")||""}set type(h){h?this.setAttribute("type",h):this.removeAttribute("type")}connectedCallback(){this.value&&(this._inputContent.value=this.value,this._input.setAttribute("value",this.value)),this.status&&this._input.setAttribute("status",this.status),Ce(this)&&(this._input.setAttribute("disabled",""),this._inputContent.setAttribute("disabled","")),this.type&&this._inputContent.setAttribute("type",this.type),this._inputContent.addEventListener("input",this.customInput),document.readyState==="complete"&&this.dealIcon()}disconnectCallback(){this._inputContent.removeEventListener("input",this.customInput)}attributeChangedCallback(h,p,f){this.listenEvent(h,p,f)}};function Bd(){return typeof window<"u"&&!customElements.get("r-input")?(customElements.define("r-input",fn),fn):Ie("document is undefined or r-input is exist")}const Nd=Bd(),Ud=Object.freeze(Object.defineProperty({__proto__:null,Input:fn,default:Nd},Symbol.toStringTag,{value:"Module"}));var Gd=Object.defineProperty,Hd=(k,h,p)=>h in k?Gd(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,Ct=(k,h,p)=>Hd(k,typeof h!="symbol"?h+"":h,p);const _o='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host([type="toast"]) .ran-message-notice{padding:8px;text-align:center;max-width:90%;margin:0 auto;word-break:break-all}:host([type="toast"]) .ran-message-notice-content{display:inline-block;padding:10px 16px;background:#000000b3;border-radius:7px;pointer-events:all}:host([type="toast"]) .ran-message-notice-content-info{align-items:center;display:flex}:host([type="toast"]) .ran-message-notice-content-info span{margin:0;padding:0;font-size:14px;font-variant:tabular-nums;list-style:none;font-feature-settings:"tnum";z-index:1010;width:100%;pointer-events:none;color:#fff}.ran-message-notice{padding:var(--ran-message-notice-padding, 8px);text-align:var(--ran-message-notice-text-align, center);max-width:var(--ran-message-notice-max-width, 90%);margin:var(--ran-message-notice-margin, 0 auto);word-break:var(--ran-message-notice-word-break, break-all)}.ran-message-notice-content{display:var(--ran-message-notice-content-display, inline-block);padding:var(--ran-message-notice-content-padding, 10px 16px);background:var(--ran-message-notice-content-background, #fff);border-radius:var(--ran-message-notice-content-border-radius, 8px);box-shadow:var(--ran-message-notice-content-box-shadow, 0 3px 6px -4px #0000001f, 0 6px 16px #00000014, 0 9px 28px 8px #0000000d);pointer-events:var(--ran-message-notice-content-pointer-events, all)}.ran-message-notice-content-info{align-items:var(--ran-message-notice-content-info-align-items, center);display:var(--ran-message-notice-content-info-display, flex)}.ran-message-notice-content-info span{margin:var(--ran-message-notice-content-info-span-margin, 0);padding:var(--ran-message-notice-content-info-span-padding, 0);color:var(--ran-message-notice-content-info-span-color, #000000d9);font-size:var(--ran-message-notice-content-info-span-font-size, 14px);font-variant:var(--ran-message-notice-content-info-span-font-variant, tabular-nums);list-style:var(--ran-message-notice-content-info-span-list-style, none);font-feature-settings:var(--ran-message-notice-content-info-span-font-feature-settings, "tnum");z-index:var(--ran-message-notice-content-info-span-z-index, 1010);width:var(--ran-message-notice-content-info-span-width, 100%);pointer-events:var(--ran-message-notice-content-info-span-pointer-events, none)}@keyframes rotate{to{transform:rotate(360deg)}}@keyframes MessageMoveIn{0%{padding:0;transform:translateY(-100%);opacity:0}to{padding:8px;transform:translateY(0);opacity:1}}@keyframes MessageMoveOut{0%{max-height:150px;padding:8px;opacity:1}to{max-height:0;padding:0;opacity:0}}.ranui-message{box-sizing:var(--ran-message-box-sizing, border-box);margin:var(--ran-message-margin, 0);padding:var(--ran-message-padding, 0);color:var(--ran-message-color, #000000d9);font-size:var(--ran-message-font-size, 14px);font-variant:var(--ran-message-font-variant, tabular-nums);line-height:var(--ran-message-line-height, 1.5715);list-style:var(--ran-message-ist-style, none);font-feature-settings:var(--ran-message-font-feature-settings, "tnum");position:var(--ran-message-position, fixed);top:var(--ran-message-top, 8px);left:var(--ran-message-left, 0);z-index:var(--ran-message-z-index, 1010);width:var(--ran-message-width, 100%);pointer-events:var(--ran-message-pointer-events, none)}.ranui-message .message-in{animation-name:var(--ran-message-in-animation-name, MessageMoveIn);animation-duration:var(--ran-message-in-animation-duration, .3s);animation-timing-function:var(--ran-message-in-animation-timing-function, cubic-bezier(.78, .14, .15, .86))}.ranui-message .message-leave{animation-name:var(--ran-message-leave-animation-name, MessageMoveOut);animation-duration:var(--ran-message-leave-animation-duration, .3s);animation-timing-function:var(--ran-message-leave-animation-timing-function, cubic-bezier(.78, .14, .15, .86))}',ko=300,xo=3e3,Kd=new Map([["success","check-circle-fill"],["warning","warning-circle-fill"],["error","close-circle-fill"],["info","info-circle-fill"],["toast",null]]),Vd=new Map([["success","#52c41a"],["warning","#faad14"],["error","#ff4d4f"],["info","#1890ff"],["toast","rgba(0, 0, 0, 0.7)"]]);function zd(){if(typeof window<"u"&&!customElements.get("r-message")){class k extends HTMLElement{constructor(){super(),Ct(this,"_info"),Ct(this,"_notice"),Ct(this,"_content"),Ct(this,"_icon"),Ct(this,"_span"),Ct(this,"timeId"),Ct(this,"close"),Ct(this,"setIcon",G=>{var F,q,j,de;const te=Kd.get(G),le=Vd.get(G);te&&((F=this._icon)==null||F.setAttribute("name",te),(q=this._icon)==null||q.style.setProperty("margin-right","8px"),(j=this._icon)==null||j.setAttribute("size","18"),le&&((de=this._icon)==null||de.setAttribute("color",le)))}),this._notice=document.createElement("div"),this._notice.setAttribute("class","ran-message-notice"),this._content=document.createElement("div"),this._content.setAttribute("class","ran-message-notice-content"),this._info=document.createElement("div"),this._info.setAttribute("class","ran-message-notice-content-info"),this._icon=document.createElement("r-icon"),this._span=document.createElement("span"),this._info.appendChild(this._icon),this._info.appendChild(this._span),this._content.appendChild(this._info),this._notice.appendChild(this._content);const T=this.attachShadow({mode:"closed"}),D=document.createElement("style");D.textContent=_o,T.appendChild(D),T.appendChild(this._notice)}static get observedAttributes(){return["type","content"]}get type(){return this.getAttribute("type")}set type(T){T&&this.setAttribute("type",T)}get content(){return this.getAttribute("content")}set content(T){T&&this.setAttribute("content",T)}attributeChangedCallback(T,D,G){T==="content"&&D!==G&&(this._span.textContent=G),T==="type"&&D!==G&&this.setIcon(G)}}customElements.define("r-message",k);const h=document.createElement("div"),p=z("style").setTextContent(_o),f=document.createElement("div");f.setAttribute("class","ranui-message"),document.body.appendChild(h),h.appendChild(p.element),h.appendChild(f);const w=x=>T=>{const D=new k;D.setAttribute("class","message"),D.timeId&&clearTimeout(D.timeId),D.setAttribute("type",x);let G=xo,F;if(!T)return;typeof T=="string"?D.setAttribute("content",T):(D.setAttribute("content",T.content),F=T.close,G=T.duration||xo);const q=setTimeout(()=>{D.classList.remove("message-in"),D.classList.add("message-leave"),clearTimeout(q)},G-ko);D.timeId=setTimeout(()=>{D.classList.remove("message-leave"),f.removeChild(D),F&&F()},G),f.appendChild(D),D.classList.add("message-in"),setTimeout(()=>{D.classList.remove("message-in")},ko)};return{info:w("info"),success:w("success"),error:w("error"),warning:w("warning"),toast:w("toast")}}return null}const bi=zd();typeof window<"u"&&bi&&(window.message=bi,window.ranui||(window.ranui={}),window.ranui.message=bi);const Yd=Object.freeze(Object.defineProperty({__proto__:null,default:bi},Symbol.toStringTag,{value:"Module"}));var jd=Object.defineProperty,qd=(k,h,p)=>h in k?jd(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,je=(k,h,p)=>qd(k,typeof h!="symbol"?h+"":h,p);const To='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.r-preview-slot{display:block}:host{cursor:pointer}.r-preview-mask{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:#00000073;z-index:1081}.r-preview-mask .r-preview-loading{position:absolute;top:30vh;left:50vw;transform:translate(-50%);display:flex;flex-flow:column;align-items:center}.r-preview-mask .r-preview-loading-text{color:#fff;font-size:16px}.r-preview-mask .r-preview-options{width:100%;pointer-events:auto;display:flex;flex-flow:row-reverse nowrap;align-items:center;justify-content:space-between}.r-preview-mask .r-preview-options-close{margin:14px;border:none;cursor:pointer;transition:all .3s;-webkit-user-select:none;user-select:none}.r-preview-mask .r-preview-contain{max-width:calc(100vw - 20px);margin:0 auto;display:flex;flex-flow:column nowrap;align-items:center;justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context{margin:0 auto;height:calc(100vh - 68px);display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items:center;overflow:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main{width:100%;height:100%;margin-bottom:10px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet{font-size:13px;line-height:normal;-webkit-user-select:none;user-select:none;-moz-user-select:none;font-family:Lato,Source Sans Pro,Roboto,Helvetica,Arial,sans-serif;box-sizing:content-box;background:#fff;-webkit-font-smoothing:antialiased}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet textarea{font:400 13px Arial,Lato,Source Sans Pro,Roboto,Helvetica,sans-serif}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-sheet{position:relative;overflow:hidden}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-table{vertical-align:bottom}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-tooltip{font-family:inherit;position:absolute;padding:5px 10px;color:#fff;border-radius:1px;background:#000;font-size:12px;z-index:201}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-tooltip:before{pointer-events:none;position:absolute;left:calc(50% - 4px);top:-4px;content:"";width:8px;height:8px;background:inherit;-webkit-transform:rotate(45deg);transform:rotate(45deg);z-index:1;box-shadow:1px 1px 3px -1px #0000004d}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette{padding:5px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette table{margin:0;padding:0;border-collapse:separate;border-spacing:2;background:#fff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette table td{margin:0;cursor:pointer;border:1px solid transparent}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette table td:hover{border-color:#ddd}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-color-palette table td .x-spreadsheet-color-palette-cell{width:16px;height:16px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette{padding:6px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette table{margin:0;padding:0;border-collapse:separate;border-spacing:0;background:#fff;table-layout:fixed}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette table td{margin:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left{border-right:1px solid #eee;padding-right:6px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell{width:30px;height:30px;cursor:pointer;text-align:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-left .x-spreadsheet-border-palette-cell:hover{background-color:#eee}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-right{padding-left:6px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-border-palette .x-spreadsheet-border-palette-right .x-spreadsheet-line-type{position:relative;left:0;top:-3px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown{position:relative}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown .x-spreadsheet-dropdown-content{position:absolute;z-index:200;background:#fff;box-shadow:1px 2px 5px 2px #33333326}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown.bottom-left .x-spreadsheet-dropdown-content{top:calc(100% + 5px);left:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown.bottom-right .x-spreadsheet-dropdown-content{top:calc(100% + 5px);right:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown.top-left .x-spreadsheet-dropdown-content{bottom:calc(100% + 5px);left:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown.top-right .x-spreadsheet-dropdown-content{bottom:calc(100% + 5px);right:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dropdown .x-spreadsheet-dropdown-title{padding:0 5px;display:inline-block}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer{position:absolute;z-index:11}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer .x-spreadsheet-resizer-hover{background-color:#4b89ff40}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer .x-spreadsheet-resizer-line{position:absolute}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer.horizontal{cursor:row-resize}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer.horizontal .x-spreadsheet-resizer-line{border-bottom:2px dashed #4b89ff;left:0;bottom:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer.vertical{cursor:col-resize}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-resizer.vertical .x-spreadsheet-resizer-line{border-right:2px dashed #4b89ff;top:0;right:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar{position:absolute;bottom:0;right:0;background-color:#f4f5f8;opacity:.9;z-index:12}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar.horizontal{right:15px;overflow-x:scroll;overflow-y:hidden}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar.horizontal>div{height:1px;background:#ddd}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar.vertical{bottom:15px;overflow-x:hidden;overflow-y:scroll}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-scrollbar.vertical>div{width:1px;background:#ddd}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-overlayer{position:absolute;left:0;top:0;z-index:10}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-overlayer .x-spreadsheet-overlayer-content{position:absolute;overflow:hidden;pointer-events:none;width:100%;height:100%}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector{box-sizing:content-box;position:absolute;overflow:hidden;pointer-events:none;top:0;left:0;width:100%;height:100%}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .hide-input{position:absolute;z-index:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .hide-input input{padding:0;width:0;border:none!important}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-area{position:absolute;border:2px solid #4b89ff;background:#4b89ff1a;z-index:5}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-clipboard,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-autofill{position:absolute;background:transparent;z-index:100}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-clipboard{border:2px dashed #4b89ff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-autofill{border:1px dashed rgba(0,0,0,.45)}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-selector .x-spreadsheet-selector-corner{pointer-events:auto;position:absolute;cursor:crosshair;font-size:0;height:5px;width:5px;right:-5px;bottom:-5px;border:2px solid #ffffff;background:#4b89ff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor{z-index:20}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor .x-spreadsheet-editor-area{position:absolute;text-align:left;border:2px solid #4b89ff;line-height:0;z-index:100;pointer-events:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor .x-spreadsheet-editor-area textarea{box-sizing:content-box;border:none;padding:0 3px;outline:none;resize:none;text-align:start;overflow-y:hidden;font:400 13px Arial,Lato,Source Sans Pro,Roboto,Helvetica,sans-serif;color:inherit;white-space:normal;word-wrap:break-word;line-height:22px;margin:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-editor .x-spreadsheet-editor-area .textline{overflow:hidden;visibility:hidden;position:fixed;top:0;left:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item{-webkit-user-select:none;user-select:none;background:0;border:1px solid transparent;outline:none;height:26px;color:#000000e6;line-height:26px;list-style:none;padding:2px 10px;cursor:default;text-align:left;overflow:hidden}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.disabled{pointer-events:none;opacity:.5}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item:hover,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.active{background:#0000000d}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.divider{height:0;padding:0;margin:5px 0;border:none;border-bottom:1px solid rgba(0,0,0,.1)}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item .label{float:right;opacity:.65;font-size:1em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.state,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-header.state{padding-left:35px!important;position:relative}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.state:before,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-header.state:before{content:"";position:absolute;width:10px;height:10px;left:12px;top:calc(50% - 5px);background:#00000014;border-radius:2px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-item.state.checked:before,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-header.state.checked:before{background:#4b89ff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-checkbox{position:relative;display:inline-block;backface-visibility:hidden;outline:0;vertical-align:baseline;font-style:normal;font-size:1rem;line-height:1em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-checkbox>input{position:absolute;top:0;left:0;opacity:0!important;outline:0;z-index:-1}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-suggest,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-contextmenu,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-sort-filter{position:absolute;box-shadow:1px 2px 5px 2px #33333326;background:#fff;z-index:100;width:260px;pointer-events:auto;overflow:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-suggest{width:200px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-filter{border:1px solid #e9e9e9;font-size:12px;margin:10px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-filter .x-spreadsheet-header{padding:.5em .75em;background:#f8f8f9;border-bottom:1px solid #e9e9e9;border-left:1px solid transparent}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-filter .x-spreadsheet-body{height:200px;overflow-y:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-filter .x-spreadsheet-body .x-spreadsheet-item{height:20px;line-height:20px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-sort-filter .x-spreadsheet-buttons{margin:10px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-bottombar{height:40px;padding:0 30px;text-align:left;background:#f5f6f7;display:flex}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-bottombar{position:relative;border-top:1px solid #e0e2e4}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-bottombar .x-spreadsheet-menu>li{line-height:40px;height:40px;padding-top:0;padding-bottom:0;vertical-align:middle;border-right:1px solid #e8eaed}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu{list-style:none;margin:0;padding:0;-webkit-user-select:none;user-select:none}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu>li{float:left;line-height:1.25em;padding:.785em 1em;margin:0;vertical-align:middle;text-align:left;font-weight:400;color:#80868b;white-space:nowrap;cursor:pointer;transition:all .3s;font-weight:700}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu>li.active{background-color:#fff;color:#000000a6}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu>li .x-spreadsheet-dropdown{display:inline-block}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print{position:absolute;left:0;top:0;z-index:100;width:100%;height:100%;display:flex;flex-direction:column}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-bar{background:#424242;height:60px;line-height:60px;padding:0 30px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-bar .-title{color:#fff;font-weight:700;font-size:1.2em;float:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-bar .-right{float:right;margin-top:12px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-content{display:flex;flex:auto;flex-direction:row;background:#d0d0d0;height:calc(100% - 60px)}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-content .-sider{flex:0 0 300px;width:300px;border-left:2px solid #ccc;background:#fff}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-print-content .-content{flex:auto;overflow-x:auto;overflow-y:scroll;height:100%}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-canvas-card-wraper{margin:40px 20px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-canvas-card{background:#fff;margin:auto;page-break-before:auto;page-break-after:always;box-shadow:0 8px 10px 1px #00000024,0 3px 14px 3px #0000001f,0 4px 5px #0003}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar{color:#000000a6;background:#fff;-webkit-user-select:none;user-select:none}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header{font-weight:700;line-height:30px;text-align:center;width:100%;float:left;background:#f9fafb}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header .calendar-header-left{padding-left:5px;float:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header .calendar-header-right{float:right}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header .calendar-header-right a{padding:3px 0;margin-right:2px;border-radius:2px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-header .calendar-header-right a:hover{background:#00000014}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body{border-collapse:collapse;border-spacing:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body th,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td{width:14.28571429%;min-width:32px;text-align:center;font-weight:700;line-height:30px;padding:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td>.cell:hover{background:#ecf6fd}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td>.cell.active,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td>.cell.active:hover{background:#ecf6fd;color:#2185d0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-calendar .calendar-body td>.cell.disabled{pointer-events:none;opacity:.5}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-datepicker{box-shadow:2px 2px 5px #0003;position:absolute;left:0;top:calc(100% + 5px);z-index:10;width:auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-buttons{display:flex;justify-content:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-buttons .x-spreadsheet-button{margin-left:8px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button{display:inline-block;border-radius:3px;line-height:1em;min-height:1em;white-space:nowrap;text-align:center;cursor:pointer;font-size:1em;font-weight:700;padding:.75em 1em;color:#0009;background:#e0e1e2;text-decoration:none;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;outline:none;vertical-align:baseline;zoom:1;-webkit-user-select:none;user-select:none;transition:all .1s linear}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button.active,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button:hover{background-color:#c0c1c2;color:#000c}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button.primary{color:#fff;background-color:#2185d0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button.primary:hover,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-button.primary.active{color:#fff;background-color:#1678c2}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-input{font-size:1em;position:relative;font-weight:400;display:inline-flex;color:#000000de}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-input input{z-index:1;margin:0;max-width:100%;flex:1 0 auto;outline:0;-webkit-tap-highlight-color:rgba(255,255,255,0);text-align:left;line-height:30px;height:30px;padding:0 8px;background:#fff;border:1px solid #e9e9e9;border-radius:3px;transition:box-shadow .1s ease,border-color .1s ease;box-shadow:inset 0 1px 2px #0a0a0a0f}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-input input:focus{border-color:#4b89ff;box-shadow:inset 0 1px 2px #4b89ff33}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-select{position:relative;display:inline-block;background:#fff;border:1px solid #e9e9e9;border-radius:2px;cursor:pointer;color:#000000de;-webkit-user-select:none;user-select:none;box-shadow:inset 0 1px 2px #0a0a0a0f}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-select .input-text{text-overflow:ellipsis;white-space:nowrap;min-width:60px;width:auto;height:30px;line-height:30px;padding:0 8px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-fields{display:flex;flex-direction:row;flex-wrap:wrap}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-fields .x-spreadsheet-form-field{flex:0 1 auto}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-fields .x-spreadsheet-form-field .label{display:inline-block;margin:0 10px 0 0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field{display:block;vertical-align:middle;margin-left:10px;margin-bottom:10px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field:first-child{margin-left:0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field.error .x-spreadsheet-form-select,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field.error input{border-color:#f04134}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-form-field .tip{color:#f04134;font-size:.9em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dimmer{display:none;position:absolute;top:0!important;left:0!important;width:100%;height:100%;text-align:center;vertical-align:middle;background-color:#0009;opacity:0;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:.5s;animation-duration:.5s;transition:background-color .5s linear;-webkit-user-select:none;user-select:none;z-index:1000}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-dimmer.active{display:block;opacity:1}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main form fieldset{border:none}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main form fieldset label{display:block;margin-bottom:.5em;font-size:1em;color:#666}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main form fieldset select{font-size:1.1em;width:100%;background-color:#fff;border:none;border-bottom:2px solid #ddd;padding:.5em .85em;border-radius:2px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast{font-size:13px;position:fixed;z-index:1001;text-align:left;line-height:1.25em;min-width:360px;color:#000000de;font-family:Lato,Source Sans Pro,Roboto,Helvetica,Arial,sans-serif;border-radius:4px;border:1px solid rgba(0,0,0,.1);background-color:#fff;background-clip:padding-box;box-shadow:#0003 0 2px 8px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast{background-color:#ffffffd9}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal-header,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast-header{font-weight:600;background-clip:padding-box;background-color:#ffffffd9;border-bottom:1px solid rgba(0,0,0,.05);border-radius:4px 4px 0 0}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast-header{color:#f2711c}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal-header{border-bottom:1px solid #e0e2e4;background:#00000014;font-size:1.0785em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal-header,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-modal-content,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast-header,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-toast-content{padding:.75em 1em}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-excel-main .x-spreadsheet-menu li:first-child{display:none}.r-preview-mask .r-preview-contain .r-preview-context .docx-wrapper{background:none}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section{width:100%;height:690px;position:relative;border:1px solid #333;background-color:#efefef;text-align:center;border-radius:10px;box-shadow:1px 1px 3px #aaa;overflow:hidden}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.block{position:absolute;top:0;left:0;width:100%}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.content{display:flex;flex-direction:column}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.v-up{justify-content:flex-start}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.v-mid{justify-content:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.v-down{justify-content:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.h-left{align-items:flex-start;text-align:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.h-mid{align-items:center;text-align:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.h-right{align-items:flex-end;text-align:right}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.up-left{justify-content:flex-start;align-items:flex-start;text-align:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.up-center{justify-content:flex-start;align-items:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.up-right{justify-content:flex-start;align-items:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.center-left{justify-content:center;align-items:flex-start;text-align:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.center-center{justify-content:center;align-items:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.center-right{justify-content:center;align-items:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.down-left{justify-content:flex-end;align-items:flex-start;text-align:left}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.down-center{justify-content:flex-end;align-items:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section div.down-right{justify-content:flex-end;align-items:flex-end}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main li.slide{margin:10px 0;font-size:18px}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main div.footer{text-align:center}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section table{position:absolute}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section table,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section th,.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section td{border:1px solid black}.r-preview-mask .r-preview-contain .r-preview-context .r-preview-pptx-main section svg.drawing{position:absolute;overflow:visible}',$d="application/vnd.openxmlformats-officedocument.presentationml.presentation",Qd="application/pdf",Wd="application/vnd.openxmlformats-officedocument.wordprocessingml.document",Co="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",So="application/vnd.ms-excel";async function Xd(){if(typeof document<"u"&&!customElements.get("r-preview")){const{warning:k=Yo}=bi,{renderPptx:h}=await V(async()=>{const{renderPptx:q}=await import("./index-Co9E57uv.BtZPXcWW.js");return{renderPptx:q}},__vite__mapDeps([0,1,2])),{renderDocx:p}=await V(async()=>{const{renderDocx:q}=await import("./docx-VUApAnRr.Cl4GUa7G.js");return{renderDocx:q}},__vite__mapDeps([3,4,5])),{renderPdf:f}=await V(async()=>{const{renderPdf:q}=await import("./pdf-Cx0VWKFo.BKCfi8kk.js");return{renderPdf:q}},__vite__mapDeps([6,1])),{renderExcel:w}=await V(async()=>{const{renderExcel:q}=await import("./index-Ba501-HG.BBoApf2J.js");return{renderExcel:q}},__vite__mapDeps([7,5,2,1])),x=(q,j)=>{if(typeof XMLHttpRequest>"u")throw new Error("XMLHttpRequest is not defined");return typeof document>"u"?Promise.reject("document is not defined"):new Promise(function(de,te){const le=new XMLHttpRequest;le.open(j.method||"GET",q,!0),le.responseType=j.responseType||"arraybuffer",le.onload=function(){if(le.status===200){const ce={success:!0,data:le.response,message:""};j.onLoad&&j.onLoad(ce),de(ce)}else{const ce={success:!1,data:le.status,message:`The request status is${le.status}`};j.onError&&j.onError(ce),te(ce)}},le.onerror=function(ce){const Pe={success:!1,data:ce,message:""};j.onError&&j.onError(Pe),te(Pe)},le.onprogress=ce=>{j.onProgress&&j.onProgress(ce)},le.withCredentials=j.withCredentials||!1,j.headers&&Object.keys(j.headers).forEach(function(ce){j!=null&&j.headers&&le.setRequestHeader(ce,j.headers[ce])}),le.send(j.body)})},T=(q,j)=>{const{dom:de,onError:te,onLoad:le}=j;return new Promise((ce,Pe)=>{const ze=new FileReader;ze.readAsArrayBuffer(q),ze.onload=()=>{var qe;if(ze.result&&de){const ei={pptx:ze.result,resultElement:de,onError:te,onLoad:le};(qe=h(ei))==null||qe.then(()=>{ce()})}},ze.onerror=qe=>{Pe(qe)},ze.onabort=qe=>{Pe(qe)}})},D=(q,j)=>{const{dom:de,onError:te,onLoad:le}=j;return Promise.resolve().then(()=>p({buffer:q,bodyContainer:de})).then(()=>{le&&le({success:!0,message:""})}).catch(ce=>{te&&te({success:!0,data:ce,message:""})})},G=new Map([[Qd,f],[$d,T],[Wd,D],[Co,w],[So,w]]);class F extends HTMLElement{constructor(){super(),je(this,"_loadingText"),je(this,"preview"),je(this,"previewContext"),je(this,"_slot"),je(this,"_div"),je(this,"_loadingElement"),je(this,"createLoading",()=>{this._loadingElement=document.createElement("div"),this._loadingElement.setAttribute("class","r-preview-loading");const te=document.createElement("r-icon");return te.setAttribute("name","loading"),te.setAttribute("size","100"),te.setAttribute("color","#1E90FF"),te.setAttribute("spin",""),this._loadingText=document.createElement("div"),this._loadingElement.appendChild(te),this._loadingText.setAttribute("class","r-preview-loading-text"),this._loadingElement.appendChild(this._loadingText),this._loadingElement}),je(this,"onProgress",te=>{const le=te.loaded/te.total*100,ce=Math.min(99,le).toFixed(2)+"%";this._loadingText&&this._loadingElement&&(this._loadingText.innerText=`Loading ${ce}`,le>=100&&setTimeout(()=>{this._loadingText.innerText="Loading..."},300))}),je(this,"onError",()=>{var te;(te=this.preview)==null||te.removeChild(this._loadingElement)}),je(this,"onLoad",()=>{var te;(te=this.preview)==null||te.removeChild(this._loadingElement)}),je(this,"handleFile",async te=>{try{if(typeof te=="string"){const{success:le,data:ce,message:Pe}=await x(te,{onProgress:this.onProgress,onError:this.onError,responseType:"blob"});if(le&&ce){te=new File([ce],ce.name,{type:ce.type});const{type:ze}=te,qe=G.get(ze);if(qe&&this.previewContext){ze===Co||ze===So?this.previewContext.style.setProperty("width","100%"):this.previewContext.style.setProperty("width","100%");const ei={dom:this.previewContext,onError:this.onError,onLoad:this.onLoad};qe(te,ei)}}else k(Pe)}}catch{}}),je(this,"closePreview",()=>{this.preview&&(document.body.removeChild(this.preview),this.preview=void 0)}),je(this,"showPreview",()=>{var te;if(this.src){if(this.preview)this.preview.style.display="block";else{this.preview=document.createElement("div"),this.preview.setAttribute("class","r-preview-mask"),this.preview.setAttribute("id","r-preview-mask");const le=document.createElement("div");if(le.setAttribute("class","r-preview-options"),this.closeable!=="false"){const Pe=document.createElement("r-icon");Pe.setAttribute("class","r-preview-options-close"),Pe.setAttribute("name","close-circle-fill"),Pe.setAttribute("size","40"),Pe.addEventListener("click",this.closePreview),le.appendChild(Pe)}const ce=document.createElement("div");ce.setAttribute("class","r-preview-contain"),this.previewContext=document.createElement("div"),this.previewContext.setAttribute("class","r-preview-context"),ce.appendChild(this.previewContext),this.preview.appendChild(le),(te=this.preview)==null||te.appendChild(ce),this._loadingElement=this.createLoading(),this.preview.appendChild(this._loadingElement),document.body.appendChild(this.preview)}this.handleFile(this.src)}}),this._div=document.createElement("div"),this.preview=document.getElementById("r-preview-mask"),this._slot=document.createElement("slot"),this._div.appendChild(this._slot),this._slot.setAttribute("class","r-preview-slot"),this._div.setAttribute("class","r-preview");const j=this.attachShadow({mode:"closed"}),de=document.createElement("style");de.textContent=To,j.appendChild(de),j.appendChild(this._div)}static get observedAttributes(){return["src","closeable"]}get label(){return this.getAttribute("label")}set label(j){j&&this.setAttribute("label",j)}get src(){return this.getAttribute("src")}set src(j){j&&this.setAttribute("src",j)}get closeable(){return this.getAttribute("closeable")}set closeable(j){j&&this.setAttribute("closeable",j)}connectedCallback(){this.preview=document.getElementById("r-preview-mask"),this.addEventListener("click",this.showPreview)}disconnectedCallback(){this.removeEventListener("click",this.showPreview)}attributeChangedCallback(j,de,te){te!==de&&j==="src"&&te&&(this.setAttribute("src",te),this.showPreview())}}if(typeof document<"u"&&!customElements.get("r-preview")){customElements.define("r-preview",F);const q=z("style").setTextContent(To);document.body.appendChild(q.element)}}}const Jd=Xd(),Zd=Object.freeze(Object.defineProperty({__proto__:null,default:Jd},Symbol.toStringTag,{value:"Module"}));var ec=Object.defineProperty,tc=(k,h,p)=>h in k?ec(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,ic=(k,h,p)=>tc(k,h+"",p);const rc='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}@keyframes skeleton{0%{transform:translate(-37.5%)}to{transform:translate(37.5%)}}.ran-skeleton{position:relative;z-index:0;overflow:hidden;background:0 0;width:100%;height:16px;background:#0000000f;border-radius:4px}.ran-skeleton:after{position:absolute;top:0;inset-inline-end:-150%;bottom:0;inset-inline-start:-150%;background:linear-gradient(90deg,#0000000f 25%,#00000026 37%,#0000000f 63%);animation-name:skeleton;animation-duration:1.4s;animation-timing-function:ease;animation-iteration-count:infinite;content:""}';function nc(){if(typeof window<"u"&&!customElements.get("r-skeleton")){class k extends HTMLElement{constructor(){super(),ic(this,"_div"),this._div=document.createElement("div"),this._div.setAttribute("class","ran-skeleton");const p=this.attachShadow({mode:"closed"}),f=document.createElement("style");f.textContent=rc,p.appendChild(f),p.appendChild(this._div)}static get observedAttributes(){return["disabled"]}connectedCallback(){}disconnectCallback(){}attributeChangedCallback(p,f,w){}}window.customElements.define("r-skeleton",k)}}const ac=nc(),oc=Object.freeze(Object.defineProperty({__proto__:null,default:ac},Symbol.toStringTag,{value:"Module"}));var sc=Object.defineProperty,lc=(k,h,p)=>h in k?sc(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,sn=(k,h,p)=>lc(k,typeof h!="symbol"?h+"":h,p);const dc=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}";function cc(){if(typeof window<"u"&&!customElements.get("r-tab")){class k extends HTMLElement{constructor(){super(),sn(this,"_div"),sn(this,"parent"),sn(this,"initAttribute",()=>{var w,x,T;this.parent=this.parentNode,this.key&&((w=this.parent)==null||w.updateAttribute(this.key,"icon",this.icon)),this.key&&((x=this.parent)==null||x.updateAttribute(this.key,"iconSize",this.iconSize)),this.key&&((T=this.parent)==null||T.updateAttribute(this.key,"effect",this.effect))}),this._div=document.createElement("slot");const p=this.attachShadow({mode:"closed"}),f=document.createElement("style");f.textContent=dc,p.appendChild(f),p.appendChild(this._div)}static get observedAttributes(){return["label","key","disabled","icon","effect","iconSize"]}get label(){return this.getAttribute("label")||""}set label(p){this.setAttribute("label",p)}get icon(){return this.getAttribute("icon")}set icon(p){!p||p==="false"?this.removeAttribute("icon"):this.setAttribute("icon",p)}get iconSize(){return this.getAttribute("iconSize")}set iconSize(p){!p||p==="false"?this.removeAttribute("iconSize"):this.setAttribute("iconSize",p)}get key(){return this.getAttribute("r-key")}set key(p){p?this.setAttribute("r-key",p):this.removeAttribute("r-key")}get disabled(){return this.getAttribute("disabled")}set disabled(p){!p||p==="false"?this.removeAttribute("disabled"):this.setAttribute("disabled",p)}get effect(){return this.getAttribute("effect")}set effect(p){!p||p==="false"?this.removeAttribute("effect"):this.setAttribute("effect",p)}onClick(p){}connectedCallback(){this._div.addEventListener("click",this.onClick),document.addEventListener("DOMContentLoaded",this.initAttribute)}disconnectCallback(){document.removeEventListener("DOMContentLoaded",this.initAttribute)}attributeChangedCallback(p,f,w){var x,T,D,G,F;f!==w&&this.key&&((x=this.parent)!=null&&x.updateAttribute)&&(p==="icon"&&((T=this.parent)==null||T.updateAttribute(this.key,"icon",w)),p==="iconSize"&&((D=this.parent)==null||D.updateAttribute(this.key,"iconSize",w)),p==="effect"&&((G=this.parent)==null||G.updateAttribute(this.key,"effect",w)),p==="disabled"&&((F=this.parent)==null||F.updateAttribute(this.key,"disabled",w)))}}return customElements.define("r-tab",k),k}}const hc=cc(),uc=Object.freeze(Object.defineProperty({__proto__:null,default:hc},Symbol.toStringTag,{value:"Module"}));var fc=Object.defineProperty,pc=(k,h,p)=>h in k?fc(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,Te=(k,h,p)=>pc(k,typeof h!="symbol"?h+"":h,p);const gc='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-tab ::slotted(r-tab){box-sizing:border-box;width:100%;height:100%;padding:10px;flex-shrink:0;overflow:auto;text-align:start}.ran-tab-header{position:relative;overflow:hidden;scroll-behavior:smooth}.ran-tab-header-nav{display:flex;flex-flow:row nowrap;justify-content:flex-start;align-items:center}.ran-tab-header-nav::-webkit-scrollbar{display:none}.ran-tab-header-nav-item{flex-shrink:0}.ran-tab-header-nav .active{color:var(--active-color, #1890ff)}.ran-tab-header-line{position:absolute;width:0;margin-top:-2px;height:2px;border-radius:2px;background:var(--line-color, #1890ff);transition:.2s}.ran-tab-content{overflow:hidden}.ran-tab-content-wrap{display:flex;width:100%;height:100%;transition:.2s}:host([type="line"]) .ran-tab-header-nav-item{border:solid 1px transparent}:host([type="line"]) .ran-tab-header-nav .active{color:var(--line-color, #1890ff);border:solid 1px transparent;border-color:var(--border-color, rgba(0, 0, 0, .2)) var(--border-color, rgba(0, 0, 0, .2)) transparent;border-radius:var(--border-radius, .25em) var(--border-radius, .25em) 0 0}:host([type="line"]) .ran-tab-header-line{transition:none;visibility:hidden}:host([type="line"]) .ran-tab-header-line:after,:host([type="line"]) .ran-tab-header-line:before{content:"";position:absolute;visibility:visible;width:9999px;height:1px;bottom:0;background:var(--border-color, rgba(0, 0, 0, .2))}:host([type="line"]) .ran-tab-header-line:after{left:100%}:host([type="line"]) .ran-tab-header-line:before{right:100%}:host([align="center"]) .ran-tab-header-nav{justify-content:center}:host([align="center"]) .ran-tab-header-line{left:50%}:host([align="end"]) .ran-tab-header-nav{justify-content:flex-end}';function mc(){if(typeof window<"u"&&!customElements.get("r-tabs")){class k extends HTMLElement{constructor(){super(),Te(this,"_container"),Te(this,"_header"),Te(this,"_nav"),Te(this,"_line"),Te(this,"_content"),Te(this,"_wrap"),Te(this,"_slot"),Te(this,"tabHeaderKeyMapIndex"),Te(this,"initTabHeaderKeyMapIndex",(w,x)=>{if(this.tabHeaderKeyMapIndex[w])throw new Error("tab 组件的 key 值存在重复,或者某个 tab 组件缺少 key 属性");this.tabHeaderKeyMapIndex[w]=x}),Te(this,"initTabLineAlignCenter",()=>{const{length:w}=this._nav.children;let x=0;for(let T=0;T{const{length:w}=this._nav.children;let x=0;for(let T=0;T{if(w){const x=this.tabHeaderKeyMapIndex[w],T=this._nav.children[x],{width:D=0}=T.getBoundingClientRect();this._line.style.setProperty("width",`${D}px`);let G=0;for(let F=0;F{if(w){const x=this.tabHeaderKeyMapIndex[w];this._wrap.style.setProperty("transform",`translateX(${x*-100}%)`)}}),Te(this,"clickTabHead",w=>{const x=w.target,T=x.getAttribute("r-key");!Ce(x)&&T&&(this.setAttribute("active",T),this.setTabLine(T),this.setTabContent(T),ud(this._nav,"active"),Re(x,"active"))}),Te(this,"updateAttribute",(w,x,T="")=>{var D,G;const F=this.tabHeaderKeyMapIndex[w];w&&T&&this._nav.children[F]?(D=this._nav.children[F])==null||D.setAttribute(x,T):(G=this._nav.children[F])==null||G.removeAttribute(x)}),Te(this,"initActive",()=>{const w=[...this._nav.children],x=w.filter(F=>!Ce(F));let T;if(this.active!=null&&(T=x.find(F=>F.getAttribute("r-key")===this.active),T==null||T.setAttribute("r-key",this.active)),T||(T=x.shift()),!T)return;const D=w.findIndex(F=>F===T),G=(T==null?void 0:T.getAttribute("r-key"))||`${D}`;G!=null&&(this.setAttribute("active",`${G}`),Re(T,"active"),this.setTabContent(G),setTimeout(()=>{this.setTabLine(G)},200))}),Te(this,"listenSlotChange",()=>{this._slot.assignedElements().forEach((x,T)=>{const D=this.createTabHeader(x,T);this._nav.appendChild(D),D.addEventListener("click",this.clickTabHead)}),this.initActive(),this.align&&(this.align==="center"&&this.initTabLineAlignCenter(),this.align==="end"&&this.initTabLineAlignEnd())}),Te(this,"initTab",()=>{this._slot.addEventListener("slotchange",this.listenSlotChange)}),Te(this,"unloadTab",()=>{this._slot.removeEventListener("slotchange",this.listenSlotChange)}),this._container=document.createElement("div"),this._container.setAttribute("class","ran-tab"),this._header=document.createElement("div"),this._header.setAttribute("class","ran-tab-header"),this._nav=document.createElement("div"),this._nav.setAttribute("class","ran-tab-header-nav"),this._line=document.createElement("div"),this._line.setAttribute("class","ran-tab-header-line"),this._content=document.createElement("div"),this._content.setAttribute("class","ran-tab-content"),this._wrap=document.createElement("div"),this._wrap.setAttribute("class","ran-tab-content-wrap"),this._slot=document.createElement("slot"),this._wrap.appendChild(this._slot),this._content.appendChild(this._wrap),this._header.appendChild(rt([this._nav,this._line])),this._container.appendChild(rt([this._header,this._content])),this.tabHeaderKeyMapIndex={};const p=this.attachShadow({mode:"closed"}),f=document.createElement("style");f.textContent=gc,p.appendChild(f),p.appendChild(this._container)}static get observedAttributes(){return["active","forceRender","type","align","effect"]}get align(){return this.getAttribute("align")||"start"}set align(p){this.setAttribute("align",p)}set type(p){this.setAttribute("type",p)}get type(){return this.getAttribute("type")||"flat"}get active(){return this.getAttribute("active")}set active(p){p?(this.setAttribute("active",p),this.setTabLine(p),this.setTabContent(p)):this.removeAttribute("active")}get effect(){return this.getAttribute("effect")}set effect(p){!p||p==="false"?this.removeAttribute("effect"):this.setAttribute("effect",p)}createTabHeader(p,f){const w=p.getAttribute("label")||"",x=p.getAttribute("icon")||"",T=p.getAttribute("iconSize")||"",D=p.getAttribute("r-key")||`${f}`,G=p.getAttribute("type")||"text";this.initTabHeaderKeyMapIndex(D,f);const F=document.createElement("r-button");return F.setAttribute("class","tab-header-nav-item"),F.setAttribute("type",G),x&&F.setAttribute("icon",x),T&&F.setAttribute("iconSize",T),Ce(p)&&F.setAttribute("disabled",""),F.setAttribute("r-key",D),this.effect&&(p.setAttribute("effect",this.effect),this._line.style.setProperty("display","none")),p.setAttribute("r-key",D),F.innerHTML=w,F}connectedCallback(){this.initTab()}disconnectCallback(){this.unloadTab()}attributeChangedCallback(p,f,w){f!==w&&(this.dispatchEvent(new CustomEvent("change",{detail:{active:this.active}})),p==="align"&&(w==="center"&&this.initTabLineAlignCenter(),w==="end"&&this.initTabLineAlignEnd()),p==="effect"&&[...this._nav.children].forEach(T=>{!this.effect||this.effect==="false"?T.removeAttribute("effect"):T.setAttribute("effect",w)}),p==="active"&&this.setAttribute(p,w))}}return customElements.define("r-tabs",k),k}}const vc=mc(),bc=Object.freeze(Object.defineProperty({__proto__:null,default:vc},Symbol.toStringTag,{value:"Module"}));var yc=Object.defineProperty,wc=(k,h,p)=>h in k?yc(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,ht=(k,h,p)=>wc(k,typeof h!="symbol"?h+"":h,p);const Ec=".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ran-radar{position:var(--ran-radar-position, relative);width:var(--ran-radar-width, 100%);height:var(--ran-radar-height, 100%);display:var(--ran-radar-display, block)}",Ac="rgba(0,0,0,0)",_c="rgba(0,0,0,1)",Lo="#e6e6e6",Do="#e6e6e6",kc="黑体",Ro="rgba(255,121,35,0.60)",Io="rgba(255,121,35,0.60)";function xc(){if(typeof document<"u"&&!customElements.get("r-radar")){class k extends HTMLElement{constructor(){super(),ht(this,"mData"),ht(this,"mCount"),ht(this,"mW"),ht(this,"mCenter"),ht(this,"mRadius"),ht(this,"mAngle"),ht(this,"abilityRadarChartContainer"),ht(this,"abilityRadarChart"),ht(this,"_iconElement"),ht(this,"_shadowDom"),this.abilityRadarChartContainer=document.createElement("div"),this.abilityRadarChartContainer.setAttribute("class","ran-radar"),this.abilityRadarChart=document.createElement("canvas"),this.abilityRadarChart.style.setProperty("width","100%"),this.abilityRadarChart.style.setProperty("height","100%"),this.abilityRadarChartContainer.appendChild(this.abilityRadarChart);const p=this.attachShadow({mode:"closed"}),f=document.createElement("style");f.textContent=Ec,p.appendChild(f),this._shadowDom=p,p.appendChild(this.abilityRadarChartContainer)}static get observedAttributes(){return["abilitys","colorPolygon","colorLine","fillColor","strokeColor"]}get abilitys(){const p=this.getAttribute("abilitys");if(typeof p=="string")try{return JSON.parse(p)}catch{return p}return p}set abilitys(p){typeof p=="string"?this.setAttribute("abilitys",p||""):this.setAttribute("abilitys",JSON.stringify(p)||"")}get colorPolygon(){return this.getAttribute("colorPolygon")||Lo}set colorPolygon(p){this.setAttribute("colorPolygon",p||Lo)}get colorLine(){return this.getAttribute("colorLine")||Do}set colorLine(p){this.setAttribute("colorLine",p||Do)}get fillColor(){return this.getAttribute("fillColor")||Ro}set fillColor(p){this.setAttribute("fillColor",p||Ro)}get strokeColor(){return this.getAttribute("strokeColor")||Io}set strokeColor(p){this.setAttribute("strokeColor",p||Io)}refreshData(){var p;const f=this.abilityRadarChart.getContext("2d");if(!this.abilityRadarChartContainer||!f)return;const w=Zt(f),x=this.abilityRadarChartContainer.clientWidth*w,T=this.abilityRadarChartContainer.clientHeight*w;this.abilityRadarChart.width=x,this.abilityRadarChart.height=T,this.mW=x,this.mData=this.abilitys,this.mCount=((p=this.mData)==null?void 0:p.length)||1,this.mCenter=this.mW/2,this.mRadius=this.mCenter-50*w,this.mAngle=Math.PI*2/this.mCount,this.drawPolygon(f),this.drawSide(f),this.drawLines(f),this.drawText(f),this.drawRegion(f),this.drawCircle(f)}drawSide(p){if(!this.mRadius||!this.mCount||!this.mCenter||!this.mAngle)return;p.save(),p.strokeStyle=this.colorLine;const f=this.mRadius;for(let w=0;w=0&&this.mAngle*F=Math.PI/2&&this.mAngle*F=Math.PI&&this.mAngle*Fh in k?Sc(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,St=(k,h,p)=>Lc(k,typeof h!="symbol"?h+"":h,p);const Dc='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}@keyframes ranui-dropdown-down-in{0%{transform:scaleY(.8);transform-origin:100% 100%;opacity:0}to{transform:scaleY(1);transform-origin:100% 100%;opacity:1}}@keyframes ranui-dropdown-down-out{0%{transform:scaleY(1);transform-origin:100% 100%;opacity:1}to{transform:scaleY(.8);transform-origin:100% 100%;opacity:0}}@keyframes ranui-dropdown-up-in{0%{transform:scaleY(.8);transform-origin:0% 0%;opacity:0}to{transform:scaleY(1);transform-origin:0% 0%;opacity:1}}@keyframes ranui-dropdown-up-out{0%{transform:scaleY(1);transform-origin:0% 0%;opacity:1}to{transform:scaleY(.8);transform-origin:0% 0%;opacity:0}}.ran-dropdown-down-in{animation:ranui-dropdown-up-in .2s;animation-fill-mode:forwards}.ran-dropdown-down-out{animation:ranui-dropdown-up-out .2s;animation-fill-mode:forwards}.ran-dropdown-up-in{animation:ranui-dropdown-down-in .2s;animation-fill-mode:forwards}.ran-dropdown-up-out{animation:ranui-dropdown-down-out .2s;animation-fill-mode:forwards}:host{text-align:var(--ran-dropdown-host-text-align, left);z-index:10}.ranui-dropdown{transform-origin:var(--ran-x, 50%) var(--ran-y, 50%);box-sizing:var(--ran-dropdown-box-sizing, border-box);margin:var(--ran-dropdown-margin, 0);padding:var(--ran-dropdown-padding, 4px);color:var(--ran-dropdown-color, rgba(0, 0, 0, .88));font-size:var(--ran-dropdown-font-size, 14px);list-style:var(--ran-dropdown-list-style, none);font-family:var(--ran-dropdown-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");z-index:var(--ran-dropdown-z-index, 1050);overflow:var(--ran-dropdown-overflow, hidden);font-variant:var(--ran-dropdown-font-variant, initial);background:var(--ran-dropdown-background, #ffffff);border-radius:var(--ran-dropdown-border-radius, 8px);outline:var(--ran-dropdown-outline, none);box-shadow:var(--ran-dropdown-box-shadow, 0 6px 16px 0 rgba(0, 0, 0, .08), 0 3px 6px -4px rgba(0, 0, 0, .12), 0 9px 28px 8px rgba(0, 0, 0, .05));cursor:var(--ran-dropdown-cursor, pointer);width:var(--ran-dropdown-width, 100%)}.ranui-dropdown-container{position:var(--ran-dropdown-container-position, relative);display:var(--ran-dropdown-container-display, inline-block);width:var(--ran-dropdown-container-width, 100%);min-width:var(--ran-popover-width)}.ranui-dropdown-container .top{transform:translate(calc(var(--ran-popover-width) / 2 - 8px)) translateY(-16px) rotate(0);top:0}.ranui-dropdown-container .bottom{transform:translate(calc(var(--ran-popover-width) / 2 - 8px)) translateY(0) rotate(180deg);top:calc(var(--ran-popover-height) - 4px,0px)}.ranui-dropdown-arrow{position:var(--ran-dropdown-arrow-position, absolute);z-index:var(--ran-dropdown-arrow-z-index, 1);display:var(--ran-dropdown-arrow-display, block);pointer-events:var(--ran-dropdown-arrow-pointer-events, none);width:var(--ran-dropdown-arrow-width, 16px);height:var(--ran-dropdown-arrow-height, 16px);overflow:var(--ran-dropdown-arrow-overflow, hidden)}.ranui-dropdown-arrow:before{background:var(--ran-dropdown-arrow-before-background, #fff);position:var(--ran-dropdown-arrow-before-position, absolute);bottom:var(--ran-dropdown-arrow-before-bottom, 0);inset-inline-start:0;width:var(--ran-dropdown-arrow-before-width, 16px);height:var(--ran-dropdown-arrow-before-height, 8px );clip-path:path("M 0 8 A 4 4 0 0 0 2.82842712474619 6.82842712474619 L 6.585786437626905 3.0710678118654755 A 2 2 0 0 1 9.414213562373096 3.0710678118654755 L 13.17157287525381 6.82842712474619 A 4 4 0 0 0 16 8 Z");content:var(--ran-dropdown-arrow-before-content, "")}.ranui-dropdown-arrow:after{content:var(--ran-dropdown-arrow-after-content, "");position:var(--ran-dropdown-arrow-after-position, absolute);width:var(--ran-dropdown-arrow-after-width, 9px);height:var(--ran-dropdown-arrow-after-height, 9px);bottom:var(--ran-dropdown-arrow-after-bottom, 0);inset-inline:0;margin:var(--ran-dropdown-arrow-after-margin, auto);border-radius:var(--ran-dropdown-arrow-after-border-radius, 0 0 2px 0);transform:var(--ran-dropdown-arrow-after-transform, translateY(50%) rotate(-135deg));box-shadow:var(--ran-dropdown-arrow-after-box-shadow, 2px 2px 5px rgba(0, 0, 0, .05));z-index:var(--ran-dropdown-arrow-after-z-index, 0);background:var(--ran-dropdown-arrow-after-background, transparent)}',Po=300;class Oo extends Fe(){constructor(){super(),St(this,"dropdown"),St(this,"_slot"),St(this,"_shadowDom"),St(this,"arrowIcon"),St(this,"container"),St(this,"handlerTransit",()=>{this.transit&&(Re(this.dropdown.element,this.transit),setTimeout(()=>{Ve(this.dropdown.element,this.transit)},Po))}),St(this,"handlerArrow",()=>{this.arrow&&(this.arrowIcon||(this.arrowIcon=z("div").setAttribute("class",`ranui-dropdown-arrow ${this.arrow}`),this.container.addChild([this.arrowIcon])))}),St(this,"stopPropagation",f=>{f.stopPropagation()}),this._slot=z("slot").setAttribute("class","slot"),this.dropdown=z("div").setStyle("-webkit-tap-highlight-color","transparent").setStyle("outline","0").setAttribute("class","ranui-dropdown").setAttribute("part","ranui-dropdown").addChild([this._slot]),this.container=z("div").setAttribute("class","ranui-dropdown-container").addChild([this.dropdown]);const h=this.attachShadow({mode:"closed"}),p=document.createElement("style");p.textContent=Dc,h.appendChild(p),this._shadowDom=h,h.appendChild(this.container.element)}static get observedAttributes(){return["transit","arrow"]}get transit(){return this.getAttribute("transit")||""}set transit(h){h?this.setAttribute("transit",h):this.removeAttribute("transit")}get arrow(){return this.getAttribute("arrow")||""}set arrow(h){h?this.setAttribute("arrow",h):this.removeAttribute("arrow")}get show(){return this.getAttribute("show")||""}set show(h){h?this.setAttribute("show",h):this.removeAttribute("show")}connectedCallback(){this.handlerTransit(),this.handlerArrow()}disconnectedCallback(){}attributeChangedCallback(h,p,f){h==="transit"&&f&&(Re(this.dropdown.element,this.transit),setTimeout(()=>{Ve(this.dropdown.element,this.transit)},Po)),h==="arrow"&&this.handlerArrow()}}function Rc(){return typeof document<"u"&&!customElements.get("r-dropdown")?(customElements.define("r-dropdown",Oo),Oo):Ie("document is undefined or r-dropdown is exist")}Rc();var Ic=Object.defineProperty,Pc=(k,h,p)=>h in k?Ic(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,se=(k,h,p)=>Pc(k,typeof h!="symbol"?h+"":h,p);const Oc='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}r-select{position:var(--ran-select, relative);width:var(--ran-select, 120px);height:var(--ran-select, 40px)}:host{position:var(--ran-select-host, relative);display:var(--ran-select-host, inline-block);cursor:var(--ran-select-host, pointer);height:var(--ran-select-host, 32px);outline:var(--ran-select-host, 0);-webkit-tap-highlight-color:var(--ran-select-host-highlight-color, transparent)}:host,:host(:focus),:host(:active){outline:var(--ran-select-host-focus-outline, 0);-webkit-tap-highlight-color:transparent}:host ::slotted(r-option){display:none}:host([disabled]){cursor:var(--ran-select-host-disabled-cursor, not-allowed);pointer-events:var(--ran-select-host-disabled-pointer-events, all);opacity:var(--ran-select-host-disabled-opacity, .6)}:host([type="text"])::part(selection){border:none}:host([type="text"])::part(icon){display:none}:host(:not([disabled]):hover) .select{cursor:var(--ran-select-host-hover-cursor, pointer)}:host(:not([disabled]):hover) .selection{border:var(--ran-select-host-selection-border, 1px solid #1890ff)}:host(:not([disabled]):hover) .selection-search{cursor:var(--ran-select-host-selection-search-cursor, pointer)}:host(:not([disabled]):hover) .selection-item{cursor:var(--ran-select-host-selection-item-cursor, pointer);color:var(--ran-select-host-selection-item-color, #bfbfbf)}:host(:not([disabled]):focus) .selection{border:var(--ran-select-host-selection-focus-border, 1px solid #1890ff)}:host(:not([disabled]):focus) .selection-search{cursor:var(--ran-select-host-selection-focus-search-cursor, pointer)}:host(:not([disabled]):focus) .selection-item{cursor:var(--ran-select-host-selection-focus-item-cursor, pointer);color:var(--ran-select-host-selection-focus-item-color, #bfbfbf)}:host .selection-search{display:var(--ran-select-host-selection-search-display, none)}:host([showSearch]:not([disabled])) .selection-search{cursor:var(--ran-select-host-showSearch-selection-search-cursor, text);display:var(--ran-select-host-showSearch-selection-search-display, block)}:host([showSearch]:not([disabled])) .selection-item{cursor:var(--ran-select-host-showSearch-selection-item-cursor, pointer)}:host([showSearch]:not([disabled]):focus) .selection-search{display:var(--ran-select-host-showSearch-selection-search-display, block);cursor:var(--ran-select-host-showSearch-selection-search-cursor, text);opacity:var(--ran-select-host-showSearch-selection-search-opacity, 1)}.ran-select{width:var(--ran-select-width, 100%);height:var(--ran-select-width, 100%);font-size:var(--ran-select-font-size, 14px);box-sizing:var(--ran-select-box-sizing, border-box);margin:var(--ran-select-margin, 0);padding:var(--ran-select-padding, 0);color:var(--ran-select-color, rgba(0, 0, 0, .88));line-height:var(--ran-select-line-height, 1.57142857);list-style:var(--ran-select-list-style, none);font-family:var(--ran-select-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");position:var(--ran-select-position, relative);display:var(--ran-select-display, inline-block)}.ran-select .selection{position:var(--ran-select-selection-position, relative);background-color:var(--ran-select-selection-background-color, #ffffff);border:var(--ran-select-selection-border, 1px solid #d9d9d9);transition:var(--ran-select-selection-transition, all .2s cubic-bezier(.645, .045, .355, 1));width:var(--ran-select-selection-width, 100%);height:var(--ran-select-selection-height, 100%);padding:var(--ran-select-selection-padding, 0 11px);box-sizing:var(--ran-select-selection-box-sizing, border-box);margin:var(--ran-select-selection-margin, 0);color:var(--ran-select-selection-color, rgba(0, 0, 0, .88));font-size:var(--ran-select-selection-font-size, 14px);line-height:var(--ran-select-selection-line-height, 1.57142857);list-style:var(--ran-select-selection-list-style, none);font-family:var(--ran-select-selection-font-family, inherit);display:var(--ran-select-selection-display, flex);border-radius:var(--ran-select-selection-border-radius, 6px)}.ran-select .selection-search{position:var(--ran-select-selection-search-position, absolute);opacity:var(--ran-select-selection-search-opacity, 0);top:var(--ran-select-selection-search-top, 0);left:var(--ran-select-selection-search-left, 0);height:var(--ran-select-selection-search-height, 100%);inset-inline-start:var(--ran-select-selection-search-inset-inline-start, 11px);inset-inline-end:var(--ran-select-selection-search-inset-inline-end, 11px);margin:var(--ran-select-selection-search-margin, 0);padding:var(--ran-select-selection-search-padding, 0);background:var(--ran-select-selection-search-background, transparent);border:var(--ran-select-selection-search-border, none);outline:var(--ran-select-selection-search-outline, none);-webkit-appearance:var(--ran-select-selection-search-appearance, none);-moz-appearance:var(--ran-select-selection-search-appearance, none);appearance:var(--ran-select-selection-search-appearance, none);font-family:var(--ran-select-selection-search-font-family, inherit);cursor:var(--ran-select-selection-search-cursor, not-allowed)}.ran-select .selection-search::-webkit-search-cancel-button{display:none;-webkit-appearance:none}.ran-select .selection-search::part(ran-input){border:none;padding:0;height:100%;outline:none}.ran-select .selection-search::part(ran-input):active{border:none;padding:0;height:100%;outline:none;border-color:transparent;box-shadow:none;border-right-width:0px}.ran-select .selection-item{position:var(--ran-select-selection-item-position, absolute);top:var(--ran-select-selection-item-top, 0);left:var(--ran-select-selection-item-left, 12px);margin:var(--ran-select-selection-item-margin, 0);padding:var(--ran-select-selection-item-padding, 0);background:var(--ran-select-selection-item-background, transparent);border:var(--ran-select-selection-item-border, none);outline:var(--ran-select-selection-item-outline, none);-webkit-appearance:var(--ran-select-selection-item-appearance, none);-moz-appearance:var(--ran-select-selection-item-appearance, none);appearance:var(--ran-select-selection-item-appearance, none);font-family:var(--ran-select-selection-item-font-family, inherit);height:var(--ran-select-selection-item-height, 100%);-webkit-user-select:var(--ran-select-selection-item-user-select, none);user-select:var(--ran-select-selection-item-user-select, none);overflow:var(--ran-select-selection-item-overflow, hidden);white-space:var(--ran-select-selection-item-white-space, nowrap);text-overflow:var(--ran-select-selection-item-text-overflow, ellipsis);cursor:var(--ran-select-selection-item-cursor, pointer)}.ran-select .selection-select{color:var(--ran-select-selection-select-color, rgba(0, 0, 0, .25))}.ran-select .selection .icon{display:var(--ran-select-selection-icon-display, flex);align-items:var(--ran-select-selection-icon-align-items, center);color:var(--ran-select-selection-icon-color, rgba(0, 0, 0, .25));font-style:var(--ran-select-selection-icon-font-style, normal);text-align:var(--ran-select-selection-icon-text-align, center);text-transform:var(--ran-select-selection-icon-text-transform, none);text-rendering:var(--ran-select-selection-icon-text-rendering, optimizeLegibility);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;position:var(--ran-select-selection-icon-position, absolute);top:var(--ran-select-selection-icon-top, 50%);inset-inline-start:var(--ran-select-selection-icon-inset-inline-start, auto);inset-inline-end:var(--ran-select-selection-icon-inset-inline-end, 8px);height:var(--ran-select-selection-icon-height, 12px);margin-top:var(--ran-select-selection-icon-margin-top, -3px);font-size:var(--ran-select-selection-icon-font-size, 12px);pointer-events:var(--ran-select-selection-icon-color, pointer-events)}';function Mc(){if(typeof document<"u"&&!customElements.get("r-option")){class k extends HTMLElement{constructor(){super(),se(this,"_option"),se(this,"_optionContent"),se(this,"_shadowDom"),se(this,"_slot"),this._slot=document.createElement("slot"),this._option=document.createElement("div"),this._option.setAttribute("class","ran-option"),this._optionContent=document.createElement("div"),this._optionContent.setAttribute("class","ran-option-content"),this._optionContent.appendChild(this._slot),this._option.appendChild(this._optionContent);const p=this.attachShadow({mode:"closed"});this._shadowDom=p,p.appendChild(this._option)}static get observedAttributes(){return["disabled","sheet","value"]}get value(){return this.getAttribute("value")}set value(p){this.setAttribute("value",p||"")}get sheet(){return this.getAttribute("sheet")}set sheet(p){this.setAttribute("sheet",p||"")}get disabled(){return Ce(this)}set disabled(p){!p||p==="false"?this.removeAttribute("disabled"):this.setAttribute("disabled","")}handlerExternalCss(){if(this.sheet)try{const p=new CSSStyleSheet;p.insertRule(this.sheet),this._shadowDom.adoptedStyleSheets=[p]}catch{console.error(`Failed to parse the rule in CSSStyleSheet: ${this.sheet}`)}}connectedCallback(){}disconnectCallback(){}attributeChangedCallback(p,f,w){p==="disabled"&&this._option&&(!w||w==="false"?this._option.setAttribute("disabled",""):this._option.removeAttribute("disabled")),p==="sheet"&&this._shadowDom&&f!==w&&this.handlerExternalCss()}}return k}else return Ie("document is undefined or r-option is exist")}Mc();const Fc='.remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}.ranui-dropdown-option-item{position:var(--ran-dropdown-option-item-position, relative);display:var(--ran-dropdown-option-item-display, block);padding:var(--ran-dropdown-option-item-padding, 5px 12px);color:var(--ran-dropdown-option-item-color, rgba(0, 0, 0, .88));font-weight:var(--ran-dropdown-option-item-font-weight, normal);font-size:var(--ran-dropdown-option-item-font-size, 14px);transition:var(--ran-dropdown-option-item-transition, background .3s ease);border-radius:var(--ran-dropdown-option-item-border-radius, 4px)}.ranui-dropdown-option-item:hover{background-color:var(--ran-dropdown-option-item-hover-background-color, rgba(0, 0, 0, .04))}.ranui-dropdown-option-item-content{text-align:var(--ran-dropdown-content-text-align, left);overflow:var(--ran-dropdown-content-overflow, hidden);white-space:var(--ran-dropdown-content-white-space, nowrap);text-overflow:var(--ran-dropdown-content-text-overflow, ellipsis);color:var(--ran-dropdown-content-color, rgba(0, 0, 0, .88));font-size:var(--ran-dropdown-content-font-size, 14px);line-height:var(--ran-dropdown-content-line-height, 1.57142857);box-sizing:var(--ran-dropdown-content-box-sizing, border-box);list-style:var(--ran-dropdown-content-list-style, none);font-family:var(--ran-dropdown-content-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-variant:var(--ran-dropdown-content-font-variant, initial)}.ranui-dropdown-option-active{background-color:var(--ran-dropdown-option-active-background-color, #e6f7ff);font-weight:var(--ran-dropdown-option-active-font-weight, bold)}.ranui-dropdown-option-active:hover{background-color:var(--ran-dropdown-option-active-hover-background-color, #e6f7ff)}';class Mo extends Fe(){constructor(){super(),se(this,"ionDropdownItem"),se(this,"_slot"),se(this,"_shadowDom"),se(this,"ionDropdownItemContent"),this._slot=z("slot").setAttribute("class","slot"),this.ionDropdownItemContent=z("div").setAttribute("class","ranui-dropdown-option-item-content").setAttribute("part","ranui-dropdown-option-item-content").addChild(this._slot),this.ionDropdownItem=z("div").setAttribute("class","ranui-dropdown-option-item").setAttribute("part","ranui-dropdown-option-item").addChild([this.ionDropdownItemContent]);const h=this.attachShadow({mode:"closed"});this._shadowDom=h;const p=z("style").setTextContent(Fc);h.appendChild(p.element),h.appendChild(this.ionDropdownItem.element)}static get observedAttributes(){return["active","value","title"]}get value(){return this.getAttribute("value")||""}set value(h){!Ce(this)&&h?this.setAttribute("value",h):this.removeAttribute("value")}get active(){return this.getAttribute("active")||""}set active(h){h?this.setAttribute("active",h):this.removeAttribute("active")}get title(){return this.getAttribute("title")||""}set title(h){h?this.setAttribute("title",h):this.removeAttribute("title")}connectedCallback(){this.active&&Re(this.ionDropdownItem.element,"ranui-dropdown-option-active")}attributeChangedCallback(h,p,f){h==="active"&&f?Re(this.ionDropdownItem.element,"ranui-dropdown-option-active"):Ve(this.ionDropdownItem.element,"ranui-dropdown-option-active")}}function Bc(){return typeof document<"u"&&!customElements.get("r-dropdown-item")?(customElements.define("r-dropdown-item",Mo),Mo):Ie("document is undefined or r-dropdown-item is exist")}Bc();const Fo={bottom:{add:"ran-dropdown-down-in",remove:"ran-dropdown-down-out"},top:{add:"ran-dropdown-up-in",remove:"ran-dropdown-up-out"}},Nc=Zi(),Bo=300;let pn=class extends Fe(){constructor(){super(),se(this,"removeTimeId"),se(this,"_slot"),se(this,"_shadowDom"),se(this,"_select"),se(this,"_selection"),se(this,"_search"),se(this,"_icon"),se(this,"_selectDropdown"),se(this,"_selectionDropdown"),se(this,"_selectDropDownInTimeId"),se(this,"_selectDropDownOutTimeId"),se(this,"_optionList"),se(this,"_optionLabelMapValue"),se(this,"_optionValueMapLabel"),se(this,"_activeOption"),se(this,"_text"),se(this,"_selector"),se(this,"onSearch"),se(this,"setSelectDropdownDisplayNone",()=>{this._selectDropDownOutTimeId||this._selectionDropdown&&this._selectionDropdown.style.display!=="none"&&(this._selectionDropdown.setAttribute("transit",Fo[this.placement].remove),this._selectDropDownOutTimeId=setTimeout(()=>{var f;(f=this._selectionDropdown)==null||f.style.setProperty("display","none"),this._selectionDropdown&&this._selectionDropdown.removeAttribute("transit"),clearTimeout(this._selectDropDownOutTimeId),this._selectDropDownOutTimeId=void 0},Bo))}),se(this,"setSelectDropdownDisplayBlock",()=>{var f;this._selectDropDownInTimeId||this._selectionDropdown&&this._selectionDropdown.style.display!=="block"&&(this._selectionDropdown.setAttribute("transit",Fo[this.placement].add),(f=this._selectionDropdown)==null||f.style.setProperty("display","block"),this._selectDropDownInTimeId=setTimeout(()=>{this._selectionDropdown&&this._selectionDropdown.removeAttribute("transit"),clearTimeout(this._selectDropDownInTimeId),this._selectDropDownInTimeId=void 0},Bo))}),se(this,"placementPosition",()=>{if(!this._selectionDropdown||!this._selectDropdown)return;const f=this.getBoundingClientRect(),{top:w,left:x,bottom:T,width:D,height:G,x:F,y:q,right:j}=f,de=document.getElementById(this.getPopupContainerId);this._selectionDropdown.style.setProperty("position","absolute"),this._selectionDropdown.style.setProperty("--ran-x",`${w+window.scrollX}`),this._selectionDropdown.style.setProperty("--ran-y",`${x+window.scrollY}`);let te=T+window.scrollY,le=x+window.scrollX;if(this._selectionDropdown.style.setProperty("width",`${D}px`),this.placement==="top"&&(te=w+window.scrollY-this._selectionDropdown.clientHeight),this.getPopupContainerId&&de){const ce=de.getBoundingClientRect();le=x-ce.left,this.placement==="top"?te=w-de.getBoundingClientRect().top-this._selectionDropdown.clientHeight:te=de.getBoundingClientRect().height}this._selectionDropdown.style.setProperty("inset",`${te}px auto auto ${le}px`)}),se(this,"selectMouseDown",f=>{f.stopPropagation(),!Ce(this)&&(this.removeDropDownTimeId(f),this.setSelectDropdownDisplayNone(),this.setSelectDropdownDisplayBlock(),this.placementPosition())}),se(this,"removeDropDownTimeId",f=>{f.stopPropagation(),this._search.setAttribute("value",""),this.trigger.includes("hover")&&!_t()&&(clearTimeout(this.removeTimeId),this.removeTimeId=void 0)}),se(this,"selectBlur",f=>{f.stopPropagation(),this.removeTimeId&&this.removeDropDownTimeId(f),this.removeTimeId=setTimeout(()=>{this.removeDropDownTimeId(f),this.setSelectDropdownDisplayNone()},300)}),se(this,"clickOption",f=>{f.stopPropagation();const w=f.target,x=w.innerHTML,T=this._optionLabelMapValue.get(x);T&&(this.setAttribute("value",T),this._text.innerHTML=x,this._text.setAttribute("title",x),this._search.setAttribute("placeholder",x));const D=this.getBoundingClientRect(),{height:G}=D;this._text.style.setProperty("line-height",`${G}px`),this._activeOption&&this._activeOption.removeAttribute("active"),this._activeOption=w,this._activeOption&&this._activeOption.setAttribute("active",T||""),this.setSelectDropdownDisplayNone(),this.dispatchEvent(new CustomEvent("change",{detail:{value:T,label:x}})),this.removeDropDownTimeId(f)}),se(this,"createOption",()=>{if(!this._selectDropdown){const f=document.getElementById(this.getPopupContainerId)||document.body;this._selectDropdown=document.createElement("div"),this._selectDropdown.style.setProperty("-webkit-tap-highlight-color","transparent"),this._selectDropdown.style.setProperty("outline","0"),this._selectDropdown.addEventListener("click",this.clickOption),this._selectionDropdown=document.createElement("r-dropdown"),this.dropdownclass&&this._selectionDropdown.setAttribute("class",this.dropdownclass),this.trigger.includes("hover")&&!_t()&&(this._selectDropdown.addEventListener("mouseleave",this.selectBlur),this._selectDropdown.addEventListener("mouseenter",this.removeDropDownTimeId)),this._selectDropdown.appendChild(this._selectionDropdown),this._selectionDropdown.style.setProperty("display","none"),f.appendChild(this._selectDropdown)}}),se(this,"removeSelectDropdown",()=>{try{this._selectDropdown&&(document.getElementById(this.getPopupContainerId)||document.body).removeChild(this._selectDropdown)}catch{}}),se(this,"addOptionToSlot",()=>{this._slot.assignedElements().forEach(w=>{var x;if(w.tagName!=="R-OPTION")return;const T=w.innerHTML,D=w.getAttribute("value")||"";(x=this._optionList)==null||x.push({label:T,value:D}),this._optionLabelMapValue.get(T)&&console.warn(`${T} is repeat option`),this._optionValueMapLabel.get(D)&&console.warn(`${D} is repeat option`),this._optionLabelMapValue.set(T,D),this._optionValueMapLabel.set(D,T)}),this.createSelectDropdownContent(this._optionList)}),se(this,"createSelectDropdownContent",(f=[])=>{var w,x;f.length===0?(w=this._selectDropdown)==null||w.style.setProperty("display","none"):(x=this._selectDropdown)==null||x.style.setProperty("display","block"),f.forEach(T=>{if(this._selectionDropdown){const{label:D,value:G}=T,F=document.createElement("r-dropdown-item");(this.getAttribute("defaultValue")||this.getAttribute("value"))===G?(F.setAttribute("active",G),this._activeOption=F):F.removeAttribute("active"),F.innerHTML=`${D}`,F.setAttribute("value",`${G}`),F.setAttribute("title",`${D}`),this._selectionDropdown.appendChild(F)}}),this.setDefaultValue()}),se(this,"setDefaultValue",()=>{const f=this.getAttribute("defaultValue")||this.getAttribute("value");if(!f)return;const w=this._optionValueMapLabel.get(f);if(!w)return;this.setAttribute("value",f);const x=this.getBoundingClientRect(),{height:T}=x;this._text.style.setProperty("line-height",`${T}px`),this._text.innerHTML=w,this._text.setAttribute("title",w)}),se(this,"changeSearch",f=>{const w=f.detail.value||"";if(this.dispatchEvent(new CustomEvent("search",{detail:{value:w}})),this._selectionDropdown&&(this._selectionDropdown.innerHTML=""),w.length>0){const x=this._optionList.map(T=>{const{label:D}=T;if(`${D}`.toLowerCase().includes(w))return{label:D,value:T.value}}).filter(T=>T);this.createSelectDropdownContent(x)}else this.createSelectDropdownContent(this._optionList)}),se(this,"setShowSearch",()=>{this.onSearch=Nc(this.changeSearch),this.onSearch&&this._search.addEventListener("change",this.onSearch),this.onSearch&&this._search.addEventListener("click",this.onSearch)}),se(this,"removeShowSearch",()=>{this.onSearch&&this._search.removeEventListener("change",this.onSearch),this.onSearch&&this._search.removeEventListener("click",this.onSearch)}),se(this,"listenSlotChange",()=>{this._slot.addEventListener("slotchange",this.addOptionToSlot)}),se(this,"removeListenSlotChange",()=>{this._slot.removeEventListener("slotchange",this.addOptionToSlot)}),se(this,"listenActionEvent",()=>{this.removeEventListener("mouseenter",this.selectMouseDown),this.removeEventListener("mouseleave",this.selectBlur),this.removeEventListener("click",this.selectMouseDown),this.removeEventListener("blur",this.selectBlur),this.trigger.includes("hover")&&!_t()&&(this.addEventListener("mouseenter",this.selectMouseDown),this.addEventListener("mouseleave",this.selectBlur)),this.trigger.includes("click")&&(this.addEventListener("click",this.selectMouseDown),this.addEventListener("blur",this.selectBlur))}),se(this,"clickRemoveSelect",f=>{f.stopPropagation(),this.setSelectDropdownDisplayNone()}),this._slot=document.createElement("slot"),this._select=document.createElement("div"),this._select.setAttribute("class","ran-select"),this._select.setAttribute("part","select"),this._selection=document.createElement("div"),this._selection.setAttribute("class","selection"),this._selection.setAttribute("part","selection"),this._selector=document.createElement("div"),this._search=document.createElement("r-input"),this._search.setAttribute("class","selection-search"),this._search.setAttribute("part","search"),this._search.setAttribute("type","search"),this._search.setAttribute("autocomplete","off"),this._text=document.createElement("span"),this._text.setAttribute("class","selection-item"),this._text.setAttribute("part","selection-item"),this._icon=document.createElement("ra-icon"),this._icon.setAttribute("class","icon"),this._icon.setAttribute("part","icon"),this._icon.setAttribute("name","arrow-down"),this._icon.setAttribute("color","#d9d9d9"),this._icon.setAttribute("size","16"),this._selector.appendChild(this._text),this._selector.appendChild(this._search),this._selection.appendChild(this._icon),this._selection.appendChild(this._selector),this._slot.setAttribute("class","slot"),this._select.appendChild(this._selection),this._select.appendChild(this._slot),this._optionList=[],this._optionLabelMapValue=new Map,this._optionValueMapLabel=new Map;const h=this.attachShadow({mode:"closed"}),p=document.createElement("style");p.textContent=Oc,h.appendChild(p),this._shadowDom=h,this._shadowDom.appendChild(this._select)}static get observedAttributes(){return["disabled","sheet","clear","type","defaultValue","showSearch","placement","getPopupContainerId","dropdownclass","trigger"]}get value(){return this.getAttribute("value")||""}set value(h){!Ce(this)&&h?this.setAttribute("value",h):this.removeAttribute("value")}get defaultValue(){return this.getAttribute("defaultValue")||""}set defaultValue(h){this.setAttribute("defaultValue",h||"")}get showSearch(){return this.getAttribute("showSearch")||""}set showSearch(h){this.setAttribute("showSearch",h||"")}get type(){return this.getAttribute("type")||""}set type(h){this.setAttribute("type",h||"")}get placement(){return this.getAttribute("placement")||"bottom"}set placement(h){this.setAttribute("placement",h||"")}get sheet(){return this.getAttribute("sheet")||""}set sheet(h){this.setAttribute("sheet",h||"")}get getPopupContainerId(){return this.getAttribute("getPopupContainerId")||""}set getPopupContainerId(h){this.setAttribute("getPopupContainerId",h||"")}get dropdownclass(){return this.getAttribute("dropdownclass")||""}set dropdownclass(h){this.setAttribute("dropdownclass",h||"")}get trigger(){return this.getAttribute("trigger")||"click"}set trigger(h){this.setAttribute("trigger",h||"")}get disabled(){return Ce(this)}set disabled(h){!h||h==="false"?(this.removeAttribute("disabled"),this._selection.removeAttribute("disabled")):(this.setAttribute("disabled",""),this._selection.setAttribute("disabled",""))}handlerExternalCss(){if(this.sheet)try{const h=new CSSStyleSheet;h.insertRule(this.sheet),this._shadowDom.adoptedStyleSheets=[h]}catch{console.error(`Failed to parse the rule in CSSStyleSheet: ${this.sheet}`)}}connectedCallback(){this.handlerExternalCss(),this.createOption(),this.listenActionEvent(),this.listenSlotChange(),this.setShowSearch(),document.addEventListener("click",this.clickRemoveSelect)}disconnectCallback(){var h;this.removeEventListener("mouseenter",this.selectMouseDown),this.removeEventListener("mouseleave",this.selectBlur),this.removeEventListener("click",this.selectMouseDown),this.removeEventListener("blur",this.selectBlur),this.removeSelectDropdown(),(h=this._selectDropdown)==null||h.removeEventListener("click",this.clickOption),this.removeListenSlotChange(),document.removeEventListener("click",this.clickRemoveSelect)}attributeChangedCallback(h,p,f){h==="disabled"&&this._select&&(!f||f==="false"?(this._select.setAttribute("disabled",""),this._selection.setAttribute("disabled","")):(this._select.removeAttribute("disabled"),this._selection.removeAttribute("disabled"))),h==="sheet"&&this._shadowDom&&p!==f&&this.handlerExternalCss()}};function Uc(){return typeof document<"u"&&!customElements.get("r-select")?(customElements.define("r-select",pn),pn):Ie("document is undefined or r-select is exist")}const Gc=Uc(),Hc=Object.freeze(Object.defineProperty({__proto__:null,Select:pn,default:Gc},Symbol.toStringTag,{value:"Module"}));var Kc=Object.defineProperty,Vc=(k,h,p)=>h in k?Kc(k,h,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[h]=p,H=(k,h,p)=>Vc(k,typeof h!="symbol"?h+"":h,p);(function k(h){var p,f;p=this,f=function(){function w(o,n){var e=Object.keys(o);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(o);n&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(o,i).enumerable})),e.push.apply(e,t)}return e}function x(o){for(var n=1;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function le(o,n,e){return le=te()?Reflect.construct.bind():function(t,i,r){var a=[null];a.push.apply(a,i);var s=new(Function.bind.apply(t,a));return r&&de(s,r.prototype),s},le.apply(null,arguments)}function ce(o){var n=typeof Map=="function"?new Map:void 0;return ce=function(e){if(e===null||(t=e,Function.toString.call(t).indexOf("[native code]")===-1))return e;var t;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(n!==void 0){if(n.has(e))return n.get(e);n.set(e,i)}function i(){return le(e,arguments,j(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),de(i,e)},ce(o)}function Pe(o,n){(n==null||n>o.length)&&(n=o.length);for(var e=0,t=new Array(n);e=o.length?{done:!0}:{done:!1,value:o[t++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function qe(o){var n=function(e,t){if(typeof e!="object"||e===null)return e;var i=e[Symbol.toPrimitive];if(i!==void 0){var r=i.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}(o,"string");return typeof n=="symbol"?n:String(n)}function ei(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var _n={exports:{}};(function(o,n){var e,t,i,r,a;e=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,t=/^(?=([^\/?#]*))\1([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,r=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(s,l,d){if(d=d||{},s=s.trim(),!(l=l.trim())){if(!d.alwaysNormalize)return s;var c=a.parseURL(s);if(!c)throw new Error("Error trying to parse base URL.");return c.path=a.normalizePath(c.path),a.buildURLFromParts(c)}var u=a.parseURL(l);if(!u)throw new Error("Error trying to parse relative URL.");if(u.scheme)return d.alwaysNormalize?(u.path=a.normalizePath(u.path),a.buildURLFromParts(u)):l;var g=a.parseURL(s);if(!g)throw new Error("Error trying to parse base URL.");if(!g.netLoc&&g.path&&g.path[0]!=="/"){var m=t.exec(g.path);g.netLoc=m[1],g.path=m[2]}g.netLoc&&!g.path&&(g.path="/");var v={scheme:g.scheme,netLoc:u.netLoc,path:null,params:u.params,query:u.query,fragment:u.fragment};if(!u.netLoc&&(v.netLoc=g.netLoc,u.path[0]!=="/"))if(u.path){var y=g.path,_=y.substring(0,y.lastIndexOf("/")+1)+u.path;v.path=a.normalizePath(_)}else v.path=g.path,u.params||(v.params=g.params,u.query||(v.query=g.query));return v.path===null&&(v.path=d.alwaysNormalize?a.normalizePath(u.path):u.path),a.buildURLFromParts(v)},parseURL:function(s){var l=e.exec(s);return l?{scheme:l[1]||"",netLoc:l[2]||"",path:l[3]||"",params:l[4]||"",query:l[5]||"",fragment:l[6]||""}:null},normalizePath:function(s){for(s=s.split("").reverse().join("").replace(i,"");s.length!==(s=s.replace(r,"")).length;);return s.split("").reverse().join("")},buildURLFromParts:function(s){return s.scheme+s.netLoc+s.path+s.params+s.query+s.fragment}},o.exports=a})(_n);var er=_n.exports,ie=Number.isFinite||function(o){return typeof o=="number"&&isFinite(o)},A=function(o){return o.MEDIA_ATTACHING="hlsMediaAttaching",o.MEDIA_ATTACHED="hlsMediaAttached",o.MEDIA_DETACHING="hlsMediaDetaching",o.MEDIA_DETACHED="hlsMediaDetached",o.BUFFER_RESET="hlsBufferReset",o.BUFFER_CODECS="hlsBufferCodecs",o.BUFFER_CREATED="hlsBufferCreated",o.BUFFER_APPENDING="hlsBufferAppending",o.BUFFER_APPENDED="hlsBufferAppended",o.BUFFER_EOS="hlsBufferEos",o.BUFFER_FLUSHING="hlsBufferFlushing",o.BUFFER_FLUSHED="hlsBufferFlushed",o.MANIFEST_LOADING="hlsManifestLoading",o.MANIFEST_LOADED="hlsManifestLoaded",o.MANIFEST_PARSED="hlsManifestParsed",o.LEVEL_SWITCHING="hlsLevelSwitching",o.LEVEL_SWITCHED="hlsLevelSwitched",o.LEVEL_LOADING="hlsLevelLoading",o.LEVEL_LOADED="hlsLevelLoaded",o.LEVEL_UPDATED="hlsLevelUpdated",o.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",o.LEVELS_UPDATED="hlsLevelsUpdated",o.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",o.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",o.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",o.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",o.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",o.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",o.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",o.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",o.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",o.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",o.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",o.CUES_PARSED="hlsCuesParsed",o.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",o.INIT_PTS_FOUND="hlsInitPtsFound",o.FRAG_LOADING="hlsFragLoading",o.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",o.FRAG_LOADED="hlsFragLoaded",o.FRAG_DECRYPTED="hlsFragDecrypted",o.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",o.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",o.FRAG_PARSING_METADATA="hlsFragParsingMetadata",o.FRAG_PARSED="hlsFragParsed",o.FRAG_BUFFERED="hlsFragBuffered",o.FRAG_CHANGED="hlsFragChanged",o.FPS_DROP="hlsFpsDrop",o.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",o.ERROR="hlsError",o.DESTROYING="hlsDestroying",o.KEY_LOADING="hlsKeyLoading",o.KEY_LOADED="hlsKeyLoaded",o.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",o.BACK_BUFFER_REACHED="hlsBackBufferReached",o}({}),ne=function(o){return o.NETWORK_ERROR="networkError",o.MEDIA_ERROR="mediaError",o.KEY_SYSTEM_ERROR="keySystemError",o.MUX_ERROR="muxError",o.OTHER_ERROR="otherError",o}({}),O=function(o){return o.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",o.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",o.KEY_SYSTEM_NO_SESSION="keySystemNoSession",o.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",o.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",o.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",o.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",o.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",o.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",o.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",o.MANIFEST_LOAD_ERROR="manifestLoadError",o.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",o.MANIFEST_PARSING_ERROR="manifestParsingError",o.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",o.LEVEL_EMPTY_ERROR="levelEmptyError",o.LEVEL_LOAD_ERROR="levelLoadError",o.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",o.LEVEL_PARSING_ERROR="levelParsingError",o.LEVEL_SWITCH_ERROR="levelSwitchError",o.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",o.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",o.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",o.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",o.FRAG_LOAD_ERROR="fragLoadError",o.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",o.FRAG_DECRYPT_ERROR="fragDecryptError",o.FRAG_PARSING_ERROR="fragParsingError",o.FRAG_GAP="fragGap",o.REMUX_ALLOC_ERROR="remuxAllocError",o.KEY_LOAD_ERROR="keyLoadError",o.KEY_LOAD_TIMEOUT="keyLoadTimeOut",o.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",o.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",o.BUFFER_APPEND_ERROR="bufferAppendError",o.BUFFER_APPENDING_ERROR="bufferAppendingError",o.BUFFER_STALLED_ERROR="bufferStalledError",o.BUFFER_FULL_ERROR="bufferFullError",o.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",o.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",o.INTERNAL_EXCEPTION="internalException",o.INTERNAL_ABORTED="aborted",o.UNKNOWN="unknown",o}({}),Rt=function(){},tr={trace:Rt,debug:Rt,log:Rt,warn:Rt,info:Rt,error:Rt},ti=tr;function Qo(o){var n=self.console[o];return n?n.bind(self.console,"["+o+"] >"):Rt}function kn(o,n){if(self.console&&o===!0||typeof o=="object"){(function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;rNumber.MAX_SAFE_INTEGER?1/0:t},n.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var i=new Uint8Array(t.length/2),r=0;rNumber.MAX_SAFE_INTEGER?1/0:t},n.decimalFloatingPoint=function(e){return parseFloat(this[e])},n.optionalFloat=function(e,t){var i=this[e];return i?parseFloat(i):t},n.enumeratedString=function(e){return this[e]},n.bool=function(e){return this[e]==="YES"},n.decimalResolution=function(e){var t=Wo.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},o.parseAttrList=function(e){var t,i={};for(xn.lastIndex=0;(t=xn.exec(e))!==null;){var r=t[2];r.indexOf('"')===0&&r.lastIndexOf('"')===r.length-1&&(r=r.slice(1,-1)),i[t[1].trim()]=r}return i},o}();function Xo(o){return o==="SCTE35-OUT"||o==="SCTE35-IN"}var Tn=function(){function o(n,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){var t=e.attr;for(var i in t)if(Object.prototype.hasOwnProperty.call(n,i)&&n[i]!==t[i]){R.warn('DATERANGE tag attribute: "'+i+'" does not match for tags with ID: "'+n.ID+'"'),this._badValueForSameId=i;break}n=F(new _e({}),t,n)}if(this.attr=n,this._startDate=new Date(n["START-DATE"]),"END-DATE"in this.attr){var r=new Date(this.attr["END-DATE"]);ie(r.getTime())&&(this._endDate=r)}}return D(o,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var n=this.duration;return n!==null?new Date(this._startDate.getTime()+1e3*n):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var n=this.attr.decimalFloatingPoint("DURATION");if(ie(n))return n}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&ie(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),o}(),yi=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}},Be="audio",Ze="video",ir="audiovideo",Cn=function(){function o(n){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((e={})[Be]=null,e[Ze]=null,e[ir]=null,e),this.baseurl=n}return o.prototype.setByteRange=function(n,e){var t=n.split("@",2),i=[];t.length===1?i[0]=e?e.byteRangeEndOffset:0:i[0]=parseInt(t[1]),i[1]=parseInt(t[0])+i[0],this._byteRange=i},D(o,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=er.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(n){this._url=n}}]),o}(),rr=function(o){function n(t,i){var r;return(r=o.call(this,i)||this)._decryptdata=null,r.rawProgramDateTime=null,r.programDateTime=null,r.tagList=[],r.duration=0,r.sn=0,r.levelkeys=void 0,r.type=void 0,r.loader=null,r.keyLoader=null,r.level=-1,r.cc=0,r.startPTS=void 0,r.endPTS=void 0,r.startDTS=void 0,r.endDTS=void 0,r.start=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,r.stats=new yi,r.urlId=0,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.endList=void 0,r.gap=void 0,r.type=t,r}q(n,o);var e=n.prototype;return e.setKeyFormat=function(t){if(this.levelkeys){var i=this.levelkeys[t];i&&!this._decryptdata&&(this._decryptdata=i.getDecryptData(this.sn))}},e.abortRequests=function(){var t,i;(t=this.loader)==null||t.abort(),(i=this.keyLoader)==null||i.abort()},e.setElementaryStreamInfo=function(t,i,r,a,s,l){l===void 0&&(l=!1);var d=this.elementaryStreams,c=d[t];c?(c.startPTS=Math.min(c.startPTS,i),c.endPTS=Math.max(c.endPTS,r),c.startDTS=Math.min(c.startDTS,a),c.endDTS=Math.max(c.endDTS,s)):d[t]={startPTS:i,endPTS:r,startDTS:a,endDTS:s,partial:l}},e.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[Be]=null,t[Ze]=null,t[ir]=null},D(n,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{var i=Object.keys(this.levelkeys);if(i.length===1)return this._decryptdata=this.levelkeys[i[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!ie(this.programDateTime))return null;var t=ie(this.duration)?this.duration:0;return this.programDateTime+1e3*t}},{key:"encrypted",get:function(){var t;if((t=this._decryptdata)!=null&&t.encrypted)return!0;if(this.levelkeys){var i=Object.keys(this.levelkeys),r=i.length;if(r>1||r===1&&this.levelkeys[i[0]].encrypted)return!0}return!1}}]),n}(Cn),Jo=function(o){function n(e,t,i,r,a){var s;(s=o.call(this,i)||this).fragOffset=0,s.duration=0,s.gap=!1,s.independent=!1,s.relurl=void 0,s.fragment=void 0,s.index=void 0,s.stats=new yi,s.duration=e.decimalFloatingPoint("DURATION"),s.gap=e.bool("GAP"),s.independent=e.bool("INDEPENDENT"),s.relurl=e.enumeratedString("URI"),s.fragment=t,s.index=r;var l=e.enumeratedString("BYTERANGE");return l&&s.setByteRange(l,a),a&&(s.fragOffset=a.fragOffset+a.duration),s}return q(n,o),D(n,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),n}(Cn),Zo=function(){function o(n){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=n}return o.prototype.reloaded=function(n){if(!n)return this.advanced=!0,void(this.updated=!0);var e=this.lastPartSn-n.lastPartSn,t=this.lastPartIndex-n.lastPartIndex;this.updated=this.endSN!==n.endSN||!!t||!!e||!this.live,this.advanced=this.endSN>n.endSN||e>0||e===0&&t>0,this.updated||this.advanced?this.misses=Math.floor(.6*n.misses):this.misses=n.misses+1,this.availabilityDelay=n.availabilityDelay},D(o,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&ie(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var n=this.driftEndTime-this.driftStartTime;return n>0?1e3*(this.driftEnd-this.driftStart)/n:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var n;return(n=this.partList)!=null&&n.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var n;return(n=this.fragments)!=null&&n.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var n;return(n=this.partList)!=null&&n.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var n;return(n=this.partList)!=null&&n.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),o}();function nr(o){return Uint8Array.from(atob(o),function(n){return n.charCodeAt(0)})}function es(o){var n,e,t=o.split(":"),i=null;if(t[0]==="data"&&t.length===2){var r=t[1].split(";"),a=r[r.length-1].split(",");if(a.length===2){var s=a[0]==="base64",l=a[1];s?(r.splice(-1,1),i=nr(l)):(n=Sn(l).subarray(0,16),(e=new Uint8Array(16)).set(n,16-n.length),i=e)}}return i}function Sn(o){return Uint8Array.from(unescape(encodeURIComponent(o)),function(n){return n.charCodeAt(0)})}var Ee={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},ar="org.w3.clearkey",or="com.apple.streamingkeydelivery",wi="com.microsoft.playready",Ei="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function Ln(o){switch(o){case or:return Ee.FAIRPLAY;case wi:return Ee.PLAYREADY;case Ei:return Ee.WIDEVINE;case ar:return Ee.CLEARKEY}}var Dn="edef8ba979d64acea3c827dcd51d21ed";function Rn(o){switch(o){case Ee.FAIRPLAY:return or;case Ee.PLAYREADY:return wi;case Ee.WIDEVINE:return Ei;case Ee.CLEARKEY:return ar}}function sr(o){var n=o.drmSystems,e=o.widevineLicenseUrl,t=n?[Ee.FAIRPLAY,Ee.WIDEVINE,Ee.PLAYREADY,Ee.CLEARKEY].filter(function(i){return!!n[i]}):[];return!t[Ee.WIDEVINE]&&e&&t.push(Ee.WIDEVINE),t}var In=typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function It(o,n,e){return Uint8Array.prototype.slice?o.slice(n,e):new Uint8Array(Array.prototype.slice.call(o,n,e))}var lr,dr=function(o,n){return n+10<=o.length&&o[n]===73&&o[n+1]===68&&o[n+2]===51&&o[n+3]<255&&o[n+4]<255&&o[n+6]<128&&o[n+7]<128&&o[n+8]<128&&o[n+9]<128},Pn=function(o,n){return n+10<=o.length&&o[n]===51&&o[n+1]===68&&o[n+2]===73&&o[n+3]<255&&o[n+4]<255&&o[n+6]<128&&o[n+7]<128&&o[n+8]<128&&o[n+9]<128},Ai=function(o,n){for(var e=n,t=0;dr(o,n);)t+=10,t+=_i(o,n+6),Pn(o,n+10)&&(t+=10),n+=t;if(t>0)return o.subarray(e,e+t)},_i=function(o,n){var e=0;return e=(127&o[n])<<21,e|=(127&o[n+1])<<14,e|=(127&o[n+2])<<7,e|=127&o[n+3]},ts=function(o,n){return dr(o,n)&&_i(o,n+6)+10<=o.length-n},On=function(o){return o&&o.key==="PRIV"&&o.info==="com.apple.streaming.transportStreamTimestamp"},is=function(o){var n=String.fromCharCode(o[0],o[1],o[2],o[3]),e=_i(o,4);return{type:n,size:e,data:o.subarray(10,10+e)}},Mn=function(o){for(var n=0,e=[];dr(o,n);){for(var t=_i(o,n+6),i=(n+=10)+t;n+8>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(r);break;case 12:case 13:a=o[c++],d+=String.fromCharCode((31&r)<<6|63&a);break;case 14:a=o[c++],s=o[c++],d+=String.fromCharCode((15&r)<<12|(63&a)<<6|(63&s)<<0)}}return d};function ls(){return lr||self.TextDecoder===void 0||(lr=new self.TextDecoder("utf-8")),lr}var ot=function(o){for(var n="",e=0;e>24,o[n+1]=e>>16&255,o[n+2]=e>>8&255,o[n+3]=255&e}function ge(o,n){var e=[];if(!n.length)return e;for(var t=o.byteLength,i=0;i1?i+r:t;if(Se(o.subarray(i+4,i+8))===n[0])if(n.length===1)e.push(o.subarray(i+8,a));else{var s=ge(o.subarray(i+8,a),n.slice(1));s.length&&ds.apply(e,s)}i=a}return e}function cs(o){var n=[],e=o[0],t=8,i=oe(o,t);t+=4,t+=e===0?8:16,t+=2;var r=o.length+0,a=Bn(o,t);t+=2;for(var s=0;s>>31==1)return R.warn("SIDX has hierarchical references (not supported)"),null;var u=oe(o,l);l+=4,n.push({referenceSize:c,subsegmentDuration:u,info:{duration:u/i,start:r,end:r+c-1}}),r+=c,t=l+=4}return{earliestPresentationTime:0,timescale:i,version:e,referencesCount:a,references:n}}function Un(o){for(var n=[],e=ge(o,["moov","trak"]),t=0;t>1&63;return e===39||e===40}return(31&n)==6}function Kn(o,n,e,t){var i=Vn(o),r=0;r+=n;for(var a=0,s=0,l=!1,d=0;r=i.length)break;a+=d=i[r++]}while(d===255);s=0;do{if(r>=i.length)break;s+=d=i[r++]}while(d===255);var c=i.length-r;if(!l&&a===4&&r16){for(var S=[],C=0;C<16;C++){var L=i[r++].toString(16);S.push(L.length==1?"0"+L:L),C!==3&&C!==5&&C!==7&&C!==9||S.push("-")}for(var I=s-16,P=new Uint8Array(I),N=0;Nc)break}}function Vn(o){for(var n=o.byteLength,e=[],t=1;t0?(r=new Uint8Array(4),n.length>0&&new DataView(r.buffer).setUint32(0,n.length,!1)):r=new Uint8Array;var a=new Uint8Array(4);return e&&e.byteLength>0&&new DataView(a.buffer).setUint32(0,e.byteLength,!1),function(s){for(var l=arguments.length,d=new Array(l>1?l-1:0),c=1;c>24&255,v[1]=g>>16&255,v[2]=g>>8&255,v[3]=255&g,v.set(s,4),m=0,g=8;m>8*(15-E)&255;return b}(e);return new o(this.method,this.uri,"identity",this.keyFormatVersions,t)}var i=es(this.uri);if(i)switch(this.keyFormat){case Ei:this.pssh=i,i.length>=22&&(this.keyId=i.subarray(i.length-22,i.length-6));break;case wi:var r=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=fs(r,null,i);var a=new Uint16Array(i.buffer,i.byteOffset,i.byteLength/2),s=String.fromCharCode.apply(null,Array.from(a)),l=s.substring(s.indexOf("<"),s.length),d=new DOMParser().parseFromString(l,"text/xml").getElementsByTagName("KID")[0];if(d){var c=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(c){var u=nr(c).subarray(0,16);(function(_){var b=function(E,S,C){var L=E[S];E[S]=E[C],E[C]=L};b(_,0,3),b(_,1,2),b(_,4,5),b(_,6,7)})(u),this.keyId=u}}break;default:var g=i.subarray(0,16);if(g.length!==16){var m=new Uint8Array(16);m.set(g,16-g.length),g=m}this.keyId=g}if(!this.keyId||this.keyId.byteLength!==16){var v=xi[this.uri];if(!v){var y=Object.keys(xi).length%Number.MAX_SAFE_INTEGER;v=new Uint8Array(16),new DataView(v.buffer,12,4).setUint32(0,y),xi[this.uri]=v}this.keyId=v}return this},o}(),zn=/\{\$([a-zA-Z0-9-_]+)\}/g;function Yn(o){return zn.test(o)}function Ne(o,n,e){if(o.variableList!==null||o.hasVariableRefs)for(var t=e.length;t--;){var i=e[t],r=n[i];r&&(n[i]=ur(o,r))}}function ur(o,n){if(o.variableList!==null||o.hasVariableRefs){var e=o.variableList;return n.replace(zn,function(t){var i=t.substring(2,t.length-1),r=e==null?void 0:e[i];return r===void 0?(o.playlistParsingError||(o.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'+i+'"')),t):r})}return n}function jn(o,n,e){var t,i,r=o.variableList;if(r||(o.variableList=r={}),"QUERYPARAM"in n){t=n.QUERYPARAM;try{var a=new self.URL(e).searchParams;if(!a.has(t))throw new Error('"'+t+'" does not match any query parameter in URI: "'+e+'"');i=a.get(t)}catch(s){o.playlistParsingError||(o.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+s.message))}}else t=n.NAME,i=n.VALUE;t in r?o.playlistParsingError||(o.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'+t+'"')):r[t]=i||""}function ps(o,n,e){var t=n.IMPORT;if(e&&t in e){var i=o.variableList;i||(o.variableList=i={}),i[t]=e[t]}else o.playlistParsingError||(o.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'+t+'"'))}function Ti(){if(typeof self<"u")return self.MediaSource||self.WebKitMediaSource}var gs={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},qn=Ti();function fr(o,n){var e;return(e=qn==null?void 0:qn.isTypeSupported((n||"video")+'/mp4;codecs="'+o+'"'))!=null&&e}var $n=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,Qn=/#EXT-X-MEDIA:(.*)/g,ms=/^#EXT(?:INF|-X-TARGETDURATION):/m,Wn=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),vs=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),ii=function(){function o(){}return o.findGroup=function(n,e){for(var t=0;t2){var t=e.shift()+".";return t+=parseInt(e.shift()).toString(16),t+=("000"+parseInt(e.shift()).toString(16)).slice(-4)}return n},o.resolve=function(n,e){return er.buildAbsoluteURL(e,n,{alwaysNormalize:!0})},o.isMediaPlaylist=function(n){return ms.test(n)},o.parseMasterPlaylist=function(n,e){var t,i={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Yn(n)},r=[];for($n.lastIndex=0;(t=$n.exec(n))!=null;)if(t[1]){var a,s=new _e(t[1]);Ne(i,s,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var l=ur(i,t[2]),d={attrs:s,bitrate:s.decimalInteger("AVERAGE-BANDWIDTH")||s.decimalInteger("BANDWIDTH"),name:s.NAME,url:o.resolve(l,e)},c=s.decimalResolution("RESOLUTION");c&&(d.width=c.width,d.height=c.height),bs((s.CODECS||"").split(/[ ,]+/).filter(function(S){return S}),d),d.videoCodec&&d.videoCodec.indexOf("avc1")!==-1&&(d.videoCodec=o.convertAVC1ToAVCOTI(d.videoCodec)),(a=d.unknownCodecs)!=null&&a.length||r.push(d),i.levels.push(d)}else if(t[3]){var u=t[3],g=t[4];switch(u){case"SESSION-DATA":var m=new _e(g);Ne(i,m,["DATA-ID","LANGUAGE","VALUE","URI"]);var v=m["DATA-ID"];v&&(i.sessionData===null&&(i.sessionData={}),i.sessionData[v]=m);break;case"SESSION-KEY":var y=Xn(g,e,i);y.encrypted&&y.isSupported()?(i.sessionKeys===null&&(i.sessionKeys=[]),i.sessionKeys.push(y)):R.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+g+'"');break;case"DEFINE":var _=new _e(g);Ne(i,_,["NAME","VALUE","QUERYPARAM"]),jn(i,_,e);break;case"CONTENT-STEERING":var b=new _e(g);Ne(i,b,["SERVER-URI","PATHWAY-ID"]),i.contentSteering={uri:o.resolve(b["SERVER-URI"],e),pathwayId:b["PATHWAY-ID"]||"."};break;case"START":i.startTimeOffset=Jn(g)}}var E=r.length>0&&r.length0&&ye.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=ye.optionalFloat("PART-HOLD-BACK",0),c.holdBack=ye.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Ge=new _e(B);c.partTarget=Ge.decimalFloatingPoint("PART-TARGET");break;case"PART":var ke=c.partList;ke||(ke=c.partList=[]);var et=v>0?ke[ke.length-1]:void 0,Xe=v++,Je=new _e(B);Ne(c,Je,["BYTERANGE","URI"]);var xe=new Jo(Je,E,e,Xe,et);ke.push(xe),E.duration+=xe.duration;break;case"PRELOAD-HINT":var De=new _e(B);Ne(c,De,["URI"]),c.preloadHint=De;break;case"RENDITION-REPORT":var ct=new _e(B);Ne(c,ct,["URI"]),c.renditionReports=c.renditionReports||[],c.renditionReports.push(ct);break;default:R.warn("line parsed but not handled: "+s)}}}b&&!b.relurl?(u.pop(),y-=b.duration,c.partList&&(c.fragmentHint=b)):c.partList&&(ea(E,b),E.cc=_,c.fragmentHint=E,d&&ia(E,d,c));var Tt=u.length,Ye=u[0],pi=u[Tt-1];if((y+=c.skippedSegments*c.targetduration)>0&&Tt&&pi){c.averagetargetduration=y/Tt;var gi=pi.sn;c.endSN=gi!=="initSegment"?gi:0,c.live||(pi.endList=!0),Ye&&(c.startCC=Ye.cc)}else c.endSN=0,c.startCC=0;return c.fragmentHint&&(y+=c.fragmentHint.duration),c.totalduration=y,c.endCC=_,S>0&&function(zi,Xt){for(var Ut=zi[Xt],mi=Xt;mi--;){var wt=zi[mi];if(!wt)return;wt.programDateTime=Ut.programDateTime-1e3*wt.duration,Ut=wt}}(u,S),c},o}();function Xn(o,n,e){var t,i,r=new _e(o);Ne(e,r,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);var a=(t=r.METHOD)!=null?t:"",s=r.URI,l=r.hexadecimalInteger("IV"),d=r.KEYFORMATVERSIONS,c=(i=r.KEYFORMAT)!=null?i:"identity";s&&r.IV&&!l&&R.error("Invalid IV: "+r.IV);var u=s?ii.resolve(s,n):"",g=(d||"1").split("/").map(Number).filter(Number.isFinite);return new hr(a,u,c,g,l)}function Jn(o){var n=new _e(o).decimalFloatingPoint("TIME-OFFSET");return ie(n)?n:null}function bs(o,n){["video","audio","text"].forEach(function(e){var t=o.filter(function(r){return function(a,s){var l=gs[s];return!!l&&l[a.slice(0,4)]===!0}(r,e)});if(t.length){var i=t.filter(function(r){return r.lastIndexOf("avc1",0)===0||r.lastIndexOf("mp4a",0)===0});n[e+"Codec"]=i.length>0?i[0]:t[0],o=o.filter(function(r){return t.indexOf(r)===-1})}}),n.unknownCodecs=o}function Zn(o,n,e){var t=n[e];t&&(o[e]=t)}function ea(o,n){o.rawProgramDateTime?o.programDateTime=Date.parse(o.rawProgramDateTime):n!=null&&n.programDateTime&&(o.programDateTime=n.endProgramDateTime),ie(o.programDateTime)||(o.programDateTime=null,o.rawProgramDateTime=null)}function ta(o,n,e,t){o.relurl=n.URI,n.BYTERANGE&&o.setByteRange(n.BYTERANGE),o.level=e,o.sn="initSegment",t&&(o.levelkeys=t),o.initSegment=null}function ia(o,n,e){o.levelkeys=n;var t=e.encryptedFragments;t.length&&t[t.length-1].levelkeys===n||!Object.keys(n).some(function(i){return n[i].isCommonEncryption})||t.push(o)}var Gt="manifest",Ot="level",st="audioTrack",pt="subtitleTrack",ve="main",lt="audio",kt="subtitle";function ra(o){switch(o.type){case st:return lt;case pt:return kt;default:return ve}}function pr(o,n){var e=o.url;return e!==void 0&&e.indexOf("data:")!==0||(e=n.url),e}var ys=function(){function o(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}var n=o.prototype;return n.startLoad=function(e){},n.stopLoad=function(){this.destroyInternalLoaders()},n.registerListeners=function(){var e=this.hls;e.on(A.MANIFEST_LOADING,this.onManifestLoading,this),e.on(A.LEVEL_LOADING,this.onLevelLoading,this),e.on(A.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(A.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},n.unregisterListeners=function(){var e=this.hls;e.off(A.MANIFEST_LOADING,this.onManifestLoading,this),e.off(A.LEVEL_LOADING,this.onLevelLoading,this),e.off(A.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(A.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},n.createInternalLoader=function(e){var t=this.hls.config,i=t.pLoader,r=t.loader,a=new(i||r)(t);return this.loaders[e.type]=a,a},n.getInternalLoader=function(e){return this.loaders[e.type]},n.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},n.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},n.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},n.onManifestLoading=function(e,t){var i=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Gt,url:i,deliveryDirectives:null})},n.onLevelLoading=function(e,t){var i=t.id,r=t.level,a=t.url,s=t.deliveryDirectives;this.load({id:i,level:r,responseType:"text",type:Ot,url:a,deliveryDirectives:s})},n.onAudioTrackLoading=function(e,t){var i=t.id,r=t.groupId,a=t.url,s=t.deliveryDirectives;this.load({id:i,groupId:r,level:null,responseType:"text",type:st,url:a,deliveryDirectives:s})},n.onSubtitleTrackLoading=function(e,t){var i=t.id,r=t.groupId,a=t.url,s=t.deliveryDirectives;this.load({id:i,groupId:r,level:null,responseType:"text",type:pt,url:a,deliveryDirectives:s})},n.load=function(e){var t,i,r,a=this,s=this.hls.config,l=this.getInternalLoader(e);if(l){var d=l.context;if(d&&d.url===e.url)return void R.trace("[playlist-loader]: playlist request ongoing");R.log("[playlist-loader]: aborting previous loader for type: "+e.type),l.abort()}if(i=e.type===Gt?s.manifestLoadPolicy.default:F({},s.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),l=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part&&(e.type===Ot&&e.level!==null?r=this.hls.levels[e.level].details:e.type===st&&e.id!==null?r=this.hls.audioTracks[e.id].details:e.type===pt&&e.id!==null&&(r=this.hls.subtitleTracks[e.id].details),r)){var c=r.partTarget,u=r.targetduration;if(c&&u){var g=1e3*Math.max(3*c,.8*u);i=F({},i,{maxTimeToFirstByteMs:Math.min(g,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(g,i.maxTimeToFirstByteMs)})}}var m=i.errorRetry||i.timeoutRetry||{},v={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:m.maxNumRetry||0,retryDelay:m.retryDelayMs||0,maxRetryDelay:m.maxRetryDelayMs||0},y={onSuccess:function(_,b,E,S){var C=a.getInternalLoader(E);a.resetInternalLoader(E.type);var L=_.data;L.indexOf("#EXTM3U")===0?(b.parsing.start=performance.now(),ii.isMediaPlaylist(L)?a.handleTrackOrLevelPlaylist(_,b,E,S||null,C):a.handleMasterPlaylist(_,b,E,S)):a.handleManifestParsingError(_,E,new Error("no EXTM3U delimiter"),S||null,b)},onError:function(_,b,E,S){a.handleNetworkError(b,E,!1,_,S)},onTimeout:function(_,b,E){a.handleNetworkError(b,E,!0,void 0,_)}};l.load(e,v,y)},n.handleMasterPlaylist=function(e,t,i,r){var a=this.hls,s=e.data,l=pr(e,i),d=ii.parseMasterPlaylist(s,l);if(d.playlistParsingError)this.handleManifestParsingError(e,i,d.playlistParsingError,r,t);else{var c=d.contentSteering,u=d.levels,g=d.sessionData,m=d.sessionKeys,v=d.startTimeOffset,y=d.variableList;this.variableList=y;var _=ii.parseMasterPlaylistMedia(s,l,d),b=_.AUDIO,E=b===void 0?[]:b,S=_.SUBTITLES,C=_["CLOSED-CAPTIONS"];E.length&&(E.some(function(L){return!L.url})||!u[0].audioCodec||u[0].attrs.AUDIO||(R.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),E.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new _e({}),bitrate:0,url:""}))),a.trigger(A.MANIFEST_LOADED,{levels:u,audioTracks:E,subtitles:S,captions:C,contentSteering:c,url:l,stats:t,networkDetails:r,sessionData:g,sessionKeys:m,startTimeOffset:v,variableList:y})}},n.handleTrackOrLevelPlaylist=function(e,t,i,r,a){var s=this.hls,l=i.id,d=i.level,c=i.type,u=pr(e,i),g=ie(l)?l:0,m=ie(d)?d:g,v=ra(i),y=ii.parseLevelPlaylist(e.data,u,m,v,g,this.variableList);if(c===Gt){var _={attrs:new _e({}),bitrate:0,details:y,name:"",url:u};s.trigger(A.MANIFEST_LOADED,{levels:[_],audioTracks:[],url:u,stats:t,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=y,this.handlePlaylistLoaded(y,e,t,i,r,a)},n.handleManifestParsingError=function(e,t,i,r,a){this.hls.trigger(A.ERROR,{type:ne.NETWORK_ERROR,details:O.MANIFEST_PARSING_ERROR,fatal:t.type===Gt,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:r,stats:a})},n.handleNetworkError=function(e,t,i,r,a){i===void 0&&(i=!1);var s="A network "+(i?"timeout":"error"+(r?" (status "+r.code+")":""))+" occurred while loading "+e.type;e.type===Ot?s+=": "+e.level+" id: "+e.id:e.type!==st&&e.type!==pt||(s+=" id: "+e.id+' group-id: "'+e.groupId+'"');var l=new Error(s);R.warn("[playlist-loader]: "+s);var d=O.UNKNOWN,c=!1,u=this.getInternalLoader(e);switch(e.type){case Gt:d=i?O.MANIFEST_LOAD_TIMEOUT:O.MANIFEST_LOAD_ERROR,c=!0;break;case Ot:d=i?O.LEVEL_LOAD_TIMEOUT:O.LEVEL_LOAD_ERROR,c=!1;break;case st:d=i?O.AUDIO_TRACK_LOAD_TIMEOUT:O.AUDIO_TRACK_LOAD_ERROR,c=!1;break;case pt:d=i?O.SUBTITLE_TRACK_LOAD_TIMEOUT:O.SUBTITLE_LOAD_ERROR,c=!1}u&&this.resetInternalLoader(e.type);var g={type:ne.NETWORK_ERROR,details:d,fatal:c,url:e.url,loader:u,context:e,error:l,networkDetails:t,stats:a};if(r){var m=(t==null?void 0:t.url)||e.url;g.response=x({url:m,data:void 0},r)}this.hls.trigger(A.ERROR,g)},n.handlePlaylistLoaded=function(e,t,i,r,a,s){var l=this.hls,d=r.type,c=r.level,u=r.id,g=r.groupId,m=r.deliveryDirectives,v=pr(t,r),y=ra(r),_=typeof r.level=="number"&&y===ve?c:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var b=e.playlistParsingError;if(b)l.trigger(A.ERROR,{type:ne.NETWORK_ERROR,details:O.LEVEL_PARSING_ERROR,fatal:!1,url:v,error:b,reason:b.message,response:t,context:r,level:_,parent:y,networkDetails:a,stats:i});else switch(e.live&&s&&(s.getCacheAge&&(e.ageHeader=s.getCacheAge()||0),s.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),d){case Gt:case Ot:l.trigger(A.LEVEL_LOADED,{details:e,level:_||0,id:u||0,stats:i,networkDetails:a,deliveryDirectives:m});break;case st:l.trigger(A.AUDIO_TRACK_LOADED,{details:e,id:u||0,groupId:g||"",stats:i,networkDetails:a,deliveryDirectives:m});break;case pt:l.trigger(A.SUBTITLE_TRACK_LOADED,{details:e,id:u||0,groupId:g||"",stats:i,networkDetails:a,deliveryDirectives:m})}}else{var E=new Error("No Segments found in Playlist");l.trigger(A.ERROR,{type:ne.NETWORK_ERROR,details:O.LEVEL_EMPTY_ERROR,fatal:!1,url:v,error:E,reason:E.message,response:t,context:r,level:_,parent:y,networkDetails:a,stats:i})}},o}();function na(o,n){var e;try{e=new Event("addtrack")}catch{(e=document.createEvent("Event")).initEvent("addtrack",!1,!1)}e.track=o,n.dispatchEvent(e)}function aa(o,n){var e=o.mode;if(e==="disabled"&&(o.mode="hidden"),o.cues&&!o.cues.getCueById(n.id))try{if(o.addCue(n),!o.cues.getCueById(n.id))throw new Error("addCue is failed for: "+n)}catch(i){R.debug("[texttrack-utils]: "+i);try{var t=new self.TextTrackCue(n.startTime,n.endTime,n.text);t.id=n.id,o.addCue(t)}catch(r){R.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: "+r)}}e==="disabled"&&(o.mode=e)}function Ht(o){var n=o.mode;if(n==="disabled"&&(o.mode="hidden"),o.cues)for(var e=o.cues.length;e--;)o.removeCue(o.cues[e]);n==="disabled"&&(o.mode=n)}function gr(o,n,e,t){var i=o.mode;if(i==="disabled"&&(o.mode="hidden"),o.cues&&o.cues.length>0)for(var r=function(s,l,d){var c=[],u=function(y,_){if(_y[b].endTime)return-1;for(var E=0,S=b;E<=S;){var C=Math.floor((S+E)/2);if(_y[C].startTime&&E-1)for(var g=u,m=s.length;g=l&&v.endTime<=d)c.push(v);else if(v.startTime>d)return c}return c}(o.cues,n,e),a=0;aCi&&(m=Ci),m-g<=0&&(m=g+.25);for(var v=0;vS.startDate&&Z.push(he),Z},[]).sort(function(Z,ae){return Z.startDate.getTime()-ae.startDate.getTime()})[0];B&&(N=vr(B.startDate,v),I=!0)}for(var Y,K,Q=Object.keys(S.attr),re=0;re.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,s)),g=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,g))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}}}}},n.estimateLiveEdge=function(){var e=this.levelDetails;return e===null?null:e.edge+e.age},n.computeLatency=function(){var e=this.estimateLiveEdge();return e===null?null:e-this.currentTime},D(o,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(e===null)return null;var t=e.holdBack,i=e.partHoldBack,r=e.targetduration,a=this.config,s=a.liveSyncDuration,l=a.liveSyncDurationCount,d=a.lowLatencyMode,c=this.hls.userConfig,u=d&&i||t;(c.liveSyncDuration||c.liveSyncDurationCount||u===0)&&(u=s!==void 0?s:l*r);var g=r;return u+Math.min(1*this.stallCount,g)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,i=this.levelDetails;if(e===null||t===null||i===null)return null;var r=i.edge,a=e-t-this.edgeStalled,s=r-i.totalduration,l=r-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(s,a),l)}},{key:"drift",get:function(){var e=this.levelDetails;return e===null?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(e===null)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}}]),o}(),br=["NONE","TYPE-0","TYPE-1",null],yr="",_s="YES",ks="v2",oa=function(){function o(n,e,t){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=n,this.part=e,this.skip=t}return o.prototype.addDirectives=function(n){var e=new self.URL(n);return this.msn!==void 0&&e.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href},o}(),ai=function(){function o(n){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[n.url],this._attrs=[n.attrs],this.bitrate=n.bitrate,n.details&&(this.details=n.details),this.id=n.id||0,this.name=n.name,this.width=n.width||0,this.height=n.height||0,this.audioCodec=n.audioCodec,this.videoCodec=n.videoCodec,this.unknownCodecs=n.unknownCodecs,this.codecSet=[n.videoCodec,n.audioCodec].filter(function(e){return e}).join(",").replace(/\.[^.,]+/g,"")}return o.prototype.addFallback=function(n){this.url.push(n.url),this._attrs.push(n.attrs)},D(o,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"attrs",get:function(){return this._attrs[this._urlId]}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(n){var e=n%this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}},{key:"audioGroupId",get:function(){var n;return(n=this.audioGroupIds)==null?void 0:n[this.urlId]}},{key:"textGroupId",get:function(){var n;return(n=this.textGroupIds)==null?void 0:n[this.urlId]}}]),o}();function wr(o,n){var e=n.startPTS;if(ie(e)){var t,i=0;n.sn>o.sn?(i=e-o.start,t=o):(i=o.start-e,t=n),t.duration!==i&&(t.duration=i)}else n.sn>o.sn?o.cc===n.cc&&o.minEndPTS?n.start=o.start+(o.minEndPTS-o.start):n.start=o.start+o.duration:n.start=Math.max(o.start-n.duration,0)}function sa(o,n,e,t,i,r){t-e<=0&&(R.warn("Fragment should have a positive duration",n),t=e+n.duration,r=i+n.duration);var a=e,s=t,l=n.startPTS,d=n.endPTS;if(ie(l)){var c=Math.abs(l-e);ie(n.deltaPTS)?n.deltaPTS=Math.max(c,n.deltaPTS):n.deltaPTS=c,a=Math.max(e,l),e=Math.min(e,l),i=Math.min(i,n.startDTS),s=Math.min(t,d),t=Math.max(t,d),r=Math.max(r,n.endDTS)}var u=e-n.start;n.start!==0&&(n.start=e),n.duration=t-n.start,n.startPTS=e,n.maxStartPTS=a,n.startDTS=i,n.endPTS=t,n.minEndPTS=s,n.endDTS=r;var g,m=n.sn;if(!o||mo.endSN)return 0;var v=m-o.startSN,y=o.fragments;for(y[v]=n,g=v;g>0;g--)wr(y[g],y[g-1]);for(g=v;g=0;i--){var r=t[i].initSegment;if(r){e=r;break}}o.fragmentHint&&delete o.fragmentHint.endPTS;var a,s,l,d,c,u=0;if(function(b,E,S){for(var C=E.skippedSegments,L=Math.max(b.startSN,E.startSN)-E.startSN,I=(b.fragmentHint?1:0)+(C?E.endSN:Math.min(b.endSN,E.endSN))-E.startSN,P=E.startSN-b.startSN,N=E.fragmentHint?E.fragments.concat(E.fragmentHint):E.fragments,M=b.fragmentHint?b.fragments.concat(b.fragmentHint):b.fragments,B=L;B<=I;B++){var Y=M[P+B],K=N[B];C&&!K&&B=t.length||Er(n,t[e].start)}function Er(o,n){if(n){for(var e=o.fragments,t=o.skippedSegments;t499)}(t)||!!e)}var fa=function(o,n){for(var e=0,t=o.length-1,i=null,r=null;e<=t;){var a=n(r=o[i=(e+t)/2|0]);if(a>0)e=i+1;else{if(!(a<0))return r;t=i-1}}return null};function oi(o,n,e,t){e===void 0&&(e=0),t===void 0&&(t=0);var i=null;if(o?i=n[o.sn-n[0].sn+1]||null:e===0&&n[0].start===0&&(i=n[0]),i&&_r(e,t,i)===0)return i;var r=fa(n,_r.bind(null,e,t));return!r||r===o&&i?i:r}function _r(o,n,e){if(o===void 0&&(o=0),n===void 0&&(n=0),e.start<=o&&e.start+e.duration>o)return 0;var t=Math.min(n,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-t<=o?1:e.start-t>o&&e.start?-1:0}function Ts(o,n,e){var t=1e3*Math.min(n,e.duration+(e.deltaPTS?e.deltaPTS:0));return(e.endProgramDateTime||0)-t>o}var kr,Cs=3e5,xr=0,gt=2,Di=5,Kt=0,Ri=1,pa=2,Ss=function(){function o(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=R.log.bind(R,"[info]:"),this.warn=R.warn.bind(R,"[warning]:"),this.error=R.error.bind(R,"[error]:"),this.registerListeners()}var n=o.prototype;return n.registerListeners=function(){var e=this.hls;e.on(A.ERROR,this.onError,this),e.on(A.MANIFEST_LOADING,this.onManifestLoading,this),e.on(A.LEVEL_UPDATED,this.onLevelUpdated,this)},n.unregisterListeners=function(){var e=this.hls;e&&(e.off(A.ERROR,this.onError,this),e.off(A.ERROR,this.onErrorOut,this),e.off(A.MANIFEST_LOADING,this.onManifestLoading,this),e.off(A.LEVEL_UPDATED,this.onLevelUpdated,this))},n.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},n.startLoad=function(e){this.playlistError=0},n.stopLoad=function(){},n.getVariantLevelIndex=function(e){return(e==null?void 0:e.type)===ve?e.level:this.hls.loadLevel},n.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},n.onLevelUpdated=function(){this.playlistError=0},n.onError=function(e,t){var i,r;if(!t.fatal){var a=this.hls,s=t.context;switch(t.details){case O.FRAG_LOAD_ERROR:case O.FRAG_LOAD_TIMEOUT:case O.KEY_LOAD_ERROR:case O.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case O.FRAG_PARSING_ERROR:if((i=t.frag)!=null&&i.gap)return void(t.errorAction={action:xr,flags:Kt});case O.FRAG_GAP:case O.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=gt);case O.LEVEL_EMPTY_ERROR:case O.LEVEL_PARSING_ERROR:var l,d,c=t.parent===ve?t.level:a.loadLevel;return void(t.details===O.LEVEL_EMPTY_ERROR&&(l=t.context)!=null&&(d=l.levelDetails)!=null&&d.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,c):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,c)));case O.LEVEL_LOAD_ERROR:case O.LEVEL_LOAD_TIMEOUT:return void(typeof(s==null?void 0:s.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,s.level)));case O.AUDIO_TRACK_LOAD_ERROR:case O.AUDIO_TRACK_LOAD_TIMEOUT:case O.SUBTITLE_LOAD_ERROR:case O.SUBTITLE_TRACK_LOAD_TIMEOUT:if(s){var u=a.levels[a.loadLevel];if(u&&(s.type===st&&s.groupId===u.audioGroupId||s.type===pt&&s.groupId===u.textGroupId))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.loadLevel),t.errorAction.action=gt,void(t.errorAction.flags=Ri)}return;case O.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var g=a.levels[a.loadLevel],m=g==null?void 0:g.attrs["HDCP-LEVEL"];return void(m&&(t.errorAction={action:gt,flags:pa,hdcpLevel:m}));case O.BUFFER_ADD_CODEC_ERROR:case O.REMUX_ALLOC_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,(r=t.level)!=null?r:a.loadLevel));case O.INTERNAL_EXCEPTION:case O.BUFFER_APPENDING_ERROR:case O.BUFFER_APPEND_ERROR:case O.BUFFER_FULL_ERROR:case O.LEVEL_SWITCH_ERROR:case O.BUFFER_STALLED_ERROR:case O.BUFFER_SEEK_OVER_HOLE:case O.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:xr,flags:Kt})}if(t.type===ne.KEY_SYSTEM_ERROR){var v=this.getVariantLevelIndex(t.frag);return t.levelRetry=!1,void(t.errorAction=this.getLevelSwitchAction(t,v))}}},n.getPlaylistRetryOrSwitchAction=function(e,t){var i,r=ha(this.hls.config.playlistLoadPolicy,e),a=this.playlistError++,s=(i=e.response)==null?void 0:i.code;if(Li(r,a,Si(e),s))return{action:Di,flags:Kt,retryConfig:r,retryCount:a};var l=this.getLevelSwitchAction(e,t);return r&&(l.retryConfig=r,l.retryCount=a),l},n.getFragRetryOrSwitchAction=function(e){var t=this.hls,i=this.getVariantLevelIndex(e.frag),r=t.levels[i],a=t.config,s=a.fragLoadPolicy,l=a.keyLoadPolicy,d=ha(e.details.startsWith("key")?l:s,e),c=t.levels.reduce(function(v,y){return v+y.fragmentError},0);if(r){var u;e.details!==O.FRAG_GAP&&r.fragmentError++;var g=(u=e.response)==null?void 0:u.code;if(Li(d,c,Si(e),g))return{action:Di,flags:Kt,retryConfig:d,retryCount:c}}var m=this.getLevelSwitchAction(e,i);return d&&(m.retryConfig=d,m.retryCount=c),m},n.getLevelSwitchAction=function(e,t){var i=this.hls;t==null&&(t=i.loadLevel);var r=this.hls.levels[t];if(r&&(r.loadError++,i.autoLevelEnabled)){for(var a,s,l=-1,d=i.levels,c=i.loadLevel,u=i.minAutoLevel,g=i.maxAutoLevel,m=(a=e.frag)==null?void 0:a.type,v=(s=e.context)!=null?s:{},y=v.type,_=v.groupId,b=d.length;b--;){var E=(b+c)%d.length;if(E!==c&&E>=u&&E<=g&&d[E].loadError===0){var S=d[E];if(e.details===O.FRAG_GAP&&e.frag){var C=d[E].details;if(C){var L=oi(e.frag,C.fragments,e.frag.start);if(L!=null&&L.gap)continue}}else if(y===st&&_===S.audioGroupId||y===pt&&_===S.textGroupId||m===lt&&r.audioGroupId===S.audioGroupId||m===kt&&r.textGroupId===S.textGroupId)continue;l=E;break}}if(l>-1&&i.loadLevel!==l)return e.levelRetry=!0,this.playlistError=0,{action:gt,flags:Kt,nextAutoLevel:l}}return{action:gt,flags:Ri}},n.onErrorOut=function(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case xr:break;case gt:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===O.FRAG_GAP||(t.fatal=!0)}t.fatal&&this.hls.stopLoad()},n.sendAlternateToPenaltyBox=function(e){var t=this.hls,i=e.errorAction;if(i){var r=i.flags,a=i.hdcpLevel,s=i.nextAutoLevel;switch(r){case Kt:this.switchLevel(e,s);break;case Ri:i.resolved||(i.resolved=this.redundantFailover(e));break;case pa:a&&(t.maxHdcpLevel=br[br.indexOf(a)-1],i.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower')}i.resolved||this.switchLevel(e,s)}},n.switchLevel=function(e,t){t!==void 0&&e.errorAction&&(this.warn("switching to level "+t+" after "+e.details),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},n.redundantFailover=function(e){var t=this,i=this.hls,r=this.penalizedRenditions,a=e.parent===ve?e.level:i.loadLevel,s=i.levels[a],l=s.url.length,d=e.frag?e.frag.urlId:s.urlId;s.urlId!==d||e.frag&&!s.details||this.penalizeRendition(s,e);for(var c=function(){var m=(d+u)%l,v=r[m];if(!v||function(y,_,b){if(performance.now()-y.lastErrorPerfMs>Cs)return!0;var E=y.details;if(_.details===O.FRAG_GAP&&E&&_.frag){var S=_.frag.start,C=oi(null,E.fragments,S);if(C&&!C.gap)return!0}if(b&&y.errors.length3*E.targetduration)return!0}return!1}(v,e,r[d]))return t.warn("Switching to Redundant Stream "+(m+1)+"/"+l+': "'+s.url[m]+'" after '+e.details),t.playlistError=0,i.levels.forEach(function(y){y.urlId=m}),i.nextLoadLevel=a,{v:!0}},u=1;u=0&&g>t.partTarget&&(u+=1)}return new oa(c,u>=0?u:void 0,yr)}}},n.loadPlaylist=function(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},n.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},n.shouldReloadPlaylist=function(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)},n.playlistLoaded=function(e,t,i){var r=this,a=t.details,s=t.stats,l=self.performance.now(),d=s.loading.first?Math.max(0,l-s.loading.first):0;if(a.advancedDateTime=Date.now()-d,a.live||i!=null&&i.live){if(a.reloaded(i),i&&this.log("live playlist "+e+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:a.updated?"UPDATED":"MISSED")),i&&a.fragments.length>0&&xs(i,a),!this.canLoad||!a.live)return;var c,u=void 0,g=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var m=this.hls.config.lowLatencyMode,v=a.lastPartSn,y=a.endSN,_=a.lastPartIndex,b=v===y;_!==-1?(u=b?y+1:v,g=b?m?0:_:_+1):u=y+1;var E=a.age,S=E+a.ageHeader,C=Math.min(S-a.partTarget,1.5*a.targetduration);if(C>0){if(i&&C>i.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+i.tuneInGoal+" to: "+C+" with playlist age: "+a.age),C=0;else{var L=Math.floor(C/a.targetduration);u+=L,g!==void 0&&(g+=Math.round(C%a.targetduration/a.partTarget)),this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+E.toFixed(2)+"s goal: "+C+" skip sn "+L+" to part "+g)}a.tuneInGoal=C}if(c=this.getDeliveryDirectives(a,t.deliveryDirectives,u,g),m||!b)return void this.loadPlaylist(c)}else(a.canBlockReload||a.canSkipUntil)&&(c=this.getDeliveryDirectives(a,t.deliveryDirectives,u,g));var I=this.hls.mainForwardBufferInfo,P=I?I.end-I.len:0,N=function(B,Y){Y===void 0&&(Y=1/0);var K=1e3*B.targetduration;if(B.updated){var Q=B.fragments;if(Q.length&&4*K>Y){var re=1e3*Q[Q.length-1].duration;rethis.requestScheduled+N&&(this.requestScheduled=s.loading.start),u!==void 0&&a.canBlockReload?this.requestScheduled=s.loading.first+N-(1e3*a.partTarget||1e3):this.requestScheduled===-1||this.requestScheduled+N=u.maxNumRetry)return!1;if(r&&(m=e.context)!=null&&m.deliveryDirectives)this.warn("Retrying playlist loading "+(c+1)+"/"+u.maxNumRetry+' after "'+i+'" without delivery-directives'),this.loadPlaylist();else{var v=Ar(u,c);this.timer=self.setTimeout(function(){return t.loadPlaylist()},v),this.warn("Retrying playlist loading "+(c+1)+"/"+u.maxNumRetry+' after "'+i+'" in '+v+"ms")}e.levelRetry=!0,a.resolved=!0}return g},o}(),Ls=function(o){function n(t,i){var r;return(r=o.call(this,t,"[level-controller]")||this)._levels=[],r._firstLevel=-1,r._startLevel=void 0,r.currentLevel=null,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.steering=void 0,r.onParsedComplete=void 0,r.steering=i,r._registerListeners(),r}q(n,o);var e=n.prototype;return e._registerListeners=function(){var t=this.hls;t.on(A.MANIFEST_LOADING,this.onManifestLoading,this),t.on(A.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(A.LEVEL_LOADED,this.onLevelLoaded,this),t.on(A.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(A.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(A.FRAG_LOADED,this.onFragLoaded,this),t.on(A.ERROR,this.onError,this)},e._unregisterListeners=function(){var t=this.hls;t.off(A.MANIFEST_LOADING,this.onManifestLoading,this),t.off(A.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(A.LEVEL_LOADED,this.onLevelLoaded,this),t.off(A.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(A.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(A.FRAG_LOADED,this.onFragLoaded,this),t.off(A.ERROR,this.onError,this)},e.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),o.prototype.destroy.call(this)},e.startLoad=function(){this._levels.forEach(function(t){t.loadError=0,t.fragmentError=0}),o.prototype.startLoad.call(this)},e.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]},e.onManifestLoading=function(t,i){this.resetLevels()},e.onManifestLoaded=function(t,i){var r,a=[],s={};i.levels.forEach(function(l){var d,c=l.attrs;((d=l.audioCodec)==null?void 0:d.indexOf("mp4a.40.34"))!==-1&&(kr||(kr=/chrome|firefox/i.test(navigator.userAgent)),kr&&(l.audioCodec=void 0));var u=c.AUDIO,g=c.CODECS,m=c["FRAME-RATE"],v=c["PATHWAY-ID"],y=c.RESOLUTION,_=c.SUBTITLES,b=(v||".")+"-"+l.bitrate+"-"+y+"-"+m+"-"+g;(r=s[b])?r.addFallback(l):(r=new ai(l),s[b]=r,a.push(r)),Ii(r,"audio",u),Ii(r,"text",_)}),this.filterAndSortMediaOptions(a,i)},e.filterAndSortMediaOptions=function(t,i){var r=this,a=[],s=[],l=!1,d=!1,c=!1,u=t.filter(function(E){var S=E.audioCodec,C=E.videoCodec,L=E.width,I=E.height,P=E.unknownCodecs;return l||(l=!(!L||!I)),d||(d=!!C),c||(c=!!S),!(P!=null&&P.length)&&(!S||fr(S,"audio"))&&(!C||fr(C,"video"))});if((l||d)&&c&&(u=u.filter(function(E){var S=E.videoCodec,C=E.width,L=E.height;return!!S||!(!C||!L)})),u.length!==0){i.audioTracks&&ga(a=i.audioTracks.filter(function(E){return!E.audioCodec||fr(E.audioCodec,"audio")})),i.subtitles&&ga(s=i.subtitles);var g=u.slice(0);u.sort(function(E,S){return E.attrs["HDCP-LEVEL"]!==S.attrs["HDCP-LEVEL"]?(E.attrs["HDCP-LEVEL"]||"")>(S.attrs["HDCP-LEVEL"]||"")?1:-1:E.bitrate!==S.bitrate?E.bitrate-S.bitrate:E.attrs["FRAME-RATE"]!==S.attrs["FRAME-RATE"]?E.attrs.decimalFloatingPoint("FRAME-RATE")-S.attrs.decimalFloatingPoint("FRAME-RATE"):E.attrs.SCORE!==S.attrs.SCORE?E.attrs.decimalFloatingPoint("SCORE")-S.attrs.decimalFloatingPoint("SCORE"):l&&E.height!==S.height?E.height-S.height:0});var m=g[0];if(this.steering&&(u=this.steering.filterParsedLevels(u)).length!==g.length){for(var v=0;v1&&i!==void 0?(l.url=l.url.filter(a),l.audioGroupIds&&(l.audioGroupIds=l.audioGroupIds.filter(a)),l.textGroupIds&&(l.textGroupIds=l.textGroupIds.filter(a)),l.urlId=0,!0):(r.steering&&r.steering.removeLevel(l),!1))});this.hls.trigger(A.LEVELS_UPDATED,{levels:s})},e.onLevelsUpdated=function(t,i){var r=i.levels;r.forEach(function(a,s){var l=a.details;l!=null&&l.fragments&&l.fragments.forEach(function(d){d.level=s})}),this._levels=r},D(n,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var i=this._levels;if(i.length!==0){if(t<0||t>=i.length){var r=new Error("invalid level idx"),a=t<0;if(this.hls.trigger(A.ERROR,{type:ne.OTHER_ERROR,details:O.LEVEL_SWITCH_ERROR,level:t,fatal:a,error:r,reason:r.message}),a)return;t=Math.min(t,i.length-1)}var s=this.currentLevelIndex,l=this.currentLevel,d=l?l.attrs["PATHWAY-ID"]:void 0,c=i[t],u=c.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=c,s!==t||!c.details||!l||d!==u){this.log("Switching to level "+t+(u?" with Pathway "+u:"")+" from level "+s+(d?" with Pathway "+d:""));var g=F({},c,{level:t,maxBitrate:c.maxBitrate,attrs:c.attrs,uri:c.uri,urlId:c.urlId});delete g._attrs,delete g._urlId,this.hls.trigger(A.LEVEL_SWITCHING,g);var m=c.details;if(!m||m.live){var v=this.switchParams(c.uri,l==null?void 0:l.details);this.loadPlaylist(v)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var t=this.hls.config.startLevel;return t!==void 0?t:this._firstLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}}]),n}(Tr);function Ii(o,n,e){e&&(n==="audio"?(o.audioGroupIds||(o.audioGroupIds=[]),o.audioGroupIds[o.url.length-1]=e):n==="text"&&(o.textGroupIds||(o.textGroupIds=[]),o.textGroupIds[o.url.length-1]=e))}function ga(o){var n={};o.forEach(function(e){var t=e.groupId||"";e.id=n[t]=n[t]||0,n[t]++})}var si="NOT_LOADED",ma="APPENDING",Vt="PARTIAL",li="OK",Ds=function(){function o(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}var n=o.prototype;return n._registerListeners=function(){var e=this.hls;e.on(A.BUFFER_APPENDED,this.onBufferAppended,this),e.on(A.FRAG_BUFFERED,this.onFragBuffered,this),e.on(A.FRAG_LOADED,this.onFragLoaded,this)},n._unregisterListeners=function(){var e=this.hls;e.off(A.BUFFER_APPENDED,this.onBufferAppended,this),e.off(A.FRAG_BUFFERED,this.onFragBuffered,this),e.off(A.FRAG_LOADED,this.onFragLoaded,this)},n.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},n.getAppendedFrag=function(e,t){var i=this.activePartLists[t];if(i)for(var r=i.length;r--;){var a=i[r];if(!a)break;var s=a.end;if(a.start<=e&&s!==null&&e<=s)return a}return this.getBufferedFrag(e,t)},n.getBufferedFrag=function(e,t){for(var i=this.fragments,r=Object.keys(i),a=r.length;a--;){var s=i[r[a]];if((s==null?void 0:s.body.type)===t&&s.buffered){var l=s.body;if(l.start<=e&&e<=l.end)return l}}return null},n.detectEvictedFragments=function(e,t,i,r){var a=this;this.timeRanges&&(this.timeRanges[e]=t);var s=(r==null?void 0:r.fragment.sn)||-1;Object.keys(this.fragments).forEach(function(l){var d=a.fragments[l];if(d&&!(s>=d.body.sn))if(d.buffered||d.loaded){var c=d.range[e];c&&c.time.some(function(u){var g=!a.isTimeBuffered(u.startPTS,u.endPTS,t);return g&&a.removeFragment(d.body),g})}else d.body.type===i&&a.removeFragment(d.body)})},n.detectPartialFragments=function(e){var t=this,i=this.timeRanges,r=e.frag,a=e.part;if(i&&r.sn!=="initSegment"){var s=zt(r),l=this.fragments[s];if(!(!l||l.buffered&&r.gap)){var d=!r.relurl;Object.keys(i).forEach(function(c){var u=r.elementaryStreams[c];if(u){var g=i[c],m=d||u.partial===!0;l.range[c]=t.getBufferedTimes(r,a,m,g)}}),l.loaded=null,Object.keys(l.range).length?(l.buffered=!0,(l.body.endList=r.endList||l.body.endList)&&(this.endListFragments[l.body.type]=l),Pi(l)||this.removeParts(r.sn-1,r.type)):this.removeFragment(l.body)}}},n.removeParts=function(e,t){var i=this.activePartLists[t];i&&(this.activePartLists[t]=i.filter(function(r){return r.fragment.sn>=e}))},n.fragBuffered=function(e,t){var i=zt(e),r=this.fragments[i];!r&&t&&(r=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),r&&(r.loaded=null,r.buffered=!0)},n.getBufferedTimes=function(e,t,i,r){for(var a={time:[],partial:i},s=e.start,l=e.end,d=e.minEndPTS||l,c=e.maxStartPTS||s,u=0;u=g&&d<=m){a.time.push({startPTS:Math.max(s,r.start(u)),endPTS:Math.min(l,r.end(u))});break}if(sg)a.partial=!0,a.time.push({startPTS:Math.max(s,r.start(u)),endPTS:Math.min(l,r.end(u))});else if(l<=g)break}return a},n.getPartialFragment=function(e){var t,i,r,a=null,s=0,l=this.bufferPadding,d=this.fragments;return Object.keys(d).forEach(function(c){var u=d[c];u&&Pi(u)&&(i=u.body.start-l,r=u.body.end+l,e>=i&&e<=r&&(t=Math.min(e-i,r-e),s<=t&&(a=u.body,s=t)))}),a},n.isEndListAppended=function(e){var t=this.endListFragments[e];return t!==void 0&&(t.buffered||Pi(t))},n.getState=function(e){var t=zt(e),i=this.fragments[t];return i?i.buffered?Pi(i)?Vt:li:ma:si},n.isTimeBuffered=function(e,t,i){for(var r,a,s=0;s=r&&t<=a)return!0;if(t<=r)return!1}return!1},n.onFragLoaded=function(e,t){var i=t.frag,r=t.part;if(i.sn!=="initSegment"&&!i.bitrateTest){var a=r?null:t,s=zt(i);this.fragments[s]={body:i,appendedPTS:null,loaded:a,buffered:!1,range:Object.create(null)}}},n.onBufferAppended=function(e,t){var i=this,r=t.frag,a=t.part,s=t.timeRanges;if(r.sn!=="initSegment"){var l=r.type;if(a){var d=this.activePartLists[l];d||(this.activePartLists[l]=d=[]),d.push(a)}this.timeRanges=s,Object.keys(s).forEach(function(c){var u=s[c];i.detectEvictedFragments(c,u,l,a)})}},n.onFragBuffered=function(e,t){this.detectPartialFragments(t)},n.hasFragment=function(e){var t=zt(e);return!!this.fragments[t]},n.hasParts=function(e){var t;return!((t=this.activePartLists[e])==null||!t.length)},n.removeFragmentsInRange=function(e,t,i,r,a){var s=this;r&&!this.hasGaps||Object.keys(this.fragments).forEach(function(l){var d=s.fragments[l];if(d){var c=d.body;c.type!==i||r&&!c.gap||c.starte&&(d.buffered||a)&&s.removeFragment(c)}})},n.removeFragment=function(e){var t=zt(e);e.stats.loaded=0,e.clearElementaryStreamInfo();var i=this.activePartLists[e.type];if(i){var r=e.sn;this.activePartLists[e.type]=i.filter(function(a){return a.fragment.sn!==r})}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},n.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},o}();function Pi(o){var n,e,t;return o.buffered&&(o.body.gap||((n=o.range.video)==null?void 0:n.partial)||((e=o.range.audio)==null?void 0:e.partial)||((t=o.range.audiovideo)==null?void 0:t.partial))}function zt(o){return o.type+"_"+o.level+"_"+o.urlId+"_"+o.sn}var va=Math.pow(2,17),Rs=function(){function o(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var n=o.prototype;return n.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},n.abort=function(){this.loader&&this.loader.abort()},n.load=function(e,t){var i=this,r=e.url;if(!r)return Promise.reject(new mt({type:ne.NETWORK_ERROR,details:O.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(r?"part list":"url")),networkDetails:null}));this.abort();var a=this.config,s=a.fLoader,l=a.loader;return new Promise(function(d,c){if(i.loader&&i.loader.destroy(),e.gap){if(e.tagList.some(function(y){return y[0]==="GAP"}))return void c(ya(e));e.gap=!1}var u=i.loader=e.loader=s?new s(a):new l(a),g=ba(e),m=ua(a.fragLoadPolicy.default),v={loadPolicy:m,timeout:m.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:va};e.stats=u.stats,u.load(g,v,{onSuccess:function(y,_,b,E){i.resetLoader(e,u);var S=y.data;b.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(S.slice(0,16)),S=S.slice(16)),d({frag:e,part:null,payload:S,networkDetails:E})},onError:function(y,_,b,E){i.resetLoader(e,u),c(new mt({type:ne.NETWORK_ERROR,details:O.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:x({url:r,data:void 0},y),error:new Error("HTTP Error "+y.code+" "+y.text),networkDetails:b,stats:E}))},onAbort:function(y,_,b){i.resetLoader(e,u),c(new mt({type:ne.NETWORK_ERROR,details:O.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:b,stats:y}))},onTimeout:function(y,_,b){i.resetLoader(e,u),c(new mt({type:ne.NETWORK_ERROR,details:O.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+v.timeout+"ms"),networkDetails:b,stats:y}))},onProgress:function(y,_,b,E){t&&t({frag:e,part:null,payload:b,networkDetails:E})}})})},n.loadPart=function(e,t,i){var r=this;this.abort();var a=this.config,s=a.fLoader,l=a.loader;return new Promise(function(d,c){if(r.loader&&r.loader.destroy(),e.gap||t.gap)c(ya(e,t));else{var u=r.loader=e.loader=s?new s(a):new l(a),g=ba(e,t),m=ua(a.fragLoadPolicy.default),v={loadPolicy:m,timeout:m.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:va};t.stats=u.stats,u.load(g,v,{onSuccess:function(y,_,b,E){r.resetLoader(e,u),r.updateStatsFromPart(e,t);var S={frag:e,part:t,payload:y.data,networkDetails:E};i(S),d(S)},onError:function(y,_,b,E){r.resetLoader(e,u),c(new mt({type:ne.NETWORK_ERROR,details:O.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:x({url:g.url,data:void 0},y),error:new Error("HTTP Error "+y.code+" "+y.text),networkDetails:b,stats:E}))},onAbort:function(y,_,b){e.stats.aborted=t.stats.aborted,r.resetLoader(e,u),c(new mt({type:ne.NETWORK_ERROR,details:O.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:b,stats:y}))},onTimeout:function(y,_,b){r.resetLoader(e,u),c(new mt({type:ne.NETWORK_ERROR,details:O.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+v.timeout+"ms"),networkDetails:b,stats:y}))}})}})},n.updateStatsFromPart=function(e,t){var i=e.stats,r=t.stats,a=r.total;if(i.loaded+=r.loaded,a){var s=Math.round(e.duration/t.duration),l=Math.min(Math.round(i.loaded/a),s),d=(s-l)*Math.round(i.loaded/l);i.total=i.loaded+d}else i.total=Math.max(i.loaded,i.total);var c=i.loading,u=r.loading;c.start?c.first+=u.first-u.start:(c.start=u.start,c.first=u.first),c.end=u.end},n.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},o}();function ba(o,n){n===void 0&&(n=null);var e=n||o,t={frag:o,part:n,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},i=e.byteRangeStartOffset,r=e.byteRangeEndOffset;if(ie(i)&&ie(r)){var a,s=i,l=r;if(o.sn==="initSegment"&&((a=o.decryptdata)==null?void 0:a.method)==="AES-128"){var d=r-i;d%16&&(l=r+(16-d%16)),i!==0&&(t.resetIV=!0,s=i-16)}t.rangeStart=s,t.rangeEnd=l}return t}function ya(o,n){var e=new Error("GAP "+(o.gap?"tag":"attribute")+" found"),t={type:ne.MEDIA_ERROR,details:O.FRAG_GAP,fatal:!1,frag:o,error:e,networkDetails:null};return n&&(t.part=n),(n||o).stats.aborted=!0,new mt(t)}var mt=function(o){function n(e){var t;return(t=o.call(this,e.error.message)||this).data=void 0,t.data=e,t}return q(n,o),n}(ce(Error)),Is=function(){function o(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}var n=o.prototype;return n.abort=function(e){for(var t in this.keyUriToKeyInfo){var i=this.keyUriToKeyInfo[t].loader;if(i){if(e&&e!==i.context.frag.type)return;i.abort()}}},n.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},n.destroy=function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},n.createKeyLoadError=function(e,t,i,r,a){return t===void 0&&(t=O.KEY_LOAD_ERROR),new mt({type:ne.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:i,networkDetails:r})},n.loadClear=function(e,t){var i=this;if(this.emeController&&this.config.emeEnabled)for(var r=e.sn,a=e.cc,s=function(){var d=t[l];if(a<=d.cc&&(r==="initSegment"||d.sn==="initSegment"||r1&&this.tickImmediate(),this._tickCallCount=0)},n.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},n.doTick=function(){},o}(),Os={length:0,start:function(){return 0},end:function(){return 0}},Ae=function(){function o(){}return o.isBuffered=function(n,e){try{if(n){for(var t=o.getBuffered(n),i=0;i=t.start(i)&&e<=t.end(i))return!0}}catch{}return!1},o.bufferInfo=function(n,e,t){try{if(n){var i,r=o.getBuffered(n),a=[];for(i=0;is&&(i[a-1].end=n[r].end):i.push(n[r])}else i.push(n[r])}else i=n;for(var l,d=0,c=e,u=e,g=0;g=m&&ed.startCC||s&&s.cc>>8^255&E^99,e[y]=E,t[E]=y;var S=v[y],C=v[S],L=v[C],I=257*v[E]^16843008*E;r[y]=I<<24|I>>>8,a[y]=I<<16|I>>>16,s[y]=I<<8|I>>>24,l[y]=I,I=16843009*L^65537*C^257*S^16843008*y,c[E]=I<<24|I>>>8,u[E]=I<<16|I>>>16,g[E]=I<<8|I>>>24,m[E]=I,y?(y=S^v[v[v[L^S]]],_^=v[v[_]]):y=_=1}},n.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),i=!0,r=0;rd.end){var m=l>g;(l0&&d&&d.key&&d.iv&&d.method==="AES-128"){var c=self.performance.now();return r.decrypter.decrypt(new Uint8Array(l),d.key.buffer,d.iv.buffer).catch(function(u){throw s.trigger(A.ERROR,{type:ne.MEDIA_ERROR,details:O.FRAG_DECRYPT_ERROR,fatal:!1,error:u,reason:u.message,frag:t}),u}).then(function(u){var g=self.performance.now();return s.trigger(A.FRAG_DECRYPTED,{frag:t,payload:u,stats:{tstart:c,tdecrypt:g}}),a.payload=u,a})}return a}).then(function(a){var s=r.fragCurrent,l=r.hls;if(!r.levels)throw new Error("init load aborted, missing levels");var d=t.stats;r.state=ue,i.fragmentError=0,t.data=new Uint8Array(a.payload),d.parsing.start=d.buffering.start=self.performance.now(),d.parsing.end=d.buffering.end=self.performance.now(),a.frag===s&&l.trigger(A.FRAG_BUFFERED,{stats:d,frag:s,part:null,id:t.type}),r.tick()}).catch(function(a){r.state!==$e&&r.state!==qt&&(r.warn(a),r.resetFragmentLoading(t))})},e.fragContextChanged=function(t){var i=this.fragCurrent;return!t||!i||t.level!==i.level||t.sn!==i.sn||t.urlId!==i.urlId},e.fragBufferedComplete=function(t,i){var r,a,s,l,d=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+t.type+" sn: "+t.sn+(i?" part: "+i.index:"")+" of "+(this.playlistType===ve?"level":"track")+" "+t.level+" (frag:["+((r=t.startPTS)!=null?r:NaN).toFixed(3)+"-"+((a=t.endPTS)!=null?a:NaN).toFixed(3)+"] > buffer:"+(d?Us(Ae.getBuffered(d)):"(detached)")+")"),this.state=ue,d&&(!this.loadedmetadata&&t.type==ve&&d.buffered.length&&((s=this.fragCurrent)==null?void 0:s.sn)===((l=this.fragPrevious)==null?void 0:l.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},e.seekToStartPos=function(){},e._handleFragmentLoadComplete=function(t){var i=this.transmuxer;if(i){var r=t.frag,a=t.part,s=t.partsLoaded,l=!s||s.length===0||s.some(function(c){return!c}),d=new Cr(r.level,r.sn,r.stats.chunkCount+1,0,a?a.index:-1,!l);i.flush(d)}},e._handleFragmentLoadProgress=function(t){},e._doFragLoad=function(t,i,r,a){var s,l=this;r===void 0&&(r=null);var d=i==null?void 0:i.details;if(!this.levels||!d)throw new Error("frag load aborted, missing level"+(d?"":" detail")+"s");var c=null;if(!t.encrypted||(s=t.decryptdata)!=null&&s.key?!t.encrypted&&d.encryptedFragments.length&&this.keyLoader.loadClear(t,d.encryptedFragments):(this.log("Loading key for "+t.sn+" of ["+d.startSN+"-"+d.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+t.level),this.state=Dr,this.fragCurrent=t,c=this.keyLoader.load(t).then(function(b){if(!l.fragContextChanged(b.frag))return l.hls.trigger(A.KEY_LOADED,b),l.state===Dr&&(l.state=ue),b}),this.hls.trigger(A.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(c=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),r=Math.max(t.start,r||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){var u=d.partList;if(u&&a){r>t.end&&d.fragmentHint&&(t=d.fragmentHint);var g=this.getNextPart(u,t,r);if(g>-1){var m,v=u[g];return this.log("Loading part sn: "+t.sn+" p: "+v.index+" cc: "+t.cc+" of playlist ["+d.startSN+"-"+d.endSN+"] parts [0-"+g+"-"+(u.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=v.start+v.duration,this.state=Yt,m=c?c.then(function(b){return!b||l.fragContextChanged(b.frag)?null:l.doFragPartsLoad(t,v,i,a)}).catch(function(b){return l.handleFragLoadError(b)}):this.doFragPartsLoad(t,v,i,a).catch(function(b){return l.handleFragLoadError(b)}),this.hls.trigger(A.FRAG_LOADING,{frag:t,part:v,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):m}if(!t.url||this.loadedEndOfParts(u,r))return Promise.resolve(null)}}this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(d?"of ["+d.startSN+"-"+d.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(r.toFixed(3))),ie(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=Yt;var y,_=this.config.progressive;return y=_&&c?c.then(function(b){return!b||l.fragContextChanged(b==null?void 0:b.frag)?null:l.fragmentLoader.load(t,a)}).catch(function(b){return l.handleFragLoadError(b)}):Promise.all([this.fragmentLoader.load(t,_?a:void 0),c]).then(function(b){var E=b[0];return!_&&E&&a&&a(E),E}).catch(function(b){return l.handleFragLoadError(b)}),this.hls.trigger(A.FRAG_LOADING,{frag:t,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):y},e.doFragPartsLoad=function(t,i,r,a){var s=this;return new Promise(function(l,d){var c,u=[],g=(c=r.details)==null?void 0:c.partList;(function m(v){s.fragmentLoader.loadPart(t,v,a).then(function(y){u[v.index]=y;var _=y.part;s.hls.trigger(A.FRAG_LOADED,y);var b=da(r,t.sn,v.index+1)||ca(g,t.sn,v.index+1);if(!b)return l({frag:t,part:_,partsLoaded:u});m(b)}).catch(d)})(i)})},e.handleFragLoadError=function(t){if("data"in t){var i=t.data;t.data&&i.details===O.INTERNAL_ABORTED?this.handleFragLoadAborted(i.frag,i.part):this.hls.trigger(A.ERROR,i)}else this.hls.trigger(A.ERROR,{type:ne.OTHER_ERROR,details:O.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},e._handleTransmuxerFlush=function(t){var i=this.getCurrentContext(t);if(i&&this.state===vt){var r=i.frag,a=i.part,s=i.level,l=self.performance.now();r.stats.parsing.end=l,a&&(a.stats.parsing.end=l),this.updateLevelTiming(r,a,s,t.partial)}else this.fragCurrent||this.state===$e||this.state===qt||(this.state=ue)},e.getCurrentContext=function(t){var i=this.levels,r=this.fragCurrent,a=t.level,s=t.sn,l=t.part;if(i==null||!i[a])return this.warn("Levels object was unset while buffering fragment "+s+" of level "+a+". The current chunk will not be buffered."),null;var d=i[a],c=l>-1?da(d,s,l):null,u=c?c.fragment:function(g,m,v){if(g==null||!g.details)return null;var y=g.details,_=y.fragments[m-y.startSN];return _||((_=y.fragmentHint)&&_.sn===m?_:ml&&this.flushMainBuffer(d,t.start)}else this.flushMainBuffer(0,t.start)},e.getFwdBufferInfo=function(t,i){var r=this.getLoadPosition();return ie(r)?this.getFwdBufferInfoAtPos(t,r,i):null},e.getFwdBufferInfoAtPos=function(t,i,r){var a=this.config.maxBufferHole,s=Ae.bufferInfo(t,i,a);if(s.len===0&&s.nextStart!==void 0){var l=this.fragmentTracker.getBufferedFrag(i,r);if(l&&s.nextStart=r&&(i.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+i.maxMaxBufferLength+"s"),!0)},e.getAppendedFrag=function(t,i){var r=this.fragmentTracker.getAppendedFrag(t,ve);return r&&"fragment"in r?r.fragment:r},e.getNextFragment=function(t,i){var r=i.fragments,a=r.length;if(!a)return null;var s,l=this.config,d=r[0].start;if(i.live){var c=l.initialLiveManifestSize;if(ai},e.getNextFragmentLoopLoading=function(t,i,r,a,s){var l=t.gap,d=this.getNextFragment(this.nextLoadPosition,i);if(d===null)return d;if(t=d,l&&t&&!t.gap&&r.nextStart){var c=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,a);if(c!==null&&r.len+c.len>=s)return this.log('buffer full after gaps in "'+a+'" playlist starting at sn: '+t.sn),null}return t},e.mapToInitFragWhenRequired=function(t){return t==null||!t.initSegment||t!=null&&t.initSegment.data||this.bitrateTest?t:t.initSegment},e.getNextPart=function(t,i,r){for(var a=-1,s=!1,l=!0,d=0,c=t.length;d-1&&rr.start&&r.loaded},e.getInitialLiveFragment=function(t,i){var r=this.fragPrevious,a=null;if(r){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),a=function(c,u,g){if(u===null||!Array.isArray(c)||!c.length||!ie(u)||u<(c[0].programDateTime||0)||u>=(c[c.length-1].endProgramDateTime||0))return null;g=g||0;for(var m=0;m=t.startSN&&s<=t.endSN){var l=i[s-t.startSN];r.cc===l.cc&&(a=l,this.log("Live playlist, switching playlist, load frag with next SN: "+a.sn))}a||(a=function(c,u){return fa(c,function(g){return g.ccu?-1:0})}(i,r.cc),a&&this.log("Live playlist, switching playlist, load frag with same CC: "+a.sn))}}else{var d=this.hls.liveSyncPosition;d!==null&&(a=this.getFragmentAtPosition(d,this.bitrateTest?t.fragmentEnd:t.edge,t))}return a},e.getFragmentAtPosition=function(t,i,r){var a,s=this.config,l=this.fragPrevious,d=r.fragments,c=r.endSN,u=r.fragmentHint,g=s.maxFragLookUpTolerance,m=r.partList,v=!!(s.lowLatencyMode&&m!=null&&m.length&&u);if(v&&u&&!this.bitrateTest&&(d=d.concat(u),c=u.sn),a=ti-g?0:g):d[d.length-1]){var y=a.sn-r.startSN,_=this.fragmentTracker.getState(a);if((_===li||_===Vt&&a.gap)&&(l=a),l&&a.sn===l.sn&&(!v||m[0].fragment.sn>a.sn)&&l&&a.level===l.level){var b=d[y+1];a=a.sn=l-i.maxFragLookUpTolerance&&s<=d;if(a!==null&&r.duration>a&&(s"+t.startSN+" prev-sn: "+(s?s.sn:"na")+" fragments: "+d),m}return c},e.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},e.setStartPosition=function(t,i){var r=this.startPosition;if(r "+((s=this.fragCurrent)==null?void 0:s.url))}else{var l=i.details===O.FRAG_GAP;l&&this.fragmentTracker.fragBuffered(a,!0);var d=i.errorAction,c=d||{},u=c.action,g=c.retryCount,m=g===void 0?0:g,v=c.retryConfig;if(d&&u===Di&&v){var y;this.resetStartWhenNotLoaded((y=this.levelLastLoaded)!=null?y:a.level);var _=Ar(v,m);this.warn("Fragment "+a.sn+" of "+t+" "+a.level+" errored with "+i.details+", retrying loading "+(m+1)+"/"+v.maxNumRetry+" in "+_+"ms"),d.resolved=!0,this.retryDate=self.performance.now()+_,this.state=jt}else v&&d?(this.resetFragmentErrors(t),m.5;a&&this.reduceMaxBufferLength(r.len);var s=!a;return s&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+i+" buffer"),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),s}return!1},e.resetFragmentErrors=function(t){t===lt&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==$e&&(this.state=ue)},e.afterBufferFlushed=function(t,i,r){if(t){var a=Ae.getBuffered(t);this.fragmentTracker.detectEvictedFragments(i,a,r),this.state===ci&&this.resetLoadingState()}},e.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=ue},e.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var i=this.levels?this.levels[t].details:null;i!=null&&i.live?(this.startPosition=-1,this.setStartPosition(i,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},e.resetWhenMissingContext=function(t){var i;this.warn("The loading context changed while buffering fragment "+t.sn+" of level "+t.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded((i=this.levelLastLoaded)!=null?i:t.level),this.resetLoadingState()},e.removeUnbufferedFrags=function(t){t===void 0&&(t=0),this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)},e.updateLevelTiming=function(t,i,r,a){var s,l=this,d=r.details;if(d){if(Object.keys(t.elementaryStreams).reduce(function(u,g){var m=t.elementaryStreams[g];if(m){var v=m.endPTS-m.startPTS;if(v<=0)return l.warn("Could not parse fragment "+t.sn+" "+g+" duration reliably ("+v+")"),u||!1;var y=a?0:sa(d,t,m.startPTS,m.endPTS,m.startDTS,m.endDTS);return l.hls.trigger(A.LEVEL_PTS_UPDATED,{details:d,level:r,drift:y,type:g,frag:t,start:m.startPTS,end:m.endPTS}),!0}return u},!1))r.fragmentError=0;else if(((s=this.transmuxer)==null?void 0:s.error)===null){var c=new Error("Found no media in fragment "+t.sn+" of level "+t.level+" resetting transmuxer to fallback to playlist timing");if(r.fragmentError===0&&(r.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(c.message),this.hls.trigger(A.ERROR,{type:ne.MEDIA_ERROR,details:O.FRAG_PARSING_ERROR,fatal:!1,error:c,frag:t,reason:"Found no media in msn "+t.sn+' of level "'+r.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=Oi,this.hls.trigger(A.FRAG_PARSED,{frag:t,part:i})}else this.warn("level.details undefined")},e.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},e.recoverWorkerError=function(t){var i,r,a;t.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((i=(r=this.levelLastLoaded)!=null?r:(a=this.fragCurrent)==null?void 0:a.level)!=null?i:0),this.resetLoadingState())},D(n,[{key:"state",get:function(){return this._state},set:function(t){var i=this._state;i!==t&&(this._state=t,this.log(i+"->"+t))}}]),n}(Ps);function _a(){return self.SourceBuffer||self.WebKitSourceBuffer}function dt(o,n){return o===void 0&&(o=""),n===void 0&&(n=9e4),{type:o,id:-1,pid:-1,inputTimeScale:n,sequenceNumber:-1,samples:[],dropped:0}}var ka=function(){function o(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var n=o.prototype;return n.resetInitSegment=function(e,t,i,r){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},n.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},n.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},n.canParse=function(e,t){return!1},n.appendFrame=function(e,t,i){},n.demux=function(e,t){this.cachedData&&(e=Pt(this.cachedData,e),this.cachedData=null);var i,r=Ai(e,0),a=r?r.length:0,s=this._audioTrack,l=this._id3Track,d=r?function(m){for(var v=Mn(m),y=0;y0&&l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:ri,duration:Number.POSITIVE_INFINITY});a>>5}function Mi(o,n){return n+1=o.length)return!1;var t=Ir(o,n);if(t<=e)return!1;var i=n+t;return i===o.length||Mi(o,i)}return!1}function Ca(o,n,e,t,i){if(!o.samplerate){var r=function(a,s,l,d){var c,u,g,m,v=navigator.userAgent.toLowerCase(),y=d,_=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];c=1+((192&s[l+2])>>>6);var b=(60&s[l+2])>>>2;if(!(b>_.length-1))return g=(1&s[l+2])<<2,g|=(192&s[l+3])>>>6,R.log("manifest codec:"+d+", ADTS type:"+c+", samplingIndex:"+b),/firefox/i.test(v)?b>=6?(c=5,m=new Array(4),u=b-3):(c=2,m=new Array(2),u=b):v.indexOf("android")!==-1?(c=2,m=new Array(2),u=b):(c=5,m=new Array(4),d&&(d.indexOf("mp4a.40.29")!==-1||d.indexOf("mp4a.40.5")!==-1)||!d&&b>=6?u=b-3:((d&&d.indexOf("mp4a.40.2")!==-1&&(b>=6&&g===1||/vivaldi/i.test(v))||!d&&g===1)&&(c=2,m=new Array(2)),u=b)),m[0]=c<<3,m[0]|=(14&b)>>1,m[1]|=(1&b)<<7,m[1]|=g<<3,c===5&&(m[1]|=(14&u)>>1,m[2]=(1&u)<<7,m[2]|=8,m[3]=0),{config:m,samplerate:_[b],channelCount:g,codec:"mp4a.40."+c,manifestCodec:y};a.trigger(A.ERROR,{type:ne.MEDIA_ERROR,details:O.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+b})}(n,e,t,i);if(!r)return;o.config=r.config,o.samplerate=r.samplerate,o.channelCount=r.channelCount,o.codec=r.codec,o.manifestCodec=r.manifestCodec,R.log("parsed codec:"+o.codec+", rate:"+r.samplerate+", channels:"+r.channelCount)}}function Sa(o){return 9216e4/o}function La(o,n,e,t,i){var r,a=t+i*Sa(o.samplerate),s=function(v,y){var _=Ta(v,y);if(y+_<=v.length){var b=Ir(v,y)-_;if(b>0)return{headerLength:_,frameLength:b}}}(n,e);if(s){var l=s.frameLength,d=s.headerLength,c=d+l,u=Math.max(0,e+c-n.length);u?(r=new Uint8Array(c-d)).set(n.subarray(e+d,n.length),0):r=n.subarray(e+d,e+c);var g={unit:r,pts:a};return u||o.samples.push(g),{sample:g,length:c,missing:u}}var m=n.length-e;return(r=new Uint8Array(m)).set(n.subarray(e,n.length),0),{sample:{unit:r,pts:a},length:m,missing:-1}}var Ks=function(o){function n(t,i){var r;return(r=o.call(this)||this).observer=void 0,r.config=void 0,r.observer=t,r.config=i,r}q(n,o);var e=n.prototype;return e.resetInitSegment=function(t,i,r,a){o.prototype.resetInitSegment.call(this,t,i,r,a),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:i,duration:a,inputTimeScale:9e4,dropped:0}},n.probe=function(t){if(!t)return!1;for(var i=(Ai(t,0)||[]).length,r=t.length;i16384?e.subarray(0,16384):e,["moof"]).length>0},n.demux=function(e,t){this.timeOffset=t;var i=e,r=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=Pt(this.remainderData,e));var s=function(d){var c={valid:null,remainder:null},u=ge(d,["moof"]);if(!u)return c;if(u.length<2)return c.remainder=d,c;var g=u[u.length-1];return c.valid=It(d,0,g.byteOffset-8),c.remainder=It(d,g.byteOffset-8),c}(i);this.remainderData=s.remainder,r.samples=s.valid||new Uint8Array}else r.samples=i;var l=this.extractID3Track(r,t);return a.samples=Hn(t,r),{videoTrack:r,audioTrack:this.audioTrack,id3Track:l,textTrack:this.txtTrack}},n.flush=function(){var e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var r=this.extractID3Track(t,this.timeOffset);return i.samples=Hn(e,t),{videoTrack:t,audioTrack:dt(),id3Track:r,textTrack:dt()}},n.extractID3Track=function(e,t){var i=this.id3Track;if(e.samples.length){var r=ge(e.samples,["emsg"]);r&&r.forEach(function(a){var s=function(u){var g=u[0],m="",v="",y=0,_=0,b=0,E=0,S=0,C=0;if(g===0){for(;Se(u.subarray(C,C+1))!=="\0";)m+=Se(u.subarray(C,C+1)),C+=1;for(m+=Se(u.subarray(C,C+1)),C+=1;Se(u.subarray(C,C+1))!=="\0";)v+=Se(u.subarray(C,C+1)),C+=1;v+=Se(u.subarray(C,C+1)),C+=1,y=oe(u,12),_=oe(u,16),E=oe(u,20),S=oe(u,24),C=28}else if(g===1){y=oe(u,C+=4);var L=oe(u,C+=4),I=oe(u,C+=4);for(C+=4,b=Math.pow(2,32)*L+I,Number.isSafeInteger(b)||(b=Number.MAX_SAFE_INTEGER,R.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),E=oe(u,C),S=oe(u,C+=4),C+=4;Se(u.subarray(C,C+1))!=="\0";)m+=Se(u.subarray(C,C+1)),C+=1;for(m+=Se(u.subarray(C,C+1)),C+=1;Se(u.subarray(C,C+1))!=="\0";)v+=Se(u.subarray(C,C+1)),C+=1;v+=Se(u.subarray(C,C+1)),C+=1}return{schemeIdUri:m,value:v,timeScale:y,presentationTime:b,presentationTimeDelta:_,eventDuration:E,id:S,payload:u.subarray(C,u.byteLength)}}(a);if(Vs.test(s.schemeIdUri)){var l=ie(s.presentationTime)?s.presentationTime/s.timeScale:t+s.presentationTimeDelta/s.timeScale,d=s.eventDuration===4294967295?Number.POSITIVE_INFINITY:s.eventDuration/s.timeScale;d<=.001&&(d=Number.POSITIVE_INFINITY);var c=s.payload;i.samples.push({data:c,len:c.byteLength,dts:l,pts:l,type:ni,duration:d})}})}return i},n.demuxSampleAes=function(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},n.destroy=function(){},o}(),Fi=null,Ys=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],js=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],qs=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],$s=[0,1,1,4];function Da(o,n,e,t,i){if(!(e+24>n.length)){var r=Ra(n,e);if(r&&e+r.frameLength<=n.length){var a=t+i*(9e4*r.samplesPerFrame/r.sampleRate),s={unit:n.subarray(e,e+r.frameLength),pts:a,dts:a};return o.config=[],o.channelCount=r.channelCount,o.samplerate=r.sampleRate,o.samples.push(s),{sample:s,length:r.frameLength,missing:0}}}}function Ra(o,n){var e=o[n+1]>>3&3,t=o[n+1]>>1&3,i=o[n+2]>>4&15,r=o[n+2]>>2&3;if(e!==1&&i!==0&&i!==15&&r!==3){var a=o[n+2]>>1&1,s=o[n+3]>>6,l=1e3*Ys[14*(e===3?3-t:t===3?3:4)+i-1],d=js[3*(e===3?0:e===2?1:2)+r],c=s===3?1:2,u=qs[e][t],g=$s[t],m=8*u*g,v=Math.floor(u*l/d+a)*g;if(Fi===null){var y=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Fi=y?parseInt(y[1]):0}return Fi&&Fi<=87&&t===2&&l>=224e3&&s===0&&(o[n+3]=128|o[n+3]),{sampleRate:d,channelCount:c,frameLength:v,samplesPerFrame:m}}}function Pr(o,n){return o[n]===255&&(224&o[n+1])==224&&(6&o[n+1])!=0}function Ia(o,n){return n+1e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},n.readBits=function(e){var t=Math.min(this.bitsAvailable,e),i=this.word>>>32-t;if(e>32&&R.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?i<>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},n.skipUEG=function(){this.skipBits(1+this.skipLZ())},n.skipEG=function(){this.skipBits(1+this.skipLZ())},n.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},n.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},n.readBoolean=function(){return this.readBits(1)===1},n.readUByte=function(){return this.readBits(8)},n.readUShort=function(){return this.readBits(16)},n.readUInt=function(){return this.readBits(32)},n.skipScalingList=function(e){for(var t=8,i=8,r=0;r=e.length)return void i();if(!(e[t].unit.length<32||(this.decryptAacSample(e,t,i),this.decrypter.isSync())))return}},n.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,i=new Int8Array(t),r=0,a=32;a=e.length)return void r();for(var a=e[t].units;!(i>=a.length);i++){var s=a[i];if(!(s.data.length<=48||s.type!==1&&s.type!==5||(this.decryptAvcSample(e,t,i,r,s),this.decrypter.isSync())))return}}},o}(),Ue=188,Xs=function(){function o(e,t,i){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=e,this.config=t,this.typeSupported=i}o.probe=function(e){var t=o.syncOffset(e);return t>0&&R.warn("MPEG2-TS detected but first sync word found @ offset "+t),t!==-1},o.syncOffset=function(e){for(var t=e.length,i=Math.min(940,e.length-Ue)+1,r=0;r1&&(s===0&&l>2||d+Ue>i))return s}r++}return-1},o.createTrack=function(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:Fn[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}};var n=o.prototype;return n.resetInitSegment=function(e,t,i,r){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=o.createTrack("video"),this._audioTrack=o.createTrack("audio",r),this._id3Track=o.createTrack("id3"),this._txtTrack=o.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i,this._duration=r},n.resetTimeStamp=function(){},n.resetContiguity=function(){var e=this._audioTrack,t=this._avcTrack,i=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},n.demux=function(e,t,i,r){var a;i===void 0&&(i=!1),r===void 0&&(r=!1),i||(this.sampleAes=null);var s=this._avcTrack,l=this._audioTrack,d=this._id3Track,c=this._txtTrack,u=s.pid,g=s.pesData,m=l.pid,v=d.pid,y=l.pesData,_=d.pesData,b=null,E=this.pmtParsed,S=this._pmtId,C=e.length;if(this.remainderData&&(C=(e=Pt(this.remainderData,e)).length,this.remainderData=null),C>4>1){if((B=P+5+e[P+4])===P+Ue)continue}else B=P+4;switch(M){case u:N&&(g&&(a=$t(g))&&this.parseAVCPES(s,c,a,!1),g={data:[],size:0}),g&&(g.data.push(e.subarray(B,P+Ue)),g.size+=P+Ue-B);break;case m:if(N){if(y&&(a=$t(y)))switch(l.segmentCodec){case"aac":this.parseAACPES(l,a);break;case"mp3":this.parseMPEGPES(l,a)}y={data:[],size:0}}y&&(y.data.push(e.subarray(B,P+Ue)),y.size+=P+Ue-B);break;case v:N&&(_&&(a=$t(_))&&this.parseID3PES(d,a),_={data:[],size:0}),_&&(_.data.push(e.subarray(B,P+Ue)),_.size+=P+Ue-B);break;case 0:N&&(B+=e[B]+1),S=this._pmtId=Js(e,B);break;case S:N&&(B+=e[B]+1);var Y=Zs(e,B,this.typeSupported,i);(u=Y.avc)>0&&(s.pid=u),(m=Y.audio)>0&&(l.pid=m,l.segmentCodec=Y.segmentCodec),(v=Y.id3)>0&&(d.pid=v),b===null||E||(R.warn("MPEG-TS PMT found at "+P+" after unknown PID '"+b+"'. Backtracking to sync byte @"+L+" to parse all TS packets."),b=null,P=L-188),E=this.pmtParsed=!0;break;case 17:case 8191:break;default:b=M}}else I++;if(I>0){var K=new Error("Found "+I+" TS packet/s that do not start with 0x47");this.observer.emit(A.ERROR,A.ERROR,{type:ne.MEDIA_ERROR,details:O.FRAG_PARSING_ERROR,fatal:!1,error:K,reason:K.message})}s.pesData=g,l.pesData=y,d.pesData=_;var Q={audioTrack:l,videoTrack:s,id3Track:d,textTrack:c};return r&&this.extractRemainingSamples(Q),Q},n.flush=function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},n.extractRemainingSamples=function(e){var t,i=e.audioTrack,r=e.videoTrack,a=e.id3Track,s=e.textTrack,l=r.pesData,d=i.pesData,c=a.pesData;if(l&&(t=$t(l))?(this.parseAVCPES(r,s,t,!0),r.pesData=null):r.pesData=l,d&&(t=$t(d))){switch(i.segmentCodec){case"aac":this.parseAACPES(i,t);break;case"mp3":this.parseMPEGPES(i,t)}i.pesData=null}else d!=null&&d.size&&R.log("last AAC PES packet truncated,might overlap between fragments"),i.pesData=d;c&&(t=$t(c))?(this.parseID3PES(a,t),a.pesData=null):a.pesData=c},n.demuxSampleAes=function(e,t,i){var r=this.demux(e,i,!0,!this.config.progressive),a=this.sampleAes=new Ws(this.observer,this.config,t);return this.decrypt(r,a)},n.decrypt=function(e,t){return new Promise(function(i){var r=e.audioTrack,a=e.videoTrack;r.samples&&r.segmentCodec==="aac"?t.decryptAacSamples(r.samples,0,function(){a.samples?t.decryptAvcSamples(a.samples,0,0,function(){i(e)}):i(e)}):a.samples&&t.decryptAvcSamples(a.samples,0,0,function(){i(e)})})},n.destroy=function(){this._duration=0},n.parseAVCPES=function(e,t,i,r){var a,s=this,l=this.parseAVCNALu(e,i.data),d=this.avcSample,c=!1;i.data=null,d&&l.length&&!e.audFound&&(ui(d,e),d=this.avcSample=Bi(!1,i.pts,i.dts,"")),l.forEach(function(u){var g;switch(u.type){case 1:var m=!1;a=!0;var v,y=u.data;if(c&&y.length>4){var _=new Pa(y).readSliceType();_!==2&&_!==4&&_!==7&&_!==9||(m=!0)}m&&(v=d)!=null&&v.frame&&!d.key&&(ui(d,e),d=s.avcSample=null),d||(d=s.avcSample=Bi(!0,i.pts,i.dts,"")),d.frame=!0,d.key=m;break;case 5:a=!0,(g=d)!=null&&g.frame&&!d.key&&(ui(d,e),d=s.avcSample=null),d||(d=s.avcSample=Bi(!0,i.pts,i.dts,"")),d.key=!0,d.frame=!0;break;case 6:a=!0,Kn(u.data,1,i.pts,t.samples);break;case 7:if(a=!0,c=!0,!e.sps){var b=u.data,E=new Pa(b).readSPS();e.width=E.width,e.height=E.height,e.pixelRatio=E.pixelRatio,e.sps=[b],e.duration=s._duration;for(var S=b.subarray(1,4),C="avc1.",L=0;L<3;L++){var I=S[L].toString(16);I.length<2&&(I="0"+I),C+=I}e.codec=C}break;case 8:a=!0,e.pps||(e.pps=[u.data]);break;case 9:a=!1,e.audFound=!0,d&&ui(d,e),d=s.avcSample=Bi(!1,i.pts,i.dts,"");break;case 12:a=!0;break;default:a=!1,d&&(d.debug+="unknown NAL "+u.type+" ")}d&&a&&d.units.push(u)}),r&&d&&(ui(d,e),this.avcSample=null)},n.getLastNalUnit=function(e){var t,i,r=this.avcSample;if(r&&r.units.length!==0||(r=e[e.length-1]),(t=r)!=null&&t.units){var a=r.units;i=a[a.length-1]}return i},n.parseAVCNALu=function(e,t){var i,r,a=t.byteLength,s=e.naluState||0,l=s,d=[],c=0,u=-1,g=0;for(s===-1&&(u=0,g=31&t[0],s=0,c=1);c=0){var m={data:t.subarray(u,c-s-1),type:g};d.push(m)}else{var v=this.getLastNalUnit(e.samples);if(v&&(l&&c<=4-l&&v.state&&(v.data=v.data.subarray(0,v.data.byteLength-l)),(r=c-s-1)>0)){var y=new Uint8Array(v.data.byteLength+r);y.set(v.data,0),y.set(t.subarray(0,r),v.data.byteLength),v.data=y,v.state=0}}c=0&&s>=0){var _={data:t.subarray(u,a),type:g,state:s};d.push(_)}if(d.length===0){var b=this.getLastNalUnit(e.samples);if(b){var E=new Uint8Array(b.data.byteLength+t.byteLength);E.set(b.data,0),E.set(t,b.data.byteLength),b.data=E}}return e.naluState=s,d},n.parseAACPES=function(e,t){var i,r,a,s=0,l=this.aacOverFlow,d=t.data;if(l){this.aacOverFlow=null;var c=l.missing,u=l.sample.unit.byteLength;if(c===-1){var g=new Uint8Array(u+d.byteLength);g.set(l.sample.unit,0),g.set(d,u),d=g}else{var m=u-c;l.sample.unit.set(d.subarray(0,c),m),e.samples.push(l.sample),s=l.missing}}for(i=s,r=d.length;i1;){var l=new Uint8Array(s[0].length+s[1].length);l.set(s[0]),l.set(s[1],s[0].length),s[0]=l,s.splice(1,1)}if(((n=s[0])[0]<<16)+(n[1]<<8)+n[2]===1){if((e=(n[4]<<8)+n[5])&&e>o.size-6)return null;var d=n[7];192&d&&(i=536870912*(14&n[9])+4194304*(255&n[10])+16384*(254&n[11])+128*(255&n[12])+(254&n[13])/2,64&d?i-(r=536870912*(14&n[14])+4194304*(255&n[15])+16384*(254&n[16])+128*(255&n[17])+(254&n[18])/2)>54e5&&(R.warn(Math.round((i-r)/9e4)+"s delta between PTS and DTS, align them"),i=r):r=i);var c=(t=n[8])+9;if(o.size<=c)return null;o.size-=c;for(var u=new Uint8Array(o.size),g=0,m=s.length;gv){c-=v;continue}n=n.subarray(c),v-=c,c=0}u.set(n,a),a+=v}return e&&(e-=t+3),{data:u,pts:i,dts:r,len:e}}return null}function ui(o,n){if(o.units.length&&o.frame){if(o.pts===void 0){var e=n.samples,t=e.length;if(!t)return void n.dropped++;var i=e[t-1];o.pts=i.pts,o.dts=i.dts}n.samples.push(o)}o.debug.length&&R.log(o.pts+"/"+o.dts+":"+o.debug)}var el=function(o){function n(){return o.apply(this,arguments)||this}q(n,o);var e=n.prototype;return e.resetInitSegment=function(t,i,r,a){o.prototype.resetInitSegment.call(this,t,i,r,a),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:i,duration:a,inputTimeScale:9e4,dropped:0}},n.probe=function(t){if(!t)return!1;for(var i=(Ai(t,0)||[]).length,r=t.length;i1?t-1:0),r=1;r>24&255,l[1]=e>>16&255,l[2]=e>>8&255,l[3]=255&e,l.set(n,4),a=0,e=8;a>24&255,n>>16&255,n>>8&255,255&n,t>>24,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,85,196,0,0]))},o.mdia=function(n){return o.box(o.types.mdia,o.mdhd(n.timescale,n.duration),o.hdlr(n.type),o.minf(n))},o.mfhd=function(n){return o.box(o.types.mfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n]))},o.minf=function(n){return n.type==="audio"?o.box(o.types.minf,o.box(o.types.smhd,o.SMHD),o.DINF,o.stbl(n)):o.box(o.types.minf,o.box(o.types.vmhd,o.VMHD),o.DINF,o.stbl(n))},o.moof=function(n,e,t){return o.box(o.types.moof,o.mfhd(n),o.traf(t,e))},o.moov=function(n){for(var e=n.length,t=[];e--;)t[e]=o.trak(n[e]);return o.box.apply(null,[o.types.moov,o.mvhd(n[0].timescale,n[0].duration)].concat(t).concat(o.mvex(n)))},o.mvex=function(n){for(var e=n.length,t=[];e--;)t[e]=o.trex(n[e]);return o.box.apply(null,[o.types.mvex].concat(t))},o.mvhd=function(n,e){e*=n;var t=Math.floor(e/(xt+1)),i=Math.floor(e%(xt+1)),r=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,n>>24&255,n>>16&255,n>>8&255,255&n,t>>24,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return o.box(o.types.mvhd,r)},o.sdtp=function(n){var e,t,i=n.samples||[],r=new Uint8Array(4+i.length);for(e=0;e>>8&255),r.push(255&i),r=r.concat(Array.prototype.slice.call(t));for(e=0;e>>8&255),a.push(255&i),a=a.concat(Array.prototype.slice.call(t));var s=o.box(o.types.avcC,new Uint8Array([1,r[3],r[4],r[5],255,224|n.sps.length].concat(r).concat([n.pps.length]).concat(a))),l=n.width,d=n.height,c=n.pixelRatio[0],u=n.pixelRatio[1];return o.box(o.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,d>>8&255,255&d,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),s,o.box(o.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),o.box(o.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,u>>24,u>>16&255,u>>8&255,255&u])))},o.esds=function(n){var e=n.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(n.config).concat([6,1,2]))},o.mp4a=function(n){var e=n.samplerate;return o.box(o.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,n.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]),o.box(o.types.esds,o.esds(n)))},o.mp3=function(n){var e=n.samplerate;return o.box(o.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,n.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]))},o.stsd=function(n){return n.type==="audio"?n.segmentCodec==="mp3"&&n.codec==="mp3"?o.box(o.types.stsd,o.STSD,o.mp3(n)):o.box(o.types.stsd,o.STSD,o.mp4a(n)):o.box(o.types.stsd,o.STSD,o.avc1(n))},o.tkhd=function(n){var e=n.id,t=n.duration*n.timescale,i=n.width,r=n.height,a=Math.floor(t/(xt+1)),s=Math.floor(t%(xt+1));return o.box(o.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,s>>24,s>>16&255,s>>8&255,255&s,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>8&255,255&i,0,0,r>>8&255,255&r,0,0]))},o.traf=function(n,e){var t=o.sdtp(n),i=n.id,r=Math.floor(e/(xt+1)),a=Math.floor(e%(xt+1));return o.box(o.types.traf,o.box(o.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),o.box(o.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,a>>24,a>>16&255,a>>8&255,255&a])),o.trun(n,t.length+16+20+8+16+8+8),t)},o.trak=function(n){return n.duration=n.duration||4294967295,o.box(o.types.trak,o.tkhd(n),o.mdia(n))},o.trex=function(n){var e=n.id;return o.box(o.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},o.trun=function(n,e){var t,i,r,a,s,l,d=n.samples||[],c=d.length,u=12+16*c,g=new Uint8Array(u);for(e+=8+u,g.set([n.type==="video"?1:0,0,15,1,c>>>24&255,c>>>16&255,c>>>8&255,255&c,e>>>24&255,e>>>16&255,e>>>8&255,255&e],0),t=0;t>>24&255,r>>>16&255,r>>>8&255,255&r,a>>>24&255,a>>>16&255,a>>>8&255,255&a,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*t);return o.box(o.types.trun,g)},o.initSegment=function(n){o.types||o.init();var e=o.moov(n),t=new Uint8Array(o.FTYP.byteLength+e.byteLength);return t.set(o.FTYP),t.set(e,o.FTYP.byteLength),t},o}();function Mr(o,n,e,t){e===void 0&&(e=1),t===void 0&&(t=!1);var i=o*n*e;return t?Math.round(i):i}function fi(o,n){return Mr(o,1e3,1/9e4,n)}Le.types=void 0,Le.HDLR_TYPES=void 0,Le.STTS=void 0,Le.STSC=void 0,Le.STCO=void 0,Le.STSZ=void 0,Le.VMHD=void 0,Le.SMHD=void 0,Le.STSD=void 0,Le.FTYP=void 0,Le.DINF=void 0;var Ni=null,Fr=null,Br=function(){function o(e,t,i,r){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=!1,Ni===null){var a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ni=a?parseInt(a[1]):0}if(Fr===null){var s=navigator.userAgent.match(/Safari\/(\d+)/i);Fr=s?parseInt(s[1]):0}}var n=o.prototype;return n.destroy=function(){},n.resetTimeStamp=function(e){R.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},n.resetNextTimestamp=function(){R.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},n.resetInitSegment=function(){R.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},n.getVideoStartPts=function(e){var t=!1,i=e.reduce(function(r,a){var s=a.pts-r;return s<-4294967296?(t=!0,Qe(r,a.pts)):s>0?r:a.pts},e[0].pts);return t&&R.debug("PTS rollover detected"),i},n.remux=function(e,t,i,r,a,s,l,d){var c,u,g,m,v,y,_=a,b=a,E=e.pid>-1,S=t.pid>-1,C=t.samples.length,L=e.samples.length>0,I=l&&C>0||C>1;if((!E||L)&&(!S||I)||this.ISGenerated||l){this.ISGenerated||(g=this.generateIS(e,t,a,s));var P,N=this.isVideoContiguous,M=-1;if(I&&(M=function(re){for(var W=0;W0){R.warn("[mp4-remuxer]: Dropped "+M+" out of "+C+" video samples due to a missing keyframe");var B=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(M),t.dropped+=M,P=b+=(t.samples[0].pts-B)/t.inputTimeScale}else M===-1&&(R.warn("[mp4-remuxer]: No keyframe found out of "+C+" video samples"),y=!1);if(this.ISGenerated){if(L&&I){var Y=this.getVideoStartPts(t.samples),K=(Qe(e.samples[0].pts,Y)-Y)/t.inputTimeScale;_+=Math.max(0,K),b+=Math.max(0,-K)}if(L){if(e.samplerate||(R.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),g=this.generateIS(e,t,a,s)),u=this.remuxAudio(e,_,this.isAudioContiguous,s,S||I||d===lt?b:void 0),I){var Q=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(R.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),g=this.generateIS(e,t,a,s)),c=this.remuxVideo(t,b,N,Q)}}else I&&(c=this.remuxVideo(t,b,N,0));c&&(c.firstKeyFrame=M,c.independent=M!==-1,c.firstKeyFramePTS=P)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(v=Ma(i,a,this._initPTS,this._initDTS)),r.samples.length&&(m=Fa(r,a,this._initPTS))),{audio:u,video:c,initSegment:g,independent:y,text:m,id3:v}},n.generateIS=function(e,t,i,r){var a,s,l,d=e.samples,c=t.samples,u=this.typeSupported,g={},m=this._initPTS,v=!m||r,y="audio/mp4";if(v&&(a=s=1/0),e.config&&d.length&&(e.timescale=e.samplerate,e.segmentCodec==="mp3"&&(u.mpeg?(y="audio/mpeg",e.codec=""):u.mp3&&(e.codec="mp3")),g.audio={id:"audio",container:y,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&u.mpeg?new Uint8Array(0):Le.initSegment([e]),metadata:{channelCount:e.channelCount}},v&&(l=e.inputTimeScale,m&&l===m.timescale?v=!1:a=s=d[0].pts-Math.round(l*i))),t.sps&&t.pps&&c.length&&(t.timescale=t.inputTimeScale,g.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:Le.initSegment([t]),metadata:{width:t.width,height:t.height}},v))if(l=t.inputTimeScale,m&&l===m.timescale)v=!1;else{var _=this.getVideoStartPts(c),b=Math.round(l*i);s=Math.min(s,Qe(c[0].dts,_)-b),a=Math.min(a,_-b)}if(Object.keys(g).length)return this.ISGenerated=!0,v?(this._initPTS={baseTime:a,timescale:l},this._initDTS={baseTime:s,timescale:l}):a=l=void 0,{tracks:g,initPTS:a,timescale:l}},n.remuxVideo=function(e,t,i,r){var a,s,l=e.inputTimeScale,d=e.samples,c=[],u=d.length,g=this._initPTS,m=this.nextAvcDts,v=8,y=this.videoSampleDuration,_=Number.POSITIVE_INFINITY,b=Number.NEGATIVE_INFINITY,E=!1;i&&m!==null||(m=t*l-(d[0].pts-Qe(d[0].dts,d[0].pts)));for(var S=g.baseTime*l/g.timescale,C=0;C0?C-1:C].dts&&(E=!0)}E&&d.sort(function(Yi,yo){var Jl=Yi.dts-yo.dts,Zl=Yi.pts-yo.pts;return Jl||Zl}),a=d[0].dts;var I=(s=d[d.length-1].dts)-a,P=I?Math.round(I/(u-1)):y||e.inputTimeScale/30;if(i){var N=a-m,M=N>P,B=N<-1;if((M||B)&&(M?R.warn("AVC: "+fi(N,!0)+" ms ("+N+"dts) hole between fragments detected, filling it"):R.warn("AVC: "+fi(-N,!0)+" ms ("+N+"dts) overlapping between fragments detected"),!B||m>=d[0].pts)){a=m;var Y=d[0].pts-N;d[0].dts=a,d[0].pts=Y,R.log("Video: First PTS/DTS adjusted: "+fi(Y,!0)+"/"+fi(a,!0)+", delta: "+fi(N,!0)+" ms")}}a=Math.max(0,a);for(var K=0,Q=0,re=0;re0?De.dts-d[xe-1].dts:P;if(Ut=xe>0?De.pts-d[xe-1].pts:P,mi.stretchShortVideoTrack&&this.nextAudioPts!==null){var ql=Math.floor(mi.maxBufferHole*l),nn=(r?_+r*l:this.nextAudioPts)-De.pts;nn>ql?((y=nn-wt)<0?y=wt:Ge=!0,R.log("[mp4-remuxer]: It is approximately "+nn/90+" ms to the next segment; using duration "+y/90+" ms for the last video frame.")):y=wt}else y=wt}var $l=Math.round(De.pts-De.dts);ke=Math.min(ke,y),Xe=Math.max(Xe,y),et=Math.min(et,Ut),Je=Math.max(Je,Ut),c.push(new Ba(De.key,y,Tt,$l))}if(c.length){if(Ni){if(Ni<70){var mo=c[0].flags;mo.dependsOn=2,mo.isNonSync=0}}else if(Fr&&Je-et0&&(r&&Math.abs(E-b)<9e3||Math.abs(Qe(y[0].pts-S,E)-b)<20*c),y.forEach(function(Ye){Ye.pts=Qe(Ye.pts-S,E)}),!i||b<0){if(y=y.filter(function(Ye){return Ye.pts>=0}),!y.length)return;b=a===0?0:r&&!v?Math.max(0,E):y[0].pts}if(e.segmentCodec==="aac")for(var C=this.config.maxAudioFramesDrift,L=0,I=b;L=C*c&&B<1e4&&v){var Y=Math.round(M/c);(I=N-Y*c)<0&&(Y--,I+=c),L===0&&(this.nextAudioPts=b=I),R.warn("[mp4-remuxer]: Injecting "+Y+" audio frame @ "+(I/s).toFixed(3)+"s due to "+Math.round(1e3*M/s)+" ms gap.");for(var K=0;K0))return;Z+=_;try{W=new Uint8Array(Z)}catch(Ye){return void this.observer.emit(A.ERROR,A.ERROR,{type:ne.MUX_ERROR,details:O.REMUX_ALLOC_ERROR,fatal:!1,error:Ye,bytes:Z,reason:"fail allocating audio mdat "+Z})}g||(new DataView(W.buffer).setUint32(0,Z),W.set(Le.types.mdat,4))}W.set(Ge,_);var et=Ge.byteLength;_+=et,m.push(new Ba(!0,d,et,0)),ee=ke}var Xe=m.length;if(Xe){var Je=m[m.length-1];this.nextAudioPts=b=ee+l*Je.duration;var xe=g?new Uint8Array(0):Le.moof(e.sequenceNumber++,J/l,F({},e,{samples:m}));e.samples=[];var De=J/s,ct=b/s,Tt={data1:xe,data2:W,startPTS:De,endPTS:ct,startDTS:De,endDTS:ct,type:"audio",hasAudio:!0,hasVideo:!1,nb:Xe};return this.isAudioContiguous=!0,Tt}},n.remuxEmptyAudio=function(e,t,i,r){var a=e.inputTimeScale,s=a/(e.samplerate?e.samplerate:a),l=this.nextAudioPts,d=this._initDTS,c=9e4*d.baseTime/d.timescale,u=(l!==null?l:r.startDTS*a)+c,g=r.endDTS*a+c,m=1024*s,v=Math.ceil((g-u)/m),y=Oa.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(R.warn("[mp4-remuxer]: remux empty Audio"),y){for(var _=[],b=0;b4294967296;)o+=e;return o}function Ma(o,n,e,t){var i=o.samples.length;if(i){for(var r=o.inputTimeScale,a=0;a0;g||(u=ge(c,["encv"])),u.forEach(function(m){ge(g?m.subarray(28):m.subarray(78),["sinf"]).forEach(function(v){var y=Gn(v);if(y){var _=y.subarray(8,24);_.some(function(b){return b!==0})||(R.log("[eme] Patching keyId in 'enc"+(g?"a":"v")+">sinf>>tenc' box: "+ot(_)+" -> "+ot(l)),y.set(l,8))}})})}),a}(e,r)),this.emitInitSegment=!0},n.generateInitSegment=function(e){var t=this.audioCodec,i=this.videoCodec;if(e==null||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var r=this.initData=Un(e);t||(t=Na(r.audio,Be)),i||(i=Na(r.video,Ze));var a={};r.audio&&r.video?a.audiovideo={container:"video/mp4",codec:t+","+i,initSegment:e,id:"main"}:r.audio?a.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:r.video?a.video={container:"video/mp4",codec:i,initSegment:e,id:"main"}:R.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a},n.remux=function(e,t,i,r,a,s){var l,d,c=this.initPTS,u=this.lastEndTime,g={audio:void 0,video:void 0,text:r,id3:i,initSegment:void 0};ie(u)||(u=this.lastEndTime=a||0);var m=t.samples;if(m==null||!m.length)return g;var v={initPTS:void 0,timescale:1},y=this.initData;if((l=y)!=null&&l.length||(this.generateInitSegment(m),y=this.initData),(d=y)==null||!d.length)return R.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),g;this.emitInitSegment&&(v.tracks=this.initTracks,this.emitInitSegment=!1);var _=function(M,B){for(var Y=0,K=0,Q=0,re=ge(M,["moof","traf"]),W=0;WQ}(c,E,a,_)||v.timescale!==c.timescale&&s)&&(v.initPTS=E-a,c&&c.timescale===1&&R.warn("Adjusting initPTS by "+(v.initPTS-c.baseTime)),this.initPTS=c={baseTime:v.initPTS,timescale:1});var S=e?E-c.baseTime/c.timescale:u,C=S+_;(function(M,B,Y){ge(B,["moof","traf"]).forEach(function(K){ge(K,["tfhd"]).forEach(function(Q){var re=oe(Q,4),W=M[re];if(W){var J=W.timescale||9e4;ge(K,["tfdt"]).forEach(function(ee){var Z=ee[0],ae=oe(ee,4);if(Z===0)ae-=Y*J,cr(ee,4,ae=Math.max(ae,0));else{ae*=Math.pow(2,32),ae+=oe(ee,8),ae-=Y*J,ae=Math.max(ae,0);var he=Math.floor(ae/(ki+1)),fe=Math.floor(ae%(ki+1));cr(ee,4,he),cr(ee,8,fe)}})}})})})(y,m,c.baseTime/c.timescale),_>0?this.lastEndTime=C:(R.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var L=!!y.audio,I=!!y.video,P="";L&&(P+="audio"),I&&(P+="video");var N={data1:m,startPTS:S,startDTS:S,endPTS:C,endDTS:C,type:P,hasAudio:L,hasVideo:I,nb:1,dropped:0};return g.audio=N.type==="audio"?N:void 0,g.video=N.type!=="audio"?N:void 0,g.initSegment=v,g.id3=Ma(i,a,c,c),r.samples.length&&(g.text=Fa(r,a,c)),g},o}();function Na(o,n){var e=o==null?void 0:o.codec;return e&&e.length>4?e:e==="hvc1"||e==="hev1"?"hvc1.1.6.L120.90":e==="av01"?"av01.0.04M.08":e==="avc1"||n===Ze?"avc1.42e01e":"mp4a.40.5"}try{bt=self.performance.now.bind(self.performance)}catch{R.debug("Unable to use Performance API on this environment"),bt=typeof self<"u"&&self.Date.now}var Nr=[{demux:zs,remux:il},{demux:Xs,remux:Br},{demux:Ks,remux:Br},{demux:el,remux:Br}],Ur=function(){function o(e,t,i,r,a){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=i,this.vendor=r,this.id=a}var n=o.prototype;return n.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},n.push=function(e,t,i,r){var a=this,s=i.transmuxing;s.executeStart=bt();var l=new Uint8Array(e),d=this.currentTransmuxState,c=this.transmuxConfig;r&&(this.currentTransmuxState=r);var u=r||d,g=u.contiguous,m=u.discontinuity,v=u.trackSwitch,y=u.accurateTimeOffset,_=u.timeOffset,b=u.initSegmentChange,E=c.audioCodec,S=c.videoCodec,C=c.defaultInitPts,L=c.duration,I=c.initSegmentData,P=function(re,W){var J=null;return re.byteLength>0&&W!=null&&W.key!=null&&W.iv!==null&&W.method!=null&&(J=W),J}(l,t);if(P&&P.method==="AES-128"){var N=this.getDecrypter();if(!N.isSync())return this.decryptionPromise=N.webCryptoDecrypt(l,P.key.buffer,P.iv.buffer).then(function(re){var W=a.push(re,null,i);return a.decryptionPromise=null,W}),this.decryptionPromise;var M=N.softwareDecrypt(l,P.key.buffer,P.iv.buffer);if(i.part>-1&&(M=N.flush()),!M)return s.executeEnd=bt(),Gr(i);l=new Uint8Array(M)}var B=this.needsProbing(m,v);if(B){var Y=this.configureTransmuxer(l);if(Y)return R.warn("[transmuxer] "+Y.message),this.observer.emit(A.ERROR,A.ERROR,{type:ne.MEDIA_ERROR,details:O.FRAG_PARSING_ERROR,fatal:!1,error:Y,reason:Y.message}),s.executeEnd=bt(),Gr(i)}(m||v||b||B)&&this.resetInitSegment(I,E,S,L,t),(m||b||B)&&this.resetInitialTimestamp(C),g||this.resetContiguity();var K=this.transmux(l,P,_,y,i),Q=this.currentTransmuxState;return Q.contiguous=!0,Q.discontinuity=!1,Q.trackSwitch=!1,s.executeEnd=bt(),K},n.flush=function(e){var t=this,i=e.transmuxing;i.executeStart=bt();var r=this.decrypter,a=this.currentTransmuxState,s=this.decryptionPromise;if(s)return s.then(function(){return t.flush(e)});var l=[],d=a.timeOffset;if(r){var c=r.flush();c&&l.push(this.push(c,null,e))}var u=this.demuxer,g=this.remuxer;if(!u||!g)return i.executeEnd=bt(),[Gr(e)];var m=u.flush(d);return Ft(m)?m.then(function(v){return t.flushRemux(l,v,e),l}):(this.flushRemux(l,m,e),l)},n.flushRemux=function(e,t,i){var r=t.audioTrack,a=t.videoTrack,s=t.id3Track,l=t.textTrack,d=this.currentTransmuxState,c=d.accurateTimeOffset,u=d.timeOffset;R.log("[transmuxer.ts]: Flushed fragment "+i.sn+(i.part>-1?" p: "+i.part:"")+" of level "+i.level);var g=this.remuxer.remux(r,a,s,l,u,c,!0,this.id);e.push({remuxResult:g,chunkMeta:i}),i.transmuxing.executeEnd=bt()},n.resetInitialTimestamp=function(e){var t=this.demuxer,i=this.remuxer;t&&i&&(t.resetTimeStamp(e),i.resetTimeStamp(e))},n.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},n.resetInitSegment=function(e,t,i,r,a){var s=this.demuxer,l=this.remuxer;s&&l&&(s.resetInitSegment(e,t,i,r),l.resetInitSegment(e,t,i,a))},n.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},n.transmux=function(e,t,i,r,a){return t&&t.method==="SAMPLE-AES"?this.transmuxSampleAes(e,t,i,r,a):this.transmuxUnencrypted(e,i,r,a)},n.transmuxUnencrypted=function(e,t,i,r){var a=this.demuxer.demux(e,t,!1,!this.config.progressive),s=a.audioTrack,l=a.videoTrack,d=a.id3Track,c=a.textTrack;return{remuxResult:this.remuxer.remux(s,l,d,c,t,i,!1,this.id),chunkMeta:r}},n.transmuxSampleAes=function(e,t,i,r,a){var s=this;return this.demuxer.demuxSampleAes(e,t,i).then(function(l){return{remuxResult:s.remuxer.remux(l.audioTrack,l.videoTrack,l.id3Track,l.textTrack,i,r,!1,s.id),chunkMeta:a}})},n.configureTransmuxer=function(e){for(var t,i=this.config,r=this.observer,a=this.typeSupported,s=this.vendor,l=0,d=Nr.length;l"u"||(s.workerPath,0))this.transmuxer=new Ur(this.observer,m,s,v,t);else try{s.workerPath?(R.log("loading Web Worker "+s.workerPath+' for "'+t+'"'),this.workerContext=(u=s.workerPath,g=new self.URL(u,self.location.href).href,{worker:new self.Worker(g),scriptURL:g})):(R.log('injecting Web Worker for "'+t+'"'),this.workerContext=(d=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+k.toString()+")(true);"],{type:"text/javascript"}),c=self.URL.createObjectURL(d),{worker:new self.Worker(c),objectURL:c})),this.onwmsg=function(_){return a.onWorkerMessage(_)};var y=this.workerContext.worker;y.addEventListener("message",this.onwmsg),y.onerror=function(_){var b=new Error(_.message+" ("+_.filename+":"+_.lineno+")");s.enableWorker=!1,R.warn('Error in "'+t+'" Web Worker, fallback to inline'),a.hls.trigger(A.ERROR,{type:ne.OTHER_ERROR,details:O.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:b})},y.postMessage({cmd:"init",typeSupported:m,vendor:v,id:t,config:JSON.stringify(s)})}catch(_){R.warn('Error setting up "'+t+'" Web Worker, fallback to inline',_),this.resetWorker(),this.error=null,this.transmuxer=new Ur(this.observer,m,s,v,t)}}var n=o.prototype;return n.resetWorker=function(){if(this.workerContext){var e=this.workerContext,t=e.worker,i=e.objectURL;i&&self.URL.revokeObjectURL(i),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}},n.destroy=function(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},n.push=function(e,t,i,r,a,s,l,d,c,u){var g,m,v=this;c.transmuxing.start=self.performance.now();var y=this.transmuxer,_=s?s.start:a.start,b=a.decryptdata,E=this.frag,S=!(E&&a.cc===E.cc),C=!(E&&c.level===E.level),L=E?c.sn-E.sn:-1,I=this.part?c.part-this.part.index:-1,P=L===0&&c.id>1&&c.id===(E==null?void 0:E.stats.chunkCount),N=!C&&(L===1||L===0&&(I===1||P&&I<=0)),M=self.performance.now();(C||L||a.stats.parsing.start===0)&&(a.stats.parsing.start=M),!s||!I&&N||(s.stats.parsing.start=M);var B=!(E&&((g=a.initSegment)==null?void 0:g.url)===((m=E.initSegment)==null?void 0:m.url)),Y=new nl(S,N,d,C,_,B);if(!N||S||B){R.log("[transmuxer-interface, "+a.type+"]: Starting new transmux session for sn: "+c.sn+" p: "+c.part+" level: "+c.level+" id: "+c.id+` discontinuity: `+S+` trackSwitch: `+C+` diff --git a/assets/chunks/loading.vue_vue_type_style_index_0_lang.Byf79MII.js b/assets/chunks/loading.vue_vue_type_style_index_0_lang.gqANFo1t.js similarity index 84% rename from assets/chunks/loading.vue_vue_type_style_index_0_lang.Byf79MII.js rename to assets/chunks/loading.vue_vue_type_style_index_0_lang.gqANFo1t.js index e9fa45e2ff..76c765f2f2 100644 --- a/assets/chunks/loading.vue_vue_type_style_index_0_lang.Byf79MII.js +++ b/assets/chunks/loading.vue_vue_type_style_index_0_lang.gqANFo1t.js @@ -1 +1 @@ -import"./index.CafPLwUV.js";import{d as i,p as r,o,c as t,j as e,F as s,C as a,t as d}from"./framework.eq-HTtE3.js";const u={class:"loading"},p={class:"loading-icon"},m=["name"],h=i({__name:"loading",setup(_){const c=r(["stretch","rotate","double-bounce","cube","dot","triple-bounce","scale-out","circle","circle-line","square","pulse","solar","cube-fold","circle-fold","cube-grid","circle-turn","circle-rotate","circle-spin","dot-bar","dot-circle","line","dot-pulse","line-scale","text","cube-dim","dot-line","arc","drop","pacman"]);return(b,l)=>(o(),t("div",null,[l[0]||(l[0]=e("h3",null,"Move the mouse over the icon to see the loading animation",-1)),(o(!0),t(s,null,a(c.value,n=>(o(),t("div",null,[e("div",u,[e("div",null,d(n),1),e("div",p,[e("r-loading",{name:n},null,8,m)])])]))),256))]))}});export{h as _}; +import"./index.MWfHGcqb.js";import{d as i,p as r,o,c as t,j as e,F as s,C as a,t as d}from"./framework.CHSXtLMd.js";const u={class:"loading"},p={class:"loading-icon"},m=["name"],h=i({__name:"loading",setup(_){const c=r(["stretch","rotate","double-bounce","cube","dot","triple-bounce","scale-out","circle","circle-line","square","pulse","solar","cube-fold","circle-fold","cube-grid","circle-turn","circle-rotate","circle-spin","dot-bar","dot-circle","line","dot-pulse","line-scale","text","cube-dim","dot-line","arc","drop","pacman"]);return(b,l)=>(o(),t("div",null,[l[0]||(l[0]=e("h3",null,"Move the mouse over the icon to see the loading animation",-1)),(o(!0),t(s,null,a(c.value,n=>(o(),t("div",null,[e("div",u,[e("div",null,d(n),1),e("div",p,[e("r-loading",{name:n},null,8,m)])])]))),256))]))}});export{h as _}; diff --git a/assets/chunks/pdf-Cx0VWKFo.CmQSFM5C.js b/assets/chunks/pdf-Cx0VWKFo.BKCfi8kk.js similarity index 99% rename from assets/chunks/pdf-Cx0VWKFo.CmQSFM5C.js rename to assets/chunks/pdf-Cx0VWKFo.BKCfi8kk.js index b4e3d684ef..62f75522d2 100644 --- a/assets/chunks/pdf-Cx0VWKFo.CmQSFM5C.js +++ b/assets/chunks/pdf-Cx0VWKFo.BKCfi8kk.js @@ -1 +1 @@ -import{l as N}from"./index.CafPLwUV.js";import"./framework.eq-HTtE3.js";var s=Object.defineProperty,y=(A,I,g)=>I in A?s(A,I,{enumerable:!0,configurable:!0,writable:!0,value:g}):A[I]=g,C=(A,I,g)=>y(A,typeof I!="symbol"?I+"":I,g);const o="LyoqCiAqIEBsaWNzdGFydCBUaGUgZm9sbG93aW5nIGlzIHRoZSBlbnRpcmUgbGljZW5zZSBub3RpY2UgZm9yIHRoZQogKiBKYXZhU2NyaXB0IGNvZGUgaW4gdGhpcyBwYWdlCiAqCiAqIENvcHlyaWdodCAyMDIzIE1vemlsbGEgRm91bmRhdGlvbgogKgogKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgogKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKICoKICogICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAogKgogKiBVbmxlc3MgcmVxdWlyZWQgYnkgYXBwbGljYWJsZSBsYXcgb3IgYWdyZWVkIHRvIGluIHdyaXRpbmcsIHNvZnR3YXJlCiAqIGRpc3RyaWJ1dGVkIHVuZGVyIHRoZSBMaWNlbnNlIGlzIGRpc3RyaWJ1dGVkIG9uIGFuICJBUyBJUyIgQkFTSVMsCiAqIFdJVEhPVVQgV0FSUkFOVElFUyBPUiBDT05ESVRJT05TIE9GIEFOWSBLSU5ELCBlaXRoZXIgZXhwcmVzcyBvciBpbXBsaWVkLgogKiBTZWUgdGhlIExpY2Vuc2UgZm9yIHRoZSBzcGVjaWZpYyBsYW5ndWFnZSBnb3Zlcm5pbmcgcGVybWlzc2lvbnMgYW5kCiAqIGxpbWl0YXRpb25zIHVuZGVyIHRoZ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ZvOwogICAgICAgICAgICAgICAgZXhwb3J0cy5pc0FycmF5QnVmZmVyID0gaXNBcnJheUJ1ZmZlcjsKICAgICAgICAgICAgICAgIGV4cG9ydHMuaXNBcnJheUVxdWFsID0gaXNBcnJheUVxdWFsOwogICAgICAgICAgICAgICAgZXhwb3J0cy5vYmplY3RGcm9tTWFwID0gb2JqZWN0RnJvbU1hcDsKICAgICAgICAgICAgICAgIGV4cG9ydHMub2JqZWN0U2l6ZSA9IG9iamVjdFNpemU7CiAgICAgICAgICAgICAgICBleHBvcnRzLnNldFZlcmJvc2l0eUxldmVsID0gc2V0VmVyYm9zaXR5TGV2ZWw7CiAgICAgICAgICAgICAgICBleHBvcnRzLnNoYWRvdyA9IHNoYWRvdzsKICAgICAgICAgICAgICAgIGV4cG9ydHMuc3RyaW5nMzIgPSBzdHJpbmczMjsKICAgICAgICAgICAgICAgIGV4cG9ydHMuc3RyaW5nVG9CeXRlcyA9IHN0cmluZ1RvQnl0ZXM7CiAgICAgICAgICAgICAgICBleHBvcnRzLnN0cmluZ1RvUERGU3RyaW5nID0gc3RyaW5nVG9QREZTdHJpbmc7CiAgICAgICAgICAgICAgICBleHBvcnRzLnN0cmluZ1RvVVRGOFN0cmluZyA9IHN0cmluZ1RvVVRGOFN0cmluZzsKICAgICAgICAgICAgICAgIGV4cG9ydHMudW5yZWFjaGFibGUgPSB1bnJlYWNoYWJsZTsKICAgICAgICAgICAgICAgIGV4cG9ydHMudXRmOFN0cmluZ1RvU3RyaW5nID0gdXRmOFN0cmluZ1RvU3RyaW5nOwogICAgICAgICAgICAgICAgZXhwb3J0cy53YXJuID0gd2FybjsKICAgICAgICAgICAgICAgIGlmICghZ2xvYmFsVGhpcy5fcGRmanNDb21wYXRpYmlsaXR5Q2hlY2tlZCkgewogICAgICAgICAgICAgICAgICAgIGdsb2JhbFRoaXMuX3BkZmpzQ29tcGF0aWJpbGl0eUNoZWNrZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oMik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjb25zdCBJREVOVElUWV9NQVRSSVggPSBbMSwgMCwgMCwgMSwgMCwgMF07CiAgICAgICAgICAgICAgICBleHBvcnRzLklERU5USVRZX01BVFJJWCA9IElERU5USVRZX01BVFJJWDsKICAgICAgICAgICAgICAgIGNvbnN0IEZPTlRfSURFTlRJVFlfTUFUUklYID0gWzAuMDAxLCAwLCAwLCAwLjAwMSwgMCwgMF07CiAgICAgICAgICAgICAgICBleHBvcnRzLkZPTlRfSURFTlRJVFlfTUFUUklYID0gRk9OVF9JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICBjb25zdCBNQVhfSU1BR0VfU0laRV9UT19DQUNIRSA9IDEwZTY7CiAgICAgICAgICAgICAgICBleHBvcnRzLk1BWF9JTUFHRV9TSVpFX1RPX0NBQ0hFID0gTUFYX0lNQUdFX1NJWkVfVE9fQ0FDSEU7CiAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0ZBQ1RPUiA9IDEuMzU7CiAgICAgICAgICAgICAgICBleHBvcnRzLkxJTkVfRkFDVE9SID0gTElORV9GQUNUT1I7CiAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0RFU0NFTlRfRkFDVE9SID0gMC4zNTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuTElORV9ERVNDRU5UX0ZBQ1RPUiA9IExJTkVfREVTQ0VOVF9GQUNUT1I7CiAgICAgICAgICAgICAgICBjb25zdCBCQVNFTElORV9GQUNUT1IgPSBMSU5FX0RFU0NFTlRfRkFDVE9SIC8gTElORV9GQUNUT1I7CiAgICAgICAgICAgICAgICBleHBvcnRzLkJBU0VMSU5FX0ZBQ1RPUiA9IEJBU0VMSU5FX0ZBQ1RPUjsKICAgICAgICAgICAgICAgIGNvbnN0IFJlbmRlcmluZ0ludGVudEZsYWcgPSB7CiAgICAgICAgICAgICAgICAgICAgQU5ZOiAweDAxLAogICAgICAgICAgICAgICAgICAgIERJU1BMQVk6IDB4MDIsCiAgICAgICAgICAgICAgICAgICAgUFJJTlQ6IDB4MDQsCiAgICAgICAgICAgICAgICAgICAgU0FWRTogMHgwOCwKICAgICAgICAgICAgICAgICAgICBBTk5PVEFUSU9OU19GT1JNUzogMHgxMCwKICAgICAgICAgICAgICAgICAgICBBTk5PVEFUSU9OU19TVE9SQUdFOiAweDIwLAogICAgICAgICAgICAgICAgICAgIEFOTk9UQVRJT05TX0RJU0FCTEU6IDB4NDAsCiAgICAgICAgICAgICAgICAgICAgT1BMSVNUOiAweDEwMAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuUmVuZGVyaW5nSW50ZW50RmxhZyA9IFJlbmRlcmluZ0ludGVudEZsYWc7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uTW9kZSA9IHsKICAgICAgICAgICAgICAgICAgICBESVNBQkxFOiAwLAogICAgICAgICAgICAgICAgICAgIEVOQUJMRTogMSwKICAgICAgICAgICAgICAgICAgICBFTkFCTEVfRk9STVM6IDIsCiAgICAgICAgICAgICAgICAgICAgRU5BQkxFX1NUT1JBR0U6IDMKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25Nb2RlID0gQW5ub3RhdGlvbk1vZGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uRWRpdG9yUHJlZml4ID0gInBkZmpzX2ludGVybmFsX2VkaXRvcl8iOwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yUHJlZml4ID0gQW5ub3RhdGlvbkVkaXRvclByZWZpeDsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25FZGl0b3JUeXBlID0gewogICAgICAgICAgICAgICAgICAgIERJU0FCTEU6IC0xLAogICAgICAgICAgICAgICAgICAgIE5PTkU6IDAsCiAgICAgICAgICAgICAgICAgICAgRlJFRVRFWFQ6IDMsCiAgICAgICAgICAgICAgICAgICAgSU5LOiAxNQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvclR5cGUgPSBBbm5vdGF0aW9uRWRpdG9yVHlwZTsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlID0gewogICAgICAgICAgICAgICAgICAgIEZSRUVURVhUX1NJWkU6IDEsCiAgICAgICAgICAgICAgICAgICAgRlJFRVRFWFRfQ09MT1I6IDIsCiAgICAgICAgICAgICAgICAgICAgRlJFRVRFWFRfT1BBQ0lUWTogMywKICAgICAgICAgICAgICAgICAgICBJTktfQ09MT1I6IDExLAogICAgICAgICAgICAgICAgICAgIElOS19USElDS05FU1M6IDEyLAogICAgICAgICAgICAgICAgICAgIElOS19PUEFDSVRZOiAxMwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUgPSBBbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZTsKICAgICAgICAgICAgICAgIGNvbnN0IFBlcm1pc3Npb25GbGFnID0gewogICAgICAgICAgICAgICAgICAgIFBSSU5UOiAweDA0LAogICAgICAgICAgICAgICAgICAgIE1PRElGWV9DT05URU5UUzogMHgwOCwKICAgICAgICAgICAgICAgICAgICBDT1BZOiAweDEwLAogICAgICAgICAgICAgICAgICAgIE1PRElGWV9BTk5PVEFUSU9OUzogMHgyMCwKICAgICAgICAgICAgICAgICAgICBGSUxMX0lOVEVSQUNUSVZFX0ZPUk1TOiAweDEwMCwKICAgICAgICAgICAgICAgICAgICBDT1BZX0ZPUl9BQ0NFU1NJQklMSVRZOiAweDIwMCwKICAgICAgICAgICAgICAgICAgICBBU1NFTUJMRTogMHg0MDAsCiAgICAgICAgICAgICAgICAgICAgUFJJTlRfSElHSF9RVUFMSVRZOiAweDgwMAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuUGVybWlzc2lvbkZsYWcgPSBQZXJtaXNzaW9uRmxhZzsKICAgICAgICAgICAgICAgIGNvbnN0IFRleHRSZW5kZXJpbmdNb2RlID0gewogICAgICAgICAgICAgICAgICAgIEZJTEw6IDAsCiAgICAgICAgICAgICAgICAgICAgU1RST0tFOiAxLAogICAgICAgICAgICAgICAgICAgIEZJTExfU1RST0tFOiAyLAogICAgICAgICAgICAgICAgICAgIElOVklTSUJMRTogMywKICAgICAgICAgICAgICAgICAgICBGSUxMX0FERF9UT19QQVRIOiA0LAogICAgICAgICAgICAgICAgICAgIFNUUk9LRV9BRERfVE9fUEFUSDogNSwKICAgICAgICAgICAgICAgICAgICBGSUxMX1NUUk9LRV9BRERfVE9fUEFUSDogNiwKICAgICAgICAgICAgICAgICAgICBBRERfVE9fUEFUSDogNywKICAgICAgICAgICAgICAgICAgICBGSUxMX1NUUk9LRV9NQVNLOiAzLAogICAgICAgICAgICAgICAgICAgIEFERF9UT19QQVRIX0ZMQUc6IDQKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLlRleHRSZW5kZXJpbmdNb2RlID0gVGV4dFJlbmRlcmluZ01vZGU7CiAgICAgICAgICAgICAgICBjb25zdCBJbWFnZUtpbmQgPSB7CiAgICAgICAgICAgICAgICAgICAgR1JBWVNDQUxFXzFCUFA6IDEsCiAgICAgICAgICAgICAgICAgICAgUkdCXzI0QlBQOiAyLAogICAgICAgICAgICAgICAgICAgIFJHQkFfMzJCUFA6IDMKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkltYWdlS2luZCA9IEltYWdlS2luZDsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25UeXBlID0gewogICAgICAgICAgICAgICAgICAgIFRFWFQ6IDEsCiAgICAgICAgICAgICAgICAgICAgTElOSzogMiwKICAgICAgICAgICAgICAgICAgICBGUkVFVEVYVDogMywKICAgICAgICAgICAgICAgICAgICBMSU5FOiA0LAogICAgICAgICAgICAgICAgICAgIFNRVUFSRTogNSwKICAgICAgICAgICAgICAgICAgICBDSVJDTEU6IDYsCiAgICAgICAgICAgICAgICAgICAgUE9MWUdPTjogNywKICAgICAgICAgICAgICAgICAgICBQT0xZTElORTogOCwKICAgICAgICAgICAgICAgICAgICBISUdITElHSFQ6IDksCiAgICAgICAgICAgICAgICAgICAgVU5ERVJMSU5FOiAxMCwKICAgICAgICAgICAgICAgICAgICBTUVVJR0dMWTogMTEsCiAgICAgICAgICAgICAgICAgICAgU1RSSUtFT1VUOiAxMiwKICAgICAgICAgICAgICAgICAgICBTVEFNUDogMTMsCiAgICAgICAgICAgICAgICAgICAgQ0FSRVQ6IDE0LAogICAgICAgICAgICAgICAgICAgIElOSzogMTUsCiAgICAgICAgICAgICAgICAgICAgUE9QVVA6IDE2LAogICAgICAgICAgICAgICAgICAgIEZJTEVBVFRBQ0hNRU5UOiAxNywKICAgICAgICAgICAgICAgICAgICBTT1VORDogMTgsCiAgICAgICAgICAgICAgICAgICAgTU9WSUU6IDE5LAogICAgICAgICAgICAgICAgICAgIFdJREdFVDogMjAsCiAgICAgICAgICAgICAgICAgICAgU0NSRUVOOiAyMSwKICAgICAgICAgICAgICAgICAgICBQUklOVEVSTUFSSzogMjIsCiAgICAgICAgICAgICAgICAgICAgVFJBUE5FVDogMjMsCiAgICAgICAgICAgICAgICAgICAgV0FURVJNQVJLOiAyNCwKICAgICAgICAgICAgICAgICAgICBUSFJFRUQ6IDI1LAogICAgICAgICAgICAgICAgICAgIFJFREFDVDogMjYKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25UeXBlID0gQW5ub3RhdGlvblR5cGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uU3RhdGVNb2RlbFR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgTUFSS0VEOiAiTWFya2VkIiwKICAgICAgICAgICAgICAgICAgICBSRVZJRVc6ICJSZXZpZXciCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uU3RhdGVNb2RlbFR5cGUgPSBBbm5vdGF0aW9uU3RhdGVNb2RlbFR5cGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uTWFya2VkU3RhdGUgPSB7CiAgICAgICAgICAgICAgICAgICAgTUFSS0VEOiAiTWFya2VkIiwKICAgICAgICAgICAgICAgICAgICBVTk1BUktFRDogIlVubWFya2VkIgogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbk1hcmtlZFN0YXRlID0gQW5ub3RhdGlvbk1hcmtlZFN0YXRlOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvblJldmlld1N0YXRlID0gewogICAgICAgICAgICAgICAgICAgIEFDQ0VQVEVEOiAiQWNjZXB0ZWQiLAogICAgICAgICAgICAgICAgICAgIFJFSkVDVEVEOiAiUmVqZWN0ZWQiLAogICAgICAgICAgICAgICAgICAgIENBTkNFTExFRDogIkNhbmNlbGxlZCIsCiAgICAgICAgICAgICAgICAgICAgQ09NUExFVEVEOiAiQ29tcGxldGVkIiwKICAgICAgICAgICAgICAgICAgICBOT05FOiAiTm9uZSIKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25SZXZpZXdTdGF0ZSA9IEFubm90YXRpb25SZXZpZXdTdGF0ZTsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25SZXBseVR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgR1JPVVA6ICJHcm91cCIsCiAgICAgICAgICAgICAgICAgICAgUkVQTFk6ICJSIgogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvblJlcGx5VHlwZSA9IEFubm90YXRpb25SZXBseVR5cGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uRmxhZyA9IHsKICAgICAgICAgICAgICAgICAgICBJTlZJU0lCTEU6IDB4MDEsCiAgICAgICAgICAgICAgICAgICAgSElEREVOOiAweDAyLAogICAgICAgICAgICAgICAgICAgIFBSSU5UOiAweDA0LAogICAgICAgICAgICAgICAgICAgIE5PWk9PTTogMHgwOCwKICAgICAgICAgICAgICAgICAgICBOT1JPVEFURTogMHgxMCwKICAgICAgICAgICAgICAgICAgICBOT1ZJRVc6IDB4MjAsCiAgICAgICAgICAgICAgICAgICAgUkVBRE9OTFk6IDB4NDAsCiAgICAgICAgICAgICAgICAgICAgTE9DS0VEOiAweDgwLAogICAgICAgICAgICAgICAgICAgIFRPR0dMRU5PVklFVzogMHgxMDAsCiAgICAgICAgICAgICAgICAgICAgTE9DS0VEQ09OVEVOVFM6IDB4MjAwCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRmxhZyA9IEFubm90YXRpb25GbGFnOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvbkZpZWxkRmxhZyA9IHsKICAgICAgICAgICAgICAgICAgICBSRUFET05MWTogMHgwMDAwMDAxLAogICAgICAgICAgICAgICAgICAgIFJFUVVJUkVEOiAweDAwMDAwMDIsCiAgICAgICAgICAgICAgICAgICAgTk9FWFBPUlQ6IDB4MDAwMDAwNCwKICAgICAgICAgICAgICAgICAgICBNVUxUSUxJTkU6IDB4MDAwMTAwMCwKICAgICAgICAgICAgICAgICAgICBQQVNTV09SRDogMHgwMDAyMDAwLAogICAgICAgICAgICAgICAgICAgIE5PVE9HR0xFVE9PRkY6IDB4MDAwNDAwMCwKICAgICAgICAgICAgICAgICAgICBSQURJTzogMHgwMDA4MDAwLAogICAgICAgICAgICAgICAgICAgIFBVU0hCVVRUT046IDB4MDAxMDAwMCwKICAgICAgICAgICAgICAgICAgICBDT01CTzogMHgwMDIwMDAwLAogICAgICAgICAgICAgICAgICAgIEVESVQ6IDB4MDA0MDAwMCwKICAgICAgICAgICAgICAgICAgICBTT1JUOiAweDAwODAwMDAsCiAgICAgICAgICAgICAgICAgICAgRklMRVNFTEVDVDogMHgwMTAwMDAwLAogICAgICAgICAgICAgICAgICAgIE1VTFRJU0VMRUNUOiAweDAyMDAwMDAsCiAgICAgICAgICAgICAgICAgICAgRE9OT1RTUEVMTENIRUNLOiAweDA0MDAwMDAsCiAgICAgICAgICAgICAgICAgICAgRE9OT1RTQ1JPTEw6IDB4MDgwMDAwMCwKICAgICAgICAgICAgICAgICAgICBDT01COiAweDEwMDAwMDAsCiAgICAgICAgICAgICAgICAgICAgUklDSFRFWFQ6IDB4MjAwMDAwMCwKICAgICAgICAgICAgICAgICAgICBSQURJT1NJTlVOSVNPTjogMHgyMDAwMDAwLAogICAgICAgICAgICAgICAgICAgIENPTU1JVE9OU0VMQ0hBTkdFOiAweDQwMDAwMDAKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25GaWVsZEZsYWcgPSBBbm5vdGF0aW9uRmllbGRGbGFnOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvbkJvcmRlclN0eWxlVHlwZSA9IHsKICAgICAgICAgICAgICAgICAgICBTT0xJRDogMSwKICAgICAgICAgICAgICAgICAgICBEQVNIRUQ6IDIsCiAgICAgICAgICAgICAgICAgICAgQkVWRUxFRDogMywKICAgICAgICAgICAgICAgICAgICBJTlNFVDogNCwKICAgICAgICAgICAgICAgICAgICBVTkRFUkxJTkU6IDUKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25Cb3JkZXJTdHlsZVR5cGUgPSBBbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvbkFjdGlvbkV2ZW50VHlwZSA9IHsKICAgICAgICAgICAgICAgICAgICBFOiAiTW91c2UgRW50ZXIiLAogICAgICAgICAgICAgICAgICAgIFg6ICJNb3VzZSBFeGl0IiwKICAgICAgICAgICAgICAgICAgICBEOiAiTW91c2UgRG93biIsCiAgICAgICAgICAgICAgICAgICAgVTogIk1vdXNlIFVwIiwKICAgICAgICAgICAgICAgICAgICBGbzogIkZvY3VzIiwKICAgICAgICAgICAgICAgICAgICBCbDogIkJsdXIiLAogICAgICAgICAgICAgICAgICAgIFBPOiAiUGFnZU9wZW4iLAogICAgICAgICAgICAgICAgICAgIFBDOiAiUGFnZUNsb3NlIiwKICAgICAgICAgICAgICAgICAgICBQVjogIlBhZ2VWaXNpYmxlIiwKICAgICAgICAgICAgICAgICAgICBQSTogIlBhZ2VJbnZpc2libGUiLAogICAgICAgICAgICAgICAgICAgIEs6ICJLZXlzdHJva2UiLAogICAgICAgICAgICAgICAgICAgIEY6ICJGb3JtYXQiLAogICAgICAgICAgICAgICAgICAgIFY6ICJWYWxpZGF0ZSIsCiAgICAgICAgICAgICAgICAgICAgQzogIkNhbGN1bGF0ZSIKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25BY3Rpb25FdmVudFR5cGUgPSBBbm5vdGF0aW9uQWN0aW9uRXZlbnRUeXBlOwogICAgICAgICAgICAgICAgY29uc3QgRG9jdW1lbnRBY3Rpb25FdmVudFR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgV0M6ICJXaWxsQ2xvc2UiLAogICAgICAgICAgICAgICAgICAgIFdTOiAiV2lsbFNhdmUiLAogICAgICAgICAgICAgICAgICAgIERTOiAiRGlkU2F2ZSIsCiAgICAgICAgICAgICAgICAgICAgV1A6ICJXaWxsUHJpbnQiLAogICAgICAgICAgICAgICAgICAgIERQOiAiRGlkUHJpbnQiCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5Eb2N1bWVudEFjdGlvbkV2ZW50VHlwZSA9IERvY3VtZW50QWN0aW9uRXZlbnRUeXBlOwogICAgICAgICAgICAgICAgY29uc3QgUGFnZUFjdGlvbkV2ZW50VHlwZSA9IHsKICAgICAgICAgICAgICAgICAgICBPOiAiUGFnZU9wZW4iLAogICAgICAgICAgICAgICAgICAgIEM6ICJQYWdlQ2xvc2UiCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5QYWdlQWN0aW9uRXZlbnRUeXBlID0gUGFnZUFjdGlvbkV2ZW50VHlwZTsKICAgICAgICAgICAgICAgIGNvbnN0IFZlcmJvc2l0eUxldmVsID0gewogICAgICAgICAgICAgICAgICAgIEVSUk9SUzogMCwKICAgICAgICAgICAgICAgICAgICBXQVJOSU5HUzogMSwKICAgICAgICAgICAgICAgICAgICBJTkZPUzogNQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuVmVyYm9zaXR5TGV2ZWwgPSBWZXJib3NpdHlMZXZlbDsKICAgICAgICAgICAgICAgIGNvbnN0IENNYXBDb21wcmVzc2lvblR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgTk9ORTogMCwKICAgICAgICAgICAgICAgICAgICBCSU5BUlk6IDEKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkNNYXBDb21wcmVzc2lvblR5cGUgPSBDTWFwQ29tcHJlc3Npb25UeXBlOwogICAgICAgICAgICAgICAgY29uc3QgT1BTID0gewogICAgICAgICAgICAgICAgICAgIGRlcGVuZGVuY3k6IDEsCiAgICAgICAgICAgICAgICAgICAgc2V0TGluZVdpZHRoOiAyLAogICAgICAgICAgICAgICAgICAgIHNldExpbmVDYXA6IDMsCiAgICAgICAgICAgICAgICAgICAgc2V0TGluZUpvaW46IDQsCiAgICAgICAgICAgICAgICAgICAgc2V0TWl0ZXJMaW1pdDogNSwKICAgICAgICAgICAgICAgICAgICBzZXREYXNoOiA2LAogICAgICAgICAgICAgICAgICAgIHNldFJlbmRlcmluZ0ludGVudDogNywKICAgICAgICAgICAgICAgICAgICBzZXRGbGF0bmVzczogOCwKICAgICAgICAgICAgICAgICAgICBzZXRHU3RhdGU6IDksCiAgICAgICAgICAgICAgICAgICAgc2F2ZTogMTAsCiAgICAgICAgICAgICAgICAgICAgcmVzdG9yZTogMTEsCiAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtOiAxMiwKICAgICAgICAgICAgICAgICAgICBtb3ZlVG86IDEzLAogICAgICAgICAgICAgICAgICAgIGxpbmVUbzogMTQsCiAgICAgICAgICAgICAgICAgICAgY3VydmVUbzogMTUsCiAgICAgICAgICAgICAgICAgICAgY3VydmVUbzI6IDE2LAogICAgICAgICAgICAgICAgICAgIGN1cnZlVG8zOiAxNywKICAgICAgICAgICAgICAgICAgICBjbG9zZVBhdGg6IDE4LAogICAgICAgICAgICAgICAgICAgIHJlY3RhbmdsZTogMTksCiAgICAgICAgICAgICAgICAgICAgc3Ryb2tlOiAyMCwKICAgICAgICAgICAgICAgICAgICBjbG9zZVN0cm9rZTogMjEsCiAgICAgICAgICAgICAgICAgICAgZmlsbDogMjIsCiAgICAgICAgICAgICAgICAgICAgZW9GaWxsOiAyMywKICAgICAgICAgICAgICAgICAgICBmaWxsU3Ryb2tlOiAyNCwKICAgICAgICAgICAgICAgICAgICBlb0ZpbGxTdHJva2U6IDI1LAogICAgICAgICAgICAgICAgICAgIGNsb3NlRmlsbFN0cm9rZTogMjYsCiAgICAgICAgICAgICAgICAgICAgY2xvc2VFT0ZpbGxTdHJva2U6IDI3LAogICAgICAgICAgICAgICAgICAgIGVuZFBhdGg6IDI4LAogICAgICAgICAgICAgICAgICAgIGNsaXA6IDI5LAogICAgICAgICAgICAgICAgICAgIGVvQ2xpcDogMzAsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5UZXh0OiAzMSwKICAgICAgICAgICAgICAgICAgICBlbmRUZXh0OiAzMiwKICAgICAgICAgICAgICAgICAgICBzZXRDaGFyU3BhY2luZzogMzMsCiAgICAgICAgICAgICAgICAgICAgc2V0V29yZFNwYWNpbmc6IDM0LAogICAgICAgICAgICAgICAgICAgIHNldEhTY2FsZTogMzUsCiAgICAgICAgICAgICAgICAgICAgc2V0TGVhZGluZzogMzYsCiAgICAgICAgICAgICAgICAgICAgc2V0Rm9udDogMzcsCiAgICAgICAgICAgICAgICAgICAgc2V0VGV4dFJlbmRlcmluZ01vZGU6IDM4LAogICAgICAgICAgICAgICAgICAgIHNldFRleHRSaXNlOiAzOSwKICAgICAgICAgICAgICAgICAgICBtb3ZlVGV4dDogNDAsCiAgICAgICAgICAgICAgICAgICAgc2V0TGVhZGluZ01vdmVUZXh0OiA0MSwKICAgICAgICAgICAgICAgICAgICBzZXRUZXh0TWF0cml4OiA0MiwKICAgICAgICAgICAgICAgICAgICBuZXh0TGluZTogNDMsCiAgICAgICAgICAgICAgICAgICAgc2hvd1RleHQ6IDQ0LAogICAgICAgICAgICAgICAgICAgIHNob3dTcGFjZWRUZXh0OiA0NSwKICAgICAgICAgICAgICAgICAgICBuZXh0TGluZVNob3dUZXh0OiA0NiwKICAgICAgICAgICAgICAgICAgICBuZXh0TGluZVNldFNwYWNpbmdTaG93VGV4dDogNDcsCiAgICAgICAgICAgICAgICAgICAgc2V0Q2hhcldpZHRoOiA0OCwKICAgICAgICAgICAgICAgICAgICBzZXRDaGFyV2lkdGhBbmRCb3VuZHM6IDQ5LAogICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZUNvbG9yU3BhY2U6IDUwLAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDb2xvclNwYWNlOiA1MSwKICAgICAgICAgICAgICAgICAgICBzZXRTdHJva2VDb2xvcjogNTIsCiAgICAgICAgICAgICAgICAgICAgc2V0U3Ryb2tlQ29sb3JOOiA1MywKICAgICAgICAgICAgICAgICAgICBzZXRGaWxsQ29sb3I6IDU0LAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDb2xvck46IDU1LAogICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZUdyYXk6IDU2LAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxHcmF5OiA1NywKICAgICAgICAgICAgICAgICAgICBzZXRTdHJva2VSR0JDb2xvcjogNTgsCiAgICAgICAgICAgICAgICAgICAgc2V0RmlsbFJHQkNvbG9yOiA1OSwKICAgICAgICAgICAgICAgICAgICBzZXRTdHJva2VDTVlLQ29sb3I6IDYwLAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDTVlLQ29sb3I6IDYxLAogICAgICAgICAgICAgICAgICAgIHNoYWRpbmdGaWxsOiA2MiwKICAgICAgICAgICAgICAgICAgICBiZWdpbklubGluZUltYWdlOiA2MywKICAgICAgICAgICAgICAgICAgICBiZWdpbkltYWdlRGF0YTogNjQsCiAgICAgICAgICAgICAgICAgICAgZW5kSW5saW5lSW1hZ2U6IDY1LAogICAgICAgICAgICAgICAgICAgIHBhaW50WE9iamVjdDogNjYsCiAgICAgICAgICAgICAgICAgICAgbWFya1BvaW50OiA2NywKICAgICAgICAgICAgICAgICAgICBtYXJrUG9pbnRQcm9wczogNjgsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5NYXJrZWRDb250ZW50OiA2OSwKICAgICAgICAgICAgICAgICAgICBiZWdpbk1hcmtlZENvbnRlbnRQcm9wczogNzAsCiAgICAgICAgICAgICAgICAgICAgZW5kTWFya2VkQ29udGVudDogNzEsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5Db21wYXQ6IDcyLAogICAgICAgICAgICAgICAgICAgIGVuZENvbXBhdDogNzMsCiAgICAgICAgICAgICAgICAgICAgcGFpbnRGb3JtWE9iamVjdEJlZ2luOiA3NCwKICAgICAgICAgICAgICAgICAgICBwYWludEZvcm1YT2JqZWN0RW5kOiA3NSwKICAgICAgICAgICAgICAgICAgICBiZWdpbkdyb3VwOiA3NiwKICAgICAgICAgICAgICAgICAgICBlbmRHcm91cDogNzcsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5Bbm5vdGF0aW9uOiA4MCwKICAgICAgICAgICAgICAgICAgICBlbmRBbm5vdGF0aW9uOiA4MSwKICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlTWFza1hPYmplY3Q6IDgzLAogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VNYXNrWE9iamVjdEdyb3VwOiA4NCwKICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlWE9iamVjdDogODUsCiAgICAgICAgICAgICAgICAgICAgcGFpbnRJbmxpbmVJbWFnZVhPYmplY3Q6IDg2LAogICAgICAgICAgICAgICAgICAgIHBhaW50SW5saW5lSW1hZ2VYT2JqZWN0R3JvdXA6IDg3LAogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VYT2JqZWN0UmVwZWF0OiA4OCwKICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlTWFza1hPYmplY3RSZXBlYXQ6IDg5LAogICAgICAgICAgICAgICAgICAgIHBhaW50U29saWRDb2xvckltYWdlTWFzazogOTAsCiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0UGF0aDogOTEKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLk9QUyA9IE9QUzsKICAgICAgICAgICAgICAgIGNvbnN0IFBhc3N3b3JkUmVzcG9uc2VzID0gewogICAgICAgICAgICAgICAgICAgIE5FRURfUEFTU1dPUkQ6IDEsCiAgICAgICAgICAgICAgICAgICAgSU5DT1JSRUNUX1BBU1NXT1JEOiAyCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5QYXNzd29yZFJlc3BvbnNlcyA9IFBhc3N3b3JkUmVzcG9uc2VzOwogICAgICAgICAgICAgICAgbGV0IHZlcmJvc2l0eSA9IFZlcmJvc2l0eUxldmVsLldBUk5JTkdTOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gc2V0VmVyYm9zaXR5TGV2ZWwobGV2ZWwpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihsZXZlbCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmVyYm9zaXR5ID0gbGV2ZWw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0VmVyYm9zaXR5TGV2ZWwoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZlcmJvc2l0eTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGluZm8obXNnKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHZlcmJvc2l0eSA+PSBWZXJib3NpdHlMZXZlbC5JTkZPUykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhgSW5mbzogJHttc2d9YCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gd2Fybihtc2cpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodmVyYm9zaXR5ID49IFZlcmJvc2l0eUxldmVsLldBUk5JTkdTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKGBXYXJuaW5nOiAke21zZ31gKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiB1bnJlYWNoYWJsZShtc2cpIHsKICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IobXNnKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGFzc2VydChjb25kLCBtc2cpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWNvbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdW5yZWFjaGFibGUobXNnKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfaXNWYWxpZFByb3RvY29sKHVybCkgewogICAgICAgICAgICAgICAgICAgIGlmICghdXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh1cmwucHJvdG9jb2wpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiaHR0cDoiOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJodHRwczoiOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJmdHA6IjoKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAibWFpbHRvOiI6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgInRlbDoiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY3JlYXRlVmFsaWRBYnNvbHV0ZVVybCh1cmwpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgYmFzZVVybCA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBsZXQgb3B0aW9ucyA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBpZiAoIXVybCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMgJiYgdHlwZW9mIHVybCA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcHRpb25zLmFkZERlZmF1bHRQcm90b2NvbCAmJiB1cmwuc3RhcnRzV2l0aCgid3d3LiIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZG90cyA9IHVybC5tYXRjaCgvXC4vZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRvdHMgJiYgZG90cy5sZW5ndGggPj0gMikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmwgPSBgaHR0cDovLyR7dXJsfWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMudHJ5Q29udmVydEVuY29kaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsID0gc3RyaW5nVG9VVEY4U3RyaW5nKHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHt9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWJzb2x1dGVVcmwgPSBiYXNlVXJsID8gbmV3IFVSTCh1cmwsIGJhc2VVcmwpIDogbmV3IFVSTCh1cmwpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2lzVmFsaWRQcm90b2NvbChhYnNvbHV0ZVVybCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhYnNvbHV0ZVVybDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7fQogICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gc2hhZG93KG9iaiwgcHJvcCwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgbm9uU2VyaWFsaXphYmxlID0gYXJndW1lbnRzLmxlbmd0aCA+IDMgJiYgYXJndW1lbnRzWzNdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbM10gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkob2JqLCBwcm9wLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiAhbm9uU2VyaWFsaXphYmxlLAogICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiBmYWxzZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbnN0IEJhc2VFeGNlcHRpb24gPSBmdW5jdGlvbiBCYXNlRXhjZXB0aW9uQ2xvc3VyZSgpIHsKICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBCYXNlRXhjZXB0aW9uKG1lc3NhZ2UsIG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IEJhc2VFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVucmVhY2hhYmxlKCJDYW5ub3QgaW5pdGlhbGl6ZSBCYXNlRXhjZXB0aW9uLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWVzc2FnZSA9IG1lc3NhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmFtZSA9IG5hbWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIEJhc2VFeGNlcHRpb24ucHJvdG90eXBlID0gbmV3IEVycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgQmFzZUV4Y2VwdGlvbi5jb25zdHJ1Y3RvciA9IEJhc2VFeGNlcHRpb247CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEJhc2VFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9KCk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkJhc2VFeGNlcHRpb24gPSBCYXNlRXhjZXB0aW9uOwogICAgICAgICAgICAgICAgY2xhc3MgUGFzc3dvcmRFeGNlcHRpb24gZXh0ZW5kcyBCYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2csIGNvZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIobXNnLCAiUGFzc3dvcmRFeGNlcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2RlID0gY29kZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBhc3N3b3JkRXhjZXB0aW9uID0gUGFzc3dvcmRFeGNlcHRpb247CiAgICAgICAgICAgICAgICBjbGFzcyBVbmtub3duRXJyb3JFeGNlcHRpb24gZXh0ZW5kcyBCYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2csIGRldGFpbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIobXNnLCAiVW5rbm93bkVycm9yRXhjZXB0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGV0YWlscyA9IGRldGFpbHM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Vbmtub3duRXJyb3JFeGNlcHRpb24gPSBVbmtub3duRXJyb3JFeGNlcHRpb247CiAgICAgICAgICAgICAgICBjbGFzcyBJbnZhbGlkUERGRXhjZXB0aW9uIGV4dGVuZHMgQmFzZUV4Y2VwdGlvbiB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobXNnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIkludmFsaWRQREZFeGNlcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkludmFsaWRQREZFeGNlcHRpb24gPSBJbnZhbGlkUERGRXhjZXB0aW9uOwogICAgICAgICAgICAgICAgY2xhc3MgTWlzc2luZ1BERkV4Y2VwdGlvbiBleHRlbmRzIEJhc2VFeGNlcHRpb24gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKG1zZykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihtc2csICJNaXNzaW5nUERGRXhjZXB0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5NaXNzaW5nUERGRXhjZXB0aW9uID0gTWlzc2luZ1BERkV4Y2VwdGlvbjsKICAgICAgICAgICAgICAgIGNsYXNzIFVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiBleHRlbmRzIEJhc2VFeGNlcHRpb24gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKG1zZywgc3RhdHVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YXR1cyA9IHN0YXR1czsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiA9IFVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbjsKICAgICAgICAgICAgICAgIGNsYXNzIEZvcm1hdEVycm9yIGV4dGVuZHMgQmFzZUV4Y2VwdGlvbiB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobXNnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIkZvcm1hdEVycm9yIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Gb3JtYXRFcnJvciA9IEZvcm1hdEVycm9yOwogICAgICAgICAgICAgICAgY2xhc3MgQWJvcnRFeGNlcHRpb24gZXh0ZW5kcyBCYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2cpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIobXNnLCAiQWJvcnRFeGNlcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkFib3J0RXhjZXB0aW9uID0gQWJvcnRFeGNlcHRpb247CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBieXRlc1RvU3RyaW5nKGJ5dGVzKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBieXRlcyAhPT0gIm9iamVjdCIgfHwgYnl0ZXMgPT09IG51bGwgfHwgYnl0ZXMubGVuZ3RoID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdW5yZWFjaGFibGUoIkludmFsaWQgYXJndW1lbnQgZm9yIGJ5dGVzVG9TdHJpbmciKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuZ3RoID0gYnl0ZXMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IE1BWF9BUkdVTUVOVF9DT1VOVCA9IDgxOTI7CiAgICAgICAgICAgICAgICAgICAgaWYgKGxlbmd0aCA8IE1BWF9BUkdVTUVOVF9DT1VOVCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gU3RyaW5nLmZyb21DaGFyQ29kZS5hcHBseShudWxsLCBieXRlcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ckJ1ZiA9IFtdOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGVuZ3RoOyBpICs9IE1BWF9BUkdVTUVOVF9DT1VOVCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVua0VuZCA9IE1hdGgubWluKGkgKyBNQVhfQVJHVU1FTlRfQ09VTlQsIGxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gYnl0ZXMuc3ViYXJyYXkoaSwgY2h1bmtFbmQpOwogICAgICAgICAgICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlLmFwcGx5KG51bGwsIGNodW5rKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHJCdWYuam9pbigiIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzdHJpbmdUb0J5dGVzKHN0cikgewogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygc3RyICE9PSAic3RyaW5nIikgewogICAgICAgICAgICAgICAgICAgICAgICB1bnJlYWNoYWJsZSgiSW52YWxpZCBhcmd1bWVudCBmb3Igc3RyaW5nVG9CeXRlcyIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBsZW5ndGggPSBzdHIubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkobGVuZ3RoKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgKytpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2ldID0gc3RyLmNoYXJDb2RlQXQoaSkgJiAweGZmOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gYnl0ZXM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzdHJpbmczMih2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBTdHJpbmcuZnJvbUNoYXJDb2RlKHZhbHVlID4+IDI0ICYgMHhmZiwgdmFsdWUgPj4gMTYgJiAweGZmLCB2YWx1ZSA+PiA4ICYgMHhmZiwgdmFsdWUgJiAweGZmKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG9iamVjdFNpemUob2JqKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE9iamVjdC5rZXlzKG9iaikubGVuZ3RoOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gb2JqZWN0RnJvbU1hcChtYXApIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBvYmogPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleSwgdmFsdWVdIG9mIG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBvYmpba2V5XSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gb2JqOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gaXNMaXR0bGVFbmRpYW4oKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgYnVmZmVyOCA9IG5ldyBVaW50OEFycmF5KDQpOwogICAgICAgICAgICAgICAgICAgIGJ1ZmZlcjhbMF0gPSAxOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHZpZXczMiA9IG5ldyBVaW50MzJBcnJheShidWZmZXI4LmJ1ZmZlciwgMCwgMSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZpZXczMlswXSA9PT0gMTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGlzRXZhbFN1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICBuZXcgRnVuY3Rpb24oIiIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBGZWF0dXJlVGVzdCB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBpc0xpdHRsZUVuZGlhbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAiaXNMaXR0bGVFbmRpYW4iLCBpc0xpdHRsZUVuZGlhbigpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBpc0V2YWxTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzaGFkb3codGhpcywgImlzRXZhbFN1cHBvcnRlZCIsIGlzRXZhbFN1cHBvcnRlZCgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAiaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQiLCB0eXBlb2YgT2Zmc2NyZWVuQ2FudmFzICE9PSAidW5kZWZpbmVkIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXQgcGxhdGZvcm0oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgbmF2aWdhdG9yID09PSAidW5kZWZpbmVkIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAicGxhdGZvcm0iLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNXaW46IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzTWFjOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAicGxhdGZvcm0iLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1dpbjogbmF2aWdhdG9yLnBsYXRmb3JtLmluY2x1ZGVzKCJXaW4iKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzTWFjOiBuYXZpZ2F0b3IucGxhdGZvcm0uaW5jbHVkZXMoIk1hYyIpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRmVhdHVyZVRlc3QgPSBGZWF0dXJlVGVzdDsKICAgICAgICAgICAgICAgIGNvbnN0IGhleE51bWJlcnMgPSBbLi4uQXJyYXkoMjU2KS5rZXlzKCldLm1hcChuID0+IG4udG9TdHJpbmcoMTYpLnBhZFN0YXJ0KDIsICIwIikpOwogICAgICAgICAgICAgICAgY2xhc3MgVXRpbCB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIG1ha2VIZXhDb2xvcihyLCBnLCBiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgIyR7aGV4TnVtYmVyc1tyXX0ke2hleE51bWJlcnNbZ119JHtoZXhOdW1iZXJzW2JdfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBzY2FsZU1pbk1heCh0cmFuc2Zvcm0sIG1pbk1heCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgdGVtcDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRyYW5zZm9ybVswXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRyYW5zZm9ybVswXSA8IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZW1wID0gbWluTWF4WzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFswXSA9IG1pbk1heFsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMV0gPSB0ZW1wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzBdICo9IHRyYW5zZm9ybVswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSAqPSB0cmFuc2Zvcm1bMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNmb3JtWzNdIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXAgPSBtaW5NYXhbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzJdID0gbWluTWF4WzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMl0gKj0gdHJhbnNmb3JtWzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzNdICo9IHRyYW5zZm9ybVszXTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXAgPSBtaW5NYXhbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMF0gPSBtaW5NYXhbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMl0gPSB0ZW1wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGVtcCA9IG1pbk1heFsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSA9IG1pbk1heFszXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNmb3JtWzFdIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXAgPSBtaW5NYXhbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzJdID0gbWluTWF4WzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMl0gKj0gdHJhbnNmb3JtWzFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzNdICo9IHRyYW5zZm9ybVsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc2Zvcm1bMl0gPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGVtcCA9IG1pbk1heFswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMF0gPSBtaW5NYXhbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzFdID0gdGVtcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFswXSAqPSB0cmFuc2Zvcm1bMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMV0gKj0gdHJhbnNmb3JtWzJdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFswXSArPSB0cmFuc2Zvcm1bNF07CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSArPSB0cmFuc2Zvcm1bNF07CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsyXSArPSB0cmFuc2Zvcm1bNV07CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSArPSB0cmFuc2Zvcm1bNV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB0cmFuc2Zvcm0obTEsIG0yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbbTFbMF0gKiBtMlswXSArIG0xWzJdICogbTJbMV0sIG0xWzFdICogbTJbMF0gKyBtMVszXSAqIG0yWzFdLCBtMVswXSAqIG0yWzJdICsgbTFbMl0gKiBtMlszXSwgbTFbMV0gKiBtMlsyXSArIG0xWzNdICogbTJbM10sIG0xWzBdICogbTJbNF0gKyBtMVsyXSAqIG0yWzVdICsgbTFbNF0sIG0xWzFdICogbTJbNF0gKyBtMVszXSAqIG0yWzVdICsgbTFbNV1dOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgYXBwbHlUcmFuc2Zvcm0ocCwgbSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4dCA9IHBbMF0gKiBtWzBdICsgcFsxXSAqIG1bMl0gKyBtWzRdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5dCA9IHBbMF0gKiBtWzFdICsgcFsxXSAqIG1bM10gKyBtWzVdOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3h0LCB5dF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBhcHBseUludmVyc2VUcmFuc2Zvcm0ocCwgbSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkID0gbVswXSAqIG1bM10gLSBtWzFdICogbVsyXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeHQgPSAocFswXSAqIG1bM10gLSBwWzFdICogbVsyXSArIG1bMl0gKiBtWzVdIC0gbVs0XSAqIG1bM10pIC8gZDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeXQgPSAoLXBbMF0gKiBtWzFdICsgcFsxXSAqIG1bMF0gKyBtWzRdICogbVsxXSAtIG1bNV0gKiBtWzBdKSAvIGQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeHQsIHl0XTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldEF4aWFsQWxpZ25lZEJvdW5kaW5nQm94KHIsIG0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDEgPSBVdGlsLmFwcGx5VHJhbnNmb3JtKHIsIG0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMiA9IFV0aWwuYXBwbHlUcmFuc2Zvcm0oci5zbGljZSgyLCA0KSwgbSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAzID0gVXRpbC5hcHBseVRyYW5zZm9ybShbclswXSwgclszXV0sIG0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwNCA9IFV0aWwuYXBwbHlUcmFuc2Zvcm0oW3JbMl0sIHJbMV1dLCBtKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtNYXRoLm1pbihwMVswXSwgcDJbMF0sIHAzWzBdLCBwNFswXSksIE1hdGgubWluKHAxWzFdLCBwMlsxXSwgcDNbMV0sIHA0WzFdKSwgTWF0aC5tYXgocDFbMF0sIHAyWzBdLCBwM1swXSwgcDRbMF0pLCBNYXRoLm1heChwMVsxXSwgcDJbMV0sIHAzWzFdLCBwNFsxXSldOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgaW52ZXJzZVRyYW5zZm9ybShtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQgPSBtWzBdICogbVszXSAtIG1bMV0gKiBtWzJdOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW21bM10gLyBkLCAtbVsxXSAvIGQsIC1tWzJdIC8gZCwgbVswXSAvIGQsIChtWzJdICogbVs1XSAtIG1bNF0gKiBtWzNdKSAvIGQsIChtWzRdICogbVsxXSAtIG1bNV0gKiBtWzBdKSAvIGRdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgc2luZ3VsYXJWYWx1ZURlY29tcG9zZTJkU2NhbGUobSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0cmFuc3Bvc2UgPSBbbVswXSwgbVsyXSwgbVsxXSwgbVszXV07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGEgPSBtWzBdICogdHJhbnNwb3NlWzBdICsgbVsxXSAqIHRyYW5zcG9zZVsyXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYiA9IG1bMF0gKiB0cmFuc3Bvc2VbMV0gKyBtWzFdICogdHJhbnNwb3NlWzNdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjID0gbVsyXSAqIHRyYW5zcG9zZVswXSArIG1bM10gKiB0cmFuc3Bvc2VbMl07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQgPSBtWzJdICogdHJhbnNwb3NlWzFdICsgbVszXSAqIHRyYW5zcG9zZVszXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlyc3QgPSAoYSArIGQpIC8gMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2Vjb25kID0gTWF0aC5zcXJ0KChhICsgZCkgKiogMiAtIDQgKiAoYSAqIGQgLSBjICogYikpIC8gMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ggPSBmaXJzdCArIHNlY29uZCB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzeSA9IGZpcnN0IC0gc2Vjb25kIHx8IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbTWF0aC5zcXJ0KHN4KSwgTWF0aC5zcXJ0KHN5KV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBub3JtYWxpemVSZWN0KHJlY3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgciA9IHJlY3Quc2xpY2UoMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZWN0WzBdID4gcmVjdFsyXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgclswXSA9IHJlY3RbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByWzJdID0gcmVjdFswXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVjdFsxXSA+IHJlY3RbM10pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJbMV0gPSByZWN0WzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgclszXSA9IHJlY3RbMV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBpbnRlcnNlY3QocmVjdDEsIHJlY3QyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHhMb3cgPSBNYXRoLm1heChNYXRoLm1pbihyZWN0MVswXSwgcmVjdDFbMl0pLCBNYXRoLm1pbihyZWN0MlswXSwgcmVjdDJbMl0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeEhpZ2ggPSBNYXRoLm1pbihNYXRoLm1heChyZWN0MVswXSwgcmVjdDFbMl0pLCBNYXRoLm1heChyZWN0MlswXSwgcmVjdDJbMl0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhMb3cgPiB4SGlnaCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeUxvdyA9IE1hdGgubWF4KE1hdGgubWluKHJlY3QxWzFdLCByZWN0MVszXSksIE1hdGgubWluKHJlY3QyWzFdLCByZWN0MlszXSkpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5SGlnaCA9IE1hdGgubWluKE1hdGgubWF4KHJlY3QxWzFdLCByZWN0MVszXSksIE1hdGgubWF4KHJlY3QyWzFdLCByZWN0MlszXSkpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoeUxvdyA+IHlIaWdoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3hMb3csIHlMb3csIHhIaWdoLCB5SGlnaF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBiZXppZXJCb3VuZGluZ0JveCh4MCwgeTAsIHgxLCB5MSwgeDIsIHkyLCB4MywgeTMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHZhbHVlcyA9IFtdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzID0gW1tdLCBbXV07CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBhLCBiLCBjLCB0LCB0MSwgdDIsIGIyYWMsIHNxcnRiMmFjOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI7ICsraSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiID0gNiAqIHgwIC0gMTIgKiB4MSArIDYgKiB4MjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhID0gLTMgKiB4MCArIDkgKiB4MSAtIDkgKiB4MiArIDMgKiB4MzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjID0gMyAqIHgxIC0gMyAqIHgwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiID0gNiAqIHkwIC0gMTIgKiB5MSArIDYgKiB5MjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhID0gLTMgKiB5MCArIDkgKiB5MSAtIDkgKiB5MiArIDMgKiB5MzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjID0gMyAqIHkxIC0gMyAqIHkwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKE1hdGguYWJzKGEpIDwgMWUtMTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoTWF0aC5hYnMoYikgPCAxZS0xMikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdCA9IC1jIC8gYjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoMCA8IHQgJiYgdCA8IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHZhbHVlcy5wdXNoKHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGIyYWMgPSBiICogYiAtIDQgKiBjICogYTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNxcnRiMmFjID0gTWF0aC5zcXJ0KGIyYWMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGIyYWMgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0MSA9ICgtYiArIHNxcnRiMmFjKSAvICgyICogYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoMCA8IHQxICYmIHQxIDwgMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR2YWx1ZXMucHVzaCh0MSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0MiA9ICgtYiAtIHNxcnRiMmFjKSAvICgyICogYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoMCA8IHQyICYmIHQyIDwgMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR2YWx1ZXMucHVzaCh0Mik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGogPSB0dmFsdWVzLmxlbmd0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG10OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBqbGVuID0gajsKICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGotLSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdCA9IHR2YWx1ZXNbal07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdCA9IDEgLSB0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzWzBdW2pdID0gbXQgKiBtdCAqIG10ICogeDAgKyAzICogbXQgKiBtdCAqIHQgKiB4MSArIDMgKiBtdCAqIHQgKiB0ICogeDIgKyB0ICogdCAqIHQgKiB4MzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kc1sxXVtqXSA9IG10ICogbXQgKiBtdCAqIHkwICsgMyAqIG10ICogbXQgKiB0ICogeTEgKyAzICogbXQgKiB0ICogdCAqIHkyICsgdCAqIHQgKiB0ICogeTM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzWzBdW2psZW5dID0geDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kc1sxXVtqbGVuXSA9IHkwOwogICAgICAgICAgICAgICAgICAgICAgICBib3VuZHNbMF1bamxlbiArIDFdID0geDM7CiAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kc1sxXVtqbGVuICsgMV0gPSB5MzsKICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzWzBdLmxlbmd0aCA9IGJvdW5kc1sxXS5sZW5ndGggPSBqbGVuICsgMjsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtNYXRoLm1pbiguLi5ib3VuZHNbMF0pLCBNYXRoLm1pbiguLi5ib3VuZHNbMV0pLCBNYXRoLm1heCguLi5ib3VuZHNbMF0pLCBNYXRoLm1heCguLi5ib3VuZHNbMV0pXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlV0aWwgPSBVdGlsOwogICAgICAgICAgICAgICAgY29uc3QgUERGU3RyaW5nVHJhbnNsYXRlVGFibGUgPSBbMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMCwgMHgyZDgsIDB4MmM3LCAweDJjNiwgMHgyZDksIDB4MmRkLCAweDJkYiwgMHgyZGEsIDB4MmRjLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAwLCAw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gPT09ICJceEZFIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5jb2RpbmcgPSAidXRmLTE2bGUiOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHN0clswXSA9PT0gIlx4RUYiICYmIHN0clsxXSA9PT0gIlx4QkIiICYmIHN0clsyXSA9PT0gIlx4QkYiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmNvZGluZyA9ICJ1dGYtOCI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuY29kaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlY29kZXIgPSBuZXcgVGV4dERlY29kZXIoZW5jb2RpbmcsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmF0YWw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBzdHJpbmdUb0J5dGVzKHN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlY29kZXIuZGVjb2RlKGJ1ZmZlcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdhcm4oYHN0cmluZ1RvUERGU3RyaW5nOiAiJHtleH0iLmApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ckJ1ZiA9IFtdOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IHN0ci5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvZGUgPSBQREZTdHJpbmdUcmFuc2xhdGVUYWJsZVtzdHIuY2hhckNvZGVBdChpKV07CiAgICAgICAgICAgICAgICAgICAgICAgIHN0ckJ1Zi5wdXNoKGNvZGUgPyBTdHJpbmcuZnJvbUNoYXJDb2RlKGNvZGUpIDogc3RyLmNoYXJBdChpKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHJCdWYuam9pbigiIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzdHJpbmdUb1VURjhTdHJpbmcoc3RyKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlY29kZVVSSUNvbXBvbmVudChlc2NhcGUoc3RyKSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiB1dGY4U3RyaW5nVG9TdHJpbmcoc3RyKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVuZXNjYXBlKGVuY29kZVVSSUNvbXBvbmVudChzdHIpKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGlzQXJyYXlCdWZmZXIodikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB0eXBlb2YgdiA9PT0gIm9iamVjdCIgJiYgdiAhPT0gbnVsbCAmJiB2LmJ5dGVMZW5ndGggIT09IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGlzQXJyYXlFcXVhbChhcnIxLCBhcnIyKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGFycjEubGVuZ3RoICE9PSBhcnIyLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGFycjEubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXJyMVtpXSAhPT0gYXJyMltpXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0TW9kaWZpY2F0aW9uRGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgZGF0ZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogbmV3IERhdGUoKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBbZGF0ZS5nZXRVVENGdWxsWWVhcigpLnRvU3RyaW5nKCksIChkYXRlLmdldFVUQ01vbnRoKCkgKyAxKS50b1N0cmluZygpLnBhZFN0YXJ0KDIsICIwIiksIGRhdGUuZ2V0VVRDRGF0ZSgpLnRvU3RyaW5nKCkucGFkU3RhcnQoMiwgIjAiKSwgZGF0ZS5nZXRVVENIb3VycygpLnRvU3RyaW5nKCkucGFkU3RhcnQoMiwgIjAiKSwgZGF0ZS5nZXRVVENNaW51dGVzKCkudG9TdHJpbmcoKS5wYWRTdGFydCgyLCAiMCIpLCBkYXRlLmdldFVUQ1NlY29uZHMoKS50b1N0cmluZygpLnBhZFN0YXJ0KDIsICIwIildOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBidWZmZXIuam9pbigiIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSgpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjYXBhYmlsaXR5ID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICBsZXQgaXNTZXR0bGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGNhcGFiaWxpdHksICJzZXR0bGVkIiwgewogICAgICAgICAgICAgICAgICAgICAgICBnZXQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXNTZXR0bGVkOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgY2FwYWJpbGl0eS5wcm9taXNlID0gbmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmUsIHJlamVjdCkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXBhYmlsaXR5LnJlc29sdmUgPSBmdW5jdGlvbiAoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNTZXR0bGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHkucmVqZWN0ID0gZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNTZXR0bGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlamVjdChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBjYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAyICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgdmFyIF9pc19ub2RlID0gX193X3BkZmpzX3JlcXVpcmVfXygzKTsKICAgICAgICAgICAgICAgIChmdW5jdGlvbiBjaGVja0RPTU1hdHJpeCgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoZ2xvYmFsVGhpcy5ET01NYXRyaXggfHwgIV9pc19ub2RlLmlzTm9kZUpTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2xvYmFsVGhpcy5ET01NYXRyaXggPSByZXF1aXJlKCJjYW52YXMiKS5ET01NYXRyaXg7CiAgICAgICAgICAgICAgICB9KSgpOwogICAgICAgICAgICAgICAgKGZ1bmN0aW9uIGNoZWNrUGF0aDJEKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxUaGlzLlBhdGgyRCB8fCAhX2lzX25vZGUuaXNOb2RlSlMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIENhbnZhc1JlbmRlcmluZ0NvbnRleHQyRAogICAgICAgICAgICAgICAgICAgIH0gPSByZXF1aXJlKCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlmaWxsUGF0aDJECiAgICAgICAgICAgICAgICAgICAgfSA9IHJlcXVpcmUoInBhdGgyZC1wb2x5ZmlsbCIpOwogICAgICAgICAgICAgICAgICAgIGdsb2JhbFRoaXMuQ2FudmFzUmVuZGVyaW5nQ29udGV4dDJEID0gQ2FudmFzUmVuZGVyaW5nQ29udGV4dDJEOwogICAgICAgICAgICAgICAgICAgIHBvbHlmaWxsUGF0aDJEKGdsb2JhbFRoaXMpOwogICAgICAgICAgICAgICAgfSkoKTsKICAgICAgICAgICAgICAgIChmdW5jdGlvbiBjaGVja1JlYWRhYmxlU3RyZWFtKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxUaGlzLlJlYWRhYmxlU3RyZWFtIHx8ICFfaXNfbm9kZS5pc05vZGVKUykgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdsb2JhbFRoaXMuUmVhZGFibGVTdHJlYW0gPSByZXF1aXJlKCJ3ZWItc3RyZWFtcy1wb2x5ZmlsbC9kaXN0L3BvbnlmaWxsLmpzIikuUmVhZGFibGVTdHJlYW07CiAgICAgICAgICAgICAgICB9KSgpOwogICAgICAgICAgICAgICAgKGZ1bmN0aW9uIGNoZWNrQXJyYXlBdCgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkucHJvdG90eXBlLmF0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXyg0KTsKICAgICAgICAgICAgICAgIH0pKCk7CiAgICAgICAgICAgICAgICAoZnVuY3Rpb24gY2hlY2tUeXBlZEFycmF5QXQoKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKFVpbnQ4QXJyYXkucHJvdG90eXBlLmF0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXyg3OCk7CiAgICAgICAgICAgICAgICB9KSgpOwogICAgICAgICAgICAgICAgKGZ1bmN0aW9uIGNoZWNrU3RydWN0dXJlZENsb25lKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxUaGlzLnN0cnVjdHVyZWRDbG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oOTApOwogICAgICAgICAgICAgICAgfSkoKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLmlzTm9kZUpTID0gdm9pZCAwOwogICAgICAgICAgICAgICAgY29uc3QgaXNOb2RlSlMgPSB0eXBlb2YgcHJvY2VzcyA9PT0gIm9iamVjdCIgJiYgcHJvY2VzcyArICIiID09PSAiW29iamVjdCBwcm9jZXNzXSIgJiYgIXByb2Nlc3MudmVyc2lvbnMubncgJiYgIShwcm9jZXNzLnZlcnNpb25zLmVsZWN0cm9uICYmIHByb2Nlc3MudHlwZSAmJiBwcm9jZXNzLnR5cGUgIT09ICJicm93c2VyIik7CiAgICAgICAgICAgICAgICBleHBvcnRzLmlzTm9kZUpTID0gaXNOb2RlSlM7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDQgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oNSk7CiAgICAgICAgICAgICAgICB2YXIgZW50cnlVbmJpbmQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDc3KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZW50cnlVbmJpbmQoJ0FycmF5JywgJ2F0Jyk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDUgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciAkID0gX193X3BkZmpzX3JlcXVpcmVfXyg2KTsKICAgICAgICAgICAgICAgIHZhciB0b09iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNDMpOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgdG9JbnRlZ2VyT3JJbmZpbml0eSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjUpOwogICAgICAgICAgICAgICAgdmFyIGFkZFRvVW5zY29wYWJsZXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcyKTsKICAgICAgICAgICAgICAgICQoewogICAgICAgICAgICAgICAgICAgIHRhcmdldDogJ0FycmF5JywKICAgICAgICAgICAgICAgICAgICBwcm90bzogdHJ1ZQogICAgICAgICAgICAgICAgfSwgewogICAgICAgICAgICAgICAgICAgIGF0OiBmdW5jdGlvbiBhdChpbmRleCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgTyA9IHRvT2JqZWN0KHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgbGVuID0gbGVuZ3RoT2ZBcnJheUxpa2UoTyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciByZWxhdGl2ZUluZGV4ID0gdG9JbnRlZ2VyT3JJbmZpbml0eShpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBrID0gcmVsYXRpdmVJbmRleCA+PSAwID8gcmVsYXRpdmVJbmRleCA6IGxlbiArIHJlbGF0aXZlSW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBrIDwgMCB8fCBrID49IGxlbiA/IHVuZGVmaW5lZCA6IE9ba107CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBhZGRUb1Vuc2NvcGFibGVzKCdhdCcpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZ2xvYmFsID0gX193X3BkZmpzX3JlcXVpcmVfXyg3KTsKICAgICAgICAgICAgICAgIHZhciBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IgPSAoX193X3BkZmpzX3JlcXVpcmVfXyg4KS5mKTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ3KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lR2xvYmFsUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQxKTsKICAgICAgICAgICAgICAgIHZhciBjb3B5Q29uc3RydWN0b3JQcm9wZXJ0aWVzID0gX193X3BkZmpzX3JlcXVpcmVfXyg1OSk7CiAgICAgICAgICAgICAgICB2YXIgaXNGb3JjZWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcxKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKG9wdGlvbnMsIHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgIHZhciBUQVJHRVQgPSBvcHRpb25zLnRhcmdldDsKICAgICAgICAgICAgICAgICAgICB2YXIgR0xPQkFMID0gb3B0aW9ucy5nbG9iYWw7CiAgICAgICAgICAgICAgICAgICAgdmFyIFNUQVRJQyA9IG9wdGlvbnMuc3RhdDsKICAgICAgICAgICAgICAgICAgICB2YXIgRk9SQ0VELCB0YXJnZXQsIGtleSwgdGFyZ2V0UHJvcGVydHksIHNvdXJjZVByb3BlcnR5LCBkZXNjcmlwdG9yOwogICAgICAgICAgICAgICAgICAgIGlmIChHTE9CQUwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0ID0gZ2xvYmFsOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoU1RBVElDKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldCA9IGdsb2JhbFtUQVJHRVRdIHx8IGRlZmluZUdsb2JhbFByb3BlcnR5KFRBUkdFVCwge30pOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldCA9IChnbG9iYWxbVEFSR0VUXSB8fCB7fSkucHJvdG90eXBlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAodGFyZ2V0KQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGtleSBpbiBzb3VyY2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZVByb3BlcnR5ID0gc291cmNlW2tleV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3B0aW9ucy5kb250Q2FsbEdldFNldCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc2NyaXB0b3IgPSBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IodGFyZ2V0LCBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldFByb3BlcnR5ID0gZGVzY3JpcHRvciAmJiBkZXNjcmlwdG9yLnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0UHJvcGVydHkgPSB0YXJnZXRba2V5XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZPUkNFRCA9IGlzRm9yY2VkKEdMT0JBTCA/IGtleSA6IFRBUkdFVCArIChTVEFUSUMgPyAnLicgOiAnIycpICsga2V5LCBvcHRpb25zLmZvcmNlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIUZPUkNFRCAmJiB0YXJnZXRQcm9wZXJ0eSAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBzb3VyY2VQcm9wZXJ0eSA9PSB0eXBlb2YgdGFyZ2V0UHJvcGVydHkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvcHlDb25zdHJ1Y3RvclByb3BlcnRpZXMoc291cmNlUHJvcGVydHksIHRhcmdldFByb3BlcnR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcHRpb25zLnNoYW0gfHwgdGFyZ2V0UHJvcGVydHkgJiYgdGFyZ2V0UHJvcGVydHkuc2hhbSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShzb3VyY2VQcm9wZXJ0eSwgJ3NoYW0nLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4odGFyZ2V0LCBrZXksIHNvdXJjZVByb3BlcnR5LCBvcHRpb25zKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjaGVjayA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBpdCAmJiBpdC5NYXRoID09IE1hdGggJiYgaXQ7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBjaGVjayh0eXBlb2YgZ2xvYmFsVGhpcyA9PSAnb2JqZWN0JyAmJiBnbG9iYWxUaGlzKSB8fCBjaGVjayh0eXBlb2Ygd2luZG93ID09ICdvYmplY3QnICYmIHdpbmRvdykgfHwgY2hlY2sodHlwZW9mIHNlbGYgPT0gJ29iamVjdCcgJiYgc2VsZikgfHwgY2hlY2sodHlwZW9mIGdsb2JhbCA9PSAnb2JqZWN0JyAmJiBnbG9iYWwpIHx8IChmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgICAgICAgICB9KCkpIHx8IEZ1bmN0aW9uKCdyZXR1cm4gdGhpcycpKCk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDggKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgY2FsbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTEpOwogICAgICAgICAgICAgICAgdmFyIHByb3BlcnR5SXNFbnVtZXJhYmxlTW9kdWxlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMyk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNCk7CiAgICAgICAgICAgICAgICB2YXIgdG9JbmRleGVkT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNSk7CiAgICAgICAgICAgICAgICB2YXIgdG9Qcm9wZXJ0eUtleSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjEpOwogICAgICAgICAgICAgICAgdmFyIGhhc093biA9IF9fd19wZGZqc19yZXF1aXJlX18oNDIpOwogICAgICAgICAgICAgICAgdmFyIElFOF9ET01fREVGSU5FID0gX193X3BkZmpzX3JlcXVpcmVfXyg0NSk7CiAgICAgICAgICAgICAgICB2YXIgJGdldE93blByb3BlcnR5RGVzY3JpcHRvciA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3I7CiAgICAgICAgICAgICAgICBleHBvcnRzLmYgPSBERVNDUklQVE9SUyA/ICRnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IgOiBmdW5jdGlvbiBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IoTywgUCkgewogICAgICAgICAgICAgICAgICAgIE8gPSB0b0luZGV4ZWRPYmplY3QoTyk7CiAgICAgICAgICAgICAgICAgICAgUCA9IHRvUHJvcGVydHlLZXkoUCk7CiAgICAgICAgICAgICAgICAgICAgaWYgKElFOF9ET01fREVGSU5FKQogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICRnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IoTywgUCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoaGFzT3duKE8sIFApKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yKCFjYWxsKHByb3BlcnR5SXNFbnVtZXJhYmxlTW9kdWxlLmYsIE8sIFApLCBPW1BdKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBPYmplY3QuZGVmaW5lUHJvcGVydHkoe30sIDEsIHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gNzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pWzFdICE9IDc7CiAgICAgICAgICAgICAgICB9KTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTAgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChleGVjKSB7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICEhZXhlYygpOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgTkFUSVZFX0JJTkQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyKTsKICAgICAgICAgICAgICAgIHZhciBjYWxsID0gRnVuY3Rpb24ucHJvdG90eXBlLmNhbGw7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IE5BVElWRV9CSU5EID8gY2FsbC5iaW5kKGNhbGwpIDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsLmFwcGx5KGNhbGwsIGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICFmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHRlc3QgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgfS5iaW5kKCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiB0ZXN0ICE9ICdmdW5jdGlvbicgfHwgdGVzdC5oYXNPd25Qcm9wZXJ0eSgncHJvdG90eXBlJyk7CiAgICAgICAgICAgICAgICB9KTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTMgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCiAgICAgICAgICAgICAgICB2YXIgJHByb3BlcnR5SXNFbnVtZXJhYmxlID0ge30ucHJvcGVydHlJc0VudW1lcmFibGU7CiAgICAgICAgICAgICAgICB2YXIgZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yID0gT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcjsKICAgICAgICAgICAgICAgIHZhciBOQVNIT1JOX0JVRyA9IGdldE93blByb3BlcnR5RGVzY3JpcHRvciAmJiAhJHByb3BlcnR5SXNFbnVtZXJhYmxlLmNhbGwoeyAxOiAyIH0sIDEpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5mID0gTkFTSE9STl9CVUcgPyBmdW5jdGlvbiBwcm9wZXJ0eUlzRW51bWVyYWJsZShWKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGRlc2NyaXB0b3IgPSBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IodGhpcywgVik7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICEhZGVzY3JpcHRvciAmJiBkZXNjcmlwdG9yLmVudW1lcmFibGU7CiAgICAgICAgICAgICAgICB9IDogJHByb3BlcnR5SXNFbnVtZXJhYmxlOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGJpdG1hcCwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiAhKGJpdG1hcCAmIDEpLAogICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6ICEoYml0bWFwICYgMiksCiAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiAhKGJpdG1hcCAmIDQpLAogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTUgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBJbmRleGVkT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNik7CiAgICAgICAgICAgICAgICB2YXIgcmVxdWlyZU9iamVjdENvZXJjaWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTkpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gSW5kZXhlZE9iamVjdChyZXF1aXJlT2JqZWN0Q29lcmNpYmxlKGl0KSk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBjbGFzc29mID0gX193X3BkZmpzX3JlcXVpcmVfXygxOCk7CiAgICAgICAgICAgICAgICB2YXIgJE9iamVjdCA9IE9iamVjdDsKICAgICAgICAgICAgICAgIHZhciBzcGxpdCA9IHVuY3VycnlUaGlzKCcnLnNwbGl0KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiAhJE9iamVjdCgneicpLnByb3BlcnR5SXNFbnVtZXJhYmxlKDApOwogICAgICAgICAgICAgICAgfSkgPyBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xhc3NvZihpdCkgPT0gJ1N0cmluZycgPyBzcGxpdChpdCwgJycpIDogJE9iamVjdChpdCk7CiAgICAgICAgICAgICAgICB9IDogJE9iamVjdDsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBOQVRJVkVfQklORCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTIpOwogICAgICAgICAgICAgICAgdmFyIEZ1bmN0aW9uUHJvdG90eXBlID0gRnVuY3Rpb24ucHJvdG90eXBlOwogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBGdW5jdGlvblByb3RvdHlwZS5jYWxsOwogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzV2l0aEJpbmQgPSBOQVRJVkVfQklORCAmJiBGdW5jdGlvblByb3RvdHlwZS5iaW5kLmJpbmQoY2FsbCwgY2FsbCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IE5BVElWRV9CSU5EID8gdW5jdXJyeVRoaXNXaXRoQmluZCA6IGZ1bmN0aW9uIChmbikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsLmFwcGx5KGZuLCBhcmd1bWVudHMpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgdG9TdHJpbmcgPSB1bmN1cnJ5VGhpcyh7fS50b1N0cmluZyk7CiAgICAgICAgICAgICAgICB2YXIgc3RyaW5nU2xpY2UgPSB1bmN1cnJ5VGhpcygnJy5zbGljZSk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHJpbmdTbGljZSh0b1N0cmluZyhpdCksIDgsIC0xKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE5ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaXNOdWxsT3JVbmRlZmluZWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIwKTsKICAgICAgICAgICAgICAgIHZhciAkVHlwZUVycm9yID0gVHlwZUVycm9yOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaXNOdWxsT3JVbmRlZmluZWQoaXQpKQogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyAkVHlwZUVycm9yKCJDYW4ndCBjYWxsIG1ldGhvZCBvbiAiICsgaXQpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBpdDsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDIwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlKSA9PiB7CgogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXQgPT09IG51bGwgfHwgaXQgPT09IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDIxICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgdG9QcmltaXRpdmUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIyKTsKICAgICAgICAgICAgICAgIHZhciBpc1N5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjYpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICB2YXIga2V5ID0gdG9QcmltaXRpdmUoYXJndW1lbnQsICdzdHJpbmcnKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXNTeW1ib2woa2V5KSA/IGtleSA6IGtleSArICcnOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMjIgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjYWxsID0gX193X3BkZmpzX3JlcXVpcmVfXygxMSk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBpc1N5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjYpOwogICAgICAgICAgICAgICAgdmFyIGdldE1ldGhvZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzMpOwogICAgICAgICAgICAgICAgdmFyIG9yZGluYXJ5VG9QcmltaXRpdmUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM2KTsKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciAkVHlwZUVycm9yID0gVHlwZUVycm9yOwogICAgICAgICAgICAgICAgdmFyIFRPX1BSSU1JVElWRSA9IHdlbGxLbm93blN5bWJvbCgndG9QcmltaXRpdmUnKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGlucHV0LCBwcmVmKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFpc09iamVjdChpbnB1dCkgfHwgaXNTeW1ib2woaW5wdXQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaW5wdXQ7CiAgICAgICAgICAgICAgICAgICAgdmFyIGV4b3RpY1RvUHJpbSA9IGdldE1ldGhvZChpbnB1dCwgVE9fUFJJTUlUSVZFKTsKICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0OwogICAgICAgICAgICAgICAgICAgIGlmIChleG90aWNUb1ByaW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHByZWYgPT09IHVuZGVmaW5lZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZWYgPSAnZGVmYXVsdCc7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9IGNhbGwoZXhvdGljVG9QcmltLCBpbnB1dCwgcHJlZik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNPYmplY3QocmVzdWx0KSB8fCBpc1N5bWJvbChyZXN1bHQpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcigiQ2FuJ3QgY29udmVydCBvYmplY3QgdG8gcHJpbWl0aXZlIHZhbHVlIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChwcmVmID09PSB1bmRlZmluZWQpCiAgICAgICAgICAgICAgICAgICAgICAgIHByZWYgPSAnbnVtYmVyJzsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gb3JkaW5hcnlUb1ByaW1pdGl2ZShpbnB1dCwgcHJlZik7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAyMyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciAkZG9jdW1lbnRBbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI1KTsKICAgICAgICAgICAgICAgIHZhciBkb2N1bWVudEFsbCA9ICRkb2N1bWVudEFsbC5hbGw7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICRkb2N1bWVudEFsbC5JU19IVE1MRERBID8gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiBpdCA9PSAnb2JqZWN0JyA/IGl0ICE9PSBudWxsIDogaXNDYWxsYWJsZShpdCkgfHwgaXQgPT09IGRvY3VtZW50QWxsOwogICAgICAgICAgICAgICAgfSA6IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB0eXBlb2YgaXQgPT0gJ29iamVjdCcgPyBpdCAhPT0gbnVsbCA6IGlzQ2FsbGFibGUoaXQpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMjQgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciAkZG9jdW1lbnRBbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI1KTsKICAgICAgICAgICAgICAgIHZhciBkb2N1bWVudEFsbCA9ICRkb2N1bWVudEFsbC5hbGw7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICRkb2N1bWVudEFsbC5JU19IVE1MRERBID8gZnVuY3Rpb24gKGFyZ3VtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiBhcmd1bWVudCA9PSAnZnVuY3Rpb24nIHx8IGFyZ3VtZW50ID09PSBkb2N1bWVudEFsbDsKICAgICAgICAgICAgICAgIH0gOiBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHlwZW9mIGFyZ3VtZW50ID09ICdmdW5jdGlvbic7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAyNSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIHZhciBkb2N1bWVudEFsbCA9IHR5cGVvZiBkb2N1bWVudCA9PSAnb2JqZWN0JyAmJiBkb2N1bWVudC5hbGw7CiAgICAgICAgICAgICAgICB2YXIgSVNfSFRNTEREQSA9IHR5cGVvZiBkb2N1bWVudEFsbCA9PSAndW5kZWZpbmVkJyAmJiBkb2N1bWVudEFsbCAhPT0gdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgYWxsOiBkb2N1bWVudEFsbCwKICAgICAgICAgICAgICAgICAgICBJU19IVE1MRERBOiBJU19IVE1MRERBCiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAyNiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGdldEJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI3KTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgaXNQcm90b3R5cGVPZiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjgpOwogICAgICAgICAgICAgICAgdmFyIFVTRV9TWU1CT0xfQVNfVUlEID0gX193X3BkZmpzX3JlcXVpcmVfXygyOSk7CiAgICAgICAgICAgICAgICB2YXIgJE9iamVjdCA9IE9iamVjdDsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gVVNFX1NZTUJPTF9BU19VSUQgPyBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHlwZW9mIGl0ID09ICdzeW1ib2wnOwogICAgICAgICAgICAgICAgfSA6IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHZhciAkU3ltYm9sID0gZ2V0QnVpbHRJbignU3ltYm9sJyk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGlzQ2FsbGFibGUoJFN5bWJvbCkgJiYgaXNQcm90b3R5cGVPZigkU3ltYm9sLnByb3RvdHlwZSwgJE9iamVjdChpdCkpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMjcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBhRnVuY3Rpb24gPSBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXNDYWxsYWJsZShhcmd1bWVudCkgPyBhcmd1bWVudCA6IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChuYW1lc3BhY2UsIG1ldGhvZCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBhcmd1bWVudHMubGVuZ3RoIDwgMiA/IGFGdW5jdGlvbihnbG9iYWxbbmFtZXNwYWNlXSkgOiBnbG9iYWxbbmFtZXNwYWNlXSAmJiBnbG9iYWxbbmFtZXNwYWNlXVttZXRob2RdOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMjggKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB1bmN1cnJ5VGhpcyh7fS5pc1Byb3RvdHlwZU9mKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMjkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBOQVRJVkVfU1lNQk9MID0gX193X3BkZmpzX3JlcXVpcmVfXygzMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IE5BVElWRV9TWU1CT0wgJiYgIVN5bWJvbC5zaGFtICYmIHR5cGVvZiBTeW1ib2wuaXRlcmF0b3IgPT0gJ3N5bWJvbCc7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDMwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgVjhfVkVSU0lPTiA9IF9fd19wZGZqc19yZXF1aXJlX18oMzEpOwogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICEhT2JqZWN0LmdldE93blByb3BlcnR5U3ltYm9scyAmJiAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciBzeW1ib2wgPSBTeW1ib2woKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gIVN0cmluZyhzeW1ib2wpIHx8ICEoT2JqZWN0KHN5bWJvbCkgaW5zdGFuY2VvZiBTeW1ib2wpIHx8ICFTeW1ib2wuc2hhbSAmJiBWOF9WRVJTSU9OICYmIFY4X1ZFUlNJT04gPCA0MTsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAzMSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGdsb2JhbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNyk7CiAgICAgICAgICAgICAgICB2YXIgdXNlckFnZW50ID0gX193X3BkZmpzX3JlcXVpcmVfXygzMik7CiAgICAgICAgICAgICAgICB2YXIgcHJvY2VzcyA9IGdsb2JhbC5wcm9jZXNzOwogICAgICAgICAgICAgICAgdmFyIERlbm8gPSBnbG9iYWwuRGVubzsKICAgICAgICAgICAgICAgIHZhciB2ZXJzaW9ucyA9IHByb2Nlc3MgJiYgcHJvY2Vzcy52ZXJzaW9ucyB8fCBEZW5vICYmIERlbm8udmVyc2lvbjsKICAgICAgICAgICAgICAgIHZhciB2OCA9IHZlcnNpb25zICYmIHZlcnNpb25zLnY4OwogICAgICAgICAgICAgICAgdmFyIG1hdGNoLCB2ZXJzaW9uOwogICAgICAgICAgICAgICAgaWYgKHY4KSB7CiAgICAgICAgICAgICAgICAgICAgbWF0Y2ggPSB2OC5zcGxpdCgnLicpOwogICAgICAgICAgICAgICAgICAgIHZlcnNpb24gPSBtYXRjaFswXSA+IDAgJiYgbWF0Y2hbMF0gPCA0ID8gMSA6ICsobWF0Y2hbMF0gKyBtYXRjaFsxXSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoIXZlcnNpb24gJiYgdXNlckFnZW50KSB7CiAgICAgICAgICAgICAgICAgICAgbWF0Y2ggPSB1c2VyQWdlbnQubWF0Y2goL0VkZ2VcLyhcZCspLyk7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFtYXRjaCB8fCBtYXRjaFsxXSA+PSA3NCkgewogICAgICAgICAgICAgICAgICAgICAgICBtYXRjaCA9IHVzZXJBZ2VudC5tYXRjaCgvQ2hyb21lXC8oXGQrKS8pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobWF0Y2gpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2ZXJzaW9uID0gK21hdGNoWzFdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gdmVyc2lvbjsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMzIgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHR5cGVvZiBuYXZpZ2F0b3IgIT0gJ3VuZGVmaW5lZCcgJiYgU3RyaW5nKG5hdmlnYXRvci51c2VyQWdlbnQpIHx8ICcnOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAzMyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGFDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMzQpOwogICAgICAgICAgICAgICAgdmFyIGlzTnVsbE9yVW5kZWZpbmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygyMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChWLCBQKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGZ1bmMgPSBWW1BdOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBpc051bGxPclVuZGVmaW5lZChmdW5jKSA/IHVuZGVmaW5lZCA6IGFDYWxsYWJsZShmdW5jKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDM0ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIHRyeVRvU3RyaW5nID0gX193X3BkZmpzX3JlcXVpcmVfXygzNSk7CiAgICAgICAgICAgICAgICB2YXIgJFR5cGVFcnJvciA9IFR5cGVFcnJvcjsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGFyZ3VtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzQ2FsbGFibGUoYXJndW1lbnQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYXJndW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcih0cnlUb1N0cmluZyhhcmd1bWVudCkgKyAnIGlzIG5vdCBhIGZ1bmN0aW9uJyk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAzNSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIHZhciAkU3RyaW5nID0gU3RyaW5nOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJFN0cmluZyhhcmd1bWVudCk7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdPYmplY3QnOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDM2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgY2FsbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTEpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc09iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjMpOwogICAgICAgICAgICAgICAgdmFyICRUeXBlRXJyb3IgPSBUeXBlRXJyb3I7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpbnB1dCwgcHJlZikgewogICAgICAgICAgICAgICAgICAgIHZhciBmbiwgdmFsOwogICAgICAgICAgICAgICAgICAgIGlmIChwcmVmID09PSAnc3RyaW5nJyAmJiBpc0NhbGxhYmxlKGZuID0gaW5wdXQudG9TdHJpbmcpICYmICFpc09iamVjdCh2YWwgPSBjYWxsKGZuLCBpbnB1dCkpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsOwogICAgICAgICAgICAgICAgICAgIGlmIChpc0NhbGxhYmxlKGZuID0gaW5wdXQudmFsdWVPZikgJiYgIWlzT2JqZWN0KHZhbCA9IGNhbGwoZm4sIGlucHV0KSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWw7CiAgICAgICAgICAgICAgICAgICAgaWYgKHByZWYgIT09ICdzdHJpbmcnICYmIGlzQ2FsbGFibGUoZm4gPSBpbnB1dC50b1N0cmluZykgJiYgIWlzT2JqZWN0KHZhbCA9IGNhbGwoZm4sIGlucHV0KSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWw7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcigiQ2FuJ3QgY29udmVydCBvYmplY3QgdG8gcHJpbWl0aXZlIHZhbHVlIik7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAzNyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGdsb2JhbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNyk7CiAgICAgICAgICAgICAgICB2YXIgc2hhcmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygzOCk7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgdWlkID0gX193X3BkZmpzX3JlcXVpcmVfXyg0NCk7CiAgICAgICAgICAgICAgICB2YXIgTkFUSVZFX1NZTUJPTCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzApOwogICAgICAgICAgICAgICAgdmFyIFVTRV9TWU1CT0xfQVNfVUlEID0gX193X3BkZmpzX3JlcXVpcmVfXygyOSk7CiAgICAgICAgICAgICAgICB2YXIgU3ltYm9sID0gZ2xvYmFsLlN5bWJvbDsKICAgICAgICAgICAgICAgIHZhciBXZWxsS25vd25TeW1ib2xzU3RvcmUgPSBzaGFyZWQoJ3drcycpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZVdlbGxLbm93blN5bWJvbCA9IFVTRV9TWU1CT0xfQVNfVUlEID8gU3ltYm9sWydmb3InXSB8fCBTeW1ib2wgOiBTeW1ib2wgJiYgU3ltYm9sLndpdGhvdXRTZXR0ZXIgfHwgdWlkOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAobmFtZSkgewogICAgICAgICAgICAgICAgICAgIGlmICghaGFzT3duKFdlbGxLbm93blN5bWJvbHNTdG9yZSwgbmFtZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgV2VsbEtub3duU3ltYm9sc1N0b3JlW25hbWVdID0gTkFUSVZFX1NZTUJPTCAmJiBoYXNPd24oU3ltYm9sLCBuYW1lKSA/IFN5bWJvbFtuYW1lXSA6IGNyZWF0ZVdlbGxLbm93blN5bWJvbCgnU3ltYm9sLicgKyBuYW1lKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFdlbGxLbm93blN5bWJvbHNTdG9yZVtuYW1lXTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDM4ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgSVNfUFVSRSA9IF9fd19wZGZqc19yZXF1aXJlX18oMzkpOwogICAgICAgICAgICAgICAgdmFyIHN0b3JlID0gX193X3BkZmpzX3JlcXVpcmVfXyg0MCk7CiAgICAgICAgICAgICAgICAobW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoa2V5LCB2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdG9yZVtrZXldIHx8IChzdG9yZVtrZXldID0gdmFsdWUgIT09IHVuZGVmaW5lZCA/IHZhbHVlIDoge30pOwogICAgICAgICAgICAgICAgfSkoJ3ZlcnNpb25zJywgW10pLnB1c2goewogICAgICAgICAgICAgICAgICAgIHZlcnNpb246ICczLjI5LjEnLAogICAgICAgICAgICAgICAgICAgIG1vZGU6IElTX1BVUkUgPyAncHVyZScgOiAnZ2xvYmFsJywKICAgICAgICAgICAgICAgICAgICBjb3B5cmlnaHQ6ICfCqSAyMDE0LTIwMjMgRGVuaXMgUHVzaGthcmV2ICh6bG9pcm9jay5ydSknLAogICAgICAgICAgICAgICAgICAgIGxpY2Vuc2U6ICdodHRwczovL2dpdGh1Yi5jb20vemxvaXJvY2svY29yZS1qcy9ibG9iL3YzLjI5LjEvTElDRU5TRScsCiAgICAgICAgICAgICAgICAgICAgc291cmNlOiAnaHR0cHM6Ly9naXRodWIuY29tL3psb2lyb2NrL2NvcmUtanMnCiAgICAgICAgICAgICAgICB9KTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMzkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZhbHNlOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0MCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGdsb2JhbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNyk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lR2xvYmFsUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQxKTsKICAgICAgICAgICAgICAgIHZhciBTSEFSRUQgPSAnX19jb3JlLWpzX3NoYXJlZF9fJzsKICAgICAgICAgICAgICAgIHZhciBzdG9yZSA9IGdsb2JhbFtTSEFSRURdIHx8IGRlZmluZUdsb2JhbFByb3BlcnR5KFNIQVJFRCwge30pOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBzdG9yZTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNDEgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZVByb3BlcnR5ID0gT2JqZWN0LmRlZmluZVByb3BlcnR5OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoa2V5LCB2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KGdsb2JhbCwga2V5LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICBnbG9iYWxba2V5XSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0MiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgdG9PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQzKTsKICAgICAgICAgICAgICAgIHZhciBoYXNPd25Qcm9wZXJ0eSA9IHVuY3VycnlUaGlzKHt9Lmhhc093blByb3BlcnR5KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gT2JqZWN0Lmhhc093biB8fCBmdW5jdGlvbiBoYXNPd24oaXQsIGtleSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBoYXNPd25Qcm9wZXJ0eSh0b09iamVjdChpdCksIGtleSk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0MyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHJlcXVpcmVPYmplY3RDb2VyY2libGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE5KTsKICAgICAgICAgICAgICAgIHZhciAkT2JqZWN0ID0gT2JqZWN0OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gJE9iamVjdChyZXF1aXJlT2JqZWN0Q29lcmNpYmxlKGFyZ3VtZW50KSk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0NCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgaWQgPSAwOwogICAgICAgICAgICAgICAgdmFyIHBvc3RmaXggPSBNYXRoLnJhbmRvbSgpOwogICAgICAgICAgICAgICAgdmFyIHRvU3RyaW5nID0gdW5jdXJyeVRoaXMoMS4wLnRvU3RyaW5nKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGtleSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiAnU3ltYm9sKCcgKyAoa2V5ID09PSB1bmRlZmluZWQgPyAnJyA6IGtleSkgKyAnKV8nICsgdG9TdHJpbmcoKytpZCArIHBvc3RmaXgsIDM2KTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDQ1ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgREVTQ1JJUFRPUlMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkpOwogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlRWxlbWVudCA9IF9fd19wZGZqc19yZXF1aXJlX18oNDYpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSAhREVTQ1JJUFRPUlMgJiYgIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmRlZmluZVByb3BlcnR5KGNyZWF0ZUVsZW1lbnQoJ2RpdicpLCAnYScsIHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gNzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pLmEgIT0gNzsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0NiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGdsb2JhbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNyk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBkb2N1bWVudCA9IGdsb2JhbC5kb2N1bWVudDsKICAgICAgICAgICAgICAgIHZhciBFWElTVFMgPSBpc09iamVjdChkb2N1bWVudCkgJiYgaXNPYmplY3QoZG9jdW1lbnQuY3JlYXRlRWxlbWVudCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBFWElTVFMgPyBkb2N1bWVudC5jcmVhdGVFbGVtZW50KGl0KSA6IHt9OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNDcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lUHJvcGVydHlNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ4KTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVQcm9wZXJ0eURlc2NyaXB0b3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gREVTQ1JJUFRPUlMgPyBmdW5jdGlvbiAob2JqZWN0LCBrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmluZVByb3BlcnR5TW9kdWxlLmYob2JqZWN0LCBrZXksIGNyZWF0ZVByb3BlcnR5RGVzY3JpcHRvcigxLCB2YWx1ZSkpOwogICAgICAgICAgICAgICAgfSA6IGZ1bmN0aW9uIChvYmplY3QsIGtleSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICBvYmplY3Rba2V5XSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBvYmplY3Q7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0OCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIERFU0NSSVBUT1JTID0gX193X3BkZmpzX3JlcXVpcmVfXyg5KTsKICAgICAgICAgICAgICAgIHZhciBJRThfRE9NX0RFRklORSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDUpOwogICAgICAgICAgICAgICAgdmFyIFY4X1BST1RPVFlQRV9ERUZJTkVfQlVHID0gX193X3BkZmpzX3JlcXVpcmVfXyg0OSk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciB0b1Byb3BlcnR5S2V5ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMSk7CiAgICAgICAgICAgICAgICB2YXIgJFR5cGVFcnJvciA9IFR5cGVFcnJvcjsKICAgICAgICAgICAgICAgIHZhciAkZGVmaW5lUHJvcGVydHkgPSBPYmplY3QuZGVmaW5lUHJvcGVydHk7CiAgICAgICAgICAgICAgICB2YXIgJGdldE93blByb3BlcnR5RGVzY3JpcHRvciA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3I7CiAgICAgICAgICAgICAgICB2YXIgRU5VTUVSQUJMRSA9ICdlbnVtZXJhYmxlJzsKICAgICAgICAgICAgICAgIHZhciBDT05GSUdVUkFCTEUgPSAnY29uZmlndXJhYmxlJzsKICAgICAgICAgICAgICAgIHZhciBXUklUQUJMRSA9ICd3cml0YWJsZSc7CiAgICAgICAgICAgICAgICBleHBvcnRzLmYgPSBERVNDUklQVE9SUyA/IFY4X1BST1RPVFlQRV9ERUZJTkVfQlVHID8gZnVuY3Rpb24gZGVmaW5lUHJvcGVydHkoTywgUCwgQXR0cmlidXRlcykgewogICAgICAgICAgICAgICAgICAgIGFuT2JqZWN0KE8pOwogICAgICAgICAgICAgICAgICAgIFAgPSB0b1Byb3BlcnR5S2V5KFApOwogICAgICAgICAgICAgICAgICAgIGFuT2JqZWN0KEF0dHJpYnV0ZXMpOwogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgTyA9PT0gJ2Z1bmN0aW9uJyAmJiBQID09PSAncHJvdG90eXBlJyAmJiAndmFsdWUnIGluIEF0dHJpYnV0ZXMgJiYgV1JJVEFCTEUgaW4gQXR0cmlidXRlcyAmJiAhQXR0cmlidXRlc1tXUklUQUJMRV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGN1cnJlbnQgPSAkZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yKE8sIFApOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudCAmJiBjdXJyZW50W1dSSVRBQkxFXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgT1tQXSA9IEF0dHJpYnV0ZXMudmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBBdHRyaWJ1dGVzID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogQ09ORklHVVJBQkxFIGluIEF0dHJpYnV0ZXMgPyBBdHRyaWJ1dGVzW0NPTkZJR1VSQUJMRV0gOiBjdXJyZW50W0NPTkZJR1VSQUJMRV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW51bWVyYWJsZTogRU5VTUVSQUJMRSBpbiBBdHRyaWJ1dGVzID8gQXR0cmlidXRlc1tFTlVNRVJBQkxFXSA6IGN1cnJlbnRbRU5VTUVSQUJMRV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiAkZGVmaW5lUHJvcGVydHkoTywgUCwgQXR0cmlidXRlcyk7CiAgICAgICAgICAgICAgICB9IDogJGRlZmluZVByb3BlcnR5IDogZnVuY3Rpb24gZGVmaW5lUHJvcGVydHkoTywgUCwgQXR0cmlidXRlcykgewogICAgICAgICAgICAgICAgICAgIGFuT2JqZWN0KE8pOwogICAgICAgICAgICAgICAgICAgIFAgPSB0b1Byb3BlcnR5S2V5KFApOwogICAgICAgICAgICAgICAgICAgIGFuT2JqZWN0KEF0dHJpYnV0ZXMpOwogICAgICAgICAgICAgICAgICAgIGlmIChJRThfRE9NX0RFRklORSkKICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkZGVmaW5lUHJvcGVydHkoTywgUCwgQXR0cmlidXRlcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoJ2dldCcgaW4gQXR0cmlidXRlcyB8fCAnc2V0JyBpbiBBdHRyaWJ1dGVzKQogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyAkVHlwZUVycm9yKCdBY2Nlc3NvcnMgbm90IHN1cHBvcnRlZCcpOwogICAgICAgICAgICAgICAgICAgIGlmICgndmFsdWUnIGluIEF0dHJpYnV0ZXMpCiAgICAgICAgICAgICAgICAgICAgICAgIE9bUF0gPSBBdHRyaWJ1dGVzLnZhbHVlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBPOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNDkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gREVTQ1JJUFRPUlMgJiYgZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBPYmplY3QuZGVmaW5lUHJvcGVydHkoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIH0sICdwcm90b3R5cGUnLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiA0MiwKICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgfSkucHJvdG90eXBlICE9IDQyOwogICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDUwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciAkU3RyaW5nID0gU3RyaW5nOwogICAgICAgICAgICAgICAgdmFyICRUeXBlRXJyb3IgPSBUeXBlRXJyb3I7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChhcmd1bWVudCkgewogICAgICAgICAgICAgICAgICAgIGlmIChpc09iamVjdChhcmd1bWVudCkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcmd1bWVudDsKICAgICAgICAgICAgICAgICAgICB0aHJvdyAkVHlwZUVycm9yKCRTdHJpbmcoYXJndW1lbnQpICsgJyBpcyBub3QgYW4gb2JqZWN0Jyk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA1MSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eU1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDgpOwogICAgICAgICAgICAgICAgdmFyIG1ha2VCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1Mik7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lR2xvYmFsUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQxKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKE8sIGtleSwgdmFsdWUsIG9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIW9wdGlvbnMpCiAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbnMgPSB7fTsKICAgICAgICAgICAgICAgICAgICB2YXIgc2ltcGxlID0gb3B0aW9ucy5lbnVtZXJhYmxlOwogICAgICAgICAgICAgICAgICAgIHZhciBuYW1lID0gb3B0aW9ucy5uYW1lICE9PSB1bmRlZmluZWQgPyBvcHRpb25zLm5hbWUgOiBrZXk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzQ2FsbGFibGUodmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICBtYWtlQnVpbHRJbih2YWx1ZSwgbmFtZSwgb3B0aW9ucyk7CiAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMuZ2xvYmFsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzaW1wbGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBPW2tleV0gPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lR2xvYmFsUHJvcGVydHkoa2V5LCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb3B0aW9ucy51bnNhZmUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIE9ba2V5XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgaWYgKE9ba2V5XSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW1wbGUgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzaW1wbGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBPW2tleV0gPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lUHJvcGVydHlNb2R1bGUuZihPLCBrZXksIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW51bWVyYWJsZTogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiAhb3B0aW9ucy5ub25Db25maWd1cmFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6ICFvcHRpb25zLm5vbldyaXRhYmxlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE87CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA1MiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgREVTQ1JJUFRPUlMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkpOwogICAgICAgICAgICAgICAgdmFyIENPTkZJR1VSQUJMRV9GVU5DVElPTl9OQU1FID0gKF9fd19wZGZqc19yZXF1aXJlX18oNTMpLkNPTkZJR1VSQUJMRSk7CiAgICAgICAgICAgICAgICB2YXIgaW5zcGVjdFNvdXJjZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNTQpOwogICAgICAgICAgICAgICAgdmFyIEludGVybmFsU3RhdGVNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDU1KTsKICAgICAgICAgICAgICAgIHZhciBlbmZvcmNlSW50ZXJuYWxTdGF0ZSA9IEludGVybmFsU3RhdGVNb2R1bGUuZW5mb3JjZTsKICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbFN0YXRlID0gSW50ZXJuYWxTdGF0ZU1vZHVsZS5nZXQ7CiAgICAgICAgICAgICAgICB2YXIgJFN0cmluZyA9IFN0cmluZzsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eSA9IE9iamVjdC5kZWZpbmVQcm9wZXJ0eTsKICAgICAgICAgICAgICAgIHZhciBzdHJpbmdTbGljZSA9IHVuY3VycnlUaGlzKCcnLnNsaWNlKTsKICAgICAgICAgICAgICAgIHZhciByZXBsYWNlID0gdW5jdXJyeVRoaXMoJycucmVwbGFjZSk7CiAgICAgICAgICAgICAgICB2YXIgam9pbiA9IHVuY3VycnlUaGlzKFtdLmpvaW4pOwogICAgICAgICAgICAgICAgdmFyIENPTkZJR1VSQUJMRV9MRU5HVEggPSBERVNDUklQVE9SUyAmJiAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBkZWZpbmVQcm9wZXJ0eShmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgfSwgJ2xlbmd0aCcsIHsgdmFsdWU6IDggfSkubGVuZ3RoICE9PSA4OwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB2YXIgVEVNUExBVEUgPSBTdHJpbmcoU3RyaW5nKS5zcGxpdCgnU3RyaW5nJyk7CiAgICAgICAgICAgICAgICB2YXIgbWFrZUJ1aWx0SW4gPSBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uICh2YWx1ZSwgbmFtZSwgb3B0aW9ucykgewogICAgICAgICAgICAgICAgICAgIGlmIChzdHJpbmdTbGljZSgkU3RyaW5nKG5hbWUpLCAwLCA3KSA9PT0gJ1N5bWJvbCgnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUgPSAnWycgKyByZXBsYWNlKCRTdHJpbmcobmFtZSksIC9eU3ltYm9sXCgoW14pXSopXCkvLCAnJDEnKSArICddJzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMgJiYgb3B0aW9ucy5nZXR0ZXIpCiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUgPSAnZ2V0ICcgKyBuYW1lOwogICAgICAgICAgICAgICAgICAgIGlmIChvcHRpb25zICYmIG9wdGlvbnMuc2V0dGVyKQogICAgICAgICAgICAgICAgICAgICAgICBuYW1lID0gJ3NldCAnICsgbmFtZTsKICAgICAgICAgICAgICAgICAgICBpZiAoIWhhc093bih2YWx1ZSwgJ25hbWUnKSB8fCBDT05GSUdVUkFCTEVfRlVOQ1RJT05fTkFNRSAmJiB2YWx1ZS5uYW1lICE9PSBuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChERVNDUklQVE9SUykKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KHZhbHVlLCAnbmFtZScsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZS5uYW1lID0gbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKENPTkZJR1VSQUJMRV9MRU5HVEggJiYgb3B0aW9ucyAmJiBoYXNPd24ob3B0aW9ucywgJ2FyaXR5JykgJiYgdmFsdWUubGVuZ3RoICE9PSBvcHRpb25zLmFyaXR5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KHZhbHVlLCAnbGVuZ3RoJywgeyB2YWx1ZTogb3B0aW9ucy5hcml0eSB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMgJiYgaGFzT3duKG9wdGlvbnMsICdjb25zdHJ1Y3RvcicpICYmIG9wdGlvbnMuY29uc3RydWN0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChERVNDUklQVE9SUykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVQcm9wZXJ0eSh2YWx1ZSwgJ3Byb3RvdHlwZScsIHsgd3JpdGFibGU6IGZhbHNlIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHZhbHVlLnByb3RvdHlwZSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLnByb3RvdHlwZSA9IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBlbmZvcmNlSW50ZXJuYWxTdGF0ZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFoYXNPd24oc3RhdGUsICdzb3VyY2UnKSkgewogICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5zb3VyY2UgPSBqb2luKFRFTVBMQVRFLCB0eXBlb2YgbmFtZSA9PSAnc3RyaW5nJyA/IG5hbWUgOiAnJyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBGdW5jdGlvbi5wcm90b3R5cGUudG9TdHJpbmcgPSBtYWtlQnVpbHRJbihmdW5jdGlvbiB0b1N0cmluZygpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXNDYWxsYWJsZSh0aGlzKSAmJiBnZXRJbnRlcm5hbFN0YXRlKHRoaXMpLnNvdXJjZSB8fCBpbnNwZWN0U291cmNlKHRoaXMpOwogICAgICAgICAgICAgICAgfSwgJ3RvU3RyaW5nJyk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDUzICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgREVTQ1JJUFRPUlMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkpOwogICAgICAgICAgICAgICAgdmFyIGhhc093biA9IF9fd19wZGZqc19yZXF1aXJlX18oNDIpOwogICAgICAgICAgICAgICAgdmFyIEZ1bmN0aW9uUHJvdG90eXBlID0gRnVuY3Rpb24ucHJvdG90eXBlOwogICAgICAgICAgICAgICAgdmFyIGdldERlc2NyaXB0b3IgPSBERVNDUklQVE9SUyAmJiBPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yOwogICAgICAgICAgICAgICAgdmFyIEVYSVNUUyA9IGhhc093bihGdW5jdGlvblByb3RvdHlwZSwgJ25hbWUnKTsKICAgICAgICAgICAgICAgIHZhciBQUk9QRVIgPSBFWElTVFMgJiYgZnVuY3Rpb24gc29tZXRoaW5nKCkgewogICAgICAgICAgICAgICAgfS5uYW1lID09PSAnc29tZXRoaW5nJzsKICAgICAgICAgICAgICAgIHZhciBDT05GSUdVUkFCTEUgPSBFWElTVFMgJiYgKCFERVNDUklQVE9SUyB8fCBERVNDUklQVE9SUyAmJiBnZXREZXNjcmlwdG9yKEZ1bmN0aW9uUHJvdG90eXBlLCAnbmFtZScpLmNvbmZpZ3VyYWJsZSk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHsKICAgICAgICAgICAgICAgICAgICBFWElTVFM6IEVYSVNUUywKICAgICAgICAgICAgICAgICAgICBQUk9QRVI6IFBST1BFUiwKICAgICAgICAgICAgICAgICAgICBDT05GSUdVUkFCTEU6IENPTkZJR1VSQUJMRQogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNTQgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBzdG9yZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDApOwogICAgICAgICAgICAgICAgdmFyIGZ1bmN0aW9uVG9TdHJpbmcgPSB1bmN1cnJ5VGhpcyhGdW5jdGlvbi50b1N0cmluZyk7CiAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUoc3RvcmUuaW5zcGVjdFNvdXJjZSkpIHsKICAgICAgICAgICAgICAgICAgICBzdG9yZS5pbnNwZWN0U291cmNlID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvblRvU3RyaW5nKGl0KTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBzdG9yZS5pbnNwZWN0U291cmNlOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA1NSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIE5BVElWRV9XRUFLX01BUCA9IF9fd19wZGZqc19yZXF1aXJlX18oNTYpOwogICAgICAgICAgICAgICAgdmFyIGdsb2JhbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNyk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ3KTsKICAgICAgICAgICAgICAgIHZhciBoYXNPd24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQyKTsKICAgICAgICAgICAgICAgIHZhciBzaGFyZWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQwKTsKICAgICAgICAgICAgICAgIHZhciBzaGFyZWRLZXkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDU3KTsKICAgICAgICAgICAgICAgIHZhciBoaWRkZW5LZXlzID0gX193X3BkZmpzX3JlcXVpcmVfXyg1OCk7CiAgICAgICAgICAgICAgICB2YXIgT0JKRUNUX0FMUkVBRFlfSU5JVElBTElaRUQgPSAnT2JqZWN0IGFscmVhZHkgaW5pdGlhbGl6ZWQnOwogICAgICAgICAgICAgICAgdmFyIFR5cGVFcnJvciA9IGdsb2JhbC5UeXBlRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgV2Vha01hcCA9IGdsb2JhbC5XZWFrTWFwOwogICAgICAgICAgICAgICAgdmFyIHNldCwgZ2V0LCBoYXM7CiAgICAgICAgICAgICAgICB2YXIgZW5mb3JjZSA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBoYXMoaXQpID8gZ2V0KGl0KSA6IHNldChpdCwge30pOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBnZXR0ZXJGb3IgPSBmdW5jdGlvbiAoVFlQRSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHN0YXRlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KGl0KSB8fCAoc3RhdGUgPSBnZXQoaXQpKS50eXBlICE9PSBUWVBFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBUeXBlRXJyb3IoJ0luY29tcGF0aWJsZSByZWNlaXZlciwgJyArIFRZUEUgKyAnIHJlcXVpcmVkJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN0YXRlOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgaWYgKE5BVElWRV9XRUFLX01BUCB8fCBzaGFyZWQuc3RhdGUpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgc3RvcmUgPSBzaGFyZWQuc3RhdGUgfHwgKHNoYXJlZC5zdGF0ZSA9IG5ldyBXZWFrTWFwKCkpOwogICAgICAgICAgICAgICAgICAgIHN0b3JlLmdldCA9IHN0b3JlLmdldDsKICAgICAgICAgICAgICAgICAgICBzdG9yZS5oYXMgPSBzdG9yZS5oYXM7CiAgICAgICAgICAgICAgICAgICAgc3RvcmUuc2V0ID0gc3RvcmUuc2V0OwogICAgICAgICAgICAgICAgICAgIHNldCA9IGZ1bmN0aW9uIChpdCwgbWV0YWRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0b3JlLmhhcyhpdCkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBUeXBlRXJyb3IoT0JKRUNUX0FMUkVBRFlfSU5JVElBTElaRUQpOwogICAgICAgICAgICAgICAgICAgICAgICBtZXRhZGF0YS5mYWNhZGUgPSBpdDsKICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmUuc2V0KGl0LCBtZXRhZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBtZXRhZGF0YTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGdldCA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3RvcmUuZ2V0KGl0KSB8fCB7fTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGhhcyA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3RvcmUuaGFzKGl0KTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICB2YXIgU1RBVEUgPSBzaGFyZWRLZXkoJ3N0YXRlJyk7CiAgICAgICAgICAgICAgICAgICAgaGlkZGVuS2V5c1tTVEFURV0gPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIHNldCA9IGZ1bmN0aW9uIChpdCwgbWV0YWRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGhhc093bihpdCwgU1RBVEUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgVHlwZUVycm9yKE9CSkVDVF9BTFJFQURZX0lOSVRJQUxJWkVEKTsKICAgICAgICAgICAgICAgICAgICAgICAgbWV0YWRhdGEuZmFjYWRlID0gaXQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShpdCwgU1RBVEUsIG1ldGFkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1ldGFkYXRhOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgZ2V0ID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBoYXNPd24oaXQsIFNUQVRFKSA/IGl0W1NUQVRFXSA6IHt9OwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgaGFzID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBoYXNPd24oaXQsIFNUQVRFKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgc2V0OiBzZXQsCiAgICAgICAgICAgICAgICAgICAgZ2V0OiBnZXQsCiAgICAgICAgICAgICAgICAgICAgaGFzOiBoYXMsCiAgICAgICAgICAgICAgICAgICAgZW5mb3JjZTogZW5mb3JjZSwKICAgICAgICAgICAgICAgICAgICBnZXR0ZXJGb3I6IGdldHRlckZvcgogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNTYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBXZWFrTWFwID0gZ2xvYmFsLldlYWtNYXA7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGlzQ2FsbGFibGUoV2Vha01hcCkgJiYgL25hdGl2ZSBjb2RlLy50ZXN0KFN0cmluZyhXZWFrTWFwKSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDU3ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgc2hhcmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygzOCk7CiAgICAgICAgICAgICAgICB2YXIgdWlkID0gX193X3BkZmpzX3JlcXVpcmVfXyg0NCk7CiAgICAgICAgICAgICAgICB2YXIga2V5cyA9IHNoYXJlZCgna2V5cycpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoa2V5KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGtleXNba2V5XSB8fCAoa2V5c1trZXldID0gdWlkKGtleSkpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNTggKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHt9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA1OSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGhhc093biA9IF9fd19wZGZqc19yZXF1aXJlX18oNDIpOwogICAgICAgICAgICAgICAgdmFyIG93bktleXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYwKTsKICAgICAgICAgICAgICAgIHZhciBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3JNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDgpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZVByb3BlcnR5TW9kdWxlID0gX193X3BkZmpzX3JlcXVpcmVfXyg0OCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uICh0YXJnZXQsIHNvdXJjZSwgZXhjZXB0aW9ucykgewogICAgICAgICAgICAgICAgICAgIHZhciBrZXlzID0gb3duS2V5cyhzb3VyY2UpOwogICAgICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eSA9IGRlZmluZVByb3BlcnR5TW9kdWxlLmY7CiAgICAgICAgICAgICAgICAgICAgdmFyIGdldE93blByb3BlcnR5RGVzY3JpcHRvciA9IGdldE93blByb3BlcnR5RGVzY3JpcHRvck1vZHVsZS5mOwogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwga2V5cy5sZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIga2V5ID0ga2V5c1tpXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFoYXNPd24odGFyZ2V0LCBrZXkpICYmICEoZXhjZXB0aW9ucyAmJiBoYXNPd24oZXhjZXB0aW9ucywga2V5KSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KHRhcmdldCwga2V5LCBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3Ioc291cmNlLCBrZXkpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDYwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZ2V0QnVpbHRJbiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjcpOwogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjEpOwogICAgICAgICAgICAgICAgdmFyIGdldE93blByb3BlcnR5U3ltYm9sc01vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNzApOwogICAgICAgICAgICAgICAgdmFyIGFuT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MCk7CiAgICAgICAgICAgICAgICB2YXIgY29uY2F0ID0gdW5jdXJyeVRoaXMoW10uY29uY2F0KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZ2V0QnVpbHRJbignUmVmbGVjdCcsICdvd25LZXlzJykgfHwgZnVuY3Rpb24gb3duS2V5cyhpdCkgewogICAgICAgICAgICAgICAgICAgIHZhciBrZXlzID0gZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZS5mKGFuT2JqZWN0KGl0KSk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGdldE93blByb3BlcnR5U3ltYm9scyA9IGdldE93blByb3BlcnR5U3ltYm9sc01vZHVsZS5mOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBnZXRPd25Qcm9wZXJ0eVN5bWJvbHMgPyBjb25jYXQoa2V5cywgZ2V0T3duUHJvcGVydHlTeW1ib2xzKGl0KSkgOiBrZXlzOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNjEgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBpbnRlcm5hbE9iamVjdEtleXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYyKTsKICAgICAgICAgICAgICAgIHZhciBlbnVtQnVnS2V5cyA9IF9fd19wZGZqc19yZXF1aXJlX18oNjkpOwogICAgICAgICAgICAgICAgdmFyIGhpZGRlbktleXMgPSBlbnVtQnVnS2V5cy5jb25jYXQoJ2xlbmd0aCcsICdwcm90b3R5cGUnKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuZiA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eU5hbWVzIHx8IGZ1bmN0aW9uIGdldE93blByb3BlcnR5TmFtZXMoTykgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBpbnRlcm5hbE9iamVjdEtleXMoTywgaGlkZGVuS2V5cyk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA2MiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgdG9JbmRleGVkT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNSk7CiAgICAgICAgICAgICAgICB2YXIgaW5kZXhPZiA9IChfX3dfcGRmanNfcmVxdWlyZV9fKDYzKS5pbmRleE9mKTsKICAgICAgICAgICAgICAgIHZhciBoaWRkZW5LZXlzID0gX193X3BkZmpzX3JlcXVpcmVfXyg1OCk7CiAgICAgICAgICAgICAgICB2YXIgcHVzaCA9IHVuY3VycnlUaGlzKFtdLnB1c2gpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAob2JqZWN0LCBuYW1lcykgewogICAgICAgICAgICAgICAgICAgIHZhciBPID0gdG9JbmRleGVkT2JqZWN0KG9iamVjdCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGkgPSAwOwogICAgICAgICAgICAgICAgICAgIHZhciByZXN1bHQgPSBbXTsKICAgICAgICAgICAgICAgICAgICB2YXIga2V5OwogICAgICAgICAgICAgICAgICAgIGZvciAoa2V5IGluIE8pCiAgICAgICAgICAgICAgICAgICAgICAgICFoYXNPd24oaGlkZGVuS2V5cywga2V5KSAmJiBoYXNPd24oTywga2V5KSAmJiBwdXNoKHJlc3VsdCwga2V5KTsKICAgICAgICAgICAgICAgICAgICB3aGlsZSAobmFtZXMubGVuZ3RoID4gaSkKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGhhc093bihPLCBrZXkgPSBuYW1lc1tpKytdKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgfmluZGV4T2YocmVzdWx0LCBrZXkpIHx8IHB1c2gocmVzdWx0LCBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDYzICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgdG9JbmRleGVkT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNSk7CiAgICAgICAgICAgICAgICB2YXIgdG9BYnNvbHV0ZUluZGV4ID0gX193X3BkZmpzX3JlcXVpcmVfXyg2NCk7CiAgICAgICAgICAgICAgICB2YXIgbGVuZ3RoT2ZBcnJheUxpa2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDY3KTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVNZXRob2QgPSBmdW5jdGlvbiAoSVNfSU5DTFVERVMpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKCR0aGlzLCBlbCwgZnJvbUluZGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBPID0gdG9JbmRleGVkT2JqZWN0KCR0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGxlbmd0aCA9IGxlbmd0aE9mQXJyYXlMaWtlKE8pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgaW5kZXggPSB0b0Fic29sdXRlSW5kZXgoZnJvbUluZGV4LCBsZW5ndGgpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChJU19JTkNMVURFUyAmJiBlbCAhPSBlbCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChsZW5ndGggPiBpbmRleCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlID0gT1tpbmRleCsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmFsdWUgIT0gdmFsdWUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKDsgbGVuZ3RoID4gaW5kZXg7IGluZGV4KyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoKElTX0lOQ0xVREVTIHx8IGluZGV4IGluIE8pICYmIE9baW5kZXhdID09PSBlbCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElTX0lOQ0xVREVTIHx8IGluZGV4IHx8IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhSVNfSU5DTFVERVMgJiYgLTE7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHsKICAgICAgICAgICAgICAgICAgICBpbmNsdWRlczogY3JlYXRlTWV0aG9kKHRydWUpLAogICAgICAgICAgICAgICAgICAgIGluZGV4T2Y6IGNyZWF0ZU1ldGhvZChmYWxzZSkKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDY0ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgdG9JbnRlZ2VyT3JJbmZpbml0eSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjUpOwogICAgICAgICAgICAgICAgdmFyIG1heCA9IE1hdGgubWF4OwogICAgICAgICAgICAgICAgdmFyIG1pbiA9IE1hdGgubWluOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaW5kZXgsIGxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgIHZhciBpbnRlZ2VyID0gdG9JbnRlZ2VyT3JJbmZpbml0eShpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGludGVnZXIgPCAwID8gbWF4KGludGVnZXIgKyBsZW5ndGgsIDApIDogbWluKGludGVnZXIsIGxlbmd0aCk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA2NSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHRydW5jID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nik7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChhcmd1bWVudCkgewogICAgICAgICAgICAgICAgICAgIHZhciBudW1iZXIgPSArYXJndW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bWJlciAhPT0gbnVtYmVyIHx8IG51bWJlciA9PT0gMCA/IDAgOiB0cnVuYyhudW1iZXIpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNjYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgY2VpbCA9IE1hdGguY2VpbDsKICAgICAgICAgICAgICAgIHZhciBmbG9vciA9IE1hdGguZmxvb3I7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IE1hdGgudHJ1bmMgfHwgZnVuY3Rpb24gdHJ1bmMoeCkgewogICAgICAgICAgICAgICAgICAgIHZhciBuID0gK3g7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChuID4gMCA/IGZsb29yIDogY2VpbCkobik7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA2NyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHRvTGVuZ3RoID0gX193X3BkZmpzX3JlcXVpcmVfXyg2OCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChvYmopIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdG9MZW5ndGgob2JqLmxlbmd0aCk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA2OCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHRvSW50ZWdlck9ySW5maW5pdHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDY1KTsKICAgICAgICAgICAgICAgIHZhciBtaW4gPSBNYXRoLm1pbjsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGFyZ3VtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFyZ3VtZW50ID4gMCA/IG1pbih0b0ludGVnZXJPckluZmluaXR5KGFyZ3VtZW50KSwgMHgxRkZGRkZGRkZGRkZGRikgOiAwOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNjkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IFsKICAgICAgICAgICAgICAgICAgICAnY29uc3RydWN0b3InLAogICAgICAgICAgICAgICAgICAgICdoYXNPd25Qcm9wZXJ0eScsCiAgICAgICAgICAgICAgICAgICAgJ2lzUHJvdG90eXBlT2YnLAogICAgICAgICAgICAgICAgICAgICdwcm9wZXJ0eUlzRW51bWVyYWJsZScsCiAgICAgICAgICAgICAgICAgICAgJ3RvTG9jYWxlU3RyaW5nJywKICAgICAgICAgICAgICAgICAgICAndG9TdHJpbmcnLAogICAgICAgICAgICAgICAgICAgICd2YWx1ZU9mJwogICAgICAgICAgICAgICAgXTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNzAgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cykgPT4gewoKICAgICAgICAgICAgICAgIGV4cG9ydHMuZiA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHM7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDcxICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgcmVwbGFjZW1lbnQgPSAvI3xcLnByb3RvdHlwZVwuLzsKICAgICAgICAgICAgICAgIHZhciBpc0ZvcmNlZCA9IGZ1bmN0aW9uIChmZWF0dXJlLCBkZXRlY3Rpb24pIHsKICAgICAgICAgICAgICAgICAgICB2YXIgdmFsdWUgPSBkYXRhW25vcm1hbGl6ZShmZWF0dXJlKV07CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlID09IFBPTFlGSUxMID8gdHJ1ZSA6IHZhbHVlID09IE5BVElWRSA/IGZhbHNlIDogaXNDYWxsYWJsZShkZXRlY3Rpb24pID8gZmFpbHMoZGV0ZWN0aW9uKSA6ICEhZGV0ZWN0aW9uOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBub3JtYWxpemUgPSBpc0ZvcmNlZC5ub3JtYWxpemUgPSBmdW5jdGlvbiAoc3RyaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFN0cmluZyhzdHJpbmcpLnJlcGxhY2UocmVwbGFjZW1lbnQsICcuJykudG9Mb3dlckNhc2UoKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgZGF0YSA9IGlzRm9yY2VkLmRhdGEgPSB7fTsKICAgICAgICAgICAgICAgIHZhciBOQVRJVkUgPSBpc0ZvcmNlZC5OQVRJVkUgPSAnTic7CiAgICAgICAgICAgICAgICB2YXIgUE9MWUZJTEwgPSBpc0ZvcmNlZC5QT0xZRklMTCA9ICdQJzsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gaXNGb3JjZWQ7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDcyICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlID0gX193X3BkZmpzX3JlcXVpcmVfXyg3Myk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lUHJvcGVydHkgPSAoX193X3BkZmpzX3JlcXVpcmVfXyg0OCkuZik7CiAgICAgICAgICAgICAgICB2YXIgVU5TQ09QQUJMRVMgPSB3ZWxsS25vd25TeW1ib2woJ3Vuc2NvcGFibGVzJyk7CiAgICAgICAgICAgICAgICB2YXIgQXJyYXlQcm90b3R5cGUgPSBBcnJheS5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICBpZiAoQXJyYXlQcm90b3R5cGVbVU5TQ09QQUJMRVNdID09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KEFycmF5UHJvdG90eXBlLCBVTlNDT1BBQkxFUywgewogICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjcmVhdGUobnVsbCkKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGtleSkgewogICAgICAgICAgICAgICAgICAgIEFycmF5UHJvdG90eXBlW1VOU0NPUEFCTEVTXVtrZXldID0gdHJ1ZTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDczICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0aWVzTW9kdWxlID0gX193X3BkZmpzX3JlcXVpcmVfXyg3NCk7CiAgICAgICAgICAgICAgICB2YXIgZW51bUJ1Z0tleXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDY5KTsKICAgICAgICAgICAgICAgIHZhciBoaWRkZW5LZXlzID0gX193X3BkZmpzX3JlcXVpcmVfXyg1OCk7CiAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNzYpOwogICAgICAgICAgICAgICAgdmFyIGRvY3VtZW50Q3JlYXRlRWxlbWVudCA9IF9fd19wZGZqc19yZXF1aXJlX18oNDYpOwogICAgICAgICAgICAgICAgdmFyIHNoYXJlZEtleSA9IF9fd19wZGZqc19yZXF1aXJlX18oNTcpOwogICAgICAgICAgICAgICAgdmFyIEdUID0gJz4nOwogICAgICAgICAgICAgICAgdmFyIExUID0gJzwnOwogICAgICAgICAgICAgICAgdmFyIFBST1RPVFlQRSA9ICdwcm90b3R5cGUnOwogICAgICAgICAgICAgICAgdmFyIFNDUklQVCA9ICdzY3JpcHQnOwogICAgICAgICAgICAgICAgdmFyIElFX1BST1RPID0gc2hhcmVkS2V5KCdJRV9QUk9UTycpOwogICAgICAgICAgICAgICAgdmFyIEVtcHR5Q29uc3RydWN0b3IgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIHNjcmlwdFRhZyA9IGZ1bmN0aW9uIChjb250ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIExUICsgU0NSSVBUICsgR1QgKyBjb250ZW50ICsgTFQgKyAnLycgKyBTQ1JJUFQgKyBHVDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgTnVsbFByb3RvT2JqZWN0VmlhQWN0aXZlWCA9IGZ1bmN0aW9uIChhY3RpdmVYRG9jdW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICBhY3RpdmVYRG9jdW1lbnQud3JpdGUoc2NyaXB0VGFnKCcnKSk7CiAgICAgICAgICAgICAgICAgICAgYWN0aXZlWERvY3VtZW50LmNsb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIHRlbXAgPSBhY3RpdmVYRG9jdW1lbnQucGFyZW50V2luZG93Lk9iamVjdDsKICAgICAgICAgICAgICAgICAgICBhY3RpdmVYRG9jdW1lbnQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB0ZW1wOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBOdWxsUHJvdG9PYmplY3RWaWFJRnJhbWUgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGlmcmFtZSA9IGRvY3VtZW50Q3JlYXRlRWxlbWVudCgnaWZyYW1lJyk7CiAgICAgICAgICAgICAgICAgICAgdmFyIEpTID0gJ2phdmEnICsgU0NSSVBUICsgJzonOwogICAgICAgICAgICAgICAgICAgIHZhciBpZnJhbWVEb2N1bWVudDsKICAgICAgICAgICAgICAgICAgICBpZnJhbWUuc3R5bGUuZGlzcGxheSA9ICdub25lJzsKICAgICAgICAgICAgICAgICAgICBodG1sLmFwcGVuZENoaWxkKGlmcmFtZSk7CiAgICAgICAgICAgICAgICAgICAgaWZyYW1lLnNyYyA9IFN0cmluZyhKUyk7CiAgICAgICAgICAgICAgICAgICAgaWZyYW1lRG9jdW1lbnQgPSBpZnJhbWUuY29udGVudFdpbmRvdy5kb2N1bWVudDsKICAgICAgICAgICAgICAgICAgICBpZnJhbWVEb2N1bWVudC5vcGVuKCk7CiAgICAgICAgICAgICAgICAgICAgaWZyYW1lRG9jdW1lbnQud3JpdGUoc2NyaXB0VGFnKCdkb2N1bWVudC5GPU9iamVjdCcpKTsKICAgICAgICAgICAgICAgICAgICBpZnJhbWVEb2N1bWVudC5jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBpZnJhbWVEb2N1bWVudC5GOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBhY3RpdmVYRG9jdW1lbnQ7CiAgICAgICAgICAgICAgICB2YXIgTnVsbFByb3RvT2JqZWN0ID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGFjdGl2ZVhEb2N1bWVudCA9IG5ldyBBY3RpdmVYT2JqZWN0KCdodG1sZmlsZScpOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIE51bGxQcm90b09iamVjdCA9IHR5cGVvZiBkb2N1bWVudCAhPSAndW5kZWZpbmVkJyA/IGRvY3VtZW50LmRvbWFpbiAmJiBhY3RpdmVYRG9jdW1lbnQgPyBOdWxsUHJvdG9PYmplY3RWaWFBY3RpdmVYKGFjdGl2ZVhEb2N1bWVudCkgOiBOdWxsUHJvdG9PYmplY3RWaWFJRnJhbWUoKSA6IE51bGxQcm90b09iamVjdFZpYUFjdGl2ZVgoYWN0aXZlWERvY3VtZW50KTsKICAgICAgICAgICAgICAgICAgICB2YXIgbGVuZ3RoID0gZW51bUJ1Z0tleXMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIHdoaWxlIChsZW5ndGgtLSkKICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIE51bGxQcm90b09iamVjdFtQUk9UT1RZUEVdW2VudW1CdWdLZXlzW2xlbmd0aF1dOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBOdWxsUHJvdG9PYmplY3QoKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBoaWRkZW5LZXlzW0lFX1BST1RPXSA9IHRydWU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IE9iamVjdC5jcmVhdGUgfHwgZnVuY3Rpb24gY3JlYXRlKE8sIFByb3BlcnRpZXMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0OwogICAgICAgICAgICAgICAgICAgIGlmIChPICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIEVtcHR5Q29uc3RydWN0b3JbUFJPVE9UWVBFXSA9IGFuT2JqZWN0KE8pOwogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBuZXcgRW1wdHlDb25zdHJ1Y3RvcigpOwogICAgICAgICAgICAgICAgICAgICAgICBFbXB0eUNvbnN0cnVjdG9yW1BST1RPVFlQRV0gPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRbSUVfUFJPVE9dID0gTzsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gTnVsbFByb3RvT2JqZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFByb3BlcnRpZXMgPT09IHVuZGVmaW5lZCA/IHJlc3VsdCA6IGRlZmluZVByb3BlcnRpZXNNb2R1bGUuZihyZXN1bHQsIFByb3BlcnRpZXMpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNzQgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgVjhfUFJPVE9UWVBFX0RFRklORV9CVUcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ5KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eU1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDgpOwogICAgICAgICAgICAgICAgdmFyIGFuT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MCk7CiAgICAgICAgICAgICAgICB2YXIgdG9JbmRleGVkT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNSk7CiAgICAgICAgICAgICAgICB2YXIgb2JqZWN0S2V5cyA9IF9fd19wZGZqc19yZXF1aXJlX18oNzUpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5mID0gREVTQ1JJUFRPUlMgJiYgIVY4X1BST1RPVFlQRV9ERUZJTkVfQlVHID8gT2JqZWN0LmRlZmluZVByb3BlcnRpZXMgOiBmdW5jdGlvbiBkZWZpbmVQcm9wZXJ0aWVzKE8sIFByb3BlcnRpZXMpIHsKICAgICAgICAgICAgICAgICAgICBhbk9iamVjdChPKTsKICAgICAgICAgICAgICAgICAgICB2YXIgcHJvcHMgPSB0b0luZGV4ZWRPYmplY3QoUHJvcGVydGllcyk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGtleXMgPSBvYmplY3RLZXlzKFByb3BlcnRpZXMpOwogICAgICAgICAgICAgICAgICAgIHZhciBsZW5ndGggPSBrZXlzLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICB2YXIgaW5kZXggPSAwOwogICAgICAgICAgICAgICAgICAgIHZhciBrZXk7CiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGxlbmd0aCA+IGluZGV4KQogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVQcm9wZXJ0eU1vZHVsZS5mKE8sIGtleSA9IGtleXNbaW5kZXgrK10sIHByb3BzW2tleV0pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBPOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNzUgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBpbnRlcm5hbE9iamVjdEtleXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYyKTsKICAgICAgICAgICAgICAgIHZhciBlbnVtQnVnS2V5cyA9IF9fd19wZGZqc19yZXF1aXJlX18oNjkpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBPYmplY3Qua2V5cyB8fCBmdW5jdGlvbiBrZXlzKE8pIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaW50ZXJuYWxPYmplY3RLZXlzKE8sIGVudW1CdWdLZXlzKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDc2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZ2V0QnVpbHRJbiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjcpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBnZXRCdWlsdEluKCdkb2N1bWVudCcsICdkb2N1bWVudEVsZW1lbnQnKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNzcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChDT05TVFJVQ1RPUiwgTUVUSE9EKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVuY3VycnlUaGlzKGdsb2JhbFtDT05TVFJVQ1RPUl0ucHJvdG90eXBlW01FVEhPRF0pOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNzggKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXyg3OSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDc5ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCiAgICAgICAgICAgICAgICB2YXIgQXJyYXlCdWZmZXJWaWV3Q29yZSA9IF9fd19wZGZqc19yZXF1aXJlX18oODApOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgdG9JbnRlZ2VyT3JJbmZpbml0eSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjUpOwogICAgICAgICAgICAgICAgdmFyIGFUeXBlZEFycmF5ID0gQXJyYXlCdWZmZXJWaWV3Q29yZS5hVHlwZWRBcnJheTsKICAgICAgICAgICAgICAgIHZhciBleHBvcnRUeXBlZEFycmF5TWV0aG9kID0gQXJyYXlCdWZmZXJWaWV3Q29yZS5leHBvcnRUeXBlZEFycmF5TWV0aG9kOwogICAgICAgICAgICAgICAgZXhwb3J0VHlwZWRBcnJheU1ldGhvZCgnYXQnLCBmdW5jdGlvbiBhdChpbmRleCkgewogICAgICAgICAgICAgICAgICAgIHZhciBPID0gYVR5cGVkQXJyYXkodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGxlbiA9IGxlbmd0aE9mQXJyYXlMaWtlKE8pOwogICAgICAgICAgICAgICAgICAgIHZhciByZWxhdGl2ZUluZGV4ID0gdG9JbnRlZ2VyT3JJbmZpbml0eShpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGsgPSByZWxhdGl2ZUluZGV4ID49IDAgPyByZWxhdGl2ZUluZGV4IDogbGVuICsgcmVsYXRpdmVJbmRleDsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gayA8IDAgfHwgayA+PSBsZW4gPyB1bmRlZmluZWQgOiBPW2tdOwogICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDgwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIE5BVElWRV9BUlJBWV9CVUZGRVIgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDgxKTsKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgZ2xvYmFsID0gX193X3BkZmpzX3JlcXVpcmVfXyg3KTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBoYXNPd24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQyKTsKICAgICAgICAgICAgICAgIHZhciBjbGFzc29mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Mik7CiAgICAgICAgICAgICAgICB2YXIgdHJ5VG9TdHJpbmcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM1KTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ3KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lQnVpbHRJbkFjY2Vzc29yID0gX193X3BkZmpzX3JlcXVpcmVfXyg4NCk7CiAgICAgICAgICAgICAgICB2YXIgaXNQcm90b3R5cGVPZiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjgpOwogICAgICAgICAgICAgICAgdmFyIGdldFByb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4NSk7CiAgICAgICAgICAgICAgICB2YXIgc2V0UHJvdG90eXBlT2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg3KTsKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciB1aWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ0KTsKICAgICAgICAgICAgICAgIHZhciBJbnRlcm5hbFN0YXRlTW9kdWxlID0gX193X3BkZmpzX3JlcXVpcmVfXyg1NSk7CiAgICAgICAgICAgICAgICB2YXIgZW5mb3JjZUludGVybmFsU3RhdGUgPSBJbnRlcm5hbFN0YXRlTW9kdWxlLmVuZm9yY2U7CiAgICAgICAgICAgICAgICB2YXIgZ2V0SW50ZXJuYWxTdGF0ZSA9IEludGVybmFsU3RhdGVNb2R1bGUuZ2V0OwogICAgICAgICAgICAgICAgdmFyIEludDhBcnJheSA9IGdsb2JhbC5JbnQ4QXJyYXk7CiAgICAgICAgICAgICAgICB2YXIgSW50OEFycmF5UHJvdG90eXBlID0gSW50OEFycmF5ICYmIEludDhBcnJheS5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICB2YXIgVWludDhDbGFtcGVkQXJyYXkgPSBnbG9iYWwuVWludDhDbGFtcGVkQXJyYXk7CiAgICAgICAgICAgICAgICB2YXIgVWludDhDbGFtcGVkQXJyYXlQcm90b3R5cGUgPSBVaW50OENsYW1wZWRBcnJheSAmJiBVaW50OENsYW1wZWRBcnJheS5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICB2YXIgVHlwZWRBcnJheSA9IEludDhBcnJheSAmJiBnZXRQcm90b3R5cGVPZihJbnQ4QXJyYXkpOwogICAgICAgICAgICAgICAgdmFyIFR5cGVkQXJyYXlQcm90b3R5cGUgPSBJbnQ4QXJyYXlQcm90b3R5cGUgJiYgZ2V0UHJvdG90eXBlT2YoSW50OEFycmF5UHJvdG90eXBlKTsKICAgICAgICAgICAgICAgIHZhciBPYmplY3RQcm90b3R5cGUgPSBPYmplY3QucHJvdG90eXBlOwogICAgICAgICAgICAgICAgdmFyIFR5cGVFcnJvciA9IGdsb2JhbC5UeXBlRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgVE9fU1RSSU5HX1RBRyA9IHdlbGxLbm93blN5bWJvbCgndG9TdHJpbmdUYWcnKTsKICAgICAgICAgICAgICAgIHZhciBUWVBFRF9BUlJBWV9UQUcgPSB1aWQoJ1RZUEVEX0FSUkFZX1RBRycpOwogICAgICAgICAgICAgICAgdmFyIFRZUEVEX0FSUkFZX0NPTlNUUlVDVE9SID0gJ1R5cGVkQXJyYXlDb25zdHJ1Y3Rvcic7CiAgICAgICAgICAgICAgICB2YXIgTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUyA9IE5BVElWRV9BUlJBWV9CVUZGRVIgJiYgISFzZXRQcm90b3R5cGVPZiAmJiBjbGFzc29mKGdsb2JhbC5vcGVyYSkgIT09ICdPcGVyYSc7CiAgICAgICAgICAgICAgICB2YXIgVFlQRURfQVJSQVlfVEFHX1JFUVVJUkVEID0gZmFsc2U7CiAgICAgICAgICAgICAgICB2YXIgTkFNRSwgQ29uc3RydWN0b3IsIFByb3RvdHlwZTsKICAgICAgICAgICAgICAgIHZhciBUeXBlZEFycmF5Q29uc3RydWN0b3JzTGlzdCA9IHsKICAgICAgICAgICAgICAgICAgICBJbnQ4QXJyYXk6IDEsCiAgICAgICAgICAgICAgICAgICAgVWludDhBcnJheTogMSwKICAgICAgICAgICAgICAgICAgICBVaW50OENsYW1wZWRBcnJheTogMSwKICAgICAgICAgICAgICAgICAgICBJbnQxNkFycmF5OiAyLAogICAgICAgICAgICAgICAgICAgIFVpbnQxNkFycmF5OiAyLAogICAgICAgICAgICAgICAgICAgIEludDMyQXJyYXk6IDQsCiAgICAgICAgICAgICAgICAgICAgVWludDMyQXJyYXk6IDQsCiAgICAgICAgICAgICAgICAgICAgRmxvYXQzMkFycmF5OiA0LAogICAgICAgICAgICAgICAgICAgIEZsb2F0NjRBcnJheTogOAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBCaWdJbnRBcnJheUNvbnN0cnVjdG9yc0xpc3QgPSB7CiAgICAgICAgICAgICAgICAgICAgQmlnSW50NjRBcnJheTogOCwKICAgICAgICAgICAgICAgICAgICBCaWdVaW50NjRBcnJheTogOAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBpc1ZpZXcgPSBmdW5jdGlvbiBpc1ZpZXcoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBrbGFzcyA9IGNsYXNzb2YoaXQpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBrbGFzcyA9PT0gJ0RhdGFWaWV3JyB8fCBoYXNPd24oVHlwZWRBcnJheUNvbnN0cnVjdG9yc0xpc3QsIGtsYXNzKSB8fCBoYXNPd24oQmlnSW50QXJyYXlDb25zdHJ1Y3RvcnNMaXN0LCBrbGFzcyk7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIGdldFR5cGVkQXJyYXlDb25zdHJ1Y3RvciA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHZhciBwcm90byA9IGdldFByb3RvdHlwZU9mKGl0KTsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KHByb3RvKSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIHZhciBzdGF0ZSA9IGdldEludGVybmFsU3RhdGUocHJvdG8pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdGF0ZSAmJiBoYXNPd24oc3RhdGUsIFRZUEVEX0FSUkFZX0NPTlNUUlVDVE9SKSA/IHN0YXRlW1RZUEVEX0FSUkFZX0NPTlNUUlVDVE9SXSA6IGdldFR5cGVkQXJyYXlDb25zdHJ1Y3Rvcihwcm90byk7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIGlzVHlwZWRBcnJheSA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIGlmICghaXNPYmplY3QoaXQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgdmFyIGtsYXNzID0gY2xhc3NvZihpdCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGhhc093bihUeXBlZEFycmF5Q29uc3RydWN0b3JzTGlzdCwga2xhc3MpIHx8IGhhc093bihCaWdJbnRBcnJheUNvbnN0cnVjdG9yc0xpc3QsIGtsYXNzKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgYVR5cGVkQXJyYXkgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaXNUeXBlZEFycmF5KGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0OwogICAgICAgICAgICAgICAgICAgIHRocm93IFR5cGVFcnJvcignVGFyZ2V0IGlzIG5vdCBhIHR5cGVkIGFycmF5Jyk7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIGFUeXBlZEFycmF5Q29uc3RydWN0b3IgPSBmdW5jdGlvbiAoQykgewogICAgICAgICAgICAgICAgICAgIGlmIChpc0NhbGxhYmxlKEMpICYmICghc2V0UHJvdG90eXBlT2YgfHwgaXNQcm90b3R5cGVPZihUeXBlZEFycmF5LCBDKSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBDOwogICAgICAgICAgICAgICAgICAgIHRocm93IFR5cGVFcnJvcih0cnlUb1N0cmluZyhDKSArICcgaXMgbm90IGEgdHlwZWQgYXJyYXkgY29uc3RydWN0b3InKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgZXhwb3J0VHlwZWRBcnJheU1ldGhvZCA9IGZ1bmN0aW9uIChLRVksIHByb3BlcnR5LCBmb3JjZWQsIG9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIURFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgaWYgKGZvcmNlZCkKICAgICAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgQVJSQVkgaW4gVHlwZWRBcnJheUNvbnN0cnVjdG9yc0xpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBUeXBlZEFycmF5Q29uc3RydWN0b3IgPSBnbG9iYWxbQVJSQVldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFR5cGVkQXJyYXlDb25zdHJ1Y3RvciAmJiBoYXNPd24oVHlwZWRBcnJheUNvbnN0cnVjdG9yLnByb3RvdHlwZSwgS0VZKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgVHlwZWRBcnJheUNvbnN0cnVjdG9yLnByb3RvdHlwZVtLRVldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBUeXBlZEFycmF5Q29uc3RydWN0b3IucHJvdG90eXBlW0tFWV0gPSBwcm9wZXJ0eTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoIVR5cGVkQXJyYXlQcm90b3R5cGVbS0VZXSB8fCBmb3JjZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lQnVpbHRJbihUeXBlZEFycmF5UHJvdG90eXBlLCBLRVksIGZvcmNlZCA/IHByb3BlcnR5IDogTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUyAmJiBJbnQ4QXJyYXlQcm90b3R5cGVbS0VZXSB8fCBwcm9wZXJ0eSwgb3B0aW9ucyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBleHBvcnRUeXBlZEFycmF5U3RhdGljTWV0aG9kID0gZnVuY3Rpb24gKEtFWSwgcHJvcGVydHksIGZvcmNlZCkgewogICAgICAgICAgICAgICAgICAgIHZhciBBUlJBWSwgVHlwZWRBcnJheUNvbnN0cnVjdG9yOwogICAgICAgICAgICAgICAgICAgIGlmICghREVTQ1JJUFRPUlMpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICBpZiAoc2V0UHJvdG90eXBlT2YpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZvcmNlZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoQVJSQVkgaW4gVHlwZWRBcnJheUNvbnN0cnVjdG9yc0xpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBUeXBlZEFycmF5Q29uc3RydWN0b3IgPSBnbG9iYWxbQVJSQVldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChUeXBlZEFycmF5Q29uc3RydWN0b3IgJiYgaGFzT3duKFR5cGVkQXJyYXlDb25zdHJ1Y3RvciwgS0VZKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBUeXBlZEFycmF5Q29uc3RydWN0b3JbS0VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIVR5cGVkQXJyYXlbS0VZXSB8fCBmb3JjZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmluZUJ1aWx0SW4oVHlwZWRBcnJheSwgS0VZLCBmb3JjZWQgPyBwcm9wZXJ0eSA6IE5BVElWRV9BUlJBWV9CVUZGRVJfVklFV1MgJiYgVHlwZWRBcnJheVtLRVldIHx8IHByb3BlcnR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKEFSUkFZIGluIFR5cGVkQXJyYXlDb25zdHJ1Y3RvcnNMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIFR5cGVkQXJyYXlDb25zdHJ1Y3RvciA9IGdsb2JhbFtBUlJBWV07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChUeXBlZEFycmF5Q29uc3RydWN0b3IgJiYgKCFUeXBlZEFycmF5Q29uc3RydWN0b3JbS0VZXSB8fCBmb3JjZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluKFR5cGVkQXJyYXlDb25zdHJ1Y3RvciwgS0VZLCBwcm9wZXJ0eSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZm9yIChOQU1FIGluIFR5cGVkQXJyYXlDb25zdHJ1Y3RvcnNMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgQ29uc3RydWN0b3IgPSBnbG9iYWxbTkFNRV07CiAgICAgICAgICAgICAgICAgICAgUHJvdG90eXBlID0gQ29uc3RydWN0b3IgJiYgQ29uc3RydWN0b3IucHJvdG90eXBlOwogICAgICAgICAgICAgICAgICAgIGlmIChQcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgIGVuZm9yY2VJbnRlcm5hbFN0YXRlKFByb3RvdHlwZSlbVFlQRURfQVJSQVlfQ09OU1RSVUNUT1JdID0gQ29uc3RydWN0b3I7CiAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICBOQVRJVkVfQVJSQVlfQlVGRkVSX1ZJRVdTID0gZmFsc2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmb3IgKE5BTUUgaW4gQmlnSW50QXJyYXlDb25zdHJ1Y3RvcnNMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgQ29uc3RydWN0b3IgPSBnbG9iYWxbTkFNRV07CiAgICAgICAgICAgICAgICAgICAgUHJvdG90eXBlID0gQ29uc3RydWN0b3IgJiYgQ29uc3RydWN0b3IucHJvdG90eXBlOwogICAgICAgICAgICAgICAgICAgIGlmIChQcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgIGVuZm9yY2VJbnRlcm5hbFN0YXRlKFByb3RvdHlwZSlbVFlQRURfQVJSQVlfQ09OU1RSVUNUT1JdID0gQ29uc3RydWN0b3I7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoIU5BVElWRV9BUlJBWV9CVUZGRVJfVklFV1MgfHwgIWlzQ2FsbGFibGUoVHlwZWRBcnJheSkgfHwgVHlwZWRBcnJheSA9PT0gRnVuY3Rpb24ucHJvdG90eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgVHlwZWRBcnJheSA9IGZ1bmN0aW9uIFR5cGVkQXJyYXkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IFR5cGVFcnJvcignSW5jb3JyZWN0IGludm9jYXRpb24nKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGlmIChOQVRJVkVfQVJSQVlfQlVGRkVSX1ZJRVdTKQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKE5BTUUgaW4gVHlwZWRBcnJheUNvbnN0cnVjdG9yc0xpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxbTkFNRV0pCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0UHJvdG90eXBlT2YoZ2xvYmFsW05BTUVdLCBUeXBlZEFycmF5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKCFOQVRJVkVfQVJSQVlfQlVGRkVSX1ZJRVdTIHx8ICFUeXBlZEFycmF5UHJvdG90eXBlIHx8IFR5cGVkQXJyYXlQcm90b3R5cGUgPT09IE9iamVjdFByb3RvdHlwZSkgewogICAgICAgICAgICAgICAgICAgIFR5cGVkQXJyYXlQcm90b3R5cGUgPSBUeXBlZEFycmF5LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICBpZiAoTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUykKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChOQU1FIGluIFR5cGVkQXJyYXlDb25zdHJ1Y3RvcnNMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ2xvYmFsW05BTUVdKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFByb3RvdHlwZU9mKGdsb2JhbFtOQU1FXS5wcm90b3R5cGUsIFR5cGVkQXJyYXlQcm90b3R5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUyAmJiBnZXRQcm90b3R5cGVPZihVaW50OENsYW1wZWRBcnJheVByb3RvdHlwZSkgIT09IFR5cGVkQXJyYXlQcm90b3R5cGUpIHsKICAgICAgICAgICAgICAgICAgICBzZXRQcm90b3R5cGVPZihVaW50OENsYW1wZWRBcnJheVByb3RvdHlwZSwgVHlwZWRBcnJheVByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoREVTQ1JJUFRPUlMgJiYgIWhhc093bihUeXBlZEFycmF5UHJvdG90eXBlLCBUT19TVFJJTkdfVEFHKSkgewogICAgICAgICAgICAgICAgICAgIFRZUEVEX0FSUkFZX1RBR19SRVFVSVJFRCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgZGVmaW5lQnVpbHRJbkFjY2Vzc29yKFR5cGVkQXJyYXlQcm90b3R5cGUsIFRPX1NUUklOR19UQUcsIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpc09iamVjdCh0aGlzKSA/IHRoaXNbVFlQRURfQVJSQVlfVEFHXSA6IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIGZvciAoTkFNRSBpbiBUeXBlZEFycmF5Q29uc3RydWN0b3JzTGlzdCkKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdsb2JhbFtOQU1FXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlTm9uRW51bWVyYWJsZVByb3BlcnR5KGdsb2JhbFtOQU1FXSwgVFlQRURfQVJSQVlfVEFHLCBOQU1FKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUzogTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUywKICAgICAgICAgICAgICAgICAgICBUWVBFRF9BUlJBWV9UQUc6IFRZUEVEX0FSUkFZX1RBR19SRVFVSVJFRCAmJiBUWVBFRF9BUlJBWV9UQUcsCiAgICAgICAgICAgICAgICAgICAgYVR5cGVkQXJyYXk6IGFUeXBlZEFycmF5LAogICAgICAgICAgICAgICAgICAgIGFUeXBlZEFycmF5Q29uc3RydWN0b3I6IGFUeXBlZEFycmF5Q29uc3RydWN0b3IsCiAgICAgICAgICAgICAgICAgICAgZXhwb3J0VHlwZWRBcnJheU1ldGhvZDogZXhwb3J0VHlwZWRBcnJheU1ldGhvZCwKICAgICAgICAgICAgICAgICAgICBleHBvcnRUeXBlZEFycmF5U3RhdGljTWV0aG9kOiBleHBvcnRUeXBlZEFycmF5U3RhdGljTWV0aG9kLAogICAgICAgICAgICAgICAgICAgIGdldFR5cGVkQXJyYXlDb25zdHJ1Y3RvcjogZ2V0VHlwZWRBcnJheUNvbnN0cnVjdG9yLAogICAgICAgICAgICAgICAgICAgIGlzVmlldzogaXNWaWV3LAogICAgICAgICAgICAgICAgICAgIGlzVHlwZWRBcnJheTogaXNUeXBlZEFycmF5LAogICAgICAgICAgICAgICAgICAgIFR5cGVkQXJyYXk6IFR5cGVkQXJyYXksCiAgICAgICAgICAgICAgICAgICAgVHlwZWRBcnJheVByb3RvdHlwZTogVHlwZWRBcnJheVByb3RvdHlwZQogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogODEgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHR5cGVvZiBBcnJheUJ1ZmZlciAhPSAndW5kZWZpbmVkJyAmJiB0eXBlb2YgRGF0YVZpZXcgIT0gJ3VuZGVmaW5lZCc7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDgyICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgVE9fU1RSSU5HX1RBR19TVVBQT1JUID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Myk7CiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIGNsYXNzb2ZSYXcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE4KTsKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciBUT19TVFJJTkdfVEFHID0gd2VsbEtub3duU3ltYm9sKCd0b1N0cmluZ1RhZycpOwogICAgICAgICAgICAgICAgdmFyICRPYmplY3QgPSBPYmplY3Q7CiAgICAgICAgICAgICAgICB2YXIgQ09SUkVDVF9BUkdVTUVOVFMgPSBjbGFzc29mUmF3KChmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFyZ3VtZW50czsKICAgICAgICAgICAgICAgIH0oKSkpID09ICdBcmd1bWVudHMnOwogICAgICAgICAgICAgICAgdmFyIHRyeUdldCA9IGZ1bmN0aW9uIChpdCwga2V5KSB7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0W2tleV07CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBUT19TVFJJTkdfVEFHX1NVUFBPUlQgPyBjbGFzc29mUmF3IDogZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIE8sIHRhZywgcmVzdWx0OwogICAgICAgICAgICAgICAgICAgIHJldHVybiBpdCA9PT0gdW5kZWZpbmVkID8gJ1VuZGVmaW5lZCcgOiBpdCA9PT0gbnVsbCA/ICdOdWxsJyA6IHR5cGVvZiAodGFnID0gdHJ5R2V0KE8gPSAkT2JqZWN0KGl0KSwgVE9fU1RSSU5HX1RBRykpID09ICdzdHJpbmcnID8gdGFnIDogQ09SUkVDVF9BUkdVTUVOVFMgPyBjbGFzc29mUmF3KE8pIDogKHJlc3VsdCA9IGNsYXNzb2ZSYXcoTykpID09ICdPYmplY3QnICYmIGlzQ2FsbGFibGUoTy5jYWxsZWUpID8gJ0FyZ3VtZW50cycgOiByZXN1bHQ7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA4MyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHdlbGxLbm93blN5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzcpOwogICAgICAgICAgICAgICAgdmFyIFRPX1NUUklOR19UQUcgPSB3ZWxsS25vd25TeW1ib2woJ3RvU3RyaW5nVGFnJyk7CiAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHt9OwogICAgICAgICAgICAgICAgdGVzdFtUT19TVFJJTkdfVEFHXSA9ICd6JzsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gU3RyaW5nKHRlc3QpID09PSAnW29iamVjdCB6XSc7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDg0ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgbWFrZUJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUyKTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDgpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAodGFyZ2V0LCBuYW1lLCBkZXNjcmlwdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGRlc2NyaXB0b3IuZ2V0KQogICAgICAgICAgICAgICAgICAgICAgICBtYWtlQnVpbHRJbihkZXNjcmlwdG9yLmdldCwgbmFtZSwgeyBnZXR0ZXI6IHRydWUgfSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGRlc2NyaXB0b3Iuc2V0KQogICAgICAgICAgICAgICAgICAgICAgICBtYWtlQnVpbHRJbihkZXNjcmlwdG9yLnNldCwgbmFtZSwgeyBzZXR0ZXI6IHRydWUgfSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmluZVByb3BlcnR5LmYodGFyZ2V0LCBuYW1lLCBkZXNjcmlwdG9yKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDg1ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIHRvT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Myk7CiAgICAgICAgICAgICAgICB2YXIgc2hhcmVkS2V5ID0gX193X3BkZmpzX3JlcXVpcmVfXyg1Nyk7CiAgICAgICAgICAgICAgICB2YXIgQ09SUkVDVF9QUk9UT1RZUEVfR0VUVEVSID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Nik7CiAgICAgICAgICAgICAgICB2YXIgSUVfUFJPVE8gPSBzaGFyZWRLZXkoJ0lFX1BST1RPJyk7CiAgICAgICAgICAgICAgICB2YXIgJE9iamVjdCA9IE9iamVjdDsKICAgICAgICAgICAgICAgIHZhciBPYmplY3RQcm90b3R5cGUgPSAkT2JqZWN0LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gQ09SUkVDVF9QUk9UT1RZUEVfR0VUVEVSID8gJE9iamVjdC5nZXRQcm90b3R5cGVPZiA6IGZ1bmN0aW9uIChPKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIG9iamVjdCA9IHRvT2JqZWN0KE8pOwogICAgICAgICAgICAgICAgICAgIGlmIChoYXNPd24ob2JqZWN0LCBJRV9QUk9UTykpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBvYmplY3RbSUVfUFJPVE9dOwogICAgICAgICAgICAgICAgICAgIHZhciBjb25zdHJ1Y3RvciA9IG9iamVjdC5jb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgICAgICBpZiAoaXNDYWxsYWJsZShjb25zdHJ1Y3RvcikgJiYgb2JqZWN0IGluc3RhbmNlb2YgY29uc3RydWN0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbnN0cnVjdG9yLnByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG9iamVjdCBpbnN0YW5jZW9mICRPYmplY3QgPyBPYmplY3RQcm90b3R5cGUgOiBudWxsOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogODYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIEYoKSB7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIEYucHJvdG90eXBlLmNvbnN0cnVjdG9yID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmdldFByb3RvdHlwZU9mKG5ldyBGKCkpICE9PSBGLnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA4NyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzQWNjZXNzb3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg4KTsKICAgICAgICAgICAgICAgIHZhciBhbk9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNTApOwogICAgICAgICAgICAgICAgdmFyIGFQb3NzaWJsZVByb3RvdHlwZSA9IF9fd19wZGZqc19yZXF1aXJlX18oODkpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBPYmplY3Quc2V0UHJvdG90eXBlT2YgfHwgKCdfX3Byb3RvX18nIGluIHt9ID8gKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgQ09SUkVDVF9TRVRURVIgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHt9OwogICAgICAgICAgICAgICAgICAgIHZhciBzZXR0ZXI7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0dGVyID0gdW5jdXJyeVRoaXNBY2Nlc3NvcihPYmplY3QucHJvdG90eXBlLCAnX19wcm90b19fJywgJ3NldCcpOwogICAgICAgICAgICAgICAgICAgICAgICBzZXR0ZXIodGVzdCwgW10pOwogICAgICAgICAgICAgICAgICAgICAgICBDT1JSRUNUX1NFVFRFUiA9IHRlc3QgaW5zdGFuY2VvZiBBcnJheTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gc2V0UHJvdG90eXBlT2YoTywgcHJvdG8pIHsKICAgICAgICAgICAgICAgICAgICAgICAgYW5PYmplY3QoTyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGFQb3NzaWJsZVByb3RvdHlwZShwcm90byk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChDT1JSRUNUX1NFVFRFUikKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldHRlcihPLCBwcm90byk7CiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgIE8uX19wcm90b19fID0gcHJvdG87CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBPOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9KCkpIDogdW5kZWZpbmVkKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogODggKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgdmFyIGFDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMzQpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAob2JqZWN0LCBrZXksIG1ldGhvZCkgewogICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1bmN1cnJ5VGhpcyhhQ2FsbGFibGUoT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcihvYmplY3QsIGtleSlbbWV0aG9kXSkpOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogODkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgJFN0cmluZyA9IFN0cmluZzsKICAgICAgICAgICAgICAgIHZhciAkVHlwZUVycm9yID0gVHlwZUVycm9yOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGFyZ3VtZW50ID09ICdvYmplY3QnIHx8IGlzQ2FsbGFibGUoYXJndW1lbnQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYXJndW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcigiQ2FuJ3Qgc2V0ICIgKyAkU3RyaW5nKGFyZ3VtZW50KSArICcgYXMgYSBwcm90b3R5cGUnKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDkwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICBfX3dfcGRmanNfcmVxdWlyZV9fKDkxKTsKICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oOTgpOwogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXygxMDApOwogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXygxMjMpOwogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXygxMjUpOwogICAgICAgICAgICAgICAgdmFyIHBhdGggPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzNyk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHBhdGguc3RydWN0dXJlZENsb25lOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA5MSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciB0b0luZGV4ZWRPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1KTsKICAgICAgICAgICAgICAgIHZhciBhZGRUb1Vuc2NvcGFibGVzID0gX193X3BkZmpzX3JlcXVpcmVfXyg3Mik7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JzID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Mik7CiAgICAgICAgICAgICAgICB2YXIgSW50ZXJuYWxTdGF0ZU1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNTUpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZVByb3BlcnR5ID0gKF9fd19wZGZqc19yZXF1aXJlX18oNDgpLmYpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZUl0ZXJhdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Myk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlSXRlclJlc3VsdE9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oOTcpOwogICAgICAgICAgICAgICAgdmFyIElTX1BVUkUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM5KTsKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgQVJSQVlfSVRFUkFUT1IgPSAnQXJyYXkgSXRlcmF0b3InOwogICAgICAgICAgICAgICAgdmFyIHNldEludGVybmFsU3RhdGUgPSBJbnRlcm5hbFN0YXRlTW9kdWxlLnNldDsKICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbFN0YXRlID0gSW50ZXJuYWxTdGF0ZU1vZHVsZS5nZXR0ZXJGb3IoQVJSQVlfSVRFUkFUT1IpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBkZWZpbmVJdGVyYXRvcihBcnJheSwgJ0FycmF5JywgZnVuY3Rpb24gKGl0ZXJhdGVkLCBraW5kKSB7CiAgICAgICAgICAgICAgICAgICAgc2V0SW50ZXJuYWxTdGF0ZSh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IEFSUkFZX0lURVJBVE9SLAogICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXQ6IHRvSW5kZXhlZE9iamVjdChpdGVyYXRlZCksCiAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4OiAwLAogICAgICAgICAgICAgICAgICAgICAgICBraW5kOiBraW5kCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9LCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHN0YXRlID0gZ2V0SW50ZXJuYWxTdGF0ZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB2YXIgdGFyZ2V0ID0gc3RhdGUudGFyZ2V0OwogICAgICAgICAgICAgICAgICAgIHZhciBraW5kID0gc3RhdGUua2luZDsKICAgICAgICAgICAgICAgICAgICB2YXIgaW5kZXggPSBzdGF0ZS5pbmRleCsrOwogICAgICAgICAgICAgICAgICAgIGlmICghdGFyZ2V0IHx8IGluZGV4ID49IHRhcmdldC5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUudGFyZ2V0ID0gdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlSXRlclJlc3VsdE9iamVjdCh1bmRlZmluZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoa2luZCA9PSAna2V5cycpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjcmVhdGVJdGVyUmVzdWx0T2JqZWN0KGluZGV4LCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGtpbmQgPT0gJ3ZhbHVlcycpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjcmVhdGVJdGVyUmVzdWx0T2JqZWN0KHRhcmdldFtpbmRleF0sIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlSXRlclJlc3VsdE9iamVjdChbCiAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXRbaW5kZXhdCiAgICAgICAgICAgICAgICAgICAgXSwgZmFsc2UpOwogICAgICAgICAgICAgICAgfSwgJ3ZhbHVlcycpOwogICAgICAgICAgICAgICAgdmFyIHZhbHVlcyA9IEl0ZXJhdG9ycy5Bcmd1bWVudHMgPSBJdGVyYXRvcnMuQXJyYXk7CiAgICAgICAgICAgICAgICBhZGRUb1Vuc2NvcGFibGVzKCdrZXlzJyk7CiAgICAgICAgICAgICAgICBhZGRUb1Vuc2NvcGFibGVzKCd2YWx1ZXMnKTsKICAgICAgICAgICAgICAgIGFkZFRvVW5zY29wYWJsZXMoJ2VudHJpZXMnKTsKICAgICAgICAgICAgICAgIGlmICghSVNfUFVSRSAmJiBERVNDUklQVE9SUyAmJiB2YWx1ZXMubmFtZSAhPT0gJ3ZhbHVlcycpCiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lUHJvcGVydHkodmFsdWVzLCAnbmFtZScsIHsgdmFsdWU6ICd2YWx1ZXMnIH0pOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA5MiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0ge307CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDkzICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyICQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYpOwogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExKTsKICAgICAgICAgICAgICAgIHZhciBJU19QVVJFID0gX193X3BkZmpzX3JlcXVpcmVfXygzOSk7CiAgICAgICAgICAgICAgICB2YXIgRnVuY3Rpb25OYW1lID0gX193X3BkZmpzX3JlcXVpcmVfXyg1Myk7CiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZUl0ZXJhdG9yQ29uc3RydWN0b3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk0KTsKICAgICAgICAgICAgICAgIHZhciBnZXRQcm90b3R5cGVPZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODUpOwogICAgICAgICAgICAgICAgdmFyIHNldFByb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Nyk7CiAgICAgICAgICAgICAgICB2YXIgc2V0VG9TdHJpbmdUYWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk2KTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ3KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MSk7CiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JzID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Mik7CiAgICAgICAgICAgICAgICB2YXI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TWV0aG9kID0gZnVuY3Rpb24gKEtJTkQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEtJTkQgPT09IERFRkFVTFQgJiYgZGVmYXVsdEl0ZXJhdG9yKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmF1bHRJdGVyYXRvcjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFCVUdHWV9TQUZBUklfSVRFUkFUT1JTICYmIEtJTkQgaW4gSXRlcmFibGVQcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gSXRlcmFibGVQcm90b3R5cGVbS0lORF07CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoS0lORCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBLRVlTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBrZXlzKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEl0ZXJhdG9yQ29uc3RydWN0b3IodGhpcywgS0lORCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgVkFMVUVTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiB2YWx1ZXMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgSXRlcmF0b3JDb25zdHJ1Y3Rvcih0aGlzLCBLSU5EKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBFTlRSSUVTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBlbnRyaWVzKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEl0ZXJhdG9yQ29uc3RydWN0b3IodGhpcywgS0lORCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBJdGVyYXRvckNvbnN0cnVjdG9yKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgdmFyIFRPX1NUUklOR19UQUcgPSBOQU1FICsgJyBJdGVyYXRvcic7CiAgICAgICAgICAgICAgICAgICAgdmFyIElOQ09SUkVDVF9WQUxVRVNfTkFNRSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBJdGVyYWJsZVByb3RvdHlwZSA9IEl0ZXJhYmxlLnByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICB2YXIgbmF0aXZlSXRlcmF0b3IgPSBJdGVyYWJsZVByb3RvdHlwZVtJVEVSQVRPUl0gfHwgSXRlcmFibGVQcm90b3R5cGVbJ0BAaXRlcmF0b3InXSB8fCBERUZBVUxUICYmIEl0ZXJhYmxlUHJvdG90eXBlW0RFRkFVTFRdOwogICAgICAgICAgICAgICAgICAgIHZhciBkZWZhdWx0SXRlcmF0b3IgPSAhQlVHR1lfU0FGQVJJX0lURVJBVE9SUyAmJiBuYXRpdmVJdGVyYXRvciB8fCBnZXRJdGVyYXRpb25NZXRob2QoREVGQVVMVCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGFueU5hdGl2ZUl0ZXJhdG9yID0gTkFNRSA9PSAnQXJyYXknID8gSXRlcmFibGVQcm90b3R5cGUuZW50cmllcyB8fCBuYXRpdmVJdGVyYXRvciA6IG5hdGl2ZUl0ZXJhdG9yOwogICAgICAgICAgICAgICAgICAgIHZhciBDdXJyZW50SXRlcmF0b3JQcm90b3R5cGUsIG1ldGhvZHMsIEtFWTsKICAgICAgICAgICAgICAgICAgICBpZiAoYW55TmF0aXZlSXRlcmF0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlID0gZ2V0UHJvdG90eXBlT2YoYW55TmF0aXZlSXRlcmF0b3IuY2FsbChuZXcgSXRlcmFibGUoKSkpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlICE9PSBPYmplY3QucHJvdG90eXBlICYmIEN1cnJlbnRJdGVyYXRvclByb3RvdHlwZS5uZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIUlTX1BVUkUgJiYgZ2V0UHJvdG90eXBlT2YoQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlKSAhPT0gSXRlcmF0b3JQcm90b3R5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2V0UHJvdG90eXBlT2YpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0UHJvdG90eXBlT2YoQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlLCBJdGVyYXRvclByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICghaXNDYWxsYWJsZShDdXJyZW50SXRlcmF0b3JQcm90b3R5cGVbSVRFUkFUT1JdKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluKEN1cnJlbnRJdGVyYXRvclByb3RvdHlwZSwgSVRFUkFUT1IsIHJldHVyblRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFRvU3RyaW5nVGFnKEN1cnJlbnRJdGVyYXRvclByb3RvdHlwZSwgVE9fU1RSSU5HX1RBRywgdHJ1ZSwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoSVNfUFVSRSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJdGVyYXRvcnNbVE9fU1RSSU5HX1RBR10gPSByZXR1cm5UaGlzOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChQUk9QRVJfRlVOQ1RJT05fTkFNRSAmJiBERUZBVUxUID09IFZBTFVFUyAmJiBuYXRpdmVJdGVyYXRvciAmJiBuYXRpdmVJdGVyYXRvci5uYW1lICE9PSBWQUxVRVMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFJU19QVVJFICYmIENPTkZJR1VSQUJMRV9GVU5DVElPTl9OQU1FKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkoSXRlcmFibGVQcm90b3R5cGUsICduYW1lJywgVkFMVUVTKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIElOQ09SUkVDVF9WQUxVRVNfTkFNRSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0SXRlcmF0b3IgPSBmdW5jdGlvbiB2YWx1ZXMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGwobmF0aXZlSXRlcmF0b3IsIHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoREVGQVVMVCkgewogICAgICAgICAgICAgICAgICAgICAgICBtZXRob2RzID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWVzOiBnZXRJdGVyYXRpb25NZXRob2QoVkFMVUVTKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtleXM6IElTX1NFVCA/IGRlZmF1bHRJdGVyYXRvciA6IGdldEl0ZXJhdGlvbk1ldGhvZChLRVlTKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJpZXM6IGdldEl0ZXJhdGlvbk1ldGhvZChFTlRSSUVTKQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoRk9SQ0VEKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChLRVkgaW4gbWV0aG9kcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChCVUdHWV9TQUZBUklfSVRFUkFUT1JTIHx8IElOQ09SUkVDVF9WQUxVRVNfTkFNRSB8fCAhKEtFWSBpbiBJdGVyYWJsZVByb3RvdHlwZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lQnVpbHRJbihJdGVyYWJsZVByb3RvdHlwZSwgS0VZLCBtZXRob2RzW0tFWV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgJCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiBOQU1FLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb3RvOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcmNlZDogQlVHR1lfU0FGQVJJX0lURVJBVE9SUyB8fCBJTkNPUlJFQ1RfVkFMVUVTX05BTUUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIG1ldGhvZHMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoKCFJU19QVVJFIHx8IEZPUkNFRCkgJiYgSXRlcmFibGVQcm90b3R5cGVbSVRFUkFUT1JdICE9PSBkZWZhdWx0SXRlcmF0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lQnVpbHRJbihJdGVyYWJsZVByb3RvdHlwZSwgSVRFUkFUT1IsIGRlZmF1bHRJdGVyYXRvciwgeyBuYW1lOiBERUZBVUxUIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBJdGVyYXRvcnNbTkFNRV0gPSBkZWZhdWx0SXRlcmF0b3I7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1ldGhvZHM7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA5NCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBJdGVyYXRvclByb3RvdHlwZSA9IChfX3dfcGRmanNfcmVxdWlyZV9fKDk1KS5JdGVyYXRvclByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlID0gX193X3BkZmpzX3JlcXVpcmVfXyg3Myk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNCk7CiAgICAgICAgICAgICAgICB2YXIgc2V0VG9TdHJpbmdUYWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk2KTsKICAgICAgICAgICAgICAgIHZhciBJdGVyYXRvcnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkyKTsKICAgICAgICAgICAgICAgIHZhciByZXR1cm5UaGlzID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKEl0ZXJhdG9yQ29uc3RydWN0b3IsIE5BTUUsIG5leHQsIEVOVU1FUkFCTEVfTkVYVCkgewogICAgICAgICAgICAgICAgICAgIHZhciBUT19TVFJJTkdfVEFHID0gTkFNRSArICcgSXRlcmF0b3InOwogICAgICAgICAgICAgICAgICAgIEl0ZXJhdG9yQ29uc3RydWN0b3IucHJvdG90eXBlID0gY3JlYXRlKEl0ZXJhdG9yUHJvdG90eXBlLCB7IG5leHQ6IGNyZWF0ZVByb3BlcnR5RGVzY3JpcHRvcigrIUVOVU1FUkFCTEVfTkVYVCwgbmV4dCkgfSk7CiAgICAgICAgICAgICAgICAgICAgc2V0VG9TdHJpbmdUYWcoSXRlcmF0b3JDb25zdHJ1Y3RvciwgVE9fU1RSSU5HX1RBRywgZmFsc2UsIHRydWUpOwogICAgICAgICAgICAgICAgICAgIEl0ZXJhdG9yc1tUT19TVFJJTkdfVEFHXSA9IHJldHVyblRoaXM7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEl0ZXJhdG9yQ29uc3RydWN0b3I7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA5NSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc09iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjMpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNzMpOwogICAgICAgICAgICAgICAgdmFyIGdldFByb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4NSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lQnVpbHRJbiA9IF9fd19wZGZqc19yZXF1aXJlX18oNTEpOwogICAgICAgICAgICAgICAgdmFyIHdlbGxLbm93blN5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzcpOwogICAgICAgICAgICAgICAgdmFyIElTX1BVUkUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM5KTsKICAgICAgICAgICAgICAgIHZhciBJVEVSQVRPUiA9IHdlbGxLbm93blN5bWJvbCgnaXRlcmF0b3InKTsKICAgICAgICAgICAgICAgIHZhciBCVUdHWV9TQUZBUklfSVRFUkFUT1JTID0gZmFsc2U7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JQcm90b3R5cGUsIFByb3RvdHlwZU9mQXJyYXlJdGVyYXRvclByb3RvdHlwZSwgYXJyYXlJdGVyYXRvcjsKICAgICAgICAgICAgICAgIGlmIChbXS5rZXlzKSB7CiAgICAgICAgICAgICAgICAgICAgYXJyYXlJdGVyYXRvciA9IFtdLmtleXMoKTsKICAgICAgICAgICAgICAgICAgICBpZiAoISgnbmV4dCcgaW4gYXJyYXlJdGVyYXRvcikpCiAgICAgICAgICAgICAgICAgICAgICAgIEJVR0dZX1NBRkFSSV9JVEVSQVRPUlMgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBQcm90b3R5cGVPZkFycmF5SXRlcmF0b3JQcm90b3R5cGUgPSBnZXRQcm90b3R5cGVPZihnZXRQcm90b3R5cGVPZihhcnJheUl0ZXJhdG9yKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChQcm90b3R5cGVPZkFycmF5SXRlcmF0b3JQcm90b3R5cGUgIT09IE9iamVjdC5wcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBJdGVyYXRvclByb3RvdHlwZSA9IFByb3RvdHlwZU9mQXJyYXlJdGVyYXRvclByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB2YXIgTkVXX0lURVJBVE9SX1BST1RPVFlQRSA9ICFpc09iamVjdChJdGVyYXRvclByb3RvdHlwZSkgfHwgZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciB0ZXN0ID0ge307CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEl0ZXJhdG9yUHJvdG90eXBlW0lURVJBVE9SXS5jYWxsKHRlc3QpICE9PSB0ZXN0OwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBpZiAoTkVXX0lURVJBVE9SX1BST1RPVFlQRSkKICAgICAgICAgICAgICAgICAgICBJdGVyYXRvclByb3RvdHlwZSA9IHt9OwogICAgICAgICAgICAgICAgZWxzZSBpZiAoSVNfUFVSRSkKICAgICAgICAgICAgICAgICAgICBJdGVyYXRvclByb3RvdHlwZSA9IGNyZWF0ZShJdGVyYXRvclByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUoSXRlcmF0b3JQcm90b3R5cGVbSVRFUkFUT1JdKSkgewogICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4oSXRlcmF0b3JQcm90b3R5cGUsIElURVJBVE9SLCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgSXRlcmF0b3JQcm90b3R5cGU6IEl0ZXJhdG9yUHJvdG90eXBlLAogICAgICAgICAgICAgICAgICAgIEJVR0dZX1NBRkFSSV9JVEVSQVRPUlM6IEJVR0dZX1NBRkFSSV9JVEVSQVRPUlMKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDk2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lUHJvcGVydHkgPSAoX193X3BkZmpzX3JlcXVpcmVfXyg0OCkuZik7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgVE9fU1RSSU5HX1RBRyA9IHdlbGxLbm93blN5bWJvbCgndG9TdHJpbmdUYWcnKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKHRhcmdldCwgVEFHLCBTVEFUSUMpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodGFyZ2V0ICYmICFTVEFUSUMpCiAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldCA9IHRhcmdldC5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRhcmdldCAmJiAhaGFzT3duKHRhcmdldCwgVE9fU1RSSU5HX1RBRykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lUHJvcGVydHkodGFyZ2V0LCBUT19TVFJJTkdfVEFHLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogVEFHCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDk3ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlKSA9PiB7CgogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAodmFsdWUsIGRvbmUpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IGRvbmUKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogOTggKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIFRPX1NUUklOR19UQUdfU1VQUE9SVCA9IF9fd19wZGZqc19yZXF1aXJlX18oODMpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZUJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUxKTsKICAgICAgICAgICAgICAgIHZhciB0b1N0cmluZyA9IF9fd19wZGZqc19yZXF1aXJlX18oOTkpOwogICAgICAgICAgICAgICAgaWYgKCFUT19TVFJJTkdfVEFHX1NVUFBPUlQpIHsKICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluKE9iamVjdC5wcm90b3R5cGUsICd0b1N0cmluZycsIHRvU3RyaW5nLCB7IHVuc2FmZTogdHJ1ZSB9KTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogOTkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCiAgICAgICAgICAgICAgICB2YXIgVE9fU1RSSU5HX1RBR19TVVBQT1JUID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Myk7CiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODIpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBUT19TVFJJTkdfVEFHX1NVUFBPUlQgPyB7fS50b1N0cmluZyA6IGZ1bmN0aW9uIHRvU3RyaW5nKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiAnW29iamVjdCAnICsgY2xhc3NvZih0aGlzKSArICddJzsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwMCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICBfX3dfcGRmanNfcmVxdWlyZV9fKDEwMSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwMSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIGNvbGxlY3Rpb24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwMik7CiAgICAgICAgICAgICAgICB2YXIgY29sbGVjdGlvblN0cm9uZyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTIwKTsKICAgICAgICAgICAgICAgIGNvbGxlY3Rpb24oJ01hcCcsIGZ1bmN0aW9uIChpbml0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uIE1hcCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGluaXQodGhpcywgYXJndW1lbnRzLmxlbmd0aCA/IGFyZ3VtZW50c1swXSA6IHVuZGVmaW5lZCk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0sIGNvbGxlY3Rpb25TdHJvbmcpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMDIgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCiAgICAgICAgICAgICAgICB2YXIgJCA9IF9fd19wZGZqc19yZXF1aXJlX18oNik7CiAgICAgICAgICAgICAgICB2YXIgZ2xvYmFsID0gX193X3BkZmpzX3JlcXVpcmVfXyg3KTsKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgdmFyIGlzRm9yY2VkID0gX193X3BkZmpzX3JlcXVpcmVfXyg3MSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lQnVpbHRJbiA9IF9fd19wZGZqc19yZXF1aXJlX18oNTEpOwogICAgICAgICAgICAgICAgdmFyIEludGVybmFsTWV0YWRhdGFNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwMyk7CiAgICAgICAgICAgICAgICB2YXIgaXRlcmF0ZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTEwKTsKICAgICAgICAgICAgICAgIHZhciBhbkluc3RhbmNlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTcpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc051bGxPclVuZGVmaW5lZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjApOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBjaGVja0NvcnJlY3RuZXNzT2ZJdGVyYXRpb24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExOCk7CiAgICAgICAgICAgICAgICB2YXIgc2V0VG9TdHJpbmdUYWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk2KTsKICAgICAgICAgICAgICAgIHZhciBpbmhlcml0SWZSZXF1aXJlZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTE5KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKENPTlNUUlVDVE9SX05BTUUsIHdyYXBwZXIsIGNvbW1vbikgewogICAgICAgICAgICAgICAgICAgIHZhciBJU19NQVAgPSBDT05TVFJVQ1RPUl9OQU1FLmluZGV4T2YoJ01hcCcpICE9PSAtMTsKICAgICAgICAgICAgICAgICAgICB2YXIgSVNfV0VBSyA9IENPTlNUUlVDVE9SX05BTUUuaW5kZXhPZignV2VhaycpICE9PSAtMTsKICAgICAgICAgICAgICAgICAgICB2YXIgQURERVIgPSBJU19NQVAgPyAnc2V0JyA6ICdhZGQnOwogICAgICAgICAgICAgICAgICAgIHZhciBOYXRpdmVDb25zdHJ1Y3RvciA9IGdsb2JhbFtDT05TVFJVQ1RPUl9OQU1FXTsKICAgICAgICAgICAgICAgICAgICB2YXIgTmF0aXZlUHJvdG90eXBlID0gTmF0aXZlQ29uc3RydWN0b3IgJiYgTmF0aXZlQ29uc3RydWN0b3IucHJvdG90eXBlOwogICAgICAgICAgICAgICAgICAgIHZhciBDb25zdHJ1Y3RvciA9IE5hdGl2ZUNvbnN0cnVjdG9yOwogICAgICAgICAgICAgICAgICAgIHZhciBleHBvcnRlZCA9IHt9OwogICAgICAgICAgICAgICAgICAgIHZhciBmaXhNZXRob2QgPSBmdW5jdGlvbiAoS0VZKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB1bmN1cnJpZWROYXRpdmVNZXRob2QgPSB1bmN1cnJ5VGhpcyhOYXRpdmVQcm90b3R5cGVbS0VZXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4oTmF0aXZlUHJvdG90eXBlLCBLRVksIEtFWSA9PSAnYWRkJyA/IGZ1bmN0aW9uIGFkZCh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5jdXJyaWVkTmF0aXZlTWV0aG9kKHRoaXMsIHZhbHVlID09PSAwID8gMCA6IHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICB9IDogS0VZID09ICdkZWxldGUnID8gZnVuY3Rpb24gKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElTX1dFQUsgJiYgIWlzT2JqZWN0KGtleSkgPyBmYWxzZSA6IHVuY3VycmllZE5hdGl2ZU1ldGhvZCh0aGlzLCBrZXkgPT09IDAgPyAwIDoga2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSA6IEtFWSA9PSAnZ2V0JyA/IGZ1bmN0aW9uIGdldChrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBJU19XRUFLICYmICFpc09iamVjdChrZXkpID8gdW5kZWZpbmVkIDogdW5jdXJyaWVkTmF0aXZlTWV0aG9kKHRoaXMsIGtleSA9PT0gMCA/IDAgOiBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICB9IDogS0VZID09ICdoYXMnID8gZnVuY3Rpb24gaGFzKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElTX1dFQUsgJiYgIWlzT2JqZWN0KGtleSkgPyBmYWxzZSA6IHVuY3VycmllZE5hdGl2ZU1ldGhvZCh0aGlzLCBrZXkgPT09IDAgPyAwIDoga2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSA6IGZ1bmN0aW9uIHNldChrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bmN1cnJpZWROYXRpdmVNZXRob2QodGhpcywga2V5ID09PSAwID8gMCA6IGtleSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgdmFyIFJFUExBQ0UgPSBpc0ZvcmNlZChDT05TVFJVQ1RPUl9OQU1FLCAhaXNDYWxsYWJsZShOYXRpdmVDb25zdHJ1Y3RvcikgfHwgIShJU19XRUFLIHx8IE5hdGl2ZVByb3RvdHlwZS5mb3JFYWNoICYmICFmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBOYXRpdmVDb25zdHJ1Y3RvcigpLmVudHJpZXMoKS5uZXh0KCk7CiAgICAgICAgICAgICAgICAgICAgfSkpKTsKICAgICAgICAgICAgICAgICAgICBpZiAoUkVQTEFDRSkgewogICAgICAgICAgICAgICAgICAgICAgICBDb25zdHJ1Y3RvciA9IGNvbW1vbi5nZXRDb25zdHJ1Y3Rvcih3cmFwcGVyLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVAsIEFEREVSKTsKICAgICAgICAgICAgICAgICAgICAgICAgSW50ZXJuYWxNZXRhZGF0YU1vZHVsZS5lbmFibGUoKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGlzRm9yY2VkKENPTlNUUlVDVE9SX05BTUUsIHRydWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBpbnN0YW5jZSA9IG5ldyBDb25zdHJ1Y3RvcigpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgSEFTTlRfQ0hBSU5JTkcgPSBpbnN0YW5jZVtBRERFUl0oSVNfV0VBSyA/IHt9IDogLTAsIDEpICE9IGluc3RhbmNlOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgVEhST1dTX09OX1BSSU1JVElWRVMgPSBmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnN0YW5jZS5oYXMoMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgQUNDRVBUX0lURVJBQkxFUyA9IGNoZWNrQ29ycmVjdG5lc3NPZkl0ZXJhdGlvbihmdW5jdGlvbiAoaXRlcmFibGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBOYXRpdmVDb25zdHJ1Y3RvcihpdGVyYWJsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgQlVHR1lfWkVSTyA9ICFJU19XRUFLICYmIGZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciAkaW5zdGFuY2UgPSBuZXcgTmF0aXZlQ29uc3RydWN0b3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBpbmRleCA9IDU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoaW5kZXgtLSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkaW5zdGFuY2VbQURERVJdKGluZGV4LCBpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gISRpbnN0YW5jZS5oYXMoLTApOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFBQ0NFUFRfSVRFUkFCTEVTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zdHJ1Y3RvciA9IHdyYXBwZXIoZnVuY3Rpb24gKGR1bW15LCBpdGVyYWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFuSW5zdGFuY2UoZHVtbXksIE5hdGl2ZVByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRoYXQgPSBpbmhlcml0SWZSZXF1aXJlZChuZXcgTmF0aXZlQ29uc3RydWN0b3IoKSwgZHVtbXksIENvbnN0cnVjdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzTnVsbE9yVW5kZWZpbmVkKGl0ZXJhYmxlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlcmF0ZShpdGVyYWJsZSwgdGhhdFtBRERFUl0sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQ6IHRoYXQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBU19FTlRSSUVTOiBJU19NQVAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoYXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnN0cnVjdG9yLnByb3RvdHlwZSA9IE5hdGl2ZVByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIE5hdGl2ZVByb3RvdHlwZS5jb25zdHJ1Y3RvciA9IENvbnN0cnVjdG9yOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChUSFJPV1NfT05fUFJJTUlUSVZFUyB8fCBCVUdHWV9aRVJPKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaXhNZXRob2QoJ2RlbGV0ZScpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZml4TWV0aG9kKCdoYXMnKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIElTX01BUCAmJiBmaXhNZXRob2QoJ2dldCcpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChCVUdHWV9aRVJPIHx8IEhBU05UX0NIQUlOSU5HKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZml4TWV0aG9kKEFEREVSKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKElTX1dFQUsgJiYgTmF0aXZlUHJvdG90eXBlLmNsZWFyKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIE5hdGl2ZVByb3RvdHlwZS5jbGVhcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0ZWRbQ09OU1RSVUNUT1JfTkFNRV0gPSBDb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgICAgICAkKHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2xvYmFsOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcjogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgZm9yY2VkOiBDb25zdHJ1Y3RvciAhPSBOYXRpdmVDb25zdHJ1Y3RvcgogICAgICAgICAgICAgICAgICAgIH0sIGV4cG9ydGVkKTsKICAgICAgICAgICAgICAgICAgICBzZXRUb1N0cmluZ1RhZyhDb25zdHJ1Y3RvciwgQ09OU1RSVUNUT1JfTkFNRSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFJU19XRUFLKQogICAgICAgICAgICAgICAgICAgICAgICBjb21tb24uc2V0U3Ryb25nKENvbnN0cnVjdG9yLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVApOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBDb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwMyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyICQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYpOwogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgaGlkZGVuS2V5cyA9IF9fd19wZGZqc19yZXF1aXJlX18oNTgpOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lUHJvcGVydHkgPSAoX193X3BkZmpzX3JlcXVpcmVfXyg0OCkuZik7CiAgICAgICAgICAgICAgICB2YXIgZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjEpOwogICAgICAgICAgICAgICAgdmFyIGdldE93blByb3BlcnR5TmFtZXNFeHRlcm5hbE1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTA0KTsKICAgICAgICAgICAgICAgIHZhciBpc0V4dGVuc2libGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwNyk7CiAgICAgICAgICAgICAgICB2YXIgdWlkID0gX193X3BkZmpzX3JlcXVpcmVfXyg0NCk7CiAgICAgICAgICAgICAgICB2YXIgRlJFRVpJTkcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwOSk7CiAgICAgICAgICAgICAgICB2YXIgUkVRVUlSRUQgPSBmYWxzZTsKICAgICAgICAgICAgICAgIHZhciBNRVRBREFUQSA9IHVpZCgnbWV0YScpOwogICAgICAgICAgICAgICAgdmFyIGlkID0gMDsKICAgICAgICAgICAgICAgIHZhciBzZXRNZXRhZGF0YSA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KGl0LCBNRVRBREFUQSwgewogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2JqZWN0SUQ6ICdPJyArIGlkKyssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3ZWFrRGF0YToge30KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBmYXN0S2V5ID0gZnVuY3Rpb24gKGl0LCBjcmVhdGUpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiBpdCA9PSAnc3ltYm9sJyA/IGl0IDogKHR5cGVvZiBpdCA9PSAnc3RyaW5nJyA/ICdTJyA6ICdQJykgKyBpdDsKICAgICAgICAgICAgICAgICAgICBpZiAoIWhhc093bihpdCwgTUVUQURBVEEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNFeHRlbnNpYmxlKGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAnRic7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghY3JlYXRlKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdFJzsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0TWV0YWRhdGEoaXQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXRbTUVUQURBVEFdLm9iamVjdElEOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBnZXRXZWFrRGF0YSA9IGZ1bmN0aW9uIChpdCwgY3JlYXRlKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFoYXNPd24oaXQsIE1FVEFEQVRBKSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzRXh0ZW5zaWJsZShpdCkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjcmVhdGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHNldE1ldGFkYXRhKGl0KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0W01FVEFEQVRBXS53ZWFrRGF0YTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgb25GcmVlemUgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoRlJFRVpJTkcgJiYgUkVRVUlSRUQgJiYgaXNFeHRlbnNpYmxlKGl0KSAmJiAhaGFzT3duKGl0LCBNRVRBREFUQSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHNldE1ldGFkYXRhKGl0KTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXQ7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIGVuYWJsZSA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICBtZXRhLmVuYWJsZSA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIFJFUVVJUkVEID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB2YXIgZ2V0T3duUHJvcGVydHlOYW1lcyA9IGdldE93blByb3BlcnR5TmFtZXNNb2R1bGUuZjsKICAgICAgICAgICAgICAgICAgICB2YXIgc3BsaWNlID0gdW5jdXJyeVRoaXMoW10uc3BsaWNlKTsKICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHt9OwogICAgICAgICAgICAgICAgICAgIHRlc3RbTUVUQURBVEFdID0gMTsKICAgICAgICAgICAgICAgICAgICBpZiAoZ2V0T3duUHJvcGVydHlOYW1lcyh0ZXN0KS5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZS5mID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gZ2V0T3duUHJvcGVydHlOYW1lcyhpdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgbGVuZ3RoID0gcmVzdWx0Lmxlbmd0aDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdFtpXSA9PT0gTUVUQURBVEEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3BsaWNlKHJlc3VsdCwgaSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICQoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiAnT2JqZWN0JywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXQ6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JjZWQ6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSwgeyBnZXRPd25Qcm9wZXJ0eU5hbWVzOiBnZXRPd25Qcm9wZXJ0eU5hbWVzRXh0ZXJuYWxNb2R1bGUuZiB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIG1ldGEgPSBtb2R1bGUuZXhwb3J0cyA9IHsKICAgICAgICAgICAgICAgICAgICBlbmFibGU6IGVuYWJsZSwKICAgICAgICAgICAgICAgICAgICBmYXN0S2V5OiBmYXN0S2V5LAogICAgICAgICAgICAgICAgICAgIGdldFdlYWtEYXRhOiBnZXRXZWFrRGF0YSwKICAgICAgICAgICAgICAgICAgICBvbkZyZWV6ZTogb25GcmVlemUKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBoaWRkZW5LZXlzW01FVEFEQVRBXSA9IHRydWU7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwNCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGNsYXNzb2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE4KTsKICAgICAgICAgICAgICAgIHZhciB0b0luZGV4ZWRPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1KTsKICAgICAgICAgICAgICAgIHZhciAkZ2V0T3duUHJvcGVydHlOYW1lcyA9IChfX3dfcGRmanNfcmVxdWlyZV9fKDYxKS5mKTsKICAgICAgICAgICAgICAgIHZhciBhcnJheVNsaWNlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMDUpOwogICAgICAgICAgICAgICAgdmFyIHdpbmRvd05hbWVzID0gdHlwZW9mIHdpbmRvdyA9PSAnb2JqZWN0JyAmJiB3aW5kb3cgJiYgT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXMgPyBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyh3aW5kb3cpIDogW107CiAgICAgICAgICAgICAgICB2YXIgZ2V0V2luZG93TmFtZXMgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJGdldE93blByb3BlcnR5TmFtZXMoaXQpOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcnJheVNsaWNlKHdpbmRvd05hbWVzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMuZiA9IGZ1bmN0aW9uIGdldE93blByb3BlcnR5TmFtZXMoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gd2luZG93TmFtZXMgJiYgY2xhc3NvZihpdCkgPT0gJ1dpbmRvdycgPyBnZXRXaW5kb3dOYW1lcyhpdCkgOiAkZ2V0T3duUHJvcGVydHlOYW1lcyh0b0luZGV4ZWRPYmplY3QoaXQpKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwNSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHRvQWJzb2x1dGVJbmRleCA9IF9fd19wZGZqc19yZXF1aXJlX18oNjQpOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwNik7CiAgICAgICAgICAgICAgICB2YXIgJEFycmF5ID0gQXJyYXk7CiAgICAgICAgICAgICAgICB2YXIgbWF4ID0gTWF0aC5tYXg7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChPLCBzdGFydCwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGxlbmd0aCA9IGxlbmd0aE9mQXJyYXlMaWtlKE8pOwogICAgICAgICAgICAgICAgICAgIHZhciBrID0gdG9BYnNvbHV0ZUluZGV4KHN0YXJ0LCBsZW5ndGgpOwogICAgICAgICAgICAgICAgICAgIHZhciBmaW4gPSB0b0Fic29sdXRlSW5kZXgoZW5kID09PSB1bmRlZmluZWQgPyBsZW5ndGggOiBlbmQsIGxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIHJlc3VsdCA9ICRBcnJheShtYXgoZmluIC0gaywgMCkpOwogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIG4gPSAwOyBrIDwgZmluOyBrKyssIG4rKykKICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUHJvcGVydHkocmVzdWx0LCBuLCBPW2tdKTsKICAgICAgICAgICAgICAgICAgICByZXN1bHQubGVuZ3RoID0gbjsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTA2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIHRvUHJvcGVydHlLZXkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIxKTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eU1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDgpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZVByb3BlcnR5RGVzY3JpcHRvciA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAob2JqZWN0LCBrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHByb3BlcnR5S2V5ID0gdG9Qcm9wZXJ0eUtleShrZXkpOwogICAgICAgICAgICAgICAgICAgIGlmIChwcm9wZXJ0eUtleSBpbiBvYmplY3QpCiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5TW9kdWxlLmYob2JqZWN0LCBwcm9wZXJ0eUtleSwgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yKDAsIHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICBvYmplY3RbcHJvcGVydHlLZXldID0gdmFsdWU7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMDcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oMTgpOwogICAgICAgICAgICAgICAgdmFyIEFSUkFZX0JVRkZFUl9OT05fRVhURU5TSUJMRSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTA4KTsKICAgICAgICAgICAgICAgIHZhciAkaXNFeHRlbnNpYmxlID0gT2JqZWN0LmlzRXh0ZW5zaWJsZTsKICAgICAgICAgICAgICAgIHZhciBGQUlMU19PTl9QUklNSVRJVkVTID0gZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICRpc0V4dGVuc2libGUoMSk7CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gRkFJTFNfT05fUFJJTUlUSVZFUyB8fCBBUlJBWV9CVUZGRVJfTk9OX0VYVEVOU0lCTEUgPyBmdW5jdGlvbiBpc0V4dGVuc2libGUoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIGlmIChBUlJBWV9CVUZGRVJfTk9OX0VYVEVOU0lCTEUgJiYgY2xhc3NvZihpdCkgPT0gJ0FycmF5QnVmZmVyJykKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiAkaXNFeHRlbnNpYmxlID8gJGlzRXh0ZW5zaWJsZShpdCkgOiB0cnVlOwogICAgICAgICAgICAgICAgfSA6ICRpc0V4dGVuc2libGU7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIEFycmF5QnVmZmVyID09ICdmdW5jdGlvbicpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGJ1ZmZlciA9IG5ldyBBcnJheUJ1ZmZlcig4KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKE9iamVjdC5pc0V4dGVuc2libGUoYnVmZmVyKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShidWZmZXIsICdhJywgeyB2YWx1ZTogOCB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTA5ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmlzRXh0ZW5zaWJsZShPYmplY3QucHJldmVudEV4dGVuc2lvbnMoe30pKTsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTAgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBiaW5kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTEpOwogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExKTsKICAgICAgICAgICAgICAgIHZhciBhbk9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNTApOwogICAgICAgICAgICAgICAgdmFyIHRyeVRvU3RyaW5nID0gX193X3BkZmpzX3JlcXVpcmVfXygzNSk7CiAgICAgICAgICAgICAgICB2YXIgaXNBcnJheUl0ZXJhdG9yTWV0aG9kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTMpOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgaXNQcm90b3R5cGVPZiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjgpOwogICAgICAgICAgICAgICAgdmFyIGdldEl0ZXJhdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTQpOwogICAgICAgICAgICAgICAgdmFyIGdldEl0ZXJhdG9yTWV0aG9kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTUpOwogICAgICAgICAgICAgICAgdmFyIGl0ZXJhdG9yQ2xvc2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExNik7CiAgICAgICAgICAgICAgICB2YXIgJFR5cGVFcnJvciA9IFR5cGVFcnJvcjsKICAgICAgICAgICAgICAgIHZhciBSZXN1bHQgPSBmdW5jdGlvbiAoc3RvcHBlZCwgcmVzdWx0KSB7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5zdG9wcGVkID0gc3RvcHBlZDsKICAgICAgICAgICAgICAgICAgICB0aGlzLnJlc3VsdCA9IHJlc3VsdDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgUmVzdWx0UHJvdG90eXBlID0gUmVzdWx0LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0ZXJhYmxlLCB1bmJvdW5kRnVuY3Rpb24sIG9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgdGhhdCA9IG9wdGlvbnMgJiYgb3B0aW9ucy50aGF0OwogICAgICAgICAgICAgICAgICAgIHZhciBBU19FTlRSSUVTID0gISEob3B0aW9ucyAmJiBvcHRpb25zLkFTX0VOVFJJRVMpOwogICAgICAgICAgICAgICAgICAgIHZhciBJU19SRUNPUkQgPSAhIShvcHRpb25zICYmIG9wdGlvbnMuSVNfUkVDT1JEKTsKICAgICAgICAgICAgICAgICAgICB2YXIgSVNfSVRFUkFUT1IgPSAhIShvcHRpb25zICYmIG9wdGlvbnMuSVNfSVRFUkFUT1IpOwogICAgICAgICAgICAgICAgICAgIHZhciBJTlRFUlJVUFRFRCA9ICEhKG9wdGlvbnMgJiYgb3B0aW9ucy5JTlRFUlJVUFRFRCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGZuID0gYmluZCh1bmJvdW5kRnVuY3Rpb24sIHRoYXQpOwogICAgICAgICAgICAgICAgICAgIHZhciBpdGVyYXRvciwgaXRlckZuLCBpbmRleCwgbGVuZ3RoLCByZXN1bHQsIG5leHQsIHN0ZXA7CiAgICAgICAgICAgICAgICAgICAgdmFyIHN0b3AgPSBmdW5jdGlvbiAoY29uZGl0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpdGVyYXRvcikKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZXJhdG9yQ2xvc2UoaXRlcmF0b3IsICdub3JtYWwnLCBjb25kaXRpb24pOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFJlc3VsdCh0cnVlLCBjb25kaXRpb24pOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgdmFyIGNhbGxGbiA9IGZ1bmN0aW9uICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoQVNfRU5UUklFUykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5PYmplY3QodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOVEVSUlVQVEVEID8gZm4odmFsdWVbMF0sIHZhbHVlWzFdLCBzdG9wKSA6IGZuKHZhbHVlWzBdLCB2YWx1ZVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOVEVSUlVQVEVEID8gZm4odmFsdWUsIHN0b3ApIDogZm4odmFsdWUpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgaWYgKElTX1JFQ09SRCkgewogICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRvciA9IGl0ZXJhYmxlLml0ZXJhdG9yOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoSVNfSVRFUkFUT1IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaXRlcmF0b3IgPSBpdGVyYWJsZTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBpdGVyRm4gPSBnZXRJdGVyYXRvck1ldGhvZChpdGVyYWJsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXRlckZuKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcih0cnlUb1N0cmluZyhpdGVyYWJsZSkgKyAnIGlzIG5vdCBpdGVyYWJsZScpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNBcnJheUl0ZXJhdG9yTWV0aG9kKGl0ZXJGbikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaW5kZXggPSAwLCBsZW5ndGggPSBsZW5ndGhPZkFycmF5TGlrZShpdGVyYWJsZSk7IGxlbmd0aCA+IGluZGV4OyBpbmRleCsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gY2FsbEZuKGl0ZXJhYmxlW2luZGV4XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdCAmJiBpc1Byb3RvdHlwZU9mKFJlc3VsdFByb3RvdHlwZSwgcmVzdWx0KSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUmVzdWx0KGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRvciA9IGdldEl0ZXJhdG9yKGl0ZXJhYmxlLCBpdGVyRm4pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBuZXh0ID0gSVNfUkVDT1JEID8gaXRlcmFibGUubmV4dCA6IGl0ZXJhdG9yLm5leHQ7CiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKCEoc3RlcCA9IGNhbGwobmV4dCwgaXRlcmF0b3IpKS5kb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBjYWxsRm4oc3RlcC52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRvckNsb3NlKGl0ZXJhdG9yLCAndGhyb3cnLCBlcnJvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZXN1bHQgPT0gJ29iamVjdCcgJiYgcmVzdWx0ICYmIGlzUHJvdG90eXBlT2YoUmVzdWx0UHJvdG90eXBlLCByZXN1bHQpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBSZXN1bHQoZmFsc2UpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTExICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgdW5jdXJyeVRoaXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExMik7CiAgICAgICAgICAgICAgICB2YXIgYUNhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygzNCk7CiAgICAgICAgICAgICAgICB2YXIgTkFUSVZFX0JJTkQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyKTsKICAgICAgICAgICAgICAgIHZhciBiaW5kID0gdW5jdXJyeVRoaXModW5jdXJyeVRoaXMuYmluZCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChmbiwgdGhhdCkgewogICAgICAgICAgICAgICAgICAgIGFDYWxsYWJsZShmbik7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoYXQgPT09IHVuZGVmaW5lZCA/IGZuIDogTkFUSVZFX0JJTkQgPyBiaW5kKGZuLCB0aGF0KSA6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZuLmFwcGx5KHRoYXQsIGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExMiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGNsYXNzb2ZSYXcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE4KTsKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoZm4pIHsKICAgICAgICAgICAgICAgICAgICBpZiAoY2xhc3NvZlJhdyhmbikgPT09ICdGdW5jdGlvbicpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1bmN1cnJ5VGhpcyhmbik7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTMgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciBJdGVyYXRvcnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkyKTsKICAgICAgICAgICAgICAgIHZhciBJVEVSQVRPUiA9IHdlbGxLbm93blN5bWJvbCgnaXRlcmF0b3InKTsKICAgICAgICAgICAgICAgIHZhciBBcnJheVByb3RvdHlwZSA9IEFycmF5LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ICE9PSB1bmRlZmluZWQgJiYgKEl0ZXJhdG9ycy5BcnJheSA9PT0gaXQgfHwgQXJyYXlQcm90b3R5cGVbSVRFUkFUT1JdID09PSBpdCk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTQgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjYWxsID0gX193X3BkZmpzX3JlcXVpcmVfXygxMSk7CiAgICAgICAgICAgICAgICB2YXIgYUNhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygzNCk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciB0cnlUb1N0cmluZyA9IF9fd19wZGZqc19yZXF1aXJlX18oMzUpOwogICAgICAgICAgICAgICAgdmFyIGdldEl0ZXJhdG9yTWV0aG9kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTUpOwogICAgICAgICAgICAgICAgdmFyICRUeXBlRXJyb3IgPSBUeXBlRXJyb3I7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChhcmd1bWVudCwgdXNpbmdJdGVyYXRvcikgewogICAgICAgICAgICAgICAgICAgIHZhciBpdGVyYXRvck1ldGhvZCA9IGFyZ3VtZW50cy5sZW5ndGggPCAyID8gZ2V0SXRlcmF0b3JNZXRob2QoYXJndW1lbnQpIDogdXNpbmdJdGVyYXRvcjsKICAgICAgICAgICAgICAgICAgICBpZiAoYUNhbGxhYmxlKGl0ZXJhdG9yTWV0aG9kKSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFuT2JqZWN0KGNhbGwoaXRlcmF0b3JNZXRob2QsIGFyZ3VtZW50KSk7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcih0cnlUb1N0cmluZyhhcmd1bWVudCkgKyAnIGlzIG5vdCBpdGVyYWJsZScpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTE1ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODIpOwogICAgICAgICAgICAgICAgdmFyIGdldE1ldGhvZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzMpOwogICAgICAgICAgICAgICAgdmFyIGlzTnVsbE9yVW5kZWZpbmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygyMCk7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JzID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Mik7CiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgSVRFUkFUT1IgPSB3ZWxsS25vd25TeW1ib2woJ2l0ZXJhdG9yJyk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIGlmICghaXNOdWxsT3JVbmRlZmluZWQoaXQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZ2V0TWV0aG9kKGl0LCBJVEVSQVRPUikgfHwgZ2V0TWV0aG9kKGl0LCAnQEBpdGVyYXRvcicpIHx8IEl0ZXJhdG9yc1tjbGFzc29mKGl0KV07CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjYWxsID0gX193X3BkZmpzX3JlcXVpcmVfXygxMSk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciBnZXRNZXRob2QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDMzKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0ZXJhdG9yLCBraW5kLCB2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHZhciBpbm5lclJlc3VsdCwgaW5uZXJFcnJvcjsKICAgICAgICAgICAgICAgICAgICBhbk9iamVjdChpdGVyYXRvcik7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJSZXN1bHQgPSBnZXRNZXRob2QoaXRlcmF0b3IsICdyZXR1cm4nKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpbm5lclJlc3VsdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGtpbmQgPT09ICd0aHJvdycpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJSZXN1bHQgPSBjYWxsKGlubmVyUmVzdWx0LCBpdGVyYXRvcik7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJFcnJvciA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlubmVyUmVzdWx0ID0gZXJyb3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09PSAndGhyb3cnKQogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICBpZiAoaW5uZXJFcnJvcikKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgaW5uZXJSZXN1bHQ7CiAgICAgICAgICAgICAgICAgICAgYW5PYmplY3QoaW5uZXJSZXN1bHQpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExNyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGlzUHJvdG90eXBlT2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI4KTsKICAgICAgICAgICAgICAgIHZhciAkVHlwZUVycm9yID0gVHlwZUVycm9yOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQsIFByb3RvdHlwZSkgewogICAgICAgICAgICAgICAgICAgIGlmIChpc1Byb3RvdHlwZU9mKFByb3RvdHlwZSwgaXQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXQ7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcignSW5jb3JyZWN0IGludm9jYXRpb24nKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHdlbGxLbm93blN5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzcpOwogICAgICAgICAgICAgICAgdmFyIElURVJBVE9SID0gd2VsbEtub3duU3ltYm9sKCdpdGVyYXRvcicpOwogICAgICAgICAgICAgICAgdmFyIFNBRkVfQ0xPU0lORyA9IGZhbHNlOwogICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICB2YXIgY2FsbGVkID0gMDsKICAgICAgICAgICAgICAgICAgICB2YXIgaXRlcmF0b3JXaXRoUmV0dXJuID0gewogICAgICAgICAgICAgICAgICAgICAgICBuZXh0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4geyBkb25lOiAhIWNhbGxlZCsrIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICdyZXR1cm4nOiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBTQUZFX0NMT1NJTkcgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBpdGVyYXRvcldpdGhSZXR1cm5bSVRFUkFUT1JdID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIEFycmF5LmZyb20oaXRlcmF0b3JXaXRoUmV0dXJuLCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IDI7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoZXhlYywgU0tJUF9DTE9TSU5HKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFTS0lQX0NMT1NJTkcgJiYgIVNBRkVfQ0xPU0lORykKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBJVEVSQVRJT05fU1VQUE9SVCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBvYmplY3QgPSB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgb2JqZWN0W0lURVJBVE9SXSA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV4dDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4geyBkb25lOiBJVEVSQVRJT05fU1VQUE9SVCA9IHRydWUgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBleGVjKG9iamVjdCk7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElURVJBVElPTl9TVVBQT1JUOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTE5ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgc2V0UHJvdG90eXBlT2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg3KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKCR0aGlzLCBkdW1teSwgV3JhcHBlcikgewogICAgICAgICAgICAgICAgICAgIHZhciBOZXdUYXJnZXQsIE5ld1RhcmdldFByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICBpZiAoc2V0UHJvdG90eXBlT2YgJiYgaXNDYWxsYWJsZShOZXdUYXJnZXQgPSBkdW1teS5jb25zdHJ1Y3RvcikgJiYgTmV3VGFyZ2V0ICE9PSBXcmFwcGVyICYmIGlzT2JqZWN0KE5ld1RhcmdldFByb3RvdHlwZSA9IE5ld1RhcmdldC5wcm90b3R5cGUpICYmIE5ld1RhcmdldFByb3RvdHlwZSAhPT0gV3JhcHBlci5wcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgIHNldFByb3RvdHlwZU9mKCR0aGlzLCBOZXdUYXJnZXRQcm90b3R5cGUpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiAkdGhpczsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyMCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBjcmVhdGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDczKTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluQWNjZXNzb3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg0KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdElucyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTIxKTsKICAgICAgICAgICAgICAgIHZhciBiaW5kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTEpOwogICAgICAgICAgICAgICAgdmFyIGFuSW5zdGFuY2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExNyk7CiAgICAgICAgICAgICAgICB2YXIgaXNOdWxsT3JVbmRlZmluZWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIwKTsKICAgICAgICAgICAgICAgIHZhciBpdGVyYXRlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTApOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZUl0ZXJhdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Myk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlSXRlclJlc3VsdE9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oOTcpOwogICAgICAgICAgICAgICAgdmFyIHNldFNwZWNpZXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyMik7CiAgICAgICAgICAgICAgICB2YXIgREVTQ1JJUFRPUlMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkpOwogICAgICAgICAgICAgICAgdmFyIGZhc3RLZXkgPSAoX193X3BkZmpzX3JlcXVpcmVfXygxMDMpLmZhc3RLZXkpOwogICAgICAgICAgICAgICAgdmFyIEludGVybmFsU3RhdGVNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDU1KTsKICAgICAgICAgICAgICAgIHZhciBzZXRJbnRlcm5hbFN0YXRlID0gSW50ZXJuYWxTdGF0ZU1vZHVsZS5zZXQ7CiAgICAgICAgICAgICAgICB2YXIgaW50ZXJuYWxTdGF0ZUdldHRlckZvciA9IEludGVybmFsU3RhdGVNb2R1bGUuZ2V0dGVyRm9yOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgZ2V0Q29uc3RydWN0b3I6IGZ1bmN0aW9uICh3cmFwcGVyLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVAsIEFEREVSKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBDb25zdHJ1Y3RvciA9IHdyYXBwZXIoZnVuY3Rpb24gKHRoYXQsIGl0ZXJhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbkluc3RhbmNlKHRoYXQsIFByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJbnRlcm5hbFN0YXRlKHRoYXQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBDT05TVFJVQ1RPUl9OQU1FLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4OiBjcmVhdGUobnVsbCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3Q6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXN0OiB1bmRlZmluZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZTogMAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIURFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQuc2l6ZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzTnVsbE9yVW5kZWZpbmVkKGl0ZXJhYmxlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRlKGl0ZXJhYmxlLCB0aGF0W0FEREVSXSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGF0OiB0aGF0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBU19FTlRSSUVTOiBJU19NQVAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBQcm90b3R5cGUgPSBDb25zdHJ1Y3Rvci5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbFN0YXRlID0gaW50ZXJuYWxTdGF0ZUdldHRlckZvcihDT05TVFJVQ1RPUl9OQU1FKTsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGRlZmluZSA9IGZ1bmN0aW9uICh0aGF0LCBrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBnZXRJbnRlcm5hbFN0YXRlKHRoYXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVudHJ5ID0gZ2V0RW50cnkodGhhdCwga2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwcmV2aW91cywgaW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW50cnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeS52YWx1ZSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5sYXN0ID0gZW50cnkgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4OiBpbmRleCA9IGZhc3RLZXkoa2V5LCB0cnVlKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5OiBrZXksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldmlvdXM6IHByZXZpb3VzID0gc3RhdGUubGFzdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV4dDogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW1vdmVkOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzdGF0ZS5maXJzdCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUuZmlyc3QgPSBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJldmlvdXMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXZpb3VzLm5leHQgPSBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoREVTQ1JJUFRPUlMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLnNpemUrKzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQuc2l6ZSsrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCAhPT0gJ0YnKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5pbmRleFtpbmRleF0gPSBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGF0OwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgZ2V0RW50cnkgPSBmdW5jdGlvbiAodGhhdCwga2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBnZXRJbnRlcm5hbFN0YXRlKHRoYXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGluZGV4ID0gZmFzdEtleShrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVudHJ5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGluZGV4ICE9PSAnRicpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN0YXRlLmluZGV4W2luZGV4XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoZW50cnkgPSBzdGF0ZS5maXJzdDsgZW50cnk7IGVudHJ5ID0gZW50cnkubmV4dCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbnRyeS5rZXkgPT0ga2V5KQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZW50cnk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW5zKFByb3RvdHlwZSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXI6IGZ1bmN0aW9uIGNsZWFyKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0aGF0ID0gdGhpczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBnZXRJbnRlcm5hbFN0YXRlKHRoYXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBkYXRhID0gc3RhdGUuaW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVudHJ5ID0gc3RhdGUuZmlyc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGVudHJ5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LnJlbW92ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW50cnkucHJldmlvdXMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeS5wcmV2aW91cyA9IGVudHJ5LnByZXZpb3VzLm5leHQgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBkYXRhW2VudHJ5LmluZGV4XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnkgPSBlbnRyeS5uZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5maXJzdCA9IHN0YXRlLmxhc3QgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5zaXplID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQuc2l6ZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgJ2RlbGV0ZSc6IGZ1bmN0aW9uIChrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGhhdCA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHN0YXRlID0gZ2V0SW50ZXJuYWxTdGF0ZSh0aGF0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgZW50cnkgPSBnZXRFbnRyeSh0aGF0LCBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbnRyeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgbmV4dCA9IGVudHJ5Lm5leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwcmV2ID0gZW50cnkucHJldmlvdXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBzdGF0ZS5pbmRleFtlbnRyeS5pbmRleF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LnJlbW92ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJldikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXYubmV4dCA9IG5leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXh0KQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV4dC5wcmV2aW91cyA9IHByZXY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5maXJzdCA9PSBlbnRyeSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLmZpcnN0ID0gbmV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlLmxhc3QgPT0gZW50cnkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5sYXN0ID0gcHJldjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUuc2l6ZS0tOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGF0LnNpemUtLTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICEhZW50cnk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yRWFjaDogZnVuY3Rpb24gZm9yRWFjaChjYWxsYmFja2ZuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHN0YXRlID0gZ2V0SW50ZXJuYWxTdGF0ZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgYm91bmRGdW5jdGlvbiA9IGJpbmQoY2FsbGJhY2tmbiwgYXJndW1lbnRzLmxlbmd0aCA+IDEgPyBhcmd1bWVudHNbMV0gOiB1bmRlZmluZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoZW50cnkgPSBlbnRyeSA/IGVudHJ5Lm5leHQgOiBzdGF0ZS5maXJzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib3VuZEZ1bmN0aW9uKGVudHJ5LnZhbHVlLCBlbnRyeS5rZXksIHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoZW50cnkgJiYgZW50cnkucmVtb3ZlZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5ID0gZW50cnkucHJldmlvdXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhczogZnVuY3Rpb24gaGFzKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhIWdldEVudHJ5KHRoaXMsIGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdElucyhQcm90b3R5cGUsIElTX01BUCA/IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gZ2V0KGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlbnRyeSA9IGdldEVudHJ5KHRoaXMsIGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGVudHJ5ICYmIGVudHJ5LnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24gc2V0KGtleSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZGVmaW5lKHRoaXMsIGtleSA9PT0gMCA/IDAgOiBrZXksIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSA6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFkZDogZnVuY3Rpb24gYWRkKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmluZSh0aGlzLCB2YWx1ZSA9IHZhbHVlID09PSAwID8gMCA6IHZhbHVlLCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoREVTQ1JJUFRPUlMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluQWNjZXNzb3IoUHJvdG90eXBlLCAnc2l6ZScsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBnZXRJbnRlcm5hbFN0YXRlKHRoaXMpLnNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBDb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgIHNldFN0cm9uZzogZnVuY3Rpb24gKENvbnN0cnVjdG9yLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVApIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIElURVJBVE9SX05BTUUgPSBDT05TVFJVQ1RPUl9OQU1FICsgJyBJdGVyYXRvcic7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbENvbGxlY3Rpb25TdGF0ZSA9IGludGVybmFsU3RhdGVHZXR0ZXJGb3IoQ09OU1RSVUNUT1JfTkFNRSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbEl0ZXJhdG9yU3RhdGUgPSBpbnRlcm5hbFN0YXRlR2V0dGVyRm9yKElURVJBVE9SX05BTUUpOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVJdGVyYXRvcihDb25zdHJ1Y3RvciwgQ09OU1RSVUNUT1JfTkFNRSwgZnVuY3Rpb24gKGl0ZXJhdGVkLCBraW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJbnRlcm5hbFN0YXRlKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBJVEVSQVRPUl9OQU1FLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldDogaXRlcmF0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGU6IGdldEludGVybmFsQ29sbGVjdGlvblN0YXRlKGl0ZXJhdGVkKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBraW5kOiBraW5kLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxhc3Q6IHVuZGVmaW5lZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBzdGF0ZSA9IGdldEludGVybmFsSXRlcmF0b3JTdGF0ZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBraW5kID0gc3RhdGUua2luZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlbnRyeSA9IHN0YXRlLmxhc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoZW50cnkgJiYgZW50cnkucmVtb3ZlZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeSA9IGVudHJ5LnByZXZpb3VzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzdGF0ZS50YXJnZXQgfHwgIShzdGF0ZS5sYXN0ID0gZW50cnkgPSBlbnRyeSA/IGVudHJ5Lm5leHQgOiBzdGF0ZS5zdGF0ZS5maXJzdCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS50YXJnZXQgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNyZWF0ZUl0ZXJSZXN1bHRPYmplY3QodW5kZWZpbmVkLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09ICdrZXlzJykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlSXRlclJlc3VsdE9iamVjdChlbnRyeS5rZXksIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09ICd2YWx1ZXMnKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjcmVhdGVJdGVyUmVzdWx0T2JqZWN0KGVudHJ5LnZhbHVlLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlSXRlclJlc3VsdE9iamVjdChbCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnkua2V5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LnZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBdLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIElTX01BUCA/ICdlbnRyaWVzJyA6ICd2YWx1ZXMnLCAhSVNfTUFQLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0U3BlY2llcyhDT05TVFJVQ1RPUl9OQU1FKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjEgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MSk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uICh0YXJnZXQsIHNyYywgb3B0aW9ucykgewogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGtleSBpbiBzcmMpCiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4odGFyZ2V0LCBrZXksIHNyY1trZXldLCBvcHRpb25zKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGFyZ2V0OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTIyICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIGdldEJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI3KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluQWNjZXNzb3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg0KTsKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgU1BFQ0lFUyA9IHdlbGxLbm93blN5bWJvbCgnc3BlY2llcycpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoQ09OU1RSVUNUT1JfTkFNRSkgewogICAgICAgICAgICAgICAgICAgIHZhciBDb25zdHJ1Y3RvciA9IGdldEJ1aWx0SW4oQ09OU1RSVUNUT1JfTkFNRSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKERFU0NSSVBUT1JTICYmIENvbnN0cnVjdG9yICYmICFDb25zdHJ1Y3RvcltTUEVDSUVTXSkgewogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluQWNjZXNzb3IoQ29uc3RydWN0b3IsIFNQRUNJRVMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjMgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXygxMjQpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjQgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBjb2xsZWN0aW9uID0gX193X3BkZmpzX3JlcXVpcmVfXygxMDIpOwogICAgICAgICAgICAgICAgdmFyIGNvbGxlY3Rpb25TdHJvbmcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyMCk7CiAgICAgICAgICAgICAgICBjb2xsZWN0aW9uKCdTZXQnLCBmdW5jdGlvbiAoaW5pdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBTZXQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpbml0KHRoaXMsIGFyZ3VtZW50cy5sZW5ndGggPyBhcmd1bWVudHNbMF0gOiB1bmRlZmluZWQpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9LCBjb2xsZWN0aW9uU3Ryb25nKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTI1ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBJU19QVVJFID0gX193X3BkZmpzX3JlcXVpcmVfXygzOSk7CiAgICAgICAgICAgICAgICB2YXIgJCA9IF9fd19wZGZqc19yZXF1aXJlX18oNik7CiAgICAgICAgICAgICAgICB2YXIgZ2xvYmFsID0gX193X3BkZmpzX3JlcXVpcmVfXyg3KTsKICAgICAgICAgICAgICAgIHZhciBnZXRCdWlsdGluID0gX193X3BkZmpzX3JlcXVpcmVfXygyNyk7CiAgICAgICAgICAgICAgICB2YXIgdW5jdXJyeVRoaXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE3KTsKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgdmFyIHVpZCA9IF9fd19wZGZqc19yZXF1aXJlX18oNDQpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc0NvbnN0cnVjdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxMjYpOwogICAgICAgICAgICAgICAgdmFyIGlzTnVsbE9yVW5kZWZpbmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygyMCk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBpc1N5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjYpOwogICAgICAgICAgICAgICAgdmFyIGl0ZXJhdGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExMCk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciBjbGFzc29mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Mik7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwNik7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlTm9uRW51bWVyYWJsZVByb3BlcnR5ID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Nyk7CiAgICAgICAgICAgICAgICB2YXIgbGVuZ3RoT2ZBcnJheUxpa2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDY3KTsKICAgICAgICAgICAgICAgIHZhciB2YWxpZGF0ZUFyZ3VtZW50c0xlbmd0aCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTI3KTsKICAgICAgICAgICAgICAgIHZhciBnZXRSZWdFeHBGbGFncyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTI4KTsKICAgICAgICAgICAgICAgIHZhciBNYXBIZWxwZXJzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMzApOwogICAgICAgICAgICAgICAgdmFyIFNldEhlbHBlcnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzMSk7CiAgICAgICAgICAgICAgICB2YXIgRVJST1JfU1RBQ0tfSU5TVEFMTEFCTEUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzMik7CiAgICAgICAgICAgICAgICB2YXIgUFJPUEVSX1RSQU5TRkVSID0gX193X3BkZmpzX3JlcXVpcmVfXygxMzMpOwogICAgICAgICAgICAgICAgdmFyIE9iamVjdCA9IGdsb2JhbC5PYmplY3Q7CiAgICAgICAgICAgICAgICB2YXIgQXJyYXkgPSBnbG9iYWwuQXJyYXk7CiAgICAgICAgICAgICAgICB2YXIgRGF0ZSA9IGdsb2JhbC5EYXRlOwogICAgICAgICAgICAgICAgdmFyIEVycm9yID0gZ2xvYmFsLkVycm9yOwogICAgICAgICAgICAgICAgdmFyIEV2YWxFcnJvciA9IGdsb2JhbC5FdmFsRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgUmFuZ2VFcnJvciA9IGdsb2JhbC5SYW5nZUVycm9yOwogICAgICAgICAgICAgICAgdmFyIFJlZmVyZW5jZUVycm9yID0gZ2xvYmFsLlJlZmVyZW5jZUVycm9yOwogICAgICAgICAgICAgICAgdmFyIFN5bnRheEVycm9yID0gZ2xvYmFsLlN5bnRheEVycm9yOwogICAgICAgICAgICAgICAgdmFyIFR5cGVFcnJvciA9IGdsb2JhbC5UeXBlRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgVVJJRXJyb3IgPSBnbG9iYWwuVVJJRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgUGVyZm9ybWFuY2VNYXJrID0gZ2xvYmFsLlBlcmZvcm1hbmNlTWFyazsKICAgICAgICAgICAgICAgIHZhciBXZWJBc3NlbWJseSA9IGdsb2JhbC5XZWJBc3NlbWJseTsKICAgICAgICAgICAgICAgIHZhciBDb21waWxlRXJyb3IgPSBXZWJBc3NlbWJseSAmJiBXZWJBc3NlbWJseS5Db21waWxlRXJyb3IgfHwgRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgTGlua0Vycm9yID0gV2ViQXNzZW1ibHkgJiYgV2ViQXNzZW1ibHkuTGlua0Vycm9yIHx8IEVycm9yOwogICAgICAgICAgICAgICAgdmFyIFJ1bnRpbWVFcnJvciA9IFdlYkFzc2VtYmx5ICYmIFdlYkFzc2VtYmx5LlJ1bnRpbWVFcnJvciB8fCBFcnJvcjsKICAgICAgICAgICAgICAgIHZhciBET01FeGNlcHRpb24gPSBnZXRCdWlsdGluKCdET01FeGNlcHRpb24nKTsKICAgICAgICAgICAgICAgIHZhciBNYXAgPSBNYXBIZWxwZXJzLk1hcDsKICAgICAgICAgICAgICAgIHZhciBtYXBIYXMgPSBNYXBIZWxwZXJzLmhhczsKICAgICAgICAgICAgICAgIHZhciBtYXBHZXQgPSBNYXBIZWxwZXJzLmdldDsKICAgICAgICAgICAgICAgIHZhciBtYXBTZXQgPSBNYXBIZWxwZXJzLnNldDsKICAgICAgICAgICAgICAgIHZhciBTZXQgPSBTZXRIZWxwZXJzLlNldDsKICAgICAgICAgICAgICAgIHZhciBzZXRBZGQgPSBTZXRIZWxwZXJzLmFkZDsKICAgICAgICAgICAgICAgIHZhciBvYmplY3RLZXlzID0gZ2V0QnVpbHRpbignT2JqZWN0JywgJ2tleXMnKTsKICAgICAgICAgICAgICAgIHZhciBwdXNoID0gdW5jdXJyeVRoaXMoW10ucHVzaCk7CiAgICAgICAgICAgICAgICB2YXIgdGhpc0Jvb2xlYW5WYWx1ZSA9IHVuY3VycnlUaGlzKHRydWUudmFsdWVPZik7CiAgICAgICAgICAgICAgICB2YXIgdGhpc051bWJlclZhbHVlID0gdW5jdXJyeVRoaXMoMS4wLnZhbHVlT2YpOwogICAgICAgICAgICAgICAgdmFyIHRoaXNTdHJpbmdWYWx1ZSA9IHVuY3VycnlUaGlzKCcnLnZhbHVlT2YpOwogICAgICAgICAgICAgICAgdmFyIHRoaXNUaW1lVmFsdWUgPSB1bmN1cnJ5VGhpcyhEYXRlLnByb3RvdHlwZS5nZXRUaW1lKTsKICAgICAgICAgICAgICAgIHZhciBQRVJGT1JNQU5DRV9NQVJLID0gdWlkKCdzdHJ1Y3R1cmVkQ2xvbmUnKTsKICAgICAgICAgICAgICAgIHZhciBEQVRBX0NMT05FX0VSUk9SID0gJ0RhdGFDbG9uZUVycm9yJzsKICAgICAgICAgICAgICAgIHZhciBUUkFOU0ZFUlJJTkcgPSAnVHJhbnNmZXJyaW5nJzsKICAgICAgICAgICAgICAgIHZhciBjaGVja0Jhc2ljU2VtYW50aWMgPSBmdW5jdGlvbiAoc3RydWN0dXJlZENsb25lSW1wbGVtZW50YXRpb24pIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHNldDEgPSBuZXcgZ2xvYmFsLlNldChbN10pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgc2V0MiA9IHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uKHNldDEpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgbnVtYmVyID0gc3RydWN0dXJlZENsb25lSW1wbGVtZW50YXRpb24oT2JqZWN0KDcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNldDIgPT0gc2V0MSB8fCAhc2V0Mi5oYXMoNykgfHwgdHlwZW9mIG51bWJlciAhPSAnb2JqZWN0JyB8fCBudW1iZXIgIT0gNzsKICAgICAgICAgICAgICAgICAgICB9KSAmJiBzdHJ1Y3R1cmVkQ2xvbmVJbXBsZW1lbnRhdGlvbjsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgY2hlY2tFcnJvcnNDbG9uaW5nID0gZnVuY3Rpb24gKHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uLCAkRXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVycm9yID0gbmV3ICRFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGE6IGVycm9yLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYjogZXJyb3IKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhKHRlc3QgJiYgdGVzdC5hID09PSB0ZXN0LmIgJiYgdGVzdC5hIGluc3RhbmNlb2YgJEVycm9yICYmIHRlc3QuYS5zdGFjayA9PT0gZXJyb3Iuc3RhY2spOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBjaGVja05ld0Vycm9yc0Nsb25pbmdTZW1hbnRpYyA9IGZ1bmN0aW9uIChzdHJ1Y3R1cmVkQ2xvbmVJbXBsZW1lbnRhdGlvbikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uKG5ldyBnbG9iYWwuQWdncmVnYXRlRXJyb3IoWzFdLCBQRVJGT1JNQU5DRV9NQVJLLCB7IGNhdXNlOiAzIH0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRlc3QubmFtZSAhPSAnQWdncmVnYXRlRXJyb3InIHx8IHRlc3QuZXJyb3JzWzBdICE9IDEgfHwgdGVzdC5tZXNzYWdlICE9IFBFUkZPUk1BTkNFX01BUksgfHwgdGVzdC5jYXVzZSAhPSAzOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBuYXRpdmVTdHJ1Y3R1cmVkQ2xvbmUgPSBnbG9iYWwuc3RydWN0dXJlZENsb25lOwogICAgICAgICAgICAgICAgdmFyIEZPUkNFRF9SRVBMQUNFTUVOVCA9IElTX1BVUkUgfHwgIWNoZWNrRXJyb3JzQ2xvbmluZyhuYXRpdmVTdHJ1Y3R1cmVkQ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dpbmUnLCBEQVRBX0NMT05FX0VSUk9SKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlRGF0YVRyYW5zZmVyID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciBkYXRhVHJhbnNmZXI7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyID0gbmV3IGdsb2JhbC5EYXRhVHJhbnNmZXIoKTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyID0gbmV3IGdsb2JhbC5DbGlwYm9hcmRFdmVudCgnJykuY2xpcGJvYXJkRGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGFUcmFuc2ZlciAmJiBkYXRhVHJhbnNmZXIuaXRlbXMgJiYgZGF0YVRyYW5zZmVyLmZpbGVzID8gZGF0YVRyYW5zZmVyIDogbnVsbDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgc3RydWN0dXJlZENsb25lSW50ZXJuYWwgPSBmdW5jdGlvbiAodmFsdWUsIG1hcCkgewogICAgICAgICAgICAgICAgICAgIGlmIChpc1N5bWJvbCh2YWx1ZSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5jbG9uZWFibGUoJ1N5bWJvbCcpOwogICAgICAgICAgICAgICAgICAgIGlmICghaXNPYmplY3QodmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgaWYgKG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAobWFwSGFzKG1hcCwgdmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hcEdldChtYXAsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgbWFwID0gbmV3IE1hcCgpOwogICAgICAgICAgICAgICAgICAgIHZhciB0eXBlID0gY2xhc3NvZih2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGRlZXAgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB2YXIgQywgbmFtZSwgY2xvbmVkLCBkYXRhVHJhbnNmZXIsIGksIGxlbmd0aCwga2V5cywga2V5LCBzb3VyY2UsIHRhcmdldCwgb3B0aW9uczsKICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gQXJyYXkobGVuZ3RoT2ZBcnJheUxpa2UodmFsdWUpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZXAgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ09iamVjdCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZXAgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ01hcCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWVwID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdTZXQnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmV3IFNldCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVlcCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnUmVnRXhwJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBSZWdFeHAodmFsdWUuc291cmNlLCBnZXRSZWdFeHBGbGFncyh2YWx1ZSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Vycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUgPSB2YWx1ZS5uYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQWdncmVnYXRlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBnZXRCdWlsdGluKCdBZ2dyZWdhdGVFcnJvcicpKFtdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRXZhbEVycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gRXZhbEVycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1JhbmdlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBSYW5nZUVycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1JlZmVyZW5jZUVycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gUmVmZXJlbmNlRXJyb3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnU3ludGF4RXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBTeW50YXhFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdUeXBlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBUeXBlRXJyb3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnVVJJRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBVUklFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdDb21waWxlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBDb21waWxlRXJyb3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnTGlua0Vycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gTGlua0Vycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1J1bnRpbWVFcnJvcic6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IFJ1bnRpbWVFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVlcCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NRXhjZXB0aW9uJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBET01FeGNlcHRpb24odmFsdWUubWVzc2FnZSwgdmFsdWUubmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWVwID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdEYXRhVmlldyc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ludDhBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1VpbnQ4QXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdVaW50OENsYW1wZWRBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ludDE2QXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdVaW50MTZBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ludDMyQXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdVaW50MzJBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Zsb2F0MzJBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Zsb2F0NjRBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0JpZ0ludDY0QXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdCaWdVaW50NjRBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDID0gZ2xvYmFsW3R5cGVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpc09iamVjdChDKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmV3IEMoc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUuYnVmZmVyLCBtYXApLCB2YWx1ZS5ieXRlT2Zmc2V0LCB0eXBlID09PSAnRGF0YVZpZXcnID8gdmFsdWUuYnl0ZUxlbmd0aCA6IHZhbHVlLmxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NUXVhZCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBET01RdWFkKHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLnAxLCBtYXApLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2YWx1ZS5wMiwgbWFwKSwgc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUucDMsIG1hcCksIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLnA0LCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hdGl2ZVJlc3RyaWN0ZWRTdHJ1Y3R1cmVkQ2xvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRmlsZUxpc3QnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyID0gY3JlYXRlRGF0YVRyYW5zZmVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVRyYW5zZmVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMCwgbGVuZ3RoID0gbGVuZ3RoT2ZBcnJheUxpa2UodmFsdWUpOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyLml0ZW1zLmFkZChzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2YWx1ZVtpXSwgbWFwKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IGRhdGFUcmFuc2Zlci5maWxlczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5hdGl2ZVJlc3RyaWN0ZWRTdHJ1Y3R1cmVkQ2xvbmUodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdJbWFnZURhdGEnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBuZXcgSW1hZ2VEYXRhKHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLmRhdGEsIG1hcCksIHZhbHVlLndpZHRoLCB2YWx1ZS5oZWlnaHQsIHsgY29sb3JTcGFjZTogdmFsdWUuY29sb3JTcGFjZSB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hdGl2ZVJlc3RyaWN0ZWRTdHJ1Y3R1cmVkQ2xvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuYXRpdmVSZXN0cmljdGVkU3RydWN0dXJlZENsb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQmlnSW50JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IE9iamVjdCh2YWx1ZS52YWx1ZU9mKCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Jvb2xlYW4nOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gT2JqZWN0KHRoaXNCb29sZWFuVmFsdWUodmFsdWUpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdOdW1iZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gT2JqZWN0KHRoaXNOdW1iZXJWYWx1ZSh2YWx1ZSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1N0cmluZyc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBPYmplY3QodGhpc1N0cmluZ1ZhbHVlKHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRGF0ZSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBuZXcgRGF0ZSh0aGlzVGltZVZhbHVlKHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQXJyYXlCdWZmZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbC5EYXRhVmlldzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghQyAmJiB0eXBlb2YgdmFsdWUuc2xpY2UgIT0gJ2Z1bmN0aW9uJykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlLnNsaWNlID09ICdmdW5jdGlvbicgJiYgIXZhbHVlLnJlc2l6YWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSB2YWx1ZS5zbGljZSgwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGggPSB2YWx1ZS5ieXRlTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25zID0gJ21heEJ5dGVMZW5ndGgnIGluIHZhbHVlID8geyBtYXhCeXRlTGVuZ3RoOiB2YWx1ZS5tYXhCeXRlTGVuZ3RoIH0gOiB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBBcnJheUJ1ZmZlcihsZW5ndGgsIG9wdGlvbnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2UgPSBuZXcgQyh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldCA9IG5ldyBDKGNsb25lZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0LnNldFVpbnQ4KGksIHNvdXJjZS5nZXRVaW50OChpKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oJ0FycmF5QnVmZmVyIGlzIGRldGFjaGVkJywgREFUQV9DTE9ORV9FUlJPUik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnU2hhcmVkQXJyYXlCdWZmZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQmxvYic6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IHZhbHVlLnNsaWNlKDAsIHZhbHVlLnNpemUsIHZhbHVlLnR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0RPTVBvaW50JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NUG9pbnRSZWFkT25seSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDID0gZ2xvYmFsW3R5cGVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBDLmZyb21Qb2ludCA/IEMuZnJvbVBvaW50KHZhbHVlKSA6IG5ldyBDKHZhbHVlLngsIHZhbHVlLnksIHZhbHVlLnosIHZhbHVlLncpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0RPTVJlY3QnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdET01SZWN0UmVhZE9ubHknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbFt0eXBlXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gQy5mcm9tUmVjdCA/IEMuZnJvbVJlY3QodmFsdWUpIDogbmV3IEModmFsdWUueCwgdmFsdWUueSwgdmFsdWUud2lkdGgsIHZhbHVlLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NTWF0cml4JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NTWF0cml4UmVhZE9ubHknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbFt0eXBlXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gQy5mcm9tTWF0cml4ID8gQy5mcm9tTWF0cml4KHZhbHVlKSA6IG5ldyBDKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBdWRpb0RhdGEnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdWaWRlb0ZyYW1lJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNDYWxsYWJsZSh2YWx1ZS5jbG9uZSkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gdmFsdWUuY2xvbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbmNsb25lYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdGaWxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmV3IEZpbGUoW3ZhbHVlXSwgdmFsdWUubmFtZSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Nyb3BUYXJnZXQnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdDcnlwdG9LZXknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdGaWxlU3lzdGVtRGlyZWN0b3J5SGFuZGxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRmlsZVN5c3RlbUZpbGVIYW5kbGUnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdGaWxlU3lzdGVtSGFuZGxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnR1BVQ29tcGlsYXRpb25JbmZvJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnR1BVQ29tcGlsYXRpb25NZXNzYWdlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnSW1hZ2VCaXRtYXAnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdSVENDZXJ0aWZpY2F0ZSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1dlYkFzc2VtYmx5Lk1vZHVsZSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbmNsb25lYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG1hcFNldChtYXAsIHZhbHVlLCBjbG9uZWQpOwogICAgICAgICAgICAgICAgICAgIGlmIChkZWVwKQogICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0FycmF5JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ09iamVjdCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5cyA9IG9iamVjdEtleXModmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDAsIGxlbmd0aCA9IGxlbmd0aE9mQXJyYXlMaWtlKGtleXMpOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5ID0ga2V5c1tpXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUHJvcGVydHkoY2xvbmVkLCBrZXksIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlW2tleV0sIG1hcCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ01hcCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUuZm9yRWFjaChmdW5jdGlvbiAodiwgaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXBTZXQoY2xvbmVkLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbChrLCBtYXApLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2LCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1NldCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUuZm9yRWFjaChmdW5jdGlvbiAodikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRBZGQoY2xvbmVkLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2LCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Vycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkoY2xvbmVkLCAnbWVzc2FnZScsIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLm1lc3NhZ2UsIG1hcCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoYXNPd24odmFsdWUsICdjYXVzZScpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShjbG9uZWQsICdjYXVzZScsIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLmNhdXNlLCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hbWUgPT0gJ0FnZ3JlZ2F0ZUVycm9yJykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQuZXJyb3JzID0gc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUuZXJyb3JzLCBtYXApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0RPTUV4Y2VwdGlvbic6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEVSUk9SX1NUQUNLX0lOU1RBTExBQkxFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShjbG9uZWQsICdzdGFjaycsIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLnN0YWNrLCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xvbmVkOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciB0cnlUb1RyYW5zZmVyID0gZnVuY3Rpb24gKHJhd1RyYW5zZmVyLCBtYXApIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KHJhd1RyYW5zZmVyKSkKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgVHlwZUVycm9yKCdUcmFuc2ZlciBvcHRpb24gY2Fubm90IGJlIGNvbnZlcnRlZCB0byBhIHNlcXVlbmNlJyk7CiAgICAgICAgICAgICAgICAgICAgdmFyIHRyYW5zZmVyID0gW107CiAgICAgICAgICAgICAgICAgICAgaXRlcmF0ZShyYXdUcmFuc2ZlciwgZnVuY3Rpb24gKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHB1c2godHJhbnNmZXIsIGFuT2JqZWN0KHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGkgPSAwOwogICAgICAgICAgICAgICAgICAgIHZhciBsZW5ndGggPSBsZW5ndGhPZkFycmF5TGlrZSh0cmFuc2Zlcik7CiAgICAgICAgICAgICAgICAgICAgdmFyIHZhbHVlLCB0eXBlLCBDLCB0cmFuc2ZlcnJlZEFycmF5LCB0cmFuc2ZlcnJlZCwgY2FudmFzLCBjb250ZXh0OwogICAgICAgICAgICAgICAgICAgIGlmIChQUk9QRVJfVFJBTlNGRVIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmZXJyZWRBcnJheSA9IG5hdGl2ZVN0cnVjdHVyZWRDbG9uZSh0cmFuc2ZlciwgeyB0cmFuc2ZlcjogdHJhbnNmZXIgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChpIDwgbGVuZ3RoKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwU2V0KG1hcCwgdHJhbnNmZXJbaV0sIHRyYW5zZmVycmVkQXJyYXlbaSsrXSk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChpIDwgbGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHRyYW5zZmVyW2krK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobWFwSGFzKG1hcCwgdmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oJ0R1cGxpY2F0ZSB0cmFuc2ZlcmFibGUnLCBEQVRBX0NMT05FX0VSUk9SKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUgPSBjbGFzc29mKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ltYWdlQml0bWFwJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbC5PZmZzY3JlZW5DYW52YXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNDb25zdHJ1Y3RvcihDKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSwgVFJBTlNGRVJSSU5HKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcyA9IG5ldyBDKHZhbHVlLndpZHRoLCB2YWx1ZS5oZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dCA9IGNhbnZhcy5nZXRDb250ZXh0KCdiaXRtYXByZW5kZXJlcicpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dC50cmFuc2ZlckZyb21JbWFnZUJpdG1hcCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2ZlcnJlZCA9IGNhbnZhcy50cmFuc2ZlclRvSW1hZ2VCaXRtYXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBdWRpb0RhdGEnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1ZpZGVvRnJhbWUnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUodmFsdWUuY2xvbmUpIHx8ICFpc0NhbGxhYmxlKHZhbHVlLmNsb3NlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSwgVFJBTlNGRVJSSU5HKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zZmVycmVkID0gdmFsdWUuY2xvbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLmNsb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQXJyYXlCdWZmZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUodmFsdWUudHJhbnNmZXIpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlLCBUUkFOU0ZFUlJJTkcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2ZlcnJlZCA9IHZhbHVlLnRyYW5zZmVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ01lZGlhU291cmNlSGFuZGxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdNZXNzYWdlUG9ydCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnT2Zmc2NyZWVuQ2FudmFzJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdSZWFkYWJsZVN0cmVhbSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnVHJhbnNmb3JtU3RyZWFtJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdXcml0YWJsZVN0cmVhbSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSwgVFJBTlNGRVJSSU5HKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc2ZlcnJlZCA9PT0gdW5kZWZpbmVkKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oJ1RoaXMgb2JqZWN0IGNhbm5vdCBiZSB0cmFuc2ZlcnJlZDogJyArIHR5cGUsIERBVEFfQ0xPTkVfRVJST1IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwU2V0KG1hcCwgdmFsdWUsIHRyYW5zZmVycmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICQoewogICAgICAgICAgICAgICAgICAgIGdsb2JhbDogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgIHNoYW06ICFQUk9QRVJfVFJBTlNGRVIsCiAgICAgICAgICAgICAgICAgICAgZm9yY2VkOiBGT1JDRURfUkVQTEFDRU1FTlQKICAgICAgICAgICAgICAgIH0sIHsKICAgICAgICAgICAgICAgICAgICBzdHJ1Y3R1cmVkQ2xvbmU6IGZ1bmN0aW9uIHN0cnVjdHVyZWRDbG9uZSh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgb3B0aW9ucyA9IHZhbGlkYXRlQXJndW1lbnRzTGVuZ3RoKGFyZ3VtZW50cy5sZW5ndGgsIDEpID4gMSAmJiAhaXNOdWxsT3JVbmRlZmluZWQoYXJndW1lbnRzWzFdKSA/IGFuT2JqZWN0KGFyZ3VtZW50c1sxXSkgOiB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0cmFuc2ZlciA9IG9wdGlvbnMgPyBvcHRpb25zLnRyYW5zZmVyIDogdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgbWFwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNmZXIgIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwID0gbmV3IE1hcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5VG9UcmFuc2Zlcih0cmFuc2ZlciwgbWFwKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUsIG1hcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyNiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODIpOwogICAgICAgICAgICAgICAgdmFyIGdldEJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI3KTsKICAgICAgICAgICAgICAgIHZhciBpbnNwZWN0U291cmNlID0gX193X3BkZmpzX3JlcXVpcmVfXyg1NCk7CiAgICAgICAgICAgICAgICB2YXIgbm9vcCA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgZW1wdHkgPSBbXTsKICAgICAgICAgICAgICAgIHZhciBjb25zdHJ1Y3QgPSBnZXRCdWlsdEluKCdSZWZsZWN0JywgJ2NvbnN0cnVjdCcpOwogICAgICAgICAgICAgICAgdmFyIGNvbnN0cnVjdG9yUmVnRXhwID0gL15ccyooPzpjbGFzc3xmdW5jdGlvbilcYi87CiAgICAgICAgICAgICAgICB2YXIgZXhlYyA9IHVuY3VycnlUaGlzKGNvbnN0cnVjdG9yUmVnRXhwLmV4ZWMpOwogICAgICAgICAgICAgICAgdmFyIElOQ09SUkVDVF9UT19TVFJJTkcgPSAhY29uc3RydWN0b3JSZWdFeHAuZXhlYyhub29wKTsKICAgICAgICAgICAgICAgIHZhciBpc0NvbnN0cnVjdG9yTW9kZXJuID0gZnVuY3Rpb24gaXNDb25zdHJ1Y3Rvcihhcmd1bWVudCkgewogICAgICAgICAgICAgICAgICAgIGlmICghaXNDYWxsYWJsZShhcmd1bWVudCkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Qobm9vcCwgZW1wdHksIGFyZ3VtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgaXNDb25zdHJ1Y3RvckxlZ2FjeSA9IGZ1bmN0aW9uIGlzQ29uc3RydWN0b3IoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUoYXJndW1lbnQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChjbGFzc29mKGFyZ3VtZW50KSkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBc3luY0Z1bmN0aW9uJzoKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnR2VuZXJhdG9yRnVuY3Rpb24nOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBc3luY0dlbmVyYXRvckZ1bmN0aW9uJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOQ09SUkVDVF9UT19TVFJJTkcgfHwgISFleGVjKGNvbnN0cnVjdG9yUmVnRXhwLCBpbnNwZWN0U291cmNlKGFyZ3VtZW50KSk7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGlzQ29uc3RydWN0b3JMZWdhY3kuc2hhbSA9IHRydWU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICFjb25zdHJ1Y3QgfHwgZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciBjYWxsZWQ7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGlzQ29uc3RydWN0b3JNb2Rlcm4oaXNDb25zdHJ1Y3Rvck1vZGVybi5jYWxsKSB8fCAhaXNDb25zdHJ1Y3Rvck1vZGVybihPYmplY3QpIHx8ICFpc0NvbnN0cnVjdG9yTW9kZXJuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9KSB8fCBjYWxsZWQ7CiAgICAgICAgICAgICAgICB9KSA/IGlzQ29uc3RydWN0b3JMZWdhY3kgOiBpc0NvbnN0cnVjdG9yTW9kZXJuOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgJFR5cGVFcnJvciA9IFR5cGVFcnJvcjsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKHBhc3NlZCwgcmVxdWlyZWQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAocGFzc2VkIDwgcmVxdWlyZWQpCiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93ICRUeXBlRXJyb3IoJ05vdCBlbm91Z2ggYXJndW1lbnRzJyk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhc3NlZDsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExKTsKICAgICAgICAgICAgICAgIHZhciBoYXNPd24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQyKTsKICAgICAgICAgICAgICAgIHZhciBpc1Byb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXygyOCk7CiAgICAgICAgICAgICAgICB2YXIgcmVnRXhwRmxhZ3MgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyOSk7CiAgICAgICAgICAgICAgICB2YXIgUmVnRXhwUHJvdG90eXBlID0gUmVnRXhwLnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKFIpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgZmxhZ3MgPSBSLmZsYWdzOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBmbGFncyA9PT0gdW5kZWZpbmVkICYmICEoJ2ZsYWdzJyBpbiBSZWdFeHBQcm90b3R5cGUpICYmICFoYXNPd24oUiwgJ2ZsYWdzJykgJiYgaXNQcm90b3R5cGVPZihSZWdFeHBQcm90b3R5cGUsIFIpID8gY2FsbChyZWdFeHBGbGFncywgUikgOiBmbGFnczsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyOSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBhbk9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNTApOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHRoYXQgPSBhbk9iamVjdCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gJyc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuaGFzSW5kaWNlcykKICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ICs9ICdkJzsKICAgICAgICAgICAgICAgICAgICBpZiAodGhhdC5nbG9iYWwpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAnZyc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuaWdub3JlQ2FzZSkKICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ICs9ICdpJzsKICAgICAgICAgICAgICAgICAgICBpZiAodGhhdC5tdWx0aWxpbmUpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAnbSc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuZG90QWxsKQogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgKz0gJ3MnOwogICAgICAgICAgICAgICAgICAgIGlmICh0aGF0LnVuaWNvZGUpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAndSc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQudW5pY29kZVNldHMpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAndic7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuc3RpY2t5KQogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgKz0gJ3knOwogICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzAgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgdmFyIE1hcFByb3RvdHlwZSA9IE1hcC5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHsKICAgICAgICAgICAgICAgICAgICBNYXA6IE1hcCwKICAgICAgICAgICAgICAgICAgICBzZXQ6IHVuY3VycnlUaGlzKE1hcFByb3RvdHlwZS5zZXQpLAogICAgICAgICAgICAgICAgICAgIGdldDogdW5jdXJyeVRoaXMoTWFwUHJvdG90eXBlLmdldCksCiAgICAgICAgICAgICAgICAgICAgaGFzOiB1bmN1cnJ5VGhpcyhNYXBQcm90b3R5cGUuaGFzKSwKICAgICAgICAgICAgICAgICAgICByZW1vdmU6IHVuY3VycnlUaGlzKE1hcFByb3RvdHlwZVsnZGVsZXRlJ10pLAogICAgICAgICAgICAgICAgICAgIHByb3RvOiBNYXBQcm90b3R5cGUKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzMSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgU2V0UHJvdG90eXBlID0gU2V0LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gewogICAgICAgICAgICAgICAgICAgIFNldDogU2V0LAogICAgICAgICAgICAgICAgICAgIGFkZDogdW5jdXJyeVRoaXMoU2V0UHJvdG90eXBlLmFkZCksCiAgICAgICAgICAgICAgICAgICAgaGFzOiB1bmN1cnJ5VGhpcyhTZXRQcm90b3R5cGUuaGFzKSwKICAgICAgICAgICAgICAgICAgICByZW1vdmU6IHVuY3VycnlUaGlzKFNldFByb3RvdHlwZVsnZGVsZXRlJ10pLAogICAgICAgICAgICAgICAgICAgIHByb3RvOiBTZXRQcm90b3R5cGUsCiAgICAgICAgICAgICAgICAgICAgJGhhczogU2V0UHJvdG90eXBlLmhhcywKICAgICAgICAgICAgICAgICAgICAka2V5czogU2V0UHJvdG90eXBlLmtleXMKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzMiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICFmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGVycm9yID0gRXJyb3IoJ2EnKTsKICAgICAgICAgICAgICAgICAgICBpZiAoISgnc3RhY2snIGluIGVycm9yKSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGVycm9yLCAnc3RhY2snLCBjcmVhdGVQcm9wZXJ0eURlc2NyaXB0b3IoMSwgNykpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBlcnJvci5zdGFjayAhPT0gNzsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzMgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICB2YXIgVjggPSBfX3dfcGRmanNfcmVxdWlyZV9fKDMxKTsKICAgICAgICAgICAgICAgIHZhciBJU19CUk9XU0VSID0gX193X3BkZmpzX3JlcXVpcmVfXygxMzQpOwogICAgICAgICAgICAgICAgdmFyIElTX0RFTk8gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzNSk7CiAgICAgICAgICAgICAgICB2YXIgSVNfTk9ERSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTM2KTsKICAgICAgICAgICAgICAgIHZhciBzdHJ1Y3R1cmVkQ2xvbmUgPSBnbG9iYWwuc3RydWN0dXJlZENsb25lOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSAhIXN0cnVjdHVyZWRDbG9uZSAmJiAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChJU19ERU5PICYmIFY4ID4gOTIgfHwgSVNfTk9ERSAmJiBWOCA+IDk0IHx8IElTX0JST1dTRVIgJiYgVjggPiA5NykKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIoOCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGNsb25lID0gc3RydWN0dXJlZENsb25lKGJ1ZmZlciwgeyB0cmFuc2ZlcjogW2J1ZmZlcl0gfSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGJ1ZmZlci5ieXRlTGVuZ3RoICE9IDAgfHwgY2xvbmUuYnl0ZUxlbmd0aCAhPSA4OwogICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzNCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIElTX0RFTk8gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzNSk7CiAgICAgICAgICAgICAgICB2YXIgSVNfTk9ERSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTM2KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gIUlTX0RFTk8gJiYgIUlTX05PREUgJiYgdHlwZW9mIHdpbmRvdyA9PSAnb2JqZWN0JyAmJiB0eXBlb2YgZG9jdW1lbnQgPT0gJ29iamVjdCc7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzNSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gdHlwZW9mIERlbm8gPT0gJ29iamVjdCcgJiYgRGVubyAmJiB0eXBlb2YgRGVuby52ZXJzaW9uID09ICdvYmplY3QnOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjbGFzc29mID0gX193X3BkZmpzX3JlcXVpcmVfXygxOCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHR5cGVvZiBwcm9jZXNzICE9ICd1bmRlZmluZWQnICYmIGNsYXNzb2YocHJvY2VzcykgPT0gJ3Byb2Nlc3MnOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBnbG9iYWw7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzOCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0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KDE1NSk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0Q2FudmFzRmFjdG9yeSA9IERlZmF1bHRDYW52YXNGYWN0b3J5ID0gTm9kZUNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0Q01hcFJlYWRlckZhY3RvcnkgPSBEZWZhdWx0Q01hcFJlYWRlckZhY3RvcnkgPSBOb2RlQ01hcFJlYWRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0RmlsdGVyRmFjdG9yeSA9IERlZmF1bHRGaWx0ZXJGYWN0b3J5ID0gTm9kZUZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0U3RhbmRhcmRGb250RGF0YUZhY3RvcnkgPSBEZWZhdWx0U3RhbmRhcmRGb250RGF0YUZhY3RvcnkgPSBOb2RlU3RhbmRhcmRGb250RGF0YUZhY3Rvcnk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBsZXQgY3JlYXRlUERGTmV0d29ya1N0cmVhbTsKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZiAoX2lzX25vZGUuaXNOb2RlSlMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUERGTm9kZVN0cmVhbQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTYpOwogICAgICAgICAgICAgICAgICAgICAgICBjcmVhdGVQREZOZXR3b3JrU3RyZWFtID0gcGFyYW1zID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUERGTm9kZVN0cmVhbShwYXJhbXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIFBERk5ldHdvcmtTdHJlYW0KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTU5KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUERGRmV0Y2hTdHJlYW0KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTYwKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUERGTmV0d29ya1N0cmVhbSA9IHBhcmFtcyA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF9kaXNwbGF5X3V0aWxzLmlzVmFsaWRGZXRjaFVybCkocGFyYW1zLnVybCkgPyBuZXcgUERGRmV0Y2hTdHJlYW0ocGFyYW1zKSA6IG5ldyBQREZOZXR3b3JrU3RyZWFtKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0RG9jdW1lbnQoc3JjKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBzcmMgPT09ICJzdHJpbmciIHx8IHNyYyBpbnN0YW5jZW9mIFVSTCkgewogICAgICAgICAgICAgICAgICAgICAgICBzcmMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmw6IHNyYwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoKDAsIF91dGlsLmlzQXJyYXlCdWZmZXIpKHNyYykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3JjID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YTogc3JjCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygc3JjICE9PSAib2JqZWN0IikgewogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcGFyYW1ldGVyIGluIGdldERvY3VtZW50LCBuZWVkIHBhcmFtZXRlciBvYmplY3QuIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghc3JjLnVybCAmJiAhc3JjLmRhdGEgJiYgIXNyYy5yYW5nZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcGFyYW1ldGVyIG9iamVjdDogbmVlZCBlaXRoZXIgLmRhdGEsIC5yYW5nZSBvciAudXJsIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgUERGRG9jdW1lbnRMb2FkaW5nVGFzaygpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgZG9jSWQKICAgICAgICAgICAgICAgICAgICB9ID0gdGFzazsKICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBzcmMudXJsID8gZ2V0VXJsUHJvcChzcmMudXJsKSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHNyYy5kYXRhID8gZ2V0RGF0YVByb3Aoc3JjLmRhdGEpIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBodHRwSGVhZGVycyA9IHNyYy5odHRwSGVhZGVycyB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpdGhDcmVkZW50aWFscyA9IHNyYy53aXRoQ3JlZGVudGlhbHMgPT09IHRydWU7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFzc3dvcmQgPSBzcmMucGFzc3dvcmQgPz8gbnVsbDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBy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ZUZvbnRGYWNlIDogX2lzX25vZGUuaXNOb2RlSlM7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udEV4dHJhUHJvcGVydGllcyA9IHNyYy5mb250RXh0cmFQcm9wZXJ0aWVzID09PSB0cnVlOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGVuYWJsZVhmYSA9IHNyYy5lbmFibGVYZmEgPT09IHRydWU7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3duZXJEb2N1bWVudCA9IHNyYy5vd25lckRvY3VtZW50IHx8IGdsb2JhbFRoaXMuZG9jdW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZGlzYWJsZVJhbmdlID0gc3JjLmRpc2FibGVSYW5nZSA9PT0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXNhYmxlU3RyZWFtID0gc3JjLmRpc2FibGVTdHJlYW0gPT09IHRydWU7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZGlzYWJsZUF1dG9GZXRjaCA9IHNyYy5kaXNhYmxlQXV0b0ZldGNoID09PSB0cnVlOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBkZkJ1ZyA9IHNyYy5wZGZCdWcgPT09IHRydWU7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuZ3RoID0gcmFuZ2VUcmFuc3BvcnQgPyByYW5nZVRyYW5zcG9ydC5sZW5ndGggOiBzcmMubGVuZ3RoID8/IE5hTjsKICAgICAgICAgICAgICAgICAgICBjb25zdCB1c2VTeXN0ZW1Gb250cyA9IHR5cGVvZiBzcmMudXNlU3lzdGVtRm9udHMgPT09ICJib29sZWFuIiA/IHNyYy51c2VTeXN0ZW1Gb250cyA6ICFfaXNfbm9kZS5pc05vZGVKUyAmJiAhZGlzYWJsZUZvbnRGYWNlOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHVzZVdvcmtlckZldGNoID0gdHlwZW9mIHNyYy51c2VXb3JrZXJGZXRjaCA9PT0gImJvb2xlYW4iID8gc3JjLnVzZVdvcmtlckZldGNoIDogQ01hcFJlYWRlckZhY3RvcnkgPT09IF9kaXNwbGF5X3V0aWxzLkRPTUNNYXBSZWFkZXJGYWN0b3J5ICYmIFN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID09PSBfZGlzcGxheV91dGlscy5ET01TdGFuZGFyZEZvbnREYXRhRmFjdG9yeSAmJiAoMCwgX2Rpc3BsYXlfdXRpbHMuaXNWYWxpZEZldGNoVXJsKShjTWFwVXJsLCBkb2N1bWVudC5iYXNlVVJJKSAmJiAoMCwgX2Rpc3BsYXlfdXRpbHMuaXNWYWxpZEZldGNoVXJsKShzdGFuZGFyZEZvbnREYXRhVXJsLCBkb2N1bWVudC5iYXNlVVJJKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXNGYWN0b3J5ID0gc3JjLmNhbnZhc0ZhY3RvcnkgfHwgbmV3IERlZmF1bHRDYW52YXNGYWN0b3J5KHsKICAgICAgICAgICAgICAgICAgICAgICAgb3duZXJEb2N1bWVudAogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpbHRlckZhY3RvcnkgPSBzcmMuZmlsdGVyRmFjdG9yeSB8fCBuZXcgRGVmYXVsdEZpbHRlckZhY3RvcnkoewogICAgICAgICAgICAgICAgICAgICAgICBkb2NJZCwKICAgICAgICAgICAgICAgICAgICAgICAgb3duZXJEb2N1bWVudAogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0eWxlRWxlbWVudCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnNldFZlcmJvc2l0eUxldmVsKSh2ZXJib3NpdHkpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydEZhY3RvcnkgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc0ZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlckZhY3RvcnkKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGlmICghdXNlV29ya2VyRmV0Y2gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNwb3J0RmFjdG9yeS5jTWFwUmVhZGVyRmFjdG9yeSA9IG5ldyBDTWFwUmVhZGVyRmFjdG9yeSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYXNlVXJsOiBjTWFwVXJsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNDb21wcmVzc2VkOiBjTWFwUGFja2VkCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0cmFuc3BvcnRGYWN0b3J5LnN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gbmV3IFN0YW5kYXJkRm9udERhdGFGYWN0b3J5KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VVcmw6IHN0YW5kYXJkRm9udERhdGFVcmwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghd29ya2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdvcmtlclBhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZlcmJvc2l0eSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvcnQ6IF93b3JrZXJfb3B0aW9ucy5HbG9iYWxXb3JrZXJPcHRpb25zLndvcmtlclBvcnQKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgd29ya2VyID0gd29ya2VyUGFyYW1zLnBvcnQgPyBQREZXb3JrZXIuZnJvbVBvcnQod29ya2VyUGFyYW1zKSA6IG5ldyBQREZXb3JrZXIod29ya2VyUGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGFzay5fd29ya2VyID0gd29ya2VyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBmZXRjaERvY1BhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgZG9jSWQsCiAgICAgICAgICAgICAgICAgICAgICAgIGFwaVZlcnNpb246ICczLjUuMTIyJywKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgcGFzc3dvcmQsCiAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVBdXRvRmV0Y2gsCiAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlQ2h1bmtTaXplLAogICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgIGRvY0Jhc2VVcmwsCiAgICAgICAgICAgICAgICAgICAgICAgIGVuYWJsZVhmYSwKICAgICAgICAgICAgICAgICAgICAgICAgZXZhbHVhdG9yT3B0aW9uczogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4SW1hZ2VTaXplLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUZvbnRGYWNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlRXJyb3JzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNFdmFsU3VwcG9ydGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNNYXhBcmVhSW5CeXRlcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvbnRFeHRyYVByb3BlcnRpZXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VTeXN0ZW1Gb250cywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNNYXBVcmw6IHVzZVdvcmtlckZldGNoID8gY01hcFVybCA6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFuZGFyZEZvbnREYXRhVXJsOiB1c2VXb3JrZXJGZXRjaCA/IHN0YW5kYXJkRm9udERhdGFVcmwgOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydFBhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlRXJyb3JzLAogICAgICAgICAgICAgICAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVGb250RmFjZSwKICAgICAgICAgICAgICAgICAgICAgICAgZm9udEV4dHJhUHJvcGVydGllcywKICAgICAgICAgICAgICAgICAgICAgICAgZW5hYmxlWGZhLAogICAgICAgICAgICAgICAgICAgICAgICBvd25lckRvY3VtZW50LAogICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlQXV0b0ZldGNoLAogICAgICAgICAgICAgICAgICAgICAgICBwZGZCdWcsCiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlRWxlbWVudAogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgd29ya2VyLnByb21pc2UudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0YXNrLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJMb2FkaW5nIGFib3J0ZWQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3b3JrZXJJZFByb21pc2UgPSBfZmV0Y2hEb2N1bWVudCh3b3JrZXIsIGZldGNoRG9jUGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbmV0d29ya1N0cmVhbVByb21pc2UgPSBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG5ldHdvcmtTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmFuZ2VUcmFuc3BvcnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXR3b3JrU3RyZWFtID0gbmV3IF90cmFuc3BvcnRfc3RyZWFtLlBERkRhdGFUcmFuc3BvcnRTdHJlYW0oewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluaXRpYWxEYXRhOiByYW5nZVRyYW5zcG9ydC5pbml0aWFsRGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvZ3Jlc3NpdmVEb25lOiByYW5nZVRyYW5zcG9ydC5wcm9ncmVzc2l2ZURvbmUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lOiByYW5nZVRyYW5zcG9ydC5jb250ZW50RGlzcG9zaXRpb25GaWxlbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZVJhbmdlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlU3RyZWFtCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgcmFuZ2VUcmFuc3BvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICghZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldHdvcmtTdHJlYW0gPSBjcmVhdGVQREZOZXR3b3JrU3RyZWFtKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGh0dHBIZWFkZXJzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aXRoQ3JlZGVudGlhbHMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlQ2h1bmtTaXplLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlUmFuZ2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVTdHJlYW0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUobmV0d29ya1N0cmVhbSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5hbGwoW3dvcmtlcklkUHJvbWlzZSwgbmV0d29ya1N0cmVhbVByb21pc2VdKS50aGVuKGZ1bmN0aW9uIChfcmVmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgW3dvcmtlcklkLCBuZXR3b3JrU3RyZWFtXSA9IF9yZWY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGFzay5kZXN0cm95ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkxvYWRpbmcgYWJvcnRlZCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWVzc2FnZUhhbmRsZXIgPSBuZXcgX21lc3NhZ2VfaGFuZGxlci5NZXNzYWdlSGFuZGxlcihkb2NJZCwgd29ya2VySWQsIHdvcmtlci5wb3J0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydCA9IG5ldyBXb3JrZXJUcmFuc3BvcnQobWVzc2FnZUhhbmRsZXIsIHRhc2ssIG5ldHdvcmtTdHJlYW0sIHRyYW5zcG9ydFBhcmFtcywgdHJhbnNwb3J0RmFjdG9yeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXNrLl90cmFuc3BvcnQgPSB0cmFuc3BvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlSGFuZGxlci5zZW5kKCJSZWFkeSIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9KS5jYXRjaCh0YXNrLl9jYXBhYmlsaXR5LnJlamVjdCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRhc2s7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBhc3luYyBmdW5jdGlvbiBfZmV0Y2hEb2N1bWVudCh3b3JrZXIsIHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgIGlmICh3b3JrZXIuZGVzdHJveWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiV29ya2VyIHdhcyBkZXN0cm95ZWQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgd29ya2VySWQgPSBhd2FpdCB3b3JrZXIubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXREb2NSZXF1ZXN0Iiwgc291cmNlLCBzb3VyY2UuZGF0YSA/IFtzb3VyY2UuZGF0YS5idWZmZXJdIDogbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHdvcmtlci5kZXN0cm95ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJXb3JrZXIgd2FzIGRlc3Ryb3llZCIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VySWQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRVcmxQcm9wKHZhbCkgewogICAgICAgICAgICAgICAgICAgIGlmICh2YWwgaW5zdGFuY2VvZiBVUkwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbC5ocmVmOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFVSTCh2YWwsIHdpbmRvdy5sb2NhdGlvbikuaHJlZjsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2lzX25vZGUuaXNOb2RlSlMgJiYgdHlwZW9mIHZhbCA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJJbnZhbGlkIFBERiB1cmwgZGF0YTogIiArICJlaXRoZXIgc3RyaW5nIG9yIFVSTC1vYmplY3QgaXMgZXhwZWN0ZWQgaW4gdGhlIHVybCBwcm9wZXJ0eS4iKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldERhdGFQcm9wKHZhbCkgewogICAgICAgICAgICAgICAgICAgIGlmIChfaXNfbm9kZS5pc05vZGVKUyAmJiB0eXBlb2YgQnVmZmVyICE9PSAidW5kZWZpbmVkIiAmJiB2YWwgaW5zdGFuY2VvZiBCdWZmZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF9kaXNwbGF5X3V0aWxzLmRlcHJlY2F0ZWQpKCJQbGVhc2UgcHJvdmlkZSBiaW5hcnkgZGF0YSBhcyBgVWludDhBcnJheWAsIHJhdGhlciB0aGFuIGBCdWZmZXJgLiIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFVpbnQ4QXJyYXkodmFsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHZhbCBpbnN0YW5jZW9mIFVpbnQ4QXJyYXkgJiYgdmFsLmJ5dGVMZW5ndGggPT09IHZhbC5idWZmZXIuYnl0ZUxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbCA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zdHJpbmdUb0J5dGVzKSh2YWwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbCA9PT0gIm9iamVjdCIgJiYgIWlzTmFOKHZhbCA9PT0gbnVsbCB8fCB2YWwgPT09IHZvaWQgMCA/IHZvaWQgMCA6IHZhbC5sZW5ndGgpIHx8ICgwLCBfdXRpbC5pc0FycmF5QnVmZmVyKSh2YWwpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgVWludDhBcnJheSh2YWwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgUERGIGJpbmFyeSBkYXRhOiBlaXRoZXIgVHlwZWRBcnJheSwgIiArICJzdHJpbmcsIG9yIGFycmF5LWxpa2Ugb2JqZWN0IGlzIGV4cGVjdGVkIGluIHRoZSBkYXRhIHByb3BlcnR5LiIpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUERGRG9jdW1lbnRMb2FkaW5nVGFzayB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljICNkb2NJZCA9IDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RyYW5zcG9ydCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3dvcmtlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZG9jSWQgPSBgZCR7UERGRG9jdW1lbnRMb2FkaW5nVGFzay4jZG9jSWQrK31gOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3Ryb3llZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUGFzc3dvcmQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJvbWlzZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2NhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgZGVzdHJveSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF90cmFuc3BvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdHJveWVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgKChfdGhpcyRfdHJhbnNwb3J0ID0gdGhpcy5fdHJhbnNwb3J0KSA9PT0gbnVsbCB8fCBfdGhpcyRfdHJhbnNwb3J0ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfdHJhbnNwb3J0LmRlc3Ryb3koKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RyYW5zcG9ydCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl93b3JrZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3dvcmtlci5kZXN0cm95KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl93b3JrZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZEb2N1bWVudExvYWRpbmdUYXNrID0gUERGRG9jdW1lbnRMb2FkaW5nVGFzazsKICAgICAgICAgICAgICAgIGNsYXNzIFBERkRhdGFSYW5nZVRyYW5zcG9ydCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobGVuZ3RoLCBpbml0aWFsRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcHJvZ3Jlc3NpdmVEb25lID0gYXJndW1lbnRzLmxlbmd0aCA+IDIgJiYgYXJndW1lbnRzWzJdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMl0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lID0gYXJndW1lbnRzLmxlbmd0aCA+IDMgJiYgYXJndW1lbnRzWzNdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbM10gOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxlbmd0aCA9IGxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pbml0aWFsRGF0YSA9IGluaXRpYWxEYXRhOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnByb2dyZXNzaXZlRG9uZSA9IHByb2dyZXNzaXZlRG9uZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250ZW50RGlzcG9zaXRpb25GaWxlbmFtZSA9IGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZUxpc3RlbmVycyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wcm9ncmVzc0xpc3RlbmVycyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wcm9ncmVzc2l2ZVJlYWRMaXN0ZW5lcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcHJvZ3Jlc3NpdmVEb25lTGlzdGVuZXJzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWR5Q2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkUmFuZ2VMaXN0ZW5lcihsaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZUxpc3RlbmVycy5wdXNoKGxpc3RlbmVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkUHJvZ3Jlc3NMaXN0ZW5lcihsaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wcm9ncmVzc0xpc3RlbmVycy5wdXNoKGxpc3RlbmVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkUHJvZ3Jlc3NpdmVSZWFkTGlzdGVuZXIobGlzdGVuZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcHJvZ3Jlc3NpdmVSZWFkTGlzdGVuZXJzLnB1c2gobGlzdGVuZXIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRQcm9ncmVzc2l2ZURvbmVMaXN0ZW5lcihsaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wcm9ncmVzc2l2ZURvbmVMaXN0ZW5lcnMucHVzaChsaXN0ZW5lcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uRGF0YVJhbmdlKGJlZ2luLCBjaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpc3RlbmVyIG9mIHRoaXMuX3JhbmdlTGlzdGVuZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaXN0ZW5lcihiZWdpbiwgY2h1bmspOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uRGF0YVByb2dyZXNzKGxvYWRlZCwgdG90YWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnByb21pc2UudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpc3RlbmVyIG9mIHRoaXMuX3Byb2dyZXNzTGlzdGVuZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlzdGVuZXIobG9hZGVkLCB0b3RhbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBvbkRhdGFQcm9ncmVzc2l2ZVJlYWQoY2h1bmspIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnByb21pc2UudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpc3RlbmVyIG9mIHRoaXMuX3Byb2dyZXNzaXZlUmVhZExpc3RlbmVycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpc3RlbmVyKGNodW5rKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uRGF0YVByb2dyZXNzaXZlRG9uZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnByb21pc2UudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpc3RlbmVyIG9mIHRoaXMuX3Byb2dyZXNzaXZlRG9uZUxpc3RlbmVycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpc3RlbmVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0cmFuc3BvcnRSZWFkeSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVxdWVzdERhdGFSYW5nZShiZWdpbiwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkFic3RyYWN0IG1ldGhvZCBQREZEYXRhUmFuZ2VUcmFuc3BvcnQucmVxdWVzdERhdGFSYW5nZSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhYm9ydCgpIHt9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkRhdGFSYW5nZVRyYW5zcG9ydCA9IFBERkRhdGFSYW5nZVRyYW5zcG9ydDsKICAgICAgICAgICAgICAgIGNsYXNzIFBERkRvY3VtZW50UHJveHkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBkZkluZm8sIHRyYW5zcG9ydCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZJbmZvID0gcGRmSW5mbzsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdHJhbnNwb3J0ID0gdHJhbnNwb3J0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgYW5ub3RhdGlvblN0b3JhZ2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuYW5ub3RhdGlvblN0b3JhZ2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBmaWx0ZXJGYWN0b3J5KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBudW1QYWdlcygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3BkZkluZm8ubnVtUGFnZXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBmaW5nZXJwcmludHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9wZGZJbmZvLmZpbmdlcnByaW50czsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGlzUHVyZVhmYSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJpc1B1cmVYZmEiLCAhIXRoaXMuX3RyYW5zcG9ydC5faHRtbEZvclhmYSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBhbGxYZmFIdG1sKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0Ll9odG1sRm9yWGZhOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYWdlKHBhZ2VOdW1iZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5nZXRQYWdlKHBhZ2VOdW1iZXIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYWdlSW5kZXgocmVmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0UGFnZUluZGV4KHJlZik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERlc3RpbmF0aW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5nZXREZXN0aW5hdGlvbnMoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RGVzdGluYXRpb24oaWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5nZXREZXN0aW5hdGlvbihpZCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhZ2VMYWJlbHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0UGFnZUxhYmVscygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYWdlTGF5b3V0KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldFBhZ2VMYXlvdXQoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGFnZU1vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0UGFnZU1vZGUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0Vmlld2VyUHJlZmVyZW5jZXMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0Vmlld2VyUHJlZmVyZW5jZXMoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0T3BlbkFjdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5nZXRPcGVuQWN0aW9uKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEF0dGFjaG1lbnRzKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldEF0dGFjaG1lbnRzKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEphdmFTY3JpcHQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0SmF2YVNjcmlwdCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRKU0FjdGlvbnMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0RG9jSlNBY3Rpb25zKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE91dGxpbmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0T3V0bGluZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRPcHRpb25hbENvbnRlbnRDb25maWcoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0T3B0aW9uYWxDb250ZW50Q29uZmlnKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBlcm1pc3Npb25zKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldFBlcm1pc3Npb25zKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE1ldGFkYXRhKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldE1ldGFkYXRhKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE1hcmtJbmZvKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldE1hcmtJbmZvKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERhdGEoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0RGF0YSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzYXZlRG9jdW1lbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuc2F2ZURvY3VtZW50KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERvd25sb2FkSW5mbygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5kb3dubG9hZEluZm9DYXBhYmlsaXR5LnByb21pc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsZWFudXAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrZWVwTG9hZGVkRm9udHMgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LnN0YXJ0Q2xlYW51cChrZWVwTG9hZGVkRm9udHMgfHwgdGhpcy5pc1B1cmVYZmEpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5sb2FkaW5nVGFzay5kZXN0cm95KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBsb2FkaW5nUGFyYW1zKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmxvYWRpbmdQYXJhbXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBsb2FkaW5nVGFzaygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5sb2FkaW5nVGFzazsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RmllbGRPYmplY3RzKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldEZpZWxkT2JqZWN0cygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXNKU0FjdGlvbnMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuaGFzSlNBY3Rpb25zKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldENhbGN1bGF0aW9uT3JkZXJJZHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0Q2FsY3VsYXRpb25PcmRlcklkcygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuUERGRG9jdW1lbnRQcm94eSA9IFBERkRvY3VtZW50UHJveHk7CiAgICAgICAgICAgICAgICB2YXIgX2RlbGF5ZWRDbGVhbnVwVGltZW91dCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9wZW5kaW5nQ2xlYW51cCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF90cnlDbGVhbnVwID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2Fib3J0RGVsYXllZENsZWFudXAgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIFBERlBhZ2VQcm94eSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFnZUluZGV4LCBwYWdlSW5mbywgdHJhbnNwb3J0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwZGZCdWcgPSBhcmd1bWVudHMubGVuZ3RoID4gMyAmJiBhcmd1bWVudHNbM10gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1szXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2Fib3J0RGVsYXllZENsZWFudXApOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3RyeUNsZWFudXApOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZGVsYXllZENsZWFudXBUaW1lb3V0LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcGVuZGluZ0NsZWFudXAsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYWdlSW5kZXggPSBwYWdlSW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3BhZ2VJbmZvID0gcGFnZUluZm87CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RyYW5zcG9ydCA9IHRyYW5zcG9ydDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RhdHMgPSBwZGZCdWcgPyBuZXcgX2Rpc3BsYXlfdXRpbHMuU3RhdFRpbWVyKCkgOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZCdWcgPSBwZGZCdWc7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbW9uT2JqcyA9IHRyYW5zcG9ydC5jb21tb25PYmpzOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9ianMgPSBuZXcgUERGT2JqZWN0cygpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tYXliZUNsZWFudXBBZnRlclJlbmRlciA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pbnRlbnRTdGF0ZXMgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdHJveWVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwYWdlTnVtYmVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcGFnZUluZGV4ICsgMTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHJvdGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3BhZ2VJbmZvLnJvdGF0ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHJlZigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3BhZ2VJbmZvLnJlZjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHVzZXJVbml0KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcGFnZUluZm8udXNlclVuaXQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCB2aWV3KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcGFnZUluZm8udmlldzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0Vmlld3BvcnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uID0gdGhpcy5yb3RhdGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRYID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFkgPSAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9udEZsaXAgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBfZGlzcGxheV91dGlscy5QYWdlVmlld3BvcnQoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld0JveDogdGhpcy52aWV3LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9udEZsaXAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFubm90YXRpb25zKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50ID0gImRpc3BsYXkiCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IHt9OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnRlbnRBcmdzID0gdGhpcy5fdHJhbnNwb3J0LmdldFJlbmRlcmluZ0ludGVudChpbnRlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldEFubm90YXRpb25zKHRoaXMuX3BhZ2VJbmRleCwgaW50ZW50QXJncy5yZW5kZXJpbmdJbnRlbnQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRKU0FjdGlvbnMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0UGFnZUpTQWN0aW9ucyh0aGlzLl9wYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNQdXJlWGZhKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgImlzUHVyZVhmYSIsICEhdGhpcy5fdHJhbnNwb3J0Ll9odG1sRm9yWGZhKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgZ2V0WGZhKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3RyYW5zcG9ydCRfaHRtOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKChfdGhpcyRfdHJhbnNwb3J0JF9odG0gPSB0aGlzLl90cmFuc3BvcnQuX2h0bWxGb3JYZmEpID09PSBudWxsIHx8IF90aGlzJF90cmFuc3BvcnQkX2h0bSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX3RyYW5zcG9ydCRfaHRtLmNoaWxkcmVuW3RoaXMuX3BhZ2VJbmRleF0pIHx8IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcihfcmVmMikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3N0YXRzOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzQ29udGV4dCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50ID0gImRpc3BsYXkiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvbk1vZGUgPSBfdXRpbC5Bbm5vdGF0aW9uTW9kZS5FTkFCTEUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0gPSBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzRmFjdG9yeSA9IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWNrZ3JvdW5kID0gbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbmFsQ29udGVudENvbmZpZ1Byb21pc2UgPSBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvbkNhbnZhc01hcCA9IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlQ29sb3JzID0gbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50QW5ub3RhdGlvblN0b3JhZ2UgPSBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNhbnZhc0ZhY3RvcnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfZGlzcGxheV91dGlscy5kZXByZWNhdGVkKSgicmVuZGVyIG5vIGxvbmdlciBhY2NlcHRzIHRoZSBgY2FudmFzRmFjdG9yeWAtb3B0aW9uLCAiICsgInBsZWFzZSBwYXNzIGl0IHRvIHRoZSBgZ2V0RG9jdW1lbnRgLWZ1bmN0aW9uIGluc3RlYWQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9zdGF0cyA9IHRoaXMuX3N0YXRzKSA9PT0gbnVsbCB8fCBfdGhpcyRfc3RhdHMgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9zdGF0cy50aW1lKCJPdmVyYWxsIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGludGVudEFyZ3MgPSB0aGlzLl90cmFuc3BvcnQuZ2V0UmVuZGVyaW5nSW50ZW50KGludGVudCwgYW5ub3RhdGlvbk1vZGUsIHByaW50QW5ub3RhdGlvblN0b3JhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3BlbmRpbmdDbGVhbnVwLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Fib3J0RGVsYXllZENsZWFudXAsIF9hYm9ydERlbGF5ZWRDbGVhbnVwMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFvcHRpb25hbENvbnRlbnRDb25maWdQcm9taXNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25hbENvbnRlbnRDb25maWdQcm9taXNlID0gdGhpcy5fdHJhbnNwb3J0LmdldE9wdGlvbmFsQ29udGVudENvbmZpZygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpbnRlbnRTdGF0ZSA9IHRoaXMuX2ludGVudFN0YXRlcy5nZXQoaW50ZW50QXJncy5jYWNoZUtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW50ZW50U3RhdGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ludGVudFN0YXRlcy5zZXQoaW50ZW50QXJncy5jYWNoZUtleSwgaW50ZW50U3RhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlbnRTdGF0ZS5zdHJlYW1SZWFkZXJDYW5jZWxUaW1lb3V0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhclRpbWVvdXQoaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyQ2FuY2VsVGltZW91dCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5zdHJlYW1SZWFkZXJDYW5jZWxUaW1lb3V0ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnRlbnRQcmludCA9ICEhKGludGVudEFyZ3MucmVuZGVyaW5nSW50ZW50ICYgX3V0aWwuUmVuZGVyaW5nSW50ZW50RmxhZy5QUklOVCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW50ZW50U3RhdGUuZGlzcGxheVJlYWR5Q2FwYWJpbGl0eSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9zdGF0czI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5kaXNwbGF5UmVhZHlDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUub3BlcmF0b3JMaXN0ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZuQXJyYXk6IFtdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFyZ3NBcnJheTogW10sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGFzdENodW5rOiBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXBhcmF0ZUFubm90czogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfc3RhdHMyID0gdGhpcy5fc3RhdHMpID09PSBudWxsIHx8IF90aGlzJF9zdGF0czIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9zdGF0czIudGltZSgiUGFnZSBSZXF1ZXN0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wdW1wT3BlcmF0b3JMaXN0KGludGVudEFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbXBsZXRlID0gZXJyb3IgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9zdGF0czMsIF90aGlzJF9zdGF0czQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5yZW5kZXJUYXNrcy5kZWxldGUoaW50ZXJuYWxSZW5kZXJUYXNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9tYXliZUNsZWFudXBBZnRlclJlbmRlciB8fCBpbnRlbnRQcmludCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfcGVuZGluZ0NsZWFudXAsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdHJ5Q2xlYW51cCwgX3RyeUNsZWFudXAyKS5jYWxsKHRoaXMsICFpbnRlbnRQcmludCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcm5hbFJlbmRlclRhc2suY2FwYWJpbGl0eS5yZWplY3QoZXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Fib3J0T3BlcmF0b3JMaXN0KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbjogZXJyb3IgaW5zdGFuY2VvZiBFcnJvciA/IGVycm9yIDogbmV3IEVycm9yKGVycm9yKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcm5hbFJlbmRlclRhc2suY2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX3N0YXRzMyA9IHRoaXMuX3N0YXRzKSA9PT0gbnVsbCB8fCBfdGhpcyRfc3RhdHMzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfc3RhdHMzLnRpbWVFbmQoIlJlbmRlcmluZyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9zdGF0czQgPSB0aGlzLl9zdGF0cykgPT09IG51bGwgfHwgX3RoaXMkX3N0YXRzNCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX3N0YXRzNC50aW1lRW5kKCJPdmVyYWxsIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGludGVybmFsUmVuZGVyVGFzayA9IG5ldyBJbnRlcm5hbFJlbmRlclRhc2soewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2s6IGNvbXBsZXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zOiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzQ29udGV4dCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFja2dyb3VuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9ianM6IHRoaXMub2JqcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1vbk9ianM6IHRoaXMuY29tbW9uT2JqcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25DYW52YXNNYXAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcGVyYXRvckxpc3Q6IGludGVudFN0YXRlLm9wZXJhdG9yTGlzdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJbmRleDogdGhpcy5fcGFnZUluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzRmFjdG9yeTogY2FudmFzRmFjdG9yeSB8fCB0aGlzLl90cmFuc3BvcnQuY2FudmFzRmFjdG9yeSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlckZhY3Rvcnk6IHRoaXMuX3RyYW5zcG9ydC5maWx0ZXJGYWN0b3J5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdXNlUmVxdWVzdEFuaW1hdGlvbkZyYW1lOiAhaW50ZW50UHJpbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZGZCdWc6IHRoaXMuX3BkZkJ1ZywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VDb2xvcnMKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIChpbnRlbnRTdGF0ZS5yZW5kZXJUYXNrcyB8fD0gbmV3IFNldCgpKS5hZGQoaW50ZXJuYWxSZW5kZXJUYXNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVuZGVyVGFzayA9IGludGVybmFsUmVuZGVyVGFzay50YXNrOwogICAgICAgICAgICAgICAgICAgICAgICBQcm9taXNlLmFsbChbaW50ZW50U3RhdGUuZGlzcGxheVJlYWR5Q2FwYWJpbGl0eS5wcm9taXNlLCBvcHRpb25hbENvbnRlbnRDb25maWdQcm9taXNlXSkudGhlbihfcmVmMyA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3N0YXRzNTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBbdHJhbnNwYXJlbmN5LCBvcHRpb25hbENvbnRlbnRDb25maWddID0gX3JlZjM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wZW5kaW5nQ2xlYW51cCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wbGV0ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfc3RhdHM1ID0gdGhpcy5fc3RhdHMpID09PSBudWxsIHx8IF90aGlzJF9zdGF0czUgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9zdGF0czUudGltZSgiUmVuZGVyaW5nIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcm5hbFJlbmRlclRhc2suaW5pdGlhbGl6ZUdyYXBoaWNzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc3BhcmVuY3ksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uYWxDb250ZW50Q29uZmlnCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVybmFsUmVuZGVyVGFzay5vcGVyYXRvckxpc3RDaGFuZ2VkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pLmNhdGNoKGNvbXBsZXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlbmRlclRhc2s7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE9wZXJhdG9yTGlzdCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudCA9ICJkaXNwbGF5IiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25Nb2RlID0gX3V0aWwuQW5ub3RhdGlvbk1vZGUuRU5BQkxFLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRBbm5vdGF0aW9uU3RvcmFnZSA9IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG9wZXJhdG9yTGlzdENoYW5nZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW50ZW50U3RhdGUub3BlcmF0b3JMaXN0Lmxhc3RDaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLm9wTGlzdFJlYWRDYXBhYmlsaXR5LnJlc29sdmUoaW50ZW50U3RhdGUub3BlcmF0b3JMaXN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5yZW5kZXJUYXNrcy5kZWxldGUob3BMaXN0VGFzayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW50ZW50QXJncyA9IHRoaXMuX3RyYW5zcG9ydC5nZXRSZW5kZXJpbmdJbnRlbnQoaW50ZW50LCBhbm5vdGF0aW9uTW9kZSwgcHJpbnRBbm5vdGF0aW9uU3RvcmFnZSwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpbnRlbnRTdGF0ZSA9IHRoaXMuX2ludGVudFN0YXRlcy5nZXQoaW50ZW50QXJncy5jYWNoZUtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW50ZW50U3RhdGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ludGVudFN0YXRlcy5zZXQoaW50ZW50QXJncy5jYWNoZUtleSwgaW50ZW50U3RhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBvcExpc3RUYXNrOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWludGVudFN0YXRlLm9wTGlzdFJlYWRDYXBhYmlsaXR5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3N0YXRzNjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wTGlzdFRhc2sgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3BMaXN0VGFzay5vcGVyYXRvckxpc3RDaGFuZ2VkID0gb3BlcmF0b3JMaXN0Q2hhbmdlZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLm9wTGlzdFJlYWRDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKGludGVudFN0YXRlLnJlbmRlclRhc2tzIHx8PSBuZXcgU2V0KCkpLmFkZChvcExpc3RUYXNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLm9wZXJhdG9yTGlzdCA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbkFycmF5OiBbXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmdzQXJyYXk6IFtdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxhc3RDaHVuazogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VwYXJhdGVBbm5vdHM6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX3N0YXRzNiA9IHRoaXMuX3N0YXRzKSA9PT0gbnVsbCB8fCBfdGhpcyRfc3RhdHM2ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfc3RhdHM2LnRpbWUoIlBhZ2UgUmVxdWVzdCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcHVtcE9wZXJhdG9yTGlzdChpbnRlbnRBcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaW50ZW50U3RhdGUub3BMaXN0UmVhZENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RyZWFtVGV4dENvbnRlbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlQ29tYmluZVRleHRJdGVtcyA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5jbHVkZU1hcmtlZENvbnRlbnQgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgVEVYVF9DT05URU5UX0NIVU5LX1NJWkUgPSAxMDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhTdHJlYW0oIkdldFRleHRDb250ZW50IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZGV4OiB0aGlzLl9wYWdlSW5kZXgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21iaW5lVGV4dEl0ZW1zOiBkaXNhYmxlQ29tYmluZVRleHRJdGVtcyAhPT0gdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluY2x1ZGVNYXJrZWRDb250ZW50OiBpbmNsdWRlTWFya2VkQ29udGVudCA9PT0gdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaWdoV2F0ZXJNYXJrOiBURVhUX0NPTlRFTlRfQ0hVTktfU0laRSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemUodGV4dENvbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGV4dENvbnRlbnQuaXRlbXMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0VGV4dENvbnRlbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwYXJhbXMgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IHt9OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fdHJhbnNwb3J0Ll9odG1sRm9yWGZhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5nZXRYZmEoKS50aGVuKHhmYSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF94ZmFfdGV4dC5YZmFUZXh0LnRleHRDb250ZW50KHhmYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWFkYWJsZVN0cmVhbSA9IHRoaXMuc3RyZWFtVGV4dENvbnRlbnQocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlLCByZWplY3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHB1bXAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZGVyLnJlYWQoKS50aGVuKGZ1bmN0aW9uIChfcmVmNCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmNDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUodGV4dENvbnRlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24odGV4dENvbnRlbnQuc3R5bGVzLCB2YWx1ZS5zdHlsZXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0Q29udGVudC5pdGVtcy5wdXNoKC4uLnZhbHVlLml0ZW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHVtcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIHJlamVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWFkZXIgPSByZWFkYWJsZVN0cmVhbS5nZXRSZWFkZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRleHRDb250ZW50ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zOiBbXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZXM6IE9iamVjdC5jcmVhdGUobnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdW1wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRTdHJ1Y3RUcmVlKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldFN0cnVjdFRyZWUodGhpcy5fcGFnZUluZGV4KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2Rlc3Ryb3koKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdHJveWVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2FpdE9uID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW50ZW50U3RhdGUgb2YgdGhpcy5faW50ZW50U3RhdGVzLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9hYm9ydE9wZXJhdG9yTGlzdCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uOiBuZXcgRXJyb3IoIlBhZ2Ugd2FzIGRlc3Ryb3llZC4iKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JjZTogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW50ZW50U3RhdGUub3BMaXN0UmVhZENhcGFiaWxpdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW50ZXJuYWxSZW5kZXJUYXNrIG9mIGludGVudFN0YXRlLnJlbmRlclRhc2tzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2FpdE9uLnB1c2goaW50ZXJuYWxSZW5kZXJUYXNrLmNvbXBsZXRlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZXJuYWxSZW5kZXJUYXNrLmNhbmNlbCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub2Jqcy5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3BlbmRpbmdDbGVhbnVwLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Fib3J0RGVsYXllZENsZWFudXAsIF9hYm9ydERlbGF5ZWRDbGVhbnVwMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFByb21pc2UuYWxsKHdhaXRPbik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsZWFudXAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZXNldFN0YXRzID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9wZW5kaW5nQ2xlYW51cCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN1Y2Nlc3MgPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF90cnlDbGVhbnVwLCBfdHJ5Q2xlYW51cDIpLmNhbGwodGhpcywgZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVzZXRTdGF0cyAmJiBzdWNjZXNzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdGF0cyAmJj0gbmV3IF9kaXNwbGF5X3V0aWxzLlN0YXRUaW1lcigpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzdWNjZXNzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfc3RhcnRSZW5kZXJQYWdlKHRyYW5zcGFyZW5jeSwgY2FjaGVLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9zdGF0czcsIF9pbnRlbnRTdGF0ZSRkaXNwbGF5UjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW50ZW50U3RhdGUgPSB0aGlzLl9pbnRlbnRTdGF0ZXMuZ2V0KGNhY2hlS2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpbnRlbnRTdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfc3RhdHM3ID0gdGhpcy5fc3RhdHMpID09PSBudWxsIHx8IF90aGlzJF9zdGF0czcgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9zdGF0czcudGltZUVuZCgiUGFnZSBSZXF1ZXN0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIChfaW50ZW50U3RhdGUkZGlzcGxheVIgPSBpbnRlbnRTdGF0ZS5kaXNwbGF5UmVhZHlDYXBhYmlsaXR5KSA9PT0gbnVsbCB8fCBfaW50ZW50U3RhdGUkZGlzcGxheVIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9pbnRlbnRTdGF0ZSRkaXNwbGF5Ui5yZXNvbHZlKHRyYW5zcGFyZW5jeSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9yZW5kZXJQYWdlQ2h1bmsob3BlcmF0b3JMaXN0Q2h1bmssIGludGVudFN0YXRlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IG9wZXJhdG9yTGlzdENodW5rLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLm9wZXJhdG9yTGlzdC5mbkFycmF5LnB1c2gob3BlcmF0b3JMaXN0Q2h1bmsuZm5BcnJheVtpXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5vcGVyYXRvckxpc3QuYXJnc0FycmF5LnB1c2gob3BlcmF0b3JMaXN0Q2h1bmsuYXJnc0FycmF5W2ldKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5vcGVyYXRvckxpc3QubGFzdENodW5rID0gb3BlcmF0b3JMaXN0Q2h1bmsubGFzdENodW5rOwogICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5vcGVyYXRvckxpc3Quc2VwYXJhdGVBbm5vdHMgPSBvcGVyYXRvckxpc3RDaHVuay5zZXBhcmF0ZUFubm90czsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBpbnRlcm5hbFJlbmRlclRhc2sgb2YgaW50ZW50U3RhdGUucmVuZGVyVGFza3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVybmFsUmVuZGVyVGFzay5vcGVyYXRvckxpc3RDaGFuZ2VkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wZXJhdG9yTGlzdENodW5rLmxhc3RDaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdHJ5Q2xlYW51cCwgX3RyeUNsZWFudXAyKS5jYWxsKHRoaXMsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9wdW1wT3BlcmF0b3JMaXN0KF9yZWY1KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJpbmdJbnRlbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZUtleSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25TdG9yYWdlTWFwCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmNTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVhZGFibGVTdHJlYW0gPSB0aGlzLl90cmFuc3BvcnQubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhTdHJlYW0oIkdldE9wZXJhdG9yTGlzdCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJbmRleDogdGhpcy5fcGFnZUluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50OiByZW5kZXJpbmdJbnRlbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZUtleSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25TdG9yYWdlOiBhbm5vdGF0aW9uU3RvcmFnZU1hcAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVhZGVyID0gcmVhZGFibGVTdHJlYW0uZ2V0UmVhZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGludGVudFN0YXRlID0gdGhpcy5faW50ZW50U3RhdGVzLmdldChjYWNoZUtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLnN0cmVhbVJlYWRlciA9IHJlYWRlcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHVtcCA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRlci5yZWFkKCkudGhlbihfcmVmNiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fdHJhbnNwb3J0LmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlbmRlclBhZ2VDaHVuayh2YWx1ZSwgaW50ZW50U3RhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1bXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fdHJhbnNwb3J0LmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlbnRTdGF0ZS5vcGVyYXRvckxpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUub3BlcmF0b3JMaXN0Lmxhc3RDaHVuayA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW50ZXJuYWxSZW5kZXJUYXNrIG9mIGludGVudFN0YXRlLnJlbmRlclRhc2tzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcm5hbFJlbmRlclRhc2sub3BlcmF0b3JMaXN0Q2hhbmdlZCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3RyeUNsZWFudXAsIF90cnlDbGVhbnVwMikuY2FsbCh0aGlzLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGludGVudFN0YXRlLmRpc3BsYXlSZWFkeUNhcGFiaWxpdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUuZGlzcGxheVJlYWR5Q2FwYWJpbGl0eS5yZWplY3QocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGludGVudFN0YXRlLm9wTGlzdFJlYWRDYXBhYmlsaXR5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLm9wTGlzdFJlYWRDYXBhYmlsaXR5LnJlamVjdChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IHJlYXNvbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgcHVtcCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfYWJvcnRPcGVyYXRvckxpc3QoX3JlZjcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yY2UgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjc7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGludGVudFN0YXRlLnN0cmVhbVJlYWRlckNhbmNlbFRpbWVvdXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFyVGltZW91dChpbnRlbnRTdGF0ZS5zdHJlYW1SZWFkZXJDYW5jZWxUaW1lb3V0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLnN0cmVhbVJlYWRlckNhbmNlbFRpbWVvdXQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZm9yY2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlbnRTdGF0ZS5yZW5kZXJUYXNrcy5zaXplID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZWFzb24gaW5zdGFuY2VvZiBfZGlzcGxheV91dGlscy5SZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGVsYXkgPSBSRU5ERVJJTkdfQ0FOQ0VMTEVEX1RJTUVPVVQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlYXNvbi5leHRyYURlbGF5ID4gMCAmJiByZWFzb24uZXh0cmFEZWxheSA8IDEwMDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsYXkgKz0gcmVhc29uLmV4dHJhRGVsYXk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLnN0cmVhbVJlYWRlckNhbmNlbFRpbWVvdXQgPSBzZXRUaW1lb3V0KCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyQ2FuY2VsVGltZW91dCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Fib3J0T3BlcmF0b3JMaXN0KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yY2U6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgZGVsYXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5zdHJlYW1SZWFkZXIuY2FuY2VsKG5ldyBfdXRpbC5BYm9ydEV4Y2VwdGlvbihyZWFzb24ubWVzc2FnZSkpLmNhdGNoKCgpID0+IHt9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3RyYW5zcG9ydC5kZXN0cm95ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IFtjdXJDYWNoZUtleSwgY3VySW50ZW50U3RhdGVdIG9mIHRoaXMuX2ludGVudFN0YXRlcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1ckludGVudFN0YXRlID09PSBpbnRlbnRTdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ludGVudFN0YXRlcy5kZWxldGUoY3VyQ2FjaGVLZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xlYW51cCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgc3RhdHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9zdGF0czsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERlBhZ2VQcm94eSA9IFBERlBhZ2VQcm94eTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF90cnlDbGVhbnVwMigpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgZGVsYXllZCA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfYWJvcnREZWxheWVkQ2xlYW51cCwgX2Fib3J0RGVsYXllZENsZWFudXAyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wZW5kaW5nQ2xlYW51cCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoZGVsYXllZCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2RlbGF5ZWRDbGVhbnVwVGltZW91dCwgc2V0VGltZW91dCgoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2RlbGF5ZWRDbGVhbnVwVGltZW91dCwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF90cnlDbGVhbnVwLCBfdHJ5Q2xlYW51cDIpLmNhbGwodGhpcywgZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICB9LCBERUxBWUVEX0NMRUFOVVBfVElNRU9VVCkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJUYXNrcywKICAgICAgICAgICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0CiAgICAgICAgICAgICAgICAgICAgfSBvZiB0aGlzLl9pbnRlbnRTdGF0ZXMudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlbmRlclRhc2tzLnNpemUgPiAwIHx8ICFvcGVyYXRvckxpc3QubGFzdENodW5rKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGhpcy5faW50ZW50U3RhdGVzLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5vYmpzLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9wZW5kaW5nQ2xlYW51cCwgZmFsc2UpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2Fib3J0RGVsYXllZENsZWFudXAyKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlbGF5ZWRDbGVhbnVwVGltZW91dCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXJUaW1lb3V0KF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVsYXllZENsZWFudXBUaW1lb3V0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZGVsYXllZENsZWFudXBUaW1lb3V0LCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBMb29wYmFja1BvcnQgewogICAgICAgICAgICAgICAgICAgICNsaXN0ZW5lcnMgPSBuZXcgU2V0KCk7CiAgICAgICAgICAgICAgICAgICAgI2RlZmVycmVkID0gUHJvbWlzZS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgcG9zdE1lc3NhZ2Uob2JqLCB0cmFuc2ZlcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBldmVudCA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGE6IHN0cnVjdHVyZWRDbG9uZShvYmosIHRyYW5zZmVyID8gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zZmVyCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IDogbnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jZGVmZXJyZWQudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpc3RlbmVyIG9mIHRoaXMuI2xpc3RlbmVycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpc3RlbmVyLmNhbGwodGhpcywgZXZlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkRXZlbnRMaXN0ZW5lcihuYW1lLCBsaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNsaXN0ZW5lcnMuYWRkKGxpc3RlbmVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlRXZlbnRMaXN0ZW5lcihuYW1lLCBsaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNsaXN0ZW5lcnMuZGVsZXRlKGxpc3RlbmVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGVybWluYXRlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNsaXN0ZW5lcnMuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkxvb3BiYWNrUG9ydCA9IExvb3BiYWNrUG9ydDsKICAgICAgICAgICAgICAgIGNvbnN0IFBERldvcmtlclV0aWwgPSB7CiAgICAgICAgICAgICAgICAgICAgaXNXb3JrZXJEaXNhYmxlZDogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgZmFsbGJhY2tXb3JrZXJTcmM6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgZmFrZVdvcmtlcklkOiAwCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZXb3JrZXJVdGlsID0gUERGV29ya2VyVXRpbDsKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZiAoX2lzX25vZGUuaXNOb2RlSlMgJiYgdHlwZW9mIHJlcXVpcmUgPT09ICJmdW5jdGlvbiIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyVXRpbC5pc1dvcmtlckRpc2FibGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyVXRpbC5mYWxsYmFja1dvcmtlclNyYyA9ICIuL3BkZi53b3JrZXIuanMiOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIGRvY3VtZW50ID09PSAib2JqZWN0IikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2RvY3VtZW50LCBfZG9jdW1lbnQkY3VycmVudFNjcmk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBkZmpzRmlsZVBhdGggPSAoX2RvY3VtZW50ID0gZG9jdW1lbnQpID09PSBudWxsIHx8IF9kb2N1bWVudCA9PT0gdm9pZCAwID8gdm9pZCAwIDogKF9kb2N1bWVudCRjdXJyZW50U2NyaSA9IF9kb2N1bWVudC5jdXJyZW50U2NyaXB0KSA9PT0gbnVsbCB8fCBfZG9jdW1lbnQkY3VycmVudFNjcmkgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9kb2N1bWVudCRjdXJyZW50U2NyaS5zcmM7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwZGZqc0ZpbGVQYXRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBQREZXb3JrZXJVdGlsLmZhbGxiYWNrV29ya2VyU3JjID0gcGRmanNGaWxlUGF0aC5yZXBsYWNlKC8oXC4oPzptaW5cLik/anMpKFw/LiopPyQvaSwgIi53b3JrZXIkMSQyIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyVXRpbC5pc1NhbWVPcmlnaW4gPSBmdW5jdGlvbiAoYmFzZVVybCwgb3RoZXJVcmwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJhc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYXNlID0gbmV3IFVSTChiYXNlVXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghYmFzZS5vcmlnaW4gfHwgYmFzZS5vcmlnaW4gPT09ICJudWxsIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG90aGVyID0gbmV3IFVSTChvdGhlclVybCwgYmFzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBiYXNlLm9yaWdpbiA9PT0gb3RoZXIub3JpZ2luOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyVXRpbC5jcmVhdGVDRE5XcmFwcGVyID0gZnVuY3Rpb24gKHVybCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3cmFwcGVyID0gYGltcG9ydFNjcmlwdHMoIiR7dXJsfSIpO2A7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBVUkwuY3JlYXRlT2JqZWN0VVJMKG5ldyBCbG9iKFt3cmFwcGVyXSkpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQREZXb3JrZXIgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyAjd29ya2VyUG9ydHMgPSBuZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZSA9IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb3J0ID0gbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZlcmJvc2l0eSA9ICgwLCBfdXRpbC5nZXRWZXJib3NpdHlMZXZlbCkoKQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBvcnQgJiYgUERGV29ya2VyLiN3b3JrZXJQb3J0cy5oYXMocG9ydCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiQ2Fubm90IHVzZSBtb3JlIHRoYW4gb25lIFBERldvcmtlciBwZXIgcG9ydC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hbWUgPSBuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3Ryb3llZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZlcmJvc2l0eSA9IHZlcmJvc2l0eTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wb3J0ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fd2ViV29ya2VyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbWVzc2FnZUhhbmRsZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocG9ydCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyLiN3b3JrZXJQb3J0cy5zZXQocG9ydCwgdGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pbml0aWFsaXplRnJvbVBvcnQocG9ydCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faW5pdGlhbGl6ZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJvbWlzZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3JlYWR5Q2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcG9ydCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3BvcnQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBtZXNzYWdlSGFuZGxlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX21lc3NhZ2VIYW5kbGVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfaW5pdGlhbGl6ZUZyb21Qb3J0KHBvcnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcG9ydCA9IHBvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX21lc3NhZ2VIYW5kbGVyID0gbmV3IF9tZXNzYWdlX2hhbmRsZXIuTWVzc2FnZUhhbmRsZXIoIm1haW4iLCAid29ya2VyIiwgcG9ydCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX21lc3NhZ2VIYW5kbGVyLm9uKCJyZWFkeSIsIGZ1bmN0aW9uICgpIHt9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbWVzc2FnZUhhbmRsZXIuc2VuZCgiY29uZmlndXJlIiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmVyYm9zaXR5OiB0aGlzLnZlcmJvc2l0eQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2luaXRpYWxpemUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghUERGV29ya2VyVXRpbC5pc1dvcmtlckRpc2FibGVkICYmICFQREZXb3JrZXIuX21haW5UaHJlYWRXb3JrZXJNZXNzYWdlSGFuZGxlcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXJTcmMKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBQREZXb3JrZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghUERGV29ya2VyVXRpbC5pc1NhbWVPcmlnaW4od2luZG93LmxvY2F0aW9uLmhyZWYsIHdvcmtlclNyYykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd29ya2VyU3JjID0gUERGV29ya2VyVXRpbC5jcmVhdGVDRE5XcmFwcGVyKG5ldyBVUkwod29ya2VyU3JjLCB3aW5kb3cubG9jYXRpb24pLmhyZWYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3b3JrZXIgPSBuZXcgV29ya2VyKHdvcmtlclNyYyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWVzc2FnZUhhbmRsZXIgPSBuZXcgX21lc3NhZ2VfaGFuZGxlci5NZXNzYWdlSGFuZGxlcigibWFpbiIsICJ3b3JrZXIiLCB3b3JrZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRlcm1pbmF0ZUVhcmx5ID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZXJyb3IiLCBvbldvcmtlckVycm9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIuZGVzdHJveSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIudGVybWluYXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnJlamVjdChuZXcgRXJyb3IoIldvcmtlciB3YXMgZGVzdHJveWVkIikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0dXBGYWtlV29ya2VyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9uV29ya2VyRXJyb3IgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5fd2ViV29ya2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXJtaW5hdGVFYXJseSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigiZXJyb3IiLCBvbldvcmtlckVycm9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlSGFuZGxlci5vbigidGVzdCIsIGRhdGEgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZXJyb3IiLCBvbldvcmtlckVycm9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGVzdHJveWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXJtaW5hdGVFYXJseSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tZXNzYWdlSGFuZGxlciA9IG1lc3NhZ2VIYW5kbGVyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcG9ydCA9IHdvcmtlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3dlYldvcmtlciA9IHdvcmtlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWR5Q2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlSGFuZGxlci5zZW5kKCJjb25maWd1cmUiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmVyYm9zaXR5OiB0aGlzLnZlcmJvc2l0eQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXR1cEZha2VXb3JrZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLmRlc3Ryb3koKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdvcmtlci50ZXJtaW5hdGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJyZWFkeSIsIGRhdGEgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZXJyb3IiLCBvbldvcmtlckVycm9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGVzdHJveWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXJtaW5hdGVFYXJseSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZW5kVGVzdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXR1cEZha2VXb3JrZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNlbmRUZXN0ID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXN0T2JqID0gbmV3IFVpbnQ4QXJyYXkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIuc2VuZCgidGVzdCIsIHRlc3RPYmosIFt0ZXN0T2JqLmJ1ZmZlcl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VuZFRlc3QoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJUaGUgd29ya2VyIGhhcyBiZWVuIGRpc2FibGVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldHVwRmFrZVdvcmtlcigpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfc2V0dXBGYWtlV29ya2VyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIVBERldvcmtlclV0aWwuaXNXb3JrZXJEaXNhYmxlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJTZXR0aW5nIHVwIGZha2Ugd29ya2VyLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyVXRpbC5pc1dvcmtlckRpc2FibGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBQREZXb3JrZXIuX3NldHVwRmFrZVdvcmtlckdsb2JhbC50aGVuKFdvcmtlck1lc3NhZ2VIYW5kbGVyID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWR5Q2FwYWJpbGl0eS5yZWplY3QobmV3IEVycm9yKCJXb3JrZXIgd2FzIGRlc3Ryb3llZCIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb3J0ID0gbmV3IExvb3BiYWNrUG9ydCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcG9ydCA9IHBvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IGBmYWtlJHtQREZXb3JrZXJVdGlsLmZha2VXb3JrZXJJZCsrfWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3b3JrZXJIYW5kbGVyID0gbmV3IF9tZXNzYWdlX2hhbmRsZXIuTWVzc2FnZUhhbmRsZXIoaWQgKyAiX3dvcmtlciIsIGlkLCBwb3J0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIFdvcmtlck1lc3NhZ2VIYW5kbGVyLnNldHVwKHdvcmtlckhhbmRsZXIsIHBvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWVzc2FnZUhhbmRsZXIgPSBuZXcgX21lc3NhZ2VfaGFuZGxlci5NZXNzYWdlSGFuZGxlcihpZCwgaWQgKyAiX3dvcmtlciIsIHBvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbWVzc2FnZUhhbmRsZXIgPSBtZXNzYWdlSGFuZGxlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWR5Q2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlSGFuZGxlci5zZW5kKCJjb25maWd1cmUiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmVyYm9zaXR5OiB0aGlzLnZlcmJvc2l0eQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pLmNhdGNoKHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkeUNhcGFiaWxpdHkucmVqZWN0KG5ldyBFcnJvcihgU2V0dGluZyB1cCBmYWtlIHdvcmtlciBmYWlsZWQ6ICIke3JlYXNvbi5tZXNzYWdlfSIuYCkpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZGVzdHJveSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kZXN0cm95ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fd2ViV29ya2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl93ZWJXb3JrZXIudGVybWluYXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl93ZWJXb3JrZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIFBERldvcmtlci4jd29ya2VyUG9ydHMuZGVsZXRlKHRoaXMuX3BvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wb3J0ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX21lc3NhZ2VIYW5kbGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tZXNzYWdlSGFuZGxlci5kZXN0cm95KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tZXNzYWdlSGFuZGxlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGZyb21Qb3J0KHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIShwYXJhbXMgIT09IG51bGwgJiYgcGFyYW1zICE9PSB2b2lkIDAgJiYgcGFyYW1zLnBvcnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIlBERldvcmtlci5mcm9tUG9ydCAtIGludmFsaWQgbWV0aG9kIHNpZ25hdHVyZS4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy4jd29ya2VyUG9ydHMuaGFzKHBhcmFtcy5wb3J0KSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI3dvcmtlclBvcnRzLmdldChwYXJhbXMucG9ydCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBQREZXb3JrZXIocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCB3b3JrZXJTcmMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfd29ya2VyX29wdGlvbnMuR2xvYmFsV29ya2VyT3B0aW9ucy53b3JrZXJTcmMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfd29ya2VyX29wdGlvbnMuR2xvYmFsV29ya2VyT3B0aW9ucy53b3JrZXJTcmM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFBERldvcmtlclV0aWwuZmFsbGJhY2tXb3JrZXJTcmMgIT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2lzX25vZGUuaXNOb2RlSlMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuZGVwcmVjYXRlZCkoJ05vICJHbG9iYWxXb3JrZXJPcHRpb25zLndvcmtlclNyYyIgc3BlY2lmaWVkLicpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFBERldvcmtlclV0aWwuZmFsbGJhY2tXb3JrZXJTcmM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdObyAiR2xvYmFsV29ya2VyT3B0aW9ucy53b3JrZXJTcmMiIHNwZWNpZmllZC4nKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBfbWFpblRocmVhZFdvcmtlck1lc3NhZ2VIYW5kbGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9nbG9iYWxUaGlzJHBkZmpzV29yazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoKF9nbG9iYWxUaGlzJHBkZmpzV29yayA9IGdsb2JhbFRoaXMucGRmanNXb3JrZXIpID09PSBudWxsIHx8IF9nbG9iYWxUaGlzJHBkZmpzV29yayA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2dsb2JhbFRoaXMkcGRmanNXb3JrLldvcmtlck1lc3NhZ2VIYW5kbGVyKSB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBfc2V0dXBGYWtlV29ya2VyR2xvYmFsKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsb2FkZXIgPSBhc3luYyAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYWluV29ya2VyTWVzc2FnZUhhbmRsZXIgPSB0aGlzLl9tYWluVGhyZWFkV29ya2VyTWVzc2FnZUhhbmRsZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobWFpbldvcmtlck1lc3NhZ2VIYW5kbGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1haW5Xb3JrZXJNZXNzYWdlSGFuZGxlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfaXNfbm9kZS5pc05vZGVKUyAmJiB0eXBlb2YgcmVxdWlyZSA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdvcmtlciA9IGV2YWwoInJlcXVpcmUiKSh0aGlzLndvcmtlclNyYyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5Xb3JrZXJNZXNzYWdlSGFuZGxlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF3YWl0ICgwLCBfZGlzcGxheV91dGlscy5sb2FkU2NyaXB0KSh0aGlzLndvcmtlclNyYyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gd2luZG93LnBkZmpzV29ya2VyLldvcmtlck1lc3NhZ2VIYW5kbGVyOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIl9zZXR1cEZha2VXb3JrZXJHbG9iYWwiLCBsb2FkZXIoKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZXb3JrZXIgPSBQREZXb3JrZXI7CiAgICAgICAgICAgICAgICB2YXIgX21ldGhvZFByb21pc2VzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX3BhZ2VDYWNoZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9wYWdlUHJvbWlzZXMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY2FjaGVTaW1wbGVNZXRob2QgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIFdvcmtlclRyYW5zcG9ydCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobWVzc2FnZUhhbmRsZXIsIGxvYWRpbmdUYXNrLCBuZXR3b3JrU3RyZWFtLCBwYXJhbXMsIGZhY3RvcnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9jYWNoZVNpbXBsZU1ldGhvZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9tZXRob2RQcm9taXNlcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbmV3IE1hcCgpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcGFnZUNhY2hlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgTWFwKCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9wYWdlUHJvbWlzZXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBNYXAoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tZXNzYWdlSGFuZGxlciA9IG1lc3NhZ2VIYW5kbGVyOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxvYWRpbmdUYXNrID0gbG9hZGluZ1Rhc2s7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbW9uT2JqcyA9IG5ldyBQREZPYmplY3RzKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZm9udExvYWRlciA9IG5ldyBfZm9udF9sb2FkZXIuRm9udExvYWRlcih7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvd25lckRvY3VtZW50OiBwYXJhbXMub3duZXJEb2N1bWVudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlRWxlbWVudDogcGFyYW1zLnN0eWxlRWxlbWVudAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFyYW1zID0gcGFyYW1zOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkgPSBmYWN0b3J5LmNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsdGVyRmFjdG9yeSA9IGZhY3RvcnkuZmlsdGVyRmFjdG9yeTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jTWFwUmVhZGVyRmFjdG9yeSA9IGZhY3RvcnkuY01hcFJlYWRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhbmRhcmRGb250RGF0YUZhY3RvcnkgPSBmYWN0b3J5LnN0YW5kYXJkRm9udERhdGFGYWN0b3J5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3Ryb3llZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3Ryb3lDYXBhYmlsaXR5ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFzc3dvcmRDYXBhYmlsaXR5ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbmV0d29ya1N0cmVhbSA9IG5ldHdvcmtTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZWFkZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sYXN0UHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRvd25sb2FkSW5mb0NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0dXBNZXNzYWdlSGFuZGxlcigpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgYW5ub3RhdGlvblN0b3JhZ2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiYW5ub3RhdGlvblN0b3JhZ2UiLCBuZXcgX2Fubm90YXRpb25fc3RvcmFnZS5Bbm5vdGF0aW9uU3RvcmFnZSgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UmVuZGVyaW5nSW50ZW50KGludGVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYW5ub3RhdGlvbk1vZGUgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IF91dGlsLkFubm90YXRpb25Nb2RlLkVOQUJMRTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHByaW50QW5ub3RhdGlvblN0b3JhZ2UgPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpc09wTGlzdCA9IGFyZ3VtZW50cy5sZW5ndGggPiAzICYmIGFyZ3VtZW50c1szXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzNdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZW5kZXJpbmdJbnRlbnQgPSBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLkRJU1BMQVk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBhbm5vdGF0aW9uTWFwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChpbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImFueSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyaW5nSW50ZW50ID0gX3V0aWwuUmVuZGVyaW5nSW50ZW50RmxhZy5BTlk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJkaXNwbGF5IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgInByaW50IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJpbmdJbnRlbnQgPSBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLlBSSU5UOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYGdldFJlbmRlcmluZ0ludGVudCAtIGludmFsaWQgaW50ZW50OiAke2ludGVudH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGFubm90YXRpb25Nb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25Nb2RlLkRJU0FCTEU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyaW5nSW50ZW50ICs9IF91dGlsLlJlbmRlcmluZ0ludGVudEZsYWcuQU5OT1RBVElPTlNfRElTQUJMRTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvbk1vZGUuRU5BQkxFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uTW9kZS5FTkFCTEVfRk9STVM6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyaW5nSW50ZW50ICs9IF91dGlsLlJlbmRlcmluZ0ludGVudEZsYWcuQU5OT1RBVElPTlNfRk9STVM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25Nb2RlLkVOQUJMRV9TVE9SQUdFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlcmluZ0ludGVudCArPSBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLkFOTk9UQVRJT05TX1NUT1JBR0U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYW5ub3RhdGlvblN0b3JhZ2UgPSByZW5kZXJpbmdJbnRlbnQgJiBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLlBSSU5UICYmIHByaW50QW5ub3RhdGlvblN0b3JhZ2UgaW5zdGFuY2VvZiBfYW5ub3RhdGlvbl9zdG9yYWdlLlByaW50QW5ub3RhdGlvblN0b3JhZ2UgPyBwcmludEFubm90YXRpb25TdG9yYWdlIDogdGhpcy5hbm5vdGF0aW9uU3RvcmFnZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uTWFwID0gYW5ub3RhdGlvblN0b3JhZ2Uuc2VyaWFsaXphYmxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYGdldFJlbmRlcmluZ0ludGVudCAtIGludmFsaWQgYW5ub3RhdGlvbk1vZGU6ICR7YW5ub3RhdGlvbk1vZGV9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzT3BMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJpbmdJbnRlbnQgKz0gX3V0aWwuUmVuZGVyaW5nSW50ZW50RmxhZy5PUExJU1Q7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlcmluZ0ludGVudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlS2V5OiBgJHtyZW5kZXJpbmdJbnRlbnR9XyR7X2Fubm90YXRpb25fc3RvcmFnZS5Bbm5vdGF0aW9uU3RvcmFnZS5nZXRIYXNoKGFubm90YXRpb25NYXApfWAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uU3RvcmFnZU1hcDogYW5ub3RhdGlvbk1hcAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kZXN0cm95Q2FwYWJpbGl0eSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZGVzdHJveUNhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3Ryb3llZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdHJveUNhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9wYXNzd29yZENhcGFiaWxpdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Bhc3N3b3JkQ2FwYWJpbGl0eS5yZWplY3QobmV3IEVycm9yKCJXb3JrZXIgd2FzIGRlc3Ryb3llZCBkdXJpbmcgb25QYXNzd29yZCBjYWxsYmFjayIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3YWl0T24gPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBwYWdlIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfcGFnZUNhY2hlKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2FpdE9uLnB1c2gocGFnZS5fZGVzdHJveSgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3BhZ2VDYWNoZSkuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wYWdlUHJvbWlzZXMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmhhc093blByb3BlcnR5KCJhbm5vdGF0aW9uU3RvcmFnZSIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFubm90YXRpb25TdG9yYWdlLnJlc2V0TW9kaWZpZWQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXJtaW5hdGVkID0gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIlRlcm1pbmF0ZSIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICB3YWl0T24ucHVzaCh0ZXJtaW5hdGVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgUHJvbWlzZS5hbGwod2FpdE9uKS50aGVuKCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbW9uT2Jqcy5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5mb250TG9hZGVyLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX21ldGhvZFByb21pc2VzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5maWx0ZXJGYWN0b3J5LmRlc3Ryb3koKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9uZXR3b3JrU3RyZWFtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbmV0d29ya1N0cmVhbS5jYW5jZWxBbGxSZXF1ZXN0cyhuZXcgX3V0aWwuQWJvcnRFeGNlcHRpb24oIldvcmtlciB3YXMgdGVybWluYXRlZC4iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5tZXNzYWdlSGFuZGxlcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWVzc2FnZUhhbmRsZXIuZGVzdHJveSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWVzc2FnZUhhbmRsZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kZXN0cm95Q2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIHRoaXMuZGVzdHJveUNhcGFiaWxpdHkucmVqZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZGVzdHJveUNhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0dXBNZXNzYWdlSGFuZGxlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkaW5nVGFzawogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdGhpczsKICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIub24oIkdldFJlYWRlciIsIChkYXRhLCBzaW5rKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KSh0aGlzLl9uZXR3b3JrU3RyZWFtLCAiR2V0UmVhZGVyIC0gbm8gYElQREZTdHJlYW1gIGluc3RhbmNlIGF2YWlsYWJsZS4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZWFkZXIgPSB0aGlzLl9uZXR3b3JrU3RyZWFtLmdldEZ1bGxSZWFkZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZWFkZXIub25Qcm9ncmVzcyA9IGV2dCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbGFzdFByb2dyZXNzID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkZWQ6IGV2dC5sb2FkZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsOiBldnQudG90YWwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpbmsub25QdWxsID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZWFkZXIucmVhZCgpLnRoZW4oZnVuY3Rpb24gKF9yZWY4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWY4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHZhbHVlIGluc3RhbmNlb2YgQXJyYXlCdWZmZXIsICJHZXRSZWFkZXIgLSBleHBlY3RlZCBhbiBBcnJheUJ1ZmZlci4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5lbnF1ZXVlKG5ldyBVaW50OEFycmF5KHZhbHVlKSwgMSwgW3ZhbHVlXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5lcnJvcihyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpbmsub25DYW5jZWwgPSByZWFzb24gPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZWFkZXIuY2FuY2VsKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5yZWFkeS5jYXRjaChyZWFkeVJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IHJlYWR5UmVhc29uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJSZWFkZXJIZWFkZXJzUmVhZHkiLCBkYXRhID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlYWRlcnNDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZnVsbFJlYWRlciA9IHRoaXMuX2Z1bGxSZWFkZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmdWxsUmVhZGVyLmhlYWRlcnNSZWFkeS50aGVuKCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWZ1bGxSZWFkZXIuaXNTdHJlYW1pbmdTdXBwb3J0ZWQgfHwgIWZ1bGxSZWFkZXIuaXNSYW5nZVN1cHBvcnRlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fbGFzdFByb2dyZXNzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2xvYWRpbmdUYXNrJG9uUHJvZ3JlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF9sb2FkaW5nVGFzayRvblByb2dyZSA9IGxvYWRpbmdUYXNrLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF9sb2FkaW5nVGFzayRvblByb2dyZSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2xvYWRpbmdUYXNrJG9uUHJvZ3JlLmNhbGwobG9hZGluZ1Rhc2ssIHRoaXMuX2xhc3RQcm9ncmVzcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnVsbFJlYWRlci5vblByb2dyZXNzID0gZXZ0ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfbG9hZGluZ1Rhc2skb25Qcm9ncmUyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF9sb2FkaW5nVGFzayRvblByb2dyZTIgPSBsb2FkaW5nVGFzay5vblByb2dyZXNzKSA9PT0gbnVsbCB8fCBfbG9hZGluZ1Rhc2skb25Qcm9ncmUyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfbG9hZGluZ1Rhc2skb25Qcm9ncmUyLmNhbGwobG9hZGluZ1Rhc2ssIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkZWQ6IGV2dC5sb2FkZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWw6IGV2dC50b3RhbAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnNDYXBhYmlsaXR5LnJlc29sdmUoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1N0cmVhbWluZ1N1cHBvcnRlZDogZnVsbFJlYWRlci5pc1N0cmVhbWluZ1N1cHBvcnRlZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSYW5nZVN1cHBvcnRlZDogZnVsbFJlYWRlci5pc1JhbmdlU3VwcG9ydGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50TGVuZ3RoOiBmdWxsUmVhZGVyLmNvbnRlbnRMZW5ndGgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIGhlYWRlcnNDYXBhYmlsaXR5LnJlamVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaGVhZGVyc0NhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJHZXRSYW5nZVJlYWRlciIsIChkYXRhLCBzaW5rKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KSh0aGlzLl9uZXR3b3JrU3RyZWFtLCAiR2V0UmFuZ2VSZWFkZXIgLSBubyBgSVBERlN0cmVhbWAgaW5zdGFuY2UgYXZhaWxhYmxlLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFuZ2VSZWFkZXIgPSB0aGlzLl9uZXR3b3JrU3RyZWFtLmdldFJhbmdlUmVhZGVyKGRhdGEuYmVnaW4sIGRhdGEuZW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghcmFuZ2VSZWFkZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW5rLmNsb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5vblB1bGwgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2VSZWFkZXIucmVhZCgpLnRoZW4oZnVuY3Rpb24gKF9yZWY5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWY5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHZhbHVlIGluc3RhbmNlb2YgQXJyYXlCdWZmZXIsICJHZXRSYW5nZVJlYWRlciAtIGV4cGVjdGVkIGFuIEFycmF5QnVmZmVyLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW5rLmVucXVldWUobmV3IFVpbnQ4QXJyYXkodmFsdWUpLCAxLCBbdmFsdWVdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KS5jYXRjaChyZWFzb24gPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW5rLmVycm9yKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5vbkNhbmNlbCA9IHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2VSZWFkZXIuY2FuY2VsKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5yZWFkeS5jYXRjaChyZWFkeVJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IHJlYWR5UmVhc29uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJHZXREb2MiLCBfcmVmMTAgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZGZJbmZvCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjEwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbnVtUGFnZXMgPSBwZGZJbmZvLm51bVBhZ2VzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faHRtbEZvclhmYSA9IHBkZkluZm8uaHRtbEZvclhmYTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBwZGZJbmZvLmh0bWxGb3JYZmE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkaW5nVGFzay5fY2FwYWJpbGl0eS5yZXNvbHZlKG5ldyBQREZEb2N1bWVudFByb3h5KHBkZkluZm8sIHRoaXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJEb2NFeGNlcHRpb24iLCBmdW5jdGlvbiAoZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZWFzb247CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGV4Lm5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJQYXNzd29yZEV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbiA9IG5ldyBfdXRpbC5QYXNzd29yZEV4Y2VwdGlvbihleC5tZXNzYWdlLCBleC5jb2RlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiSW52YWxpZFBERkV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbiA9IG5ldyBfdXRpbC5JbnZhbGlkUERGRXhjZXB0aW9uKGV4Lm1lc3NhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJNaXNzaW5nUERGRXhjZXB0aW9uIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uID0gbmV3IF91dGlsLk1pc3NpbmdQREZFeGNlcHRpb24oZXgubWVzc2FnZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbiA9IG5ldyBfdXRpbC5VbmV4cGVjdGVkUmVzcG9uc2VFeGNlcHRpb24oZXgubWVzc2FnZSwgZXguc3RhdHVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiVW5rbm93bkVycm9yRXhjZXB0aW9uIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uID0gbmV3IF91dGlsLlVua25vd25FcnJvckV4Y2VwdGlvbihleC5tZXNzYWdlLCBleC5kZXRhaWxzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiRG9jRXhjZXB0aW9uIC0gZXhwZWN0ZWQgYSB2YWxpZCBFcnJvci4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRpbmdUYXNrLl9jYXBhYmlsaXR5LnJlamVjdChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIub24oIlBhc3N3b3JkUmVxdWVzdCIsIGV4Y2VwdGlvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXNzd29yZENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobG9hZGluZ1Rhc2sub25QYXNzd29yZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVwZGF0ZVBhc3N3b3JkID0gcGFzc3dvcmQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFzc3dvcmQgaW5zdGFuY2VvZiBFcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFzc3dvcmRDYXBhYmlsaXR5LnJlamVjdChwYXNzd29yZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXNzd29yZENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFzc3dvcmQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkaW5nVGFzay5vblBhc3N3b3JkKHVwZGF0ZVBhc3N3b3JkLCBleGNlcHRpb24uY29kZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFzc3dvcmRDYXBhYmlsaXR5LnJlamVjdChleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXNzd29yZENhcGFiaWxpdHkucmVqZWN0KG5ldyBfdXRpbC5QYXNzd29yZEV4Y2VwdGlvbihleGNlcHRpb24ubWVzc2FnZSwgZXhjZXB0aW9uLmNvZGUpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9wYXNzd29yZENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJEYXRhTG9hZGVkIiwgZGF0YSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2xvYWRpbmdUYXNrJG9uUHJvZ3JlMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfbG9hZGluZ1Rhc2skb25Qcm9ncmUzID0gbG9hZGluZ1Rhc2sub25Qcm9ncmVzcykgPT09IG51bGwgfHwgX2xvYWRpbmdUYXNrJG9uUHJvZ3JlMyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2xvYWRpbmdUYXNrJG9uUHJvZ3JlMy5jYWxsKGxvYWRpbmdUYXNrLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBkYXRhLmxlbmd0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b3RhbDogZGF0YS5sZW5ndGgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kb3dubG9hZEluZm9DYXBhYmlsaXR5LnJlc29sdmUoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlSGFuZGxlci5vbigiU3RhcnRSZW5kZXJQYWdlIiwgZGF0YSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kZXN0cm95ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWdlID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wYWdlQ2FjaGUpLmdldChkYXRhLnBhZ2VJbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlLl9zdGFydFJlbmRlclBhZ2UoZGF0YS50cmFuc3BhcmVuY3ksIGRhdGEuY2FjaGVLZXkpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIub24oImNvbW1vbm9iaiIsIF9yZWYxMSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2dsb2JhbFRoaXMkRm9udEluc3BlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IFtpZCwgdHlwZSwgZXhwb3J0ZWREYXRhXSA9IF9yZWYxMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNvbW1vbk9ianMuaGFzKGlkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkZvbnQiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJhbXMgPSB0aGlzLl9wYXJhbXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgiZXJyb3IiIGluIGV4cG9ydGVkRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZXhwb3J0ZWRFcnJvciA9IGV4cG9ydGVkRGF0YS5lcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgRXJyb3IgZHVyaW5nIGZvbnQgbG9hZGluZzogJHtleHBvcnRlZEVycm9yfWApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzLnJlc29sdmUoaWQsIGV4cG9ydGVkRXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW5zcGVjdEZvbnQgPSBwYXJhbXMucGRmQnVnICYmIChfZ2xvYmFsVGhpcyRGb250SW5zcGUgPSBnbG9iYWxUaGlzLkZvbnRJbnNwZWN0b3IpICE9PSBudWxsICYmIF9nbG9iYWxUaGlzJEZvbnRJbnNwZSAhPT0gdm9pZCAwICYmIF9nbG9iYWxUaGlzJEZvbnRJbnNwZS5lbmFibGVkID8gKGZvbnQsIHVybCkgPT4gZ2xvYmFsVGhpcy5Gb250SW5zcGVjdG9yLmZvbnRBZGRlZChmb250LCB1cmwpIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udCA9IG5ldyBfZm9udF9sb2FkZXIuRm9udEZhY2VPYmplY3QoZXhwb3J0ZWREYXRhLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQ6IHBhcmFtcy5pc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlRm9udEZhY2U6IHBhcmFtcy5kaXNhYmxlRm9udEZhY2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVFcnJvcnM6IHBhcmFtcy5pZ25vcmVFcnJvcnMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnNwZWN0Rm9udAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5mb250TG9hZGVyLmJpbmQoZm9udCkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBtZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkZvbnRGYWxsYmFjayIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pLmZpbmFsbHkoKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFwYXJhbXMuZm9udEV4dHJhUHJvcGVydGllcyAmJiBmb250LmRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb250LmRhdGEgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzLnJlc29sdmUoaWQsIGZvbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiRm9udFBhdGgiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkltYWdlIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJQYXR0ZXJuIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzLnJlc29sdmUoaWQsIGV4cG9ydGVkRGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgR290IHVua25vd24gY29tbW9uIG9iamVjdCB0eXBlICR7dHlwZX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJvYmoiLCBfcmVmMTIgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IFtpZCwgcGFnZUluZGV4LCB0eXBlLCBpbWFnZURhdGFdID0gX3JlZjEyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGVzdHJveWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFnZVByb3h5ID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wYWdlQ2FjaGUpLmdldChwYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhZ2VQcm94eS5vYmpzLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJJbWFnZSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VQcm94eS5vYmpzLnJlc29sdmUoaWQsIGltYWdlRGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbWFnZURhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBsZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW1hZ2VEYXRhLmJpdG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBpbWFnZURhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVuZ3RoID0gd2lkdGggKiBoZWlnaHQgKiA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2ltYWdlRGF0YSRkYXRhOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlbmd0aCA9ICgoX2ltYWdlRGF0YSRkYXRhID0gaW1hZ2VEYXRhLmRhdGEpID09PSBudWxsIHx8IF9pbWFnZURhdGEkZGF0YSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2ltYWdlRGF0YSRkYXRhLmxlbmd0aCkgfHwgMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsZW5ndGggPiBfdXRpbC5NQVhfSU1BR0VfU0laRV9UT19DQUNIRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VQcm94eS5fbWF5YmVDbGVhbnVwQWZ0ZXJSZW5kZXIgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlBhdHRlcm4iOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlUHJveHkub2Jqcy5yZXNvbHZlKGlkLCBpbWFnZURhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYEdvdCB1bmtub3duIG9iamVjdCB0eXBlICR7dHlwZX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJEb2NQcm9ncmVzcyIsIGRhdGEgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9sb2FkaW5nVGFzayRvblByb2dyZTQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kZXN0cm95ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX2xvYWRpbmdUYXNrJG9uUHJvZ3JlNCA9IGxvYWRpbmdUYXNrLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF9sb2FkaW5nVGFzayRvblByb2dyZTQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9sb2FkaW5nVGFzayRvblByb2dyZTQuY2FsbChsb2FkaW5nVGFzaywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRlZDogZGF0YS5sb2FkZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWw6IGRhdGEudG90YWwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIub24oIkZldGNoQnVpbHRJbkNNYXAiLCBkYXRhID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdChuZXcgRXJyb3IoIldvcmtlciB3YXMgZGVzdHJveWVkLiIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jTWFwUmVhZGVyRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdChuZXcgRXJyb3IoIkNNYXBSZWFkZXJGYWN0b3J5IG5vdCBpbml0aWFsaXplZCwgc2VlIHRoZSBgdXNlV29ya2VyRmV0Y2hgIHBhcmFtZXRlci4iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jTWFwUmVhZGVyRmFjdG9yeS5mZXRjaChkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJGZXRjaFN0YW5kYXJkRm9udERhdGEiLCBkYXRhID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdChuZXcgRXJyb3IoIldvcmtlciB3YXMgZGVzdHJveWVkLiIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5zdGFuZGFyZEZvbnREYXRhRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdChuZXcgRXJyb3IoIlN0YW5kYXJkRm9udERhdGFGYWN0b3J5IG5vdCBpbml0aWFsaXplZCwgc2VlIHRoZSBgdXNlV29ya2VyRmV0Y2hgIHBhcmFtZXRlci4iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5zdGFuZGFyZEZvbnREYXRhRmFjdG9yeS5mZXRjaChkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERhdGEoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0RGF0YSIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzYXZlRG9jdW1lbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlYWRlcjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuYW5ub3RhdGlvblN0b3JhZ2Uuc2l6ZSA8PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoInNhdmVEb2N1bWVudCBjYWxsZWQgd2hpbGUgYGFubm90YXRpb25TdG9yYWdlYCBpcyBlbXB0eSwgIiArICJwbGVhc2UgdXNlIHRoZSBnZXREYXRhLW1ldGhvZCBpbnN0ZWFkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiU2F2ZURvY3VtZW50IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNQdXJlWGZhOiAhIXRoaXMuX2h0bWxGb3JYZmEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBudW1QYWdlczogdGhpcy5fbnVtUGFnZXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uU3RvcmFnZTogdGhpcy5hbm5vdGF0aW9uU3RvcmFnZS5zZXJpYWxpemFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWxlbmFtZTogKChfdGhpcyRfZnVsbFJlYWRlciA9IHRoaXMuX2Z1bGxSZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVhZGVyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlYWRlci5maWxlbmFtZSkgPz8gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KS5maW5hbGx5KCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvblN0b3JhZ2UucmVzZXRNb2RpZmllZCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGFnZShwYWdlTnVtYmVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghTnVtYmVyLmlzSW50ZWdlcihwYWdlTnVtYmVyKSB8fCBwYWdlTnVtYmVyIDw9IDAgfHwgcGFnZU51bWJlciA+IHRoaXMuX251bVBhZ2VzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZWplY3QobmV3IEVycm9yKCJJbnZhbGlkIHBhZ2UgcmVxdWVzdC4iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFnZUluZGV4ID0gcGFnZU51bWJlciAtIDEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZWRQcm9taXNlID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wYWdlUHJvbWlzZXMpLmdldChwYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2FjaGVkUHJvbWlzZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhY2hlZFByb21pc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJvbWlzZSA9IHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRQYWdlIiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZGV4CiAgICAgICAgICAgICAgICAgICAgICAgIH0pLnRoZW4ocGFnZUluZm8gPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGVzdHJveWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJUcmFuc3BvcnQgZGVzdHJveWVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWdlID0gbmV3IFBERlBhZ2VQcm94eShwYWdlSW5kZXgsIHBhZ2VJbmZvLCB0aGlzLCB0aGlzLl9wYXJhbXMucGRmQnVnKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfcGFnZUNhY2hlKS5zZXQocGFnZUluZGV4LCBwYWdlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwYWdlOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wYWdlUHJvbWlzZXMpLnNldChwYWdlSW5kZXgsIHByb21pc2UpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGFnZUluZGV4KHJlZikgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlZiAhPT0gIm9iamVjdCIgfHwgcmVmID09PSBudWxsIHx8ICFOdW1iZXIuaXNJbnRlZ2VyKHJlZi5udW0pIHx8IHJlZi5udW0gPCAwIHx8ICFOdW1iZXIuaXNJbnRlZ2VyKHJlZi5nZW4pIHx8IHJlZi5nZW4gPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZWplY3QobmV3IEVycm9yKCJJbnZhbGlkIHBhZ2VJbmRleCByZXF1ZXN0LiIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkdldFBhZ2VJbmRleCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG51bTogcmVmLm51bSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdlbjogcmVmLmdlbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0QW5ub3RhdGlvbnMocGFnZUluZGV4LCBpbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRBbm5vdGF0aW9ucyIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJbmRleCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RmllbGRPYmplY3RzKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY2FjaGVTaW1wbGVNZXRob2QsIF9jYWNoZVNpbXBsZU1ldGhvZDIpLmNhbGwodGhpcywgIkdldEZpZWxkT2JqZWN0cyIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXNKU0FjdGlvbnMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jYWNoZVNpbXBsZU1ldGhvZCwgX2NhY2hlU2ltcGxlTWV0aG9kMikuY2FsbCh0aGlzLCAiSGFzSlNBY3Rpb25zIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldENhbGN1bGF0aW9uT3JkZXJJZHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0Q2FsY3VsYXRpb25PcmRlcklkcyIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXREZXN0aW5hdGlvbnMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0RGVzdGluYXRpb25zIiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERlc3RpbmF0aW9uKGlkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgaWQgIT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZWplY3QobmV3IEVycm9yKCJJbnZhbGlkIGRlc3RpbmF0aW9uIHJlcXVlc3QuIikpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0RGVzdGluYXRpb24iLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGFnZUxhYmVscygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRQYWdlTGFiZWxzIiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhZ2VMYXlvdXQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0UGFnZUxheW91dCIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYWdlTW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRQYWdlTW9kZSIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRWaWV3ZXJQcmVmZXJlbmNlcygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRWaWV3ZXJQcmVmZXJlbmNlcyIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRPcGVuQWN0aW9uKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkdldE9wZW5BY3Rpb24iLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0QXR0YWNobWVudHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0QXR0YWNobWVudHMiLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0SmF2YVNjcmlwdCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRKYXZhU2NyaXB0IiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERvY0pTQWN0aW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXREb2NKU0FjdGlvbnMiLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGFnZUpTQWN0aW9ucyhwYWdlSW5kZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRQYWdlSlNBY3Rpb25zIiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZGV4CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRTdHJ1Y3RUcmVlKHBhZ2VJbmRleCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkdldFN0cnVjdFRyZWUiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlSW5kZXgKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE91dGxpbmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0T3V0bGluZSIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRPcHRpb25hbENvbnRlbnRDb25maWcoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0T3B0aW9uYWxDb250ZW50Q29uZmlnIiwgbnVsbCkudGhlbihyZXN1bHRzID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgX29wdGlvbmFsX2NvbnRlbnRfY29uZmlnLk9wdGlvbmFsQ29udGVudENvbmZpZyhyZXN1bHRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBlcm1pc3Npb25zKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkdldFBlcm1pc3Npb25zIiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE1ldGFkYXRhKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBuYW1lID0gIkdldE1ldGFkYXRhIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlZFByb21pc2UgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX21ldGhvZFByb21pc2VzKS5nZXQobmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjYWNoZWRQcm9taXNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FjaGVkUHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwcm9taXNlID0gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UobmFtZSwgbnVsbCkudGhlbihyZXN1bHRzID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlYWRlcjIsIF90aGlzJF9mdWxsUmVhZGVyMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5mbzogcmVzdWx0c1swXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXRhZGF0YTogcmVzdWx0c1sxXSA/IG5ldyBfbWV0YWRhdGEuTWV0YWRhdGEocmVzdWx0c1sxXSkgOiBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lOiAoKF90aGlzJF9mdWxsUmVhZGVyMiA9IHRoaXMuX2Z1bGxSZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVhZGVyMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2Z1bGxSZWFkZXIyLmZpbGVuYW1lKSA/PyBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnRMZW5ndGg6ICgoX3RoaXMkX2Z1bGxSZWFkZXIzID0gdGhpcy5fZnVsbFJlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX2Z1bGxSZWFkZXIzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlYWRlcjMuY29udGVudExlbmd0aCkgPz8gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbWV0aG9kUHJvbWlzZXMpLnNldChuYW1lLCBwcm9taXNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHByb21pc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE1hcmtJbmZvKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkdldE1hcmtJbmZvIiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFzeW5jIHN0YXJ0Q2xlYW51cCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGtlZXBMb2FkZWRGb250cyA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGF3YWl0IHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJDbGVhbnVwIiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcGFnZSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3BhZ2VDYWNoZSkudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNsZWFudXBTdWNjZXNzZnVsID0gcGFnZS5jbGVhbnVwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWNsZWFudXBTdWNjZXNzZnVsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBzdGFydENsZWFudXA6IFBhZ2UgJHtwYWdlLnBhZ2VOdW1iZXJ9IGlzIGN1cnJlbnRseSByZW5kZXJpbmcuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgha2VlcExvYWRlZEZvbnRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZvbnRMb2FkZXIuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX21ldGhvZFByb21pc2VzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbHRlckZhY3RvcnkuZGVzdHJveSh0cnVlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGxvYWRpbmdQYXJhbXMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVBdXRvRmV0Y2gsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmFibGVYZmEKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuX3BhcmFtczsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJsb2FkaW5nUGFyYW1zIiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUF1dG9GZXRjaCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuYWJsZVhmYQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2FjaGVTaW1wbGVNZXRob2QyKG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgZGF0YSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjYWNoZWRQcm9taXNlID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9tZXRob2RQcm9taXNlcykuZ2V0KG5hbWUpOwogICAgICAgICAgICAgICAgICAgIGlmIChjYWNoZWRQcm9taXNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWNoZWRQcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBwcm9taXNlID0gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UobmFtZSwgZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9tZXRob2RQcm9taXNlcykuc2V0KG5hbWUsIHByb21pc2UpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBwcm9taXNlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgdmFyIF9vYmpzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2Vuc3VyZU9iaiA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgY2xhc3MgUERGT2JqZWN0cyB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZW5zdXJlT2JqKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX29ianMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IE9iamVjdC5jcmVhdGUobnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldChvYmpJZCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY2FsbGJhY2sgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2JqID0gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZW5zdXJlT2JqLCBfZW5zdXJlT2JqMikuY2FsbCh0aGlzLCBvYmpJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYmouY2FwYWJpbGl0eS5wcm9taXNlLnRoZW4oKCkgPT4gY2FsbGJhY2sob2JqLmRhdGEpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9iaiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfb2Jqcylbb2JqSWRdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIShvYmogIT09IG51bGwgJiYgb2JqICE9PSB2b2lkIDAgJiYgb2JqLmNhcGFiaWxpdHkuc2V0dGxlZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgUmVxdWVzdGluZyBvYmplY3QgdGhhdCBpc24ndCByZXNvbHZlZCB5ZXQgJHtvYmpJZH0uYCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG9iai5kYXRhOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXMob2JqSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2JqID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vYmpzKVtvYmpJZF07CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAob2JqID09PSBudWxsIHx8IG9iaiA9PT0gdm9pZCAwID8gdm9pZCAwIDogb2JqLmNhcGFiaWxpdHkuc2V0dGxlZCkgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlc29sdmUob2JqSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhdGEgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9iaiA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Vuc3VyZU9iaiwgX2Vuc3VyZU9iajIpLmNhbGwodGhpcywgb2JqSWQpOwogICAgICAgICAgICAgICAgICAgICAgICBvYmouZGF0YSA9IGRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIG9iai5jYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2xlYXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgb2JqSWQgaW4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vYmpzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9kYXRhJGJpdG1hcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vYmpzKVtvYmpJZF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhID09PSBudWxsIHx8IGRhdGEgPT09IHZvaWQgMCA/IHZvaWQgMCA6IChfZGF0YSRiaXRtYXAgPSBkYXRhLmJpdG1hcCkgPT09IG51bGwgfHwgX2RhdGEkYml0bWFwID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfZGF0YSRiaXRtYXAuY2xvc2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX29ianMsIE9iamVjdC5jcmVhdGUobnVsbCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9lbnN1cmVPYmoyKG9iaklkKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2JqID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vYmpzKVtvYmpJZF07CiAgICAgICAgICAgICAgICAgICAgaWYgKG9iaikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gb2JqOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vYmpzKVtvYmpJZF0gPSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHk6ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKSwKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YTogbnVsbAogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBSZW5kZXJUYXNrIHsKICAgICAgICAgICAgICAgICAgICAjaW50ZXJuYWxSZW5kZXJUYXNrID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihpbnRlcm5hbFJlbmRlclRhc2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jaW50ZXJuYWxSZW5kZXJUYXNrID0gaW50ZXJuYWxSZW5kZXJUYXNrOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uQ29udGludWUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJvbWlzZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI2ludGVybmFsUmVuZGVyVGFzay5jYXBhYmlsaXR5LnByb21pc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbmNlbCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGV4dHJhRGVsYXkgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2ludGVybmFsUmVuZGVyVGFzay5jYW5jZWwobnVsbCwgZXh0cmFEZWxheSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBzZXBhcmF0ZUFubm90cygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VwYXJhdGVBbm5vdHMKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuI2ludGVybmFsUmVuZGVyVGFzay5vcGVyYXRvckxpc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc2VwYXJhdGVBbm5vdHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uQ2FudmFzTWFwCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLiNpbnRlcm5hbFJlbmRlclRhc2s7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzZXBhcmF0ZUFubm90cy5mb3JtIHx8IHNlcGFyYXRlQW5ub3RzLmNhbnZhcyAmJiAoYW5ub3RhdGlvbkNhbnZhc01hcCA9PT0gbnVsbCB8fCBhbm5vdGF0aW9uQ2FudmFzTWFwID09PSB2b2lkIDAgPyB2b2lkIDAgOiBhbm5vdGF0aW9uQ2FudmFzTWFwLnNpemUpID4gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlJlbmRlclRhc2sgPSBSZW5kZXJUYXNrOwogICAgICAgICAgICAgICAgY2xhc3MgSW50ZXJuYWxSZW5kZXJUYXNrIHsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgI2NhbnZhc0luVXNlID0gbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihfcmVmMTMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2JqcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1vbk9ianMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uQ2FudmFzTWFwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzRmFjdG9yeSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlckZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUgPSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBkZkJ1ZyA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUNvbG9ycyA9IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYxMzsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYWxsYmFjayA9IGNhbGxiYWNrOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmFtcyA9IHBhcmFtczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vYmpzID0gb2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzID0gY29tbW9uT2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbm5vdGF0aW9uQ2FudmFzTWFwID0gYW5ub3RhdGlvbkNhbnZhc01hcDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vcGVyYXRvckxpc3RJZHggPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wZXJhdG9yTGlzdCA9IG9wZXJhdG9yTGlzdDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFnZUluZGV4ID0gcGFnZUluZGV4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkgPSBjYW52YXNGYWN0b3J5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbHRlckZhY3RvcnkgPSBmaWx0ZXJGYWN0b3J5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZCdWcgPSBwZGZCdWc7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFnZUNvbG9ycyA9IHBhZ2VDb2xvcnM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucnVubmluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmdyYXBoaWNzUmVhZHlDYWxsYmFjayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JhcGhpY3NSZWFkeSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUgPSB1c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUgPT09IHRydWUgJiYgdHlwZW9mIHdpbmRvdyAhPT0gInVuZGVmaW5lZCI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FuY2VsbGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50YXNrID0gbmV3IFJlbmRlclRhc2sodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhbmNlbEJvdW5kID0gdGhpcy5jYW5jZWwuYmluZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGludWVCb3VuZCA9IHRoaXMuX2NvbnRpbnVlLmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NjaGVkdWxlTmV4dEJvdW5kID0gdGhpcy5fc2NoZWR1bGVOZXh0LmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX25leHRCb3VuZCA9IHRoaXMuX25leHQuYmluZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FudmFzID0gcGFyYW1zLmNhbnZhc0NvbnRleHQuY2FudmFzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgY29tcGxldGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jYXBhYmlsaXR5LnByb21pc2UuY2F0Y2goZnVuY3Rpb24gKCkge30pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpbml0aWFsaXplR3JhcGhpY3MoX3JlZjE0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfZ2xvYmFsVGhpcyRTdGVwcGVyTWEsIF90aGlzJGdyYXBoaWNzUmVhZHlDYTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zcGFyZW5jeSA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uYWxDb250ZW50Q29uZmlnCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMTQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNhbmNlbGxlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9jYW52YXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChJbnRlcm5hbFJlbmRlclRhc2suI2NhbnZhc0luVXNlLmhhcyh0aGlzLl9jYW52YXMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJDYW5ub3QgdXNlIHRoZSBzYW1lIGNhbnZhcyBkdXJpbmcgbXVsdGlwbGUgcmVuZGVyKCkgb3BlcmF0aW9ucy4gIiArICJVc2UgZGlmZmVyZW50IGNhbnZhcyBvciBlbnN1cmUgcHJldmlvdXMgb3BlcmF0aW9ucyB3ZXJlICIgKyAiY2FuY2VsbGVkIG9yIGNvbXBsZXRlZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIEludGVybmFsUmVuZGVyVGFzay4jY2FudmFzSW5Vc2UuYWRkKHRoaXMuX2NhbnZhcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3BkZkJ1ZyAmJiAoX2dsb2JhbFRoaXMkU3RlcHBlck1hID0gZ2xvYmFsVGhpcy5TdGVwcGVyTWFuYWdlcikgIT09IG51bGwgJiYgX2dsb2JhbFRoaXMkU3RlcHBlck1hICE9PSB2b2lkIDAgJiYgX2dsb2JhbFRoaXMkU3RlcHBlck1hLmVuYWJsZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RlcHBlciA9IGdsb2JhbFRoaXMuU3RlcHBlck1hbmFnZXIuY3JlYXRlKHRoaXMuX3BhZ2VJbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0ZXBwZXIuaW5pdCh0aGlzLm9wZXJhdG9yTGlzdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0ZXBwZXIubmV4dEJyZWFrUG9pbnQgPSB0aGlzLnN0ZXBwZXIuZ2V0TmV4dEJyZWFrUG9pbnQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNDb250ZXh0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWNrZ3JvdW5kCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLnBhcmFtczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5nZnggPSBuZXcgX2NhbnZhcy5DYW52YXNHcmFwaGljcyhjYW52YXNDb250ZXh0LCB0aGlzLmNvbW1vbk9ianMsIHRoaXMub2JqcywgdGhpcy5jYW52YXNGYWN0b3J5LCB0aGlzLmZpbHRlckZhY3RvcnksIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbmFsQ29udGVudENvbmZpZwogICAgICAgICAgICAgICAgICAgICAgICB9LCB0aGlzLmFubm90YXRpb25DYW52YXNNYXApOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmdmeC5iZWdpbkRyYXdpbmcoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc3BhcmVuY3ksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWNrZ3JvdW5kCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wZXJhdG9yTGlzdElkeCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JhcGhpY3NSZWFkeSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRncmFwaGljc1JlYWR5Q2EgPSB0aGlzLmdyYXBoaWNzUmVhZHlDYWxsYmFjaykgPT09IG51bGwgfHwgX3RoaXMkZ3JhcGhpY3NSZWFkeUNhID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRncmFwaGljc1JlYWR5Q2EuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZ2Z4OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZXJyb3IgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBleHRyYURlbGF5ID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJ1bm5pbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW5jZWxsZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkZ2Z4ID0gdGhpcy5nZngpID09PSBudWxsIHx8IF90aGlzJGdmeCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZ2Z4LmVuZERyYXdpbmcodGhpcy5wYWdlQ29sb3JzKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgSW50ZXJuYWxSZW5kZXJUYXNrLiNjYW52YXNJblVzZS5kZWxldGUodGhpcy5fY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrKGVycm9yIHx8IG5ldyBfZGlzcGxheV91dGlscy5SZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb24oYFJlbmRlcmluZyBjYW5jZWxsZWQsIHBhZ2UgJHt0aGlzLl9wYWdlSW5kZXggKyAxfWAsICJjYW52YXMiLCBleHRyYURlbGF5KSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdENoYW5nZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRzdGVwcGVyOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuZ3JhcGhpY3NSZWFkeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmdyYXBoaWNzUmVhZHlDYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JhcGhpY3NSZWFkeUNhbGxiYWNrID0gdGhpcy5fY29udGludWVCb3VuZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkc3RlcHBlciA9IHRoaXMuc3RlcHBlcikgPT09IG51bGwgfHwgX3RoaXMkc3RlcHBlciA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkc3RlcHBlci51cGRhdGVPcGVyYXRvckxpc3QodGhpcy5vcGVyYXRvckxpc3QpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5ydW5uaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGludWUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NvbnRpbnVlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJ1bm5pbmcgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jYW5jZWxsZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy50YXNrLm9uQ29udGludWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGFzay5vbkNvbnRpbnVlKHRoaXMuX3NjaGVkdWxlTmV4dEJvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NjaGVkdWxlTmV4dCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zY2hlZHVsZU5leHQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl91c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpbmRvdy5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUoKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX25leHRCb3VuZCgpLmNhdGNoKHRoaXMuX2NhbmNlbEJvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUHJvbWlzZS5yZXNvbHZlKCkudGhlbih0aGlzLl9uZXh0Qm91bmQpLmNhdGNoKHRoaXMuX2NhbmNlbEJvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyBfbmV4dCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY2FuY2VsbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vcGVyYXRvckxpc3RJZHggPSB0aGlzLmdmeC5leGVjdXRlT3BlcmF0b3JMaXN0KHRoaXMub3BlcmF0b3JMaXN0LCB0aGlzLm9wZXJhdG9yTGlzdElkeCwgdGhpcy5fY29udGludWVCb3VuZCwgdGhpcy5zdGVwcGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMub3BlcmF0b3JMaXN0SWR4ID09PSB0aGlzLm9wZXJhdG9yTGlzdC5hcmdzQXJyYXkubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJ1bm5pbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLm9wZXJhdG9yTGlzdC5sYXN0Q2h1bmspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmdmeC5lbmREcmF3aW5nKHRoaXMucGFnZUNvbG9ycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbnRlcm5hbFJlbmRlclRhc2suI2NhbnZhc0luVXNlLmRlbGV0ZSh0aGlzLl9jYW52YXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjb25zdCB2ZXJzaW9uID0gJzMuNS4xMjInOwogICAgICAgICAgICAgICAgZXhwb3J0cy52ZXJzaW9uID0gdmVyc2lvbjsKICAgICAgICAgICAgICAgIGNvbnN0IGJ1aWxkID0gJzYyMjQ2NWRjMic7CiAgICAgICAgICAgICAgICBleHBvcnRzLmJ1aWxkID0gYnVpbGQ7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzOSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlByaW50QW5ub3RhdG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YXNzRXh0cmFjdEZpZWxkRGVzY3JpcHRvcihyZWNlaXZlciwgcHJpdmF0ZU1hcCwgYWN0aW9uKSB7IGlmICghcHJpdmF0ZU1hcC5oYXMocmVjZWl2ZXIpKSB7IHRocm93IG5ldyBUeXBlRXJyb3IoImF0dGVtcHRlZCB0byAiICsgYWN0aW9uICsgIiBwcml2YXRlIGZpZWxkIG9uIG5vbi1pbnN0YW5jZSIpOyB9IHJldHVybiBwcml2YXRlTWFwLmdldChyZWNlaXZlcik7IH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jbGFzc0FwcGx5RGVzY3JpcHRvckdldChyZWNlaXZlciwgZGVzY3JpcHRvcikgeyBpZiAoZGVzY3JpcHRvci5nZXQpIHsgcmV0dXJuIGRlc2NyaXB0b3IuZ2V0LmNhbGwocmVjZWl2ZXIpOyB9IHJldHVybiBkZXNjcmlwdG9yLnZhbHVlOyB9CiAgICAgICAgICAgICAgICB2YXIgX21vZGlmaWVkID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX3N0b3JhZ2UgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfc2V0TW9kaWZpZWQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIEFubm90YXRpb25TdG9yYWdlIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRNb2RpZmllZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9tb2RpZmllZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9zdG9yYWdlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgTWFwKCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25TZXRNb2RpZmllZCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25SZXNldE1vZGlmaWVkID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vbkFubm90YXRpb25FZGl0b3IgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRWYWx1ZShrZXksIGRlZmF1bHRWYWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuZ2V0KGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZGVmYXVsdFZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBPYmplY3QuYXNzaWduKGRlZmF1bHRWYWx1ZSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSYXdWYWx1ZShrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuZ2V0KGtleSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbW92ZShrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zdG9yYWdlKS5kZWxldGUoa2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXNldE1vZGlmaWVkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB0aGlzLm9uQW5ub3RhdGlvbkVkaXRvciA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCB2YWx1ZSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3N0b3JhZ2UpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uQW5ub3RhdGlvbkVkaXRvcihudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRWYWx1ZShrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9iaiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuZ2V0KGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtb2RpZmllZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAob2JqICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2VudHJ5LCB2YWxdIG9mIE9iamVjdC5lbnRyaWVzKHZhbHVlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvYmpbZW50cnldICE9PSB2YWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9kaWZpZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYmpbZW50cnldID0gdmFsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGlmaWVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2V0KGtleSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtb2RpZmllZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0TW9kaWZpZWQsIF9zZXRNb2RpZmllZDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yICYmIHR5cGVvZiB0aGlzLm9uQW5ub3RhdGlvbkVkaXRvciA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vbkFubm90YXRpb25FZGl0b3IodmFsdWUuY29uc3RydWN0b3IuX3R5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhcyhrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuaGFzKGtleSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFsbCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZSA+IDAgPyAoMCwgX3V0aWwub2JqZWN0RnJvbU1hcCkoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zdG9yYWdlKSkgOiBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRBbGwob2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleSwgdmFsXSBvZiBPYmplY3QuZW50cmllcyhvYmopKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFZhbHVlKGtleSwgdmFsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgc2l6ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVzZXRNb2RpZmllZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbW9kaWZpZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX21vZGlmaWVkLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHRoaXMub25SZXNldE1vZGlmaWVkID09PSAiZnVuY3Rpb24iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vblJlc2V0TW9kaWZpZWQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJpbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHJpbnRBbm5vdGF0aW9uU3RvcmFnZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHNlcmlhbGl6YWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xvbmUgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleSwgdmFsXSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3N0b3JhZ2UpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzZXJpYWxpemVkID0gdmFsIGluc3RhbmNlb2YgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yID8gdmFsLnNlcmlhbGl6ZSgpIDogdmFsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNlcmlhbGl6ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZS5zZXQoa2V5LCBzZXJpYWxpemVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xvbmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXRIYXNoKG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIW1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICIiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhhc2ggPSBuZXcgX211cm11cmhhc2guTXVybXVySGFzaDNfNjQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBba2V5LCB2YWxdIG9mIG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzaC51cGRhdGUoYCR7a2V5fToke0pTT04uc3RyaW5naWZ5KHZhbCl9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGhhc2guaGV4ZGlnZXN0KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uU3RvcmFnZSA9IEFubm90YXRpb25TdG9yYWdlOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3NldE1vZGlmaWVkMigpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbW9kaWZpZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfbW9kaWZpZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHRoaXMub25TZXRNb2RpZmllZCA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vblNldE1vZGlmaWVkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQcmludEFubm90YXRpb25TdG9yYWdlIGV4dGVuZHMgQW5ub3RhdGlvblN0b3JhZ2UgewogICAgICAgICAgICAgICAgICAgICNzZXJpYWxpemFibGUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNzZXJpYWxpemFibGUgPSBzdHJ1Y3R1cmVkQ2xvbmUocGFyZW50LnNlcmlhbGl6YWJsZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwcmludCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiU2hvdWxkIG5vdCBjYWxsIFByaW50QW5ub3RhdGlvblN0b3JhZ2UucHJpbnQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHNlcmlhbGl6YWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI3NlcmlhbGl6YWJsZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlByaW50QW5ub3RhdGlvblN0b3JhZ2UgPSBQcmludEFubm90YXRpb25TdG9yYWdlOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNDAgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF90b29scyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQxKTsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uRWRpdG9yIHsKICAgICAgICAgICAgICAgICAgICAjYm91bmRGb2N1c2luID0gdGhpcy5mb2N1c2luLmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgI2JvdW5kRm9jdXNvdXQgPSB0aGlzLmZvY3Vzb3V0LmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgI2hhc0JlZW5TZWxlY3RlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICNpc0VkaXRpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAjaXNJbkVkaXRNb2RlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgX3VpTWFuYWdlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgI3pJbmRleCA9IEFubm90YXRpb25FZGl0b3IuX3pJbmRleCsrOwogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBfY29sb3JNYW5hZ2VyID0gbmV3IF90b29scy5Db2xvck1hbmFnZXIoKTsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgX3pJbmRleCA9IDE7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb25zdHJ1Y3RvciA9PT0gQW5ub3RhdGlvbkVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQW5ub3RhdGlvbkVkaXRvci4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudCA9IHBhcmFtZXRlcnMucGFyZW50OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlkID0gcGFyYW1ldGVycy5pZDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy53aWR0aCA9IHRoaXMuaGVpZ2h0ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlSW5kZXggPSBwYXJhbWV0ZXJzLnBhcmVudC5wYWdlSW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmFtZSA9IHBhcmFtZXRlcnMubmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91aU1hbmFnZXIgPSBwYXJhbWV0ZXJzLnVpTWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb24sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByYXdEaW1zOiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VIZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMucGFyZW50LnZpZXdwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJvdGF0aW9uID0gcm90YXRpb247CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFnZURpbWVuc2lvbnMgPSBbcGFnZVdpZHRoLCBwYWdlSGVpZ2h0XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlVHJhbnNsYXRpb24gPSBbcGFnZVgsIHBhZ2VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3dpZHRoLCBoZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnggPSBwYXJhbWV0ZXJzLnggLyB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy55ID0gcGFyYW1ldGVycy55IC8gaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzQXR0YWNoZWRUb0RPTSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgZ2V0IF9kZWZhdWx0TGluZUNvbG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIl9kZWZhdWx0TGluZUNvbG9yIiwgdGhpcy5fY29sb3JNYW5hZ2VyLmdldEhleENvZGUoIkNhbnZhc1RleHQiKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZENvbW1hbmRzKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91aU1hbmFnZXIuYWRkQ29tbWFuZHMocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGN1cnJlbnRMYXllcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3VpTWFuYWdlci5jdXJyZW50TGF5ZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEluQmFja2dyb3VuZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUuekluZGV4ID0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0SW5Gb3JlZ3JvdW5kKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS56SW5kZXggPSB0aGlzLiN6SW5kZXg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFBhcmVudChwYXJlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmVudCAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlSW5kZXggPSBwYXJlbnQucGFnZUluZGV4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlRGltZW5zaW9ucyA9IHBhcmVudC5wYWdlRGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudCA9IHBhcmVudDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9jdXNpbihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuI2hhc0JlZW5TZWxlY3RlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0U2VsZWN0ZWQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNoYXNCZWVuU2VsZWN0ZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb2N1c291dChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkcGFyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNBdHRhY2hlZFRvRE9NKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGFyZ2V0ID0gZXZlbnQucmVsYXRlZFRhcmdldDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRhcmdldCAhPT0gbnVsbCAmJiB0YXJnZXQgIT09IHZvaWQgMCAmJiB0YXJnZXQuY2xvc2VzdChgIyR7dGhpcy5pZH1gKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghKChfdGhpcyRwYXJlbnQgPSB0aGlzLnBhcmVudCkgIT09IG51bGwgJiYgX3RoaXMkcGFyZW50ICE9PSB2b2lkIDAgJiYgX3RoaXMkcGFyZW50LmlzTXVsdGlwbGVTZWxlY3Rpb24pKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbW1pdE9yUmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tbWl0T3JSZW1vdmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tbWl0KCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZFRvQW5ub3RhdGlvblN0b3JhZ2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkVG9Bbm5vdGF0aW9uU3RvcmFnZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdWlNYW5hZ2VyLmFkZFRvQW5ub3RhdGlvblN0b3JhZ2UodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRyYWdzdGFydChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWN0ID0gdGhpcy5wYXJlbnQuZGl2LmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YXJ0WCA9IGV2ZW50LmNsaWVudFggLSByZWN0Lng7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhcnRZID0gZXZlbnQuY2xpZW50WSAtIHJlY3QueTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuZGF0YVRyYW5zZmVyLnNldERhdGEoInRleHQvcGxhaW4iLCB0aGlzLmlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuZGF0YVRyYW5zZmVyLmVmZmVjdEFsbG93ZWQgPSAibW92ZSI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEF0KHgsIHksIHR4LCB0eSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbd2lkdGgsIGhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIFt0eCwgdHldID0gdGhpcy5zY3JlZW5Ub1BhZ2VUcmFuc2xhdGlvbih0eCwgdHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnggPSAoeCArIHR4KSAvIHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnkgPSAoeSArIHR5KSAvIGhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUubGVmdCA9IGAkezEwMCAqIHRoaXMueH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUudG9wID0gYCR7MTAwICogdGhpcy55fSVgOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0cmFuc2xhdGUoeCwgeSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbd2lkdGgsIGhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIFt4LCB5XSA9IHRoaXMuc2NyZWVuVG9QYWdlVHJhbnNsYXRpb24oeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCArPSB4IC8gd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueSArPSB5IC8gaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS5sZWZ0ID0gYCR7MTAwICogdGhpcy54fSVgOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS50b3AgPSBgJHsxMDAgKiB0aGlzLnl9JWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNjcmVlblRvUGFnZVRyYW5zbGF0aW9uKHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0aGlzLnBhcmVudFJvdGF0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDkwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeSwgLXhdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxODA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsteCwgLXldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAyNzA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsteSwgeF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeCwgeV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHBhcmVudFNjYWxlKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdWlNYW5hZ2VyLnZpZXdQYXJhbWV0ZXJzLnJlYWxTY2FsZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHBhcmVudFJvdGF0aW9uKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdWlNYW5hZ2VyLnZpZXdQYXJhbWV0ZXJzLnJvdGF0aW9uOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcGFyZW50RGltZW5zaW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhbFNjYWxlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLl91aU1hbmFnZXIudmlld1BhcmFtZXRlcnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYWdlV2lkdGgsIHBhZ2VIZWlnaHRdID0gdGhpcy5wYWdlRGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtwYWdlV2lkdGggKiByZWFsU2NhbGUsIHBhZ2VIZWlnaHQgKiByZWFsU2NhbGVdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXREaW1zKHdpZHRoLCBoZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS53aWR0aCA9IGAkezEwMCAqIHdpZHRoIC8gcGFyZW50V2lkdGh9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnN0eWxlLmhlaWdodCA9IGAkezEwMCAqIGhlaWdodCAvIHBhcmVudEhlaWdodH0lYDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZml4RGltcygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZGl2OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gc3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoUGVyY2VudCA9IHdpZHRoLmVuZHNXaXRoKCIlIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodFBlcmNlbnQgPSBoZWlnaHQuZW5kc1dpdGgoIiUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoUGVyY2VudCAmJiBoZWlnaHRQZXJjZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXdpZHRoUGVyY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUud2lkdGggPSBgJHsxMDAgKiBwYXJzZUZsb2F0KHdpZHRoKSAvIHBhcmVudFdpZHRofSVgOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaGVpZ2h0UGVyY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUuaGVpZ2h0ID0gYCR7MTAwICogcGFyc2VGbG9hdChoZWlnaHQpIC8gcGFyZW50SGVpZ2h0fSVgOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEluaXRpYWxUcmFuc2xhdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFswLCAwXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zZXRBdHRyaWJ1dGUoImRhdGEtZWRpdG9yLXJvdGF0aW9uIiwgKDM2MCAtIHRoaXMucm90YXRpb24pICUgMzYwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuY2xhc3NOYW1lID0gdGhpcy5uYW1lOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zZXRBdHRyaWJ1dGUoImlkIiwgdGhpcy5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnNldEF0dHJpYnV0ZSgidGFiSW5kZXgiLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRJbkZvcmVncm91bmQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYWRkRXZlbnRMaXN0ZW5lcigiZm9jdXNpbiIsIHRoaXMuI2JvdW5kRm9jdXNpbik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFkZEV2ZW50TGlzdGVuZXIoImZvY3Vzb3V0IiwgdGhpcy4jYm91bmRGb2N1c291dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFt0eCwgdHldID0gdGhpcy5nZXRJbml0aWFsVHJhbnNsYXRpb24oKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2xhdGUodHgsIHR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF90b29scy5iaW5kRXZlbnRzKSh0aGlzLCB0aGlzLmRpdiwgWyJkcmFnc3RhcnQiLCAicG9pbnRlcmRvd24iXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmRpdjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcG9pbnRlcmRvd24oZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNNYWMKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF91dGlsLkZlYXR1cmVUZXN0LnBsYXRmb3JtOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQuYnV0dG9uICE9PSAwIHx8IGV2ZW50LmN0cmxLZXkgJiYgaXNNYWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50LmN0cmxLZXkgJiYgIWlzTWFjIHx8IGV2ZW50LnNoaWZ0S2V5IHx8IGV2ZW50Lm1ldGFLZXkgJiYgaXNNYWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LnRvZ2dsZVNlbGVjdGVkKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0U2VsZWN0ZWQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jaGFzQmVlblNlbGVjdGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UmVjdCh0eCwgdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSB0aGlzLnBhcmVudFNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFnZVdpZHRoLCBwYWdlSGVpZ2h0XSA9IHRoaXMucGFnZURpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYWdlWCwgcGFnZVldID0gdGhpcy5wYWdlVHJhbnNsYXRpb247CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNoaWZ0WCA9IHR4IC8gc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNoaWZ0WSA9IHR5IC8gc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHggPSB0aGlzLnggKiBwYWdlV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHkgPSB0aGlzLnkgKiBwYWdlSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IHRoaXMud2lkdGggKiBwYWdlV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IHRoaXMuaGVpZ2h0ICogcGFnZUhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0aGlzLnJvdGF0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4ICsgc2hpZnRYICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5IC0gc2hpZnRZIC0gaGVpZ2h0ICsgcGFnZVksIHggKyBzaGlmdFggKyB3aWR0aCArIHBhZ2VYLCBwYWdlSGVpZ2h0IC0geSAtIHNoaWZ0WSArIHBhZ2VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgOTA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4ICsgc2hpZnRZICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5ICsgc2hpZnRYICsgcGFnZVksIHggKyBzaGlmdFkgKyBoZWlnaHQgKyBwYWdlWCwgcGFnZUhlaWdodCAtIHkgKyBzaGlmdFggKyB3aWR0aCArIHBhZ2VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMTgwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeCAtIHNoaWZ0WCAtIHdpZHRoICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5ICsgc2hpZnRZICsgcGFnZVksIHggLSBzaGlmdFggKyBwYWdlWCwgcGFnZUhlaWdodCAtIHkgKyBzaGlmdFkgKyBoZWlnaHQgKyBwYWdlWV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI3MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3ggLSBzaGlmdFkgLSBoZWlnaHQgKyBwYWdlWCwgcGFnZUhlaWdodCAtIHkgLSBzaGlmdFggLSB3aWR0aCArIHBhZ2VZLCB4IC0gc2hpZnRZICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5IC0gc2hpZnRYICsgcGFnZVldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSZWN0SW5DdXJyZW50Q29vcmRzKHJlY3QsIHBhZ2VIZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3gxLCB5MSwgeDIsIHkyXSA9IHJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0geDIgLSB4MTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0geTIgLSB5MTsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0aGlzLnJvdGF0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4MSwgcGFnZUhlaWdodCAtIHkyLCB3aWR0aCwgaGVpZ2h0XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgOTA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4MSwgcGFnZUhlaWdodCAtIHkxLCBoZWlnaHQsIHdpZHRoXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMTgwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeDIsIHBhZ2VIZWlnaHQgLSB5MSwgd2lkdGgsIGhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI3MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3gyLCBwYWdlSGVpZ2h0IC0geTIsIGhlaWdodCwgd2lkdGhdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBvbmNlQWRkZWQoKSB7fQogICAgICAgICAgICAgICAgICAgIGlzRW1wdHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5hYmxlRWRpdE1vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2lzSW5FZGl0TW9kZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRpc2FibGVFZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jaXNJbkVkaXRNb2RlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzSW5FZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI2lzSW5FZGl0TW9kZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2hvdWxkR2V0S2V5Ym9hcmRFdmVudHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgbmVlZHNUb0JlUmVidWlsdCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZGl2ICYmICF0aGlzLmlzQXR0YWNoZWRUb0RPTTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVidWlsZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGRpdiA9IHRoaXMuZGl2KSA9PT0gbnVsbCB8fCBfdGhpcyRkaXYgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGRpdi5hZGRFdmVudExpc3RlbmVyKCJmb2N1c2luIiwgdGhpcy4jYm91bmRGb2N1c2luKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2VyaWFsaXplKCkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJBbiBlZGl0b3IgbXVzdCBiZSBzZXJpYWxpemFibGUiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGRlc2VyaWFsaXplKGRhdGEsIHBhcmVudCwgdWlNYW5hZ2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVkaXRvciA9IG5ldyB0aGlzLnByb3RvdHlwZS5jb25zdHJ1Y3Rvcih7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJlbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZDogcGFyZW50LmdldE5leHRJZCgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdWlNYW5hZ2VyCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iucm90YXRpb24gPSBkYXRhLnJvdGF0aW9uOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFnZVdpZHRoLCBwYWdlSGVpZ2h0XSA9IGVkaXRvci5wYWdlRGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3gsIHksIHdpZHRoLCBoZWlnaHRdID0gZWRpdG9yLmdldFJlY3RJbkN1cnJlbnRDb29yZHMoZGF0YS5yZWN0LCBwYWdlSGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnggPSB4IC8gcGFnZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IueSA9IHkgLyBwYWdlSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iud2lkdGggPSB3aWR0aCAvIHBhZ2VXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmhlaWdodCA9IGhlaWdodCAvIHBhZ2VIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlZGl0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbW92ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZm9jdXNpbiIsIHRoaXMuI2JvdW5kRm9jdXNpbik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnJlbW92ZUV2ZW50TGlzdGVuZXIoImZvY3Vzb3V0IiwgdGhpcy4jYm91bmRGb2N1c291dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQucmVtb3ZlKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZWxlY3QoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRkaXYyOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkZGl2MiA9IHRoaXMuZGl2KSA9PT0gbnVsbCB8fCBfdGhpcyRkaXYyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRkaXYyLmNsYXNzTGlzdC5hZGQoInNlbGVjdGVkRWRpdG9yIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVuc2VsZWN0KCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZGl2MzsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGRpdjMgPSB0aGlzLmRpdikgPT09IG51bGwgfHwgX3RoaXMkZGl2MyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZGl2My5jbGFzc0xpc3QucmVtb3ZlKCJzZWxlY3RlZEVkaXRvciIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGVQYXJhbXModHlwZSwgdmFsdWUpIHt9CiAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUVkaXRpbmcoKSB7fQogICAgICAgICAgICAgICAgICAgIGVuYWJsZUVkaXRpbmcoKSB7fQogICAgICAgICAgICAgICAgICAgIGdldCBwcm9wZXJ0aWVzVG9VcGRhdGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7fTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGNvbnRlbnREaXYoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmRpdjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGlzRWRpdGluZygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI2lzRWRpdGluZzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0IGlzRWRpdGluZyh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNpc0VkaXRpbmcgPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5zZXRTZWxlY3RlZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LnNldEFjdGl2ZUVkaXRvcih0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LnNldEFjdGl2ZUVkaXRvcihudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvciA9IEFubm90YXRpb25FZGl0b3I7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE0MSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLktleWJvYXJkTWFuYWdlciA9IGV4cG9ydHMuQ29tbWFuZE1hbmFnZXIgPSBleHBvcnRzLkNvbG9yTWFuYWdlciA9IGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvclVJTWFuYWdlciA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIGV4cG9ydHMuYmluZEV2ZW50cyA9IGJpbmRFdmVudHM7CiAgICAgICAgICAgICAgICBleHBvcnRzLm9wYWNpdHlUb0hleCA9IG9wYWNpdHlUb0hleDsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICB2YXIgX2Rpc3BsYXlfdXRpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0Mik7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZGVmaW5lUHJvcGVydHkob2JqLCBrZXksIHZhbHVlKSB7IGtleSA9IF90b1Byb3BlcnR5S2V5KGt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XB0ZWQgdG8gZ2V0IHByaXZhdGUgZmllbGQgb24gbm9uLWluc3RhbmNlIik7IH0gcmV0dXJuIGZuOyB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBiaW5kRXZlbnRzKG9iaiwgZWxlbWVudCwgbmFtZXMpIHsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG5hbWUgb2YgbmFtZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKG5hbWUsIG9ialtuYW1lXS5iaW5kKG9iaikpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG9wYWNpdHlUb0hleChvcGFjaXR5KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE1hdGgucm91bmQoTWF0aC5taW4oMjU1LCBNYXRoLm1heCgxLCAyNTUgKiBvcGFjaXR5KSkpLnRvU3RyaW5nKDE2KS5wYWRTdGFydCgyLCAiMCIpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgSWRNYW5hZ2VyIHsKICAgICAgICAgICAgICAgICAgICAjaWQgPSAwOwogICAgICAgICAgICAgICAgICAgIGdldElkKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYCR7X3V0aWwuQW5ub3RhdGlvbkVkaXRvclByZWZpeH0ke3RoaXMuI2lkKyt9YDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDb21tYW5kTWFuYWdlciB7CiAgICAgICAgICAgICAgICAgICAgI2NvbW1hbmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgI2xvY2tlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICNtYXhTaXplOwogICAgICAgICAgICAgICAgICAgICNwb3NpdGlvbiA9IC0xOwogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbWF4U2l6ZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogMTI4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNtYXhTaXplID0gbWF4U2l6ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuZG8sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUgPSBOYU4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbyA9IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobXVzdEV4ZWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLiNsb2NrZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzYXZlID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY21kLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5kbywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuI3Bvc2l0aW9uID09PSAtMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuI2NvbW1hbmRzLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kcy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jcG9zaXRpb24gPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jY29tbWFuZHMucHVzaChzYXZlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAob3ZlcndyaXRlSWZTYW1lVHlwZSAmJiB0aGlzLiNjb21tYW5kc1t0aGlzLiNwb3NpdGlvbl0udHlwZSA9PT0gdHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGtlZXBVbmRvKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2F2ZS51bmRvID0gdGhpcy4jY29tbWFuZHNbdGhpcy4jcG9zaXRpb25dLnVuZG87CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kc1t0aGlzLiNwb3NpdGlvbl0gPSBzYXZlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5leHQgPSB0aGlzLiNwb3NpdGlvbiArIDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXh0ID09PSB0aGlzLiNtYXhTaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kcy5zcGxpY2UoMCwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNwb3NpdGlvbiA9IG5leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobmV4dCA8IHRoaXMuI2NvbW1hbmRzLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2NvbW1hbmRzLnNwbGljZShuZXh0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kcy5wdXNoKHNhdmUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1bmRvKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy4jcG9zaXRpb24gPT09IC0xKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jbG9ja2VkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jY29tbWFuZHNbdGhpcy4jcG9zaXRpb25dLnVuZG8oKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jbG9ja2VkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI3Bvc2l0aW9uIC09IDE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlZG8oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLiNwb3NpdGlvbiA8IHRoaXMuI2NvbW1hbmRzLmxlbmd0aCAtIDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI3Bvc2l0aW9uICs9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNsb2NrZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jY29tbWFuZHNbdGhpcy4jcG9zaXRpb25dLmNtZCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jbG9ja2VkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy4jcG9zaXRpb24gIT09IC0xOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG8oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLiNwb3NpdGlvbiA8IHRoaXMuI2NvbW1hbmRzLmxlbmd0aCAtIDE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlc3Ryb3koKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2NvbW1hbmRzID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkNvbW1hbmRNYW5hZ2VyID0gQ29tbWFuZE1hbmFnZXI7CiAgICAgICAgICAgICAgICB2YXIgX3NlcmlhbGl6ZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgY2xhc3MgS2V5Ym9hcmRNYW5hZ2VyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihjYWxsYmFja3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXJpYWxpemUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmJ1ZmZlciA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrcyA9IG5ldyBNYXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbGxLZXlzID0gbmV3IFNldCgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleXMsIGNhbGxiYWNrXSBvZiBjYWxsYmFja3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qga2V5IG9mIGtleXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc01hY0tleSA9IGtleS5zdGFydHNXaXRoKCJtYWMrIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzTWFjICYmIGlzTWFjS2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FsbGJhY2tzLnNldChrZXkuc2xpY2UoNCksIGNhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbGxLZXlzLmFkZChrZXkuc3BsaXQoIisiKS5hdCgtMSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIWlzTWFjICYmICFpc01hY0tleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrcy5zZXQoa2V5LCBjYWxsYmFjayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWxsS2V5cy5hZGQoa2V5LnNwbGl0KCIrIikuYXQoLTEpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZXhlYyhzZWxmLCBldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuYWxsS2V5cy5oYXMoZXZlbnQua2V5KSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbGxiYWNrID0gdGhpcy5jYWxsYmFja3MuZ2V0KF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NlcmlhbGl6ZSwgX3NlcmlhbGl6ZTIpLmNhbGwodGhpcywgZXZlbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrLmJpbmQoc2VsZikoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuc3RvcFByb3BhZ2F0aW9uKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5LZXlib2FyZE1hbmFnZXIgPSBLZXlib2FyZE1hbmFnZXI7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2VyaWFsaXplMihldmVudCkgewogICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5hbHRLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaCgiYWx0Iik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5jdHJsS2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYnVmZmVyLnB1c2goImN0cmwiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50Lm1ldGFLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaCgibWV0YSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQuc2hpZnRLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaCgic2hpZnQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaChldmVudC5rZXkpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ciA9IHRoaXMuYnVmZmVyLmpvaW4oIisiKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmJ1ZmZlci5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDb2xvck1hbmFnZXIgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBfY29sb3JzTWFwcGluZyA9IG5ldyBNYXAoW1siQ2FudmFzVGV4dCIsIFswLCAwLCAwXV0sIFsiQ2FudmFzIiwgWzI1NSwgMjU1LCAyNTVdXV0pOwogICAgICAgICAgICAgICAgICAgIGdldCBfY29sb3JzKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xvcnMgPSBuZXcgTWFwKFtbIkNhbnZhc1RleHQiLCBudWxsXSwgWyJDYW52YXMiLCBudWxsXV0pOwogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q29sb3JWYWx1ZXMpKGNvbG9ycyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiX2NvbG9ycyIsIGNvbG9ycyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnZlcnQoY29sb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmdiID0gKDAsIF9kaXNwbGF5X3V0aWxzLmdldFJHQikoY29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXdpbmRvdy5tYXRjaE1lZGlhKCIoZm9yY2VkLWNvbG9yczogYWN0aXZlKSIpLm1hdGNoZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZ2I7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBbbmFtZSwgUkdCXSBvZiB0aGlzLl9jb2xvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChSR0IuZXZlcnkoKHgsIGkpID0+IHggPT09IHJnYltpXSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gQ29sb3JNYW5hZ2VyLl9jb2xvcnNNYXBwaW5nLmdldChuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmdiOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRIZXhDb2RlKG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmdiID0gdGhpcy5fY29sb3JzLmdldChuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFyZ2IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvciguLi5yZ2IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQ29sb3JNYW5hZ2VyID0gQ29sb3JNYW5hZ2VyOwogICAgICAgICAgICAgICAgdmFyIF9hY3RpdmVFZGl0b3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYWxsRWRpdG9ycyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9hbGxMYXllcnMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYW5ub3RhdGlvblN0b3JhZ2UgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY29tbWFuZE1hbmFnZXIgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY3VycmVudFBhZ2VJbmRleCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9lZGl0b3JUeXBlcyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9lZGl0b3JzVG9SZXNjYWxlID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2V2ZW50QnVzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2lkTWFuYWdlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9pc0VuYWJsZWQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfbW9kZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZWxlY3RlZEVkaXRvcnMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDb3B5ID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kQ3V0ID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kUGFzdGUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRLZXlkb3duID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kT25FZGl0aW5nQWN0aW9uID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kT25QYWdlQ2hhbmdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRPblNjYWxlQ2hhbmdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRPblJvdGF0aW9uQ2hhbmdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfcHJldmlvdXNTdGF0ZXMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY29udGFpbmVyID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2FkZEtleWJvYXJkTWFuYWdlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfYWRkQ29weVBhc3RlTGlzdGVuZXJzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX3JlbW92ZUNvcHlQYXN0ZUxpc3RlbmVycyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwYXRjaFVwZGF0ZVVJID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2VuYWJsZUFsbCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNhYmxlQWxsID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2FkZEVkaXRvclRvTGF5ZXIgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfaXNFbXB0eSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZWxlY3RFZGl0b3JzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihjb250YWluZXIsIGV2ZW50QnVzLCBhbm5vdGF0aW9uU3RvcmFnZSkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3NlbGVjdEVkaXRvcnMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2lzRW1wdHkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2FkZEVkaXRvclRvTGF5ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2Rpc2FibGVBbGwpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2VuYWJsZUFsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVVSSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3JlbW92ZUNvcHlQYXN0ZUxpc3RlbmVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfYWRkQ29weVBhc3RlTGlzdGVuZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2FkZEtleWJvYXJkTWFuYWdlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hY3RpdmVFZGl0b3IsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hbGxFZGl0b3JzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgTWFwKCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hbGxMYXllcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBNYXAoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2Fubm90YXRpb25TdG9yYWdlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY29tbWFuZE1hbmFnZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBDb21tYW5kTWFuYWdlcigpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY3VycmVudFBhZ2VJbmRleCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2VkaXRvclR5cGVzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZWRpdG9yc1RvUmVzY2FsZSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbmV3IFNldCgpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZXZlbnRCdXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9pZE1hbmFnZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBJZE1hbmFnZXIoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2lzRW5hYmxlZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9tb2RlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5OT05FCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgU2V0KCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZENvcHksIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY29weS5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRDdXQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY3V0LmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZFBhc3RlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLnBhc3RlLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZEtleWRvd24sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMua2V5ZG93bi5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRPbkVkaXRpbmdBY3Rpb24sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMub25FZGl0aW5nQWN0aW9uLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZE9uUGFnZUNoYW5naW5nLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLm9uUGFnZUNoYW5naW5nLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZE9uU2NhbGVDaGFuZ2luZywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5vblNjYWxlQ2hhbmdpbmcuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kT25Sb3RhdGlvbkNoYW5naW5nLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLm9uUm90YXRpb25DaGFuZ2luZy5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcHJldmlvdXNTdGF0ZXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VkaXRpbmc6IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzRW1wdHk6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvOiBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2NvbnRhaW5lciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb250YWluZXIsIGNvbnRhaW5lcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZXZlbnRCdXMsIGV2ZW50QnVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuX29uKCJlZGl0aW5nYWN0aW9uIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZE9uRWRpdGluZ0FjdGlvbikpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb24oInBhZ2VjaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblBhZ2VDaGFuZ2luZykpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb24oInNjYWxlY2hhbmdpbmciLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kT25TY2FsZUNoYW5naW5nKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZXZlbnRCdXMpLl9vbigicm90YXRpb25jaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblJvdGF0aW9uQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9hbm5vdGF0aW9uU3RvcmFnZSwgYW5ub3RhdGlvblN0b3JhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZpZXdQYXJhbWV0ZXJzID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhbFNjYWxlOiBfZGlzcGxheV91dGlscy5QaXhlbHNQZXJJbmNoLlBERl9UT19DU1NfVU5JVFMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbjogMAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb2ZmKCJlZGl0aW5nYWN0aW9uIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZE9uRWRpdGluZ0FjdGlvbikpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb2ZmKCJwYWdlY2hhbmdpbmciLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kT25QYWdlQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuX29mZigic2NhbGVjaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblNjYWxlQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuX29mZigicm90YXRpb25jaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblJvdGF0aW9uQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBsYXllciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxheWVyLmRlc3Ryb3koKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnNUb1Jlc2NhbGUpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfYWN0aXZlRWRpdG9yLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLmRlc3Ryb3koKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25QYWdlQ2hhbmdpbmcoX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VOdW1iZXIKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYyOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2N1cnJlbnRQYWdlSW5kZXgsIHBhZ2VOdW1iZXIgLSAxKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9jdXNNYWluQ29udGFpbmVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbnRhaW5lcikuZm9jdXMoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkU2hvdWxkUmVzY2FsZShlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzVG9SZXNjYWxlKS5hZGQoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlU2hvdWxkUmVzY2FsZShlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzVG9SZXNjYWxlKS5kZWxldGUoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25TY2FsZUNoYW5naW5nKF9yZWYzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52aWV3UGFyYW1ldGVycy5yZWFsU2NhbGUgPSBzY2FsZSAqIF9kaXNwbGF5X3V0aWxzLlBpeGVsc1BlckluY2guUERGX1RPX0NTU19VTklUUzsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzVG9SZXNjYWxlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLm9uU2NhbGVDaGFuZ2luZygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uUm90YXRpb25DaGFuZ2luZyhfcmVmNCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZXNSb3RhdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52aWV3UGFyYW1ldGVycy5yb3RhdGlvbiA9IHBhZ2VzUm90YXRpb247CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZFRvQW5ub3RhdGlvblN0b3JhZ2UoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZWRpdG9yLmlzRW1wdHkoKSAmJiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Fubm90YXRpb25TdG9yYWdlKSAmJiAhX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbm5vdGF0aW9uU3RvcmFnZSkuaGFzKGVkaXRvci5pZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYW5ub3RhdGlvblN0b3JhZ2UpLnNldFZhbHVlKGVkaXRvci5pZCwgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb3B5KGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWN0aXZlRWRpdG9yKS5jb21taXRPclJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5oYXNTZWxlY3Rpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlZGl0b3JzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFlZGl0b3IuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9ycy5wdXNoKGVkaXRvci5zZXJpYWxpemUoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvcnMubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuY2xpcGJvYXJkRGF0YS5zZXREYXRhKCJhcHBsaWNhdGlvbi9wZGZqcyIsIEpTT04uc3RyaW5naWZ5KGVkaXRvcnMpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3V0KGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29weShldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVsZXRlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhc3RlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhID0gZXZlbnQuY2xpcGJvYXJkRGF0YS5nZXREYXRhKCJhcHBsaWNhdGlvbi9wZGZqcyIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9IEpTT04ucGFyc2UoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhc3RlOiAiJHtleC5tZXNzYWdlfSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGRhdGEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51bnNlbGVjdEFsbCgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsYXllciA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWxsTGF5ZXJzKS5nZXQoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jdXJyZW50UGFnZUluZGV4KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBuZXdFZGl0b3JzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGVzZXJpYWxpemVkRWRpdG9yID0gbGF5ZXIuZGVzZXJpYWxpemUoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWRlc2VyaWFsaXplZEVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld0VkaXRvcnMucHVzaChkZXNlcmlhbGl6ZWRFZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIG5ld0VkaXRvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfYWRkRWRpdG9yVG9MYXllciwgX2FkZEVkaXRvclRvTGF5ZXIyKS5jYWxsKHRoaXMsIGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NlbGVjdEVkaXRvcnMsIF9zZWxlY3RFZGl0b3JzMikuY2FsbCh0aGlzLCBuZXdFZGl0b3JzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bmRvID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIG5ld0VkaXRvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENvbW1hbmRzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5kbywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYzogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhc3RlOiAiJHtleC5tZXNzYWdlfSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAga2V5ZG93bihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZ2V0QWN0aXZlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoISgoX3RoaXMkZ2V0QWN0aXZlID0gdGhpcy5nZXRBY3RpdmUoKSkgIT09IG51bGwgJiYgX3RoaXMkZ2V0QWN0aXZlICE9PSB2b2lkIDAgJiYgX3RoaXMkZ2V0QWN0aXZlLnNob3VsZEdldEtleWJvYXJkRXZlbnRzKCkpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBBbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyLl9rZXlib2FyZE1hbmFnZXIuZXhlYyh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25FZGl0aW5nQWN0aW9uKGRldGFpbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFsidW5kbyIsICJyZWRvIiwgImRlbGV0ZSIsICJzZWxlY3RBbGwiXS5pbmNsdWRlcyhkZXRhaWxzLm5hbWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzW2RldGFpbHMubmFtZV0oKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRFZGl0aW5nU3RhdGUoaXNFZGl0aW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc0VkaXRpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2FkZEtleWJvYXJkTWFuYWdlciwgX2FkZEtleWJvYXJkTWFuYWdlcjIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hZGRDb3B5UGFzdGVMaXN0ZW5lcnMsIF9hZGRDb3B5UGFzdGVMaXN0ZW5lcnMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzRWRpdGluZzogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9tb2RlKSAhPT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuTk9ORSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VtcHR5OiBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9pc0VtcHR5LCBfaXNFbXB0eTIpLmNhbGwodGhpcyksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvOiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbW1hbmRNYW5hZ2VyKS5oYXNTb21ldGhpbmdUb1VuZG8oKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLmhhc1NvbWV0aGluZ1RvUmVkbygpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVtb3ZlQ29weVBhc3RlTGlzdGVuZXJzLCBfcmVtb3ZlQ29weVBhc3RlTGlzdGVuZXJzMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VkaXRpbmc6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZWdpc3RlckVkaXRvclR5cGVzKHR5cGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvclR5cGVzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZWRpdG9yVHlwZXMsIHR5cGVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3JUeXBlIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9yVHlwZXMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVVJLCBfZGlzcGF0Y2hVcGRhdGVVSTIpLmNhbGwodGhpcywgZWRpdG9yVHlwZS5kZWZhdWx0UHJvcGVydGllc1RvVXBkYXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRJZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaWRNYW5hZ2VyKS5nZXRJZCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgY3VycmVudExheWVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxMYXllcnMpLmdldChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2N1cnJlbnRQYWdlSW5kZXgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGN1cnJlbnRQYWdlSW5kZXgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2N1cnJlbnRQYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRMYXllcihsYXllcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuc2V0KGxheWVyLnBhZ2VJbmRleCwgbGF5ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0VuYWJsZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllci5lbmFibGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxheWVyLmRpc2FibGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW1vdmVMYXllcihsYXllcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuZGVsZXRlKGxheWVyLnBhZ2VJbmRleCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZU1vZGUobW9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX21vZGUsIG1vZGUpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuTk9ORSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRFZGl0aW5nU3RhdGUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzYWJsZUFsbCwgX2Rpc2FibGVBbGwyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRFZGl0aW5nU3RhdGUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9lbmFibGVBbGwsIF9lbmFibGVBbGwyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBsYXllciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllci51cGRhdGVNb2RlKG1vZGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZVRvb2xiYXIobW9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9tb2RlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZXZlbnRCdXMpLmRpc3BhdGNoKCJzd2l0Y2hhbm5vdGF0aW9uZWRpdG9ybW9kZSIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZVBhcmFtcyh0eXBlLCB2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9yVHlwZXMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IudXBkYXRlUGFyYW1zKHR5cGUsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvclR5cGUgb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JUeXBlcykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvclR5cGUudXBkYXRlRGVmYXVsdFBhcmFtcyh0eXBlLCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RWRpdG9ycyhwYWdlSW5kZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9ycyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbEVkaXRvcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLnBhZ2VJbmRleCA9PT0gcGFnZUluZGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9ycy5wdXNoKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGVkaXRvcnM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEVkaXRvcihpZCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5nZXQoaWQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRFZGl0b3IoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWxsRWRpdG9ycykuc2V0KGVkaXRvci5pZCwgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlRWRpdG9yKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5kZWxldGUoZWRpdG9yLmlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51bnNlbGVjdChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYW5ub3RhdGlvblN0b3JhZ2UpKSA9PT0gbnVsbCB8fCBfY2xhc3NQcml2YXRlRmllbGRHZXQyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfY2xhc3NQcml2YXRlRmllbGRHZXQyLnJlbW92ZShlZGl0b3IuaWQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRBY3RpdmVFZGl0b3IoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikgPT09IGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfYWN0aXZlRWRpdG9yLCBlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVVJLCBfZGlzcGF0Y2hVcGRhdGVVSTIpLmNhbGwodGhpcywgZWRpdG9yLnByb3BlcnRpZXNUb1VwZGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdG9nZ2xlU2VsZWN0ZWQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykuaGFzKGVkaXRvcikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5kZWxldGUoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiB0aGlzLmhhc1NlbGVjdGlvbgogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2VsZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlVUksIF9kaXNwYXRjaFVwZGF0ZVVJMikuY2FsbCh0aGlzLCBlZGl0b3IucHJvcGVydGllc1RvVXBkYXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU2VsZWN0ZWRFZGl0b3I6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFNlbGVjdGVkKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVkICE9PSBlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZC51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykuYWRkKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5zZWxlY3QoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVVSSwgX2Rpc3BhdGNoVXBkYXRlVUkyKS5jYWxsKHRoaXMsIGVkaXRvci5wcm9wZXJ0aWVzVG9VcGRhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTZWxlY3RlZEVkaXRvcjogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNTZWxlY3RlZChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5oYXMoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdW5zZWxlY3QoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykuZGVsZXRlKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiB0aGlzLmhhc1NlbGVjdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGhhc1NlbGVjdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5zaXplICE9PSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1bmRvKCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbW1hbmRNYW5hZ2VyKS51bmRvKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NvbWV0aGluZ1RvVW5kbzogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb21tYW5kTWFuYWdlcikuaGFzU29tZXRoaW5nVG9VbmRvKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VtcHR5OiBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9pc0VtcHR5LCBfaXNFbXB0eTIpLmNhbGwodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlZG8oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLnJlZG8oKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9SZWRvOiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbW1hbmRNYW5hZ2VyKS5oYXNTb21ldGhpbmdUb1JlZG8oKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzRW1wdHk6IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2lzRW1wdHksIF9pc0VtcHR5MikuY2FsbCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkQ29tbWFuZHMocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLmFkZChwYXJhbXMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1VuZG86IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNFbXB0eTogX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfaXNFbXB0eSwgX2lzRW1wdHkyKS5jYWxsKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZWxldGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmhhc1NlbGVjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVkaXRvcnMgPSBbLi4uX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgZWRpdG9ycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdW5kbyA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIGVkaXRvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hZGRFZGl0b3JUb0xheWVyLCBfYWRkRWRpdG9yVG9MYXllcjIpLmNhbGwodGhpcywgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRDb21tYW5kcyh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bmRvLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbW1pdE9yUmVtb3ZlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MzsKICAgICAgICAgICAgICAgICAgICAgICAgKF9jbGFzc1ByaXZhdGVGaWVsZEdldDMgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikpID09PSBudWxsIHx8IF9jbGFzc1ByaXZhdGVGaWVsZEdldDMgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9jbGFzc1ByaXZhdGVGaWVsZEdldDMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2VsZWN0QWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5jb21taXQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZWxlY3RFZGl0b3JzLCBfc2VsZWN0RWRpdG9yczIpLmNhbGwodGhpcywgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS52YWx1ZXMoKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVuc2VsZWN0QWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hY3RpdmVFZGl0b3IpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLnNpemUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTZWxlY3RlZEVkaXRvcjogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzQWN0aXZlKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hY3RpdmVFZGl0b3IpID09PSBlZGl0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFjdGl2ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWN0aXZlRWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbW9kZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyID0gQW5ub3RhdGlvbkVkaXRvclVJTWFuYWdlcjsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9hZGRLZXlib2FyZE1hbmFnZXIyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29udGFpbmVyK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tb3ZlRXZlbnRMaXN0ZW5lcigiY3V0IiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEN1dCkpOwogICAgICAgICAgICAgICAgICAgIGRvY3VtZW50LnJlbW92ZUV2ZW50TGlzdGVuZXIoInBhc3RlIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZFBhc3RlKSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKGRldGFpbHMpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBoYXNDaGFuZ2VkID0gT2JqZWN0LmVudHJpZXMoZGV0YWlscykuc29tZShfcmVmNSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBba2V5LCB2YWx1ZV0gPSBfcmVmNTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfcHJldmlvdXNTdGF0ZXMpW2tleV0gIT09IHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIGlmIChoYXNDaGFuZ2VkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZXZlbnRCdXMpLmRpc3BhdGNoKCJhbm5vdGF0aW9uZWRpdG9yc3RhdGVzY2hhbmdlZCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbHM6IE9iamVjdC5hc3NpZ24oX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wcmV2aW91c1N0YXRlcyksIGRldGFpbHMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9kaXNwYXRjaFVwZGF0ZVVJMihkZXRhaWxzKSB7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuZGlzcGF0Y2goImFubm90YXRpb25lZGl0b3JwYXJhbXNjaGFuZ2VkIiwgewogICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbHMKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9lbmFibGVBbGwyKCkgewogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0VuYWJsZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaXNFbmFibGVkLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBsYXllciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxheWVyLmVuYWJsZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2Rpc2FibGVBbGwyKCkgewogICAgICAgICAgICAgICAgICAgIHRoaXMudW5zZWxlY3RBbGwoKTsKICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0VuYWJsZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaXNFbmFibGVkLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbGF5ZXIgb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxMYXllcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllci5kaXNhYmxlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfYWRkRWRpdG9yVG9MYXllcjIoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGF5ZXIgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuZ2V0KGVkaXRvci5wYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgIGlmIChsYXllcikgewogICAgICAgICAgICAgICAgICAgICAgICBsYXllci5hZGRPclJlYnVpbGQoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZEVkaXRvcihlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9pc0VtcHR5MigpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5zaXplID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5zaXplID09PSAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWxsRWRpdG9ycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlZGl0b3IuaXNFbXB0eSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9zZWxlY3RFZGl0b3JzMihlZGl0b3JzKSB7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgZWRpdG9ycykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2VsZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgaGFzU2VsZWN0ZWRFZGl0b3I6IHRydWUKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShBbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyLCAiX2tleWJvYXJkTWFuYWdlciIsIG5ldyBLZXlib2FyZE1hbmFnZXIoW1tbImN0cmwrYSIsICJtYWMrbWV0YSthIl0sIEFubm90YXRpb25FZGl0b3JVSU1hbmFnZXIucHJvdG90eXBlLnNlbGVjdEFsbF0sIFtbImN0cmwreiIsICJtYWMrbWV0YSt6Il0sIEFubm90YXRpb25FZGl0b3JVSU1hbmFnZXIucHJvdG90eXBlLnVuZG9dLCBbWyJjdHJsK3kiLCAiY3RybCtzaGlmdCtaIiwgIm1hYyttZXRhK3NoaWZ0K1oiXSwgQW5ub3RhdGlvbkVkaXRvclVJTWFuYWdlci5wcm90b3R5cGUucmVkb10sIFtbIkJhY2tzcGFjZSIsICJhbHQrQmFja3NwYWNlIiwgImN0cmwrQmFja3NwYWNlIiwgInNoaWZ0K0JhY2tzcGFjZSIsICJtYWMrQmFja3NwYWNlIiwgIm1hYythbHQrQmFja3NwYWNlIiwgIm1hYytjdHJsK0JhY2tzcGFjZSIsICJEZWxldGUiLCAiY3RybCtEZWxldGUiLCAic2hpZnQrRGVsZXRlIl0sIEFubm90YXRpb25FZGl0b3JVSU1hbmFnZXIucHJvdG90eXBlLmRlbGV0ZV0sIFtbIkVzY2FwZSIsICJtYWMrRXNjYXBlIl0sIEFubm90YXRpb25FZGl0b3JVSU1hbmFnZXIucHJvdG90eXBlLnVuc2VsZWN0QWxsXV0pKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQyICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgIC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MDsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgUERGX1RPX0NTU19VTklUUyA9IHRoaXMuQ1NTIC8gdGhpcy5QREY7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBpeGVsc1BlckluY2ggPSBQaXhlbHNQZXJJbmNoOwogICAgICAgICAgICAgICAgdmFyIF9jYWNoZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9kZWZzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2RvY0lkID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2RvY3VtZW50ID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2hjbUZpbHRlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9oY21LZXkgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfaGNtVXJsID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2lkID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2NhY2hlMiA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9kZWZzMiA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9hcHBlbmRGZUZ1bmMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIERPTUZpbHRlckZhY3RvcnkgZXh0ZW5kcyBfYmFzZV9mYWN0b3J5LkJhc2VGaWx0ZXJGYWN0b3J5IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvY0lkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3duZXJEb2N1bWVudCA9IGdsb2JhbFRoaXMuZG9jdW1lbnQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfYXBwZW5kRmVGdW5jKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2RlZnMyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXQ6IF9nZXRfZGVmcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldDogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY2FjaGUyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXQ6IF9nZXRfY2FjaGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXQ6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2NhY2hlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9kZWZzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9kb2NJZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZG9jdW1lbnQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2hjbUZpbHRlciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfaGNtS2V5LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9oY21VcmwsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2lkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2RvY0lkLCBkb2NJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZG9jdW1lbnQsIG93bmVyRG9jdW1lbnQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRGaWx0ZXIobWFwcykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkaWQsIF90aGlzJGlkMjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFtYXBzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gIm5vbmUiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2YWx1ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUyKS5nZXQobWFwcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0YWJsZVIsIHRhYmxlRywgdGFibGVCLCBrZXk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXBzLmxlbmd0aCA9PT0gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFwUiA9IG1hcHNbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBuZXcgQXJyYXkoMjU2KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgMjU2OyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBidWZmZXJbaV0gPSBtYXBSW2ldIC8gMjU1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5ID0gdGFibGVSID0gdGFibGVHID0gdGFibGVCID0gYnVmZmVyLmpvaW4oIiwiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFttYXBSLCBtYXBHLCBtYXBCXSA9IG1hcHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXJSID0gbmV3IEFycmF5KDI1Nik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXJHID0gbmV3IEFycmF5KDI1Nik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXJCID0gbmV3IEFycmF5KDI1Nik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI1NjsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyUltpXSA9IG1hcFJbaV0gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyR1tpXSA9IG1hcEdbaV0gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyQltpXSA9IG1hcEJbaV0gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YWJsZVIgPSBidWZmZXJSLmpvaW4oIiwiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhYmxlRyA9IGJ1ZmZlckcuam9pbigiLCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFibGVCID0gYnVmZmVyQi5qb2luKCIsIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZXkgPSBgJHt0YWJsZVJ9JHt0YWJsZUd9JHt0YWJsZUJ9YDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUyKS5nZXQoa2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlMikuc2V0KG1hcHMsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IGBnXyR7X2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kb2NJZCl9X3RyYW5zZmVyX21hcF8keyhfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2lkLCAoX3RoaXMkaWQgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2lkKSwgX3RoaXMkaWQyID0gX3RoaXMkaWQrKywgX3RoaXMkaWQpKSwgX3RoaXMkaWQyKX1gOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBgdXJsKCMke2lkfSlgOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlMikuc2V0KG1hcHMsIHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUyKS5zZXQoa2V5LCB1cmwpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWx0ZXIgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZmlsdGVyIiwgU1ZHX05TKTsKICAgICAgICAgICAgICAgICAgICAgICAgZmlsdGVyLnNldEF0dHJpYnV0ZSgiaWQiLCBpZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlci5zZXRBdHRyaWJ1dGUoImNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycyIsICJzUkdCIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZlQ29tcG9uZW50VHJhbnNmZXIgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZmVDb21wb25lbnRUcmFuc2ZlciIpOwogICAgICAgICAgICAgICAgICAgICAgICBmaWx0ZXIuYXBwZW5kKGZlQ29tcG9uZW50VHJhbnNmZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hcHBlbmRGZUZ1bmMsIF9hcHBlbmRGZUZ1bmMyKS5jYWxsKHRoaXMsIGZlQ29tcG9uZW50VHJhbnNmZXIsICJmZUZ1bmNSIiwgdGFibGVSKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfYXBwZW5kRmVGdW5jLCBfYXBwZW5kRmVGdW5jMikuY2FsbCh0aGlzLCBmZUNvbXBvbmVudFRyYW5zZmVyLCAiZmVGdW5jRyIsIHRhYmxlRyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2FwcGVuZEZlRnVuYywgX2FwcGVuZEZlRnVuYzIpLmNhbGwodGhpcywgZmVDb21wb25lbnRUcmFuc2ZlciwgImZlRnVuY0IiLCB0YWJsZUIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMyKS5hcHBlbmQoZmlsdGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVybDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkSENNRmlsdGVyKGZnQ29sb3IsIGJnQ29sb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9jbGFzc1ByaXZhdGVGaWVsZEdldDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGtleSA9IGAke2ZnQ29sb3J9LSR7YmdDb2xvcn1gOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oY21LZXkpID09PSBrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2hjbVVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9oY21LZXksIGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGNtVXJsLCAibm9uZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaGNtRmlsdGVyKSkgPT09IG51bGwgfHwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0Mi5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFmZ0NvbG9yIHx8ICFiZ0NvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oY21VcmwpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVmczIpLnN0eWxlLmNvbG9yID0gZmdDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgZmdDb2xvciA9IGdldENvbXB1dGVkU3R5bGUoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kZWZzMikpLmdldFByb3BlcnR5VmFsdWUoImNvbG9yIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZnUkdCID0gZ2V0UkdCKGZnQ29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBmZ0NvbG9yID0gX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IoLi4uZmdSR0IpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMyKS5zdHlsZS5jb2xvciA9IGJnQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIGJnQ29sb3IgPSBnZXRDb21wdXRlZFN0eWxlKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVmczIpKS5nZXRQcm9wZXJ0eVZhbHVlKCJjb2xvciIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiZ1JHQiA9IGdldFJHQihiZ0NvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgYmdDb2xvciA9IF91dGlsLlV0aWwubWFrZUhleENvbG9yKC4uLmJnUkdCKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kZWZzMikuc3R5bGUuY29sb3IgPSAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZnQ29sb3IgPT09ICIjMDAwMDAwIiAmJiBiZ0NvbG9yID09PSAiI2ZmZmZmZiIgfHwgZmdDb2xvciA9PT0gYmdDb2xvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaGNtVXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXAgPSBuZXcgQXJyYXkoMjU2KTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPD0gMjU1OyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHggPSBpIC8gMjU1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwW2ldID0geCA8PSAwLjAzOTI4ID8geCAvIDEyLjkyIDogKCh4ICsgMC4wNTUpIC8gMS4wNTUpICoqIDIuNDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0YWJsZSA9IG1hcC5qb2luKCIsIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gYGdfJHtfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY0lkKX1faGNtX2ZpbHRlcmA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpbHRlciA9IF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGNtRmlsdGVyLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Rv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NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZmVDb2xvck1hdHJpeCIpOwogICAgICAgICAgICAgICAgICAgICAgICBmZUNvbG9yTWF0cml4LnNldEF0dHJpYnV0ZSgidHlwZSIsICJtYXRyaXgiKTsKICAgICAgICAgICAgICAgICAgICAgICAgZmVDb2xvck1hdHJpeC5zZXRBdHRyaWJ1dGUoInZhbHVlcyIsICIwLjIxMjYgMC43MTUyIDAuMDcyMiAwIDAgMC4yMTI2IDAuNzE1MiAwLjA3MjIgMCAwIDAuMjEyNiAwLjcxNTIgMC4wNzIyIDAgMCAwIDAgMCAxIDAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgZmlsdGVyLmFwcGVuZChmZUNvbG9yTWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgZmVDb21wb25lbnRUcmFuc2ZlciA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZG9jdW1lbnQpLmNyZWF0ZUVsZW1lbnROUyhTVkdfTlMsICJmZUNvbXBvbmVudFRyYW5zZmVyIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlci5hcHBlbmQoZmVDb21wb25lbnRUcmFuc2Zlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdldFN0ZXBzID0gKGMsIG4pID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0YXJ0ID0gZmdSR0JbY10gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmQgPSBiZ1JHQltjXSAvIDI1NTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyciA9IG5ldyBBcnJheShuICsgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8PSBuOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcnJbaV0gPSBzdGFydCArIGkgLyBuICogKGVuZCAtIHN0YXJ0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcnIuam9pbigiLCIpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hcHBlbmRGZUZ1bmMsIF9hcHBlbmRGZUZ1bmMyKS5jYWxsKHRoaXMsIGZlQ29tcG9uZW50VHJhbnNmZXIsICJmZUZ1bmNSIiwgZ2V0U3RlcHMoMCwgNSkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hcHBlbmRGZUZ1bmMsIF9hcHBlbmRGZUZ1bmMyKS5jYWxsKHRoaXMsIGZlQ29tcG9uZW50VHJhbnNmZXIsICJmZUZ1bmNHIiwgZ2V0U3RlcHMoMSwgNSkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hcHBlbmRGZUZ1bmMsIF9hcHBlbmRGZUZ1bmMyKS5jYWxsKHRoaXMsIGZlQ29tcG9uZW50VHJhbnNmZXIsICJmZUZ1bmNCIiwgZ2V0U3RlcHMoMiwgNSkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMyKS5hcHBlbmQoZmlsdGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9oY21VcmwsIGB1cmwoIyR7aWR9KWApOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oY21VcmwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQga2VlcEhDTSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChrZWVwSENNICYmIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaGNtVXJsKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMpLnBhcmVudE5vZGUucGFyZW50Tm9kZS5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZGVmcywgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jYWNoZSwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9pZCwgMCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5ET01GaWx0ZXJGYWN0b3J5ID0gRE9NRmlsdGVyRmFjdG9yeTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9nZXRfY2FjaGUoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUpIHx8IF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfY2FjaGUsIG5ldyBNYXAoKSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZ2V0X2RlZnMoKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRpdiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZG9jdW1lbnQpLmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gZGl2OwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLmNvbnRhaW4gPSAic3RyaWN0IjsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUud2lkdGggPSBzdHlsZS5oZWlnaHQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5wb3NpdGlvbiA9ICJhYnNvbHV0ZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLnRvcCA9IHN0eWxlLmxlZnQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS56SW5kZXggPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ZnID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kb2N1bWVudCkuY3JlYXRlRWxlbWVudE5TKFNWR19OUywgInN2ZyIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuc2V0QXR0cmlidXRlKCJ3aWR0aCIsIDApOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuc2V0QXR0cmlidXRlKCJoZWlnaHQiLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9kZWZzLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZGVmcyIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LmFwcGVuZChzdmcpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuYXBwZW5kKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVmcykpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5ib2R5LmFwcGVuZChkaXYpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kZWZzKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9hcHBlbmRGZUZ1bmMyKGZlQ29tcG9uZW50VHJhbnNmZXIsIGZ1bmMsIHRhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZmVGdW5jID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kb2N1bWVudCkuY3JlYXRlRWxlbWVudE5TKFNWR19OUywgZnVuYyk7CiAgICAgICAgICAgICAgICAgICAgZmVGdW5jLnNldEF0dHJpYnV0ZSgidHlwZSIsICJkaXNjcmV0ZSIpOwogICAgICAgICAgICAgICAgICAgIGZlRnVuYy5zZXRBdHRyaWJ1dGUoInRhYmxlVmFsdWVzIiwgdGFibGUpOwogICAgICAgICAgICAgICAgICAgIGZlQ29tcG9uZW50VHJhbnNmZXIuYXBwZW5kKGZlRnVuYyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBET01DYW52YXNGYWN0b3J5IGV4dGVuZHMgX2Jhc2VfZmFjdG9yeS5CYXNlQ2FudmFzRmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvd25lckRvY3VtZW50ID0gZ2xvYmFsVGhpcy5kb2N1bWVudAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9jdW1lbnQgPSBvd25lckRvY3VtZW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY3JlYXRlQ2FudmFzKHdpZHRoLCBoZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FudmFzID0gdGhpcy5fZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiY2FudmFzIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcy53aWR0aCA9IHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjYW52YXMuaGVpZ2h0ID0gaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FudmFzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRE9NQ2FudmFzRmFjdG9yeSA9IERPTUNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICBhc3luYyBmdW5jdGlvbiBmZXRjaERhdGEodXJsKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IGFzVHlwZWRBcnJheSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzVmFsaWRGZXRjaFVybCh1cmwsIGRvY3VtZW50LmJhc2VVUkkpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlc3BvbnNlID0gYXdhaXQgZmV0Y2godXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFyZXNwb25zZS5vaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKHJlc3BvbnNlLnN0YXR1c1RleHQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhc1R5cGVkQXJyYXkgPyBuZXcgVWludDhBcnJheShhd2FpdCByZXNwb25zZS5hcnJheUJ1ZmZlcigpKSA6ICgwLCBfdXRpbC5zdHJpbmdUb0J5dGVzKShhd2FpdCByZXNwb25zZS50ZXh0KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0ID0gbmV3IFhNTEh0dHBSZXF1ZXN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3Qub3BlbigiR0VUIiwgdXJsLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFzVHlwZWRBcnJheSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdC5yZXNwb25zZVR5cGUgPSAiYXJyYXlidWZmZXIiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3Qub25yZWFkeXN0YXRlY2hhbmdlID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlcXVlc3QucmVhZHlTdGF0ZSAhPT0gWE1MSHR0cFJlcXVlc3QuRE9ORSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXF1ZXN0LnN0YXR1cyA9PT0gMjAwIHx8IHJlcXVlc3Quc3RhdHVzID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFzVHlwZWRBcnJheSAmJiByZXF1ZXN0LnJlc3BvbnNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEgPSBuZXcgVWludDhBcnJheShyZXF1ZXN0LnJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKCFhc1R5cGVkQXJyYXkgJiYgcmVxdWVzdC5yZXNwb25zZVRleHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9ICgwLCBfdXRpbC5zdHJpbmdUb0J5dGVzKShyZXF1ZXN0LnJlc3BvbnNlVGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWplY3QobmV3IEVycm9yKHJlcXVlc3Quc3RhdHVzVGV4dCkpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0LnNlbmQobnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBET01DTWFwUmVhZGVyRmFjdG9yeSBleHRlbmRzIF9iYXNlX2ZhY3RvcnkuQmFzZUNNYXBSZWFkZXJGYWN0b3J5IHsKICAgICAgICAgICAgICAgICAgICBfZmV0Y2hEYXRhKHVybCwgY29tcHJlc3Npb25UeXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmZXRjaERhdGEodXJsLCB0aGlzLmlzQ29tcHJlc3NlZCkudGhlbihkYXRhID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY01hcERhdGE6IGRhdGEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tcHJlc3Npb25UeXBlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkRPTUNNYXBSZWFkZXJGYWN0b3J5ID0gRE9NQ01hcFJlYWRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBET01TdGFuZGFyZEZvbnREYXRhRmFjdG9yeSBleHRlbmRzIF9iYXNlX2ZhY3RvcnkuQmFzZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5IHsKICAgICAgICAgICAgICAgICAgICBfZmV0Y2hEYXRhKHVybCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmV0Y2hEYXRhKHVybCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5ET01TdGFuZGFyZEZvbnREYXRhRmFjdG9yeSA9IERPTVN0YW5kYXJkRm9udERhdGFGYWN0b3J5OwogICAgICAgICAgICAgICAgY2xhc3MgRE9NU1ZHRmFjdG9yeSBleHRlbmRzIF9iYXNlX2ZhY3RvcnkuQmFzZVNWR0ZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIF9jcmVhdGVTVkcodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudE5TKFNWR19OUywgdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5ET01TVkdGYWN0b3J5ID0gRE9NU1ZHRmFjdG9yeTsKICAgICAgICAgICAgICAgIGNsYXNzIFBhZ2VWaWV3cG9ydCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoX3JlZikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld0JveCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb24sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRYID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFkgPSAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9udEZsaXAgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52aWV3Qm94ID0gdmlld0JveDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zY2FsZSA9IHNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJvdGF0aW9uID0gcm90YXRpb247CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub2Zmc2V0WCA9IG9mZnNldFg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub2Zmc2V0WSA9IG9mZnNldFk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNlbnRlclggPSAodmlld0JveFsyXSArIHZpZXdCb3hbMF0pIC8gMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2VudGVyWSA9ICh2aWV3Qm94WzNdICsgdmlld0JveFsxXSkgLyAyOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcm90YXRlQSwgcm90YXRlQiwgcm90YXRlQywgcm90YXRlRDsKICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb24gJT0gMzYwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocm90YXRpb24gPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbiArPSAzNjA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChyb3RhdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxODA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlQSA9IC0xOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0ZUIgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0ZUMgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0ZUQgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSA5MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVBID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVCID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVDID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVEID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMjcwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0ZUEgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0ZUIgPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVDID0gLTE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlRCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlQSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlQiA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlQyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlRCA9IC0xOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIlBhZ2VWaWV3cG9ydDogSW52YWxpZCByb3RhdGlvbiwgbXVzdCBiZSBhIG11bHRpcGxlIG9mIDkwIGRlZ3JlZXMuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRvbnRGbGlwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVDID0gLXJvdGF0ZUM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVEID0gLXJvdGF0ZUQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG9mZnNldENhbnZhc1gsIG9mZnNldENhbnZhc1k7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB3aWR0aCwgaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocm90YXRlQSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0Q2FudmFzWCA9IE1hdGguYWJzKGNlbnRlclkgLSB2aWV3Qm94WzFdKSAqIHNjYWxlICsgb2Zmc2V0WDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldENhbnZhc1kgPSBNYXRoLmFicyhjZW50ZXJYIC0gdmlld0JveFswXSkgKiBzY2FsZSArIG9mZnNldFk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCA9ICh2aWV3Qm94WzNdIC0gdmlld0JveFsxXSkgKiBzY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodCA9ICh2aWV3Qm94WzJdIC0gdmlld0JveFswXSkgKiBzY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldENhbnZhc1ggPSBNYXRoLmFicyhjZW50ZXJYIC0gdmlld0JveFswXSkgKiBzY2FsZSArIG9mZnNldFg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRDYW52YXNZID0gTWF0aC5hYnMoY2VudGVyWSAtIHZpZXdCb3hbMV0pICogc2NhbGUgKyBvZmZzZXRZOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGggPSAodmlld0JveFsyXSAtIHZpZXdCb3hbMF0pICogc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQgPSAodmlld0JveFszXSAtIHZpZXdCb3hbMV0pICogc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm0gPSBbcm90YXRlQSAqIHNjYWxlLCByb3RhdGVCICogc2NhbGUsIHJvdGF0ZUMgKiBzY2FsZSwgcm90YXRlRCAqIHNjYWxlLCBvZmZzZXRDYW52YXNYIC0gcm90YXRlQSAqIHNjYWxlICogY2VudGVyWCAtIHJvdGF0ZUMgKiBzY2FsZSAqIGNlbnRlclksIG9mZnNldENhbnZhc1kgLSByb3RhdGVCICogc2NhbGUgKiBjZW50ZXJYIC0gcm90YXRlRCAqIHNjYWxlICogY2VudGVyWV07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMud2lkdGggPSB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5oZWlnaHQgPSBoZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCByYXdEaW1zKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3Qm94CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInJhd0RpbXMiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlV2lkdGg6IHZpZXdCb3hbMl0gLSB2aWV3Qm94WzBdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUhlaWdodDogdmlld0JveFszXSAtIHZpZXdCb3hbMV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlWDogdmlld0JveFswXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VZOiB2aWV3Qm94WzFdCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjbG9uZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlID0gdGhpcy5zY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uID0gdGhpcy5yb3RhdGlvbiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFggPSB0aGlzLm9mZnNldFgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZID0gdGhpcy5vZmZzZXRZLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9udEZsaXAgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBQYWdlVmlld3BvcnQoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld0JveDogdGhpcy52aWV3Qm94LnNsaWNlKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0WCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb250RmxpcAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29udmVydFRvVmlld3BvcnRQb2ludCh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFt4LCB5XSwgdGhpcy50cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb252ZXJ0VG9WaWV3cG9ydFJlY3RhbmdsZShyZWN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRvcExlZnQgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFtyZWN0WzBdLCByZWN0WzFdXSwgdGhpcy50cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBib3R0b21SaWdodCA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oW3JlY3RbMl0sIHJlY3RbM11dLCB0aGlzLnRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbdG9wTGVmdFswXSwgdG9wTGVmdFsxXSwgYm90dG9tUmlnaHRbMF0sIGJvdHRvbVJpZ2h0WzFdXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29udmVydFRvUGRmUG9pbnQoeCwgeSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuVXRpbC5hcHBseUludmVyc2VUcmFuc2Zvcm0oW3gsIHldLCB0aGlzLnRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5QYWdlVmlld3BvcnQgPSBQYWdlVmlld3BvcnQ7CiAgICAgICAgICAgICAgICBjbGFzcyBSZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb24gZXh0ZW5kcyBfdXRpbC5CYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2csIHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGV4dHJhRGVsYXkgPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIlJlbmRlcmluZ0NhbmNlbGxlZEV4Y2VwdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnR5cGUgPSB0eXBlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmV4dHJhRGVsYXkgPSBleHRyYURlbGF5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuUmVuZGVyaW5nQ2FuY2VsbGVkRXhjZXB0aW9uID0gUmVuZGVyaW5nQ2FuY2VsbGVkRXhjZXB0aW9uOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gaXNEYXRhU2NoZW1lKHVybCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IGlpID0gdXJsLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICBsZXQgaSA9IDA7CiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGkgPCBpaSAmJiB1cmxbaV0udHJpbSgpID09PSAiIikgewogICAgICAgICAgICAgICAgICAgICAgICBpKys7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiB1cmwuc3Vic3RyaW5nKGksIGkgKyA1KS50b0xvd2VyQ2FzZSgpID09PSAiZGF0YToiOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gaXNQZGZGaWxlKGZpbGVuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiBmaWxlbmFtZSA9PT0gInN0cmluZyIgJiYgL1wucGRmJC9pLnRlc3QoZmlsZW5hbWUpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0RmlsZW5hbWVGcm9tVXJsKHVybCkgewogICAgICAgICAgICAgICAgICAgIGxldCBvbmx5U3RyaXBQYXRoID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICBpZiAoIW9ubHlTdHJpcFBhdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgW3VybF0gPSB1cmwuc3BsaXQoL1sjP10vLCAxKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVybC5zdWJzdHJpbmcodXJsLmxhc3RJbmRleE9mKCIvIikgKyAxKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldFBkZkZpbGVuYW1lRnJvbVVybCh1cmwpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgZGVmYXVsdEZpbGVuYW1lID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiAiZG9jdW1lbnQucGRmIjsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHVybCAhPT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmF1bHRGaWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzRGF0YVNjaGVtZSh1cmwpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgnZ2V0UGRmRmlsZW5hbWVGcm9tVXJsOiBpZ25vcmUgImRhdGE6Ii1VUkwgZm9yIHBlcmZvcm1hbmNlIHJlYXNvbnMuJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBkZWZhdWx0RmlsZW5hbWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlVVJJID0gL14oPzooPzpbXjpdKzopP1wvXC9bXi9dKyk/KFtePyNdKikoXD9bXiNdKik/KCMuKik/JC87CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVGaWxlbmFtZSA9IC9bXi8/Iz1dK1wucGRmXGIoPyEuKlwucGRmXGIpL2k7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3BsaXRVUkkgPSByZVVSSS5leGVjKHVybCk7CiAgICAgICAgICAgICAgICAgICAgbGV0IHN1Z2dlc3RlZEZpbGVuYW1lID0gcmVGaWxlbmFtZS5leGVjKHNwbGl0VVJJWzFdKSB8fCByZUZpbGVuYW1lLmV4ZWMoc3BsaXRVUklbMl0pIHx8IHJlRmlsZW5hbWUuZXhlYyhzcGxpdFVSSVszXSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHN1Z2dlc3RlZEZpbGVuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1Z2dlc3RlZEZpbGVuYW1lID0gc3VnZ2VzdGVkRmlsZW5hbWVbMF07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdWdnZXN0ZWRGaWxlbmFtZS5pbmNsdWRlcygiJSIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1Z2dlc3RlZEZpbGVuYW1lID0gcmVGaWxlbmFtZS5leGVjKGRlY29kZVVSSUNvbXBvbmVudChzdWdnZXN0ZWRGaWxlbmFtZSkpWzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHt9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN1Z2dlc3RlZEZpbGVuYW1lIHx8IGRlZmF1bHRGaWxlbmFtZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFN0YXRUaW1lciB7CiAgICAgICAgICAgICAgICAgICAgc3RhcnRlZCA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgICAgICAgICAgICAgICAgdGltZXMgPSBbXTsKICAgICAgICAgICAgICAgICAgICB0aW1lKG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hbWUgaW4gdGhpcy5zdGFydGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYFRpbWVyIGlzIGFscmVhZHkgcnVubmluZyBmb3IgJHtuYW1lfWApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhcnRlZFtuYW1lXSA9IERhdGUubm93KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRpbWVFbmQobmFtZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIShuYW1lIGluIHRoaXMuc3RhcnRlZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgVGltZXIgaGFzIG5vdCBiZWVuIHN0YXJ0ZWQgZm9yICR7bmFtZX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRpbWVzLnB1c2goewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0OiB0aGlzLnN0YXJ0ZWRbbmFtZV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmQ6IERhdGUubm93KCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSB0aGlzLnN0YXJ0ZWRbbmFtZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRvU3RyaW5nKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvdXRCdWYgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGxvbmdlc3QgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUKICAgICAgICAgICAgICAgICAgICAgICAgfSBvZiB0aGlzLnRpbWVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb25nZXN0ID0gTWF0aC5tYXgobmFtZS5sZW5ndGgsIGxvbmdlc3QpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5kCiAgICAgICAgICAgICAgICAgICAgICAgIH0gb2YgdGhpcy50aW1lcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0QnVmLnB1c2goYCR7bmFtZS5wYWRFbmQobG9uZ2VzdCl9ICR7ZW5kIC0gc3RhcnR9bXNcbmApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBvdXRCdWYuam9pbigiIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5TdGF0VGltZXIgPSBTdGF0VGltZXI7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBpc1ZhbGlkRmV0Y2hVcmwodXJsLCBiYXNlVXJsKSB7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvdG9jb2wKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGJhc2VVcmwgPyBuZXcgVVJMKHVybCwgYmFzZVVybCkgOiBuZXcgVVJMKHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwcm90b2NvbCA9PT0gImh0dHA6IiB8fCBwcm90b2NvbCA9PT0gImh0dHBzOiI7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGxvYWRTY3JpcHQoc3JjKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IHJlbW92ZVNjcmlwdEVsZW1lbnQgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjcmlwdCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInNjcmlwdCIpOwogICAgICAgICAgICAgICAgICAgICAgICBzY3JpcHQuc3JjID0gc3JjOwogICAgICAgICAgICAgICAgICAgICAgICBzY3JpcHQub25sb2FkID0gZnVuY3Rpb24gKGV2dCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlbW92ZVNjcmlwdEVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY3JpcHQucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKGV2dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIHNjcmlwdC5vbmVycm9yID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVqZWN0KG5ldyBFcnJvcihgQ2Fubm90IGxvYWQgc2NyaXB0IGF0OiAke3NjcmlwdC5zcmN9YCkpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAoZG9jdW1lbnQuaGVhZCB8fCBkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQpLmFwcGVuZChzY3JpcHQpOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZGVwcmVjYXRlZChkZXRhaWxzKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coIkRlcHJlY2F0ZWQgQVBJIHVzYWdlOiAiICsgZGV0YWlscyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBsZXQgcGRmRGF0ZVN0cmluZ1JlZ2V4OwogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0ZVN0cmluZyB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHRvRGF0ZU9iamVjdChpbnB1dCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlucHV0IHx8IHR5cGVvZiBpbnB1dCAhPT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghcGRmRGF0ZVN0cmluZ1JlZ2V4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZGZEYXRlU3RyaW5nUmVnZXggPSBuZXcgUmVnRXhwKCJeRDoiICsgIihcXGR7NH0pIiArICIoXFxkezJ9KT8iICsgIihcXGR7Mn0pPyIgKyAiKFxcZHsyfSk/IiArICIoXFxkezJ9KT8iICsgIihcXGR7Mn0pPyIgKyAiKFtafCt8LV0pPyIgKyAiKFxcZHsyfSk/IiArICInPyIgKyAiKFxcZHsyfSk/IiArICInPyIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hdGNoZXMgPSBwZGZEYXRlU3RyaW5nUmVnZXguZXhlYyhpbnB1dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghbWF0Y2hlcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeWVhciA9IHBhcnNlSW50KG1hdGNoZXNbMV0sIDEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG1vbnRoID0gcGFyc2VJbnQobWF0Y2hlc1syXSwgMTApOwogICAgICAgICAgICAgICAgICAgICAgICBtb250aCA9IG1vbnRoID49IDEgJiYgbW9udGggPD0gMTIgPyBtb250aCAtIDEgOiAwOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGF5ID0gcGFyc2VJbnQobWF0Y2hlc1szXSwgMTApOwogICAgICAgICAgICAgICAgICAgICAgICBkYXkgPSBkYXkgPj0gMSAmJiBkYXkgPD0gMzEgPyBkYXkgOiAxOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgaG91ciA9IHBhcnNlSW50KG1hdGNoZXNbNF0sIDEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgaG91ciA9IGhvdXIgPj0gMCAmJiBob3VyIDw9IDIzID8gaG91ciA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtaW51dGUgPSBwYXJzZUludChtYXRjaGVzWzVdLCAxMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbnV0ZSA9IG1pbnV0ZSA+PSAwICYmIG1pbnV0ZSA8PSA1OSA/IG1pbnV0ZSA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzZWNvbmQgPSBwYXJzZUludChtYXRjaGVzWzZdLCAxMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHNlY29uZCA9IHNlY29uZCA+PSAwICYmIHNlY29uZCA8PSA1OSA/IHNlY29uZCA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVuaXZlcnNhbFRpbWVSZWxhdGlvbiA9IG1hdGNoZXNbN10gfHwgIloiOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgb2Zmc2V0SG91ciA9IHBhcnNlSW50KG1hdGNoZXNbOF0sIDEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0SG91ciA9IG9mZnNldEhvdXIgPj0gMCAmJiBvZmZzZXRIb3VyIDw9IDIzID8gb2Zmc2V0SG91ciA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBvZmZzZXRNaW51dGUgPSBwYXJzZUludChtYXRjaGVzWzldLCAxMCkgfHwgMDsKICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0TWludXRlID0gb2Zmc2V0TWludXRlID49IDAgJiYgb2Zmc2V0TWludXRlIDw9IDU5ID8gb2Zmc2V0TWludXRlIDogMDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHVuaXZlcnNhbFRpbWVSZWxhdGlvbiA9PT0gIi0iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBob3VyICs9IG9mZnNldEhvdXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW51dGUgKz0gb2Zmc2V0TWludXRlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHVuaXZlcnNhbFRpbWVSZWxhdGlvbiA9PT0gIisiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBob3VyIC09IG9mZnNldEhvdXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW51dGUgLT0gb2Zmc2V0TWludXRlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgRGF0ZShEYXRlLlVUQyh5ZWFyLCBtb250aCwgZGF5LCBob3VyLCBtaW51dGUsIHNlY29uZCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuUERGRGF0ZVN0cmluZyA9IFBERkRhdGVTdHJpbmc7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRYZmFQYWdlVmlld3BvcnQoeGZhUGFnZSwgX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICBzY2FsZSA9IDEsCiAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uID0gMAogICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMjsKICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICB9ID0geGZhUGFnZS5hdHRyaWJ1dGVzLnN0eWxlOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHZpZXdCb3ggPSBbMCwgMCwgcGFyc2VJbnQod2lkdGgpLCBwYXJzZUludChoZWlnaHQpXTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFBhZ2VWaWV3cG9ydCh7CiAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdCb3gsCiAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlLAogICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbgogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0UkdCKGNvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGNvbG9yLnN0YXJ0c1dpdGgoIiMiKSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xvclJHQiA9IHBhcnNlSW50KGNvbG9yLnNsaWNlKDEpLCAxNik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbKGNvbG9yUkdCICYgMHhmZjAwMDApID4+IDE2LCAoY29sb3JSR0IgJiAweDAwZmYwMCkgPj4gOCwgY29sb3JSR0IgJiAweDAwMDBmZl07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChjb2xvci5zdGFydHNXaXRoKCJyZ2IoIikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbG9yLnNsaWNlKDQsIC0xKS5zcGxpdCgiLCIpLm1hcCh4ID0+IHBhcnNlSW50KHgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGNvbG9yLnN0YXJ0c1dpdGgoInJnYmEoIikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbG9yLnNsaWNlKDUsIC0xKS5zcGxpdCgiLCIpLm1hcCh4ID0+IHBhcnNlSW50KHgpKS5zbGljZSgwLCAzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBOb3QgYSB2YWxpZCBjb2xvciBmb3JtYXQ6ICIke2NvbG9yfSJgKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzAsIDAsIDBdOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0Q29sb3JWYWx1ZXMoY29sb3JzKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3BhbiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInNwYW4iKTsKICAgICAgICAgICAgICAgICAgICBzcGFuLnN0eWxlLnZpc2liaWxpdHkgPSAiaGlkZGVuIjsKICAgICAgICAgICAgICAgICAgICBkb2N1bWVudC5ib2R5LmFwcGVuZChzcGFuKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG5hbWUgb2YgY29sb3JzLmtleXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICBzcGFuLnN0eWxlLmNvbG9yID0gbmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29tcHV0ZWRDb2xvciA9IHdpbmRvdy5nZXRDb21wdXRlZFN0eWxlKHNwYW4pLmNvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICBjb2xvcnMuc2V0KG5hbWUsIGdldFJHQihjb21wdXRlZENvbG9yKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNwYW4ucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRDdXJyZW50VHJhbnNmb3JtKGN0eCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgYSwKICAgICAgICAgICAgICAgICAgICAgICAgYiwKICAgICAgICAgICAgICAgICAgICAgICAgYywKICAgICAgICAgICAgICAgICAgICAgICAgZCwKICAgICAgICAgICAgICAgICAgICAgICAgZSwKICAgICAgICAgICAgICAgICAgICAgICAgZgogICAgICAgICAgICAgICAgICAgIH0gPSBjdHguZ2V0VHJhbnNmb3JtKCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFthLCBiLCBjLCBkLCBlLCBmXTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldEN1cnJlbnRUcmFuc2Zvcm1JbnZlcnNlKGN0eCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgYSwKICAgICAgICAgICAgICAgICAgICAgICAgYiwKICAgICAgICAgICAgICAgICAgICAgICAgYywKICAgICAgICAgICAgICAgICAgICAgICAgZCwKICAgICAgICAgICAgICAgICAgICAgICAgZSwKICAgICAgICAgICAgICAgICAgICAgICAgZgogICAgICAgICAgICAgICAgICAgIH0gPSBjdHguZ2V0VHJhbnNmb3JtKCkuaW52ZXJ0U2VsZigpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBbYSwgYiwgYywgZCwgZSwgZl07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzZXRMYXllckRpbWVuc2lvbnMoZGl2LCB2aWV3cG9ydCkgewogICAgICAgICAgICAgICAgICAgIGxldCBtdXN0RmxpcCA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgbGV0IG11c3RSb3RhdGUgPSBhcmd1bWVudHMubGVuZ3RoID4gMyAmJiBhcmd1bWVudHNbM10gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1szXSA6IHRydWU7CiAgICAgICAgICAgICAgICAgICAgaWYgKHZpZXdwb3J0IGluc3RhbmNlb2YgUGFnZVZpZXdwb3J0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VXaWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VIZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHZpZXdwb3J0LnJhd0RpbXM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBkaXY7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoU3RyID0gYGNhbGModmFyKC0tc2NhbGUtZmFjdG9yKSAqICR7cGFnZVdpZHRofXB4KWA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodFN0ciA9IGBjYWxjKHZhcigtLXNjYWxlLWZhY3RvcikgKiAke3BhZ2VIZWlnaHR9cHgpYDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFtdXN0RmxpcCB8fCB2aWV3cG9ydC5yb3RhdGlvbiAlIDE4MCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUud2lkdGggPSB3aWR0aFN0cjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLmhlaWdodCA9IGhlaWdodFN0cjsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLndpZHRoID0gaGVpZ2h0U3RyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUuaGVpZ2h0ID0gd2lkdGhTdHI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKG11c3RSb3RhdGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnNldEF0dHJpYnV0ZSgiZGF0YS1tYWluLXJvdGF0aW9uIiwgdmlld3BvcnQucm90YXRpb24pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQzICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQmFzZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gZXhwb3J0cy5CYXNlU1ZHRmFjdG9yeSA9IGV4cG9ydHMuQmFzZUZpbHRlckZhY3RvcnkgPSBleHBvcnRzLkJhc2VDYW52YXNGYWN0b3J5ID0gZXhwb3J0cy5CYXNlQ01hcFJlYWRlckZhY3RvcnkgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgY2xhc3MgQmFzZUZpbHRlckZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb25zdHJ1Y3RvciA9PT0gQmFzZUZpbHRlckZhY3RvcnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkNhbm5vdCBpbml0aWFsaXplIEJhc2VGaWx0ZXJGYWN0b3J5LiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZEZpbHRlcihtYXBzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAibm9uZSI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZEhDTUZpbHRlcihmZ0NvbG9yLCBiZ0NvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAibm9uZSI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlc3Ryb3koKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrZWVwSENNID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkJhc2VGaWx0ZXJGYWN0b3J5ID0gQmFzZUZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBCYXNlQ2FudmFzRmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNvbnN0cnVjdG9yID09PSBCYXNlQ2FudmFzRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQmFzZUNhbnZhc0ZhY3RvcnkuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3JlYXRlKHdpZHRoLCBoZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoIDw9IDAgfHwgaGVpZ2h0IDw9IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiSW52YWxpZCBjYW52YXMgc2l6ZSIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbnZhcyA9IHRoaXMuX2NyZWF0ZUNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQ6IGNhbnZhcy5nZXRDb250ZXh0KCIyZCIpCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlc2V0KGNhbnZhc0FuZENvbnRleHQsIHdpZHRoLCBoZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjYW52YXNBbmRDb250ZXh0LmNhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJDYW52YXMgaXMgbm90IHNwZWNpZmllZCIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3aWR0aCA8PSAwIHx8IGhlaWdodCA8PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgY2FudmFzIHNpemUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNBbmRDb250ZXh0LmNhbnZhcy53aWR0aCA9IHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNBbmRDb250ZXh0LmNhbnZhcy5oZWlnaHQgPSBoZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlc3Ryb3koY2FudmFzQW5kQ29udGV4dCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWNhbnZhc0FuZENvbnRleHQuY2FudmFzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkNhbnZhcyBpcyBub3Qgc3BlY2lmaWVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzQW5kQ29udGV4dC5jYW52YXMud2lkdGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNBbmRDb250ZXh0LmNhbnZhcy5oZWlnaHQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNBbmRDb250ZXh0LmNhbnZhcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc0FuZENvbnRleHQuY29udGV4dCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9jcmVhdGVDYW52YXMod2lkdGgsIGhlaWdodCkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJBYnN0cmFjdCBtZXRob2QgYF9jcmVhdGVDYW52YXNgIGNhbGxlZC4iKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkJhc2VDYW52YXNGYWN0b3J5ID0gQmFzZUNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBCYXNlQ01hcFJlYWRlckZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VVcmwgPSBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNDb21wcmVzc2VkID0gdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IEJhc2VDTWFwUmVhZGVyRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQmFzZUNNYXBSZWFkZXJGYWN0b3J5LiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVVybCA9IGJhc2VVcmw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNDb21wcmVzc2VkID0gaXNDb21wcmVzc2VkOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyBmZXRjaChfcmVmMikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5iYXNlVXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ1RoZSBDTWFwICJiYXNlVXJsIiBwYXJhbWV0ZXIgbXVzdCBiZSBzcGVjaWZpZWQsIGVuc3VyZSB0aGF0ICcgKyAndGhlICJjTWFwVXJsIiBhbmQgImNNYXBQYWNrZWQiIEFQSSBwYXJhbWV0ZXJzIGFyZSBwcm92aWRlZC4nKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIW5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiQ01hcCBuYW1lIG11c3QgYmUgc3BlY2lmaWVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVybCA9IHRoaXMuYmFzZVVybCArIG5hbWUgKyAodGhpcy5pc0NvbXByZXNzZWQgPyAiLmJjbWFwIiA6ICIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29tcHJlc3Npb25UeXBlID0gdGhpcy5pc0NvbXByZXNzZWQgPyBfdXRpbC5DTWFwQ29tcHJlc3Npb25UeXBlLkJJTkFSWSA6IF91dGlsLkNNYXBDb21wcmVzc2lvblR5cGUuTk9ORTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2ZldGNoRGF0YSh1cmwsIGNvbXByZXNzaW9uVHlwZSkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5hYmxlIHRvIGxvYWQgJHt0aGlzLmlzQ29tcHJlc3NlZCA/ICJiaW5hcnkgIiA6ICIifUNNYXAgYXQ6ICR7dXJsfWApOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2ZldGNoRGF0YSh1cmwsIGNvbXByZXNzaW9uVHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJBYnN0cmFjdCBtZXRob2QgYF9mZXRjaERhdGFgIGNhbGxlZC4iKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkJhc2VDTWFwUmVhZGVyRmFjdG9yeSA9IEJhc2VDTWFwUmVhZGVyRmFjdG9yeTsKICAgICAgICAgICAgICAgIGNsYXNzIEJhc2VTdGFuZGFyZEZvbnREYXRhRmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoX3JlZjMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VVcmwgPSBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMzsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IEJhc2VTdGFuZGFyZEZvbnREYXRhRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQmFzZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5LiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVVybCA9IGJhc2VVcmw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFzeW5jIGZldGNoKF9yZWY0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWxlbmFtZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5iYXNlVXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ1RoZSBzdGFuZGFyZCBmb250ICJiYXNlVXJsIiBwYXJhbWV0ZXIgbXVzdCBiZSBzcGVjaWZpZWQsIGVuc3VyZSB0aGF0ICcgKyAndGhlICJzdGFuZGFyZEZvbnREYXRhVXJsIiBBUEkgcGFyYW1ldGVyIGlzIHByb3ZpZGVkLicpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZmlsZW5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiRm9udCBmaWxlbmFtZSBtdXN0IGJlIHNwZWNpZmllZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBgJHt0aGlzLmJhc2VVcmx9JHtmaWxlbmFtZX1gOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fZmV0Y2hEYXRhKHVybCkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5hYmxlIHRvIGxvYWQgZm9udCBkYXRhIGF0OiAke3VybH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9mZXRjaERhdGEodXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkFic3RyYWN0IG1ldGhvZCBgX2ZldGNoRGF0YWAgY2FsbGVkLiIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQmFzZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gQmFzZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5OwogICAgICAgICAgICAgICAgY2xhc3MgQmFzZVNWR0ZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb25zdHJ1Y3RvciA9PT0gQmFzZVNWR0ZhY3RvcnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkNhbm5vdCBpbml0aWFsaXplIEJhc2VTVkdGYWN0b3J5LiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNyZWF0ZSh3aWR0aCwgaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBza2lwRGltZW5zaW9ucyA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3aWR0aCA8PSAwIHx8IGhlaWdodCA8PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgU1ZHIGRpbWVuc2lvbnMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdmcgPSB0aGlzLl9jcmVhdGVTVkcoInN2ZzpzdmciKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLnNldEF0dHJpYnV0ZSgidmVyc2lvbiIsICIxLjEiKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFza2lwRGltZW5zaW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLnNldEF0dHJpYnV0ZSgid2lkdGgiLCBgJHt3aWR0aH1weGApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLnNldEF0dHJpYnV0ZSgiaGVpZ2h0IiwgYCR7aGVpZ2h0fXB4YCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLnNldEF0dHJpYnV0ZSgicHJlc2VydmVBc3BlY3RSYXRpbyIsICJub25lIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5zZXRBdHRyaWJ1dGUoInZpZXdCb3giLCBgMCAwICR7d2lkdGh9ICR7aGVpZ2h0fWApOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3ZnOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjcmVhdGVFbGVtZW50KHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB0eXBlICE9PSAic3RyaW5nIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJJbnZhbGlkIFNWRyBlbGVtZW50IHR5cGUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fY3JlYXRlU1ZHKHR5cGUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY3JlYXRlU1ZHKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQWJzdHJhY3QgbWV0aG9kIGBfY3JlYXRlU1ZHYCBjYWxsZWQuIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5CYXNlU1ZHRmFjdG9yeSA9IEJhc2VTVkdGYWN0b3J5OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNDQgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5NdXJtdXJIYXNoM182NCA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICBjb25zdCBTRUVEID0gMHhjM2QyZTFmMDsKICAgICAgICAgICAgICAgIGNvbnN0IE1BU0tfSElHSCA9IDB4ZmZmZjAwMDA7CiAgICAgICAgICAgICAgICBjb25zdCBNQVNLX0xPVyA9IDB4ZmZmZjsKICAgICAgICAgICAgICAgIGNsYXNzIE11cm11ckhhc2gzXzY0IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzZWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaDEgPSBzZWVkID8gc2VlZCAmIDB4ZmZmZmZmZmYgOiBTRUVEOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmgyID0gc2VlZCA/IHNlZWQgJiAweGZmZmZmZmZmIDogU0VFRDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlKGlucHV0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhLCBsZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgaW5wdXQgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhID0gbmV3IFVpbnQ4QXJyYXkoaW5wdXQubGVuZ3RoICogMik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gaW5wdXQubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvZGUgPSBpbnB1dC5jaGFyQ29kZUF0KGkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjb2RlIDw9IDB4ZmYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtsZW5ndGgrK10gPSBjb2RlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFbbGVuZ3RoKytdID0gY29kZSA+Pj4gODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtsZW5ndGgrK10gPSBjb2RlICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoKDAsIF91dGlsLmlzQXJyYXlCdWZmZXIpKGlucHV0KSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9IGlucHV0LnNsaWNlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGggPSBkYXRhLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIldyb25nIGRhdGEgZm9ybWF0IGluIE11cm11ckhhc2gzXzY0X3VwZGF0ZS4gIiArICJJbnB1dCBtdXN0IGJlIGEgc3RyaW5nIG9yIGFycmF5LiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJsb2NrQ291bnRzID0gbGVuZ3RoID4+IDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRhaWxMZW5ndGggPSBsZW5ndGggLSBibG9ja0NvdW50cyAqIDQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGFVaW50MzIgPSBuZXcgVWludDMyQXJyYXkoZGF0YS5idWZmZXIsIDAsIGJsb2NrQ291bnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGsxID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsyID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGgxID0gdGhpcy5oMSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGgyID0gdGhpcy5oMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQzEgPSAweGNjOWUyZDUxLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgQzIgPSAweDFiODczNTkzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDMV9MT1cgPSBDMSAmIE1BU0tfTE9XLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgQzJfTE9XID0gQzIgJiBNQVNLX0xPVzsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBibG9ja0NvdW50czsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaSAmIDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrMSA9IGRhdGFVaW50MzJbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgazEgPSBrMSAqIEMxICYgTUFTS19ISUdIIHwgazEgKiBDMV9MT1cgJiBNQVNLX0xPVzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrMSA9IGsxIDw8IDE1IHwgazEgPj4+IDE3OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsxID0gazEgKiBDMiAmIE1BU0tfSElHSCB8IGsxICogQzJfTE9XICYgTUFTS19MT1c7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaDEgXj0gazE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaDEgPSBoMSA8PCAxMyB8IGgxID4+PiAxOTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoMSA9IGgxICogNSArIDB4ZTY1NDZiNjQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsyID0gZGF0YVVpbnQzMltpXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrMiA9IGsyICogQzEgJiBNQVNLX0hJR0ggfCBrMiAqIEMxX0xPVyAmIE1BU0tfTE9XOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsyID0gazIgPDwgMTUgfCBrMiA+Pj4gMTc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgazIgPSBrMiAqIEMyICYgTUFTS19ISUdIIHwgazIgKiBDMl9MT1cgJiBNQVNLX0xPVzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoMiBePSBrMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoMiA9IGgyIDw8IDEzIHwgaDIgPj4+IDE5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGgyID0gaDIgKiA1ICsgMHhlNjU0NmI2NDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBrMSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodGFpbExlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAzOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsxIF49IGRhdGFbYmxvY2tDb3VudHMgKiA0ICsgMl0gPDwgMTY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgazEgXj0gZGF0YVtibG9ja0NvdW50cyAqIDQgKyAxXSA8PCA4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsxIF49IGRhdGFbYmxvY2tDb3VudHMgKiA0XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrMSA9IGsxICogQzEgJiBNQVNLX0hJR0ggfCBrMSAqIEMxX0xPVyAmIE1BU0tfTE9XOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsxID0gazEgPDwgMTUgfCBrMSA+Pj4gMTc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgazEgPSBrMSAqIEMyICYgTUFTS19ISUdIIHwgazEgKiBDMl9MT1cgJiBNQVNLX0xPVzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmxvY2tDb3VudHMgJiAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGgxIF49IGsxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGgyIF49IGsxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmgxID0gaDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaDIgPSBoMjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGV4ZGlnZXN0KCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgaDEgPSB0aGlzLmgxLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaDIgPSB0aGlzLmgyOwogICAgICAgICAgICAgICAgICAgICAgICBoMSBePSBoMiA+Pj4gMTsKICAgICAgICAgICAgICAgICAgICAgICAgaDEgPSBoMSAqIDB4ZWQ1NThjY2QgJiBNQVNLX0hJR0ggfCBoMSAqIDB4OGNjZCAmIE1BU0tfTE9XOwogICAgICAgICAgICAgICAgICAgICAgICBoMiA9IGgyICogMHhmZjUxYWZkNyAmIE1BU0tfSElHSCB8ICgoaDIgPDwgMTYgfCBoMSA+Pj4gMTYpICogMHhhZmQ3ZWQ1NSAmIE1BU0tfSElHSCkgPj4+IDE2OwogICAgICAgICAgICAgICAgICAgICAgICBoMSBePSBoMiA+Pj4gMTsKICAgICAgICAgICAgICAgICAgICAgICAgaDEgPSBoMSAqIDB4MWE4NWVjNTMgJiBNQVNLX0hJR0ggfCBoMSAqIDB4ZWM1MyAmIE1BU0tfTE9XOwogICAgICAgICAgICAgICAgICAgICAgICBoMiA9IGgyICogMHhjNGNlYjlmZSAmIE1BU0tfSElHSCB8ICgoaDIgPDwgMTYgfCBoMSA+Pj4gMTYpICogMHhiOWZlMWE4NSAmIE1BU0tfSElHSCkgPj4+IDE2OwogICAgICAgICAgICAgICAgICAgICAgICBoMSBePSBoMiA+Pj4gMTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChoMSA+Pj4gMCkudG9TdHJpbmcoMTYpLnBhZFN0YXJ0KDgsICIwIikgKyAoaDIgPj4+IDApLnRvU3RyaW5nKDE2KS5wYWRTdGFydCg4LCAiMCIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuTXVybXVySGFzaDNfNjQgPSBNdXJtdXJIYXNoM182NDsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQ1ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuRm9udExvYWRlciA9IGV4cG9ydHMuRm9udEZhY2VPYmplY3QgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9pc19ub2RlID0gX193X3BkZmpzX3JlcXVpcmVfXygzKTsKICAgICAgICAgICAgICAgIGNsYXNzIEZvbnRMb2FkZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG93bmVyRG9jdW1lbnQgPSBnbG9iYWxUaGlzLmRvY3VtZW50LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGVFbGVtZW50ID0gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9jdW1lbnQgPSBvd25lckRvY3VtZW50OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hdGl2ZUZvbnRGYWNlcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0eWxlRWxlbWVudCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubG9hZGluZ1JlcXVlc3RzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubG9hZFRlc3RGb250SWQgPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGROYXRpdmVGb250RmFjZShuYXRpdmVGb250RmFjZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hdGl2ZUZvbnRGYWNlcy5wdXNoKG5hdGl2ZUZvbnRGYWNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9jdW1lbnQuZm9udHMuYWRkKG5hdGl2ZUZvbnRGYWNlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaW5zZXJ0UnVsZShydWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5zdHlsZUVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3R5bGVFbGVtZW50ID0gdGhpcy5fZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic3R5bGUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RvY3VtZW50LmRvY3VtZW50RWxlbWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgiaGVhZCIpWzBdLmFwcGVuZCh0aGlzLnN0eWxlRWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3R5bGVTaGVldCA9IHRoaXMuc3R5bGVFbGVtZW50LnNoZWV0OwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZVNoZWV0Lmluc2VydFJ1bGUocnVsZSwgc3R5bGVTaGVldC5jc3NSdWxlcy5sZW5ndGgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjbGVhcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBuYXRpdmVGb250RmFjZSBvZiB0aGlzLm5hdGl2ZUZvbnRGYWNlcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9jdW1lbnQuZm9udHMuZGVsZXRlKG5hdGl2ZUZvbnRGYWNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hdGl2ZUZvbnRGYWNlcy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5zdHlsZUVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3R5bGVFbGVtZW50LnJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHlsZUVsZW1lbnQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFzeW5jIGJpbmQoZm9udCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9udC5hdHRhY2hlZCB8fCBmb250Lm1pc3NpbmdGaWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9udC5hdHRhY2hlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRm9udExvYWRpbmdBUElTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5hdGl2ZUZvbnRGYWNlID0gZm9udC5jcmVhdGVOYXRpdmVGb250RmFjZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hdGl2ZUZvbnRGYWNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGROYXRpdmVGb250RmFjZShuYXRpdmVGb250RmFjZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgbmF0aXZlRm9udEZhY2UubG9hZGVkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgRmFpbGVkIHRvIGxvYWQgZm9udCAnJHtuYXRpdmVGb250RmFjZS5mYW1pbHl9JzogJyR7ZXh9Jy5gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9udC5kaXNhYmxlRm9udEZhY2UgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBleDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcnVsZSA9IGZvbnQuY3JlYXRlRm9udEZhY2VSdWxlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChydWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmluc2VydFJ1bGUocnVsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5pc1N5bmNGb250TG9hZGluZ1N1cHBvcnRlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF3YWl0IG5ldyBQcm9taXNlKHJlc29sdmUgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlcXVlc3QgPSB0aGlzLl9xdWV1ZUxvYWRpbmdDYWxsYmFjayhyZXNvbHZlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wcmVwYXJlRm9udExvYWRFdmVudChmb250LCByZXF1ZXN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc0ZvbnRMb2FkaW5nQVBJU3VwcG9ydGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX2RvY3VtZW50OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoYXNGb250cyA9ICEhKChfdGhpcyRfZG9jdW1lbnQgPSB0aGlzLl9kb2N1bWVudCkgIT09IG51bGwgJiYgX3RoaXMkX2RvY3VtZW50ICE9PSB2b2lkIDAgJiYgX3RoaXMkX2RvY3VtZW50LmZvbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJpc0ZvbnRMb2FkaW5nQVBJU3VwcG9ydGVkIiwgaGFzRm9udHMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNTeW5jRm9udExvYWRpbmdTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdXBwb3J0ZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9pc19ub2RlLmlzTm9kZUpTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdXBwb3J0ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBuYXZpZ2F0b3IgIT09ICJ1bmRlZmluZWQiICYmIC9Nb3ppbGxhXC81LjAuKj9ydjpcZCsuKj8gR2Vja28vLnRlc3QobmF2aWdhdG9yLnVzZXJBZ2VudCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1cHBvcnRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJpc1N5bmNGb250TG9hZGluZ1N1cHBvcnRlZCIsIHN1cHBvcnRlZCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9xdWV1ZUxvYWRpbmdDYWxsYmFjayhjYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBjb21wbGV0ZVJlcXVlc3QoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KSghcmVxdWVzdC5kb25lLCAiY29tcGxldGVSZXF1ZXN0KCkgY2Fubm90IGJlIGNhbGxlZCB0d2ljZS4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3QuZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAobG9hZGluZ1JlcXVlc3RzLmxlbmd0aCA+IDAgJiYgbG9hZGluZ1JlcXVlc3RzWzBdLmRvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvdGhlclJlcXVlc3QgPSBsb2FkaW5nUmVxdWVzdHMuc2hpZnQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KG90aGVyUmVxdWVzdC5jYWxsYmFjaywgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGluZ1JlcXVlc3RzCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wbGV0ZTogY29tcGxldGVSZXF1ZXN0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2sKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGluZ1JlcXVlc3RzLnB1c2gocmVxdWVzdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXF1ZXN0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgX2xvYWRUZXN0Rm9udCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGVzdEZvbnQgPSBhdG9iKCJUMVJVVHdBTEFJQUFBd0F3UTBaR0lESHRaZzRBQUFPWUFBQUFnVVpHVkUxbGt6WndBQUFFSEFBQUFCeEhSRVZHQUJRQSIgKyAiRlFBQUJEZ0FBQUFlVDFNdk1sWU5Zd2tBQUFFZ0FBQUFZR050WVhBQkRRTFVBQUF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N0Rm9udCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9wcmVwYXJlRm9udExvYWRFdmVudChmb250LCByZXF1ZXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGludDMyKGRhdGEsIG9mZnNldCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGEuY2hhckNvZGVBdChvZmZzZXQpIDw8IDI0IHwgZGF0YS5jaGFyQ29kZUF0KG9mZnNldCArIDEpIDw8IDE2IHwgZGF0YS5jaGFyQ29kZUF0KG9mZnNldCArIDIpIDw8IDggfCBkYXRhLmNoYXJDb2RlQXQob2Zmc2V0ICsgMykgJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHNwbGljZVN0cmluZyhzLCBvZmZzZXQsIHJlbW92ZSwgaW5zZXJ0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVuazEgPSBzLnN1YnN0cmluZygwLCBvZmZzZXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2h1bmsyID0gcy5zdWJzdHJpbmcob2Zmc2V0ICsgcmVtb3ZlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjaHVuazEgKyBpbnNlcnQgKyBjaHVuazI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGksIGlpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXMgPSB0aGlzLl9kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLndpZHRoID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLmhlaWdodCA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IGNhbnZhcy5nZXRDb250ZXh0KCIyZCIpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY2FsbGVkID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gaXNGb250UmVhZHkobmFtZSwgY2FsbGJhY2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgrK2NhbGxlZCA+IDMwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJMb2FkIHRlc3QgZm9udCBuZXZlciBsb2FkZWQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2soKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZm9udCA9ICIzMHB4ICIgKyBuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxUZXh0KCIuIiwgMCwgMjApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW1hZ2VEYXRhID0gY3R4LmdldEltYWdlRGF0YSgwLCAwLCAxLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbWFnZURhdGEuZGF0YVszXSA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFjaygpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoaXNGb250UmVhZHkuYmluZChudWxsLCBuYW1lLCBjYWxsYmFjaykpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxvYWRUZXN0Rm9udElkID0gYGx0JHtEYXRlLm5vdygpfSR7dGhpcy5sb2FkVGVzdEZvbnRJZCsrfWA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhID0gdGhpcy5fbG9hZFRlc3RGb250OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDT01NRU5UX09GRlNFVCA9IDk3NjsKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9IHNwbGljZVN0cmluZyhkYXRhLCBDT01NRU5UX09GRlNFVCwgbG9hZFRlc3RGb250SWQubGVuZ3RoLCBsb2FkVGVzdEZvbnRJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IENGRl9DSEVDS1NVTV9PRkZTRVQgPSAxNjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgWFhYWF9WQUxVRSA9IDB4NTg1ODU4NTg7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjaGVja3N1bSA9IGludDMyKGRhdGEsIENGRl9DSEVDS1NVTV9PRkZTRVQpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IGxvYWRUZXN0Rm9udElkLmxlbmd0aCAtIDM7IGkgPCBpaTsgaSArPSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGVja3N1bSA9IGNoZWNrc3VtIC0gWFhYWF9WQUxVRSArIGludDMyKGxvYWRUZXN0Rm9udElkLCBpKSB8IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPCBsb2FkVGVzdEZvbnRJZC5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrc3VtID0gY2hlY2tzdW0gLSBYWFhYX1ZBTFVFICsgaW50MzIobG9hZFRlc3RGb250SWQgKyAiWFhYIiwgaSkgfCAwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEgPSBzcGxpY2VTdHJpbmcoZGF0YSwgQ0ZGX0NIRUNLU1VNX09GRlNFVCwgNCwgKDAsIF91dGlsLnN0cmluZzMyKShjaGVja3N1bSkpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBgdXJsKGRhdGE6Zm9udC9vcGVudHlwZTtiYXNlNjQsJHtidG9hKGRhdGEpfSk7YDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcnVsZSA9IGBAZm9udC1mYWNlIHtmb250LWZhbWlseToiJHtsb2FkVGVzdEZvbnRJZH0iO3NyYzoke3VybH19YDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pbnNlcnRSdWxlKHJ1bGUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXYgPSB0aGlzLl9kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLnZpc2liaWxpdHkgPSAiaGlkZGVuIjsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLndpZHRoID0gZGl2LnN0eWxlLmhlaWdodCA9ICIxMHB4IjsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLnBvc2l0aW9uID0gImFic29sdXRlIjsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLnRvcCA9IGRpdi5zdHlsZS5sZWZ0ID0gIjBweCI7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbmFtZSBvZiBbZm9udC5sb2FkZWROYW1lLCBsb2FkVGVzdEZvbnRJZF0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNwYW4gPSB0aGlzLl9kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJzcGFuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcGFuLnRleHRDb250ZW50ID0gIkhpIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNwYW4uc3R5bGUuZm9udEZhbWlseSA9IG5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXYuYXBwZW5kKHNwYW4pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RvY3VtZW50LmJvZHkuYXBwZW5kKGRpdik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlzRm9udFJlYWR5KGxvYWRUZXN0Rm9udElkLCAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0LmNvbXBsZXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRm9udExvYWRlciA9IEZvbnRMb2FkZXI7CiAgICAgICAgICAgICAgICBjbGFzcyBGb250RmFjZU9iamVjdCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IodHJhbnNsYXRlZERhdGEsIF9yZWYyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQgPSB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUZvbnRGYWNlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVFcnJvcnMgPSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluc3BlY3RGb250ID0gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcGlsZWRHbHlwaHMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGkgaW4gdHJhbnNsYXRlZERhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXNbaV0gPSB0cmFuc2xhdGVkRGF0YVtpXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzRXZhbFN1cHBvcnRlZCA9IGlzRXZhbFN1cHBvcnRlZCAhPT0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGlzYWJsZUZvbnRGYWNlID0gZGlzYWJsZUZvbnRGYWNlID09PSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlnbm9yZUVycm9ycyA9IGlnbm9yZUVycm9ycyA9PT0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faW5zcGVjdEZvbnQgPSBpbnNwZWN0Rm9udDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3JlYXRlTmF0aXZlRm9udEZhY2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfaW5zcGVjdEZvbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhIHx8IHRoaXMuZGlzYWJsZUZvbnRGYWNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbmF0aXZlRm9udEZhY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jc3NGb250SW5mbykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmF0aXZlRm9udEZhY2UgPSBuZXcgRm9udEZhY2UodGhpcy5sb2FkZWROYW1lLCB0aGlzLmRhdGEsIHt9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNzcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3ZWlnaHQ6IHRoaXMuY3NzRm9udEluZm8uZm9udFdlaWdodAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNzc0ZvbnRJbmZvLml0YWxpY0FuZ2xlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3NzLnN0eWxlID0gYG9ibGlxdWUgJHt0aGlzLmNzc0ZvbnRJbmZvLml0YWxpY0FuZ2xlfWRlZ2A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYXRpdmVGb250RmFjZSA9IG5ldyBGb250RmFjZSh0aGlzLmNzc0ZvbnRJbmZvLmZvbnRGYW1pbHksIHRoaXMuZGF0YSwgY3NzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2luc3BlY3RGb250ID0gdGhpcy5faW5zcGVjdEZvbnQpID09PSBudWxsIHx8IF90aGlzJF9pbnNwZWN0Rm9udCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2luc3BlY3RGb250LmNhbGwodGhpcywgdGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuYXRpdmVGb250RmFjZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3JlYXRlRm9udEZhY2VSdWxlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX2luc3BlY3RGb250MjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEgfHwgdGhpcy5kaXNhYmxlRm9udEZhY2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSAoMCwgX3V0aWwuYnl0ZXNUb1N0cmluZykodGhpcy5kYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdXJsID0gYHVybChkYXRhOiR7dGhpcy5taW1ldHlwZX07YmFzZTY0LCR7YnRvYShkYXRhKX0pO2A7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBydWxlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY3NzRm9udEluZm8pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGUgPSBgQGZvbnQtZmFjZSB7Zm9udC1mYW1pbHk6IiR7dGhpcy5sb2FkZWROYW1lfSI7c3JjOiR7dXJsfX1gOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNzcyA9IGBmb250LXdlaWdodDogJHt0aGlzLmNzc0ZvbnRJbmZvLmZvbnRXZWlnaHR9O2A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jc3NGb250SW5mby5pdGFsaWNBbmdsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNzcyArPSBgZm9udC1zdHlsZTogb2JsaXF1ZSAke3RoaXMuY3NzRm9udEluZm8uaXRhbGljQW5nbGV9ZGVnO2A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlID0gYEBmb250LWZhY2Uge2ZvbnQtZmFtaWx5OiIke3RoaXMuY3NzRm9udEluZm8uZm9udEZhbWlseX0iOyR7Y3NzfXNyYzoke3VybH19YDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2luc3BlY3RGb250MiA9IHRoaXMuX2luc3BlY3RGb250KSA9PT0gbnVsbCB8fCBfdGhpcyRfaW5zcGVjdEZvbnQyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfaW5zcGVjdEZvbnQyLmNhbGwodGhpcywgdGhpcywgdXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJ1bGU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhdGhHZW5lcmF0b3Iob2JqcywgY2hhcmFjdGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNvbXBpbGVkR2x5cGhzW2NoYXJhY3Rlcl0gIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29tcGlsZWRHbHlwaHNbY2hhcmFjdGVyXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY21kczsKICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZHMgPSBvYmpzLmdldCh0aGlzLmxvYWRlZE5hbWUgKyAiX3BhdGhfIiArIGNoYXJhY3Rlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaWdub3JlRXJyb3JzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgZXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYGdldFBhdGhHZW5lcmF0b3IgLSBpZ25vcmluZyBjaGFyYWN0ZXI6ICIke2V4fSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb21waWxlZEdseXBoc1tjaGFyYWN0ZXJdID0gZnVuY3Rpb24gKGMsIHNpemUpIHt9OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRXZhbFN1cHBvcnRlZCAmJiBfdXRpbC5GZWF0dXJlVGVzdC5pc0V2YWxTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGpzQnVmID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGN1cnJlbnQgb2YgY21kcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3MgPSBjdXJyZW50LmFyZ3MgIT09IHVuZGVmaW5lZCA/IGN1cnJlbnQuYXJncy5qb2luKCIsIikgOiAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqc0J1Zi5wdXNoKCJjLiIsIGN1cnJlbnQuY21kLCAiKCIsIGFyZ3MsICIpO1xuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb21waWxlZEdseXBoc1tjaGFyYWN0ZXJdID0gbmV3IEZ1bmN0aW9uKCJjIiwgInNpemUiLCBqc0J1Zi5qb2luKCIiKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29tcGlsZWRHbHlwaHNbY2hhcmFjdGVyXSA9IGZ1bmN0aW9uIChjLCBzaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGN1cnJlbnQgb2YgY21kcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LmNtZCA9PT0gInNjYWxlIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmFyZ3MgPSBbc2l6ZSwgLXNpemVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjW2N1cnJlbnQuY21kXS5hcHBseShjLCBjdXJyZW50LmFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRm9udEZhY2VPYmplY3QgPSBGb250RmFjZU9iamVjdDsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQ2ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQ2FudmFzR3JhcGhpY3MgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwbGF5X3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDIpOwogICAgICAgICAgICAgICAgdmFyIF9wYXR0ZXJuX2hlbHBlciA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQ3KTsKICAgICAgICAgICAgICAgIHZhciBfaW1hZ2VfdXRpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0OCk7CiAgICAgICAgICAgICAgICB2YXIgX2lzX25vZGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDMpOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKG9iaiwgcHJpdmF0ZVNldCkgeyBfY2hlY2tQcml2YXRlUmVkZWNsYXJhdGlvbihvYmosIHByaXZhdGVTZXQpOyBwcml2YXRlU2V0LmFkZChvYmopOyB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2hlY2tQcml2YXRlUmV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kgZm9yd2FyZGluZyBvcGVyYXRpb25zLiIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFNhdmUgPSBjdHguc2F2ZTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFJlc3RvcmUgPSBjdHgucmVzdG9yZTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFJvdGF0ZSA9IGN0eC5yb3RhdGU7CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxTY2FsZSA9IGN0eC5zY2FsZTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFRyYW5zbGF0ZSA9IGN0eC50cmFuc2xhdGU7CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxUcmFuc2Zvcm0gPSBjdHgudHJhbnNmb3JtOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsU2V0VHJhbnNmb3JtID0gY3R4LnNldFRyYW5zZm9ybTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFJlc2V0VHJhbnNmb3JtID0gY3R4LnJlc2V0VHJhbnNmb3JtOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsQ2xpcCA9IGN0eC5jbGlwOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsTW92ZVRvID0gY3R4Lm1vdmVUbzsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbExpbmVUbyA9IGN0eC5saW5lVG87CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxCZXppZXJDdXJ2ZVRvID0gY3R4LmJlemllckN1cnZlVG87CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxSZWN0ID0gY3R4LnJlY3Q7CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxDbG9zZVBhdGggPSBjdHguY2xvc2VQYXRoOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsQmVnaW5QYXRoID0gY3R4LmJlZ2luUGF0aDsKICAgICAgICAgICAgICAgICAgICBjdHguX3JlbW92ZU1pcnJvcmluZyA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUgPSBjdHguX19vcmlnaW5hbFNhdmU7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5yZXN0b3JlID0gY3R4Ll9fb3JpZ2luYWxSZXN0b3JlOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgucm90YXRlID0gY3R4Ll9fb3JpZ2luYWxSb3RhdGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZSA9IGN0eC5fX29yaWdpbmFsU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC50cmFuc2xhdGUgPSBjdHguX19vcmlnaW5hbFRyYW5zbGF0ZTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSA9IGN0eC5fX29yaWdpbmFsVHJhbnNmb3JtOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtID0gY3R4Ll9fb3JpZ2luYWxTZXRUcmFuc2Zvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5yZXNldFRyYW5zZm9ybSA9IGN0eC5fX29yaWdpbmFsUmVzZXRUcmFuc2Zvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5jbGlwID0gY3R4Ll9fb3JpZ2luYWxDbGlwOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgubW92ZVRvID0gY3R4Ll9fb3JpZ2luYWxNb3ZlVG87CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lVG8gPSBjdHguX19vcmlnaW5hbExpbmVUbzsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmJlemllckN1cnZlVG8gPSBjdHguX19vcmlnaW5hbEJlemllckN1cnZlVG87CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5yZWN0ID0gY3R4Ll9fb3JpZ2luYWxSZWN0OwogICAgICAgICAgICAgICAgICAgICAgICBjdHguY2xvc2VQYXRoID0gY3R4Ll9fb3JpZ2luYWxDbG9zZVBhdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZWdpblBhdGggPSBjdHguX19vcmlnaW5hbEJlZ2luUGF0aDsKICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIGN0eC5fcmVtb3ZlTWlycm9yaW5nOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUgPSBmdW5jdGlvbiBjdHhTYXZlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fX29yaWdpbmFsU2F2ZSgpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUgPSBmdW5jdGlvbiBjdHhSZXN0b3JlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fX29yaWdpbmFsUmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zbGF0ZSA9IGZ1bmN0aW9uIGN0eFRyYW5zbGF0ZSh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHgudHJhbnNsYXRlKHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxUcmFuc2xhdGUoeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjdHguc2NhbGUgPSBmdW5jdGlvbiBjdHhTY2FsZSh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHguc2NhbGUoeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbFNjYWxlKHgsIHkpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSA9IGZ1bmN0aW9uIGN0eFRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHgudHJhbnNmb3JtKGEsIGIsIGMsIGQsIGUsIGYpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxUcmFuc2Zvcm0oYSwgYiwgYywgZCwgZSwgZik7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtID0gZnVuY3Rpb24gY3R4U2V0VHJhbnNmb3JtKGEsIGIsIGMsIGQsIGUsIGYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdEN0eC5zZXRUcmFuc2Zvcm0oYSwgYiwgYywgZCwgZSwgZik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbFNldFRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGN0eC5yZXNldFRyYW5zZm9ybSA9IGZ1bmN0aW9uIGN0eFJlc2V0VHJhbnNmb3JtKCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LnJlc2V0VHJhbnNmb3JtKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbFJlc2V0VHJhbnNmb3JtKCk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjdHgucm90YXRlID0gZnVuY3Rpb24gY3R4Um90YXRlKGFuZ2xlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHgucm90YXRlKGFuZ2xlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fX29yaWdpbmFsUm90YXRlKGFuZ2xlKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGN0eC5jbGlwID0gZnVuY3Rpb24gY3R4Um90YXRlKHJ1bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdEN0eC5jbGlwKHJ1bGUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxDbGlwKHJ1bGUpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4Lm1vdmVUbyA9IGZ1bmN0aW9uICh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHgubW92ZVRvKHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxNb3ZlVG8oeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjdHgubGluZVRvID0gZnVuY3Rpb24gKHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdEN0eC5saW5lVG8oeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbExpbmVUbyh4LCB5KTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGN0eC5iZXppZXJDdXJ2ZVRvID0gZnVuY3Rpb24gKGNwMXgsIGNwMXksIGNwMngsIGNwMnksIHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdEN0eC5iZXppZXJDdXJ2ZVRvKGNwMXgsIGNwMXksIGNwMngsIGNwMnksIHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxCZXppZXJDdXJ2ZVRvKGNwMXgsIGNwMXksIGNwMngsIGNwMnksIHgsIHkpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4LnJlY3QgPSBmdW5jdGlvbiAoeCwgeSwgd2lkdGgsIGhlaWdodCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LnJlY3QoeCwgeSwgd2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbFJlY3QoeCwgeSwgd2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjdHguY2xvc2VQYXRoID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LmNsb3NlUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxDbG9zZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGN0eC5iZWdpblBhdGggPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHguYmVnaW5QYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbEJlZ2luUGF0aCgpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDYWNoZWRDYW52YXNlcyB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoY2FudmFzRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkgPSBjYW52YXNGYWN0b3J5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhY2hlID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0Q2FudmFzKGlkLCB3aWR0aCwgaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjYW52YXNFbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY2FjaGVbaWRdICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc0VudHJ5ID0gdGhpcy5jYWNoZVtpZF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkucmVzZXQoY2FudmFzRW50cnksIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzRW50cnkgPSB0aGlzLmNhbnZhc0ZhY3RvcnkuY3JlYXRlKHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYWNoZVtpZF0gPSBjYW52YXNFbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FudmFzRW50cnk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlbGV0ZShpZCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5jYWNoZVtpZF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsZWFyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGlkIGluIHRoaXMuY2FjaGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbnZhc0VudHJ5ID0gdGhpcy5jYWNoZVtpZF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkuZGVzdHJveShjYW52YXNFbnRyeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5jYWNoZVtpZF07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBkcmF3SW1hZ2VBdEludGVnZXJDb29yZHMoY3R4LCBzcmNJbWcsIHNyY1gsIHNyY1ksIHNyY1csIHNyY0gsIGRlc3RYLCBkZXN0WSwgZGVzdFcsIGRlc3RIKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgW2EsIGIsIGMsIGQsIHR4LCB0eV0gPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3R4KTsKICAgICAgICAgICAgICAgICAgICBpZiAoYiA9PT0gMCAmJiBjID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRsWCA9IGRlc3RYICogYSArIHR4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByVGxYID0gTWF0aC5yb3VuZCh0bFgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bFkgPSBkZXN0WSAqIGQgKyB0eTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgclRsWSA9IE1hdGgucm91bmQodGxZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnJYID0gKGRlc3RYICsgZGVzdFcpICogYSArIHR4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByV2lkdGggPSBNYXRoLmFicyhNYXRoLnJvdW5kKGJyWCkgLSByVGxYKSB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiclkgPSAoZGVzdFkgKyBkZXN0SCkgKiBkICsgdHk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJIZWlnaHQgPSBNYXRoLmFicyhNYXRoLnJvdW5kKGJyWSkgLSByVGxZKSB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKE1hdGguc2lnbihhKSwgMCwgMCwgTWF0aC5zaWduKGQpLCByVGxYLCByVGxZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZShzcmNJbWcsIHNyY1gsIHNyY1ksIHNyY1csIHNyY0gsIDAsIDAsIHJXaWR0aCwgckhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRUcmFuc2Zvcm0oYSwgYiwgYywgZCwgdHgsIHR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtyV2lkdGgsIHJIZWlnaHRdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoYSA9PT0gMCAmJiBkID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRsWCA9IGRlc3RZICogYyArIHR4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByVGxYID0gTWF0aC5yb3VuZCh0bFgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bFkgPSBkZXN0WCAqIGIgKyB0eTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgclRsWSA9IE1hdGgucm91bmQodGxZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnJYID0gKGRlc3RZICsgZGVzdEgpICogYyArIHR4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByV2lkdGggPSBNYXRoLmFicyhNYXRoLnJvdW5kKGJyWCkgLSByVGxYKSB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiclkgPSAoZGVzdFggKyBkZXN0VykgKiBiICsgdHk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJIZWlnaHQgPSBNYXRoLmFicyhNYXRoLnJvdW5kKGJyWSkgLSByVGxZKSB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDAsIE1hdGguc2lnbihiKSwgTWF0aC5zaWduKGMpLCAwLCByVGxYLCByVGxZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZShzcmNJbWcsIHNyY1gsIHNyY1ksIHNyY1csIHNyY0gsIDAsIDAsIHJIZWlnaHQsIHJXaWR0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRUcmFuc2Zvcm0oYSwgYiwgYywgZCwgdHgsIHR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtySGVpZ2h0LCByV2lkdGhdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjdHguZHJhd0ltYWdlKHNyY0ltZywgc3JjWCwgc3JjWSwgc3JjVywgc3JjSCwgZGVzdFgsIGRlc3RZLCBkZXN0VywgZGVzdEgpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlWCA9IE1hdGguaHlwb3QoYSwgYik7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVZID0gTWF0aC5oeXBvdChjLCBkKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3NjYWxlWCAqIGRlc3RXLCBzY2FsZVkgKiBkZXN0SF07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjb21waWxlVHlwZTNHbHlwaChpbWdEYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgaGVpZ2h0CiAgICAgICAgICAgICAgICAgICAgfSA9IGltZ0RhdGE7CiAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoID4gTUFYX1NJWkVfVE9fQ09NUElMRSB8fCBoZWlnaHQgPiBNQVhfU0laRV9UT19DT01QSUxFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBQT0lOVF9UT19QUk9DRVNTX0xJTUlUID0gMTAwMDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBQT0lOVF9UWVBFUyA9IG5ldyBVaW50OEFycmF5KFswLCAyLCA0LCAwLCAxLCAwLCA1LCA0LCA4LCAxMCwgMCwgOCwgMCwgMiwgMSwgMF0pOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoMSA9IHdpZHRoICsgMTsKICAgICAgICAgICAgICAgICAgICBsZXQgcG9pbnRzID0gbmV3IFVpbnQ4QXJyYXkod2lkdGgxICogKGhlaWdodCArIDEpKTsKICAgICAgICAgICAgICAgICAgICBsZXQgaSwgaiwgajA7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGluZVNpemUgPSB3aWR0aCArIDcgJiB+NzsKICAgICAgICAgICAgICAgICAgICBsZXQgZGF0YSA9IG5ldyBVaW50OEFycmF5KGxpbmVTaXplICogaGVpZ2h0KSwKICAgICAgICAgICAgICAgICAgICAgICAgcG9zID0gMDsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVsZW0gb2YgaW1nRGF0YS5kYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtYXNrID0gMTI4OwogICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAobWFzayA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFbcG9zKytdID0gZWxlbSAmIG1hc2sgPyAwIDogMjU1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFzayA+Pj0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBsZXQgY291bnQgPSAwOwogICAgICAgICAgICAgICAgICAgIHBvcyA9IDA7CiAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGFbcG9zXSAhPT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICBwb2ludHNbMF0gPSAxOwogICAgICAgICAgICAgICAgICAgICAgICArK2NvdW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGogPSAxOyBqIDwgd2lkdGg7IGorKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVtwb3NdICE9PSBkYXRhW3BvcyArIDFdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludHNbal0gPSBkYXRhW3Bvc10gPyAyIDogMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICsrY291bnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcG9zKys7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChkYXRhW3Bvc10gIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzW2pdID0gMjsKICAgICAgICAgICAgICAgICAgICAgICAgKytjb3VudDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMTsgaSA8IGhlaWdodDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvcyA9IGkgKiBsaW5lU2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgajAgPSBpICogd2lkdGgxOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVtwb3MgLSBsaW5lU2l6ZV0gIT09IGRhdGFbcG9zXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzW2owXSA9IGRhdGFbcG9zXSA/IDEgOiA4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKytjb3VudDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc3VtID0gKGRhdGFbcG9zXSA/IDQgOiAwKSArIChkYXRhW3BvcyAtIGxpbmVTaXplXSA/IDggOiAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChqID0gMTsgaiA8IHdpZHRoOyBqKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1bSA9IChzdW0gPj4gMikgKyAoZGF0YVtwb3MgKyAxXSA/IDQgOiAwKSArIChkYXRhW3BvcyAtIGxpbmVTaXplICsgMV0gPyA4IDogMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoUE9JTlRfVFlQRVNbc3VtXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50c1tqMCArIGpdID0gUE9JTlRfVFlQRVNbc3VtXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArK2NvdW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9zKys7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGFbcG9zIC0gbGluZVNpemVdICE9PSBkYXRhW3Bvc10pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50c1tqMCArIGpdID0gZGF0YVtwb3NdID8gMiA6IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICArK2NvdW50OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjb3VudCA+IFBPSU5UX1RPX1BST0NFU1NfTElNSVQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBvcyA9IGxpbmVTaXplICogKGhlaWdodCAtIDEpOwogICAgICAgICAgICAgICAgICAgIGowID0gaSAqIHdpZHRoMTsKICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVtwb3NdICE9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50c1tqMF0gPSA4OwogICAgICAgICAgICAgICAgICAgICAgICArK2NvdW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGogPSAxOyBqIDwgd2lkdGg7IGorKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVtwb3NdICE9PSBkYXRhW3BvcyArIDFdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludHNbajAgKyBqXSA9IGRhdGFbcG9zXSA/IDQgOiA4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKytjb3VudDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwb3MrKzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGFbcG9zXSAhPT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICBwb2ludHNbajAgKyBqXSA9IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICsrY291bnQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChjb3VudCA+IFBPSU5UX1RPX1BST0NFU1NfTElNSVQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ZXBzID0gbmV3IEludDMyQXJyYXkoWzAsIHdpZHRoMSwgLTEsIDAsIC13aWR0aDEsIDAsIDAsIDAsIDFdKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRoID0gbmV3IFBhdGgyRCgpOwogICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGNvdW50ICYmIGkgPD0gaGVpZ2h0OyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHAgPSBpICogd2lkdGgxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmQgPSBwICsgd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChwIDwgZW5kICYmICFwb2ludHNbcF0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHArKzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAocCA9PT0gZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwYXRoLm1vdmVUbyhwICUgd2lkdGgxLCBpKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDAgPSBwOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgdHlwZSA9IHBvaW50c1twXTsKICAgICAgICAgICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RlcCA9IHN0ZXBzW3R5cGVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHAgKz0gc3RlcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKCFwb2ludHNbcF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHAgPSBwb2ludHNbcF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHAgIT09IDUgJiYgcHAgIT09IDEwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZSA9IHBwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50c1twXSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUgPSBwcCAmIDB4MzMgKiB0eXBlID4+IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzW3BdICY9IHR5cGUgPj4gMiB8IHR5cGUgPDwgMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgubGluZVRvKHAgJSB3aWR0aDEsIHAgLyB3aWR0aDEgfCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghcG9pbnRzW3BdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLS1jb3VudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSB3aGlsZSAocDAgIT09IHApOwogICAgICAgICAgICAgICAgICAgICAgICAtLWk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRhdGEgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIHBvaW50cyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd091dGxpbmUgPSBmdW5jdGlvbiAoYykgewogICAgICAgICAgICAgICAgICAgICAgICBjLnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgYy5zY2FsZSgxIC8gd2lkdGgsIC0xIC8gaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgYy50cmFuc2xhdGUoMCwgLWhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGMuZmlsbChwYXRoKTsKICAgICAgICAgICAgICAgICAgICAgICAgYy5iZWdpblBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgYy5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gZHJhd091dGxpbmU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDYW52YXNFeHRyYVN0YXRlIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcih3aWR0aCwgaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWxwaGFJc1NoYXBlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZm9udFNpemUgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZvbnRTaXplU2NhbGUgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRNYXRyaXggPSBfdXRpbC5JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGV4dE1hdHJpeFNjYWxlID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5mb250TWF0cml4ID0gX3V0aWwuRk9OVF9JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGVhZGluZyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGluZVggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmVZID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jaGFyU3BhY2luZyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMud29yZFNwYWNpbmcgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRIU2NhbGUgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRSZW5kZXJpbmdNb2RlID0gX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuRklMTDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50ZXh0UmlzZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbENvbG9yID0gIiMwMDAwMDAiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cm9rZUNvbG9yID0gIiMwMDAwMDAiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhdHRlcm5GaWxsID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbEFscGhhID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJva2VBbHBoYSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGluZVdpZHRoID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hY3RpdmVTTWFzayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNmZXJNYXBzID0gIm5vbmUiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YXJ0TmV3UGF0aEFuZENsaXBCb3goWzAsIDAsIHdpZHRoLCBoZWlnaHRdKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2xvbmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNsb25lID0gT2JqZWN0LmNyZWF0ZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmUuY2xpcEJveCA9IHRoaXMuY2xpcEJveC5zbGljZSgpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xvbmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEN1cnJlbnRQb2ludCh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCA9IHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueSA9IHk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZVBhdGhNaW5NYXgodHJhbnNmb3JtLCB4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIFt4LCB5XSA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oW3gsIHldLCB0cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1pblggPSBNYXRoLm1pbih0aGlzLm1pblgsIHgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1pblkgPSBNYXRoLm1pbih0aGlzLm1pblksIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1heFggPSBNYXRoLm1heCh0aGlzLm1heFgsIHgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1heFkgPSBNYXRoLm1heCh0aGlzLm1heFksIHkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGVSZWN0TWluTWF4KHRyYW5zZm9ybSwgcmVjdCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMSA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0ocmVjdCwgdHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDIgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKHJlY3Quc2xpY2UoMiksIHRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWluWCA9IE1hdGgubWluKHRoaXMubWluWCwgcDFbMF0sIHAyWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5taW5ZID0gTWF0aC5taW4odGhpcy5taW5ZLCBwMVsxXSwgcDJbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1heFggPSBNYXRoLm1heCh0aGlzLm1heFgsIHAxWzBdLCBwMlswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWF4WSA9IE1hdGgubWF4KHRoaXMubWF4WSwgcDFbMV0sIHAyWzFdKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlU2NhbGluZ1BhdGhNaW5NYXgodHJhbnNmb3JtLCBtaW5NYXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX3V0aWwuVXRpbC5zY2FsZU1pbk1heCh0cmFuc2Zvcm0sIG1pbk1heCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWluWCA9IE1hdGgubWluKHRoaXMubWluWCwgbWluTWF4WzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tYXhYID0gTWF0aC5tYXgodGhpcy5tYXhYLCBtaW5NYXhbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1pblkgPSBNYXRoLm1pbih0aGlzLm1pblksIG1pbk1heFsyXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWF4WSA9IE1hdGgubWF4KHRoaXMubWF4WSwgbWluTWF4WzNdKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlQ3VydmVQYXRoTWluTWF4KHRyYW5zZm9ybSwgeDAsIHkwLCB4MSwgeTEsIHgyLCB5MiwgeDMsIHkzLCBtaW5NYXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYm94ID0gX3V0aWwuVXRpbC5iZXppZXJCb3VuZGluZ0JveCh4MCwgeTAsIHgxLCB5MSwgeDIsIHkyLCB4MywgeTMpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobWluTWF4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMF0gPSBNYXRoLm1pbihtaW5NYXhbMF0sIGJveFswXSwgYm94WzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSA9IE1hdGgubWF4KG1pbk1heFsxXSwgYm94WzBdLCBib3hbMl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzJdID0gTWF0aC5taW4obWluTWF4WzJdLCBib3hbMV0sIGJveFszXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbM10gPSBNYXRoLm1heChtaW5NYXhbM10sIGJveFsxXSwgYm94WzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnVwZGF0ZVJlY3RNaW5NYXgodHJhbnNmb3JtLCBib3gpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYXRoQm91bmRpbmdCb3goKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwYXRoVHlwZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogX3BhdHRlcm5faGVscGVyLlBhdGhUeXBlLkZJTEw7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0cmFuc2Zvcm0gPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJveCA9IFt0aGlzLm1pblgsIHRoaXMubWluWSwgdGhpcy5tYXhYLCB0aGlzLm1heFldOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGF0aFR5cGUgPT09IF9wYXR0ZXJuX2hlbHBlci5QYXRoVHlwZS5TVFJPS0UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdHJhbnNmb3JtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiU3Ryb2tlIGJvdW5kaW5nIGJveCBtdXN0IGluY2x1ZGUgdHJhbnNmb3JtLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSBfdXRpbC5VdGlsLnNpbmd1bGFyVmFsdWVEZWNvbXBvc2UyZFNjYWxlKHRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4U3Ryb2tlUGFkID0gc2NhbGVbMF0gKiB0aGlzLmxpbmVXaWR0aCAvIDI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5U3Ryb2tlUGFkID0gc2NhbGVbMV0gKiB0aGlzLmxpbmVXaWR0aCAvIDI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBib3hbMF0gLT0geFN0cm9rZVBhZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJveFsxXSAtPSB5U3Ryb2tlUGFkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm94WzJdICs9IHhTdHJva2VQYWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBib3hbM10gKz0geVN0cm9rZVBhZDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYm94OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGVDbGlwRnJvbVBhdGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGludGVyc2VjdCA9IF91dGlsLlV0aWwuaW50ZXJzZWN0KHRoaXMuY2xpcEJveCwgdGhpcy5nZXRQYXRoQm91bmRpbmdCb3goKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhcnROZXdQYXRoQW5kQ2xpcEJveChpbnRlcnNlY3QgfHwgWzAsIDAsIDAsIDBdKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNFbXB0eUNsaXAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1pblggPT09IEluZmluaXR5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGFydE5ld1BhdGhBbmRDbGlwQm94KGJveCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXBCb3ggPSBib3g7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWluWCA9IEluZmluaXR5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1pblkgPSBJbmZpbml0eTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tYXhYID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tYXhZID0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0Q2xpcHBlZFBhdGhCb3VuZGluZ0JveCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHBhdGhUeXBlID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBfcGF0dGVybl9oZWxwZXIuUGF0aFR5cGUuRklMTDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRyYW5zZm9ybSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLlV0aWwuaW50ZXJzZWN0KHRoaXMuY2xpcEJveCwgdGhpcy5nZXRQYXRoQm91bmRpbmdCb3gocGF0aFR5cGUsIHRyYW5zZm9ybSkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHB1dEJpbmFyeUltYWdlRGF0YShjdHgsIGltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIEltYWdlRGF0YSAhPT0gInVuZGVmaW5lZCIgJiYgaW1nRGF0YSBpbnN0YW5jZW9mIEltYWdlRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBjdHgucHV0SW1hZ2VEYXRhKGltZ0RhdGEsIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGltZ0RhdGEuaGVpZ2h0LAogICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCA9IGltZ0RhdGEud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFydGlhbENodW5rSGVpZ2h0ID0gaGVpZ2h0ICUgRlVMTF9DSFVOS19IRUlHSFQ7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZnVsbENodW5rcyA9IChoZWlnaHQgLSBwYXJ0aWFsQ2h1bmtIZWlnaHQpIC8gRlVMTF9DSFVOS19IRUlHSFQ7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgdG90YWxDaHVua3MgPSBwYXJ0aWFsQ2h1bmtIZWlnaHQgPT09IDAgPyBmdWxsQ2h1bmtzIDogZnVsbENodW5rcyArIDE7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgY2h1bmtJbWdEYXRhID0gY3R4LmNyZWF0ZUltYWdlRGF0YSh3aWR0aCwgRlVMTF9DSFVOS19IRUlHSFQpOwogICAgICAgICAgICAgICAgICAgIGxldCBzcmNQb3MgPSAwLAogICAgICAgICAgICAgICAgICAgICAgICBkZXN0UG9zOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNyYyA9IGltZ0RhdGEuZGF0YTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBkZXN0ID0gY2h1bmtJbWdEYXRhLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgbGV0IGksIGosIHRoaXNDaHVua0hlaWdodCwgZWxlbXNJblRoaXNDaHVuazsKICAgICAgICAgICAgICAgICAgICBpZiAoaW1nRGF0YS5raW5kID09PSBfdXRpbC5JbWFnZUtpbmQuR1JBWVNDQUxFXzFCUFApIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3JjTGVuZ3RoID0gc3JjLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlc3QzMiA9IG5ldyBVaW50MzJBcnJheShkZXN0LmJ1ZmZlciwgMCwgZGVzdC5ieXRlTGVuZ3RoID4+IDIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZXN0MzJEYXRhTGVuZ3RoID0gZGVzdDMyLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZnVsbFNyY0RpZmYgPSB3aWR0aCArIDcgPj4gMzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2hpdGUgPSAweGZmZmZmZmZmOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBibGFjayA9IF91dGlsLkZlYXR1cmVUZXN0LmlzTGl0dGxlRW5kaWFuID8gMHhmZjAwMDAwMCA6IDB4MDAwMDAwZmY7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCB0b3RhbENodW5rczsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzQ2h1bmtIZWlnaHQgPSBpIDwgZnVsbENodW5rcyA/IEZVTExfQ0hVTktfSEVJR0hUIDogcGFydGlhbENodW5rSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFBvcyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgdGhpc0NodW5rSGVpZ2h0OyBqKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcmNEaWZmID0gc3JjTGVuZ3RoIC0gc3JjUG9zOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBrRW5kID0gc3JjRGlmZiA+IGZ1bGxTcmNEaWZmID8gd2lkdGggOiBzcmNEaWZmICogOCAtIDc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qga0VuZFVucm9sbGVkID0ga0VuZCAmIH43OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtYXNrID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgc3JjQnl0ZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yICg7IGsgPCBrRW5kVW5yb2xsZWQ7IGsgKz0gOCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcmNCeXRlID0gc3JjW3NyY1BvcysrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSBzcmNCeXRlICYgMTI4ID8gd2hpdGUgOiBibGFjazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSBzcmNCeXRlICYgNjQgPyB3aGl0ZSA6IGJsYWNrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0MzJbZGVzdFBvcysrXSA9IHNyY0J5dGUgJiAzMiA/IHdoaXRlIDogYmxhY2s7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3QzMltkZXN0UG9zKytdID0gc3JjQnl0ZSAmIDE2ID8gd2hpdGUgOiBibGFjazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSBzcmNCeXRlICYgOCA/IHdoaXRlIDogYmxhY2s7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3QzMltkZXN0UG9zKytdID0gc3JjQnl0ZSAmIDQgPyB3aGl0ZSA6IGJsYWNrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0MzJbZGVzdFBvcysrXSA9IHNyY0J5dGUgJiAyID8gd2hpdGUgOiBibGFjazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSBzcmNCeXRlICYgMSA/IHdoaXRlIDogYmxhY2s7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoOyBrIDwga0VuZDsgaysrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXNrID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcmNCeXRlID0gc3JjW3NyY1BvcysrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hc2sgPSAxMjg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSBzcmNCeXRlICYgbWFzayA/IHdoaXRlIDogYmxhY2s7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hc2sgPj49IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGRlc3RQb3MgPCBkZXN0MzJEYXRhTGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnB1dEltYWdlRGF0YShjaHVua0ltZ0RhdGEsIDAsIGkgKiBGVUxMX0NIVU5LX0hFSUdIVCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGltZ0RhdGEua2luZCA9PT0gX3V0aWwuSW1hZ2VLaW5kLlJHQkFfMzJCUFApIHsKICAgICAgICAgICAgICAgICAgICAgICAgaiA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1zSW5UaGlzQ2h1bmsgPSB3aWR0aCAqIEZVTExfQ0hVTktfSEVJR0hUICogNDsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMDsgaSA8IGZ1bGxDaHVua3M7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdC5zZXQoc3JjLnN1YmFycmF5KHNyY1Bvcywgc3JjUG9zICsgZWxlbXNJblRoaXNDaHVuaykpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3JjUG9zICs9IGVsZW1zSW5UaGlzQ2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucHV0SW1hZ2VEYXRhKGNodW5rSW1nRGF0YSwgMCwgaik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqICs9IEZVTExfQ0hVTktfSEVJR0hUOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpIDwgdG90YWxDaHVua3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1zSW5UaGlzQ2h1bmsgPSB3aWR0aCAqIHBhcnRpYWxDaHVua0hlaWdodCAqIDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0LnNldChzcmMuc3ViYXJyYXkoc3JjUG9zLCBzcmNQb3MgKyBlbGVtc0luVGhpc0NodW5rKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucHV0SW1hZ2VEYXRhKGNodW5rSW1nRGF0YSwgMCwgaik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGltZ0RhdGEua2luZCA9PT0gX3V0aWwuSW1hZ2VLaW5kLlJHQl8yNEJQUCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzQ2h1bmtIZWlnaHQgPSBGVUxMX0NIVU5LX0hFSUdIVDsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbXNJblRoaXNDaHVuayA9IHdpZHRoICogdGhpc0NodW5rSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgdG90YWxDaHVua3M7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPj0gZnVsbENodW5rcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXNDaHVua0hlaWdodCA9IHBhcnRpYWxDaHVua0hlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtc0luVGhpc0NodW5rID0gd2lkdGggKiB0aGlzQ2h1bmtIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0UG9zID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaiA9IGVsZW1zSW5UaGlzQ2h1bms7IGotLTspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBzcmNbc3JjUG9zKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcysrXSA9IHNyY1tzcmNQb3MrK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFtkZXN0UG9zKytdID0gc3JjW3NyY1BvcysrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucHV0SW1hZ2VEYXRhKGNodW5rSW1nRGF0YSwgMCwgaSAqIEZVTExfQ0hVTktfSEVJR0hUKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgYmFkIGltYWdlIGtpbmQ6ICR7aW1nRGF0YS5raW5kfWApOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHB1dEJpbmFyeUltYWdlTWFzayhjdHgsIGltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaW1nRGF0YS5iaXRtYXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZShpbWdEYXRhLmJpdG1hcCwgMCwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gaW1nRGF0YS5oZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoID0gaW1nRGF0YS53aWR0aDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJ0aWFsQ2h1bmtIZWlnaHQgPSBoZWlnaHQgJSBGVUxMX0NIVU5LX0hFSUdIVDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBmdWxsQ2h1bmtzID0gKGhlaWdodCAtIHBhcnRpYWxDaHVua0hlaWdodCkgLyBGVUxMX0NIVU5LX0hFSUdIVDsKICAgICAgICAgICAgICAgICAgICBjb25zdCB0b3RhbENodW5rcyA9IHBhcnRpYWxDaHVua0hlaWdodCA9PT0gMCA/IGZ1bGxDaHVua3MgOiBmdWxsQ2h1bmtzICsgMTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVua0ltZ0RhdGEgPSBjdHguY3JlYXRlSW1hZ2VEYXRhKHdpZHRoLCBGVUxMX0NIVU5LX0hFSUdIVCk7CiAgICAgICAgICAgICAgICAgICAgbGV0IHNyY1BvcyA9IDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3JjID0gaW1nRGF0YS5kYXRhOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlc3QgPSBjaHVua0ltZ0RhdGEuZGF0YTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRvdGFsQ2h1bmtzOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGhpc0NodW5rSGVpZ2h0ID0gaSA8IGZ1bGxDaHVua3MgPyBGVUxMX0NIVU5LX0hFSUdIVCA6IHBhcnRpYWxDaHVua0hlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNyY1BvcwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gKDAsIF9pbWFnZV91dGlscy5jb252ZXJ0QmxhY2tBbmRXaGl0ZVRvUkdCQSkoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3JjLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3JjUG9zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVpZ2h0OiB0aGlzQ2h1bmtIZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub25CbGFja0NvbG9yOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnB1dEltYWdlRGF0YShjaHVua0ltZ0RhdGEsIDAsIGkgKiBGVUxMX0NIVU5LX0hFSUdIVCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29weUN0eFN0YXRlKHNvdXJjZUN0eCwgZGVzdEN0eCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHByb3BlcnRpZXMgPSBbInN0cm9rZVN0eWxlIiwgImZpbGxTdHlsZSIsICJmaWxsUnVsZSIsICJnbG9iYWxBbHBoYSIsICJsaW5lV2lkdGgiLCAibGluZUNhcCIsICJsaW5lSm9pbiIsICJtaXRlckxpbWl0IiwgImdsb2JhbENvbXBvc2l0ZU9wZXJhdGlvbiIsICJmb250IiwgImZpbHRlciJdOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcHJvcGVydHkgb2YgcHJvcGVydGllcykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoc291cmNlQ3R4W3Byb3BlcnR5XSAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4W3Byb3BlcnR5XSA9IHNvdXJjZUN0eFtwcm9wZXJ0eV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHNvdXJjZUN0eC5zZXRMaW5lRGFzaCAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHguc2V0TGluZURhc2goc291cmNlQ3R4LmdldExpbmVEYXNoKCkpOwogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LmxpbmVEYXNoT2Zmc2V0ID0gc291cmNlQ3R4LmxpbmVEYXNoT2Zmc2V0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHJlc2V0Q3R4VG9EZWZhdWx0KGN0eCkgewogICAgICAgICAgICAgICAgICAgIGN0eC5zdHJva2VTdHlsZSA9IGN0eC5maWxsU3R5bGUgPSAiIzAwMDAwMCI7CiAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxSdWxlID0gIm5vbnplcm8iOwogICAgICAgICAgICAgICAgICAgIGN0eC5nbG9iYWxBbHBoYSA9IDE7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVXaWR0aCA9IDE7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVDYXAgPSAiYnV0dCI7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVKb2luID0gIm1pdGVyIjsKICAgICAgICAgICAgICAgICAgICBjdHgubWl0ZXJMaW1pdCA9IDEwOwogICAgICAgICAgICAgICAgICAgIGN0eC5nbG9iYWxDb21wb3NpdGVPcGVyYXRpb24gPSAic291cmNlLW92ZXIiOwogICAgICAgICAgICAgICAgICAgIGN0eC5mb250ID0gIjEwcHggc2Fucy1zZXJpZiI7CiAgICAgICAgICAgICAgICAgICAgaWYgKGN0eC5zZXRMaW5lRGFzaCAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRMaW5lRGFzaChbXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lRGFzaE9mZnNldCA9IDA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghX2lzX25vZGUuaXNOb2RlSlMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmZpbHRlciA9ICJub25lIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjb21wb3NlU01hc2tCYWNrZHJvcChieXRlcywgcjAsIGcwLCBiMCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxlbmd0aCA9IGJ5dGVzLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMzsgaSA8IGxlbmd0aDsgaSArPSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFscGhhID0gYnl0ZXNbaV07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhbHBoYSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZXNbaSAtIDNdID0gcjA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlc1tpIC0gMl0gPSBnMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2kgLSAxXSA9IGIwOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGFscGhhIDwgMjU1KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhbHBoYV8gPSAyNTUgLSBhbHBoYTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2kgLSAzXSA9IGJ5dGVzW2kgLSAzXSAqIGFscGhhICsgcjAgKiBhbHBoYV8gPj4gODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2kgLSAyXSA9IGJ5dGVzW2kgLSAyXSAqIGFscGhhICsgZzAgKiBhbHBoYV8gPj4gODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2kgLSAxXSA9IGJ5dGVzW2kgLSAxXSAqIGFscGhhICsgYjAgKiBhbHBoYV8gPj4gODsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNvbXBvc2VTTWFza0FscGhhKG1hc2tEYXRhLCBsYXllckRhdGEsIHRyYW5zZmVyTWFwKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuZ3RoID0gbWFza0RhdGEubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlID0gMSAvIDI1NTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMzsgaSA8IGxlbmd0aDsgaSArPSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFscGhhID0gdHJhbnNmZXJNYXAgPyB0cmFuc2Zlck1hcFttYXNrRGF0YVtpXV0gOiBtYXNrRGF0YVtpXTsKICAgICAgICAgICAgICAgICAgICAgICAgbGF5ZXJEYXRhW2ldID0gbGF5ZXJEYXRhW2ldICogYWxwaGEgKiBzY2FsZSB8IDA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29tcG9zZVNNYXNrTHVtaW5vc2l0eShtYXNrRGF0YSwgbGF5ZXJEYXRhLCB0cmFuc2Zlck1hcCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxlbmd0aCA9IG1hc2tEYXRhLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMzsgaSA8IGxlbmd0aDsgaSArPSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHkgPSBtYXNrRGF0YVtpIC0gM10gKiA3NyArIG1hc2tEYXRhW2kgLSAyXSAqIDE1MiArIG1hc2tEYXRhW2kgLSAxXSAqIDI4OwogICAgICAgICAgICAgICAgICAgICAgICBsYXllckRhdGFbaV0gPSB0cmFuc2Zlck1hcCA/IGxheWVyRGF0YVtpXSAqIHRyYW5zZmVyTWFwW3kgPj4gOF0gPj4gOCA6IGxheWVyRGF0YVtpXSAqIHkgPj4gMTY7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2VuZXJpY0NvbXBvc2VTTWFzayhtYXNrQ3R4LCBsYXllckN0eCwgd2lkdGgsIGhlaWdodCwgc3VidHlwZSwgYmFja2Ryb3AsIHRyYW5zZmVyTWFwLCBsYXllck9mZnNldFgsIGxheWVyT2Zmc2V0WSwgbWFza09mZnNldFgsIG1hc2tPZmZzZXRZKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgaGFzQmFja2Ryb3AgPSAhIWJhY2tkcm9wOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHIwID0gaGFzQmFja2Ryb3AgPyBiYWNrZHJvcFswXSA6IDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZzAgPSBoYXNCYWNrZHJvcCA/IGJhY2tkcm9wWzFdIDogMDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBiMCA9IGhhc0JhY2tkcm9wID8gYmFja2Ryb3BbMl0gOiAwOwogICAgICAgICAgICAgICAgICAgIGxldCBjb21wb3NlRm47CiAgICAgICAgICAgICAgICAgICAgaWYgKHN1YnR5cGUgPT09ICJMdW1pbm9zaXR5IikgewogICAgICAgICAgICAgICAgICAgICAgICBjb21wb3NlRm4gPSBjb21wb3NlU01hc2tMdW1pbm9zaXR5OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvc2VGbiA9IGNvbXBvc2VTTWFza0FscGhhOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBQSVhFTFNfVE9fUFJPQ0VTUyA9IDEwNDg1NzY7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgY2h1bmtTaXplID0gTWF0aC5taW4oaGVpZ2h0LCBNYXRoLmNlaWwoUElYRUxTX1RPX1BST0NFU1MgLyB3aWR0aCkpOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IHJvdyA9IDA7IHJvdyA8IGhlaWdodDsgcm93ICs9IGNodW5rU2l6ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVua0hlaWdodCA9IE1hdGgubWluKGNodW5rU2l6ZSwgaGVpZ2h0IC0gcm93KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFza0RhdGEgPSBtYXNrQ3R4LmdldEltYWdlRGF0YShsYXllck9mZnNldFggLSBtYXNrT2Zmc2V0WCwgcm93ICsgKGxheWVyT2Zmc2V0WSAtIG1hc2tPZmZzZXRZKSwgd2lkdGgsIGNodW5rSGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGF5ZXJEYXRhID0gbGF5ZXJDdHguZ2V0SW1hZ2VEYXRhKGxheWVyT2Zmc2V0WCwgcm93ICsgbGF5ZXJPZmZzZXRZLCB3aWR0aCwgY2h1bmtIZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaGFzQmFja2Ryb3ApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvc2VTTWFza0JhY2tkcm9wKG1hc2tEYXRhLmRhdGEsIHIwLCBnMCwgYjApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvc2VGbihtYXNrRGF0YS5kYXRhLCBsYXllckRhdGEuZGF0YSwgdHJhbnNmZXJNYXApOwogICAgICAgICAgICAgICAgICAgICAgICBsYXllckN0eC5wdXRJbWFnZURhdGEobGF5ZXJEYXRhLCBsYXllck9mZnNldFgsIHJvdyArIGxheWVyT2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29tcG9zZVNNYXNrKGN0eCwgc21hc2ssIGxheWVyQ3R4LCBsYXllckJveCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxheWVyT2Zmc2V0WCA9IGxheWVyQm94WzBdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxheWVyT2Zmc2V0WSA9IGxheWVyQm94WzFdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxheWVyV2lkdGggPSBsYXllckJveFsyXSAtIGxheWVyT2Zmc2V0WDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBsYXllckhlaWdodCA9IGxheWVyQm94WzNdIC0gbGF5ZXJPZmZzZXRZOwogICAgICAgICAgICAgICAgICAgIGlmIChsYXllcldpZHRoID09PSAwIHx8IGxheWVySGVpZ2h0ID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2VuZXJpY0NvbXBvc2VTTWFzayhzbWFzay5jb250ZXh0LCBsYXllckN0eCwgbGF5ZXJXaWR0aCwgbGF5ZXJIZWlnaHQsIHNtYXNrLnN1YnR5cGUsIHNtYXNrLmJhY2tkcm9wLCBzbWFzay50cmFuc2Zlck1hcCwgbGF5ZXJPZmZzZXRYLCBsYXllck9mZnNldFksIHNtYXNrLm9mZnNldFgsIHNtYXNrLm9mZnNldFkpOwogICAgICAgICAgICAgICAgICAgIGN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgY3R4Lmdsb2JhbEFscGhhID0gMTsKICAgICAgICAgICAgICAgICAgICBjdHguZ2xvYmFsQ29tcG9zaXRlT3BlcmF0aW9uID0gInNvdXJjZS1vdmVyIjsKICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDEsIDAsIDAsIDEsIDAsIDApOwogICAgICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UobGF5ZXJDdHguY2FudmFzLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0SW1hZ2VTbW9vdGhpbmdFbmFibGVkKHRyYW5zZm9ybSwgaW50ZXJwb2xhdGUpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZSA9IF91dGlsLlV0aWwuc2luZ3VsYXJWYWx1ZURlY29tcG9zZTJkU2NhbGUodHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICBzY2FsZVswXSA9IE1hdGguZnJvdW5kKHNjYWxlWzBdKTsKICAgICAgICAgICAgICAgICAgICBzY2FsZVsxXSA9IE1hdGguZnJvdW5kKHNjYWxlWzFdKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBhY3R1YWxTY2FsZSA9IE1hdGguZnJvdW5kKChnbG9iYWxUaGlzLmRldmljZVBpeGVsUmF0aW8gfHwgMSkgKiBfZGlzcGxheV91dGlscy5QaXhlbHNQZXJJbmNoLlBERl9UT19DU1NfVU5JVFMpOwogICAgICAgICAgICAgICAgICAgIGlmIChpbnRlcnBvbGF0ZSAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpbnRlcnBvbGF0ZTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNjYWxlWzBdIDw9IGFjdHVhbFNjYWxlIHx8IHNjYWxlWzFdIDw9IGFjdHVhbFNjYWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0NBUF9TVFlMRVMgPSBbImJ1dHQiLCAicm91bmQiLCAic3F1YXJlIl07CiAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0pPSU5fU1RZTEVTID0gWyJtaXRlciIsICJyb3VuZCIsICJiZXZlbCJdOwogICAgICAgICAgICAgICAgY29uc3QgTk9STUFMX0NMSVAgPSB7fTsKICAgICAgICAgICAgICAgIGNvbnN0IEVPX0NMSVAgPSB7fTsKICAgICAgICAgICAgICAgIHZhciBfcmVzdG9yZUluaXRpYWxTdGF0ZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgY2xhc3MgQ2FudmFzR3JhcGhpY3MgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKGNhbnZhc0N0eCwgY29tbW9uT2Jqcywgb2JqcywgY2FudmFzRmFjdG9yeSwgZmlsdGVyRmFjdG9yeSwgX3JlZiwgYW5ub3RhdGlvbkNhbnZhc01hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uYWxDb250ZW50Q29uZmlnLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFya2VkQ29udGVudFN0YWNrID0gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9yZXN0b3JlSW5pdGlhbFN0YXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHggPSBjYW52YXNDdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudCA9IG5ldyBDYW52YXNFeHRyYVN0YXRlKHRoaXMuY3R4LmNhbnZhcy53aWR0aCwgdGhpcy5jdHguY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhdGVTdGFjayA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBlbmRpbmdDbGlwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nRU9GaWxsID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVzID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy54b2JqcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbW9uT2JqcyA9IGNvbW1vbk9ianM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub2JqcyA9IG9ianM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzRmFjdG9yeSA9IGNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsdGVyRmFjdG9yeSA9IGZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JvdXBTdGFjayA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnByb2Nlc3NpbmdUeXBlMyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVRyYW5zZm9ybSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVRyYW5zZm9ybVN0YWNrID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JvdXBMZXZlbCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc21hc2tTdGFjayA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNtYXNrQ291bnRlciA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGVtcFNNYXNrID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdXNwZW5kZWRDdHggPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRlbnRWaXNpYmxlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tYXJrZWRDb250ZW50U3RhY2sgPSBtYXJrZWRDb250ZW50U3RhY2sgfHwgW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3B0aW9uYWxDb250ZW50Q29uZmlnID0gb3B0aW9uYWxDb250ZW50Q29uZmlnOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhY2hlZENhbnZhc2VzID0gbmV3IENhY2hlZENhbnZhc2VzKHRoaXMuY2FudmFzRmFjdG9yeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FjaGVkUGF0dGVybnMgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvbkNhbnZhc01hcCA9IGFubm90YXRpb25DYW52YXNNYXA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudmlld3BvcnRTY2FsZSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3V0cHV0U2NhbGVYID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vdXRwdXRTY2FsZVkgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRTY2FsZUZvclN0cm9raW5nID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkR2V0U2luZ2xlUGl4ZWxXaWR0aCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEJpdG1hcHNNYXAgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE9iamVjdChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmYWxsYmFjayA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBkYXRhID09PSAic3RyaW5nIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGEuc3RhcnRzV2l0aCgiZ18iKSA/IHRoaXMuY29tbW9uT2Jqcy5nZXQoZGF0YSkgOiB0aGlzLm9ianMuZ2V0KGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxsYmFjazsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYmVnaW5EcmF3aW5nKF9yZWYyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zcGFyZW5jeSA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFja2dyb3VuZCA9IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYyOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IHRoaXMuY3R4LmNhbnZhcy53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gdGhpcy5jdHguY2FudmFzLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRGaWxsU3R5bGUgPSB0aGlzLmN0eC5maWxsU3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LmZpbGxTdHlsZSA9IGJhY2tncm91bmQgfHwgIiNmZmZmZmYiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5maWxsUmVjdCgwLCAwLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsbFN0eWxlID0gc2F2ZWRGaWxsU3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc3BhcmVuY3kpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50Q2FudmFzID0gdGhpcy5jYWNoZWRDYW52YXNlcy5nZXRDYW52YXMoInRyYW5zcGFyZW50Iiwgd2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbXBvc2l0ZUN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc3BhcmVudENhbnZhcyA9IHRyYW5zcGFyZW50Q2FudmFzLmNhbnZhczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4ID0gdHJhbnNwYXJlbnRDYW52YXMuY29udGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnRyYW5zZm9ybSguLi4oMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5jb21wb3NpdGVDdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc2V0Q3R4VG9EZWZhdWx0KHRoaXMuY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRyYW5zZm9ybSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgudHJhbnNmb3JtKC4uLnRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm91dHB1dFNjYWxlWCA9IHRyYW5zZm9ybVswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3V0cHV0U2NhbGVZID0gdHJhbnNmb3JtWzBdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnRyYW5zZm9ybSguLi52aWV3cG9ydC50cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZpZXdwb3J0U2NhbGUgPSB2aWV3cG9ydC5zY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5iYXNlVHJhbnNmb3JtID0gKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKHRoaXMuY3R4KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZXhlY3V0ZU9wZXJhdG9yTGlzdChvcGVyYXRvckxpc3QsIGV4ZWN1dGlvblN0YXJ0SWR4LCBjb250aW51ZUNhbGxiYWNrLCBzdGVwcGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3NBcnJheSA9IG9wZXJhdG9yTGlzdC5hcmdzQXJyYXk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZuQXJyYXkgPSBvcGVyYXRvckxpc3QuZm5BcnJheTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGkgPSBleGVjdXRpb25TdGFydElkeCB8fCAwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhcmdzQXJyYXlMZW4gPSBhcmdzQXJyYXkubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXJnc0FycmF5TGVuID09PSBpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVua09wZXJhdGlvbnMgPSBhcmdzQXJyYXlMZW4gLSBpID4gRVhFQ1VUSU9OX1NURVBTICYmIHR5cGVvZiBjb250aW51ZUNhbGxiYWNrID09PSAiZnVuY3Rpb24iOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmRUaW1lID0gY2h1bmtPcGVyYXRpb25zID8gRGF0ZS5ub3coKSArIEVYRUNVVElPTl9USU1FIDogMDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHN0ZXBzID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29tbW9uT2JqcyA9IHRoaXMuY29tbW9uT2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2JqcyA9IHRoaXMub2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGZuSWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlICh0cnVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RlcHBlciAhPT0gdW5kZWZpbmVkICYmIGkgPT09IHN0ZXBwZXIubmV4dEJyZWFrUG9pbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGVwcGVyLmJyZWFrSXQoaSwgY29udGludWVDYWxsYmFjayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbklkID0gZm5BcnJheVtpXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmbklkICE9PSBfdXRpbC5PUFMuZGVwZW5kZW5jeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXNbZm5JZF0uYXBwbHkodGhpcywgYXJnc0FycmF5W2ldKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBkZXBPYmpJZCBvZiBhcmdzQXJyYXlbaV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2Jqc1Bvb2wgPSBkZXBPYmpJZC5zdGFydHNXaXRoKCJnXyIpID8gY29tbW9uT2JqcyA6IG9ianM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb2Jqc1Bvb2wuaGFzKGRlcE9iaklkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Jqc1Bvb2wuZ2V0KGRlcE9iaklkLCBjb250aW51ZUNhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaSsrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IGFyZ3NBcnJheUxlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNodW5rT3BlcmF0aW9ucyAmJiArK3N0ZXBzID4gRVhFQ1VUSU9OX1NURVBTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERhdGUubm93KCkgPiBlbmRUaW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlQ2FsbGJhY2soKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0ZXBzID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmREcmF3aW5nKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGFnZUNvbG9ycyA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVzdG9yZUluaXRpYWxTdGF0ZSwgX3Jlc3RvcmVJbml0aWFsU3RhdGUyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhY2hlZENhbnZhc2VzLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FjaGVkUGF0dGVybnMuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBjYWNoZSBvZiB0aGlzLl9jYWNoZWRCaXRtYXBzTWFwLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGNhbnZhcyBvZiBjYWNoZS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgSFRNTENhbnZhc0VsZW1lbnQgIT09ICJ1bmRlZmluZWQiICYmIGNhbnZhcyBpbnN0YW5jZW9mIEhUTUxDYW52YXNFbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcy53aWR0aCA9IGNhbnZhcy5oZWlnaHQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkQml0bWFwc01hcC5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFnZUNvbG9ycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGNtRmlsdGVySWQgPSB0aGlzLmZpbHRlckZhY3RvcnkuYWRkSENNRmlsdGVyKHBhZ2VDb2xvcnMuZm9yZWdyb3VuZCwgcGFnZUNvbG9ycy5iYWNrZ3JvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoY21GaWx0ZXJJZCAhPT0gIm5vbmUiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRGaWx0ZXIgPSB0aGlzLmN0eC5maWx0ZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsdGVyID0gaGNtRmlsdGVySWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZHJhd0ltYWdlKHRoaXMuY3R4LmNhbnZhcywgMCwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsdGVyID0gc2F2ZWRGaWx0ZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NjYWxlSW1hZ2UoaW1nLCBpbnZlcnNlVHJhbnNmb3JtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gaW1nLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBpbWcuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgd2lkdGhTY2FsZSA9IE1hdGgubWF4KE1hdGguaHlwb3QoaW52ZXJzZVRyYW5zZm9ybVswXSwgaW52ZXJzZVRyYW5zZm9ybVsxXSksIDEpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgaGVpZ2h0U2NhbGUgPSBNYXRoLm1heChNYXRoLmh5cG90KGludmVyc2VUcmFuc2Zvcm1bMl0sIGludmVyc2VUcmFuc2Zvcm1bM10pLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHBhaW50V2lkdGggPSB3aWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhaW50SGVpZ2h0ID0gaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgdG1wQ2FudmFzSWQgPSAicHJlc2NhbGUxIjsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRtcENhbnZhcywgdG1wQ3R4OwogICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAod2lkdGhTY2FsZSA+IDIgJiYgcGFpbnRXaWR0aCA+IDEgfHwgaGVpZ2h0U2NhbGUgPiAyICYmIHBhaW50SGVpZ2h0ID4gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG5ld1dpZHRoID0gcGFpbnRXaWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdIZWlnaHQgPSBwYWludEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3aWR0aFNjYWxlID4gMiAmJiBwYWludFdpZHRoID4gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld1dpZHRoID0gcGFpbnRXaWR0aCA+PSAxNjM4NCA/IE1hdGguZmxvb3IocGFpbnRXaWR0aCAvIDIpIC0gMSB8fCAxIDogTWF0aC5jZWlsKHBhaW50V2lkdGggLyAyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aFNjYWxlIC89IHBhaW50V2lkdGggLyBuZXdXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoZWlnaHRTY2FsZSA+IDIgJiYgcGFpbnRIZWlnaHQgPiAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3SGVpZ2h0ID0gcGFpbnRIZWlnaHQgPj0gMTYzODQgPyBNYXRoLmZsb29yKHBhaW50SGVpZ2h0IC8gMikgLSAxIHx8IDEgOiBNYXRoLmNlaWwocGFpbnRIZWlnaHQpIC8gMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHRTY2FsZSAvPSBwYWludEhlaWdodCAvIG5ld0hlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRtcENhbnZhcyA9IHRoaXMuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKHRtcENhbnZhc0lkLCBuZXdXaWR0aCwgbmV3SGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRtcEN0eCA9IHRtcENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LmNsZWFyUmVjdCgwLCAwLCBuZXdXaWR0aCwgbmV3SGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRtcEN0eC5kcmF3SW1hZ2UoaW1nLCAwLCAwLCBwYWludFdpZHRoLCBwYWludEhlaWdodCwgMCwgMCwgbmV3V2lkdGgsIG5ld0hlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWcgPSB0bXBDYW52YXMuY2FudmFzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRXaWR0aCA9IG5ld1dpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRIZWlnaHQgPSBuZXdIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXBDYW52YXNJZCA9IHRtcENhbnZhc0lkID09PSAicHJlc2NhbGUxIiA/ICJwcmVzY2FsZTIiIDogInByZXNjYWxlMSI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhaW50V2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWludEhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY3JlYXRlTWFza0NhbnZhcyhpbWcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVpZ2h0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBpbWc7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpbGxDb2xvciA9IHRoaXMuY3VycmVudC5maWxsQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzUGF0dGVybkZpbGwgPSB0aGlzLmN1cnJlbnQucGF0dGVybkZpbGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnRUcmFuc2Zvcm0gPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNhY2hlLCBjYWNoZUtleSwgc2NhbGVkLCBtYXNrQ2FudmFzOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoKGltZy5iaXRtYXAgfHwgaW1nLmRhdGEpICYmIGltZy5jb3VudCA+IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1haW5LZXkgPSBpbWcuYml0bWFwIHx8IGltZy5kYXRhLmJ1ZmZlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlS2V5ID0gSlNPTi5zdHJpbmdpZnkoaXNQYXR0ZXJuRmlsbCA/IGN1cnJlbnRUcmFuc2Zvcm0gOiBbY3VycmVudFRyYW5zZm9ybS5zbGljZSgwLCA0KSwgZmlsbENvbG9yXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZSA9IHRoaXMuX2NhY2hlZEJpdG1hcHNNYXAuZ2V0KG1haW5LZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjYWNoZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlID0gbmV3IE1hcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEJpdG1hcHNNYXAuc2V0KG1haW5LZXksIGNhY2hlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhY2hlZEltYWdlID0gY2FjaGUuZ2V0KGNhY2hlS2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjYWNoZWRJbWFnZSAmJiAhaXNQYXR0ZXJuRmlsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFggPSBNYXRoLnJvdW5kKE1hdGgubWluKGN1cnJlbnRUcmFuc2Zvcm1bMF0sIGN1cnJlbnRUcmFuc2Zvcm1bMl0pICsgY3VycmVudFRyYW5zZm9ybVs0XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2V0WSA9IE1hdGgucm91bmQoTWF0aC5taW4oY3VycmVudFRyYW5zZm9ybVsxXSwgY3VycmVudFRyYW5zZm9ybVszXSkgKyBjdXJyZW50VHJhbnNmb3JtWzVdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXM6IGNhY2hlZEltYWdlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZCA9IGNhY2hlZEltYWdlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc2NhbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXNrQ2FudmFzID0gdGhpcy5jYWNoZWRDYW52YXNlcy5nZXRDYW52YXMoIm1hc2tDYW52YXMiLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1dEJpbmFyeUltYWdlTWFzayhtYXNrQ2FudmFzLmNvbnRleHQsIGltZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG1hc2tUb0NhbnZhcyA9IF91dGlsLlV0aWwudHJhbnNmb3JtKGN1cnJlbnRUcmFuc2Zvcm0sIFsxIC8gd2lkdGgsIDAsIDAsIC0xIC8gaGVpZ2h0LCAwLCAwXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1hc2tUb0NhbnZhcyA9IF91dGlsLlV0aWwudHJhbnNmb3JtKG1hc2tUb0NhbnZhcywgWzEsIDAsIDAsIDEsIDAsIC1oZWlnaHRdKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29yZDEgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFswLCAwXSwgbWFza1RvQ2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29yZDIgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFt3aWR0aCwgaGVpZ2h0XSwgbWFza1RvQ2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IF91dGlsLlV0aWwubm9ybWFsaXplUmVjdChbY29yZDFbMF0sIGNvcmQxWzFdLCBjb3JkMlswXSwgY29yZDJbMV1dKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd25XaWR0aCA9IE1hdGgucm91bmQocmVjdFsyXSAtIHJlY3RbMF0pIHx8IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRyYXduSGVpZ2h0ID0gTWF0aC5yb3VuZChyZWN0WzNdIC0gcmVjdFsxXSkgfHwgMTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbENhbnZhcyA9IHRoaXMuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKCJmaWxsQ2FudmFzIiwgZHJhd25XaWR0aCwgZHJhd25IZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxsQ3R4ID0gZmlsbENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvZmZzZXRYID0gTWF0aC5taW4oY29yZDFbMF0sIGNvcmQyWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2V0WSA9IE1hdGgubWluKGNvcmQxWzFdLCBjb3JkMlsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxDdHgudHJhbnNsYXRlKC1vZmZzZXRYLCAtb2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxDdHgudHJhbnNmb3JtKC4uLm1hc2tUb0NhbnZhcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc2NhbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWQgPSB0aGlzLl9zY2FsZUltYWdlKG1hc2tDYW52YXMuY2FudmFzLCAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2UpKGZpbGxDdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZCA9IHNjYWxlZC5pbWc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2FjaGUgJiYgaXNQYXR0ZXJuRmlsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN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GwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FjaGVkQ2FudmFzZXMuZGVsZXRlKCJmaWxsQ2FudmFzIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZS5zZXQoY2FjaGVLZXksIGZpbGxDYW52YXMuY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzOiBmaWxsQ2FudmFzLmNhbnZhcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFg6IE1hdGgucm91bmQob2Zmc2V0WCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZOiBNYXRoLnJvdW5kKG9mZnNldFkpCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExpbmVXaWR0aCh3aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAod2lkdGggIT09IHRoaXMuY3VycmVudC5saW5lV2lkdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZFNjYWxlRm9yU3Ryb2tpbmcgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5saW5lV2lkdGggPSB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubGluZVdpZHRoID0gd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExpbmVDYXAoc3R5bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubGluZUNhcCA9IExJTkVfQ0FQX1NUWUxFU1tzdHlsZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExpbmVKb2luKHN0eWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LmxpbmVKb2luID0gTElORV9KT0lOX1NUWUxFU1tzdHlsZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldE1pdGVyTGltaXQobGltaXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubWl0ZXJMaW1pdCA9IGxpbWl0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXREYXNoKGRhc2hBcnJheSwgZGFzaFBoYXNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3R4LnNldExpbmVEYXNoICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRMaW5lRGFzaChkYXNoQXJyYXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVEYXNoT2Zmc2V0ID0gZGFzaFBoYXNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFJlbmRlcmluZ0ludGVudChpbnRlbnQpIHt9CiAgICAgICAgICAgICAgICAgICAgc2V0RmxhdG5lc3MoZmxhdG5lc3MpIHt9CiAgICAgICAgICAgICAgICAgICAgc2V0R1N0YXRlKHN0YXRlcykgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IFtrZXksIHZhbHVlXSBvZiBzdGF0ZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoa2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTFciOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldExpbmVXaWR0aCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkxDIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRMaW5lQ2FwKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTEoiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldExpbmVKb2luKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTUwiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldE1pdGVyTGltaXQodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJEIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREYXNoKHZhbHVlWzBdLCB2YWx1ZVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlJJIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRSZW5kZXJpbmdJbnRlbnQodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJGTCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RmxhdG5lc3ModmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJGb250IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGb250KHZhbHVlWzBdLCB2YWx1ZVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkNBIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnN0cm9rZUFscGhhID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImNhIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmZpbGxBbHBoYSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5nbG9iYWxBbHBoYSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJCTSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4Lmdsb2JhbENvbXBvc2l0ZU9wZXJhdGlvbiA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJTTWFzayI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5hY3RpdmVTTWFzayA9IHZhbHVlID8gdGhpcy50ZW1wU01hc2sgOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRlbXBTTWFzayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2hlY2tTTWFza1N0YXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlRSIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsdGVyID0gdGhpcy5jdXJyZW50LnRyYW5zZmVyTWFwcyA9IHRoaXMuZmlsdGVyRmFjdG9yeS5hZGRGaWx0ZXIodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaW5TTWFza01vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhIXRoaXMuc3VzcGVuZGVkQ3R4OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjaGVja1NNYXNrU3RhdGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGluU01hc2tNb2RlID0gdGhpcy5pblNNYXNrTW9kZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY3VycmVudC5hY3RpdmVTTWFzayAmJiAhaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmVnaW5TTWFza01vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICghdGhpcy5jdXJyZW50LmFjdGl2ZVNNYXNrICYmIGluU01hc2tNb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFNNYXNrTW9kZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJlZ2luU01hc2tNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5pblNNYXNrTW9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJiZWdpblNNYXNrTW9kZSBjYWxsZWQgd2hpbGUgYWxyZWFkeSBpbiBzbWFzayBtb2RlIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd25XaWR0aCA9IHRoaXMuY3R4LmNhbnZhcy53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd25IZWlnaHQgPSB0aGlzLmN0eC5jYW52YXMuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYWNoZUlkID0gInNtYXNrR3JvdXBBdCIgKyB0aGlzLmdyb3VwTGV2ZWw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjcmF0Y2hDYW52YXMgPSB0aGlzLmNhY2hlZENhbnZhc2VzLmdldENhbnZhcyhjYWNoZUlkLCBkcmF3bldpZHRoLCBkcmF3bkhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3VzcGVuZGVkQ3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4ID0gc2NyYXRjaENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNldFRyYW5zZm9ybSguLi4oMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5zdXNwZW5kZWRDdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29weUN0eFN0YXRlKHRoaXMuc3VzcGVuZGVkQ3R4LCBjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICBtaXJyb3JDb250ZXh0T3BlcmF0aW9ucyhjdHgsIHRoaXMuc3VzcGVuZGVkQ3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRHU3RhdGUoW1siQk0iLCAic291cmNlLW92ZXIiXSwgWyJjYSIsIDFdLCBbIkNBIiwgMV1dKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5kU01hc2tNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiZW5kU01hc2tNb2RlIGNhbGxlZCB3aGlsZSBub3QgaW4gc21hc2sgbW9kZSIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4Ll9yZW1vdmVNaXJyb3JpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29weUN0eFN0YXRlKHRoaXMuY3R4LCB0aGlzLnN1c3BlbmRlZEN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4ID0gdGhpcy5zdXNwZW5kZWRDdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3VzcGVuZGVkQ3R4ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tcG9zZShkaXJ0eUJveCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY3VycmVudC5hY3RpdmVTTWFzaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZGlydHlCb3gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcnR5Qm94ID0gWzAsIDAsIHRoaXMuY3R4LmNhbnZhcy53aWR0aCwgdGhpcy5jdHguY2FudmFzLmhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXJ0eUJveFswXSA9IE1hdGguZmxvb3IoZGlydHlCb3hbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlydHlCb3hbMV0gPSBNYXRoLmZsb29yKGRpcnR5Qm94WzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcnR5Qm94WzJdID0gTWF0aC5jZWlsKGRpcnR5Qm94WzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcnR5Qm94WzNdID0gTWF0aC5jZWlsKGRpcnR5Qm94WzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzbWFzayA9IHRoaXMuY3VycmVudC5hY3RpdmVTTWFzazsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3VzcGVuZGVkQ3R4ID0gdGhpcy5zdXNwZW5kZWRDdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvc2VTTWFzayhzdXNwZW5kZWRDdHgsIHNtYXNrLCB0aGlzLmN0eCwgZGlydHlCb3gpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNldFRyYW5zZm9ybSgxLCAwLCAwLCAxLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xlYXJSZWN0KDAsIDAsIHRoaXMuY3R4LmNhbnZhcy53aWR0aCwgdGhpcy5jdHguY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2F2ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvcHlDdHhTdGF0ZSh0aGlzLmN0eCwgdGhpcy5zdXNwZW5kZWRDdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdXNwZW5kZWRDdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9sZCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdGF0ZVN0YWNrLnB1c2gob2xkKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50ID0gb2xkLmNsb25lKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlc3RvcmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnN0YXRlU3RhY2subGVuZ3RoID09PSAwICYmIHRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kU01hc2tNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuc3RhdGVTdGFjay5sZW5ndGggIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudCA9IHRoaXMuc3RhdGVTdGFjay5wb3AoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmluU01hc2tNb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdXNwZW5kZWRDdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvcHlDdHhTdGF0ZSh0aGlzLnN1c3BlbmRlZEN0eCwgdGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNoZWNrU01hc2tTdGF0ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nQ2xpcCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRTY2FsZUZvclN0cm9raW5nID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEdldFNpbmdsZVBpeGVsV2lkdGggPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkU2NhbGVGb3JTdHJva2luZyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEdldFNpbmdsZVBpeGVsV2lkdGggPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RQYXRoKG9wcywgYXJncywgbWluTWF4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgeCA9IGN1cnJlbnQueCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBjdXJyZW50Lnk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdGFydFgsIHN0YXJ0WTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudFRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1NjYWxpbmdNYXRyaXggPSBjdXJyZW50VHJhbnNmb3JtWzBdID09PSAwICYmIGN1cnJlbnRUcmFuc2Zvcm1bM10gPT09IDAgfHwgY3VycmVudFRyYW5zZm9ybVsxXSA9PT0gMCAmJiBjdXJyZW50VHJhbnNmb3JtWzJdID09PSAwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtaW5NYXhGb3JCZXppZXIgPSBpc1NjYWxpbmdNYXRyaXggPyBtaW5NYXguc2xpY2UoMCkgOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaiA9IDAsIGlpID0gb3BzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAob3BzW2ldIHwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnJlY3RhbmdsZToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2lkdGggPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeHcgPSB4ICsgd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHloID0geSArIGhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4Lm1vdmVUbyh4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoID09PSAwIHx8IGhlaWdodCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVUbyh4dywgeWgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVUbyh4dywgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgubGluZVRvKHh3LCB5aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgubGluZVRvKHgsIHloKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzU2NhbGluZ01hdHJpeCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC51cGRhdGVSZWN0TWluTWF4KGN1cnJlbnRUcmFuc2Zvcm0sIFt4LCB5LCB4dywgeWhdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm1vdmVUbzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4Lm1vdmVUbyh4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpc1NjYWxpbmdNYXRyaXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudXBkYXRlUGF0aE1pbk1heChjdXJyZW50VHJhbnNmb3JtLCB4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5saW5lVG86CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHggPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lVG8oeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNTY2FsaW5nTWF0cml4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnVwZGF0ZVBhdGhNaW5NYXgoY3VycmVudFRyYW5zZm9ybSwgeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY3VydmVUbzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRYID0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRZID0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaiArIDRdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5ID0gYXJnc1tqICsgNV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZXppZXJDdXJ2ZVRvKGFyZ3Nbal0sIGFyZ3NbaiArIDFdLCBhcmdzW2ogKyAyXSwgYXJnc1tqICsgM10sIHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnVwZGF0ZUN1cnZlUGF0aE1pbk1heChjdXJyZW50VHJhbnNmb3JtLCBzdGFydFgsIHN0YXJ0WSwgYXJnc1tqXSwgYXJnc1tqICsgMV0sIGFyZ3NbaiArIDJdLCBhcmdzW2ogKyAzXSwgeCwgeSwgbWluTWF4Rm9yQmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaiArPSA2OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jdXJ2ZVRvMjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRYID0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRZID0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmJlemllckN1cnZlVG8oeCwgeSwgYXJnc1tqXSwgYXJnc1tqICsgMV0sIGFyZ3NbaiArIDJdLCBhcmdzW2ogKyAzXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudXBkYXRlQ3VydmVQYXRoTWluTWF4KGN1cnJlbnRUcmFuc2Zvcm0sIHN0YXJ0WCwgc3RhcnRZLCB4LCB5LCBhcmdzW2pdLCBhcmdzW2ogKyAxXSwgYXJnc1tqICsgMl0sIGFyZ3NbaiArIDNdLCBtaW5NYXhGb3JCZXppZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ID0gYXJnc1tqICsgMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBhcmdzW2ogKyAzXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaiArPSA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jdXJ2ZVRvMzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRYID0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRZID0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaiArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5ID0gYXJnc1tqICsgM107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZXppZXJDdXJ2ZVRvKGFyZ3Nbal0sIGFyZ3NbaiArIDFdLCB4LCB5LCB4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC51cGRhdGVDdXJ2ZVBhdGhNaW5NYXgoY3VycmVudFRyYW5zZm9ybSwgc3RhcnRYLCBzdGFydFksIGFyZ3Nbal0sIGFyZ3NbaiArIDFdLCB4LCB5LCB4LCB5LCBtaW5NYXhGb3JCZXppZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqICs9IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmNsb3NlUGF0aDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmNsb3NlUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNTY2FsaW5nTWF0cml4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnVwZGF0ZVNjYWxpbmdQYXRoTWluTWF4KGN1cnJlbnRUcmFuc2Zvcm0sIG1pbk1heEZvckJlemllcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5zZXRDdXJyZW50UG9pbnQoeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsb3NlUGF0aCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0cm9rZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnN1bWVQYXRoID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3Ryb2tlQ29sb3IgPSB0aGlzLmN1cnJlbnQuc3Ryb2tlQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5nbG9iYWxBbHBoYSA9IHRoaXMuY3VycmVudC5zdHJva2VBbHBoYTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygc3Ryb2tlQ29sb3IgPT09ICJvYmplY3QiICYmIHN0cm9rZUNvbG9yICE9PSBudWxsICYmIHN0cm9rZUNvbG9yICE9PSB2b2lkIDAgJiYgc3Ryb2tlQ29sb3IuZ2V0UGF0dGVybikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnN0cm9rZVN0eWxlID0gc3Ryb2tlQ29sb3IuZ2V0UGF0dGVybihjdHgsIHRoaXMsICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtSW52ZXJzZSkoY3R4KSwgX3BhdHRlcm5faGVscGVyLlBhdGhUeXBlLlNUUk9LRSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXNjYWxlQW5kU3Ryb2tlKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJlc2NhbGVBbmRTdHJva2UodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNvbnN1bWVQYXRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnN1bWVQYXRoKHRoaXMuY3VycmVudC5nZXRDbGlwcGVkUGF0aEJvdW5kaW5nQm94KCkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5nbG9iYWxBbHBoYSA9IHRoaXMuY3VycmVudC5maWxsQWxwaGE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsb3NlU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsb3NlUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmaWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY29uc3VtZVBhdGggPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxsQ29sb3IgPSB0aGlzLmN1cnJlbnQuZmlsbENvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1BhdHRlcm5GaWxsID0gdGhpcy5jdXJyZW50LnBhdHRlcm5GaWxsOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbmVlZFJlc3RvcmUgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzUGF0dGVybkZpbGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsbFN0eWxlID0gZmlsbENvbG9yLmdldFBhdHRlcm4oY3R4LCB0aGlzLCAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2UpKGN0eCksIF9wYXR0ZXJuX2hlbHBlci5QYXRoVHlwZS5GSUxMKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5lZWRSZXN0b3JlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnRlcnNlY3QgPSB0aGlzLmN1cnJlbnQuZ2V0Q2xpcHBlZFBhdGhCb3VuZGluZ0JveCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb250ZW50VmlzaWJsZSAmJiBpbnRlcnNlY3QgIT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnBlbmRpbmdFT0ZpbGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsbCgiZXZlbm9kZCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0VPRmlsbCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsbCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZWVkUmVzdG9yZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY29uc3VtZVBhdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29uc3VtZVBhdGgoaW50ZXJzZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlb0ZpbGwoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0VPRmlsbCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGwoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cm9rZShmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29uc3VtZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW9GaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBlbmRpbmdFT0ZpbGwgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGxTdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2xvc2VGaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsb3NlUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGxTdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2xvc2VFT0ZpbGxTdHJva2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0VPRmlsbCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbFN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmRQYXRoKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnN1bWVQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsaXAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0NsaXAgPSBOT1JNQUxfQ0xJUDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW9DbGlwKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBlbmRpbmdDbGlwID0gRU9fQ0xJUDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYmVnaW5UZXh0KCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQudGV4dE1hdHJpeCA9IF91dGlsLklERU5USVRZX01BVFJJWDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnRleHRNYXRyaXhTY2FsZSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC54ID0gdGhpcy5jdXJyZW50LmxpbmVYID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnkgPSB0aGlzLmN1cnJlbnQubGluZVkgPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmRUZXh0KCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRocyA9IHRoaXMucGVuZGluZ1RleHRQYXRoczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYXRocyA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguYmVnaW5QYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmJlZ2luUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHBhdGggb2YgcGF0aHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRUcmFuc2Zvcm0oLi4ucGF0aC50cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zbGF0ZShwYXRoLngsIHBhdGgueSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoLmFkZFRvUGF0aChjdHgsIHBhdGguZm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5jbGlwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZWdpblBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHRoaXMucGVuZGluZ1RleHRQYXRoczsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0Q2hhclNwYWNpbmcoc3BhY2luZykgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuY2hhclNwYWNpbmcgPSBzcGFjaW5nOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRXb3JkU3BhY2luZyhzcGFjaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC53b3JkU3BhY2luZyA9IHNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEhTY2FsZShzY2FsZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQudGV4dEhTY2FsZSA9IHNjYWxlIC8gMTAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRMZWFkaW5nKGxlYWRpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmxlYWRpbmcgPSAtbGVhZGluZzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0Rm9udChmb250UmVmTmFtZSwgc2l6ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250T2JqID0gdGhpcy5jb21tb25PYmpzLmdldChmb250UmVmTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLmN1cnJlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZm9udE9iaikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBDYW4ndCBmaW5kIGZvbnQgZm9yICR7Zm9udFJlZk5hbWV9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5mb250TWF0cml4ID0gZm9udE9iai5mb250TWF0cml4IHx8IF91dGlsLkZPTlRfSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudC5mb250TWF0cml4WzBdID09PSAwIHx8IGN1cnJlbnQuZm9udE1hdHJpeFszXSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJJbnZhbGlkIGZvbnQgbWF0cml4IGZvciBmb250ICIgKyBmb250UmVmTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNpemUgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplID0gLXNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmZvbnREaXJlY3Rpb24gPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuZm9udERpcmVjdGlvbiA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmZvbnQgPSBmb250T2JqOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuZm9udFNpemUgPSBzaXplOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9udE9iai5pc1R5cGUzRm9udCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5hbWUgPSBmb250T2JqLmxvYWRlZE5hbWUgfHwgInNhbnMtc2VyaWYiOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYm9sZCA9ICJub3JtYWwiOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9udE9iai5ibGFjaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9sZCA9ICI5MDAiOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGZvbnRPYmouYm9sZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9sZCA9ICJib2xkIjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpdGFsaWMgPSBmb250T2JqLml0YWxpYyA/ICJpdGFsaWMiIDogIm5vcm1hbCI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHR5cGVmYWNlID0gYCIke25hbWV9IiwgJHtmb250T2JqLmZhbGxiYWNrTmFtZX1gOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYnJvd3NlckZvbnRTaXplID0gc2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNpemUgPCBNSU5fRk9OVF9TSVpFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicm93c2VyRm9udFNpemUgPSBNSU5fRk9OVF9TSVpFOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNpemUgPiBNQVhfRk9OVF9TSVpFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicm93c2VyRm9udFNpemUgPSBNQVhfRk9OVF9TSVpFOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5mb250U2l6ZVNjYWxlID0gc2l6ZSAvIGJyb3dzZXJGb250U2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZm9udCA9IGAke2l0YWxpY30gJHtib2xkfSAke2Jyb3dzZXJGb250U2l6ZX1weCAke3R5cGVmYWNlfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFRleHRSZW5kZXJpbmdNb2RlKG1vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnRleHRSZW5kZXJpbmdNb2RlID0gbW9kZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0VGV4dFJpc2UocmlzZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQudGV4dFJpc2UgPSByaXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBtb3ZlVGV4dCh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC54ID0gdGhpcy5jdXJyZW50LmxpbmVYICs9IHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC55ID0gdGhpcy5jdXJyZW50LmxpbmVZICs9IHk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExlYWRpbmdNb3ZlVGV4dCh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGVhZGluZygteSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubW92ZVRleHQoeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFRleHRNYXRyaXgoYSwgYiwgYywgZCwgZSwgZikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQudGV4dE1hdHJpeCA9IFthLCBiLCBjLCBkLCBlLCBmXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnRleHRNYXRyaXhTY2FsZSA9IE1hdGguaHlwb3QoYSwgYik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC54ID0gdGhpcy5jdXJyZW50LmxpbmVYID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnkgPSB0aGlzLmN1cnJlbnQubGluZVkgPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBuZXh0TGluZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb3ZlVGV4dCgwLCB0aGlzLmN1cnJlbnQubGVhZGluZyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50Q2hhcihjaGFyYWN0ZXIsIHgsIHksIHBhdHRlcm5UcmFuc2Zvcm0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLmN1cnJlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnQgPSBjdXJyZW50LmZvbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRleHRSZW5kZXJpbmdNb2RlID0gY3VycmVudC50ZXh0UmVuZGVyaW5nTW9kZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udFNpemUgPSBjdXJyZW50LmZvbnRTaXplIC8gY3VycmVudC5mb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxsU3Ryb2tlTW9kZSA9IHRleHRSZW5kZXJpbmdNb2RlICYgX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuRklMTF9TVFJPS0VfTUFTSzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNBZGRUb1BhdGhTZXQgPSAhISh0ZXh0UmVuZGVyaW5nTW9kZSAmIF91dGlsLlRleHRSZW5kZXJpbmdNb2RlLkFERF9UT19QQVRIX0ZMQUcpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXR0ZXJuRmlsbCA9IGN1cnJlbnQucGF0dGVybkZpbGwgJiYgIWZvbnQubWlzc2luZ0ZpbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBhZGRUb1BhdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250LmRpc2FibGVGb250RmFjZSB8fCBpc0FkZFRvUGF0aFNldCB8fCBwYXR0ZXJuRmlsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRkVG9QYXRoID0gZm9udC5nZXRQYXRoR2VuZXJhdG9yKHRoaXMuY29tbW9uT2JqcywgY2hhcmFjdGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9udC5kaXNhYmxlRm9udEZhY2UgfHwgcGF0dGVybkZpbGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgudHJhbnNsYXRlKHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmJlZ2luUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRkVG9QYXRoKGN0eCwgZm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhdHRlcm5UcmFuc2Zvcm0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKC4uLnBhdHRlcm5UcmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMIHx8IGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5maWxsKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZmlsbFN0cm9rZU1vZGUgPT09IF91dGlsLlRleHRSZW5kZXJpbmdNb2RlLlNUUk9LRSB8fCBmaWxsU3Ryb2tlTW9kZSA9PT0gX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuRklMTF9TVFJPS0UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc3Ryb2tlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMIHx8IGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5maWxsVGV4dChjaGFyYWN0ZXIsIHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5TVFJPS0UgfHwgZmlsbFN0cm9rZU1vZGUgPT09IF91dGlsLlRleHRSZW5kZXJpbmdNb2RlLkZJTExfU1RST0tFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnN0cm9rZVRleHQoY2hhcmFjdGVyLCB4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNBZGRUb1BhdGhTZXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdGhzID0gdGhpcy5wZW5kaW5nVGV4dFBhdGhzIHx8ICh0aGlzLnBlbmRpbmdUZXh0UGF0aHMgPSBbXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRocy5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm06ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb250U2l6ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGRUb1BhdGgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc0ZvbnRTdWJwaXhlbEFBRW5hYmxlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dDogY3R4CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLmNhY2hlZENhbnZhc2VzLmdldENhbnZhcygiaXNGb250U3VicGl4ZWxBQUVuYWJsZWQiLCAxMCwgMTApOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2NhbGUoMS41LCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxUZXh0KCJJIiwgMCwgMTApOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gY3R4LmdldEltYWdlRGF0YSgwLCAwLCAxMCwgMTApLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBlbmFibGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAzOyBpIDwgZGF0YS5sZW5ndGg7IGkgKz0gNCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGFbaV0gPiAwICYmIGRhdGFbaV0gPCAyNTUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmFibGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgImlzRm9udFN1YnBpeGVsQUFFbmFibGVkIiwgZW5hYmxlZCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNob3dUZXh0KGdseXBocykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250ID0gY3VycmVudC5mb250OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9udC5pc1R5cGUzRm9udCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuc2hvd1R5cGUzVGV4dChnbHlwaHMpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRTaXplID0gY3VycmVudC5mb250U2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZvbnRTaXplID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250U2l6ZVNjYWxlID0gY3VycmVudC5mb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyU3BhY2luZyA9IGN1cnJlbnQuY2hhclNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdvcmRTcGFjaW5nID0gY3VycmVudC53b3JkU3BhY2luZzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udERpcmVjdGlvbiA9IGN1cnJlbnQuZm9udERpcmVjdGlvbjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dEhTY2FsZSA9IGN1cnJlbnQudGV4dEhTY2FsZSAqIGZvbnREaXJlY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdseXBoc0xlbmd0aCA9IGdseXBocy5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZlcnRpY2FsID0gZm9udC52ZXJ0aWNhbDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3BhY2luZ0RpciA9IHZlcnRpY2FsID8gMSA6IC0xOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZhdWx0Vk1ldHJpY3MgPSBmb250LmRlZmF1bHRWTWV0cmljczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2lkdGhBZHZhbmNlU2NhbGUgPSBmb250U2l6ZSAqIGN1cnJlbnQuZm9udE1hdHJpeFswXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2ltcGxlRmlsbFRleHQgPSBjdXJyZW50LnRleHRSZW5kZXJpbmdNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMICYmICFmb250LmRpc2FibGVGb250RmFjZSAmJiAhY3VycmVudC5wYXR0ZXJuRmlsbDsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSguLi5jdXJyZW50LnRleHRNYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgudHJhbnNsYXRlKGN1cnJlbnQueCwgY3VycmVudC55ICsgY3VycmVudC50ZXh0UmlzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250RGlyZWN0aW9uID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNjYWxlKHRleHRIU2NhbGUsIC0xKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZSh0ZXh0SFNjYWxlLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGF0dGVyblRyYW5zZm9ybTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQucGF0dGVybkZpbGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXR0ZXJuID0gY3VycmVudC5maWxsQ29sb3IuZ2V0UGF0dGVybihjdHgsIHRoaXMsICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtSW52ZXJzZSkoY3R4KSwgX3BhdHRlcm5faGVscGVyLlBhdGhUeXBlLkZJTEwpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVyblRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5maWxsU3R5bGUgPSBwYXR0ZXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBsaW5lV2lkdGggPSBjdXJyZW50LmxpbmVXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSBjdXJyZW50LnRleHRNYXRyaXhTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNjYWxlID09PSAwIHx8IGxpbmVXaWR0aCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbFN0cm9rZU1vZGUgPSBjdXJyZW50LnRleHRSZW5kZXJpbmdNb2RlICYgX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuRklMTF9TVFJPS0VfTUFTSzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmaWxsU3Ryb2tlTW9kZSA9PT0gX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuU1RST0tFIHx8IGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVXaWR0aCA9IHRoaXMuZ2V0U2luZ2xlUGl4ZWxXaWR0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVdpZHRoIC89IHNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250U2l6ZVNjYWxlICE9PSAxLjApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZShmb250U2l6ZVNjYWxlLCBmb250U2l6ZVNjYWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVXaWR0aCAvPSBmb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lV2lkdGggPSBsaW5lV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250LmlzSW52YWxpZFBERmpzRm9udCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hhcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB3aWR0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGdseXBoIG9mIGdseXBocykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYXJzLnB1c2goZ2x5cGgudW5pY29kZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGggKz0gZ2x5cGgud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsbFRleHQoY2hhcnMuam9pbigiIiksIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC54ICs9IHdpZHRoICogd2lkdGhBZHZhbmNlU2NhbGUgKiB0ZXh0SFNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcG9zZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgeCA9IDAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgZ2x5cGhzTGVuZ3RoOyArK2kpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdseXBoID0gZ2x5cGhzW2ldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBnbHlwaCA9PT0gIm51bWJlciIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ICs9IHNwYWNpbmdEaXIgKiBnbHlwaCAqIGZvbnRTaXplIC8gMTAwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZXN0b3JlTmVlZGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcGFjaW5nID0gKGdseXBoLmlzU3BhY2UgPyB3b3JkU3BhY2luZyA6IDApICsgY2hhclNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyYWN0ZXIgPSBnbHlwaC5mb250Q2hhcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFjY2VudCA9IGdseXBoLmFjY2VudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzY2FsZWRYLCBzY2FsZWRZOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHdpZHRoID0gZ2x5cGgud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmVydGljYWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2bWV0cmljID0gZ2x5cGgudm1ldHJpYyB8fCBkZWZhdWx0Vk1ldHJpY3M7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdnggPSAtKGdseXBoLnZtZXRyaWMgPyB2bWV0cmljWzFdIDogd2lkdGggKiAwLjUpICogd2lkdGhBZHZhbmNlU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdnkgPSB2bWV0cmljWzJdICogd2lkdGhBZHZhbmNlU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGggPSB2bWV0cmljID8gLXZtZXRyaWNbMF0gOiB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWRYID0gdnggLyBmb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZFkgPSAoeCArIHZ5KSAvIGZvbnRTaXplU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZFggPSB4IC8gZm9udFNpemVTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWRZID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250LnJlbWVhc3VyZSAmJiB3aWR0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtZWFzdXJlZFdpZHRoID0gY3R4Lm1lYXN1cmVUZXh0KGNoYXJhY3Rlcikud2lkdGggKiAxMDAwIC8gZm9udFNpemUgKiBmb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3aWR0aCA8IG1lYXN1cmVkV2lkdGggJiYgdGhpcy5pc0ZvbnRTdWJwaXhlbEFBRW5hYmxlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyYWN0ZXJTY2FsZVggPSB3aWR0aCAvIG1lYXN1cmVkV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3RvcmVOZWVkZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2NhbGUoY2hhcmFjdGVyU2NhbGVYLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVkWCAvPSBjaGFyYWN0ZXJTY2FsZVg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh3aWR0aCAhPT0gbWVhc3VyZWRXaWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWRYICs9ICh3aWR0aCAtIG1lYXN1cmVkV2lkdGgpIC8gMjAwMCAqIGZvbnRTaXplIC8gZm9udFNpemVTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb250ZW50VmlzaWJsZSAmJiAoZ2x5cGguaXNJbkZvbnQgfHwgZm9udC5taXNzaW5nRmlsZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2ltcGxlRmlsbFRleHQgJiYgIWFjY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsbFRleHQoY2hhcmFjdGVyLCBzY2FsZWRYLCBzY2FsZWRZKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhaW50Q2hhcihjaGFyYWN0ZXIsIHNjYWxlZFgsIHNjYWxlZFksIHBhdHRlcm5UcmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWNjZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZWRBY2NlbnRYID0gc2NhbGVkWCArIGZvbnRTaXplICogYWNjZW50Lm9mZnNldC54IC8gZm9udFNpemVTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlZEFjY2VudFkgPSBzY2FsZWRZIC0gZm9udFNpemUgKiBhY2NlbnQub2Zmc2V0LnkgLyBmb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludENoYXIoYWNjZW50LmZvbnRDaGFyLCBzY2FsZWRBY2NlbnRYLCBzY2FsZWRBY2NlbnRZLCBwYXR0ZXJuVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjaGFyV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmVydGljYWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGFyV2lkdGggPSB3aWR0aCAqIHdpZHRoQWR2YW5jZVNjYWxlIC0gc3BhY2luZyAqIGZvbnREaXJlY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYXJXaWR0aCA9IHdpZHRoICogd2lkdGhBZHZhbmNlU2NhbGUgKyBzcGFjaW5nICogZm9udERpcmVjdGlvbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHggKz0gY2hhcldpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3RvcmVOZWVkZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2ZXJ0aWNhbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55IC09IHg7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnggKz0geCAqIHRleHRIU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21wb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNob3dUeXBlM1RleHQoZ2x5cGhzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250ID0gY3VycmVudC5mb250OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250U2l6ZSA9IGN1cnJlbnQuZm9udFNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnREaXJlY3Rpb24gPSBjdXJyZW50LmZvbnREaXJlY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNwYWNpbmdEaXIgPSBmb250LnZlcnRpY2FsID8gMSA6IC0xOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyU3BhY2luZyA9IGN1cnJlbnQuY2hhclNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdvcmRTcGFjaW5nID0gY3VycmVudC53b3JkU3BhY2luZzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dEhTY2FsZSA9IGN1cnJlbnQudGV4dEhTY2FsZSAqIGZvbnREaXJlY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRNYXRyaXggPSBjdXJyZW50LmZvbnRNYXRyaXggfHwgX3V0aWwuRk9OVF9JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdseXBoc0xlbmd0aCA9IGdseXBocy5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzVGV4dEludmlzaWJsZSA9IGN1cnJlbnQudGV4dFJlbmRlcmluZ01vZGUgPT09IF91dGlsLlRleHRSZW5kZXJpbmdNb2RlLklOVklTSUJMRTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGksIGdseXBoLCB3aWR0aCwgc3BhY2luZ0xlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzVGV4dEludmlzaWJsZSB8fCBmb250U2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZFNjYWxlRm9yU3Ryb2tpbmcgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRHZXRTaW5nbGVQaXhlbFdpZHRoID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSguLi5jdXJyZW50LnRleHRNYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgudHJhbnNsYXRlKGN1cnJlbnQueCwgY3VycmVudC55KTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNjYWxlKHRleHRIU2NhbGUsIGZvbnREaXJlY3Rpb24pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgZ2x5cGhzTGVuZ3RoOyArK2kpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdseXBoID0gZ2x5cGhzW2ldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBnbHlwaCA9PT0gIm51bWJlciIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcGFjaW5nTGVuZ3RoID0gc3BhY2luZ0RpciAqIGdseXBoICogZm9udFNpemUgLyAxMDAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnRyYW5zbGF0ZShzcGFjaW5nTGVuZ3RoLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnggKz0gc3BhY2luZ0xlbmd0aCAqIHRleHRIU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcGFjaW5nID0gKGdseXBoLmlzU3BhY2UgPyB3b3JkU3BhY2luZyA6IDApICsgY2hhclNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvcGVyYXRvckxpc3QgPSBmb250LmNoYXJQcm9jT3BlcmF0b3JMaXN0W2dseXBoLm9wZXJhdG9yTGlzdElkXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb3BlcmF0b3JMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBUeXBlMyBjaGFyYWN0ZXIgIiR7Z2x5cGgub3BlcmF0b3JMaXN0SWR9IiBpcyBub3QgYXZhaWxhYmxlLmApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnByb2Nlc3NpbmdUeXBlMyA9IGdseXBoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZShmb250U2l6ZSwgZm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC50cmFuc2Zvcm0oLi4uZm9udE1hdHJpeCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leGVjdXRlT3BlcmF0b3JMaXN0KG9wZXJhdG9yTGlzdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0cmFuc2Zvcm1lZCA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oW2dseXBoLndpZHRoLCAwXSwgZm9udE1hdHJpeCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCA9IHRyYW5zZm9ybWVkWzBdICogZm9udFNpemUgKyBzcGFjaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zbGF0ZSh3aWR0aCwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnggKz0gd2lkdGggKiB0ZXh0SFNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucHJvY2Vzc2luZ1R5cGUzID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0Q2hhcldpZHRoKHhXaWR0aCwgeVdpZHRoKSB7fQogICAgICAgICAgICAgICAgICAgIHNldENoYXJXaWR0aEFuZEJvdW5kcyh4V2lkdGgsIHlXaWR0aCwgbGx4LCBsbHksIHVyeCwgdXJ5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnJlY3QobGx4LCBsbHksIHVyeCAtIGxseCwgdXJ5IC0gbGx5KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xpcCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0Q29sb3JOX1BhdHRlcm4oSVIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHBhdHRlcm47CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChJUlswXSA9PT0gIlRpbGluZ1BhdHRlcm4iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xvciA9IElSWzFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmFzZVRyYW5zZm9ybSA9IHRoaXMuYmFzZVRyYW5zZm9ybSB8fCAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FudmFzR3JhcGhpY3NGYWN0b3J5ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZUNhbnZhc0dyYXBoaWNzOiBjdHggPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IENhbnZhc0dyYXBoaWNzKGN0eCwgdGhpcy5jb21tb25PYmpzLCB0aGlzLm9ianMsIHRoaXMuY2FudmFzRmFjdG9yeSwgdGhpcy5maWx0ZXJGYWN0b3J5LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25hbENvbnRlbnRDb25maWc6IHRoaXMub3B0aW9uYWxDb250ZW50Q29uZmlnLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFya2VkQ29udGVudFN0YWNrOiB0aGlzLm1hcmtlZENvbnRlbnRTdGFjawogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVybiA9IG5ldyBfcGF0dGVybl9oZWxwZXIuVGlsaW5nUGF0dGVybihJUiwgY29sb3IsIHRoaXMuY3R4LCBjYW52YXNHcmFwaGljc0ZhY3RvcnksIGJhc2VUcmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVybiA9IHRoaXMuX2dldFBhdHRlcm4oSVJbMV0sIElSWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGF0dGVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0U3Ryb2tlQ29sb3JOKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuc3Ryb2tlQ29sb3IgPSB0aGlzLmdldENvbG9yTl9QYXR0ZXJuKGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDb2xvck4oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5maWxsQ29sb3IgPSB0aGlzLmdldENvbG9yTl9QYXR0ZXJuKGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5wYXR0ZXJuRmlsbCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZVJHQkNvbG9yKHIsIGcsIGIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihyLCBnLCBiKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc3Ryb2tlU3R5bGUgPSBjb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnN0cm9rZUNvbG9yID0gY29sb3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEZpbGxSR0JDb2xvcihyLCBnLCBiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IociwgZywgYik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LmZpbGxTdHlsZSA9IGNvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuZmlsbENvbG9yID0gY29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5wYXR0ZXJuRmlsbCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZ2V0UGF0dGVybihvYmpJZCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbWF0cml4ID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGF0dGVybjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY2FjaGVkUGF0dGVybnMuaGFzKG9iaklkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVybiA9IHRoaXMuY2FjaGVkUGF0dGVybnMuZ2V0KG9iaklkKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdHRlcm4gPSAoMCwgX3BhdHRlcm5faGVscGVyLmdldFNoYWRpbmdQYXR0ZXJuKSh0aGlzLmdldE9iamVjdChvYmpJZCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYWNoZWRQYXR0ZXJucy5zZXQob2JqSWQsIHBhdHRlcm4pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXRyaXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdHRlcm4ubWF0cml4ID0gbWF0cml4OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwYXR0ZXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzaGFkaW5nRmlsbChvYmpJZCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdHRlcm4gPSB0aGlzLl9nZXRQYXR0ZXJuKG9iaklkKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxTdHlsZSA9IHBhdHRlcm4uZ2V0UGF0dGVybihjdHgsIHRoaXMsICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtSW52ZXJzZSkoY3R4KSwgX3BhdHRlcm5faGVscGVyLlBhdGhUeXBlLlNIQURJTkcpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnYgPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2UpKGN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbnZhcyA9IGN0eC5jYW52YXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGNhbnZhcy53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGNhbnZhcy5oZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBibCA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oWzAsIDBdLCBpbnYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnIgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFswLCBoZWlnaHRdLCBpbnYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdWwgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFt3aWR0aCwgMF0sIGludik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1ciA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oW3dpZHRoLCBoZWlnaHRdLCBpbnYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeDAgPSBNYXRoLm1pbihibFswXSwgYnJbMF0sIHVsWzBdLCB1clswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5MCA9IE1hdGgubWluKGJsWzFdLCBiclsxXSwgdWxbMV0sIHVyWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHgxID0gTWF0aC5tYXgoYmxbMF0sIGJyWzBdLCB1bFswXSwgdXJbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeTEgPSBNYXRoLm1heChibFsxXSwgYnJbMV0sIHVsWzFdLCB1clsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5maWxsUmVjdCh4MCwgeTAsIHgxIC0geDAsIHkxIC0geTApOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsbFJlY3QoLTFlMTAsIC0xZTEwLCAyZTEwLCAyZTEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbXBvc2UodGhpcy5jdXJyZW50LmdldENsaXBwZWRQYXRoQm91bmRpbmdCb3goKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBiZWdpbklubGluZUltYWdlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJTaG91bGQgbm90IGNhbGwgYmVnaW5JbmxpbmVJbWFnZSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBiZWdpbkltYWdlRGF0YSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiU2hvdWxkIG5vdCBjYWxsIGJlZ2luSW1hZ2VEYXRhIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50Rm9ybVhPYmplY3RCZWdpbihtYXRyaXgsIGJib3gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmNvbnRlbnRWaXNpYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVRyYW5zZm9ybVN0YWNrLnB1c2godGhpcy5iYXNlVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkobWF0cml4KSAmJiBtYXRyaXgubGVuZ3RoID09PSA2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zZm9ybSguLi5tYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKSh0aGlzLmN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChiYm94KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGJib3hbMl0gLSBiYm94WzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gYmJveFszXSAtIGJib3hbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5yZWN0KGJib3hbMF0sIGJib3hbMV0sIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnVwZGF0ZVJlY3RNaW5NYXgoKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKHRoaXMuY3R4KSwgYmJveCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50Rm9ybVhPYmplY3RFbmQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmJhc2VUcmFuc2Zvcm0gPSB0aGlzLmJhc2VUcmFuc2Zvcm1TdGFjay5wb3AoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYmVnaW5Hcm91cChncm91cCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kU01hc2tNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuYWN0aXZlU01hc2sgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnRDdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFncm91cC5pc29sYXRlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJUT0RPOiBTdXBwb3J0IG5vbi1pc29sYXRlZCBncm91cHMuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLmtub2Nrb3V0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIktub2Nrb3V0IGdyb3VwcyBub3Qgc3VwcG9ydGVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnRUcmFuc2Zvcm0gPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3VycmVudEN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChncm91cC5tYXRyaXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRDdHgudHJhbnNmb3JtKC4uLmdyb3VwLm1hdHJpeCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFncm91cC5iYm94KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkJvdW5kaW5nIGJveCBpcyByZXF1aXJlZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYm91bmRzID0gX3V0aWwuVXRpbC5nZXRBeGlhbEFsaWduZWRCb3VuZGluZ0JveChncm91cC5iYm94LCAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3VycmVudEN0eCkpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXNCb3VuZHMgPSBbMCwgMCwgY3VycmVudEN0eC5jYW52YXMud2lkdGgsIGN1cnJlbnRDdHguY2FudmFzLmhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kcyA9IF91dGlsLlV0aWwuaW50ZXJzZWN0KGJvdW5kcywgY2FudmFzQm91bmRzKSB8fCBbMCwgMCwgMCwgMF07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFggPSBNYXRoLmZsb29yKGJvdW5kc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFkgPSBNYXRoLmZsb29yKGJvdW5kc1sxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkcmF3bldpZHRoID0gTWF0aC5tYXgoTWF0aC5jZWlsKGJvdW5kc1syXSkgLSBvZmZzZXRYLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRyYXduSGVpZ2h0ID0gTWF0aC5tYXgoTWF0aC5jZWlsKGJvdW5kc1szXSkgLSBvZmZzZXRZLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNjYWxlWCA9IDEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZVkgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZHJhd25XaWR0aCA+IE1BWF9HUk9VUF9TSVpFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZVggPSBkcmF3bldpZHRoIC8gTUFYX0dST1VQX1NJWkU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3bldpZHRoID0gTUFYX0dST1VQX1NJWkU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRyYXduSGVpZ2h0ID4gTUFYX0dST1VQX1NJWkUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWSA9IGRyYXduSGVpZ2h0IC8gTUFYX0dST1VQX1NJWkU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3bkhlaWdodCA9IE1BWF9HUk9VUF9TSVpFOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5zdGFydE5ld1BhdGhBbmRDbGlwQm94KFswLCAwLCBkcmF3bldpZHRoLCBkcmF3bkhlaWdodF0pOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY2FjaGVJZCA9ICJncm91cEF0IiArIHRoaXMuZ3JvdXBMZXZlbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLnNtYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZUlkICs9ICJfc21hc2tfIiArIHRoaXMuc21hc2tDb3VudGVyKysgJSAyOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjcmF0Y2hDYW52YXMgPSB0aGlzLmNhY2hlZENhbnZhc2VzLmdldENhbnZhcyhjYWNoZUlkLCBkcmF3bldpZHRoLCBkcmF3bkhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdyb3VwQ3R4ID0gc2NyYXRjaENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICBncm91cEN0eC5zY2FsZSgxIC8gc2NhbGVYLCAxIC8gc2NhbGVZKTsKICAgICAgICAgICAgICAgICAgICAgICAgZ3JvdXBDdHgudHJhbnNsYXRlKC1vZmZzZXRYLCAtb2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGdyb3VwQ3R4LnRyYW5zZm9ybSguLi5jdXJyZW50VHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLnNtYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNtYXNrU3RhY2sucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzOiBzY3JhdGNoQ2FudmFzLmNhbnZhcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZXh0OiBncm91cEN0eCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWJ0eXBlOiBncm91cC5zbWFzay5zdWJ0eXBlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhY2tkcm9wOiBncm91cC5zbWFzay5iYWNrZHJvcCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zlck1hcDogZ3JvdXAuc21hc2sudHJhbnNmZXJNYXAgfHwgbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFydFRyYW5zZm9ybUludmVyc2U6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudEN0eC5zZXRUcmFuc2Zvcm0oMSwgMCwgMCwgMSwgMCwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Q3R4LnRyYW5zbGF0ZShvZmZzZXRYLCBvZmZzZXRZKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRDdHguc2NhbGUoc2NhbGVYLCBzY2FsZVkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudEN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29weUN0eFN0YXRlKGN1cnJlbnRDdHgsIGdyb3VwQ3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHggPSBncm91cEN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRHU3RhdGUoW1siQk0iLCAic291cmNlLW92ZXIiXSwgWyJjYSIsIDFdLCBbIkNBIiwgMV1dKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5ncm91cFN0YWNrLnB1c2goY3VycmVudEN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JvdXBMZXZlbCsrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmRHcm91cChncm91cCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmdyb3VwTGV2ZWwtLTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZ3JvdXBDdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5ncm91cFN0YWNrLnBvcCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eCA9IGN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguaW1hZ2VTbW9vdGhpbmdFbmFibGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChncm91cC5zbWFzaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50ZW1wU01hc2sgPSB0aGlzLnNtYXNrU3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnRNdHggPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zZXRUcmFuc2Zvcm0oLi4uY3VycmVudE10eCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXJ0eUJveCA9IF91dGlsLlV0aWwuZ2V0QXhpYWxBbGlnbmVkQm91bmRpbmdCb3goWzAsIDAsIGdyb3VwQ3R4LmNhbnZhcy53aWR0aCwgZ3JvdXBDdHguY2FudmFzLmhlaWdodF0sIGN1cnJlbnRNdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZHJhd0ltYWdlKGdyb3VwQ3R4LmNhbnZhcywgMCwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbXBvc2UoZGlydHlCb3gpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJlZ2luQW5ub3RhdGlvbihpZCwgcmVjdCwgdHJhbnNmb3JtLCBtYXRyaXgsIGhhc093bkNhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZXN0b3JlSW5pdGlhbFN0YXRlLCBfcmVzdG9yZUluaXRpYWxTdGF0ZTIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc2V0Q3R4VG9EZWZhdWx0KHRoaXMuY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuYmFzZVRyYW5zZm9ybSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc2V0VHJhbnNmb3JtKC4uLnRoaXMuYmFzZVRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkocmVjdCkgJiYgcmVjdC5sZW5ndGggPT09IDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gcmVjdFsyXSAtIHJlY3RbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSByZWN0WzNdIC0gcmVjdFsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoYXNPd25DYW52YXMgJiYgdGhpcy5hbm5vdGF0aW9uQ2FudmFzTWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtID0gdHJhbnNmb3JtLnNsaWNlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtWzRdIC09IHJlY3RbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtWzVdIC09IHJlY3RbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdCA9IHJlY3Quc2xpY2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0WzBdID0gcmVjdFsxXSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdFsyXSA9IHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3RbM10gPSBoZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3NjYWxlWCwgc2NhbGVZXSA9IF91dGlsLlV0aWwuc2luZ3VsYXJWYWx1ZURlY29tcG9zZTJkU2NhbGUoKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKHRoaXMuY3R4KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydFNjYWxlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FudmFzV2lkdGggPSBNYXRoLmNlaWwod2lkdGggKiB0aGlzLm91dHB1dFNjYWxlWCAqIHZpZXdwb3J0U2NhbGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbnZhc0hlaWdodCA9IE1hdGguY2VpbChoZWlnaHQgKiB0aGlzLm91dHB1dFNjYWxlWSAqIHZpZXdwb3J0U2NhbGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvbkNhbnZhcyA9IHRoaXMuY2FudmFzRmFjdG9yeS5jcmVhdGUoY2FudmFzV2lkdGgsIGNhbnZhc0hlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gdGhpcy5hbm5vdGF0aW9uQ2FudmFzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvbkNhbnZhc01hcC5zZXQoaWQsIGNhbnZhcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbm5vdGF0aW9uQ2FudmFzLnNhdmVkQ3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHggPSBjb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNldFRyYW5zZm9ybShzY2FsZVgsIDAsIDAsIC1zY2FsZVksIDAsIGhlaWdodCAqIHNjYWxlWSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzZXRDdHhUb0RlZmF1bHQodGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNldEN0eFRvRGVmYXVsdCh0aGlzLmN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgucmVjdChyZWN0WzBdLCByZWN0WzFdLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5jbGlwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmRQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50ID0gbmV3IENhbnZhc0V4dHJhU3RhdGUodGhpcy5jdHguY2FudmFzLndpZHRoLCB0aGlzLmN0eC5jYW52YXMuaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm0oLi4udHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm0oLi4ubWF0cml4KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5kQW5ub3RhdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuYW5ub3RhdGlvbkNhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHggPSB0aGlzLmFubm90YXRpb25DYW52YXMuc2F2ZWRDdHg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5hbm5vdGF0aW9uQ2FudmFzLnNhdmVkQ3R4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHRoaXMuYW5ub3RhdGlvbkNhbnZhczsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlTWFza1hPYmplY3QoaW1nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvdW50ID0gaW1nLmNvdW50OwogICAgICAgICAgICAgICAgICAgICAgICBpbWcgPSB0aGlzLmdldE9iamVjdChpbWcuZGF0YSwgaW1nKTsKICAgICAgICAgICAgICAgICAgICAgICAgaW1nLmNvdW50ID0gY291bnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBnbHlwaCA9IHRoaXMucHJvY2Vzc2luZ1R5cGUzOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ2x5cGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChnbHlwaC5jb21waWxlZCA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2x5cGguY29tcGlsZWQgPSBjb21waWxlVHlwZTNHbHlwaChpbWcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdseXBoLmNvbXBpbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2x5cGguY29tcGlsZWQoY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFzayA9IHRoaXMuX2NyZWF0ZU1hc2tDYW52YXMoaW1nKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFza0NhbnZhcyA9IG1hc2suY2FudmFzOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDEsIDAsIDAsIDEsIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguZHJhd0ltYWdlKG1hc2tDYW52YXMsIG1hc2sub2Zmc2V0WCwgbWFzay5vZmZzZXRZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21wb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VNYXNrWE9iamVjdFJlcGVhdChpbWcsIHNjYWxlWCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc2tld1ggPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBza2V3WSA9IGFyZ3VtZW50cy5sZW5ndGggPiAzICYmIGFyZ3VtZW50c1szXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzNdIDogMDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNjYWxlWSA9IGFyZ3VtZW50cy5sZW5ndGggPiA0ID8gYXJndW1lbnRzWzRdIDogdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcG9zaXRpb25zID0gYXJndW1lbnRzLmxlbmd0aCA+IDUgPyBhcmd1bWVudHNbNV0gOiB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGltZyA9IHRoaXMuZ2V0T2JqZWN0KGltZy5kYXRhLCBpbWcpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudFRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgudHJhbnNmb3JtKHNjYWxlWCwgc2tld1gsIHNrZXdZLCBzY2FsZVksIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXNrID0gdGhpcy5fY3JlYXRlTWFza0NhbnZhcyhpbWcpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDEsIDAsIDAsIDEsIG1hc2sub2Zmc2V0WCAtIGN1cnJlbnRUcmFuc2Zvcm1bNF0sIG1hc2sub2Zmc2V0WSAtIGN1cnJlbnRUcmFuc2Zvcm1bNV0pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBwb3NpdGlvbnMubGVuZ3RoOyBpIDwgaWk7IGkgKz0gMikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHJhbnMgPSBfdXRpbC5VdGlsLnRyYW5zZm9ybShjdXJyZW50VHJhbnNmb3JtLCBbc2NhbGVYLCBza2V3WCwgc2tld1ksIHNjYWxlWSwgcG9zaXRpb25zW2ldLCBwb3NpdGlvbnNbaSArIDFdXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbeCwgeV0gPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFswLCAwXSwgdHJhbnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZShtYXNrLmNhbnZhcywgeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21wb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VNYXNrWE9iamVjdEdyb3VwKGltYWdlcykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbENvbG9yID0gdGhpcy5jdXJyZW50LmZpbGxDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNQYXR0ZXJuRmlsbCA9IHRoaXMuY3VycmVudC5wYXR0ZXJuRmlsbDsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBpbWFnZSBvZiBpbWFnZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBpbWFnZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hc2tDYW52YXMgPSB0aGlzLmNhY2hlZENhbnZhc2VzLmdldENhbnZhcygibWFza0NhbnZhcyIsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFza0N0eCA9IG1hc2tDYW52YXMuY29udGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hc2tDdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW1nID0gdGhpcy5nZXRPYmplY3QoZGF0YSwgaW1hZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHV0QmluYXJ5SW1hZ2VNYXNrKG1hc2tDdHgsIGltZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXNrQ3R4Lmdsb2JhbENvbXBvc2l0ZU9wZXJhdGlvbiA9ICJzb3VyY2UtaW4iOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFza0N0eC5maWxsU3R5bGUgPSBpc1BhdHRlcm5GaWxsID8gZmlsbENvbG9yLmdldFBhdHRlcm4obWFza0N0eCwgdGhpcywgKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm1JbnZlcnNlKShjdHgpLCBfcGF0dGVybl9oZWxwZXIuUGF0aFR5cGUuRklMTCkgOiBmaWxsQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXNrQ3R4LmZpbGxSZWN0KDAsIDAsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFza0N0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSguLi50cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNjYWxlKDEsIC0xKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRyYXdJbWFnZUF0SW50ZWdlckNvb3JkcyhjdHgsIG1hc2tDYW52YXMuY2FudmFzLCAwLCAwLCB3aWR0aCwgaGVpZ2h0LCAwLCAtMSwgMSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcG9zZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlWE9iamVjdChvYmpJZCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbWdEYXRhID0gdGhpcy5nZXRPYmplY3Qob2JqSWQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiRGVwZW5kZW50IGltYWdlIGlzbid0IHJlYWR5IHlldCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFpbnRJbmxpbmVJbWFnZVhPYmplY3QoaW1nRGF0YSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VYT2JqZWN0UmVwZWF0KG9iaklkLCBzY2FsZVgsIHNjYWxlWSwgcG9zaXRpb25zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltZ0RhdGEgPSB0aGlzLmdldE9iamVjdChvYmpJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW1nRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJEZXBlbmRlbnQgaW1hZ2UgaXNuJ3QgcmVhZHkgeWV0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2lkdGggPSBpbWdEYXRhLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBpbWdEYXRhLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFwID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IHBvc2l0aW9ucy5sZW5ndGg7IGkgPCBpaTsgaSArPSAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXAucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtOiBbc2NhbGVYLCAwLCAwLCBzY2FsZVksIHBvc2l0aW9uc1tpXSwgcG9zaXRpb25zW2kgKyAxXV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeDogMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5OiAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHc6IHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGg6IGhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludElubGluZUltYWdlWE9iamVjdEdyb3VwKGltZ0RhdGEsIG1hcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFwcGx5VHJhbnNmZXJNYXBzVG9DYW52YXMoY3R4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmN1cnJlbnQudHJhbnNmZXJNYXBzICE9PSAibm9uZSIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5maWx0ZXIgPSB0aGlzLmN1cnJlbnQudHJhbnNmZXJNYXBzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZShjdHguY2FudmFzLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5maWx0ZXIgPSAibm9uZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGN0eC5jYW52YXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFwcGx5VHJhbnNmZXJNYXBzVG9CaXRtYXAoaW1nRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jdXJyZW50LnRyYW5zZmVyTWFwcyA9PT0gIm5vbmUiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaW1nRGF0YS5iaXRtYXA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYml0bWFwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGltZ0RhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRtcENhbnZhcyA9IHRoaXMuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKCJpbmxpbmVJbWFnZSIsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bXBDdHggPSB0bXBDYW52YXMuY29udGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LmZpbHRlciA9IHRoaXMuY3VycmVudC50cmFuc2Zlck1hcHM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRtcEN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LmZpbHRlciA9ICJub25lIjsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRtcENhbnZhcy5jYW52YXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50SW5saW5lSW1hZ2VYT2JqZWN0KGltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmNvbnRlbnRWaXNpYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2lkdGggPSBpbWdEYXRhLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBpbWdEYXRhLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9pc19ub2RlLmlzTm9kZUpTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsdGVyID0gIm5vbmUiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZSgxIC8gd2lkdGgsIC0xIC8gaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGltZ1RvUGFpbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbWdEYXRhLmJpdG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nVG9QYWludCA9IHRoaXMuYXBwbHlUcmFuc2Zlck1hcHNUb0JpdG1hcChpbWdEYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgSFRNTEVsZW1lbnQgPT09ICJmdW5jdGlvbiIgJiYgaW1nRGF0YSBpbnN0YW5jZW9mIEhUTUxFbGVtZW50IHx8ICFpbWdEYXRhLmRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZ1RvUGFpbnQgPSBpbWdEYXRhOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdG1wQ2FudmFzID0gdGhpcy5jYWNoZWRDYW52YXNlcy5nZXRDYW52YXMoImlubGluZUltYWdlIiwgd2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bXBDdHggPSB0bXBDYW52YXMuY29udGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1dEJpbmFyeUltYWdlRGF0YSh0bXBDdHgsIGltZ0RhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nVG9QYWludCA9IHRoaXMuYXBwbHlUcmFuc2Zlck1hcHNUb0NhbnZhcyh0bXBDdHgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlZCA9IHRoaXMuX3NjYWxlSW1hZ2UoaW1nVG9QYWludCwgKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm1JbnZlcnNlKShjdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmltYWdlU21vb3RoaW5nRW5hYmxlZCA9IGdldEltYWdlU21vb3RoaW5nRW5hYmxlZCgoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3R4KSwgaW1nRGF0YS5pbnRlcnBvbGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRyYXdJbWFnZUF0SW50ZWdlckNvb3JkcyhjdHgsIHNjYWxlZC5pbWcsIDAsIDAsIHNjYWxlZC5wYWludFdpZHRoLCBzY2FsZWQucGFpbnRIZWlnaHQsIDAsIC1oZWlnaHQsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbXBvc2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50SW5saW5lSW1hZ2VYT2JqZWN0R3JvdXAoaW1nRGF0YSwgbWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgaW1nVG9QYWludDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGltZ0RhdGEuYml0bWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWdUb1BhaW50ID0gaW1nRGF0YS5iaXRtYXA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3ID0gaW1nRGF0YS53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGggPSBpbWdEYXRhLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRtcENhbnZhcyA9IHRoaXMuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKCJpbmxpbmVJbWFnZSIsIHcsIGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdG1wQ3R4ID0gdG1wQ2FudmFzLmNvbnRleHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdXRCaW5hcnlJbWFnZURhdGEodG1wQ3R4LCBpbWdEYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZ1RvUGFpbnQgPSB0aGlzLmFwcGx5VHJhbnNmZXJNYXBzVG9DYW52YXModG1wQ3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVudHJ5IG9mIG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC50cmFuc2Zvcm0oLi4uZW50cnkudHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZSgxLCAtMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3SW1hZ2VBdEludGVnZXJDb29yZHMoY3R4LCBpbWdUb1BhaW50LCBlbnRyeS54LCBlbnRyeS55LCBlbnRyeS53LCBlbnRyeS5oLCAwLCAtMSwgMSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcG9zZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwYWludFNvbGlkQ29sb3JJbWFnZU1hc2soKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LmZpbGxSZWN0KDAsIDAsIDEsIDEpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbXBvc2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgbWFya1BvaW50KHRhZykge30KICAgICAgICAgICAgICAgICAgICBtYXJrUG9pbnRQcm9wcyh0YWcsIHByb3BlcnRpZXMpIHt9CiAgICAgICAgICAgICAgICAgICAgYmVnaW5NYXJrZWRDb250ZW50KHRhZykgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hcmtlZENvbnRlbnRTdGFjay5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpc2libGU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJlZ2luTWFya2VkQ29udGVudFByb3BzKHRhZywgcHJvcGVydGllcykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGFnID09PSAiT0MiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hcmtlZENvbnRlbnRTdGFjay5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aXNpYmxlOiB0aGlzLm9wdGlvbmFsQ29udGVudENvbmZpZy5pc1Zpc2libGUocHJvcGVydGllcykKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tYXJrZWRDb250ZW50U3RhY2sucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlzaWJsZTogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250ZW50VmlzaWJsZSA9IHRoaXMuaXNDb250ZW50VmlzaWJsZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmRNYXJrZWRDb250ZW50KCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hcmtlZENvbnRlbnRTdGFjay5wb3AoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250ZW50VmlzaWJsZSA9IHRoaXMuaXNDb250ZW50VmlzaWJsZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBiZWdpbkNvbXBhdCgpIHt9CiAgICAgICAgICAgICAgICAgICAgZW5kQ29tcGF0KCkge30KICAgICAgICAgICAgICAgICAgICBjb25zdW1lUGF0aChjbGlwQm94KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzRW1wdHkgPSB0aGlzLmN1cnJlbnQuaXNFbXB0eUNsaXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucGVuZGluZ0NsaXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC51cGRhdGVDbGlwRnJvbVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMucGVuZGluZ0NsaXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcG9zZShjbGlwQm94KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucGVuZGluZ0NsaXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNFbXB0eSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnBlbmRpbmdDbGlwID09PSBFT19DTElQKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5jbGlwKCJldmVub2RkIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmNsaXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBlbmRpbmdDbGlwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuc3RhcnROZXdQYXRoQW5kQ2xpcEJveCh0aGlzLmN1cnJlbnQuY2xpcEJveCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZWdpblBhdGgoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0U2luZ2xlUGl4ZWxXaWR0aCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9jYWNoZWRHZXRTaW5nbGVQaXhlbFdpZHRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtID0gKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKHRoaXMuY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtWzFdID09PSAwICYmIG1bMl0gPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRHZXRTaW5nbGVQaXhlbFdpZHRoID0gMSAvIE1hdGgubWluKE1hdGguYWJzKG1bMF0pLCBNYXRoLmFicyhtWzNdKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFic0RldCA9IE1hdGguYWJzKG1bMF0gKiBtWzNdIC0gbVsyXSAqIG1bMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vcm1YID0gTWF0aC5oeXBvdChtWzBdLCBtWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBub3JtWSA9IE1hdGguaHlwb3QobVsxXSwgbVszXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkR2V0U2luZ2xlUGl4ZWxXaWR0aCA9IE1hdGgubWF4KG5vcm1YLCBub3JtWSkgLyBhYnNEZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2NhY2hlZEdldFNpbmdsZVBpeGVsV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFNjYWxlRm9yU3Ryb2tpbmcoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5fY2FjaGVkU2NhbGVGb3JTdHJva2luZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVXaWR0aAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG0gPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNjYWxlWCwgc2NhbGVZOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1bMV0gPT09IDAgJiYgbVsyXSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vcm1YID0gTWF0aC5hYnMobVswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgbm9ybVkgPSBNYXRoLmFicyhtWzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobGluZVdpZHRoID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWCA9IDEgLyBub3JtWDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVZID0gMSAvIG5vcm1ZOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlZFhMaW5lV2lkdGggPSBub3JtWCAqIGxpbmVXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVkWUxpbmVXaWR0aCA9IG5vcm1ZICogbGluZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZVggPSBzY2FsZWRYTGluZVdpZHRoIDwgMSA/IDEgLyBzY2FsZWRYTGluZVdpZHRoIDogMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVZID0gc2NhbGVkWUxpbmVXaWR0aCA8IDEgPyAxIC8gc2NhbGVkWUxpbmVXaWR0aCA6IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhYnNEZXQgPSBNYXRoLmFicyhtWzBdICogbVszXSAtIG1bMl0gKiBtWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBub3JtWCA9IE1hdGguaHlwb3QobVswXSwgbVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgbm9ybVkgPSBNYXRoLmh5cG90KG1bMl0sIG1bM10pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsaW5lV2lkdGggPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVYID0gbm9ybVkgLyBhYnNEZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWSA9IG5vcm1YIC8gYWJzRGV0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJhc2VBcmVhID0gbGluZVdpZHRoICogYWJzRGV0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZVggPSBub3JtWSA+IGJhc2VBcmVhID8gbm9ybVkgLyBiYXNlQXJlYSA6IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWSA9IG5vcm1YID4gYmFzZUFyZWEgPyBub3JtWCAvIGJhc2VBcmVhIDogMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRTY2FsZUZvclN0cm9raW5nID0gW3NjYWxlWCwgc2NhbGVZXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fY2FjaGVkU2NhbGVGb3JTdHJva2luZzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVzY2FsZUFuZFN0cm9rZShzYXZlUmVzdG9yZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVXaWR0aAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbc2NhbGVYLCBzY2FsZVldID0gdGhpcy5nZXRTY2FsZUZvclN0cm9raW5nKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lV2lkdGggPSBsaW5lV2lkdGggfHwgMTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNjYWxlWCA9PT0gMSAmJiBzY2FsZVkgPT09IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc2F2ZWRNYXRyaXgsIHNhdmVkRGFzaGVzLCBzYXZlZERhc2hPZmZzZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzYXZlUmVzdG9yZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2F2ZWRNYXRyaXggPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNhdmVkRGFzaGVzID0gY3R4LmdldExpbmVEYXNoKCkuc2xpY2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNhdmVkRGFzaE9mZnNldCA9IGN0eC5saW5lRGFzaE9mZnNldDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2NhbGUoc2NhbGVYLCBzY2FsZVkpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZSA9IE1hdGgubWF4KHNjYWxlWCwgc2NhbGVZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNldExpbmVEYXNoKGN0eC5nZXRMaW5lRGFzaCgpLm1hcCh4ID0+IHggLyBzY2FsZSkpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgubGluZURhc2hPZmZzZXQgLz0gc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNhdmVSZXN0b3JlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKC4uLnNhdmVkTWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRMaW5lRGFzaChzYXZlZERhc2hlcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgubGluZURhc2hPZmZzZXQgPSBzYXZlZERhc2hPZmZzZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNDb250ZW50VmlzaWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IHRoaXMubWFya2VkQ29udGVudFN0YWNrLmxlbmd0aCAtIDE7IGkgPj0gMDsgaS0tKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMubWFya2VkQ29udGVudFN0YWNrW2ldLnZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5DYW52YXNHcmFwaGljcyA9IENhbnZhc0dyYXBoaWNzOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3Jlc3RvcmVJbml0aWFsU3RhdGUyKCkgewogICAgICAgICAgICAgICAgICAgIHdoaWxlICh0aGlzLnN0YXRlU3RhY2subGVuZ3RoIHx8IHRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy50cmFuc3BhcmVudENhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eCA9IHRoaXMuY29tcG9zaXRlQ3R4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNldFRyYW5zZm9ybSgxLCAwLCAwLCAxLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZHJhd0ltYWdlKHRoaXMudHJhbnNwYXJlbnRDYW52YXMsIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNwYXJlbnRDYW52YXMgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgb3AgaW4gX3V0aWwuT1BTKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKENhbnZhc0dyYXBoaWNzLnByb3RvdHlwZVtvcF0gIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICBDYW52YXNHcmFwaGljcy5wcm90b3R5cGVbX3V0aWwuT1BTW29wXV0gPSBDYW52YXNHcmFwaGljcy5wcm90b3R5cGVbb3BdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQ3ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuVGlsaW5nUGF0dGVybiA9IGV4cG9ydHMuUGF0aFR5cGUgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICBleHBvcnRzLmdldFNoYWRpbmdQYXR0ZXJuID0gZ2V0U2hhZGluZ1BhdHRlcm47CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwbGF5X3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDIpOwogICAgICAgICAgICAgICAgY29uc3QgUGF0aFR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgRklMTDogIkZpbGwiLAogICAgICAgICAgICAgICAgICAgIFNUUk9LRTogIlN0cm9rZSIsCiAgICAgICAgICAgICAgICAgICAgU0hBRElORzogIlNoYWRpbmciCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5QYXRoVHlwZSA9IFBhdGhUeXBlOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gYXBwbHlCb3VuZGluZ0JveChjdHgsIGJib3gpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWJib3gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGJib3hbMl0gLSBiYm94WzBdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGJib3hbM10gLSBiYm94WzFdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlZ2lvbiA9IG5ldyBQYXRoMkQoKTsKICAgICAgICAgICAgICAgICAgICByZWdpb24ucmVjdChiYm94WzBdLCBiYm94WzFdLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICBjdHguY2xpcChyZWdpb24pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgQmFzZVNoYWRpbmdQYXR0ZXJuIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IEJhc2VTaGFkaW5nUGF0dGVybikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQmFzZVNoYWRpbmdQYXR0ZXJuLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhdHRlcm4oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkFic3RyYWN0IG1ldGhvZCBgZ2V0UGF0dGVybmAgY2FsbGVkLiIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFJhZGlhbEF4aWFsU2hhZGluZ1BhdHRlcm4gZXh0ZW5kcyBCYXNlU2hhZGluZ1BhdHRlcm4gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKElSKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3R5cGUgPSBJUlsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmJveCA9IElSWzJdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb2xvclN0b3BzID0gSVJbM107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3AwID0gSVJbNF07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3AxID0gSVJbNV07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3IwID0gSVJbNl07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3IxID0gSVJbN107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWF0cml4ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NyZWF0ZUdyYWRpZW50KGN0eCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZ3JhZDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3R5cGUgPT09ICJheGlhbCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWQgPSBjdHguY3JlYXRlTGluZWFyR3JhZGllbnQodGhpcy5fcDBbMF0sIHRoaXMuX3AwWzFdLCB0aGlzLl9wMVswXSwgdGhpcy5fcDFbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX3R5cGUgPT09ICJyYWRpYWwiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkID0gY3R4LmNyZWF0ZVJhZGlhbEdyYWRpZW50KHRoaXMuX3AwWzBdLCB0aGlzLl9wMFsxXSwgdGhpcy5fcjAsIHRoaXMuX3AxWzBdLCB0aGlzLl9wMVsxXSwgdGhpcy5fcjEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgY29sb3JTdG9wIG9mIHRoaXMuX2NvbG9yU3RvcHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWQuYWRkQ29sb3JTdG9wKGNvbG9yU3RvcFswXSwgY29sb3JTdG9wWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZ3JhZDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGF0dGVybihjdHgsIG93bmVyLCBpbnZlcnNlLCBwYXRoVHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGF0dGVybjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhdGhUeXBlID09PSBQYXRoVHlwZS5TVFJPS0UgfHwgcGF0aFR5cGUgPT09IFBhdGhUeXBlLkZJTEwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG93bmVyQkJveCA9IG93bmVyLmN1cnJlbnQuZ2V0Q2xpcHBlZFBhdGhCb3VuZGluZ0JveChwYXRoVHlwZSwgKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKGN0eCkpIHx8IFswLCAwLCAwLCAwXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gTWF0aC5jZWlsKG93bmVyQkJveFsyXSAtIG93bmVyQkJveFswXSkgfHwgMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IE1hdGguY2VpbChvd25lckJCb3hbM10gLSBvd25lckJCb3hbMV0pIHx8IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bXBDYW52YXMgPSBvd25lci5jYWNoZWRDYW52YXNlcy5nZXRDYW52YXMoInBhdHRlcm4iLCB3aWR0aCwgaGVpZ2h0LCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRtcEN0eCA9IHRtcENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LmNsZWFyUmVjdCgwLCAwLCB0bXBDdHguY2FudmFzLndpZHRoLCB0bXBDdHguY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXBDdHguYmVnaW5QYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXBDdHgucmVjdCgwLCAwLCB0bXBDdHguY2FudmFzLndpZHRoLCB0bXBDdHguY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXBDdHgudHJhbnNsYXRlKC1vd25lckJCb3hbMF0sIC1vd25lckJCb3hbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW52ZXJzZSA9IF91dGlsLlV0aWwudHJhbnNmb3JtKGludmVyc2UsIFsxLCAwLCAwLCAxLCBvd25lckJCb3hbMF0sIG93bmVyQkJveFsxXV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LnRyYW5zZm9ybSguLi5vd25lci5iYXNlVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLm1hdHJpeCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRtcEN0eC50cmFuc2Zvcm0oLi4udGhpcy5tYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwbHlCb3VuZGluZ0JveCh0bXBDdHgsIHRoaXMuX2Jib3gpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LmZpbGxTdHlsZSA9IHRoaXMuX2NyZWF0ZUdyYWRpZW50KHRtcEN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXBDdHguZmlsbCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVybiA9IGN0eC5jcmVhdGVQYXR0ZXJuKHRtcENhbnZhcy5jYW52YXMsICJuby1yZXBlYXQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRvbU1hdHJpeCA9IG5ldyBET01NYXRyaXgoaW52ZXJzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXR0ZXJuLnNldFRyYW5zZm9ybShkb21NYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwbHlCb3VuZGluZ0JveChjdHgsIHRoaXMuX2Jib3gpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVybiA9IHRoaXMuX2NyZWF0ZUdyYWRpZW50KGN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhdHRlcm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZHJhd1RyaWFuZ2xlKGRhdGEsIGNvbnRleHQsIHAxLCBwMiwgcDMsIGMxLCBjMiwgYzMpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjb29yZHMgPSBjb250ZXh0LmNvb3JkcywKICAgICAgICAgICAgICAgICAgICAgICAgY29sb3JzID0gY29udGV4dC5jb2xvcnM7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgYnl0ZXMgPSBkYXRhLmRhdGEsCiAgICAgICAgICAgICAgICAgICAgICAgIHJvd1NpemUgPSBkYXRhLndpZHRoICogNDsKICAgICAgICAgICAgICAgICAgICBsZXQgdG1wOwogICAgICAgICAgICAgICAgICAgIGlmIChjb29yZHNbcDEgKyAxXSA+IGNvb3Jkc1twMiArIDFdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRtcCA9IHAxOwogICAgICAgICAgICAgICAgICAgICAgICBwMSA9IHAyOwogICAgICAgICAgICAgICAgICAgICAgICBwMiA9IHRtcDsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wID0gYzE7CiAgICAgICAgICAgICAgICAgICAgICAgIGMxID0gYzI7CiAgICAgICAgICAgICAgICAgICAgICAgIGMyID0gdG1wOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoY29vcmRzW3AyICsgMV0gPiBjb29yZHNbcDMgKyAxXSkgewogICAgICAgICAgICAgICAgICAgICAgICB0bXAgPSBwMjsKICAgICAgICAgICAgICAgICAgICAgICAgcDIgPSBwMzsKICAgICAgICAgICAgICAgICAgICAgICAgcDMgPSB0bXA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRtcCA9IGMyOwogICAgICAgICAgICAgICAgICAgICAgICBjMiA9IGMzOwogICAgICAgICAgICAgICAgICAgICAgICBjMyA9IHRtcDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGNvb3Jkc1twMSArIDFdID4gY29vcmRzW3AyICsgMV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wID0gcDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHAxID0gcDI7CiAgICAgICAgICAgICAgICAgICAgICAgIHAyID0gdG1wOwogICAgICAgICAgICAgICAgICAgICAgICB0bXAgPSBjMTsKICAgICAgICAgICAgICAgICAgICAgICAgYzEgPSBjMjsKICAgICAgICAgICAgICAgICAgICAgICAgYzIgPSB0bXA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHgxID0gKGNvb3Jkc1twMV0gKyBjb250ZXh0Lm9mZnNldFgpICogY29udGV4dC5zY2FsZVg7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgeTEgPSAoY29vcmRzW3AxICsgMV0gKyBjb250ZXh0Lm9mZnNldFkpICogY29udGV4dC5zY2FsZVk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgeDIgPSAoY29vcmRzW3AyXSArIGNvbnRleHQub2Zmc2V0WCkgKiBjb250ZXh0LnNjYWxlWDsKICAgICAgICAgICAgICAgICAgICBjb25zdCB5MiA9IChjb29yZHNbcDIgKyAxXSArIGNvbnRleHQub2Zmc2V0WSkgKiBjb250ZXh0LnNjYWxlWTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB4MyA9IChjb29yZHNbcDNdICsgY29udGV4dC5vZmZzZXRYKSAqIGNvbnRleHQuc2NhbGVYOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHkzID0gKGNvb3Jkc1twMyArIDFdICsgY29udGV4dC5vZmZzZXRZKSAqIGNvbnRleHQuc2NhbGVZOwogICAgICAgICAgICAgICAgICAgIGlmICh5MSA+PSB5MykgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IGMxciA9IGNvbG9yc1tjMV0sCiAgICAgICAgICAgICAgICAgICAgICAgIGMxZyA9IGNvbG9yc1tjMSArIDFdLAogICAgICAgICAgICAgICAgICAgICAgICBjMWIgPSBjb2xvcnNbYzEgKyAyXTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjMnIgPSBjb2xvcnNbYzJdLAogICAgICAgICAgICAgICAgICAgICAgICBjMmcgPSBjb2xvcnNbYzIgKyAxXSwKICAgICAgICAgICAgICAgICAgICAgICAgYzJiID0gY29sb3JzW2MyICsgMl07CiAgICAgICAgICAgICAgICAgICAgY29uc3QgYzNyID0gY29sb3JzW2MzXSwKICAgICAgICAgICAgICAgICAgICAgICAgYzNnID0gY29sb3JzW2MzICsgMV0sCiAgICAgICAgICAgICAgICAgICAgICAgIGMzYiA9IGNvbG9yc1tjMyArIDJdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IG1pblkgPSBNYXRoLnJvdW5kKHkxKSwKICAgICAgICAgICAgICAgICAgICAgICAgbWF4WSA9IE1hdGgucm91bmQoeTMpOwogICAgICAgICAgICAgICAgICAgIGxldCB4YSwgY2FyLCBjYWcsIGNhYjsKICAgICAgICAgICAgICAgICAgICBsZXQgeGIsIGNiciwgY2JnLCBjYmI7CiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgeSA9IG1pblk7IHkgPD0gbWF4WTsgeSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh5IDwgeTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHkgPCB5MSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gKHkxIC0geSkgLyAoeTEgLSB5Mik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB4YSA9IHgxIC0gKHgxIC0geDIpICogazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhciA9IGMxciAtIChjMXIgLSBjMnIpICogazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhZyA9IGMxZyAtIChjMWcgLSBjMmcpICogazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhYiA9IGMxYiAtIChjMWIgLSBjMmIpICogazsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHkgPiB5MykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh5MiA9PT0geTMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgayA9ICh5MiAtIHkpIC8gKHkyIC0geTMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgeGEgPSB4MiAtICh4MiAtIHgzKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXIgPSBjMnIgLSAoYzJyIC0gYzNyKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWcgPSBjMmcgLSAoYzJnIC0gYzNnKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWIgPSBjMmIgLSAoYzJiIC0gYzNiKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGs7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh5IDwgeTEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHkgPiB5MykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgayA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gKHkxIC0geSkgLyAoeTEgLSB5Myk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgeGIgPSB4MSAtICh4MSAtIHgzKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNiciA9IGMxciAtIChjMXIgLSBjM3IpICogazsKICAgICAgICAgICAgICAgICAgICAgICAgY2JnID0gYzFnIC0gKGMxZyAtIGMzZykgKiBrOwogICAgICAgICAgICAgICAgICAgICAgICBjYmIgPSBjMWIgLSAoYzFiIC0gYzNiKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHgxXyA9IE1hdGgucm91bmQoTWF0aC5taW4oeGEsIHhiKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHgyXyA9IE1hdGgucm91bmQoTWF0aC5tYXgoeGEsIHhiKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBqID0gcm93U2l6ZSAqIHkgKyB4MV8gKiA0OwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCB4ID0geDFfOyB4IDw9IHgyXzsgeCsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gKHhhIC0geCkgLyAoeGEgLSB4Yik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoayA8IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoayA+IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2orK10gPSBjYXIgLSAoY2FyIC0gY2JyKSAqIGsgfCAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZXNbaisrXSA9IGNhZyAtIChjYWcgLSBjYmcpICogayB8IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlc1tqKytdID0gY2FiIC0gKGNhYiAtIGNiYikgKiBrIHwgMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2orK10gPSAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBkcmF3RmlndXJlKGRhdGEsIGZpZ3VyZSwgY29udGV4dCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBzID0gZmlndXJlLmNvb3JkczsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjcyA9IGZpZ3VyZS5jb2xvcnM7CiAgICAgICAgICAgICAgICAgICAgbGV0IGksIGlpOwogICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZmlndXJlLnR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAibGF0dGljZSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2ZXJ0aWNlc1BlclJvdyA9IGZpZ3VyZS52ZXJ0aWNlc1BlclJvdzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvd3MgPSBNYXRoLmZsb29yKHBzLmxlbmd0aCAvIHZlcnRpY2VzUGVyUm93KSAtIDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xzID0gdmVydGljZXNQZXJSb3cgLSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMDsgaSA8IHJvd3M7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBxID0gaSAqIHZlcnRpY2VzUGVyUm93OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgY29sczsgaisrLCBxKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZHJhd1RyaWFuZ2xlKGRhdGEsIGNvbnRleHQsIHBzW3FdLCBwc1txICsgMV0sIHBzW3EgKyB2ZXJ0aWNlc1BlclJvd10sIGNzW3FdLCBjc1txICsgMV0sIGNzW3EgKyB2ZXJ0aWNlc1BlclJvd10pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3VHJpYW5nbGUoZGF0YSwgY29udGV4dCwgcHNbcSArIHZlcnRpY2VzUGVyUm93ICsgMV0sIHBzW3EgKyAxXSwgcHNbcSArIHZlcnRpY2VzUGVyUm93XSwgY3NbcSArIHZlcnRpY2VzUGVyUm93ICsgMV0sIGNzW3EgKyAxXSwgY3NbcSArIHZlcnRpY2VzUGVyUm93XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgInRyaWFuZ2xlcyI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IHBzLmxlbmd0aDsgaSA8IGlpOyBpICs9IDMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3VHJpYW5nbGUoZGF0YSwgY29udGV4dCwgcHNbaV0sIHBzW2kgKyAxXSwgcHNbaSArIDJdLCBjc1tpXSwgY3NbaSArIDFdLCBjc1tpICsgMl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoImlsbGVnYWwgZmlndXJlIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgTWVzaFNoYWRpbmdQYXR0ZXJuIGV4dGVuZHMgQmFzZVNoYWRpbmdQYXR0ZXJuIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihJUikgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb29yZHMgPSBJUlsyXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29sb3JzID0gSVJbM107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZpZ3VyZXMgPSBJUls0XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYm91bmRzID0gSVJbNV07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Jib3ggPSBJUls3XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmFja2dyb3VuZCA9IElSWzhdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hdHJpeCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9jcmVhdGVNZXNoQ2FudmFzKGNvbWJpbmVkU2NhbGUsIGJhY2tncm91bmRDb2xvciwgY2FjaGVkQ2FudmFzZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgRVhQRUNURURfU0NBTEUgPSAxLjE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IE1BWF9QQVRURVJOX1NJWkUgPSAzMDAwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBCT1JERVJfU0laRSA9IDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFggPSBNYXRoLmZsb29yKHRoaXMuX2JvdW5kc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFkgPSBNYXRoLmZsb29yKHRoaXMuX2JvdW5kc1sxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJvdW5kc1dpZHRoID0gTWF0aC5jZWlsKHRoaXMuX2JvdW5kc1syXSkgLSBvZmZzZXRYOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBib3VuZHNIZWlnaHQgPSBNYXRoLmNlaWwodGhpcy5fYm91bmRzWzNdKSAtIG9mZnNldFk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gTWF0aC5taW4oTWF0aC5jZWlsKE1hdGguYWJzKGJvdW5kc1dpZHRoICogY29tYmluZWRTY2FsZVswXSAqIEVYUEVDVEVEX1NDQUxFKSksIE1BWF9QQVRURVJOX1NJWkUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBNYXRoLm1pbihNYXRoLmNlaWwoTWF0aC5hYnMoYm91bmRzSGVpZ2h0ICogY29tYmluZWRTY2FsZVsxXSAqIEVYUEVDVEVEX1NDQUxFKSksIE1BWF9QQVRURVJOX1NJWkUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZVggPSBib3VuZHNXaWR0aCAvIHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZVkgPSBib3VuZHNIZWlnaHQgLyBoZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRleHQgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb29yZHM6IHRoaXMuX2Nvb3JkcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbG9yczogdGhpcy5fY29sb3JzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0WDogLW9mZnNldFgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZOiAtb2Zmc2V0WSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWDogMSAvIHNjYWxlWCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWTogMSAvIHNjYWxlWQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWRkZWRXaWR0aCA9IHdpZHRoICsgQk9SREVSX1NJWkUgKiAyOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWRkZWRIZWlnaHQgPSBoZWlnaHQgKyBCT1JERVJfU0laRSAqIDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRtcENhbnZhcyA9IGNhY2hlZENhbnZhc2VzLmdldENhbnZhcygibWVzaCIsIHBhZGRlZFdpZHRoLCBwYWRkZWRIZWlnaHQsIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdG1wQ3R4ID0gdG1wQ2FudmFzLmNvbnRleHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSB0bXBDdHguY3JlYXRlSW1hZ2VEYXRhKHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmFja2dyb3VuZENvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBieXRlcyA9IGRhdGEuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGJ5dGVzLmxlbmd0aDsgaSA8IGlpOyBpICs9IDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlc1tpXSA9IGJhY2tncm91bmRDb2xvclswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlc1tpICsgMV0gPSBiYWNrZ3JvdW5kQ29sb3JbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZXNbaSArIDJdID0gYmFja2dyb3VuZENvbG9yWzJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2kgKyAzXSA9IDI1NTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGZpZ3VyZSBvZiB0aGlzLl9maWd1cmVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3RmlndXJlKGRhdGEsIGZpZ3VyZSwgY29udGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LnB1dEltYWdlRGF0YShkYXRhLCBCT1JERVJfU0laRSwgQk9SREVSX1NJWkUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXMgPSB0bXBDYW52YXMuY2FudmFzOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0WDogb2Zmc2V0WCAtIEJPUkRFUl9TSVpFICogc2NhbGVYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0WTogb2Zmc2V0WSAtIEJPUkRFUl9TSVpFICogc2NhbGVZLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVZCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhdHRlcm4oY3R4LCBvd25lciwgaW52ZXJzZSwgcGF0aFR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgYXBwbHlCb3VuZGluZ0JveChjdHgsIHRoaXMuX2Jib3gpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYXRoVHlwZSA9PT0gUGF0aFR5cGUuU0hBRElORykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGUgPSBfdXRpbC5VdGlsLnNpbmd1bGFyVmFsdWVEZWNvbXBvc2UyZFNjYWxlKCgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlID0gX3V0aWwuVXRpbC5zaW5ndWxhclZhbHVlRGVjb21wb3NlMmRTY2FsZShvd25lci5iYXNlVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLm1hdHJpeCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hdHJpeFNjYWxlID0gX3V0aWwuVXRpbC5zaW5ndWxhclZhbHVlRGVjb21wb3NlMmRTY2FsZSh0aGlzLm1hdHJpeCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGUgPSBbc2NhbGVbMF0gKiBtYXRyaXhTY2FsZVswXSwgc2NhbGVbMV0gKiBtYXRyaXhTY2FsZVsxXV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGVtcG9yYXJ5UGF0dGVybkNhbnZhcyA9IHRoaXMuX2NyZWF0ZU1lc2hDYW52YXMoc2NhbGUsIHBhdGhUeXBlID09PSBQYXRoVHlwZS5TSEFESU5HID8gbnVsbCA6IHRoaXMuX2JhY2tncm91bmQsIG93bmVyLmNhY2hlZENhbnZhc2VzKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhdGhUeXBlICE9PSBQYXRoVHlwZS5TSEFESU5HKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKC4uLm93bmVyLmJhc2VUcmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMubWF0cml4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSguLi50aGlzLm1hdHJpeCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zbGF0ZSh0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzLm9mZnNldFgsIHRlbXBvcmFyeVBhdHRlcm5DYW52YXMub2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZSh0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzLnNjYWxlWCwgdGVtcG9yYXJ5UGF0dGVybkNhbnZhcy5zY2FsZVkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3R4LmNyZWF0ZVBhdHRlcm4odGVtcG9yYXJ5UGF0dGVybkNhbnZhcy5jYW52YXMsICJuby1yZXBlYXQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBEdW1teVNoYWRpbmdQYXR0ZXJuIGV4dGVuZHMgQmFzZVNoYWRpbmdQYXR0ZXJuIHsKICAgICAgICAgICAgICAgICAgICBnZXRQYXR0ZXJuKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gImhvdHBpbmsiOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldFNoYWRpbmdQYXR0ZXJuKElSKSB7CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChJUlswXSkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJSYWRpYWxBeGlhbCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFJhZGlhbEF4aWFsU2hhZGluZ1BhdHRlcm4oSVIpOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJNZXNoIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgTWVzaFNoYWRpbmdQYXR0ZXJuKElSKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiRHVtbXkiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBEdW1teVNoYWRpbmdQYXR0ZXJuKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5rbm93biBJUiB0eXBlOiAke0lSWzBdfWApOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY29uc3QgUGFpbnRUeXBlID0gewogICAgICAgICAgICAgICAgICAgIENPTE9SRUQ6IDEsCiAgICAgICAgICAgICAgICAgICAgVU5DT0xPUkVEOiAyCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgY2xhc3MgVGlsaW5nUGF0dGVybiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBNQVhfUEFUVEVSTl9TSVpFKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIk1BWF9QQVRURVJOX1NJWkUiLCAzMDAwKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoSVIsIGNvbG9yLCBjdHgsIGNhbnZhc0dyYXBoaWNzRmFjdG9yeSwgYmFzZVRyYW5zZm9ybSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wZXJhdG9yTGlzdCA9IElSWzJdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hdHJpeCA9IElSWzNdIHx8IFsxLCAwLCAwLCAxLCAwLCAwXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5iYm94ID0gSVJbNF07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueHN0ZXAgPSBJUls1XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy55c3RlcCA9IElSWzZdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhaW50VHlwZSA9IElSWzddOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRpbGluZ1R5cGUgPSBJUls4XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2xvciA9IGNvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eCA9IGN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXNHcmFwaGljc0ZhY3RvcnkgPSBjYW52YXNHcmFwaGljc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVRyYW5zZm9ybSA9IGJhc2VUcmFuc2Zvcm07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNyZWF0ZVBhdHRlcm5DYW52YXMob3duZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3BlcmF0b3JMaXN0ID0gdGhpcy5vcGVyYXRvckxpc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJib3ggPSB0aGlzLmJib3g7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHhzdGVwID0gdGhpcy54c3RlcDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeXN0ZXAgPSB0aGlzLnlzdGVwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWludFR5cGUgPSB0aGlzLnBhaW50VHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGlsaW5nVHlwZSA9IHRoaXMudGlsaW5nVHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29sb3IgPSB0aGlzLmNvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXNHcmFwaGljc0ZhY3RvcnkgPSB0aGlzLmNhbnZhc0dyYXBoaWNzRmFjdG9yeTsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJUaWxpbmdUeXBlOiAiICsgdGlsaW5nVHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHgwID0gYmJveFswXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkwID0gYmJveFsxXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHgxID0gYmJveFsyXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkxID0gYmJveFszXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF0cml4U2NhbGUgPSBfdXRpbC5VdGlsLnNpbmd1bGFyVmFsdWVEZWNvbXBvc2UyZFNjYWxlKHRoaXMubWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VyTWF0cml4U2NhbGUgPSBfdXRpbC5VdGlsLnNpbmd1bGFyVmFsdWVEZWNvbXBvc2UyZFNjYWxlKHRoaXMuYmFzZVRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbWJpbmVkU2NhbGUgPSBbbWF0cml4U2NhbGVbMF0gKiBjdXJNYXRyaXhTY2FsZVswXSwgbWF0cml4U2NhbGVbMV0gKiBjdXJNYXRyaXhTY2FsZVsxXV07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRpbXggPSB0aGlzLmdldFNpemVBbmRTY2FsZSh4c3RlcCwgdGhpcy5jdHguY2FudmFzLndpZHRoLCBjb21iaW5lZFNjYWxlWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGlteSA9IHRoaXMuZ2V0U2l6ZUFuZFNjYWxlKHlzdGVwLCB0aGlzLmN0eC5jYW52YXMuaGVpZ2h0LCBjb21iaW5lZFNjYWxlWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdG1wQ2FudmFzID0gb3duZXIuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKCJwYXR0ZXJuIiwgZGlteC5zaXplLCBkaW15LnNpemUsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bXBDdHggPSB0bXBDYW52YXMuY29udGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZ3JhcGhpY3MgPSBjYW52YXNHcmFwaGljc0ZhY3RvcnkuY3JlYXRlQ2FudmFzR3JhcGhpY3ModG1wQ3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgZ3JhcGhpY3MuZ3JvdXBMZXZlbCA9IG93bmVyLmdyb3VwTGV2ZWw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RmlsbEFuZFN0cm9rZVN0eWxlVG9Db250ZXh0KGdyYXBoaWNzLCBwYWludFR5cGUsIGNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFkanVzdGVkWDAgPSB4MDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFkanVzdGVkWTAgPSB5MDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFkanVzdGVkWDEgPSB4MTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFkanVzdGVkWTEgPSB5MTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHgwIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRqdXN0ZWRYMCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGp1c3RlZFgxICs9IE1hdGguYWJzKHgwKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoeTAgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGp1c3RlZFkwID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFkanVzdGVkWTEgKz0gTWF0aC5hYnMoeTApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRtcEN0eC50cmFuc2xhdGUoLShkaW14LnNjYWxlICogYWRqdXN0ZWRYMCksIC0oZGlteS5zY2FsZSAqIGFkanVzdGVkWTApKTsKICAgICAgICAgICAgICAgICAgICAgICAgZ3JhcGhpY3MudHJhbnNmb3JtKGRpbXguc2NhbGUsIDAsIDAsIGRpbXkuc2NhbGUsIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICB0bXBDdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXBCYm94KGdyYXBoaWNzLCBhZGp1c3RlZFgwLCBhZGp1c3RlZFkwLCBhZGp1c3RlZFgxLCBhZGp1c3RlZFkxKTsKICAgICAgICAgICAgICAgICAgICAgICAgZ3JhcGhpY3MuYmFzZVRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShncmFwaGljcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICBncmFwaGljcy5leGVjdXRlT3BlcmF0b3JMaXN0KG9wZXJhdG9yTGlzdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGdyYXBoaWNzLmVuZERyYXdpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhczogdG1wQ2FudmFzLmNhbnZhcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWDogZGlteC5zY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWTogZGlteS5zY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFg6IGFkanVzdGVkWDAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZOiBhZGp1c3RlZFkwCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFNpemVBbmRTY2FsZShzdGVwLCByZWFsT3V0cHV0U2l6ZSwgc2NhbGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3RlcCA9IE1hdGguYWJzKHN0ZXApOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXhTaXplID0gTWF0aC5tYXgoVGlsaW5nUGF0dGVybi5NQVhfUEFUVEVSTl9TSVpFLCByZWFsT3V0cHV0U2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzaXplID0gTWF0aC5jZWlsKHN0ZXAgKiBzY2FsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzaXplID49IG1heFNpemUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemUgPSBtYXhTaXplOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGUgPSBzaXplIC8gc3RlcDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsaXBCYm94KGdyYXBoaWNzLCB4MCwgeTAsIHgxLCB5MSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiYm94V2lkdGggPSB4MSAtIHgwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiYm94SGVpZ2h0ID0geTEgLSB5MDsKICAgICAgICAgICAgICAgICAgICAgICAgZ3JhcGhpY3MuY3R4LnJlY3QoeDAsIHkwLCBiYm94V2lkdGgsIGJib3hIZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBncmFwaGljcy5jdXJyZW50LnVwZGF0ZVJlY3RNaW5NYXgoKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKGdyYXBoaWNzLmN0eCksIFt4MCwgeTAsIHgxLCB5MV0pOwogICAgICAgICAgICAgICAgICAgICAgICBncmFwaGljcy5jbGlwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGdyYXBoaWNzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0RmlsbEFuZFN0cm9rZVN0eWxlVG9Db250ZXh0KGdyYXBoaWNzLCBwYWludFR5cGUsIGNvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRleHQgPSBncmFwaGljcy5jdHgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50ID0gZ3JhcGhpY3MuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChwYWludFR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgUGFpbnRUeXBlLkNPTE9SRUQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dC5maWxsU3R5bGUgPSBjdHguZmlsbFN0eWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQuc3Ryb2tlU3R5bGUgPSBjdHguc3Ryb2tlU3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5maWxsQ29sb3IgPSBjdHguZmlsbFN0eWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuc3Ryb2tlQ29sb3IgPSBjdHguc3Ryb2tlU3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFBhaW50VHlwZS5VTkNPTE9SRUQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3NzQ29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihjb2xvclswXSwgY29sb3JbMV0sIGNvbG9yWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZXh0LmZpbGxTdHlsZSA9IGNzc0NvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQuc3Ryb2tlU3R5bGUgPSBjc3NDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmZpbGxDb2xvciA9IGNzc0NvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuc3Ryb2tlQ29sb3IgPSBjc3NDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBVbnN1cHBvcnRlZCBwYWludCB0eXBlOiAke3BhaW50VHlwZX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYXR0ZXJuKGN0eCwgb3duZXIsIGludmVyc2UsIHBhdGhUeXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtYXRyaXggPSBpbnZlcnNlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGF0aFR5cGUgIT09IFBhdGhUeXBlLlNIQURJTkcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hdHJpeCA9IF91dGlsLlV0aWwudHJhbnNmb3JtKG1hdHJpeCwgb3duZXIuYmFzZVRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5tYXRyaXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXRyaXggPSBfdXRpbC5VdGlsLnRyYW5zZm9ybShtYXRyaXgsIHRoaXMubWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzID0gdGhpcy5jcmVhdGVQYXR0ZXJuQ2FudmFzKG93bmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRvbU1hdHJpeCA9IG5ldyBET01NYXRyaXgobWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgZG9tTWF0cml4ID0gZG9tTWF0cml4LnRyYW5zbGF0ZSh0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzLm9mZnNldFgsIHRlbXBvcmFyeVBhdHRlcm5DYW52YXMub2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRvbU1hdHJpeCA9IGRvbU1hdHJpeC5zY2FsZSgxIC8gdGVtcG9yYXJ5UGF0dGVybkNhbnZhcy5zY2FsZVgsIDEgLyB0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzLnNjYWxlWSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdHRlcm4gPSBjdHguY3JlYXRlUGF0dGVybih0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzLmNhbnZhcywgInJlcGVhdCIpOwogICAgICAgICAgICAgICAgICAgICAgICBwYXR0ZXJuLnNldFRyYW5zZm9ybShkb21NYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGF0dGVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlRpbGluZ1BhdHRlcm4gPSBUaWxpbmdQYXR0ZXJuOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNDggKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5jb252ZXJ0QmxhY2tBbmRXaGl0ZVRvUkdCQSA9IGNvbnZlcnRCbGFja0FuZFdoaXRlVG9SR0JBOwogICAgICAgICAgICAgICAgZXhwb3J0cy5jb252ZXJ0VG9SR0JBID0gY29udmVydFRvUkdCQTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuZ3JheVRvUkdCQSA9IGdyYXlUb1JHQkE7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29udmVydFRvUkdCQShwYXJhbXMpIHsKICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHBhcmFtcy5raW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuSW1hZ2VLaW5kLkdSQVlTQ0FMRV8xQlBQOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbnZlcnRCbGFja0FuZFdoaXRlVG9SR0JBKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuSW1hZ2VLaW5kLlJHQl8yNEJQUDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjb252ZXJ0UkdCVG9SR0JBKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29udmVydEJsYWNrQW5kV2hpdGVUb1JHQkEoX3JlZikgewogICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHNyYywKICAgICAgICAgICAgICAgICAgICAgICAgc3JjUG9zID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdCwKICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodCwKICAgICAgICAgICAgICAgICAgICAgICAgbm9uQmxhY2tDb2xvciA9IDB4ZmZmZmZmZmYsCiAgICAgICAgICAgICAgICAgICAgICAgIGludmVyc2VEZWNvZGUgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJsYWNrID0gX3V0aWwuRmVhdHVyZVRlc3QuaXNMaXR0bGVFbmRpYW4gPyAweGZmMDAwMDAwIDogMHgwMDAwMDBmZjsKICAgICAgICAgICAgICAgICAgICBjb25zdCBbemVyb01hcHBpbmcsIG9uZU1hcHBpbmddID0gaW52ZXJzZURlY29kZSA/IFtub25CbGFja0NvbG9yLCBibGFja10gOiBbYmxhY2ssIG5vbkJsYWNrQ29sb3JdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoSW5Tb3VyY2UgPSB3aWR0aCA+PiAzOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoUmVtYWluZGVyID0gd2lkdGggJiA3OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNyY0xlbmd0aCA9IHNyYy5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgZGVzdCA9IG5ldyBVaW50MzJBcnJheShkZXN0LmJ1ZmZlcik7CiAgICAgICAgICAgICAgICAgICAgbGV0IGRlc3RQb3MgPSAwOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgaGVpZ2h0OyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBtYXggPSBzcmNQb3MgKyB3aWR0aEluU291cmNlOyBzcmNQb3MgPCBtYXg7IHNyY1BvcysrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbGVtID0gc3JjUG9zIDwgc3JjTGVuZ3RoID8gc3JjW3NyY1Bvc10gOiAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMGIxMDAwMDAwMCA/IG9uZU1hcHBpbmcgOiB6ZXJvTWFwcGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcysrXSA9IGVsZW0gJiAwYjEwMDAwMDAgPyBvbmVNYXBwaW5nIDogemVyb01hcHBpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMGIxMDAwMDAgPyBvbmVNYXBwaW5nIDogemVyb01hcHBpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMGIxMDAwMCA/IG9uZU1hcHBpbmcgOiB6ZXJvTWFwcGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcysrXSA9IGVsZW0gJiAwYjEwMDAgPyBvbmVNYXBwaW5nIDogemVyb01hcHBpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMGIxMDAgPyBvbmVNYXBwaW5nIDogemVyb01hcHBpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMGIxMCA/IG9uZU1hcHBpbmcgOiB6ZXJvTWFwcGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcysrXSA9IGVsZW0gJiAwYjEgPyBvbmVNYXBwaW5nIDogemVyb01hcHBpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoUmVtYWluZGVyID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbGVtID0gc3JjUG9zIDwgc3JjTGVuZ3RoID8gc3JjW3NyY1BvcysrXSA6IDI1NTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCB3aWR0aFJlbWFpbmRlcjsgaisrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMSA8PCA3IC0gaiA/IG9uZU1hcHBpbmcgOiB6ZXJvTWFwcGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICBzcmNQb3MsCiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RQb3MKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29udmVydFJHQlRvUkdCQShfcmVmMikgewogICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHNyYywKICAgICAgICAgICAgICAgICAgICAgICAgc3JjUG9zID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdCwKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFBvcyA9IDAsCiAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgbGV0IGkgPSAwOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxlbjMyID0gc3JjLmxlbmd0aCA+PiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNyYzMyID0gbmV3IFVpbnQzMkFycmF5KHNyYy5idWZmZXIsIHNyY1BvcywgbGVuMzIpOwogICAgICAgICAgICAgICAgICAgIGlmIChfdXRpbC5GZWF0dXJlVGVzdC5pc0xpdHRsZUVuZGlhbikgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKDsgaSA8IGxlbjMyIC0gMjsgaSArPSAzLCBkZXN0UG9zICs9IDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHMxID0gc3JjMzJbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzMiA9IHNyYzMyW2kgKyAxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHMzID0gc3JjMzJbaSArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFtkZXN0UG9zXSA9IHMxIHwgMHhmZjAwMDAwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcyArIDFdID0gczEgPj4+IDI0IHwgczIgPDwgOCB8IDB4ZmYwMDAwMDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MgKyAyXSA9IHMyID4+PiAxNiB8IHMzIDw8IDE2IHwgMHhmZjAwMDAwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcyArIDNdID0gczMgPj4+IDggfCAweGZmMDAwMDAwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGogPSBpICogNCwgamogPSBzcmMubGVuZ3RoOyBqIDwgamo7IGogKz0gMykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFtkZXN0UG9zKytdID0gc3JjW2pdIHwgc3JjW2ogKyAxXSA8PCA4IHwgc3JjW2ogKyAyXSA8PCAxNiB8IDB4ZmYwMDAwMDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKDsgaSA8IGxlbjMyIC0gMjsgaSArPSAzLCBkZXN0UG9zICs9IDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHMxID0gc3JjMzJbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzMiA9IHNyYzMyW2kgKyAxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHMzID0gc3JjMzJbaSArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFtkZXN0UG9zXSA9IHMxIHwgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcyArIDFdID0gczEgPDwgMjQgfCBzMiA+Pj4gOCB8IDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MgKyAyXSA9IHMyIDw8IDE2IHwgczMgPj4+IDE2IHwgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcyArIDNdID0gczMgPDwgOCB8IDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaiA9IGkgKiA0LCBqaiA9IHNyYy5sZW5ndGg7IGogPCBqajsgaiArPSAzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBzcmNbal0gPDwgMjQgfCBzcmNbaiArIDFdIDw8IDE2IHwgc3JjW2ogKyAyXSA8PCA4IHwgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICBzcmNQb3MsCiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RQb3MKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ3JheVRvUkdCQShzcmMsIGRlc3QpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoX3V0aWwuRmVhdHVyZVRlc3QuaXNMaXR0bGVFbmRpYW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gc3JjLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbaV0gPSBzcmNbaV0gKiAweDEwMTAxIHwgMHhmZjAwMDAwMDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IHNyYy5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2ldID0gc3JjW2ldICogMHgxMDEwMTAwIHwgMHgwMDAwMDBmZjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQ5ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMpID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuR2xvYmFsV29ya2VyT3B0aW9ucyA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIGNvbnN0IEdsb2JhbFdvcmtlck9wdGlvbnMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5HbG9iYWxXb3JrZXJPcHRpb25zID0gR2xvYmFsV29ya2VyT3B0aW9uczsKICAgICAgICAgICAgICAgIEdsb2JhbFdvcmtlck9wdGlvbnMud29ya2VyUG9ydCA9IG51bGw7CiAgICAgICAgICAgICAgICBHbG9iYWxXb3JrZXJPcHRpb25zLndvcmtlclNyYyA9ICIiOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNTAgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5NZXNzYWdlSGFuZGxlciA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICBjb25zdCBDYWxsYmFja0tpbmQgPSB7CiAgICAgICAgICAgICAgICAgICAgVU5LTk9XTjogMCwKICAgICAgICAgICAgICAgICAgICBEQVRBOiAxLAogICAgICAgICAgICAgICAgICAgIEVSUk9SOiAyCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgY29uc3QgU3RyZWFtS2luZCA9IHsKICAgICAgICAgICAgICAgICAgICBVTktOT1dOOiAwLAogICAgICAgICAgICAgICAgICAgIENBTkNFTDogMSwKICAgICAgICAgICAgICAgICAgICBDQU5DRUxfQ09NUExFVEU6IDIsCiAgICAgICAgICAgICAgICAgICAgQ0xPU0U6IDMsCiAgICAgICAgICAgICAgICAgICAgRU5RVUVVRTogNCwKICAgICAgICAgICAgICAgICAgICBFUlJPUjogNSwKICAgICAgICAgICAgICAgICAgICBQVUxMOiA2LAogICAgICAgICAgICAgICAgICAgIFBVTExfQ09NUExFVEU6IDcsCiAgICAgICAgICAgICAgICAgICAgU1RBUlRfQ09NUExFVEU6IDgKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBmdW5jdGlvbiB3cmFwUmVhc29uKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgIGlmICghKHJlYXNvbiBpbnN0YW5jZW9mIEVycm9yIHx8IHR5cGVvZiByZWFzb24gPT09ICJvYmplY3QiICYmIHJlYXNvbiAhPT0gbnVsbCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgnd3JhcFJlYXNvbjogRXhwZWN0ZWQgInJlYXNvbiIgdG8gYmUgYSAocG9zc2libHkgY2xvbmVkKSBFcnJvci4nKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChyZWFzb24ubmFtZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJBYm9ydEV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF91dGlsLkFib3J0RXhjZXB0aW9uKHJlYXNvbi5tZXNzYWdlKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTWlzc2luZ1BERkV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF91dGlsLk1pc3NpbmdQREZFeGNlcHRpb24ocmVhc29uLm1lc3NhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJQYXNzd29yZEV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF91dGlsLlBhc3N3b3JkRXhjZXB0aW9uKHJlYXNvbi5tZXNzYWdlLCByZWFzb24uY29kZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF91dGlsLlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbihyZWFzb24ubWVzc2FnZSwgcmVhc29uLnN0YXR1cyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlVua25vd25FcnJvckV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF91dGlsLlVua25vd25FcnJvckV4Y2VwdGlvbihyZWFzb24ubWVzc2FnZSwgcmVhc29uLmRldGFpbHMpOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBfdXRpbC5Vbmtub3duRXJyb3JFeGNlcHRpb24ocmVhc29uLm1lc3NhZ2UsIHJlYXNvbi50b1N0cmluZygpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBNZXNzYWdlSGFuZGxlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc291cmNlTmFtZSwgdGFyZ2V0TmFtZSwgY29tT2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc291cmNlTmFtZSA9IHNvdXJjZU5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGFyZ2V0TmFtZSA9IHRhcmdldE5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tT2JqID0gY29tT2JqOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrSWQgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cmVhbUlkID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJlYW1TaW5rcyA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RyZWFtQ29udHJvbGxlcnMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrQ2FwYWJpbGl0aWVzID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hY3Rpb25IYW5kbGVyID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb25Db21PYmpPbk1lc3NhZ2UgPSBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gZXZlbnQuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnRhcmdldE5hbWUgIT09IHRoaXMuc291cmNlTmFtZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnN0cmVhbSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Byb2Nlc3NTdHJlYW1NZXNzYWdlKGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmNhbGxiYWNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FsbGJhY2tJZCA9IGRhdGEuY2FsbGJhY2tJZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYXBhYmlsaXR5ID0gdGhpcy5jYWxsYmFja0NhcGFiaWxpdGllc1tjYWxsYmFja0lkXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWNhcGFiaWxpdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBDYW5ub3QgcmVzb2x2ZSBjYWxsYmFjayAke2NhbGxiYWNrSWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSB0aGlzLmNhbGxiYWNrQ2FwYWJpbGl0aWVzW2NhbGxiYWNrSWRdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmNhbGxiYWNrID09PSBDYWxsYmFja0tpbmQuREFUQSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXBhYmlsaXR5LnJlc29sdmUoZGF0YS5kYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGRhdGEuY2FsbGJhY2sgPT09IENhbGxiYWNrS2luZC5FUlJPUikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXBhYmlsaXR5LnJlamVjdCh3cmFwUmVhc29uKGRhdGEucmVhc29uKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJVbmV4cGVjdGVkIGNhbGxiYWNrIGNhc2UiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWN0aW9uID0gdGhpcy5hY3Rpb25IYW5kbGVyW2RhdGEuYWN0aW9uXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghYWN0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBVbmtub3duIGFjdGlvbiBmcm9tIHdvcmtlcjogJHtkYXRhLmFjdGlvbn1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmNhbGxiYWNrSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYlNvdXJjZU5hbWUgPSB0aGlzLnNvdXJjZU5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2JUYXJnZXROYW1lID0gZGF0YS5zb3VyY2VOYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoYWN0aW9uKGRhdGEuZGF0YSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pLnRoZW4oZnVuY3Rpb24gKHJlc3VsdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZTogY2JTb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZTogY2JUYXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2s6IENhbGxiYWNrS2luZC5EQVRBLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2tJZDogZGF0YS5jYWxsYmFja0lkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YTogcmVzdWx0CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWU6IGNiU291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldE5hbWU6IGNiVGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrOiBDYWxsYmFja0tpbmQuRVJST1IsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFja0lkOiBkYXRhLmNhbGxiYWNrSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFzb246IHdyYXBSZWFzb24ocmVhc29uKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5zdHJlYW1JZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVN0cmVhbVNpbmsoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWN0aW9uKGRhdGEuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iai5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIiwgdGhpcy5fb25Db21PYmpPbk1lc3NhZ2UpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBvbihhY3Rpb25OYW1lLCBoYW5kbGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFoID0gdGhpcy5hY3Rpb25IYW5kbGVyOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWhbYWN0aW9uTmFtZV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVGhlcmUgaXMgYWxyZWFkeSBhbiBhY3Rpb25OYW1lIGNhbGxlZCAiJHthY3Rpb25OYW1lfSJgKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBhaFthY3Rpb25OYW1lXSA9IGhhbmRsZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNlbmQoYWN0aW9uTmFtZSwgZGF0YSwgdHJhbnNmZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWU6IHRoaXMuc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldE5hbWU6IHRoaXMudGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFjdGlvbjogYWN0aW9uTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEKICAgICAgICAgICAgICAgICAgICAgICAgfSwgdHJhbnNmZXJzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2VuZFdpdGhQcm9taXNlKGFjdGlvbk5hbWUsIGRhdGEsIHRyYW5zZmVycykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYWxsYmFja0lkID0gdGhpcy5jYWxsYmFja0lkKys7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FsbGJhY2tDYXBhYmlsaXRpZXNbY2FsbGJhY2tJZF0gPSBjYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWU6IHRoaXMuc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lOiB0aGlzLnRhcmdldE5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWN0aW9uOiBhY3Rpb25OYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgdHJhbnNmZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHkucmVqZWN0KGV4KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZW5kV2l0aFN0cmVhbShhY3Rpb25OYW1lLCBkYXRhLCBxdWV1ZWluZ1N0cmF0ZWd5LCB0cmFuc2ZlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RyZWFtSWQgPSB0aGlzLnN0cmVhbUlkKyssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lID0gdGhpcy5zb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSA9IHRoaXMudGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iaiA9IHRoaXMuY29tT2JqOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFJlYWRhYmxlU3RyZWFtKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0OiBjb250cm9sbGVyID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGFydENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJlYW1Db250cm9sbGVyc1tzdHJlYW1JZF0gPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRyb2xsZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0Q2FsbDogc3RhcnRDYXBhYmlsaXR5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdWxsQ2FsbDogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FuY2VsQ2FsbDogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNDbG9zZWQ6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY3Rpb246IGFjdGlvbk5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXNpcmVkU2l6ZTogY29udHJvbGxlci5kZXNpcmVkU2l6ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIHRyYW5zZmVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN0YXJ0Q2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1bGw6IGNvbnRyb2xsZXIgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHB1bGxDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RyZWFtQ29udHJvbGxlcnNbc3RyZWFtSWRdLnB1bGxDYWxsID0gcHVsbENhcGFiaWxpdHk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLlBVTEwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXNpcmVkU2l6ZTogY29udHJvbGxlci5kZXNpcmVkU2l6ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwdWxsQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbmNlbDogcmVhc29uID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KShyZWFzb24gaW5zdGFuY2VvZiBFcnJvciwgImNhbmNlbCBtdXN0IGhhdmUgYSB2YWxpZCByZWFzb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW5jZWxDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RyZWFtQ29udHJvbGxlcnNbc3RyZWFtSWRdLmNhbmNlbENhbGwgPSBjYW5jZWxDYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RyZWFtQ29udHJvbGxlcnNbc3RyZWFtSWRdLmlzQ2xvc2VkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuQ0FOQ0VMLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uOiB3cmFwUmVhc29uKHJlYXNvbikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FuY2VsQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9LCBxdWV1ZWluZ1N0cmF0ZWd5KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NyZWF0ZVN0cmVhbVNpbmsoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdHJlYW1JZCA9IGRhdGEuc3RyZWFtSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lID0gdGhpcy5zb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSA9IGRhdGEuc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iaiA9IHRoaXMuY29tT2JqOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzZWxmID0gdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFjdGlvbiA9IHRoaXMuYWN0aW9uSGFuZGxlcltkYXRhLmFjdGlvbl07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0cmVhbVNpbmsgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnF1ZXVlKGNodW5rKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNpemUgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRyYW5zZmVycyA9IGFyZ3VtZW50cy5sZW5ndGggPiAyID8gYXJndW1lbnRzWzJdIDogdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGFzdERlc2lyZWRTaXplID0gdGhpcy5kZXNpcmVkU2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc2lyZWRTaXplIC09IHNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxhc3REZXNpcmVkU2l6ZSA+IDAgJiYgdGhpcy5kZXNpcmVkU2l6ZSA8PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2lua0NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVhZHkgPSB0aGlzLnNpbmtDYXBhYmlsaXR5LnByb21pc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldE5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5FTlFVRVVFLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCB0cmFuc2ZlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb3NlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc0NhbmNlbGxlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLkNMT1NFLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBzZWxmLnN0cmVhbVNpbmtzW3N0cmVhbUlkXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnJvcihyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KShyZWFzb24gaW5zdGFuY2VvZiBFcnJvciwgImVycm9yIG11c3QgaGF2ZSBhIHZhbGlkIHJlYXNvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc0NhbmNlbGxlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLkVSUk9SLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uOiB3cmFwUmVhc29uKHJlYXNvbikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW5rQ2FwYWJpbGl0eTogKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb25QdWxsOiBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb25DYW5jZWw6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0NhbmNlbGxlZDogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXNpcmVkU2l6ZTogZGF0YS5kZXNpcmVkU2l6ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWR5OiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbVNpbmsuc2lua0NhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1TaW5rLnJlYWR5ID0gc3RyZWFtU2luay5zaW5rQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cmVhbVNpbmtzW3N0cmVhbUlkXSA9IHN0cmVhbVNpbms7CiAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKGFjdGlvbihkYXRhLmRhdGEsIHN0cmVhbVNpbmspKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSkudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuU1RBUlRfQ09NUExFVEUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3VjY2VzczogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5TVEFSVF9DT01QTEVURSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFzb246IHdyYXBSZWFzb24ocmVhc29uKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfcHJvY2Vzc1N0cmVhbU1lc3NhZ2UoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdHJlYW1JZCA9IGRhdGEuc3RyZWFtSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lID0gdGhpcy5zb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSA9IGRhdGEuc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iaiA9IHRoaXMuY29tT2JqOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdHJlYW1Db250cm9sbGVyID0gdGhpcy5zdHJlYW1Db250cm9sbGVyc1tzdHJlYW1JZF0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1TaW5rID0gdGhpcy5zdHJlYW1TaW5rc1tzdHJlYW1JZF07CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZGF0YS5zdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgU3RyZWFtS2luZC5TVEFSVF9DT01QTEVURToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5zdWNjZXNzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUNvbnRyb2xsZXIuc3RhcnRDYWxsLnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1Db250cm9sbGVyLnN0YXJ0Q2FsbC5yZWplY3Qod3JhcFJlYXNvbihkYXRhLnJlYXNvbikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgU3RyZWFtS2luZC5QVUxMX0NPTVBMRVRFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnN1Y2Nlc3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtQ29udHJvbGxlci5wdWxsQ2FsbC5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtQ29udHJvbGxlci5wdWxsQ2FsbC5yZWplY3Qod3JhcFJlYXNvbihkYXRhLnJlYXNvbikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgU3RyZWFtS2luZC5QVUxMOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc3RyZWFtU2luaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldE5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuUFVMTF9DT01QTEVURSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3VjY2VzczogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdHJlYW1TaW5rLmRlc2lyZWRTaXplIDw9IDAgJiYgZGF0YS5kZXNpcmVkU2l6ZSA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtU2luay5zaW5rQ2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbVNpbmsuZGVzaXJlZFNpemUgPSBkYXRhLmRlc2lyZWRTaXplOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoc3RyZWFtU2luay5vblB1bGwgJiYgc3RyZWFtU2luay5vblB1bGwoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSkudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5QVUxMX0NPTVBMRVRFLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWNjZXNzOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLlBVTExfQ09NUExFVEUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbjogd3JhcFJlYXNvbihyZWFzb24pCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBTdHJlYW1LaW5kLkVOUVVFVUU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmFzc2VydCkoc3RyZWFtQ29udHJvbGxlciwgImVucXVldWUgc2hvdWxkIGhhdmUgc3RyZWFtIGNvbnRyb2xsZXIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RyZWFtQ29udHJvbGxlci5pc0Nsb3NlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtQ29udHJvbGxlci5jb250cm9sbGVyLmVucXVldWUoZGF0YS5jaHVuayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFN0cmVhbUtpbmQuQ0xPU0U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmFzc2VydCkoc3RyZWFtQ29udHJvbGxlciwgImNsb3NlIHNob3VsZCBoYXZlIHN0cmVhbSBjb250cm9sbGVyIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0cmVhbUNvbnRyb2xsZXIuaXNDbG9zZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUNvbnRyb2xsZXIuaXNDbG9zZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUNvbnRyb2xsZXIuY29udHJvbGxlci5jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RlbGV0ZVN0cmVhbUNvbnRyb2xsZXIoc3RyZWFtQ29udHJvbGxlciwgc3RyZWFtSWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBTdHJlYW1LaW5kLkVSUk9SOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHN0cmVhbUNvbnRyb2xsZXIsICJlcnJvciBzaG91bGQgaGF2ZSBzdHJlYW0gY29udHJvbGxlciIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUNvbnRyb2xsZXIuY29udHJvbGxlci5lcnJvcih3cmFwUmVhc29uKGRhdGEucmVhc29uKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGVsZXRlU3RyZWFtQ29udHJvbGxlcihzdHJlYW1Db250cm9sbGVyLCBzdHJlYW1JZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFN0cmVhbUtpbmQuQ0FOQ0VMX0NPTVBMRVRFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnN1Y2Nlc3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtQ29udHJvbGxlci5jYW5jZWxDYWxsLnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1Db250cm9sbGVyLmNhbmNlbENhbGwucmVqZWN0KHdyYXBSZWFzb24oZGF0YS5yZWFzb24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGVsZXRlU3RyZWFtQ29udHJvbGxlcihzdHJlYW1Db250cm9sbGVyLCBzdHJlYW1JZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFN0cmVhbUtpbmQuQ0FOQ0VMOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc3RyZWFtU2luaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZShzdHJlYW1TaW5rLm9uQ2FuY2VsICYmIHN0cmVhbVNpbmsub25DYW5jZWwod3JhcFJlYXNvbihkYXRhLnJlYXNvbikpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLkNBTkNFTF9DT01QTEVURSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3VjY2VzczogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5DQU5DRUxfQ09NUExFVEUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbjogd3JhcFJlYXNvbihyZWFzb24pCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbVNpbmsuc2lua0NhcGFiaWxpdHkucmVqZWN0KHdyYXBSZWFzb24oZGF0YS5yZWFzb24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1TaW5rLmlzQ2FuY2VsbGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5zdHJlYW1TaW5rc1tzdHJlYW1JZF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiVW5leHBlY3RlZCBzdHJlYW0gY2FzZSIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFzeW5jIF9kZWxldGVTdHJlYW1Db250cm9sbGVyKHN0cmVhbUNvbnRyb2xsZXIsIHN0cmVhbUlkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGF3YWl0IFByb21pc2UuYWxsU2V0dGxlZChbc3RyZWFtQ29udHJvbGxlci5zdGFydENhbGwgJiYgc3RyZWFtQ29udHJvbGxlci5zdGFydENhbGwucHJvbWlzZSwgc3RyZWFtQ29udHJvbGxlci5wdWxsQ2FsbCAmJiBzdHJlYW1Db250cm9sbGVyLnB1bGxDYWxsLnByb21pc2UsIHN0cmVhbUNvbnRyb2xsZXIuY2FuY2VsQ2FsbCAmJiBzdHJlYW1Db250cm9sbGVyLmNhbmNlbENhbGwucHJvbWlzZV0pOwogICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5zdHJlYW1Db250cm9sbGVyc1tzdHJlYW1JZF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlc3Ryb3koKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tT2JqLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLCB0aGlzLl9vbkNvbU9iak9uTWVzc2FnZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5NZXNzYWdlSGFuZGxlciA9IE1lc3NhZ2VIYW5kbGVyOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNTEgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5NZXRhZGF0YSA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICBjbGFzcyBNZXRhZGF0YSB7CiAgICAgICAgICAgICAgICAgICAgI21ldGFkYXRhTWFwOwogICAgICAgICAgICAgICAgICAgICNkYXRhOwogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcnNlZERhdGEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByYXdEYXRhCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNtZXRhZGF0YU1hcCA9IHBhcnNlZERhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2RhdGEgPSByYXdEYXRhOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSYXcoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLiNkYXRhOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQobmFtZSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy4jbWV0YWRhdGFNYXAuZ2V0KG5hbWUpID8/IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFsbCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5vYmplY3RGcm9tTWFwKSh0aGlzLiNtZXRhZGF0YU1hcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhcyhuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLiNtZXRhZGF0YU1hcC5oYXMobmFtZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5NZXRhZGF0YSA9IE1ldGFkYXRhOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNTIgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5PcHRpb25hbENvbnRlbnRDb25maWcgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9tdXJtdXJoYXNoID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDQpOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKG9iaiwgcHJpdmF0ZVNldCkgeyBfY2hlY2tQcml2YXRlUmVkZWNsYXJhdGlvbihvYmosIHByaXZhdGVTZXQpOyBwcml2YXRlU2V0LmFkZChvYmopOyB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyhvYmosIHByaXZhdGVNYXAsIHZhbHVlKSB7IF9jaGVja1ByaXZhdGVSZWRlY2xhcmF0aW9uKG9iaiwgcHJpdmF0ZU1hcCk7IHByaXZhdGVNYXAuc2V0KG9iaiwgdmFsdWUpOyB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2hlY2tQcml2YXRlUmVkZWNsYXJhd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aW50ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmFtZSA9IG5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaW50ZW50ID0gaW50ZW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgdmlzaWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI3Zpc2libGU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zZXRWaXNpYmxlKGludGVybmFsLCB2aXNpYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlcm5hbCAhPT0gSU5URVJOQUwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkludGVybmFsIG1ldGhvZCBgX3NldFZpc2libGVgIGNhbGxlZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiN2aXNpYmxlID0gdmlzaWJsZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB2YXIgX2NhY2hlZEdldEhhc2ggPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfZ3JvdXBzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2luaXRpYWxIYXNoID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX29yZGVyID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24gPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIE9wdGlvbmFsQ29udGVudENvbmZpZyB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY2FjaGVkR2V0SGFzaCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2dyb3VwcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbmV3IE1hcCgpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfaW5pdGlhbEhhc2gsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9vcmRlciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5uYW1lID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jcmVhdG9yID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hbWUgPSBkYXRhLm5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3JlYXRvciA9IGRhdGEuY3JlYXRvcjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9vcmRlciwgZGF0YS5vcmRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZ3JvdXAgb2YgZGF0YS5ncm91cHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5zZXQoZ3JvdXAuaWQsIG5ldyBPcHRpb25hbENvbnRlbnRHcm91cChncm91cC5uYW1lLCBncm91cC5pbnRlbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5iYXNlU3RhdGUgPT09ICJPRkYiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGdyb3VwIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyb3VwLl9zZXRWaXNpYmxlKElOVEVSTkFMLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvbiBvZiBkYXRhLm9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuZ2V0KG9uKS5fc2V0VmlzaWJsZShJTlRFUk5BTCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvZmYgb2YgZGF0YS5vZmYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQob2ZmKS5fc2V0VmlzaWJsZShJTlRFUk5BTCwgZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaW5pdGlhbEhhc2gsIHRoaXMuZ2V0SGFzaCgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNWaXNpYmxlKGdyb3VwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3Vwcykuc2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFncm91cCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJPcHRpb25hbCBjb250ZW50IGdyb3VwIG5vdCBkZWZpbmVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLnR5cGUgPT09ICJPQ0ciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5oYXMoZ3JvdXAuaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBPcHRpb25hbCBjb250ZW50IGdyb3VwIG5vdCBmb3VuZDogJHtncm91cC5pZH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuZ2V0KGdyb3VwLmlkKS52aXNpYmxlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGdyb3VwLnR5cGUgPT09ICJPQ01EIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLmV4cHJlc3Npb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZXZhbHVhdGVWaXNpYmlsaXR5RXhwcmVzc2lvbiwgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24yKS5jYWxsKHRoaXMsIGdyb3VwLmV4cHJlc3Npb24pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFncm91cC5wb2xpY3kgfHwgZ3JvdXAucG9saWN5ID09PSAiQW55T24iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBpZCBvZiBncm91cC5pZHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuaGFzKGlkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBPcHRpb25hbCBjb250ZW50IGdyb3VwIG5vdCBmb3VuZDogJHtpZH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuZ2V0KGlkKS52aXNpYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGdyb3VwLnBvbGljeSA9PT0gIkFsbE9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaWQgb2YgZ3JvdXAuaWRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpLnZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZ3JvdXAucG9saWN5ID09PSAiQW55T2ZmIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaWQgb2YgZ3JvdXAuaWRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpLnZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZ3JvdXAucG9saWN5ID09PSAiQWxsT2ZmIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaWQgb2YgZ3JvdXAuaWRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmdldChpZCkudmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBVbmtub3duIG9wdGlvbmFsIGNvbnRlbnQgcG9saWN5ICR7Z3JvdXAucG9saWN5fS5gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgVW5rbm93biBncm91cCB0eXBlICR7Z3JvdXAudHlwZX0uYCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRWaXNpYmlsaXR5KGlkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2aXNpYmxlID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5oYXMoaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYE9wdGlvbmFsIGNvbnRlbnQgZ3JvdXAgbm90IGZvdW5kOiAke2lkfWApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpLl9zZXRWaXNpYmxlKElOVEVSTkFMLCAhIXZpc2libGUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2NhY2hlZEdldEhhc2gsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaGFzSW5pdGlhbFZpc2liaWxpdHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmdldEhhc2goKSA9PT0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pbml0aWFsSGFzaCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE9yZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5zaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vcmRlcikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX29yZGVyKS5zbGljZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbLi4uX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmtleXMoKV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEdyb3VwcygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5zaXplID4gMCA/ICgwLCBfdXRpbC5vYmplY3RGcm9tTWFwKShfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykpIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0R3JvdXAoaWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpIHx8IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEhhc2goKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlZEdldEhhc2gpICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jYWNoZWRHZXRIYXNoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoYXNoID0gbmV3IF9tdXJtdXJoYXNoLk11cm11ckhhc2gzXzY0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2lkLCBncm91cF0gb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNoLnVwZGF0ZShgJHtpZH06JHtncm91cC52aXNpYmxlfWApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2NhY2hlZEdldEhhc2gsIGhhc2guaGV4ZGlnZXN0KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuT3B0aW9uYWxDb250ZW50Q29uZmlnID0gT3B0aW9uYWxDb250ZW50Q29uZmlnOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24yKGFycmF5KSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuZ3RoID0gYXJyYXkubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGlmIChsZW5ndGggPCAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBvcGVyYXRvciA9IGFycmF5WzBdOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAxOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudCA9IGFycmF5W2ldOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc3RhdGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGVsZW1lbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZSA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24sIF9ldmFsdWF0ZVZpc2liaWxpdHlFeHByZXNzaW9uMikuY2FsbCh0aGlzLCBlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuaGFzKGVsZW1lbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoZWxlbWVudCkudmlzaWJsZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7ZWxlbWVudH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAob3BlcmF0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkFuZCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiT3IiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJOb3QiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhc3RhdGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBvcGVyYXRvciA9PT0gIkFuZCI7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE1MyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkRhdGFUcmFuc3BvcnRTdHJlYW0gPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwbGF5X3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDIpOwogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0YVRyYW5zcG9ydFN0cmVhbSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoX3JlZiwgcGRmRGF0YVJhbmdlVHJhbnNwb3J0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbml0aWFsRGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb2dyZXNzaXZlRG9uZSA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudERpc3Bvc2l0aW9uRmlsZW5hbWUgPSBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZVJhbmdlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlU3RyZWFtID0gZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWY7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHBkZkRhdGFSYW5nZVRyYW5zcG9ydCwgJ1BERkRhdGFUcmFuc3BvcnRTdHJlYW0gLSBtaXNzaW5nIHJlcXVpcmVkICJwZGZEYXRhUmFuZ2VUcmFuc3BvcnQiIGFyZ3VtZW50LicpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9xdWV1ZWRDaHVua3MgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcHJvZ3Jlc3NpdmVEb25lID0gcHJvZ3Jlc3NpdmVEb25lOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZW50RGlzcG9zaXRpb25GaWxlbmFtZSA9IGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoKGluaXRpYWxEYXRhID09PSBudWxsIHx8IGluaXRpYWxEYXRhID09PSB2b2lkIDAgPyB2b2lkIDAgOiBpbml0aWFsRGF0YS5sZW5ndGgpID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnVmZmVyID0gaW5pdGlhbERhdGEgaW5zdGFuY2VvZiBVaW50OEFycmF5ICYmIGluaXRpYWxEYXRhLmJ5dGVMZW5ndGggPT09IGluaXRpYWxEYXRhLmJ1ZmZlci5ieXRlTGVuZ3RoID8gaW5pdGlhbERhdGEuYnVmZmVyIDogbmV3IFVpbnQ4QXJyYXkoaW5pdGlhbERhdGEpLmJ1ZmZlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rcy5wdXNoKGJ1ZmZlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0ID0gcGRmRGF0YVJhbmdlVHJhbnNwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZCA9ICFkaXNhYmxlU3RyZWFtOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1JhbmdlU3VwcG9ydGVkID0gIWRpc2FibGVSYW5nZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGVudExlbmd0aCA9IGxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZVJlYWRlcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0LmFkZFJhbmdlTGlzdGVuZXIoKGJlZ2luLCBjaHVuaykgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb25SZWNlaXZlRGF0YSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmVnaW4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0LmFkZFByb2dyZXNzTGlzdGVuZXIoKGxvYWRlZCwgdG90YWwpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX29uUHJvZ3Jlc3MoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRlZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b3RhbAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQuYWRkUHJvZ3Jlc3NpdmVSZWFkTGlzdGVuZXIoY2h1bmsgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb25SZWNlaXZlRGF0YSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0LmFkZFByb2dyZXNzaXZlRG9uZUxpc3RlbmVyKCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX29uUHJvZ3Jlc3NpdmVEb25lKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQudHJhbnNwb3J0UmVhZHkoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX29uUmVjZWl2ZURhdGEoX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlZ2luLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYyOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBjaHVuayBpbnN0YW5jZW9mIFVpbnQ4QXJyYXkgJiYgY2h1bmsuYnl0ZUxlbmd0aCA9PT0gY2h1bmsuYnVmZmVyLmJ5dGVMZW5ndGggPyBjaHVuay5idWZmZXIgOiBuZXcgVWludDhBcnJheShjaHVuaykuYnVmZmVyOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmVnaW4gPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIuX2VucXVldWUoYnVmZmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmtzLnB1c2goYnVmZmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvdW5kID0gdGhpcy5fcmFuZ2VSZWFkZXJzLnNvbWUoZnVuY3Rpb24gKHJhbmdlUmVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJhbmdlUmVhZGVyLl9iZWdpbiAhPT0gYmVnaW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYW5nZVJlYWRlci5fZW5xdWV1ZShidWZmZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KShmb3VuZCwgIl9vblJlY2VpdmVEYXRhIC0gbm8gYFBERkRhdGFUcmFuc3BvcnRTdHJlYW1SYW5nZVJlYWRlcmAgaW5zdGFuY2UgZm91bmQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IF9wcm9ncmVzc2l2ZURhdGFMZW5ndGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWE7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoKF90aGlzJF9mdWxsUmVxdWVzdFJlYSA9IHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSA9PT0gbnVsbCB8fCBfdGhpcyRfZnVsbFJlcXVlc3RSZWEgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYS5fbG9hZGVkKSA/PyAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25Qcm9ncmVzcyhldnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2dC50b3RhbCA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3JhbmdlUmVhZGVycyQsIF90aGlzJF9yYW5nZVJlYWRlcnMkJDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfcmFuZ2VSZWFkZXJzJCA9IHRoaXMuX3JhbmdlUmVhZGVyc1swXSkgPT09IG51bGwgfHwgX3RoaXMkX3JhbmdlUmVhZGVycyQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IChfdGhpcyRfcmFuZ2VSZWFkZXJzJCQgPSBfdGhpcyRfcmFuZ2VSZWFkZXJzJC5vblByb2dyZXNzKSA9PT0gbnVsbCB8fCBfdGhpcyRfcmFuZ2VSZWFkZXJzJCQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9yYW5nZVJlYWRlcnMkJC5jYWxsKF90aGlzJF9yYW5nZVJlYWRlcnMkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBldnQubG9hZGVkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLCBfdGhpcyRfZnVsbFJlcXVlc3RSZWEzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9mdWxsUmVxdWVzdFJlYTIgPSB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogKF90aGlzJF9mdWxsUmVxdWVzdFJlYTMgPSBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVxdWVzdFJlYTMgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYTMuY2FsbChfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBldnQubG9hZGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsOiBldnQudG90YWwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9vblByb2dyZXNzaXZlRG9uZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9mdWxsUmVxdWVzdFJlYTQ7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfZnVsbFJlcXVlc3RSZWE0ID0gdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVxdWVzdFJlYTQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYTQucHJvZ3Jlc3NpdmVEb25lKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Byb2dyZXNzaXZlRG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9yZW1vdmVSYW5nZVJlYWRlcihyZWFkZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaSA9IHRoaXMuX3JhbmdlUmVhZGVycy5pbmRleE9mKHJlYWRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpID49IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlUmVhZGVycy5zcGxpY2UoaSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RnVsbFJlYWRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmFzc2VydCkoIXRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyLCAiUERGRGF0YVRyYW5zcG9ydFN0cmVhbS5nZXRGdWxsUmVhZGVyIGNhbiBvbmx5IGJlIGNhbGxlZCBvbmNlLiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBxdWV1ZWRDaHVua3MgPSB0aGlzLl9xdWV1ZWRDaHVua3M7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJlYWRlcih0aGlzLCBxdWV1ZWRDaHVua3MsIHRoaXMuX3Byb2dyZXNzaXZlRG9uZSwgdGhpcy5fY29udGVudERpc3Bvc2l0aW9uRmlsZW5hbWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSYW5nZVJlYWRlcihiZWdpbiwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbmQgPD0gdGhpcy5fcHJvZ3Jlc3NpdmVEYXRhTGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWFkZXIgPSBuZXcgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJhbmdlUmVhZGVyKHRoaXMsIGJlZ2luLCBlbmQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQucmVxdWVzdERhdGFSYW5nZShiZWdpbiwgZW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VSZWFkZXJzLnB1c2gocmVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlYWRlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsQWxsUmVxdWVzdHMocmVhc29uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWE1OwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhNSA9IHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSA9PT0gbnVsbCB8fCBfdGhpcyRfZnVsbFJlcXVlc3RSZWE1ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlcXVlc3RSZWE1LmNhbmNlbChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlYWRlciBvZiB0aGlzLl9yYW5nZVJlYWRlcnMuc2xpY2UoMCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRlci5jYW5jZWwocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQuYWJvcnQoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkRhdGFUcmFuc3BvcnRTdHJlYW0gPSBQREZEYXRhVHJhbnNwb3J0U3RyZWFtOwogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJlYWRlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc3RyZWFtLCBxdWV1ZWRDaHVua3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHByb2dyZXNzaXZlRG9uZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjb250ZW50RGlzcG9zaXRpb25GaWxlbmFtZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAzICYmIGFyZ3VtZW50c1szXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzNdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RyZWFtID0gc3RyZWFtOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gcHJvZ3Jlc3NpdmVEb25lIHx8IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9maWxlbmFtZSA9ICgwLCBfZGlzcGxheV91dGlscy5pc1BkZkZpbGUpKGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lKSA/IGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmtzID0gcXVldWVkQ2h1bmtzIHx8IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZWQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGNodW5rIG9mIHRoaXMuX3F1ZXVlZENodW5rcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVkICs9IGNodW5rLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc1JlYWR5ID0gUHJvbWlzZS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbS5fZnVsbFJlcXVlc3RSZWFkZXIgPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZW5xdWV1ZShjaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSA9IHRoaXMuX3JlcXVlc3RzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0Q2FwYWJpbGl0eS5yZXNvbHZlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogY2h1bmssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmtzLnB1c2goY2h1bmspOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlZCArPSBjaHVuay5ieXRlTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaGVhZGVyc1JlYWR5KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5faGVhZGVyc1JlYWR5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgZmlsZW5hbWUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9maWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGlzUmFuZ2VTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9zdHJlYW0uX2lzUmFuZ2VTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3N0cmVhbS5faXNTdHJlYW1pbmdTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBjb250ZW50TGVuZ3RoKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fc3RyZWFtLl9jb250ZW50TGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcXVldWVkQ2h1bmtzLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gdGhpcy5fcXVldWVkQ2h1bmtzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLnB1c2gocmVxdWVzdENhcGFiaWxpdHkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwcm9ncmVzc2l2ZURvbmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9kb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJhbmdlUmVhZGVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzdHJlYW0sIGJlZ2luLCBlbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RyZWFtID0gc3RyZWFtOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9iZWdpbiA9IGJlZ2luOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbmQgPSBlbmQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZW5xdWV1ZShjaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rID0gY2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0c0NhcGFiaWxpdHkgPSB0aGlzLl9yZXF1ZXN0cy5zaGlmdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdHNDYXBhYmlsaXR5LnJlc29sdmUoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlcXVlc3RDYXBhYmlsaXR5IG9mIHRoaXMuX3JlcXVlc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB1bmRlZmluZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3N0cmVhbS5fcmVtb3ZlUmFuZ2VSZWFkZXIodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcXVldWVkQ2h1bmspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gdGhpcy5fcXVldWVkQ2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9xdWV1ZWRDaHVuayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLnB1c2gocmVxdWVzdENhcGFiaWxpdHkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdHJlYW0uX3JlbW92ZVJhbmdlUmVhZGVyKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTU0ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMpID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuWGZhVGV4dCA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIGNsYXNzIFhmYVRleHQgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB0ZXh0Q29udGVudCh4ZmEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXRlbXMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3V0cHV0ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZXM6IE9iamVjdC5jcmVhdGUobnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gd2Fsayhub2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX25vZGUkYXR0cmlidXRlczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghbm9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdHIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbmFtZSA9IG5vZGUubmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuYW1lID09PSAiI3RleHQiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyID0gbm9kZS52YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIVhmYVRleHQuc2hvdWxkQnVpbGRUZXh0KG5hbWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChub2RlICE9PSBudWxsICYmIG5vZGUgIT09IHZvaWQgMCAmJiAoX25vZGUkYXR0cmlidXRlcyA9IG5vZGUuYXR0cmlidXRlcykgIT09IG51bGwgJiYgX25vZGUkYXR0cmlidXRlcyAhPT0gdm9pZCAwICYmIF9ub2RlJGF0dHJpYnV0ZXMudGV4dENvbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIgPSBub2RlLmF0dHJpYnV0ZXMudGV4dENvbnRlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG5vZGUudmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIgPSBub2RlLnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0ciAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zLnB1c2goewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghbm9kZS5jaGlsZHJlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgY2hpbGQgb2Ygbm9kZS5jaGlsZHJlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdhbGsoY2hpbGQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHdhbGsoeGZhKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG91dHB1dDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHNob3VsZEJ1aWxkVGV4dChuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhKG5hbWUgPT09ICJ0ZXh0YXJlYSIgfHwgbmFtZSA9PT0gImlucHV0IiB8fCBuYW1lID09PSAib3B0aW9uIiB8fCBuYW1lID09PSAic2VsZWN0Iik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5YZmFUZXh0ID0gWGZhVGV4dDsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTU1ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuTm9kZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gZXhwb3J0cy5Ob2RlRmlsdGVyRmFjdG9yeSA9IGV4cG9ydHMuTm9kZUNhbnZhc0ZhY3RvcnkgPSBleHBvcnRzLk5vZGVDTWFwUmVhZGVyRmFjdG9yeSA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfYmFzZV9mYWN0b3J5ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDMpOwogICAgICAgICAgICAgICAgOwogICAgICAgICAgICAgICAgY29uc3QgZmV0Y2hEYXRhID0gZnVuY3Rpb24gKHVybCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZzID0gcmVxdWlyZSgiZnMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgZnMucmVhZEZpbGUodXJsLCAoZXJyb3IsIGRhdGEpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnJvciB8fCAhZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlamVjdChuZXcgRXJyb3IoZXJyb3IpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKG5ldyBVaW50OEFycmF5KGRhdGEpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgY2xhc3MgTm9kZUZpbHRlckZhY3RvcnkgZXh0ZW5kcyBfYmFzZV9mYWN0b3J5LkJhc2VGaWx0ZXJGYWN0b3J5IHt9CiAgICAgICAgICAgICAgICBleHBvcnRzLk5vZGVGaWx0ZXJGYWN0b3J5ID0gTm9kZUZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBOb2RlQ2FudmFzRmFjdG9yeSBleHRlbmRzIF9iYXNlX2ZhY3RvcnkuQmFzZUNhbnZhc0ZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIF9jcmVhdGVDYW52YXMod2lkdGgsIGhlaWdodCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDYW52YXMgPSByZXF1aXJlKCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIENhbnZhcy5jcmVhdGVDYW52YXMod2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Ob2RlQ2FudmFzRmFjdG9yeSA9IE5vZGVDYW52YXNGYWN0b3J5OwogICAgICAgICAgICAgICAgY2xhc3MgTm9kZUNNYXBSZWFkZXJGYWN0b3J5IGV4dGVuZHMgX2Jhc2VfZmFjdG9yeS5CYXNlQ01hcFJlYWRlckZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIF9mZXRjaERhdGEodXJsLCBjb21wcmVzc2lvblR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZldGNoRGF0YSh1cmwpLnRoZW4oZGF0YSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNNYXBEYXRhOiBkYXRhLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbXByZXNzaW9uVHlwZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Ob2RlQ01hcFJlYWRlckZhY3RvcnkgPSBOb2RlQ01hcFJlYWRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBOb2RlU3RhbmRhcmRGb250RGF0YUZhY3RvcnkgZXh0ZW5kcyBfYmFzZV9mYWN0b3J5LkJhc2VTdGFuZGFyZEZvbnREYXRhRmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgX2ZldGNoRGF0YSh1cmwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZldGNoRGF0YSh1cmwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuTm9kZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gTm9kZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNTYgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZOb2RlU3RyZWFtID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfbmV0d29ya191dGlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTU3KTsKICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGNvbnN0IGZzID0gcmVxdWlyZSgiZnMiKTsKICAgICAgICAgICAgICAgIGNvbnN0IGh0dHAgPSByZXF1aXJlKCJodHRwIik7CiAgICAgICAgICAgICAgICBjb25zdCBodHRwcyA9IHJlcXVpcmUoImh0dHBzIik7CiAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSByZXF1aXJlKCJ1cmwiKTsKICAgICAgICAgICAgICAgIGNvbnN0IGZpbGVVcmlSZWdleCA9IC9eZmlsZTpcL1wvXC9bYS16QS1aXTpcLy87CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBwYXJzZVVybChzb3VyY2VVcmwpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJzZWRVcmwgPSB1cmwucGFyc2Uoc291cmNlVXJsKTsKICAgICAgICAgICAgICAgICAgICBpZiAocGFyc2VkVXJsLnByb3RvY29sID09PSAiZmlsZToiIHx8IHBhcnNlZFVybC5ob3N0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZWRVcmw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICgvXlthLXpdOlsvXFxdL2kudGVzdChzb3VyY2VVcmwpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1cmwucGFyc2UoYGZpbGU6Ly8vJHtzb3VyY2VVcmx9YCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghcGFyc2VkVXJsLmhvc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcGFyc2VkVXJsLnByb3RvY29sID0gImZpbGU6IjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlZFVybDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBERk5vZGVTdHJlYW0gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNvdXJjZSA9IHNvdXJjZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51cmwgPSBwYXJzZVVybChzb3VyY2UudXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc0h0dHAgPSB0aGlzLnVybC5wcm90b2NvbCA9PT0gImh0dHA6IiB8fCB0aGlzLnVybC5wcm90b2NvbCA9PT0gImh0dHBzOiI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNGc1VybCA9IHRoaXMudXJsLnByb3RvY29sID09PSAiZmlsZToiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmh0dHBIZWFkZXJzID0gdGhpcy5pc0h0dHAgJiYgc291cmNlLmh0dHBIZWFkZXJzIHx8IHt9OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlUmVxdWVzdFJlYWRlcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IF9wcm9ncmVzc2l2ZURhdGFMZW5ndGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWE7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoKF90aGlzJF9mdWxsUmVxdWVzdFJlYSA9IHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSA9PT0gbnVsbCB8fCBfdGhpcyRfZnVsbFJlcXVlc3RSZWEgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYS5fbG9hZGVkKSA/PyAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRGdWxsUmVhZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KSghdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIsICJQREZOb2RlU3RyZWFtLmdldEZ1bGxSZWFkZXIgY2FuIG9ubHkgYmUgY2FsbGVkIG9uY2UuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyID0gdGhpcy5pc0ZzVXJsID8gbmV3IFBERk5vZGVTdHJlYW1Gc0Z1bGxSZWFkZXIodGhpcykgOiBuZXcgUERGTm9kZVN0cmVhbUZ1bGxSZWFkZXIodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UmFuZ2VSZWFkZXIoc3RhcnQsIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW5kIDw9IHRoaXMuX3Byb2dyZXNzaXZlRGF0YUxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFuZ2VSZWFkZXIgPSB0aGlzLmlzRnNVcmwgPyBuZXcgUERGTm9kZVN0cmVhbUZzUmFuZ2VSZWFkZXIodGhpcywgc3RhcnQsIGVuZCkgOiBuZXcgUERGTm9kZVN0cmVhbVJhbmdlUmVhZGVyKHRoaXMsIHN0YXJ0LCBlbmQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLnB1c2gocmFuZ2VSZWFkZXIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmFuZ2VSZWFkZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbmNlbEFsbFJlcXVlc3RzKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMjsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9mdWxsUmVxdWVzdFJlYTIgPSB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMi5jYW5jZWwocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZWFkZXIgb2YgdGhpcy5fcmFuZ2VSZXF1ZXN0UmVhZGVycy5zbGljZSgwKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZGVyLmNhbmNlbChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZOb2RlU3RyZWFtID0gUERGTm9kZVN0cmVhbTsKICAgICAgICAgICAgICAgIGNsYXNzIEJhc2VGdWxsUmVhZGVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdXJsID0gc3RyZWFtLnVybDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25Qcm9ncmVzcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNvdXJjZSA9IHN0cmVhbS5zb3VyY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRlbnRMZW5ndGggPSBzb3VyY2UubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZWQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9maWxlbmFtZSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHNvdXJjZS5kaXNhYmxlUmFuZ2UgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlQ2h1bmtTaXplID0gc291cmNlLnJhbmdlQ2h1bmtTaXplOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3JhbmdlQ2h1bmtTaXplICYmICF0aGlzLl9kaXNhYmxlUmFuZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNTdHJlYW1pbmdTdXBwb3J0ZWQgPSAhc291cmNlLmRpc2FibGVTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQgPSAhc291cmNlLmRpc2FibGVSYW5nZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGFibGVTdHJlYW0gPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkQ2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc0NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBoZWFkZXJzUmVhZHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9oZWFkZXJzQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgZmlsZW5hbWUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9maWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGNvbnRlbnRMZW5ndGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9jb250ZW50TGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNSYW5nZVN1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2lzU3RyZWFtaW5nU3VwcG9ydGVkOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkb25Qcm9ncmVzczsKICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgdGhpcy5fcmVhZENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2RvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9zdG9yZWRFcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgdGhpcy5fc3RvcmVkRXJyb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2h1bmsgPSB0aGlzLl9yZWFkYWJsZVN0cmVhbS5yZWFkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaHVuayA9PT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5yZWFkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVkICs9IGNodW5rLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJG9uUHJvZ3Jlc3MgPSB0aGlzLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF90aGlzJG9uUHJvZ3Jlc3MgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJG9uUHJvZ3Jlc3MuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkZWQ6IHRoaXMuX2xvYWRlZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsOiB0aGlzLl9jb250ZW50TGVuZ3RoCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBuZXcgVWludDhBcnJheShjaHVuaykuYnVmZmVyOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGJ1ZmZlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbmNlbChyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9yZWFkYWJsZVN0cmVhbSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZXJyb3IocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkYWJsZVN0cmVhbS5kZXN0cm95KHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9lcnJvcihyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSByZWFzb247CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldFJlYWRhYmxlU3RyZWFtKHJlYWRhYmxlU3RyZWFtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRhYmxlU3RyZWFtID0gcmVhZGFibGVTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJyZWFkYWJsZSIsICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJlbmQiLCAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkYWJsZVN0cmVhbS5kZXN0cm95KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJlcnJvciIsIHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lcnJvcihyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZCAmJiB0aGlzLl9pc1JhbmdlU3VwcG9ydGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lcnJvcihuZXcgX3V0aWwuQWJvcnRFeGNlcHRpb24oInN0cmVhbWluZyBpcyBkaXNhYmxlZCIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fc3RvcmVkRXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRhYmxlU3RyZWFtLmRlc3Ryb3kodGhpcy5fc3RvcmVkRXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgQmFzZVJhbmdlUmVhZGVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdXJsID0gc3RyZWFtLnVybDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25Qcm9ncmVzcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlZCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRhYmxlU3RyZWFtID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNvdXJjZSA9IHN0cmVhbS5zb3VyY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2lzU3RyZWFtaW5nU3VwcG9ydGVkID0gIXNvdXJjZS5kaXNhYmxlU3RyZWFtOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNTdHJlYW1pbmdTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgcmVhZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJG9uUHJvZ3Jlc3MyOwogICAgICAgICAgICAgICAgICAgICAgICBhd2FpdCB0aGlzLl9yZWFkQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3JlZEVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyB0aGlzLl9zdG9yZWRFcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVuayA9IHRoaXMuX3JlYWRhYmxlU3RyZWFtLnJlYWQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNodW5rID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkQ2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJlYWQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZWQgKz0gY2h1bmsubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkb25Qcm9ncmVzczIgPSB0aGlzLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF90aGlzJG9uUHJvZ3Jlc3MyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRvblByb2dyZXNzMi5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRlZDogdGhpcy5fbG9hZGVkCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBuZXcgVWludDhBcnJheShjaHVuaykuYnVmZmVyOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGJ1ZmZlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbmNlbChyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9yZWFkYWJsZVN0cmVhbSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZXJyb3IocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkYWJsZVN0cmVhbS5kZXN0cm95KHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9lcnJvcihyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSByZWFzb247CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldFJlYWRhYmxlU3RyZWFtKHJlYWRhYmxlU3RyZWFtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRhYmxlU3RyZWFtID0gcmVhZGFibGVTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJyZWFkYWJsZSIsICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJlbmQiLCAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkYWJsZVN0cmVhbS5kZXN0cm95KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJlcnJvciIsIHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lcnJvcihyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3JlZEVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkYWJsZVN0cmVhbS5kZXN0cm95KHRoaXMuX3N0b3JlZEVycm9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNyZWF0ZVJlcXVlc3RPcHRpb25zKHBhcnNlZFVybCwgaGVhZGVycykgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHByb3RvY29sOiBwYXJzZWRVcmwucHJvdG9jb2wsCiAgICAgICAgICAgICAgICAgICAgICAgIGF1dGg6IHBhcnNlZFVybC5hdXRoLAogICAgICAgICAgICAgICAgICAgICAgICBob3N0OiBwYXJzZWRVcmwuaG9zdG5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHBvcnQ6IHBhcnNlZFVybC5wb3J0LAogICAgICAgICAgICAgICAgICAgICAgICBwYXRoOiBwYXJzZWRVcmwucGF0aCwKICAgICAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiAiR0VUIiwKICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVycwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQREZOb2RlU3RyZWFtRnVsbFJlYWRlciBleHRlbmRzIEJhc2VGdWxsUmVhZGVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIoc3RyZWFtKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGFuZGxlUmVzcG9uc2UgPSByZXNwb25zZSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVzcG9uc2Uuc3RhdHVzQ29kZSA9PT0gNDA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZXJyb3IgPSBuZXcgX3V0aWwuTWlzc2luZ1BERkV4Y2VwdGlvbihgTWlzc2luZyBQREYgIiR7dGhpcy5fdXJsfSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSBlcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9oZWFkZXJzQ2FwYWJpbGl0eS5yZWplY3QoZXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hlYWRlcnNDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldFJlYWRhYmxlU3RyZWFtKHJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdldFJlc3BvbnNlSGVhZGVyID0gbmFtZSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3JlYWRhYmxlU3RyZWFtLmhlYWRlcnNbbmFtZS50b0xvd2VyQ2FzZSgpXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxsb3dSYW5nZVJlcXVlc3RzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1Z2dlc3RlZExlbmd0aAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9ICgwLCBfbmV0d29ya191dGlscy52YWxpZGF0ZVJhbmdlUmVxdWVzdENhcGFiaWxpdGllcykoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldFJlc3BvbnNlSGVhZGVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzSHR0cDogc3RyZWFtLmlzSHR0cCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYW5nZUNodW5rU2l6ZTogdGhpcy5fcmFuZ2VDaHVua1NpemUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZVJhbmdlOiB0aGlzLl9kaXNhYmxlUmFuZ2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNSYW5nZVN1cHBvcnRlZCA9IGFsbG93UmFuZ2VSZXF1ZXN0czsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRlbnRMZW5ndGggPSBzdWdnZXN0ZWRMZW5ndGggfHwgdGhpcy5fY29udGVudExlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZpbGVuYW1lID0gKDAsIF9uZXR3b3JrX3V0aWxzLmV4dHJhY3RGaWxlbmFtZUZyb21IZWFkZXIpKGdldFJlc3BvbnNlSGVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl91cmwucHJvdG9jb2wgPT09ICJodHRwOiIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3QgPSBodHRwLnJlcXVlc3QoY3JlYXRlUmVxdWVzdE9wdGlvbnModGhpcy5fdXJsLCBzdHJlYW0uaHR0cEhlYWRlcnMpLCBoYW5kbGVSZXNwb25zZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0ID0gaHR0cHMucmVxdWVzdChjcmVhdGVSZXF1ZXN0T3B0aW9ucyh0aGlzLl91cmwsIHN0cmVhbS5odHRwSGVhZGVycyksIGhhbmRsZVJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0Lm9uKCJlcnJvciIsIHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IHJlYXNvbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hlYWRlcnNDYXBhYmlsaXR5LnJlamVjdChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdC5lbmQoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQREZOb2RlU3RyZWFtUmFuZ2VSZWFkZXIgZXh0ZW5kcyBCYXNlUmFuZ2VSZWFkZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHN0cmVhbSwgc3RhcnQsIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihzdHJlYW0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9odHRwSGVhZGVycyA9IHt9OwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHByb3BlcnR5IGluIHN0cmVhbS5odHRwSGVhZGVycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmFsdWUgPSBzdHJlYW0uaHR0cEhlYWRlcnNbcHJvcGVydHldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2h0dHBIZWFkZXJzW3Byb3BlcnR5XSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2h0dHBIZWFkZXJzLlJhbmdlID0gYGJ5dGVzPSR7c3RhcnR9LSR7ZW5kIC0gMX1gOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoYW5kbGVSZXNwb25zZSA9IHJlc3BvbnNlID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXNwb25zZS5zdGF0dXNDb2RlID09PSA0MDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlcnJvciA9IG5ldyBfdXRpbC5NaXNzaW5nUERGRXhjZXB0aW9uKGBNaXNzaW5nIFBERiAiJHt0aGlzLl91cmx9Ii5gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IGVycm9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldFJlYWRhYmxlU3RyZWFtKHJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl91cmwucHJvdG9jb2wgPT09ICJodHRwOiIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3QgPSBodHRwLnJlcXVlc3QoY3JlYXRlUmVxdWVzdE9wdGlvbnModGhpcy5fdXJsLCB0aGlzLl9odHRwSGVhZGVycyksIGhhbmRsZVJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3QgPSBodHRwcy5yZXF1ZXN0KGNyZWF0ZVJlcXVlc3RPcHRpb25zKHRoaXMuX3VybCwgdGhpcy5faHR0cEhlYWRlcnMpLCBoYW5kbGVSZXNwb25zZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdC5vbigiZXJyb3IiLCByZWFzb24gPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSByZWFzb247CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0LmVuZCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBERk5vZGVTdHJlYW1Gc0Z1bGxSZWFkZXIgZXh0ZW5kcyBCYXNlRnVsbFJlYWRlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc3RyZWFtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHN0cmVhbSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwYXRoID0gZGVjb2RlVVJJQ29tcG9uZW50KHRoaXMuX3VybC5wYXRoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGVVcmlSZWdleC50ZXN0KHRoaXMuX3VybC5ocmVmKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0aCA9IHBhdGgucmVwbGFjZSgvXlwvLywgIiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZzLmxzdGF0KHBhdGgsIChlcnJvciwgc3RhdCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycm9yLmNvZGUgPT09ICJFTk9FTlQiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVycm9yID0gbmV3IF91dGlsLk1pc3NpbmdQREZFeGNlcHRpb24oYE1pc3NpbmcgUERGICIke3BhdGh9Ii5gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSBlcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9oZWFkZXJzQ2FwYWJpbGl0eS5yZWplY3QoZXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRlbnRMZW5ndGggPSBzdGF0LnNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRSZWFkYWJsZVN0cmVhbShmcy5jcmVhdGVSZWFkU3RyZWFtKHBhdGgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hlYWRlcnNDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUERGTm9kZVN0cmVhbUZzUmFuZ2VSZWFkZXIgZXh0ZW5kcyBCYXNlUmFuZ2VSZWFkZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHN0cmVhbSwgc3RhcnQsIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihzdHJlYW0pOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGF0aCA9IGRlY29kZVVSSUNvbXBvbmVudCh0aGlzLl91cmwucGF0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmaWxlVXJpUmVnZXgudGVzdCh0aGlzLl91cmwuaHJlZikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGggPSBwYXRoLnJlcGxhY2UoL15cLy8sICIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRSZWFkYWJsZVN0cmVhbShmcy5jcmVhdGVSZWFkU3RyZWFtKHBhdGgsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5kOiBlbmQgLSAxCiAgICAgICAgICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE1NyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLmNyZWF0ZVJlc3BvbnNlU3RhdHVzRXJyb3IgPSBjcmVhdGVSZXNwb25zZVN0YXR1c0Vycm9yOwogICAgICAgICAgICAgICAgZXhwb3J0cy5leHRyYWN0RmlsZW5hbWVGcm9tSGVhZGVyID0gZXh0cmFjdEZpbGVuYW1lRnJvbUhlYWRlcjsKICAgICAgICAgICAgICAgIGV4cG9ydHMudmFsaWRhdGVSYW5nZVJlcXVlc3RDYXBhYmlsaXRpZXMgPSB2YWxpZGF0ZVJhbmdlUmVxdWVzdENhcGFiaWxpdGllczsKICAgICAgICAgICAgICAgIGV4cG9ydHMudmFsaWRhdGVSZXNwb25zZVN0YXR1cyA9IHZhbGlkYXRlUmVzcG9uc2VTdGF0dXM7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9jb250ZW50X2Rpc3Bvc2l0aW9uID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwbGF5X3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDIpOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gdmFsaWRhdGVSYW5nZVJlcXVlc3RDYXBhYmlsaXRpZXMoX3JlZikgewogICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgIGdldFJlc3BvbnNlSGVhZGVyLAogICAgICAgICAgICAgICAgICAgICAgICBpc0h0dHAsCiAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlQ2h1bmtTaXplLAogICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlUmFuZ2UKICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICBjb25zdCByZXR1cm5WYWx1ZXMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGFsbG93UmFuZ2VSZXF1ZXN0czogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgIHN1Z2dlc3RlZExlbmd0aDogdW5kZWZpbmVkCiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBsZW5ndGggPSBwYXJzZUludChnZXRSZXNwb25zZUhlYWRlcigiQ29udGVudC1MZW5ndGgiKSwgMTApOwogICAgICAgICAgICAgICAgICAgIGlmICghTnVtYmVyLmlzSW50ZWdlcihsZW5ndGgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVyblZhbHVlcy5zdWdnZXN0ZWRMZW5ndGggPSBsZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgaWYgKGxlbmd0aCA8PSAyICogcmFuZ2VDaHVua1NpemUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJldHVyblZhbHVlczsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGRpc2FibGVSYW5nZSB8fCAhaXNIdHRwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChnZXRSZXNwb25zZUhlYWRlcigiQWNjZXB0LVJhbmdlcyIpICE9PSAiYnl0ZXMiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRlbnRFbmNvZGluZyA9IGdldFJlc3BvbnNlSGVhZGVyKCJDb250ZW50LUVuY29kaW5nIikgfHwgImlkZW50aXR5IjsKICAgICAgICAgICAgICAgICAgICBpZiAoY29udGVudEVuY29kaW5nICE9PSAiaWRlbnRpdHkiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVyblZhbHVlcy5hbGxvd1JhbmdlUmVxdWVzdHMgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZXM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBleHRyYWN0RmlsZW5hbWVGcm9tSGVhZGVyKGdldFJlc3BvbnNlSGVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgY29udGVudERpc3Bvc2l0aW9uID0gZ2V0UmVzcG9uc2VIZWFkZXIoIkNvbnRlbnQtRGlzcG9zaXRpb24iKTsKICAgICAgICAgICAgICAgICAgICBpZiAoY29udGVudERpc3Bvc2l0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmaWxlbmFtZSA9ICgwLCBfY29udGVudF9kaXNwb3NpdGlvbi5nZXRGaWxlbmFtZUZyb21Db250ZW50RGlzcG9zaXRpb25IZWFkZXIpKGNvbnRlbnREaXNwb3NpdGlvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmaWxlbmFtZS5pbmNsdWRlcygiJSIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVuYW1lID0gZGVjb2RlVVJJQ29tcG9uZW50KGZpbGVuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7fQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoMCwgX2Rpc3BsYXlfdXRpbHMuaXNQZGZGaWxlKShmaWxlbmFtZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmaWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNyZWF0ZVJlc3BvbnNlU3RhdHVzRXJyb3Ioc3RhdHVzLCB1cmwpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdHVzID09PSA0MDQgfHwgc3RhdHVzID09PSAwICYmIHVybC5zdGFydHNXaXRoKCJmaWxlOiIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgX3V0aWwuTWlzc2luZ1BERkV4Y2VwdGlvbignTWlzc2luZyBQREYgIicgKyB1cmwgKyAnIi4nKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBfdXRpbC5VbmV4cGVjdGVkUmVzcG9uc2VFeGNlcHRpb24oYFVuZXhwZWN0ZWQgc2VydmVyIHJlc3BvbnNlICgke3N0YXR1c30pIHdoaWxlIHJldHJpZXZpbmcgUERGICIke3VybH0iLmAsIHN0YXR1cyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiB2YWxpZGF0ZVJlc3BvbnNlU3RhdHVzKHN0YXR1cykgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdGF0dXMgPT09IDIwMCB8fCBzdGF0dXMgPT09IDIwNjsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTU4ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuZ2V0RmlsZW5hbWVGcm9tQ29udGVudERpc3Bvc2l0aW9uSGVhZGVyID0gZ2V0RmlsZW5hbWVGcm9tQ29udGVudERpc3Bvc2l0aW9uSGVhZGVyOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldEZpbGVuYW1lRnJvbUNvbnRlbnREaXNwb3NpdGlvbkhlYWRlcihjb250ZW50RGlzcG9zaXRpb24pIHsKICAgICAgICAgICAgICAgICAgICBsZXQgbmVlZHNFbmNvZGluZ0ZpeHVwID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICBsZXQgdG1wID0gdG9QYXJhbVJlZ0V4cCgiZmlsZW5hbWVcXCoiLCAiaSIpLmV4ZWMoY29udGVudERpc3Bvc2l0aW9uKTsKICAgICAgICAgICAgICAgICAgICBpZiAodG1wKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRtcCA9IHRtcFsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGZpbGVuYW1lID0gcmZjMjYxNnVucXVvdGUodG1wKTsKICAgICAgICAgICAgICAgICAgICAgICAgZmlsZW5hbWUgPSB1bmVzY2FwZShmaWxlbmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVuYW1lID0gcmZjNTk4N2RlY29kZShmaWxlbmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVuYW1lID0gcmZjMjA0N2RlY29kZShmaWxlbmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmaXh1cEVuY29kaW5nKGZpbGVuYW1lKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdG1wID0gcmZjMjIzMWdldHBhcmFtKGNvbnRlbnREaXNwb3NpdGlvbik7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRtcCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxlbmFtZSA9IHJmYzIwNDdkZWNvZGUodG1wKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZpeHVwRW5jb2RpbmcoZmlsZW5hbWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0bXAgPSB0b1BhcmFtUmVnRXhwKCJmaWxlbmFtZSIsICJpIikuZXhlYyhjb250ZW50RGlzcG9zaXRpb24pOwogICAgICAgICAgICAgICAgICAgIGlmICh0bXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wID0gdG1wWzFdOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZmlsZW5hbWUgPSByZmMyNjE2dW5xdW90ZSh0bXApOwogICAgICAgICAgICAgICAgICAgICAgICBmaWxlbmFtZSA9IHJmYzIwNDdkZWNvZGUoZmlsZW5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZml4dXBFbmNvZGluZyhmaWxlbmFtZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHRvUGFyYW1SZWdFeHAoYXR0cmlidXRlUGF0dGVybiwgZmxhZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBSZWdFeHAoIig/Ol58OylcXHMqIiArIGF0dHJpYnV0ZVBhdHRlcm4gKyAiXFxzKj1cXHMqIiArICIoIiArICdbXiI7XFxzXVteO1xcc10qJyArICJ8IiArICciKD86W14iXFxcXF18XFxcXCI/KSsiPycgKyAiKSIsIGZsYWdzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gdGV4dGRlY29kZShlbmNvZGluZywgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuY29kaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIS9eW1x4MDAtXHhGRl0rJC8udGVzdCh2YWx1ZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlY29kZXIgPSBuZXcgVGV4dERlY29kZXIoZW5jb2RpbmcsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmF0YWw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSAoMCwgX3V0aWwuc3RyaW5nVG9CeXRlcykodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlID0gZGVjb2Rlci5kZWNvZGUoYnVmZmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZWVkc0VuY29kaW5nRml4dXAgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHt9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBmaXh1cEVuY29kaW5nKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZWVkc0VuY29kaW5nRml4dXAgJiYgL1tceDgwLVx4ZmZdLy50ZXN0KHZhbHVlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSB0ZXh0ZGVjb2RlKCJ1dGYtOCIsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZWVkc0VuY29kaW5nRml4dXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHRleHRkZWNvZGUoImlzby04ODU5LTEiLCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiByZmMyMjMxZ2V0cGFyYW0oY29udGVudERpc3Bvc2l0aW9uU3RyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hdGNoZXMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG1hdGNoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpdGVyID0gdG9QYXJhbVJlZ0V4cCgiZmlsZW5hbWVcXCooKD8hMFxcZClcXGQrKShcXCo/KSIsICJpZyIpOwogICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoKG1hdGNoID0gaXRlci5leGVjKGNvbnRlbnREaXNwb3NpdGlvblN0cikpICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgWywgbiwgcXVvdCwgcGFydF0gPSBtYXRjaDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG4gPSBwYXJzZUludChuLCAxMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobiBpbiBtYXRjaGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG4gPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF0Y2hlc1tuXSA9IFtxdW90LCBwYXJ0XTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJ0cyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBuID0gMDsgbiA8IG1hdGNoZXMubGVuZ3RoOyArK24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghKG4gaW4gbWF0Y2hlcykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBbcXVvdCwgcGFydF0gPSBtYXRjaGVzW25dOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFydCA9IHJmYzI2MTZ1bnF1b3RlKHBhcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHF1b3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJ0ID0gdW5lc2NhcGUocGFydCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG4gPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFydCA9IHJmYzU5ODdkZWNvZGUocGFydCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFydHMucHVzaChwYXJ0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGFydHMuam9pbigiIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHJmYzI2MTZ1bnF1b3RlKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZS5zdGFydHNXaXRoKCciJykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhcnRzID0gdmFsdWUuc2xpY2UoMSkuc3BsaXQoJ1xcIicpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBwYXJ0cy5sZW5ndGg7ICsraSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHF1b3RpbmRleCA9IHBhcnRzW2ldLmluZGV4T2YoJyInKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocXVvdGluZGV4ICE9PSAtMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJ0c1tpXSA9IHBhcnRzW2ldLnNsaWNlKDAsIHF1b3RpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcnRzLmxlbmd0aCA9IGkgKyAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJ0c1tpXSA9IHBhcnRzW2ldLnJlcGxhY2VBbGwoL1xcKC4pL2csICIkMSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSBwYXJ0cy5qb2luKCciJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiByZmM1OTg3ZGVjb2RlKGV4dHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVuY29kaW5nZW5kID0gZXh0dmFsdWUuaW5kZXhPZigiJyIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW5jb2RpbmdlbmQgPT09IC0xKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZXh0dmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZW5jb2RpbmcgPSBleHR2YWx1ZS5zbGljZSgwLCBlbmNvZGluZ2VuZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxhbmd2YWx1ZSA9IGV4dHZhbHVlLnNsaWNlKGVuY29kaW5nZW5kICsgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gbGFuZ3ZhbHVlLnJlcGxhY2UoL15bXiddKicvLCAiIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0ZXh0ZGVjb2RlKGVuY29kaW5nLCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHJmYzIwNDdkZWNvZGUodmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF2YWx1ZS5zdGFydHNXaXRoKCI9PyIpIHx8IC9bXHgwMC1ceDE5XHg4MC1ceGZmXS8udGVzdCh2YWx1ZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWUucmVwbGFjZUFsbCgvPVw/KFtcdy1dKilcPyhbUXFCYl0pXD8oKD86W14/XXxcPyg/IT0pKSopXD89L2csIGZ1bmN0aW9uIChtYXRjaGVzLCBjaGFyc2V0LCBlbmNvZGluZywgdGV4dCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuY29kaW5nID09PSAicSIgfHwgZW5jb2RpbmcgPT09ICJRIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHQgPSB0ZXh0LnJlcGxhY2VBbGwoIl8iLCAiICIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHQgPSB0ZXh0LnJlcGxhY2VBbGwoLz0oWzAtOWEtZkEtRl17Mn0pL2csIGZ1bmN0aW9uIChtYXRjaCwgaGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBTdHJpbmcuZnJvbUNoYXJDb2RlKHBhcnNlSW50KGhleCwgMTYpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGV4dGRlY29kZShjaGFyc2V0LCB0ZXh0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dCA9IGF0b2IodGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7fQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRleHRkZWNvZGUoY2hhcnNldCwgdGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gIiI7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE1OSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERk5ldHdvcmtTdHJlYW0gPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9uZXR3b3JrX3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTcpOwogICAgICAgICAgICAgICAgOwogICAgICAgICAgICAgICAgY29uc3QgT0tfUkVTUE9OU0UgPSAyMDA7CiAgICAgICAgICAgICAgICBjb25zdCBQQVJUSUFMX0NPTlRFTlRfUkVTUE9OU0UgPSAyMDY7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRBcnJheUJ1ZmZlcih4aHIpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0geGhyLnJlc3BvbnNlOwogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgZGF0YSAhPT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiAoMCwgX3V0aWwuc3RyaW5nVG9CeXRlcykoZGF0YSkuYnVmZmVyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgTmV0d29ya01hbmFnZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHVybCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYXJncyA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudXJsID0gdXJsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzSHR0cCA9IC9eaHR0cHM/Oi9pLnRlc3QodXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5odHRwSGVhZGVycyA9IHRoaXMuaXNIdHRwICYmIGFyZ3MuaHR0cEhlYWRlcnMgfHwgT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy53aXRoQ3JlZGVudGlhbHMgPSBhcmdzLndpdGhDcmVkZW50aWFscyB8fCBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5nZXRYaHIgPSBhcmdzLmdldFhociB8fCBmdW5jdGlvbiBOZXR3b3JrTWFuYWdlcl9nZXRYaHIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFhNTEh0dHBSZXF1ZXN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VyclhocklkID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nUmVxdWVzdHMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXF1ZXN0UmFuZ2UoYmVnaW4sIGVuZCwgbGlzdGVuZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3MgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiZWdpbiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuZAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHByb3AgaW4gbGlzdGVuZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmdzW3Byb3BdID0gbGlzdGVuZXJzW3Byb3BdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJlcXVlc3QoYXJncyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlcXVlc3RGdWxsKGxpc3RlbmVycykgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5yZXF1ZXN0KGxpc3RlbmVycyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlcXVlc3QoYXJncykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4aHIgPSB0aGlzLmdldFhocigpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4aHJJZCA9IHRoaXMuY3VyclhocklkKys7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBlbmRpbmdSZXF1ZXN0ID0gdGhpcy5wZW5kaW5nUmVxdWVzdHNbeGhySWRdID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgeGhyCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIHhoci5vcGVuKCJHRVQiLCB0aGlzLnVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHhoci53aXRoQ3JlZGVudGlhbHMgPSB0aGlzLndpdGhDcmVkZW50aWFsczsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBwcm9wZXJ0eSBpbiB0aGlzLmh0dHBIZWFkZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IHRoaXMuaHR0cEhlYWRlcnNbcHJvcGVydHldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhoci5zZXRSZXF1ZXN0SGVhZGVyKHByb3BlcnR5LCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNIdHRwICYmICJiZWdpbiIgaW4gYXJncyAmJiAiZW5kIiBpbiBhcmdzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB4aHIuc2V0UmVxdWVzdEhlYWRlcigiUmFuZ2UiLCBgYnl0ZXM9JHthcmdzLmJlZ2lufS0ke2FyZ3MuZW5kIC0gMX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlbmRpbmdSZXF1ZXN0LmV4cGVjdGVkU3RhdHVzID0gUEFSVElBTF9DT05URU5UX1JFU1BPTlNFOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3QuZXhwZWN0ZWRTdGF0dXMgPSBPS19SRVNQT05TRTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB4aHIucmVzcG9uc2VUeXBlID0gImFycmF5YnVmZmVyIjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFyZ3Mub25FcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgeGhyLm9uZXJyb3IgPSBmdW5jdGlvbiAoZXZ0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJncy5vbkVycm9yKHhoci5zdGF0dXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB4aHIub25yZWFkeXN0YXRlY2hhbmdlID0gdGhpcy5vblN0YXRlQ2hhbmdlLmJpbmQodGhpcywgeGhySWQpOwogICAgICAgICAgICAgICAgICAgICAgICB4aHIub25wcm9ncmVzcyA9IHRoaXMub25Qcm9ncmVzcy5iaW5kKHRoaXMsIHhocklkKTsKICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3Qub25IZWFkZXJzUmVjZWl2ZWQgPSBhcmdzLm9uSGVhZGVyc1JlY2VpdmVkOwogICAgICAgICAgICAgICAgICAgICAgICBwZW5kaW5nUmVxdWVzdC5vbkRvbmUgPSBhcmdzLm9uRG9uZTsKICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3Qub25FcnJvciA9IGFyZ3Mub25FcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3Qub25Qcm9ncmVzcyA9IGFyZ3Mub25Qcm9ncmVzczsKICAgICAgICAgICAgICAgICAgICAgICAgeGhyLnNlbmQobnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB4aHJJZDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25Qcm9ncmVzcyh4aHJJZCwgZXZ0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGVuZGluZ1JlcXVlc3Qkb25Qcm87CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBlbmRpbmdSZXF1ZXN0ID0gdGhpcy5wZW5kaW5nUmVxdWVzdHNbeGhySWRdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXBlbmRpbmdSZXF1ZXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgKF9wZW5kaW5nUmVxdWVzdCRvblBybyA9IHBlbmRpbmdSZXF1ZXN0Lm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF9wZW5kaW5nUmVxdWVzdCRvblBybyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3BlbmRpbmdSZXF1ZXN0JG9uUHJvLmNhbGwocGVuZGluZ1JlcXVlc3QsIGV2dCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uU3RhdGVDaGFuZ2UoeGhySWQsIGV2dCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwZW5kaW5nUmVxdWVzdCA9IHRoaXMucGVuZGluZ1JlcXVlc3RzW3hocklkXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFwZW5kaW5nUmVxdWVzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHhociA9IHBlbmRpbmdSZXF1ZXN0LnhocjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhoci5yZWFkeVN0YXRlID49IDIgJiYgcGVuZGluZ1JlcXVlc3Qub25IZWFkZXJzUmVjZWl2ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlbmRpbmdSZXF1ZXN0Lm9uSGVhZGVyc1JlY2VpdmVkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgcGVuZGluZ1JlcXVlc3Qub25IZWFkZXJzUmVjZWl2ZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhoci5yZWFkeVN0YXRlICE9PSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCEoeGhySWQgaW4gdGhpcy5wZW5kaW5nUmVxdWVzdHMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHRoaXMucGVuZGluZ1JlcXVlc3RzW3hocklkXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhoci5zdGF0dXMgPT09IDAgJiYgdGhpcy5pc0h0dHApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGVuZGluZ1JlcXVlc3Qkb25FcnI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3BlbmRpbmdSZXF1ZXN0JG9uRXJyID0gcGVuZGluZ1JlcXVlc3Qub25FcnJvcikgPT09IG51bGwgfHwgX3BlbmRpbmdSZXF1ZXN0JG9uRXJyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfcGVuZGluZ1JlcXVlc3Qkb25FcnIuY2FsbChwZW5kaW5nUmVxdWVzdCwgeGhyLnN0YXR1cyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeGhyU3RhdHVzID0geGhyLnN0YXR1cyB8fCBPS19SRVNQT05TRTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2tfcmVzcG9uc2Vfb25fcmFuZ2VfcmVxdWVzdCA9IHhoclN0YXR1cyA9PT0gT0tfUkVTUE9OU0UgJiYgcGVuZGluZ1JlcXVlc3QuZXhwZWN0ZWRTdGF0dXMgPT09IFBBUlRJQUxfQ09OVEVOVF9SRVNQT05TRTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFva19yZXNwb25zZV9vbl9yYW5nZV9yZXF1ZXN0ICYmIHhoclN0YXR1cyAhPT0gcGVuZGluZ1JlcXVlc3QuZXhwZWN0ZWRTdGF0dXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGVuZGluZ1JlcXVlc3Qkb25FcnIyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF9wZW5kaW5nUmVxdWVzdCRvbkVycjIgPSBwZW5kaW5nUmVxdWVzdC5vbkVycm9yKSA9PT0gbnVsbCB8fCBfcGVuZGluZ1JlcXVlc3Qkb25FcnIyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfcGVuZGluZ1JlcXVlc3Qkb25FcnIyLmNhbGwocGVuZGluZ1JlcXVlc3QsIHhoci5zdGF0dXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gZ2V0QXJyYXlCdWZmZXIoeGhyKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhoclN0YXR1cyA9PT0gUEFSVElBTF9DT05URU5UX1JFU1BPTlNFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByYW5nZUhlYWRlciA9IHhoci5nZXRSZXNwb25zZUhlYWRlcigiQ29udGVudC1SYW5nZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF0Y2hlcyA9IC9ieXRlcyAoXGQrKS0oXGQrKVwvKFxkKykvLmV4ZWMocmFuZ2VIZWFkZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3Qub25Eb25lKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiZWdpbjogcGFyc2VJbnQobWF0Y2hlc1sxXSwgMTApLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNodW5rCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3Qub25Eb25lKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiZWdpbjogMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaHVuawogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BlbmRpbmdSZXF1ZXN0JG9uRXJyMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfcGVuZGluZ1JlcXVlc3Qkb25FcnIzID0gcGVuZGluZ1JlcXVlc3Qub25FcnJvcikgPT09IG51bGwgfHwgX3BlbmRpbmdSZXF1ZXN0JG9uRXJyMyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3BlbmRpbmdSZXF1ZXN0JG9uRXJyMy5jYWxsKHBlbmRpbmdSZXF1ZXN0LCB4aHIuc3RhdHVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSZXF1ZXN0WGhyKHhocklkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnBlbmRpbmdSZXF1ZXN0c1t4aHJJZF0ueGhyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpc1BlbmRpbmdSZXF1ZXN0KHhocklkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB4aHJJZCBpbiB0aGlzLnBlbmRpbmdSZXF1ZXN0czsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWJvcnRSZXF1ZXN0KHhocklkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHhociA9IHRoaXMucGVuZGluZ1JlcXVlc3RzW3hocklkXS54aHI7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSB0aGlzLnBlbmRpbmdSZXF1ZXN0c1t4aHJJZF07CiAgICAgICAgICAgICAgICAgICAgICAgIHhoci5hYm9ydCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBERk5ldHdvcmtTdHJlYW0gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zb3VyY2UgPSBzb3VyY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX21hbmFnZXIgPSBuZXcgTmV0d29ya01hbmFnZXIoc291cmNlLnVybCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaHR0cEhlYWRlcnM6IHNvdXJjZS5odHRwSGVhZGVycywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpdGhDcmVkZW50aWFsczogc291cmNlLndpdGhDcmVkZW50aWFscwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VDaHVua1NpemUgPSBzb3VyY2UucmFuZ2VDaHVua1NpemU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VSZXF1ZXN0UmVhZGVycyA9IFtdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25SYW5nZVJlcXVlc3RSZWFkZXJDbG9zZWQocmVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGkgPSB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLmluZGV4T2YocmVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPj0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VSZXF1ZXN0UmVhZGVycy5zcGxpY2UoaSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RnVsbFJlYWRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmFzc2VydCkoIXRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyLCAiUERGTmV0d29ya1N0cmVhbS5nZXRGdWxsUmVhZGVyIGNhbiBvbmx5IGJlIGNhbGxlZCBvbmNlLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlciA9IG5ldyBQREZOZXR3b3JrU3RyZWFtRnVsbFJlcXVlc3RSZWFkZXIodGhpcy5fbWFuYWdlciwgdGhpcy5fc291cmNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSYW5nZVJlYWRlcihiZWdpbiwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlYWRlciA9IG5ldyBQREZOZXR3b3JrU3RyZWFtUmFuZ2VSZXF1ZXN0UmVhZGVyKHRoaXMuX21hbmFnZXIsIGJlZ2luLCBlbmQpOwogICAgICAgICAgICAgICAgICAgICAgICByZWFkZXIub25DbG9zZWQgPSB0aGlzLl9vblJhbmdlUmVxdWVzdFJlYWRlckNsb3NlZC5iaW5kKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLnB1c2gocmVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlYWRlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsQWxsUmVxdWVzdHMocmVhc29uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWE7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfZnVsbFJlcXVlc3RSZWEgPSB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlcXVlc3RSZWEuY2FuY2VsKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcmVhZGVyIG9mIHRoaXMuX3JhbmdlUmVxdWVzdFJlYWRlcnMuc2xpY2UoMCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRlci5jYW5jZWwocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuUERGTmV0d29ya1N0cmVhbSA9IFBERk5ldHdvcmtTdHJlYW07CiAgICAgICAgICAgICAgICBjbGFzcyBQREZOZXR3b3JrU3RyZWFtRnVsbFJlcXVlc3RSZWFkZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKG1hbmFnZXIsIHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tYW5hZ2VyID0gbWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYXJncyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uSGVhZGVyc1JlY2VpdmVkOiB0aGlzLl9vbkhlYWRlcnNSZWNlaXZlZC5iaW5kKHRoaXMpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb25Eb25lOiB0aGlzLl9vbkRvbmUuYmluZCh0aGlzKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uRXJyb3I6IHRoaXMuX29uRXJyb3IuYmluZCh0aGlzKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uUHJvZ3Jlc3M6IHRoaXMuX29uUHJvZ3Jlc3MuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91cmwgPSBzb3VyY2UudXJsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mdWxsUmVxdWVzdElkID0gbWFuYWdlci5yZXF1ZXN0RnVsbChhcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc1JlY2VpdmVkQ2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGlzYWJsZVJhbmdlID0gc291cmNlLmRpc2FibGVSYW5nZSB8fCBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGVudExlbmd0aCA9IHNvdXJjZS5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlQ2h1bmtTaXplID0gc291cmNlLnJhbmdlQ2h1bmtTaXplOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3JhbmdlQ2h1bmtTaXplICYmICF0aGlzLl9kaXNhYmxlUmFuZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNTdHJlYW1pbmdTdXBwb3J0ZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNSYW5nZVN1cHBvcnRlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRDaHVua3MgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZmlsZW5hbWUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25IZWFkZXJzUmVjZWl2ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZ1bGxSZXF1ZXN0WGhySWQgPSB0aGlzLl9mdWxsUmVxdWVzdElkOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmdWxsUmVxdWVzdFhociA9IHRoaXMuX21hbmFnZXIuZ2V0UmVxdWVzdFhocihmdWxsUmVxdWVzdFhocklkKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZ2V0UmVzcG9uc2VIZWFkZXIgPSBuYW1lID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdWxsUmVxdWVzdFhoci5nZXRSZXNwb25zZUhlYWRlcihuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxsb3dSYW5nZVJlcXVlc3RzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3VnZ2VzdGVkTGVuZ3RoCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSAoMCwgX25ldHdvcmtfdXRpbHMudmFsaWRhdGVSYW5nZVJlcXVlc3RDYXBhYmlsaXRpZXMpKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldFJlc3BvbnNlSGVhZGVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNIdHRwOiB0aGlzLl9tYW5hZ2VyLmlzSHR0cCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlQ2h1bmtTaXplOiB0aGlzLl9yYW5nZUNodW5rU2l6ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVSYW5nZTogdGhpcy5fZGlzYWJsZVJhbmdlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWxsb3dSYW5nZVJlcXVlc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1JhbmdlU3VwcG9ydGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZW50TGVuZ3RoID0gc3VnZ2VzdGVkTGVuZ3RoIHx8IHRoaXMuX2NvbnRlbnRMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZpbGVuYW1lID0gKDAsIF9uZXR3b3JrX3V0aWxzLmV4dHJhY3RGaWxlbmFtZUZyb21IZWFkZXIpKGdldFJlc3BvbnNlSGVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX21hbmFnZXIuYWJvcnRSZXF1ZXN0KGZ1bGxSZXF1ZXN0WGhySWQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hlYWRlcnNSZWNlaXZlZENhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25Eb25lKGRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSB0aGlzLl9yZXF1ZXN0cy5zaGlmdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3RDYXBhYmlsaXR5LnJlc29sdmUoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZGF0YS5jaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkQ2h1bmtzLnB1c2goZGF0YS5jaHVuayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9jYWNoZWRDaHVua3MubGVuZ3RoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgb2YgdGhpcy5fcmVxdWVzdHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3RDYXBhYmlsaXR5LnJlc29sdmUoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB1bmRlZmluZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMubGVuZ3RoID0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX29uRXJyb3Ioc3RhdHVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3N0b3JlZEVycm9yID0gKDAsIF9uZXR3b3JrX3V0aWxzLmNyZWF0ZVJlc3BvbnNlU3RhdHVzRXJyb3IpKHN0YXR1cywgdGhpcy5fdXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc1JlY2VpdmVkQ2FwYWJpbGl0eS5yZWplY3QodGhpcy5fc3RvcmVkRXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlcXVlc3RDYXBhYmlsaXR5IG9mIHRoaXMuX3JlcXVlc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0Q2FwYWJpbGl0eS5yZWplY3QodGhpcy5fc3RvcmVkRXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZENodW5rcy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25Qcm9ncmVzcyhldnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJG9uUHJvZ3Jlc3M7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRvblByb2dyZXNzID0gdGhpcy5vblByb2dyZXNzKSA9PT0gbnVsbCB8fCBfdGhpcyRvblByb2dyZXNzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRvblByb2dyZXNzLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBldnQubG9hZGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWw6IGV2dC5sZW5ndGhDb21wdXRhYmxlID8gZXZ0LnRvdGFsIDogdGhpcy5fY29udGVudExlbmd0aAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGZpbGVuYW1lKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fZmlsZW5hbWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1JhbmdlU3VwcG9ydGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5faXNSYW5nZVN1cHBvcnRlZDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGlzU3RyZWFtaW5nU3VwcG9ydGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5faXNTdHJlYW1pbmdTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBjb250ZW50TGVuZ3RoKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fY29udGVudExlbmd0aDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGhlYWRlcnNSZWFkeSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2hlYWRlcnNSZWNlaXZlZENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgcmVhZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3JlZEVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyB0aGlzLl9zdG9yZWRFcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fY2FjaGVkQ2h1bmtzLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gdGhpcy5fY2FjaGVkQ2h1bmtzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLnB1c2gocmVxdWVzdENhcGFiaWxpdHkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc1JlY2VpdmVkQ2FwYWJpbGl0eS5yZWplY3QocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fbWFuYWdlci5pc1BlbmRpbmdSZXF1ZXN0KHRoaXMuX2Z1bGxSZXF1ZXN0SWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tYW5hZ2VyLmFib3J0UmVxdWVzdCh0aGlzLl9mdWxsUmVxdWVzdElkKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUERGTmV0d29ya1N0cmVhbVJhbmdlUmVxdWVzdFJlYWRlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobWFuYWdlciwgYmVnaW4sIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tYW5hZ2VyID0gbWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYXJncyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uRG9uZTogdGhpcy5fb25Eb25lLmJpbmQodGhpcyksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvbkVycm9yOiB0aGlzLl9vbkVycm9yLmJpbmQodGhpcyksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvblByb2dyZXNzOiB0aGlzLl9vblByb2dyZXNzLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdXJsID0gbWFuYWdlci51cmw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RJZCA9IG1hbmFnZXIucmVxdWVzdFJhbmdlKGJlZ2luLCBlbmQsIGFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9xdWV1ZWRDaHVuayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RvbmUgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25Qcm9ncmVzcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25DbG9zZWQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY2xvc2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRvbkNsb3NlZDsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJG9uQ2xvc2VkID0gdGhpcy5vbkNsb3NlZCkgPT09IG51bGwgfHwgX3RoaXMkb25DbG9zZWQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJG9uQ2xvc2VkLmNhbGwodGhpcywgdGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9vbkRvbmUoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVuayA9IGRhdGEuY2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSA9IHRoaXMuX3JlcXVlc3RzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0Q2FwYWJpbGl0eS5yZXNvbHZlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogY2h1bmssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmsgPSBjaHVuazsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25FcnJvcihzdGF0dXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSAoMCwgX25ldHdvcmtfdXRpbHMuY3JlYXRlUmVzcG9uc2VTdGF0dXNFcnJvcikoc3RhdHVzLCB0aGlzLl91cmwpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlcXVlc3RDYXBhYmlsaXR5IG9mIHRoaXMuX3JlcXVlc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0Q2FwYWJpbGl0eS5yZWplY3QodGhpcy5fc3RvcmVkRXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX29uUHJvZ3Jlc3MoZXZ0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc1N0cmVhbWluZ1N1cHBvcnRlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJG9uUHJvZ3Jlc3MyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJG9uUHJvZ3Jlc3MyID0gdGhpcy5vblByb2dyZXNzKSA9PT0gbnVsbCB8fCBfdGhpcyRvblByb2dyZXNzMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkb25Qcm9ncmVzczIuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBldnQubG9hZGVkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNTdHJlYW1pbmdTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgcmVhZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3JlZEVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyB0aGlzLl9zdG9yZWRFcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcXVldWVkQ2h1bmsgIT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gdGhpcy5fcXVldWVkQ2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9xdWV1ZWRDaHVuayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLnB1c2gocmVxdWVzdENhcGFiaWxpdHkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fbWFuYWdlci5pc1BlbmRpbmdSZXF1ZXN0KHRoaXMuX3JlcXVlc3RJZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX21hbmFnZXIuYWJvcnRSZXF1ZXN0KHRoaXMuX3JlcXVlc3RJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2xvc2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2MCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkZldGNoU3RyZWFtID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfbmV0d29ya191dGlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTU3KTsKICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNyZWF0ZUZldGNoT3B0aW9ucyhoZWFkZXJzLCB3aXRoQ3JlZGVudGlhbHMsIGFib3J0Q29udHJvbGxlcikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgIG1ldGhvZDogIkdFVCIsCiAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnMsCiAgICAgICAgICAgICAgICAgICAgICAgIHNpZ25hbDogYWJvcnRDb250cm9sbGVyLnNpZ25hbCwKICAgICAgICAgICAgICAgICAgICAgICAgbW9kZTogImNvcnMiLAogICAgICAgICAgICAgICAgICAgICAgICBjcmVkZW50aWFsczogd2l0aENyZWRlbnRpYWxzID8gImluY2x1ZGUiIDogInNhbWUtb3JpZ2luIiwKICAgICAgICAgICAgICAgICAgICAgICAgcmVkaXJlY3Q6ICJmb2xsb3ciCiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNyZWF0ZUhlYWRlcnMoaHR0cEhlYWRlcnMpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWFkZXJzID0gbmV3IEhlYWRlcnMoKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHByb3BlcnR5IGluIGh0dHBIZWFkZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gaHR0cEhlYWRlcnNbcHJvcGVydHldOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodmFsdWUgPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVycy5hcHBlbmQocHJvcGVydHksIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGhlYWRlcnM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRBcnJheUJ1ZmZlcih2YWwpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodmFsIGluc3RhbmNlb2YgVWludDhBcnJheSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsLmJ1ZmZlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHZhbCBpbnN0YW5jZW9mIEFycmF5QnVmZmVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0QXJyYXlCdWZmZXIgLSB1bmV4cGVjdGVkIGRhdGEgZm9ybWF0OiAke3ZhbH1gKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFVpbnQ4QXJyYXkodmFsKS5idWZmZXI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQREZGZXRjaFN0cmVhbSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc291cmNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc291cmNlID0gc291cmNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzSHR0cCA9IC9eaHR0cHM/Oi9pLnRlc3Qoc291cmNlLnVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaHR0cEhlYWRlcnMgPSB0aGlzLmlzSHR0cCAmJiBzb3VyY2UuaHR0cEhlYWRlcnMgfHwge307CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VSZXF1ZXN0UmVhZGVycyA9IFtdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgX3Byb2dyZXNzaXZlRGF0YUxlbmd0aCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9mdWxsUmVxdWVzdFJlYTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgoX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhID0gdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVxdWVzdFJlYSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhLl9sb2FkZWQpID8/IDA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEZ1bGxSZWFkZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKCF0aGlzLl9mdWxsUmVxdWVzdFJlYWRlciwgIlBERkZldGNoU3RyZWFtLmdldEZ1bGxSZWFkZXIgY2FuIG9ubHkgYmUgY2FsbGVkIG9uY2UuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyID0gbmV3IFBERkZldGNoU3RyZWFtUmVhZGVyKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFJhbmdlUmVhZGVyKGJlZ2luLCBlbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuZCA8PSB0aGlzLl9wcm9ncmVzc2l2ZURhdGFMZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlYWRlciA9IG5ldyBQREZGZXRjaFN0cmVhbVJhbmdlUmVhZGVyKHRoaXMsIGJlZ2luLCBlbmQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLnB1c2gocmVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlYWRlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsQWxsUmVxdWVzdHMocmVhc29uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMiA9IHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSA9PT0gbnVsbCB8fCBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLmNhbmNlbChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlYWRlciBvZiB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLnNsaWNlKDApKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkZXIuY2FuY2VsKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkZldGNoU3RyZWFtID0gUERGRmV0Y2hTdHJlYW07CiAgICAgICAgICAgICAgICBjbGFzcyBQREZGZXRjaFN0cmVhbVJlYWRlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc3RyZWFtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3N0cmVhbSA9IHN0cmVhbTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVkID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZmlsZW5hbWUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzb3VyY2UgPSBzdHJlYW0uc291cmNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl93aXRoQ3JlZGVudGlhbHMgPSBzb3VyY2Uud2l0aENyZWRlbnRpYWxzIHx8IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZW50TGVuZ3RoID0gc291cmNlLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc0NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHNvdXJjZS5kaXNhYmxlUmFuZ2UgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlQ2h1bmtTaXplID0gc291cmNlLnJhbmdlQ2h1bmtTaXplOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3JhbmdlQ2h1bmtTaXplICYmICF0aGlzLl9kaXNhYmxlUmFuZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYWJvcnRDb250cm9sbGVyID0gbmV3IEFib3J0Q29udHJvbGxlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZCA9ICFzb3VyY2UuZGlzYWJsZVN0cmVhbTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNSYW5nZVN1cHBvcnRlZCA9ICFzb3VyY2UuZGlzYWJsZVJhbmdlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9oZWFkZXJzID0gY3JlYXRlSGVhZGVycyh0aGlzLl9zdHJlYW0uaHR0cEhlYWRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBzb3VyY2UudXJsOwogICAgICAgICAgICAgICAgICAgICAgICBmZXRjaCh1cmwsIGNyZWF0ZUZldGNoT3B0aW9ucyh0aGlzLl9oZWFkZXJzLCB0aGlzLl93aXRoQ3JlZGVudGlhbHMsIHRoaXMuX2Fib3J0Q29udHJvbGxlcikpLnRoZW4ocmVzcG9uc2UgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCEoMCwgX25ldHdvcmtfdXRpbHMudmFsaWRhdGVSZXNwb25zZVN0YXR1cykocmVzcG9uc2Uuc3RhdHVzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93ICgwLCBfbmV0d29ya191dGlscy5jcmVhdGVSZXNwb25zZVN0YXR1c0Vycm9yKShyZXNwb25zZS5zdGF0dXMsIHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkZXIgPSByZXNwb25zZS5ib2R5LmdldFJlYWRlcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc0NhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZ2V0UmVzcG9uc2VIZWFkZXIgPSBuYW1lID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzcG9uc2UuaGVhZGVycy5nZXQobmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFsbG93UmFuZ2VSZXF1ZXN0cywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWdnZXN0ZWRMZW5ndGgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSAoMCwgX25ldHdvcmtfdXRpbHMudmFsaWRhdGVSYW5nZVJlcXVlc3RDYXBhYmlsaXRpZXMpKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXRSZXNwb25zZUhlYWRlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0h0dHA6IHRoaXMuX3N0cmVhbS5pc0h0dHAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2VDaHVua1NpemU6IHRoaXMuX3JhbmdlQ2h1bmtTaXplLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVSYW5nZTogdGhpcy5fZGlzYWJsZVJhbmdlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQgPSBhbGxvd1JhbmdlUmVxdWVzdHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZW50TGVuZ3RoID0gc3VnZ2VzdGVkTGVuZ3RoIHx8IHRoaXMuX2NvbnRlbnRMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9maWxlbmFtZSA9ICgwLCBfbmV0d29ya191dGlscy5leHRyYWN0RmlsZW5hbWVGcm9tSGVhZGVyKShnZXRSZXNwb25zZUhlYWRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX2lzU3RyZWFtaW5nU3VwcG9ydGVkICYmIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbmNlbChuZXcgX3V0aWwuQWJvcnRFeGNlcHRpb24oIlN0cmVhbWluZyBpcyBkaXNhYmxlZC4iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pLmNhdGNoKHRoaXMuX2hlYWRlcnNDYXBhYmlsaXR5LnJlamVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25Qcm9ncmVzcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBoZWFkZXJzUmVhZHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9oZWFkZXJzQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgZmlsZW5hbWUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9maWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGNvbnRlbnRMZW5ndGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9jb250ZW50TGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNSYW5nZVN1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2lzU3RyZWFtaW5nU3VwcG9ydGVkOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkb25Qcm9ncmVzczsKICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgdGhpcy5faGVhZGVyc0NhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBhd2FpdCB0aGlzLl9yZWFkZXIucmVhZCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlZCArPSB2YWx1ZS5ieXRlTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkb25Qcm9ncmVzcyA9IHRoaXMub25Qcm9ncmVzcykgPT09IG51bGwgfHwgX3RoaXMkb25Qcm9ncmVzcyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkb25Qcm9ncmVzcy5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRlZDogdGhpcy5fbG9hZGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWw6IHRoaXMuX2NvbnRlbnRMZW5ndGgKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZ2V0QXJyYXlCdWZmZXIodmFsdWUpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3JlYWRlcjsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9yZWFkZXIgPSB0aGlzLl9yZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9yZWFkZXIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9yZWFkZXIuY2FuY2VsKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Fib3J0Q29udHJvbGxlci5hYm9ydCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBERkZldGNoU3RyZWFtUmFuZ2VSZWFkZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHN0cmVhbSwgYmVnaW4sIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdHJlYW0gPSBzdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlZCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNvdXJjZSA9IHN0cmVhbS5zb3VyY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3dpdGhDcmVkZW50aWFscyA9IHNvdXJjZS53aXRoQ3JlZGVudGlhbHMgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZCA9ICFzb3VyY2UuZGlzYWJsZVN0cmVhbTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYWJvcnRDb250cm9sbGVyID0gbmV3IEFib3J0Q29udHJvbGxlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9oZWFkZXJzID0gY3JlYXRlSGVhZGVycyh0aGlzLl9zdHJlYW0uaHR0cEhlYWRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9oZWFkZXJzLmFwcGVuZCgiUmFuZ2UiLCBgYnl0ZXM9JHtiZWdpbn0tJHtlbmQgLSAxfWApOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBzb3VyY2UudXJsOwogICAgICAgICAgICAgICAgICAgICAgICBmZXRjaCh1cmwsIGNyZWF0ZUZldGNoT3B0aW9ucyh0aGlzLl9oZWFkZXJzLCB0aGlzLl93aXRoQ3JlZGVudGlhbHMsIHRoaXMuX2Fib3J0Q29udHJvbGxlcikpLnRoZW4ocmVzcG9uc2UgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCEoMCwgX25ldHdvcmtfdXRpbHMudmFsaWRhdGVSZXNwb25zZVN0YXR1cykocmVzcG9uc2Uuc3RhdHVzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93ICgwLCBfbmV0d29ya191dGlscy5jcmVhdGVSZXNwb25zZVN0YXR1c0Vycm9yKShyZXNwb25zZS5zdGF0dXMsIHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkQ2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkZXIgPSByZXNwb25zZS5ib2R5LmdldFJlYWRlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB9KS5jYXRjaCh0aGlzLl9yZWFkQ2FwYWJpbGl0eS5yZWplY3QpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNTdHJlYW1pbmdTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgcmVhZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJG9uUHJvZ3Jlc3MyOwogICAgICAgICAgICAgICAgICAgICAgICBhd2FpdCB0aGlzLl9yZWFkQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGF3YWl0IHRoaXMuX3JlYWRlci5yZWFkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVkICs9IHZhbHVlLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRvblByb2dyZXNzMiA9IHRoaXMub25Qcm9ncmVzcykgPT09IG51bGwgfHwgX3RoaXMkb25Qcm9ncmVzczIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJG9uUHJvZ3Jlc3MyLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiB0aGlzLl9sb2FkZWQKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZ2V0QXJyYXlCdWZmZXIodmFsdWUpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3JlYWRlcjI7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfcmVhZGVyMiA9IHRoaXMuX3JlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX3JlYWRlcjIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9yZWFkZXIyLmNhbmNlbChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9hYm9ydENvbnRyb2xsZXIuYWJvcnQoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2MSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlRleHRMYXllclJlbmRlclRhc2sgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICBleHBvcnRzLnJlbmRlclRleHRMYXllciA9IHJlbmRlclRleHRMYXllcjsKICAgICAgICAgICAgICAgIGV4cG9ydHMudXBkYXRlVGV4dExheWVyID0gdXBkYXRlVGV4dExheWVyOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfZGlzcGxheV91dGlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQyKTsKICAgICAgICAgICAgICAgIGNvbnN0IE1BWF9URVhUX0RJVlNfVE9fUkVOREVSID0gMTAwMDAwOwogICAgICAgICAgICAgICAgY29uc3QgREVGQVVMVF9GT05UX1NJWkUgPSAzMDsKICAgICAgICAgICAgICAgIGNvbnN0IERFRkFVTFRfRk9OVF9BU0NFTlQgPSAwLjg7CiAgICAgICAgICAgICAgICBjb25zdCBhc2NlbnRDYWNoZSA9IG5ldyBNYXAoKTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldEN0eChzaXplLCBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCkgewogICAgICAgICAgICAgICAgICAgIGxldCBjdHg7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkICYmIF91dGlsLkZlYXR1cmVUZXN0LmlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eCA9IG5ldyBPZmZzY3JlZW5DYW52YXMoc2l6ZSwgc2l6ZSkuZ2V0Q29udGV4dCgiMmQiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbHBoYTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FudmFzID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiY2FudmFzIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcy53aWR0aCA9IGNhbnZhcy5oZWlnaHQgPSBzaXplOwogICAgICAgICAgICAgICAgICAgICAgICBjdHggPSBjYW52YXMuZ2V0Q29udGV4dCgiMmQiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbHBoYTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBjdHg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRBc2NlbnQoZm9udEZhbWlseSwgaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjYWNoZWRBc2NlbnQgPSBhc2NlbnRDYWNoZS5nZXQoZm9udEZhbWlseSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGNhY2hlZEFzY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FjaGVkQXNjZW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSBnZXRDdHgoREVGQVVMVF9GT05UX1NJWkUsIGlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkKTsKICAgICAgICAgICAgICAgICAgICBjdHguZm9udCA9IGAke0RFRkFVTFRfRk9OVF9TSVpFfXB4ICR7Zm9udEZhbWlseX1gOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IG1ldHJpY3MgPSBjdHgubWVhc3VyZVRleHQoIiIpOwogICAgICAgICAgICAgICAgICAgIGxldCBhc2NlbnQgPSBtZXRyaWNzLmZvbnRCb3VuZGluZ0JveEFzY2VudDsKICAgICAgICAgICAgICAgICAgICBsZXQgZGVzY2VudCA9IE1hdGguYWJzKG1ldHJpY3MuZm9udEJvdW5kaW5nQm94RGVzY2VudCk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGFzY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByYXRpbyA9IGFzY2VudCAvIChhc2NlbnQgKyBkZXNjZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgYXNjZW50Q2FjaGUuc2V0KGZvbnRGYW1pbHksIHJhdGlvKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmNhbnZhcy53aWR0aCA9IGN0eC5jYW52YXMuaGVpZ2h0ID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJhdGlvOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjdHguc3Ryb2tlU3R5bGUgPSAicmVkIjsKICAgICAgICAgICAgICAgICAgICBjdHguY2xlYXJSZWN0KDAsIDAsIERFRkFVTFRfRk9OVF9TSVpFLCBERUZBVUxUX0ZPTlRfU0laRSk7CiAgICAgICAgICAgICAgICAgICAgY3R4LnN0cm9rZVRleHQoImciLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICBsZXQgcGl4ZWxzID0gY3R4LmdldEltYWdlRGF0YSgwLCAwLCBERUZBVUxUX0ZPTlRfU0laRSwgREVGQVVMVF9GT05UX1NJWkUpLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgZGVzY2VudCA9IDA7CiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IHBpeGVscy5sZW5ndGggLSAxIC0gMzsgaSA+PSAwOyBpIC09IDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBpeGVsc1tpXSA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc2NlbnQgPSBNYXRoLmNlaWwoaSAvIDQgLyBERUZBVUxUX0ZPTlRfU0laRSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjdHguY2xlYXJSZWN0KDAsIDAsIERFRkFVTFRfRk9OVF9TSVpFLCBERUZBVUxUX0ZPTlRfU0laRSk7CiAgICAgICAgICAgICAgICAgICAgY3R4LnN0cm9rZVRleHQoIkEiLCAwLCBERUZBVUxUX0ZPTlRfU0laRSk7CiAgICAgICAgICAgICAgICAgICAgcGl4ZWxzID0gY3R4LmdldEltYWdlRGF0YSgwLCAwLCBERUZBVUxUX0ZPTlRfU0laRSwgREVGQVVMVF9GT05UX1NJWkUpLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgYXNjZW50ID0gMDsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBwaXhlbHMubGVuZ3RoOyBpIDwgaWk7IGkgKz0gNCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGl4ZWxzW2ldID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYXNjZW50ID0gREVGQVVMVF9GT05UX1NJWkUgLSBNYXRoLmZsb29yKGkgLyA0IC8gREVGQVVMVF9GT05UX1NJWkUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3R4LmNhbnZhcy53aWR0aCA9IGN0eC5jYW52YXMuaGVpZ2h0ID0gMDsKICAgICAgICAgICAgICAgICAgICBpZiAoYXNjZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJhdGlvID0gYXNjZW50IC8gKGFzY2VudCArIGRlc2NlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICBhc2NlbnRDYWNoZS5zZXQoZm9udEZhbWlseSwgcmF0aW8pOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmF0aW87CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFzY2VudENhY2hlLnNldChmb250RmFtaWx5LCBERUZBVUxUX0ZPTlRfQVNDRU5UKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gREVGQVVMVF9GT05UX0FTQ0VOVDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGFwcGVuZFRleHQodGFzaywgZ2VvbSwgc3R5bGVzKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dERpdiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInNwYW4iKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXh0RGl2UHJvcGVydGllcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgYW5nbGU6IDAsCiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc1dpZHRoOiAwLAogICAgICAgICAgICAgICAgICAgICAgICBoYXNUZXh0OiBnZW9tLnN0ciAhPT0gIiIsCiAgICAgICAgICAgICAgICAgICAgICAgIGhhc0VPTDogZ2VvbS5oYXNFT0wsCiAgICAgICAgICAgICAgICAgICAgICAgIGZvbnRTaXplOiAwCiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB0YXNrLl90ZXh0RGl2cy5wdXNoKHRleHREaXYpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHR4ID0gX3V0aWwuVXRpbC50cmFuc2Zvcm0odGFzay5fdHJhbnNmb3JtLCBnZW9tLnRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgbGV0IGFuZ2xlID0gTWF0aC5hdGFuMih0eFsxXSwgdHhbMF0pOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0eWxlID0gc3R5bGVzW2dlb20uZm9udE5hbWVdOwogICAgICAgICAgICAgICAgICAgIGlmIChzdHlsZS52ZXJ0aWNhbCkgewogICAgICAgICAgICAgICAgICAgICAgICBhbmdsZSArPSBNYXRoLlBJIC8gMjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udEhlaWdodCA9IE1hdGguaHlwb3QodHhbMl0sIHR4WzNdKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250QXNjZW50ID0gZm9udEhlaWdodCAqIGdldEFzY2VudChzdHlsZS5mb250RmFtaWx5LCB0YXNrLl9pc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCk7CiAgICAgICAgICAgICAgICAgICAgbGV0IGxlZnQsIHRvcDsKICAgICAgICAgICAgICAgICAgICBpZiAoYW5nbGUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGVmdCA9IHR4WzRdOwogICAgICAgICAgICAgICAgICAgICAgICB0b3AgPSB0eFs1XSAtIGZvbnRBc2NlbnQ7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGVmdCA9IHR4WzRdICsgZm9udEFzY2VudCAqIE1hdGguc2luKGFuZ2xlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdG9wID0gdHhbNV0gLSBmb250QXNjZW50ICogTWF0aC5jb3MoYW5nbGUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZUZhY3RvclN0ciA9ICJjYWxjKHZhcigtLXNjYWxlLWZhY3RvcikqIjsKICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXZTdHlsZSA9IHRleHREaXYuc3R5bGU7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRhc2suX2NvbnRhaW5lciA9PT0gdGFzay5fcm9vdENvbnRhaW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICBkaXZTdHlsZS5sZWZ0ID0gYCR7KDEwMCAqIGxlZnQgLyB0YXNrLl9wYWdlV2lkdGgpLnRvRml4ZWQoMil9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpdlN0eWxlLnRvcCA9IGAkeygxMDAgKiB0b3AgLyB0YXNrLl9wYWdlSGVpZ2h0KS50b0ZpeGVkKDIpfSVgOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpdlN0eWxlLmxlZnQgPSBgJHtzY2FsZUZhY3RvclN0cn0ke2xlZnQudG9GaXhlZCgyKX1weClgOwogICAgICAgICAgICAgICAgICAgICAgICBkaXZTdHlsZS50b3AgPSBgJHtzY2FsZUZhY3RvclN0cn0ke3RvcC50b0ZpeGVkKDIpfXB4KWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRpdlN0eWxlLmZvbnRTaXplID0gYCR7c2NhbGVGYWN0b3JTdHJ9JHtmb250SGVpZ2h0LnRvRml4ZWQoMil9cHgpYDsKICAgICAgICAgICAgICAgICAgICBkaXZTdHlsZS5mb250RmFtaWx5ID0gc3R5bGUuZm9udEZhbWlseTsKICAgICAgICAgICAgICAgICAgICB0ZXh0RGl2UHJvcGVydGllcy5mb250U2l6ZSA9IGZvbnRIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgdGV4dERpdi5zZXRBdHRyaWJ1dGUoInJvbGUiLCAicHJlc2VudGF0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgdGV4dERpdi50ZXh0Q29udGVudCA9IGdlb20uc3RyOwogICAgICAgICAgICAgICAgICAgIHRleHREaXYuZGlyID0gZ2VvbS5kaXI7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRhc2suX2ZvbnRJbnNwZWN0b3JFbmFibGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRleHREaXYuZGF0YXNldC5mb250TmFtZSA9IGdlb20uZm9udE5hbWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChhbmdsZSAhPT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICB0ZXh0RGl2UHJvcGVydGllcy5hbmdsZSA9IGFuZ2xlICogKDE4MCAvIE1hdGguUEkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBsZXQgc2hvdWxkU2NhbGVUZXh0ID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgaWYgKGdlb20uc3RyLmxlbmd0aCA+IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc2hvdWxkU2NhbGVUZXh0ID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGdlb20uc3RyICE9PSAiICIgJiYgZ2VvbS50cmFuc2Zvcm1bMF0gIT09IGdlb20udHJhbnNmb3JtWzNdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFic1NjYWxlWCA9IE1hdGguYWJzKGdlb20udHJhbnNmb3JtWzBdKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFic1NjYWxlWSA9IE1hdGguYWJzKGdlb20udHJhbnNmb3JtWzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFic1NjYWxlWCAhPT0gYWJzU2NhbGVZICYmIE1hdGgubWF4KGFic1NjYWxlWCwgYWJzU2NhbGVZKSAvIE1hdGgubWluKGFic1NjYWxlWCwgYWJzU2NhbGVZKSA+IDEuNSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2hvdWxkU2NhbGVUZXh0ID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoc2hvdWxkU2NhbGVUZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRleHREaXZQcm9wZXJ0aWVzLmNhbnZhc1dpZHRoID0gc3R5bGUudmVydGljYWwgPyBnZW9tLmhlaWdodCA6IGdlb20ud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRhc2suX3RleHREaXZQcm9wZXJ0aWVzLnNldCh0ZXh0RGl2LCB0ZXh0RGl2UHJvcGVydGllcyk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRhc2suX2lzUmVhZGFibGVTdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGFzay5fbGF5b3V0VGV4dCh0ZXh0RGl2KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBsYXlvdXQocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICBkaXYsCiAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlLAogICAgICAgICAgICAgICAgICAgICAgICBwcm9wZXJ0aWVzLAogICAgICAgICAgICAgICAgICAgICAgICBjdHgsCiAgICAgICAgICAgICAgICAgICAgICAgIHByZXZGb250U2l6ZSwKICAgICAgICAgICAgICAgICAgICAgICAgcHJldkZvbnRGYW1pbHkKICAgICAgICAgICAgICAgICAgICB9ID0gcGFyYW1zOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICB9ID0gZGl2OwogICAgICAgICAgICAgICAgICAgIGxldCB0cmFuc2Zvcm0gPSAiIjsKICAgICAgICAgICAgICAgICAgICBpZiAocHJvcGVydGllcy5jYW52YXNXaWR0aCAhPT0gMCAmJiBwcm9wZXJ0aWVzLmhhc1RleHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9udEZhbWlseQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gc3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc1dpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9udFNpemUKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHByb3BlcnRpZXM7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwcmV2Rm9udFNpemUgIT09IGZvbnRTaXplIHx8IHByZXZGb250RmFtaWx5ICE9PSBmb250RmFtaWx5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZm9udCA9IGAke2ZvbnRTaXplICogc2NhbGV9cHggJHtmb250RmFtaWx5fWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbXMucHJldkZvbnRTaXplID0gZm9udFNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbXMucHJldkZvbnRGYW1pbHkgPSBmb250RmFtaWx5OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBjdHgubWVhc3VyZVRleHQoZGl2LnRleHRDb250ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtID0gYHNjYWxlWCgke2NhbnZhc1dpZHRoICogc2NhbGUgLyB3aWR0aH0pYDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAocHJvcGVydGllcy5hbmdsZSAhPT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0gPSBgcm90YXRlKCR7cHJvcGVydGllcy5hbmdsZX1kZWcpICR7dHJhbnNmb3JtfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc2Zvcm0ubGVuZ3RoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS50cmFuc2Zvcm0gPSB0cmFuc2Zvcm07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gcmVuZGVyKHRhc2spIHsKICAgICAgICAgICAgICAgICAgICBpZiAodGFzay5fY2FuY2VsZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXh0RGl2cyA9IHRhc2suX3RleHREaXZzOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhcGFiaWxpdHkgPSB0YXNrLl9jYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRleHREaXZzTGVuZ3RoID0gdGV4dERpdnMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0RGl2c0xlbmd0aCA+IE1BWF9URVhUX0RJVlNfVE9fUkVOREVSKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghdGFzay5faXNSZWFkYWJsZVN0cmVhbSkgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHRleHREaXYgb2YgdGV4dERpdnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhc2suX2xheW91dFRleHQodGV4dERpdik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBUZXh0TGF5ZXJSZW5kZXJUYXNrIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihfcmVmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfZ2xvYmFsVGhpcyRGb250SW5zcGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0Q29udGVudFNvdXJjZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dERpdnMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0RGl2UHJvcGVydGllcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHRDb250ZW50SXRlbXNTdHIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdGV4dENvbnRlbnRTb3VyY2UgPSB0ZXh0Q29udGVudFNvdXJjZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNSZWFkYWJsZVN0cmVhbSA9IHRleHRDb250ZW50U291cmNlIGluc3RhbmNlb2YgUmVhZGFibGVTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRhaW5lciA9IHRoaXMuX3Jvb3RDb250YWluZXIgPSBjb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RleHREaXZzID0gdGV4dERpdnMgfHwgW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RleHRDb250ZW50SXRlbXNTdHIgPSB0ZXh0Q29udGVudEl0ZW1zU3RyIHx8IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCA9IGlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mb250SW5zcGVjdG9yRW5hYmxlZCA9ICEhKChfZ2xvYmFsVGhpcyRGb250SW5zcGUgPSBnbG9iYWxUaGlzLkZvbnRJbnNwZWN0b3IpICE9PSBudWxsICYmIF9nbG9iYWxUaGlzJEZvbnRJbnNwZSAhPT0gdm9pZCAwICYmIF9nbG9iYWxUaGlzJEZvbnRJbnNwZS5lbmFibGVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdGV4dERpdlByb3BlcnRpZXMgPSB0ZXh0RGl2UHJvcGVydGllcyB8fCBuZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYW5jZWxlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sYXlvdXRUZXh0UGFyYW1zID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldkZvbnRTaXplOiBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldkZvbnRGYW1pbHk6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXY6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZTogdmlld3BvcnQuc2NhbGUgKiAoZ2xvYmFsVGhpcy5kZXZpY2VQaXhlbFJhdGlvIHx8IDEpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvcGVydGllczogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eDogZ2V0Q3R4KDAsIGlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkKQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlV2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlSGVpZ2h0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlWQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdmlld3BvcnQucmF3RGltczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdHJhbnNmb3JtID0gWzEsIDAsIDAsIC0xLCAtcGFnZVgsIHBhZ2VZICsgcGFnZUhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3BhZ2VXaWR0aCA9IHBhZ2VXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFnZUhlaWdodCA9IHBhZ2VIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfZGlzcGxheV91dGlscy5zZXRMYXllckRpbWVuc2lvbnMpKGNvbnRhaW5lciwgdmlld3BvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYXBhYmlsaXR5LnByb21pc2UuZmluYWxseSgoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sYXlvdXRUZXh0UGFyYW1zID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfSkuY2F0Y2goKCkgPT4ge30pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJvbWlzZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2NhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYW5jZWxlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZWFkZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRlci5jYW5jZWwobmV3IF91dGlsLkFib3J0RXhjZXB0aW9uKCJUZXh0TGF5ZXIgdGFzayBjYW5jZWxsZWQuIikpLmNhdGNoKCgpID0+IHt9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FwYWJpbGl0eS5yZWplY3QobmV3IF91dGlsLkFib3J0RXhjZXB0aW9uKCJUZXh0TGF5ZXIgdGFzayBjYW5jZWxsZWQuIikpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfcHJvY2Vzc0l0ZW1zKGl0ZW1zLCBzdHlsZUNhY2hlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaXRlbSBvZiBpdGVtcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGl0ZW0uc3RyID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXRlbS50eXBlID09PSAiYmVnaW5NYXJrZWRDb250ZW50UHJvcHMiIHx8IGl0ZW0udHlwZSA9PT0gImJlZ2luTWFya2VkQ29udGVudCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFyZW50ID0gdGhpcy5fY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250YWluZXIgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJzcGFuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJtYXJrZWRDb250ZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpdGVtLmlkICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250YWluZXIuc2V0QXR0cmlidXRlKCJpZCIsIGAke2l0ZW0uaWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50LmFwcGVuZCh0aGlzLl9jb250YWluZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXRlbS50eXBlID09PSAiZW5kTWFya2VkQ29udGVudCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGFpbmVyID0gdGhpcy5fY29udGFpbmVyLnBhcmVudE5vZGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdGV4dENvbnRlbnRJdGVtc1N0ci5wdXNoKGl0ZW0uc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZFRleHQodGhpcywgaXRlbSwgc3R5bGVDYWNoZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2xheW91dFRleHQodGV4dERpdikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXh0RGl2UHJvcGVydGllcyA9IHRoaXMuX2xheW91dFRleHRQYXJhbXMucHJvcGVydGllcyA9IHRoaXMuX3RleHREaXZQcm9wZXJ0aWVzLmdldCh0ZXh0RGl2KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbGF5b3V0VGV4dFBhcmFtcy5kaXYgPSB0ZXh0RGl2OwogICAgICAgICAgICAgICAgICAgICAgICBsYXlvdXQodGhpcy5fbGF5b3V0VGV4dFBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0RGl2UHJvcGVydGllcy5oYXNUZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250YWluZXIuYXBwZW5kKHRleHREaXYpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0RGl2UHJvcGVydGllcy5oYXNFT0wpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJyID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiYnIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyLnNldEF0dHJpYnV0ZSgicm9sZSIsICJwcmVzZW50YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRhaW5lci5hcHBlbmQoYnIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9yZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdHlsZUNhY2hlID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2lzUmVhZGFibGVTdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHB1bXAgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGVyLnJlYWQoKS50aGVuKF9yZWYyID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPYmplY3QuYXNzaWduKHN0eWxlQ2FjaGUsIHZhbHVlLnN0eWxlcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Byb2Nlc3NJdGVtcyh2YWx1ZS5pdGVtcywgc3R5bGVDYWNoZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1bXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBjYXBhYmlsaXR5LnJlamVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGVyID0gdGhpcy5fdGV4dENvbnRlbnRTb3VyY2UuZ2V0UmVhZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdW1wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5fdGV4dENvbnRlbnRTb3VyY2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZXMKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLl90ZXh0Q29udGVudFNvdXJjZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Byb2Nlc3NJdGVtcyhpdGVtcywgc3R5bGVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdObyAidGV4dENvbnRlbnRTb3VyY2UiIHBhcmFtZXRlciBzcGVjaWZpZWQuJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY2FwYWJpbGl0eS5wcm9taXNlLnRoZW4oKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGVDYWNoZSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXIodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIHRoaXMuX2NhcGFiaWxpdHkucmVqZWN0KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlRleHRMYXllclJlbmRlclRhc2sgPSBUZXh0TGF5ZXJSZW5kZXJUYXNrOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gcmVuZGVyVGV4dExheWVyKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgIGlmICghcGFyYW1zLnRleHRDb250ZW50U291cmNlICYmIChwYXJhbXMudGV4dENvbnRlbnQgfHwgcGFyYW1zLnRleHRDb250ZW50U3RyZWFtKSkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuZGVwcmVjYXRlZCkoIlRoZSBUZXh0TGF5ZXJSZW5kZXIgYHRleHRDb250ZW50YC9gdGV4dENvbnRlbnRTdHJlYW1gIHBhcmFtZXRlcnMgIiArICJ3aWxsIGJlIHJlbW92ZWQgaW4gdGhlIGZ1dHVyZSwgcGxlYXNlIHVzZSBgdGV4dENvbnRlbnRTb3VyY2VgIGluc3RlYWQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtcy50ZXh0Q29udGVudFNvdXJjZSA9IHBhcmFtcy50ZXh0Q29udGVudCB8fCBwYXJhbXMudGV4dENvbnRlbnRTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLAogICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydAogICAgICAgICAgICAgICAgICAgIH0gPSBwYXJhbXM7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3R5bGUgPSBnZXRDb21wdXRlZFN0eWxlKGNvbnRhaW5lcik7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgdmlzaWJpbGl0eSA9IHN0eWxlLmdldFByb3BlcnR5VmFsdWUoInZpc2liaWxpdHkiKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZUZhY3RvciA9IHBhcnNlRmxvYXQoc3R5bGUuZ2V0UHJvcGVydHlWYWx1ZSgiLS1zY2FsZS1mYWN0b3IiKSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHZpc2liaWxpdHkgPT09ICJ2aXNpYmxlIiAmJiAoIXNjYWxlRmFjdG9yIHx8IE1hdGguYWJzKHNjYWxlRmFjdG9yIC0gdmlld3BvcnQuc2NhbGUpID4gMWUtMTUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIlRoZSBgLS1zY2FsZS1mYWN0b3JgIENTUy12YXJpYWJsZSBtdXN0IGJlIHNldCwgIiArICJ0byB0aGUgc2FtZSB2YWx1ZSBhcyBgdmlld3BvcnQuc2NhbGVgLCAiICsgImVpdGhlciBvbiB0aGUgYGNvbnRhaW5lcmAtZWxlbWVudCBpdHNlbGYgb3IgaGlnaGVyIHVwIGluIHRoZSBET00uIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgVGV4dExheWVyUmVuZGVyVGFzayhwYXJhbXMpOwogICAgICAgICAgICAgICAgICAgIHRhc2suX3JlbmRlcigpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB0YXNrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gdXBkYXRlVGV4dExheWVyKF9yZWYzKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLAogICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgdGV4dERpdnMsCiAgICAgICAgICAgICAgICAgICAgICAgIHRleHREaXZQcm9wZXJ0aWVzLAogICAgICAgICAgICAgICAgICAgICAgICBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCwKICAgICAgICAgICAgICAgICAgICAgICAgbXVzdFJvdGF0ZSA9IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RSZXNjYWxlID0gdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMzsKICAgICAgICAgICAgICAgICAgICBpZiAobXVzdFJvdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuc2V0TGF5ZXJEaW1lbnNpb25zKShjb250YWluZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uOiB2aWV3cG9ydC5yb3RhdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKG11c3RSZXNjYWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IGdldEN0eCgwLCBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlID0gdmlld3BvcnQuc2NhbGUgKiAoZ2xvYmFsVGhpcy5kZXZpY2VQaXhlbFJhdGlvIHx8IDEpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJhbXMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2Rm9udFNpemU6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2Rm9udEZhbWlseTogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpdjogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvcGVydGllczogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGRpdiBvZiB0ZXh0RGl2cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLnByb3BlcnRpZXMgPSB0ZXh0RGl2UHJvcGVydGllcy5nZXQoZGl2KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtcy5kaXYgPSBkaXY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXlvdXQocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTYyICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvckxheWVyID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfdG9vbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0MSk7CiAgICAgICAgICAgICAgICB2YXIgX2ZyZWV0ZXh0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjMpOwogICAgICAgICAgICAgICAgdmFyIF9pbmsgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE2NCk7CiAgICAgICAgICAgICAgICB2YXIgX2Rpc3BsYXlfdXRpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0Mik7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWMob2JqLCBwcml2YXRlU2V0KSB7IF9jaGVja1ByaXZhdGVSZWRlY2xhcmF0aW9uKG9iaiwgcHJpdmF0ZVNldCk7IHByaXZhdGVTZXQuYWRkKG9iaik7IH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9kZWZpbmVQcm9wZXJ0eShvYmosIGtleSwgdmFsdWUpIHsga2V5ID0gX3RvUHJvcGVyd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k7CiAgICAgICAgICAgICAgICB2YXIgX2FsbG93Q2xpY2sgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRQb2ludGVydXAgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRQb2ludGVyZG93biA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9lZGl0b3JzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2hhZFBvaW50ZXJEb3duID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2lzQ2xlYW5pbmdVcCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF91aU1hbmFnZXIgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY2hhbmdlUGFyZW50ID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2NyZWF0ZU5ld0VkaXRvciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9jcmVhdGVBbmRBZGROZXdFZGl0b3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfY2xlYW51cCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgY2xhc3MgQW5ub3RhdGlvbkVkaXRvckxheWVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihvcHRpb25zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfY2xlYW51cCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfY3JlYXRlQW5kQWRkTmV3RWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9jcmVhdGVOZXdFZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2NoYW5nZVBhcmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hY2Nlc3NpYmlsaXR5TWFuYWdlciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYWxsb3dDbGljaywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZFBvaW50ZXJ1cCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5wb2ludGVydXAuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kUG9pbnRlcmRvd24sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMucG9pbnRlcmRvd24uYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2VkaXRvcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBNYXAoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2hhZFBvaW50ZXJEb3duLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2lzQ2xlYW5pbmdVcCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF91aU1hbmFnZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFBbm5vdGF0aW9uRWRpdG9yTGF5ZXIuX2luaXRpYWxpemVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBBbm5vdGF0aW9uRWRpdG9yTGF5ZXIuX2luaXRpYWxpemVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9mcmVldGV4dC5GcmVlVGV4dEVkaXRvci5pbml0aWFsaXplKG9wdGlvbnMubDEwbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfaW5rLklua0VkaXRvci5pbml0aWFsaXplKG9wdGlvbnMubDEwbik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9ucy51aU1hbmFnZXIucmVnaXN0ZXJFZGl0b3JUeXBlcyhbX2ZyZWV0ZXh0LkZyZWVUZXh0RWRpdG9yLCBfaW5rLklua0VkaXRvcl0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3VpTWFuYWdlciwgb3B0aW9ucy51aU1hbmFnZXIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhZ2VJbmRleCA9IG9wdGlvbnMucGFnZUluZGV4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdiA9IG9wdGlvbnMuZGl2OwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2FjY2Vzc2liaWxpdHlNYW5hZ2VyLCBvcHRpb25zLmFjY2Vzc2liaWxpdHlNYW5hZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmFkZExheWVyKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNFbXB0eSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9ycykuc2l6ZSA9PT0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlVG9vbGJhcihtb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS51cGRhdGVUb29sYmFyKG1vZGUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGVNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbW9kZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY2xlYW51cCwgX2NsZWFudXAyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZElua0VkaXRvcklmTmVlZGVkKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGlzYWJsZUNsaWNrKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuYWJsZUNsaWNrKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnVuc2VsZWN0QWxsKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtb2RlICE9PSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5OT05FKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QudG9nZ2xlKCJmcmVlVGV4dEVkaXRpbmciLCBtb2RlID09PSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5GUkVFVEVYVCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QudG9nZ2xlKCJpbmtFZGl0aW5nIiwgbW9kZSA9PT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmhpZGRlbiA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZElua0VkaXRvcklmTmVlZGVkKGlzQ29tbWl0dGluZykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ29tbWl0dGluZyAmJiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuZ2V0TW9kZSgpICE9PSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5JTkspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ29tbWl0dGluZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlZGl0b3IuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5zZXRJbkJhY2tncm91bmQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlZGl0b3IgPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jcmVhdGVBbmRBZGROZXdFZGl0b3IsIF9jcmVhdGVBbmRBZGROZXdFZGl0b3IyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFg6IDAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2V0SW5CYWNrZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEVkaXRpbmdTdGF0ZShpc0VkaXRpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnNldEVkaXRpbmdTdGF0ZShpc0VkaXRpbmcpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRDb21tYW5kcyhwYXJhbXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmFkZENvbW1hbmRzKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGVuYWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUucG9pbnRlckV2ZW50cyA9ICJhdXRvIjsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmVuYWJsZUVkaXRpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkaXNhYmxlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS5wb2ludGVyRXZlbnRzID0gIm5vbmUiOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuZGlzYWJsZUVkaXRpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jbGVhbnVwLCBfY2xlYW51cDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmhpZGRlbiA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0QWN0aXZlRWRpdG9yKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50QWN0aXZlID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldEFjdGl2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudEFjdGl2ZSA9PT0gZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnNldEFjdGl2ZUVkaXRvcihlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmFibGVDbGljaygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYWRkRXZlbnRMaXN0ZW5lcigicG9pbnRlcmRvd24iLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kUG9pbnRlcmRvd24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYWRkRXZlbnRMaXN0ZW5lcigicG9pbnRlcnVwIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZFBvaW50ZXJ1cCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkaXNhYmxlQ2xpY2soKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZFBvaW50ZXJkb3duKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJ1cCIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRQb2ludGVydXApKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXR0YWNoKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLnNldChlZGl0b3IuaWQsIGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRldGFjaChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9jbGFzc1ByaXZhdGVGaWVsZEdldDI7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9ycykuZGVsZXRlKGVkaXRvci5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIChfY2xhc3NQcml2YXRlRmllbGRHZXQyID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hY2Nlc3NpYmlsaXR5TWFuYWdlcikpID09PSBudWxsIHx8IF9jbGFzc1ByaXZhdGVGaWVsZEdldDIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9jbGFzc1ByaXZhdGVGaWVsZEdldDIucmVtb3ZlUG9pbnRlckluVGV4dExheWVyKGVkaXRvci5jb250ZW50RGl2KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikucmVtb3ZlRWRpdG9yKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGV0YWNoKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5kaXYuc3R5bGUuZGlzcGxheSA9ICJub25lIjsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0VGltZW91dCgoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuZGl2LnN0eWxlLmRpc3BsYXkgPSAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5kaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuaXNBdHRhY2hlZFRvRE9NID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9jdW1lbnQuYWN0aXZlRWxlbWVudCA9PT0gZG9jdW1lbnQuYm9keSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5mb2N1c01haW5Db250YWluZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0NsZWFuaW5nVXApKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZElua0VkaXRvcklmTmVlZGVkKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NoYW5nZVBhcmVudCwgX2NoYW5nZVBhcmVudDIpLmNhbGwodGhpcywgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmFkZEVkaXRvcihlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmF0dGFjaChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWVkaXRvci5pc0F0dGFjaGVkVG9ET00pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRpdiA9IGVkaXRvci5yZW5kZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFwcGVuZChkaXYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmlzQXR0YWNoZWRUb0RPTSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb3ZlRWRpdG9ySW5ET00oZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLm9uY2VBZGRlZCgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuYWRkVG9Bbm5vdGF0aW9uU3RvcmFnZShlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBtb3ZlRWRpdG9ySW5ET00oZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfY2xhc3NQcml2YXRlRmllbGRHZXQzOwogICAgICAgICAgICAgICAgICAgICAgICAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MyA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWNjZXNzaWJpbGl0eU1hbmFnZXIpKSA9PT0gbnVsbCB8fCBfY2xhc3NQcml2YXRlRmllbGRHZXQzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfY2xhc3NQcml2YXRlRmllbGRHZXQzLm1vdmVFbGVtZW50SW5ET00odGhpcy5kaXYsIGVkaXRvci5kaXYsIGVkaXRvci5jb250ZW50RGl2LCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkT3JSZWJ1aWxkKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLm5lZWRzVG9CZVJlYnVpbHQoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnJlYnVpbGQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkQU5ld0VkaXRvcihlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRPclJlYnVpbGQoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdW5kbyA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRDb21tYW5kcyh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bmRvLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZFVuZG9hYmxlRWRpdG9yKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjbWQgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZE9yUmVidWlsZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bmRvID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENvbW1hbmRzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuZG8sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYzogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE5leHRJZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5nZXRJZCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXNlcmlhbGl6ZShkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZGF0YS5hbm5vdGF0aW9uVHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5GUkVFVEVYVDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2ZyZWV0ZXh0LkZyZWVUZXh0RWRpdG9yLmRlc2VyaWFsaXplKGRhdGEsIHRoaXMsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JUeXBlLklOSzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2luay5JbmtFZGl0b3IuZGVzZXJpYWxpemUoZGF0YSwgdGhpcywgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0U2VsZWN0ZWQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5zZXRTZWxlY3RlZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0b2dnbGVTZWxlY3RlZChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnRvZ2dsZVNlbGVjdGVkKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzU2VsZWN0ZWQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuaXNTZWxlY3RlZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1bnNlbGVjdChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnVuc2VsZWN0KGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBvaW50ZXJ1cChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5idXR0b24gIT09IDAgfHwgZXZlbnQuY3RybEtleSAmJiBpc01hYykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50YXJnZXQgIT09IHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2hhZFBvaW50ZXJEb3duKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGFkUG9pbnRlckRvd24sIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbG93Q2xpY2spKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2FsbG93Q2xpY2ssIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NyZWF0ZUFuZEFkZE5ld0VkaXRvciwgX2NyZWF0ZUFuZEFkZE5ld0VkaXRvcjIpLmNhbGwodGhpcywgZXZlbnQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwb2ludGVyZG93bihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5idXR0b24gIT09IDAgfHwgZXZlbnQuY3RybEtleSAmJiBpc01hYykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50YXJnZXQgIT09IHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9oYWRQb2ludGVyRG93biwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVkaXRvciA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5nZXRBY3RpdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9hbGxvd0NsaWNrLCAhZWRpdG9yIHx8IGVkaXRvci5pc0VtcHR5KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkcm9wKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gZXZlbnQuZGF0YVRyYW5zZmVyLmdldERhdGEoInRleHQvcGxhaW4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9yID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldEVkaXRvcihpZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQucHJldmVudERlZmF1bHQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuZGF0YVRyYW5zZmVyLmRyb3BFZmZlY3QgPSAibW92ZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NoYW5nZVBhcmVudCwgX2NoYW5nZVBhcmVudDIpLmNhbGwodGhpcywgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IHRoaXMuZGl2LmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmRYID0gZXZlbnQuY2xpZW50WCAtIHJlY3QueDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZW5kWSA9IGV2ZW50LmNsaWVudFkgLSByZWN0Lnk7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci50cmFuc2xhdGUoZW5kWCAtIGVkaXRvci5zdGFydFgsIGVuZFkgLSBlZGl0b3Iuc3RhcnRZKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb3ZlRWRpdG9ySW5ET00oZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmRpdi5mb2N1cygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkcmFnb3ZlcihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBldmVudC5wcmV2ZW50RGVmYXVsdCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCgoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NCA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5nZXRBY3RpdmUoKSkgPT09IG51bGwgfHwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NC5wYXJlbnQpID09PSB0aGlzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuc2V0QWN0aXZlRWRpdG9yKG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9ycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfY2xhc3NQcml2YXRlRmllbGRHZXQ1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF9jbGFzc1ByaXZhdGVGaWVsZEdldDUgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjY2Vzc2liaWxpdHlNYW5hZ2VyKSkgPT09IG51bGwgfHwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NS5yZW1vdmVQb2ludGVySW5UZXh0TGF5ZXIoZWRpdG9yLmNvbnRlbnREaXYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnNldFBhcmVudChudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5pc0F0dGFjaGVkVG9ET00gPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5kaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5yZW1vdmVMYXllcih0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZpZXdwb3J0ID0gdmlld3BvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfZGlzcGxheV91dGlscy5zZXRMYXllckRpbWVuc2lvbnMpKHRoaXMuZGl2LCB2aWV3cG9ydCk7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdG9vbHMuYmluZEV2ZW50cykodGhpcywgdGhpcy5kaXYsIFsiZHJhZ292ZXIiLCAiZHJvcCJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldEVkaXRvcnModGhpcy5wYWdlSW5kZXgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudXBkYXRlTW9kZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGUoX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmNvbW1pdE9yUmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudmlld3BvcnQgPSB2aWV3cG9ydDsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF9kaXNwbGF5X3V0aWxzLnNldExheWVyRGltZW5zaW9ucykodGhpcy5kaXYsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uOiB2aWV3cG9ydC5yb3RhdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51cGRhdGVNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwYWdlRGltZW5zaW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdGhpcy52aWV3cG9ydC5yYXdEaW1zOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3BhZ2VXaWR0aCwgcGFnZUhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yTGF5ZXIgPSBBbm5vdGF0aW9uRWRpdG9yTGF5ZXI7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2hhbmdlUGFyZW50MihlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgX2VkaXRvciRwYXJlbnQ7CiAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvci5wYXJlbnQgPT09IHRoaXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0aGlzLmF0dGFjaChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIChfZWRpdG9yJHBhcmVudCA9IGVkaXRvci5wYXJlbnQpID09PSBudWxsIHx8IF9lZGl0b3IkcGFyZW50ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfZWRpdG9yJHBhcmVudC5kZXRhY2goZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2V0UGFyZW50KHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGlmIChlZGl0b3IuZGl2ICYmIGVkaXRvci5pc0F0dGFjaGVkVG9ET00pIHsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmRpdi5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYXBwZW5kKGVkaXRvci5kaXYpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jcmVhdGVOZXdFZGl0b3IyKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldE1vZGUoKSkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JUeXBlLkZSRUVURVhUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBfZnJlZXRleHQuRnJlZVRleHRFZGl0b3IocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5JTks6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF9pbmsuSW5rRWRpdG9yKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NyZWF0ZUFuZEFkZE5ld0VkaXRvcjIoZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IHRoaXMuZ2V0TmV4dElkKCk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9yID0gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlTmV3RWRpdG9yLCBfY3JlYXRlTmV3RWRpdG9yMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmVudDogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgIHg6IGV2ZW50Lm9mZnNldFgsCiAgICAgICAgICAgICAgICAgICAgICAgIHk6IGV2ZW50Lm9mZnNldFksCiAgICAgICAgICAgICAgICAgICAgICAgIHVpTWFuYWdlcjogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gZWRpdG9yOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NsZWFudXAyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaXNDbGVhbmluZ1VwLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlZGl0b3IuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9pc0NsZWFuaW5nVXAsIGZhbHNlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShBbm5vdGF0aW9uRWRpdG9yTGF5ZXIsICJfaW5pdGlhbGl6ZWQiLCBmYWxzZSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2MyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkZyZWVUZXh0RWRpdG9yID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfdG9vbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0MSk7CiAgICAgICAgICAgICAgICB2YXIgX2VkaXRvciA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQwKTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyhvYmosIHByaXZhdGVTZXQpIHsgX2NoZWNrUHJpdmF0ZVJlZGVjbGFyYXRpb24ob2JqLCBwcml2YXRlU2V0KTsgcHJpdmF0ZVNldC5hZGQob2JqKTsgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2RlZmluZVByb3BlcnR5KG9iaiwga2V5LCB2YWx1ZSkgeyBrZXkgPSBfdG9Qcm9wZXJ0eUtleShrZXkpOyBpZiAoa2V5IGluIG9iaikg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dG9yRGl2Rm9jdXMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRFZGl0b3JEaXZJbnB1dCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9ib3VuZEVkaXRvckRpdktleWRvd24gPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY29sb3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY29udGVudCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9lZGl0b3JEaXZJZCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9oYXNBbHJlYWR5QmVlbkNvbW1pdHRlZCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9mb250U2l6ZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF91cGRhdGVGb250U2l6ZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF91cGRhdGVDb2xvciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9leHRyYWN0VGV4dCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZXRFZGl0b3JEaW1lbnNpb25zID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBjbGFzcyBGcmVlVGV4dEVkaXRvciBleHRlbmRzIF9lZGl0b3IuQW5ub3RhdGlvbkVkaXRvciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC4uLnBhcmFtcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6ICJmcmVlVGV4dEVkaXRvciIKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc2V0RWRpdG9yRGltZW5zaW9ucyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZXh0cmFjdFRleHQpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3VwZGF0ZUNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF91cGRhdGVGb250U2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZEVkaXRvckRpdkJsdXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuZWRpdG9yRGl2Qmx1ci5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRFZGl0b3JEaXZGb2N1cywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5lZGl0b3JEaXZGb2N1cy5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRFZGl0b3JEaXZJbnB1dCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5lZGl0b3JEaXZJbnB1dC5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRFZGl0b3JEaXZLZXlkb3duLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLmVkaXRvckRpdktleWRvd24uYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2NvbG9yLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9jb250ZW50LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAiIgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2VkaXRvckRpdklkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBgJHt0aGlzLmlkfS1lZGl0b3JgCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfaGFzQWxyZWFkeUJlZW5Db21taXR0ZWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZm9udFNpemUsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb2xvciwgcGFyYW1zLmNvbG9yIHx8IEZyZWVUZXh0RWRpdG9yLl9kZWZhdWx0Q29sb3IgfHwgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9kZWZhdWx0TGluZUNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9mb250U2l6ZSwgcGFyYW1zLmZvbnRTaXplIHx8IEZyZWVUZXh0RWRpdG9yLl9kZWZhdWx0Rm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgaW5pdGlhbGl6ZShsMTBuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2wxMG5Qcm9taXNlID0gbmV3IE1hcChbImZyZWVfdGV4dDJfZGVmYXVsdF9jb250ZW50IiwgImVkaXRvcl9mcmVlX3RleHQyX2FyaWFfbGFiZWwiXS5tYXAoc3RyID0+IFtzdHIsIGwxMG4uZ2V0KHN0cildKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0eWxlID0gZ2V0Q29tcHV0ZWRTdHlsZShkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pbnRlcm5hbFBhZGRpbmcgPSBwYXJzZUZsb2F0KHN0eWxlLmdldFByb3BlcnR5VmFsdWUoIi0tZnJlZXRleHQtcGFkZGluZyIpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHVwZGF0ZURlZmF1bHRQYXJhbXModHlwZSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLkZSRUVURVhUX1NJWkU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRnJlZVRleHRFZGl0b3IuX2RlZmF1bHRGb250U2l6ZSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9DT0xPUjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBGcmVlVGV4dEVkaXRvci5fZGVmYXVsdENvbG9yID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlUGFyYW1zKHR5cGUsIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9TSVpFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3VwZGF0ZUZvbnRTaXplLCBfdXBkYXRlRm9udFNpemUyKS5jYWxsKHRoaXMsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfQ09MT1I6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlQ29sb3IsIF91cGRhdGVDb2xvcjIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXQgZGVmYXVsdFByb3BlcnRpZXNUb1VwZGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfU0laRSwgRnJlZVRleHRFZGl0b3IuX2RlZmF1bHRGb250U2l6ZV0sIFtfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9DT0xPUiwgRnJlZVRleHRFZGl0b3IuX2RlZmF1bHRDb2xvciB8fCBfZWRpdG9yLkFubm90YXRpb25FZGl0b3IuX2RlZmF1bHRMaW5lQ29sb3JdXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHByb3BlcnRpZXNUb1VwZGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfU0laRSwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9mb250U2l6ZSldLCBbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfQ09MT1IsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29sb3IpXV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEluaXRpYWxUcmFuc2xhdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSB0aGlzLnBhcmVudFNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gWy1GcmVlVGV4dEVkaXRvci5faW50ZXJuYWxQYWRkaW5nICogc2NhbGUsIC0oRnJlZVRleHRFZGl0b3IuX2ludGVybmFsUGFkZGluZyArIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZm9udFNpemUpKSAqIHNjYWxlXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVidWlsZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVidWlsZCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kaXYgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNBdHRhY2hlZFRvRE9NKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5hZGQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5hYmxlRWRpdE1vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzSW5FZGl0TW9kZSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0RWRpdGluZ1N0YXRlKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQudXBkYXRlVG9vbGJhcihfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5GUkVFVEVYVCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyLmVuYWJsZUVkaXRNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3ZlcmxheURpdi5jbGFzc0xpc3QucmVtb3ZlKCJlbmFibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmNvbnRlbnRFZGl0YWJsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmRyYWdnYWJsZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5yZW1vdmVBdHRyaWJ1dGUoImFyaWEtYWN0aXZlZGVzY2VuZGFudCIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5hZGRFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEVkaXRvckRpdktleWRvd24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuYWRkRXZlbnRMaXN0ZW5lcigiZm9jdXMiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kRWRpdG9yRGl2Rm9jdXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuYWRkRXZlbnRMaXN0ZW5lcigiYmx1ciIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRFZGl0b3JEaXZCbHVyKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmFkZEV2ZW50TGlzdGVuZXIoImlucHV0IiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEVkaXRvckRpdklucHV0KSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRpc2FibGVFZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmlzSW5FZGl0TW9kZSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0RWRpdGluZ1N0YXRlKHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5kaXNhYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vdmVybGF5RGl2LmNsYXNzTGlzdC5hZGQoImVuYWJsZWQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuY29udGVudEVkaXRhYmxlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnNldEF0dHJpYnV0ZSgiYXJpYS1hY3RpdmVkZXNjZW5kYW50IiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JEaXZJZCkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5kcmFnZ2FibGUgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5yZW1vdmVFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEVkaXRvckRpdktleWRvd24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZm9jdXMiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kRWRpdG9yRGl2Rm9jdXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYucmVtb3ZlRXZlbnRMaXN0ZW5lcigiYmx1ciIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRFZGl0b3JEaXZCbHVyKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LnJlbW92ZUV2ZW50TGlzdGVuZXIoImlucHV0IiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEVkaXRvckRpdklucHV0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmZvY3VzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXZlbnRTY3JvbGw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmRpdi5jbGFzc0xpc3QuYWRkKCJmcmVlVGV4dEVkaXRpbmciKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9jdXNpbihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5mb2N1c2luKGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50LnRhcmdldCAhPT0gdGhpcy5lZGl0b3JEaXYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmZvY3VzKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25jZUFkZGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy53aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuZm9jdXMoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNFbXB0eSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICF0aGlzLmVkaXRvckRpdiB8fCB0aGlzLmVkaXRvckRpdi5pbm5lclRleHQudHJpbSgpID09PSAiIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzRWRpdGluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5zZXRFZGl0aW5nU3RhdGUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmRpdi5jbGFzc0xpc3QuYWRkKCJmcmVlVGV4dEVkaXRpbmciKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbW1pdCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmlzSW5FZGl0TW9kZSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oYXNBbHJlYWR5QmVlbkNvbW1pdHRlZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGFzQWxyZWFkeUJlZW5Db21taXR0ZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuYWRkVW5kb2FibGVFZGl0b3IodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXNhYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb250ZW50LCBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9leHRyYWN0VGV4dCwgX2V4dHJhY3RUZXh0MikuY2FsbCh0aGlzKS50cmltRW5kKCkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRFZGl0b3JEaW1lbnNpb25zLCBfc2V0RWRpdG9yRGltZW5zaW9uczIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNob3VsZEdldEtleWJvYXJkRXZlbnRzKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5pc0luRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZGJsY2xpY2soZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmFibGVFZGl0TW9kZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5mb2N1cygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBrZXlkb3duKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50YXJnZXQgPT09IHRoaXMuZGl2ICYmIGV2ZW50LmtleSA9PT0gIkVudGVyIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmFibGVFZGl0TW9kZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuZm9jdXMoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlZGl0b3JEaXZLZXlkb3duKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIEZyZWVUZXh0RWRpdG9yLl9rZXlib2FyZE1hbmFnZXIuZXhlYyh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGVkaXRvckRpdkZvY3VzKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZWRpdG9yRGl2Qmx1cihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzRWRpdGluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlZGl0b3JEaXZJbnB1dChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5kaXYuY2xhc3NMaXN0LnRvZ2dsZSgiZnJlZVRleHRFZGl0aW5nIiwgdGhpcy5pc0VtcHR5KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkaXNhYmxlRWRpdGluZygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuc2V0QXR0cmlidXRlKCJyb2xlIiwgImNvbW1lbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYucmVtb3ZlQXR0cmlidXRlKCJhcmlhLW11bHRpbGluZSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmFibGVFZGl0aW5nKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5zZXRBdHRyaWJ1dGUoInJvbGUiLCAidGV4dGJveCIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5zZXRBdHRyaWJ1dGUoImFyaWEtbXVsdGlsaW5lIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJhc2VYLCBiYXNlWTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMud2lkdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VYID0gdGhpcy54OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFzZVkgPSB0aGlzLnk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVuZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmNsYXNzTmFtZSA9ICJpbnRlcm5hbCI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LnNldEF0dHJpYnV0ZSgiaWQiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvckRpdklkKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlRWRpdGluZygpOwogICAgICAgICAgICAgICAgICAgICAgICBGcmVlVGV4dEVkaXRvci5fbDEwblByb21pc2UuZ2V0KCJlZGl0b3JfZnJlZV90ZXh0Ml9hcmlhX2xhYmVsIikudGhlbihtc2cgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGVkaXRvckRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoX3RoaXMkZWRpdG9yRGl2ID0gdGhpcy5lZGl0b3JEaXYpID09PSBudWxsIHx8IF90aGlzJGVkaXRvckRpdiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZWRpdG9yRGl2LnNldEF0dHJpYnV0ZSgiYXJpYS1sYWJlbCIsIG1zZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBGcmVlVGV4dEVkaXRvci5fbDEwblByb21pc2UuZ2V0KCJmcmVlX3RleHQyX2RlZmF1bHRfY29udGVudCIpLnRoZW4obXNnID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRlZGl0b3JEaXYyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChfdGhpcyRlZGl0b3JEaXYyID0gdGhpcy5lZGl0b3JEaXYpID09PSBudWxsIHx8IF90aGlzJGVkaXRvckRpdjIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGVkaXRvckRpdjIuc2V0QXR0cmlidXRlKCJkZWZhdWx0LWNvbnRlbnQiLCBtc2cpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuY29udGVudEVkaXRhYmxlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZWRpdG9yRGl2OwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5mb250U2l6ZSA9IGBjYWxjKCR7X2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9mb250U2l6ZSl9cHggKiB2YXIoLS1zY2FsZS1mYWN0b3IpKWA7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLmNvbG9yID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb2xvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFwcGVuZCh0aGlzLmVkaXRvckRpdik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3ZlcmxheURpdiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm92ZXJsYXlEaXYuY2xhc3NMaXN0LmFkZCgib3ZlcmxheSIsICJlbmFibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFwcGVuZCh0aGlzLm92ZXJsYXlEaXYpOwogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3Rvb2xzLmJpbmRFdmVudHMpKHRoaXMsIHRoaXMuZGl2LCBbImRibGNsaWNrIiwgImtleWRvd24iXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLndpZHRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFyZW50V2lkdGgsIHBhcmVudEhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldEF0KGJhc2VYICogcGFyZW50V2lkdGgsIGJhc2VZICogcGFyZW50SGVpZ2h0LCB0aGlzLndpZHRoICogcGFyZW50V2lkdGgsIHRoaXMuaGVpZ2h0ICogcGFyZW50SGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbGluZSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbnRlbnQpLnNwbGl0KCJcbiIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGl2ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2LmFwcGVuZChsaW5lID8gZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUobGluZSkgOiBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJiciIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5hcHBlbmQoZGl2KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmRyYWdnYWJsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5jb250ZW50RWRpdGFibGUgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmRyYWdnYWJsZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuY29udGVudEVkaXRhYmxlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBjb250ZW50RGl2KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5lZGl0b3JEaXY7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBkZXNlcmlhbGl6ZShkYXRhLCBwYXJlbnQsIHVpTWFuYWdlcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlZGl0b3IgPSBzdXBlci5kZXNlcmlhbGl6ZShkYXRhLCBwYXJlbnQsIHVpTWFuYWdlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9mb250U2l6ZSwgZGF0YS5mb250U2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9jb2xvciwgX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IoLi4uZGF0YS5jb2xvcikpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQoZWRpdG9yLCBfY29udGVudCwgZGF0YS52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlZGl0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNlcmlhbGl6ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWRkaW5nID0gRnJlZVRleHRFZGl0b3IuX2ludGVybmFsUGFkZGluZyAqIHRoaXMucGFyZW50U2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSB0aGlzLmdldFJlY3QocGFkZGluZywgcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9jb2xvck1hbmFnZXIuY29udmVydCh0aGlzLmlzQXR0YWNoZWRUb0RPTSA/IGdldENvbXB1dGVkU3R5bGUodGhpcy5lZGl0b3JEaXYpLmNvbG9yIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb2xvcikpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvblR5cGU6IF91dGlsLkFubm90YXRpb25FZGl0b3JUeXBlLkZSRUVURVhULAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sb3IsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb250U2l6ZTogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9mb250U2l6ZSksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb250ZW50KSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJbmRleDogdGhpcy5wYWdlSW5kZXgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb246IHRoaXMucm90YXRpb24KICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkZyZWVUZXh0RWRpdG9yID0gRnJlZVRleHRFZGl0b3I7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfdXBkYXRlRm9udFNpemUyKGZvbnRTaXplKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2V0Rm9udHNpemUgPSBzaXplID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuc3R5bGUuZm9udFNpemUgPSBgY2FsYygke3NpemV9cHggKiB2YXIoLS1zY2FsZS1mYWN0b3IpKWA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNsYXRlKDAsIC0oc2l6ZSAtIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZm9udFNpemUpKSAqIHRoaXMucGFyZW50U2NhbGUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2ZvbnRTaXplLCBzaXplKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0RWRpdG9yRGltZW5zaW9ucywgX3NldEVkaXRvckRpbWVuc2lvbnMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRGb250c2l6ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldEZvbnRzaXplKGZvbnRTaXplKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgdW5kbzogKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0Rm9udHNpemUoc2F2ZWRGb250c2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RFeGVjOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9TSVpFLAogICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbzogdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3VwZGF0ZUNvbG9yMihjb2xvcikgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNhdmVkQ29sb3IgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbG9yKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENvbW1hbmRzKHsKICAgICAgICAgICAgICAgICAgICAgICAgY21kOiAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2NvbG9yLCB0aGlzLmVkaXRvckRpdi5zdHlsZS5jb2xvciA9IGNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgdW5kbzogKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb2xvciwgdGhpcy5lZGl0b3JEaXYuc3R5bGUuY29sb3IgPSBzYXZlZENvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLkZSRUVURVhUX0NPTE9SLAogICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbzogdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2V4dHJhY3RUZXh0MigpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXZzID0gdGhpcy5lZGl0b3JEaXYuZ2V0RWxlbWVudHNCeVRhZ05hbWUoImRpdiIpOwogICAgICAgICAgICAgICAgICAgIGlmIChkaXZzLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5lZGl0b3JEaXYuaW5uZXJUZXh0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBbXTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGRpdiBvZiBkaXZzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJ1ZmZlci5wdXNoKGRpdi5pbm5lclRleHQucmVwbGFjZSgvXHJcbj98XG4vLCAiIikpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gYnVmZmVyLmpvaW4oIlxuIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0RWRpdG9yRGltZW5zaW9uczIoKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgIGxldCByZWN0OwogICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzQXR0YWNoZWRUb0RPTSkgewogICAgICAgICAgICAgICAgICAgICAgICByZWN0ID0gdGhpcy5kaXYuZ2V0Qm91bmRpbmdDbGllbnRSZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudExheWVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzYXZlZERpc3BsYXkgPSBkaXYuc3R5bGUuZGlzcGxheTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLmRpc3BsYXkgPSAiaGlkZGVuIjsKICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudExheWVyLmRpdi5hcHBlbmQodGhpcy5kaXYpOwogICAgICAgICAgICAgICAgICAgICAgICByZWN0ID0gZGl2LmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICBkaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpdi5zdHlsZS5kaXNwbGF5ID0gc2F2ZWREaXNwbGF5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0aGlzLndpZHRoID0gcmVjdC53aWR0aCAvIHBhcmVudFdpZHRoOwogICAgICAgICAgICAgICAgICAgIHRoaXMuaGVpZ2h0ID0gcmVjdC5oZWlnaHQgLyBwYXJlbnRIZWlnaHQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfZnJlZVRleHREZWZhdWx0Q29udGVudCIsICIiKTsKICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShGcmVlVGV4dEVkaXRvciwgIl9sMTBuUHJvbWlzZSIsIHZvaWQgMCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfaW50ZXJuYWxQYWRkaW5nIiwgMCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfZGVmYXVsdENvbG9yIiwgbnVsbCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfZGVmYXVsdEZvbnRTaXplIiwgMTApOwogICAgICAgICAgICAgICAgX2RlZmluZVByb3BlcnR5KEZyZWVUZXh0RWRpdG9yLCAiX2tleWJvYXJkTWFuYWdlciIsIG5ldyBfdG9vbHMuS2V5Ym9hcmRNYW5hZ2VyKFtbWyJjdHJsK0VudGVyIiwgIm1hYyttZXRhK0VudGVyIiwgIkVzY2FwZSIsICJtYWMrRXNjYXBlIl0sIEZyZWVUZXh0RWRpdG9yLnByb3RvdHlwZS5jb21taXRPclJlbW92ZV1dKSk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfdHlwZSIsICJmcmVldGV4dCIpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNjQgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5JbmtFZGl0b3IgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgImZpdEN1cnZlIiwgKHsKICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3BkZmpzRml0Q3VydmUuZml0Q3VydmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfZWRpdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxND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pZHRoID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kQ2FudmFzUG9pbnRlcm1vdmUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDYW52YXNQb2ludGVybGVhdmUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDYW52YXNQb2ludGVydXAgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDYW52YXNQb2ludGVyZG93biA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNhYmxlRWRpdGluZyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9pc0NhbnZhc0luaXRpYWxpemVkID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2xhc3RQb2ludCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9vYnNlcnZlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9yZWFsV2lkdGggPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfcmVhbEhlaWdodCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9yZXF1ZXN0RnJhbWVDYWxsYmFjayA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF91cGRhdGVUaGlja25lc3MgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfdXBkYXRlQ29sb3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfdXBkYXRlT3BhY2l0eSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9nZXRJbml0aWFsQkJveCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZXRTdHJva2UgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfc3RhcnREcmF3aW5nID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2RyYXcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfc3RvcERyYXdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfcmVkcmF3ID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2VuZERyYXdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfY3JlYXRlQ2FudmFzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2NyZWF0ZU9ic2VydmVyID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX3NldENhbnZhc0RpbXMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfc2V0U2NhbGVGYWN0b3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfdXBkYXRlVHJhbnNmb3JtID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX3NlcmlhbGl6ZVBhdGhzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2V4dHJhY3RQb2ludHNPbkJlemllciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9pc0FsbW9zdEZsYXQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfZ2V0QmJveCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9nZXRQYWRkaW5nID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2ZpdFRvQ29udGVudCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZXRNaW5EaW1zID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBjbGFzcyBJbmtFZGl0b3IgZXh0ZW5kcyBfZWRpdG9yLkFubm90YXRpb25FZGl0b3IgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcih7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAuLi5wYXJhbXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiAiaW5rRWRpdG9yIgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRNaW5EaW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9maXRUb0NvbnRlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2dldFBhZGRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2dldEJib3gpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2lzQWxtb3N0RmxhdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZXh0cmFjdFBvaW50c09uQmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXJpYWxpemVQYXRocyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfdXBkYXRlVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRTY2FsZUZhY3Rvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc2V0Q2FudmFzRGltcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfY3JlYXRlT2JzZXJ2ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2NyZWF0ZUNhbnZhcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZW5kRHJhd2luZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfcmVkcmF3KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zdG9wRHJhd2luZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZHJhdyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc3RhcnREcmF3aW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRTdHJva2UpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2dldEluaXRpYWxCQm94KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF91cGRhdGVPcGFjaXR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF91cGRhdGVDb2xvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfdXBkYXRlVGhpY2tuZXNzKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2FzcGVjdFJhdGlvLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYmFzZUhlaWdodCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2Jhc2VXaWR0aCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kQ2FudmFzUG9pbnRlcm1vdmUsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY2FudmFzUG9pbnRlcm1vdmUuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kQ2FudmFzUG9pbnRlcmxlYXZlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLmNhbnZhc1BvaW50ZXJsZWF2ZS5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVydXAsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY2FudmFzUG9pbnRlcnVwLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJkb3duLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLmNhbnZhc1BvaW50ZXJkb3duLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9kaXNhYmxlRWRpdGluZywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9pc0NhbnZhc0luaXRpYWxpemVkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2xhc3RQb2ludCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX29ic2VydmVyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcmVhbFdpZHRoLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcmVhbEhlaWdodCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX3JlcXVlc3RGcmFtZUNhbGxiYWNrLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbG9yID0gcGFyYW1zLmNvbG9yIHx8IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGhpY2tuZXNzID0gcGFyYW1zLnRoaWNrbmVzcyB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wYWNpdHkgPSBwYXJhbXMub3BhY2l0eSB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhdGhzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmV6aWVyUGF0aDJEID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudFBhdGggPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zY2FsZUZhY3RvciA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNsYXRpb25YID0gdGhpcy50cmFuc2xhdGlvblkgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnkgPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgaW5pdGlhbGl6ZShsMTBuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2wxMG5Qcm9taXNlID0gbmV3IE1hcChbImVkaXRvcl9pbmtfY2FudmFzX2FyaWFfbGFiZWwiLCAiZWRpdG9yX2luazJfYXJpYV9sYWJlbCJdLm1hcChzdHIgPT4gW3N0ciwgbDEwbi5nZXQoc3RyKV0pKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHVwZGF0ZURlZmF1bHRQYXJhbXModHlwZSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19USElDS05FU1M6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSW5rRWRpdG9yLl9kZWZhdWx0VGhpY2tuZXNzID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19DT0xPUjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbmtFZGl0b3IuX2RlZmF1bHRDb2xvciA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfT1BBQ0lUWToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbmtFZGl0b3IuX2RlZmF1bHRPcGFjaXR5ID0gdmFsdWUgLyAxMDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlUGFyYW1zKHR5cGUsIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfVEhJQ0tORVNTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3VwZGF0ZVRoaWNrbmVzcywgX3VwZGF0ZVRoaWNrbmVzczIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfQ09MT1I6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlQ29sb3IsIF91cGRhdGVDb2xvcjIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfT1BBQ0lUWToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF91cGRhdGVPcGFjaXR5LCBfdXBkYXRlT3BhY2l0eTIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXQgZGVmYXVsdFByb3BlcnRpZXNUb1VwZGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuSU5LX1RISUNLTkVTUywgSW5rRWRpdG9yLl9kZWZhdWx0VGhpY2tuZXNzXSwgW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19DT0xPUiwgSW5rRWRpdG9yLl9kZWZhdWx0Q29sb3IgfHwgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9kZWZhdWx0TGluZUNvbG9yXSwgW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19PUEFDSVRZLCBNYXRoLnJvdW5kKElua0VkaXRvci5fZGVmYXVsdE9wYWNpdHkgKiAxMDApXV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwcm9wZXJ0aWVzVG9VcGRhdGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19USElDS05FU1MsIHRoaXMudGhpY2tuZXNzIHx8IElua0VkaXRvci5fZGVmYXVsdFRoaWNrbmVzc10sIFtfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfQ09MT1IsIHRoaXMuY29sb3IgfHwgSW5rRWRpdG9yLl9kZWZhdWx0Q29sb3IgfHwgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9kZWZhdWx0TGluZUNvbG9yXSwgW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19PUEFDSVRZLCBNYXRoLnJvdW5kKDEwMCAqICh0aGlzLm9wYWNpdHkgPz8gSW5rRWRpdG9yLl9kZWZhdWx0T3BhY2l0eSkpXV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlYnVpbGQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyLnJlYnVpbGQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGl2ID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmNhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlQ2FudmFzLCBfY3JlYXRlQ2FudmFzMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NyZWF0ZU9ic2VydmVyLCBfY3JlYXRlT2JzZXJ2ZXIyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0F0dGFjaGVkVG9ET00pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmFkZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldENhbnZhc0RpbXMsIF9zZXRDYW52YXNEaW1zMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9maXRUb0NvbnRlbnQsIF9maXRUb0NvbnRlbnQyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW1vdmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNhbnZhcyA9PT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMud2lkdGggPSB0aGlzLmNhbnZhcy5oZWlnaHQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX29ic2VydmVyKS5kaXNjb25uZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfb2JzZXJ2ZXIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0UGFyZW50KHBhcmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMucGFyZW50ICYmIHBhcmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdWlNYW5hZ2VyLnJlbW92ZVNob3VsZFJlc2NhbGUodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5wYXJlbnQgJiYgcGFyZW50ID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91aU1hbmFnZXIuYWRkU2hvdWxkUmVzY2FsZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5zZXRQYXJlbnQocGFyZW50KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25TY2FsZUNoYW5naW5nKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFyZW50V2lkdGgsIHBhcmVudEhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gdGhpcy53aWR0aCAqIHBhcmVudFdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSB0aGlzLmhlaWdodCAqIHBhcmVudEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1lbnNpb25zKHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmFibGVFZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGlzYWJsZUVkaXRpbmcpIHx8IHRoaXMuY2FudmFzID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIuZW5hYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuZHJhZ2dhYmxlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmFkZEV2ZW50TGlzdGVuZXIoInBvaW50ZXJkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJkb3duKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmFkZEV2ZW50TGlzdGVuZXIoInBvaW50ZXJ1cCIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVydXApKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUVkaXRNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNJbkVkaXRNb2RlKCkgfHwgdGhpcy5jYW52YXMgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5kaXNhYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuZHJhZ2dhYmxlID0gIXRoaXMuaXNFbXB0eSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QucmVtb3ZlKCJlZGl0aW5nIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJkb3duKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJ1cCIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVydXApKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25jZUFkZGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5kcmFnZ2FibGUgPSAhdGhpcy5pc0VtcHR5KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzRW1wdHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnBhdGhzLmxlbmd0aCA9PT0gMCB8fCB0aGlzLnBhdGhzLmxlbmd0aCA9PT0gMSAmJiB0aGlzLnBhdGhzWzBdLmxlbmd0aCA9PT0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tbWl0KCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kaXNhYmxlRWRpdGluZykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5jb21taXQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc0VkaXRpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXNhYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRJbkZvcmVncm91bmQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9kaXNhYmxlRWRpdGluZywgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmNsYXNzTGlzdC5hZGQoImRpc2FibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2ZpdFRvQ29udGVudCwgX2ZpdFRvQ29udGVudDIpLmNhbGwodGhpcywgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmFkZElua0VkaXRvcklmTmVlZGVkKHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5tb3ZlRWRpdG9ySW5ET00odGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmZvY3VzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXZlbnRTY3JvbGw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZvY3VzaW4oZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIuZm9jdXNpbihldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FudmFzUG9pbnRlcmRvd24oZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50LmJ1dHRvbiAhPT0gMCB8fCAhdGhpcy5pc0luRWRpdE1vZGUoKSB8fCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Rpc2FibGVFZGl0aW5nKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SW5Gb3JlZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50eXBlICE9PSAibW91c2UiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5mb2N1cygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnN0b3BQcm9wYWdhdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5hZGRFdmVudExpc3RlbmVyKCJwb2ludGVybGVhdmUiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kQ2FudmFzUG9pbnRlcmxlYXZlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmFkZEV2ZW50TGlzdGVuZXIoInBvaW50ZXJtb3ZlIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJtb3ZlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3N0YXJ0RHJhd2luZywgX3N0YXJ0RHJhd2luZzIpLmNhbGwodGhpcywgZXZlbnQub2Zmc2V0WCwgZXZlbnQub2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbnZhc1BvaW50ZXJtb3ZlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnN0b3BQcm9wYWdhdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kcmF3LCBfZHJhdzIpLmNhbGwodGhpcywgZXZlbnQub2Zmc2V0WCwgZXZlbnQub2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbnZhc1BvaW50ZXJ1cChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQuYnV0dG9uICE9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNJbkVkaXRNb2RlKCkgJiYgdGhpcy5jdXJyZW50UGF0aC5sZW5ndGggIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnN0b3BQcm9wYWdhdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZW5kRHJhd2luZywgX2VuZERyYXdpbmcyKS5jYWxsKHRoaXMsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SW5CYWNrZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FudmFzUG9pbnRlcmxlYXZlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2VuZERyYXdpbmcsIF9lbmREcmF3aW5nMikuY2FsbCh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SW5CYWNrZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJhc2VYLCBiYXNlWTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMud2lkdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VYID0gdGhpcy54OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFzZVkgPSB0aGlzLnk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVuZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIElua0VkaXRvci5fbDEwblByb21pc2UuZ2V0KCJlZGl0b3JfaW5rMl9hcmlhX2xhYmVsIikudGhlbihtc2cgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoX3RoaXMkZGl2ID0gdGhpcy5kaXYpID09PSBudWxsIHx8IF90aGlzJGRpdiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZGl2LnNldEF0dHJpYnV0ZSgiYXJpYS1sYWJlbCIsIG1zZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbeCwgeSwgdywgaF0gPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9nZXRJbml0aWFsQkJveCwgX2dldEluaXRpYWxCQm94MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRBdCh4LCB5LCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1zKHcsIGgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jcmVhdGVDYW52YXMsIF9jcmVhdGVDYW52YXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy53aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRBdChiYXNlWCAqIHBhcmVudFdpZHRoLCBiYXNlWSAqIHBhcmVudEhlaWdodCwgdGhpcy53aWR0aCAqIHBhcmVudFdpZHRoLCB0aGlzLmhlaWdodCAqIHBhcmVudEhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2lzQ2FudmFzSW5pdGlhbGl6ZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0Q2FudmFzRGltcywgX3NldENhbnZhc0RpbXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1zKHRoaXMud2lkdGggKiBwYXJlbnRXaWR0aCwgdGhpcy5oZWlnaHQgKiBwYXJlbnRIZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVkcmF3LCBfcmVkcmF3MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldE1pbkRpbXMsIF9zZXRNaW5EaW1zMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmNsYXNzTGlzdC5hZGQoImRpc2FibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QuYWRkKCJlZGl0aW5nIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuYWJsZUVkaXRNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlT2JzZXJ2ZXIsIF9jcmVhdGVPYnNlcnZlcjIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmRpdjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0RGltZW5zaW9ucyh3aWR0aCwgaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvdW5kZWRXaWR0aCA9IE1hdGgucm91bmQod2lkdGgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByb3VuZGVkSGVpZ2h0ID0gTWF0aC5yb3VuZChoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZWFsV2lkdGgpID09PSByb3VuZGVkV2lkdGggJiYgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZWFsSGVpZ2h0KSA9PT0gcm91bmRlZEhlaWdodCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfcmVhbFdpZHRoLCByb3VuZGVkV2lkdGgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3JlYWxIZWlnaHQsIHJvdW5kZWRIZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5zdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FzcGVjdFJhdGlvKSAmJiBNYXRoLmFicyhfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FzcGVjdFJhdGlvKSAtIHdpZHRoIC8gaGVpZ2h0KSA+IDFlLTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodCA9IE1hdGguY2VpbCh3aWR0aCAvIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RGltcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFyZW50V2lkdGgsIHBhcmVudEhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMud2lkdGggPSB3aWR0aCAvIHBhcmVudFdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmhlaWdodCA9IGhlaWdodCAvIHBhcmVudEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGlzYWJsZUVkaXRpbmcpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRTY2FsZUZhY3RvciwgX3NldFNjYWxlRmFjdG9yMikuY2FsbCh0aGlzLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRDYW52YXNEaW1zLCBfc2V0Q2FudmFzRGltczIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnN0eWxlLnZpc2liaWxpdHkgPSAidmlzaWJsZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZml4RGltcygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgZGVzZXJpYWxpemUoZGF0YSwgcGFyZW50LCB1aU1hbmFnZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9yID0gc3VwZXIuZGVzZXJpYWxpemUoZGF0YSwgcGFyZW50LCB1aU1hbmFnZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IudGhpY2tuZXNzID0gZGF0YS50aGlja25lc3M7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5jb2xvciA9IF91dGlsLlV0aWwubWFrZUhleENvbG9yKC4uLmRhdGEuY29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iub3BhY2l0eSA9IGRhdGEub3BhY2l0eTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhZ2VXaWR0aCwgcGFnZUhlaWdodF0gPSBlZGl0b3IucGFnZURpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gZWRpdG9yLndpZHRoICogcGFnZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBlZGl0b3IuaGVpZ2h0ICogcGFnZUhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVGYWN0b3IgPSBlZGl0b3IucGFyZW50U2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZGRpbmcgPSBkYXRhLnRoaWNrbmVzcyAvIDI7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9hc3BlY3RSYXRpbywgd2lkdGggLyBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQoZWRpdG9yLCBfZGlzYWJsZUVkaXRpbmcsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQoZWRpdG9yLCBfcmVhbFdpZHRoLCBNYXRoLnJvdW5kKHdpZHRoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9yZWFsSGVpZ2h0LCBNYXRoLnJvdW5kKGhlaWdodCkpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlemllcgogICAgICAgICAgICAgICAgICAgICAgICB9IG9mIGRhdGEucGF0aHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdGggPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5wYXRocy5wdXNoKHBhdGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHAwID0gc2NhbGVGYWN0b3IgKiAoYmV6aWVyWzBdIC0gcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcDEgPSBzY2FsZUZhY3RvciAqIChoZWlnaHQgLSBiZXppZXJbMV0gLSBwYWRkaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAyLCBpaSA9IGJlemllci5sZW5ndGg7IGkgPCBpaTsgaSArPSA2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDEwID0gc2NhbGVGYWN0b3IgKiAoYmV6aWVyW2ldIC0gcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDExID0gc2NhbGVGYWN0b3IgKiAoaGVpZ2h0IC0gYmV6aWVyW2kgKyAxXSAtIHBhZGRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAyMCA9IHNjYWxlRmFjdG9yICogKGJlemllcltpICsgMl0gLSBwYWRkaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMjEgPSBzY2FsZUZhY3RvciAqIChoZWlnaHQgLSBiZXppZXJbaSArIDNdIC0gcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDMwID0gc2NhbGVGYWN0b3IgKiAoYmV6aWVyW2kgKyA0XSAtIHBhZGRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAzMSA9IHNjYWxlRmFjdG9yICogKGhlaWdodCAtIGJlemllcltpICsgNV0gLSBwYWRkaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoLnB1c2goW1twMCwgcDFdLCBbcDEwLCBwMTFdLCBbcDIwLCBwMjFdLCBbcDMwLCBwMzFdXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcDAgPSBwMzA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcDEgPSBwMzE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRoMkQgPSBfY2xhc3NTdGF0aWNQcml2YXRlTWV0aG9kR2V0KHRoaXMsIElua0VkaXRvciwgX2J1aWxkUGF0aDJEKS5jYWxsKHRoaXMsIHBhdGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmJlemllclBhdGgyRC5wdXNoKHBhdGgyRCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmJveCA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQoZWRpdG9yLCBfZ2V0QmJveCwgX2dldEJib3gyKS5jYWxsKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9iYXNlV2lkdGgsIE1hdGgubWF4KFJFU0laRVJfU0laRSwgYmJveFsyXSAtIGJib3hbMF0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KGVkaXRvciwgX2Jhc2VIZWlnaHQsIE1hdGgubWF4KFJFU0laRVJfU0laRSwgYmJveFszXSAtIGJib3hbMV0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldChlZGl0b3IsIF9zZXRTY2FsZUZhY3RvciwgX3NldFNjYWxlRmFjdG9yMikuY2FsbChlZGl0b3IsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZWRpdG9yOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXJpYWxpemUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IHRoaXMuZ2V0UmVjdCgwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gdGhpcy5yb3RhdGlvbiAlIDE4MCA9PT0gMCA/IHJlY3RbM10gLSByZWN0WzFdIDogcmVjdFsyXSAtIHJlY3RbMF07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9jb2xvck1hbmFnZXIuY29udmVydCh0aGlzLmN0eC5zdHJva2VTdHlsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uVHlwZTogX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sb3IsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlja25lc3M6IHRoaXMudGhpY2tuZXNzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3BhY2l0eTogdGhpcy5vcGFjaXR5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0aHM6IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NlcmlhbGl6ZVBhdGhzLCBfc2VyaWFsaXplUGF0aHMyKS5jYWxsKHRoaXMsIHRoaXMuc2NhbGVGYWN0b3IgLyB0aGlzLnBhcmVudFNjYWxlLCB0aGlzLnRyYW5zbGF0aW9uWCwgdGhpcy50cmFuc2xhdGlvblksIGhlaWdodCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlSW5kZXg6IHRoaXMucGFnZUluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uOiB0aGlzLnJvdGF0aW9uCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5JbmtFZGl0b3IgPSBJbmtFZGl0b3I7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfdXBkYXRlVGhpY2tuZXNzMih0aGlja25lc3MpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBzYXZlZFRoaWNrbmVzcyA9IHRoaXMudGhpY2tuZXNzOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGhpY2tuZXNzID0gdGhpY2tuZXNzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZml0VG9Db250ZW50LCBfZml0VG9Db250ZW50MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgdW5kbzogKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50aGlja25lc3MgPSBzYXZlZFRoaWNrbmVzczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2ZpdFRvQ29udGVudCwgX2ZpdFRvQ29udGVudDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RFeGVjOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfVEhJQ0tORVNTLAogICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbzogdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3VwZGF0ZUNvbG9yMihjb2xvcikgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNhdmVkQ29sb3IgPSB0aGlzLmNvbG9yOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29sb3IgPSBjb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgIHVuZG86ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29sb3IgPSBzYXZlZENvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVkcmF3LCBfcmVkcmF3MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19DT0xPUiwKICAgICAgICAgICAgICAgICAgICAgICAgb3ZlcndyaXRlSWZTYW1lVHlwZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAga2VlcFVuZG86IHRydWUKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF91cGRhdGVPcGFjaXR5MihvcGFjaXR5KSB7CiAgICAgICAgICAgICAgICAgICAgb3BhY2l0eSAvPSAxMDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRPcGFjaXR5ID0gdGhpcy5vcGFjaXR5OwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3BhY2l0eSA9IG9wYWNpdHk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZWRyYXcsIF9yZWRyYXcyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICB1bmRvOiAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wYWNpdHkgPSBzYXZlZE9wYWNpdHk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZWRyYXcsIF9yZWRyYXcyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYzogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuSU5LX09QQUNJVFksCiAgICAgICAgICAgICAgICAgICAgICAgIG92ZXJ3cml0ZUlmU2FtZVR5cGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIGtlZXBVbmRvOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZ2V0SW5pdGlhbEJCb3gyKCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50Um90YXRpb24sCiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmVudERpbWVuc2lvbnM6IFt3aWR0aCwgaGVpZ2h0XQogICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgIHN3aXRjaCAocGFyZW50Um90YXRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSA5MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbMCwgaGVpZ2h0LCBoZWlnaHQsIHdpZHRoXTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxODA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3dpZHRoLCBoZWlnaHQsIHdpZHRoLCBoZWlnaHRdOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI3MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbd2lkdGgsIDAsIGhlaWdodCwgd2lkdGhdOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFswLCAwLCB3aWR0aCwgaGVpZ2h0XTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0U3Ryb2tlMigpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eCwKICAgICAgICAgICAgICAgICAgICAgICAgY29sb3IsCiAgICAgICAgICAgICAgICAgICAgICAgIG9wYWNpdHksCiAgICAgICAgICAgICAgICAgICAgICAgIHRoaWNrbmVzcywKICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50U2NhbGUsCiAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlRmFjdG9yCiAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVXaWR0aCA9IHRoaWNrbmVzcyAqIHBhcmVudFNjYWxlIC8gc2NhbGVGYWN0b3I7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVDYXAgPSAicm91bmQiOwogICAgICAgICAgICAgICAgICAgIGN0eC5saW5lSm9pbiA9ICJyb3VuZCI7CiAgICAgICAgICAgICAgICAgICAgY3R4Lm1pdGVyTGltaXQgPSAxMDsKICAgICAgICAgICAgICAgICAgICBjdHguc3Ryb2tlU3R5bGUgPSBgJHtjb2xvcn0keygwLCBfdG9vbHMub3BhY2l0eVRvSGV4KShvcGFjaXR5KX1gOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3N0YXJ0RHJhd2luZzIoeCwgeSkgewogICAgICAgICAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaXNDYW52YXNJbml0aWFsaXplZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9pc0NhbnZhc0luaXRpYWxpemVkLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0Q2FudmFzRGltcywgX3NldENhbnZhc0RpbXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRoaWNrbmVzcyB8fD0gSW5rRWRpdG9yLl9kZWZhdWx0VGhpY2tuZXNzOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbG9yIHx8PSBJbmtFZGl0b3IuX2RlZmF1bHRDb2xvciB8fCBfZWRpdG9yLkFubm90YXRpb25FZGl0b3IuX2RlZmF1bHRMaW5lQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3BhY2l0eSA/Pz0gSW5rRWRpdG9yLl9kZWZhdWx0T3BhY2l0eTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50UGF0aC5wdXNoKFt4LCB5XSk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9sYXN0UG9pbnQsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldFN0cm9rZSwgX3NldFN0cm9rZTIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguYmVnaW5QYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubW92ZVRvKHgsIHkpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfcmVxdWVzdEZyYW1lQ2FsbGJhY2ssICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3JlcXVlc3RGcmFtZUNhbGxiYWNrKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2xhc3RQb2ludCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNldFRyYW5zZm9ybSgxLCAwLCAwLCAxLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5jbGVhclJlY3QoMCwgMCwgdGhpcy5jYW52YXMud2lkdGgsIHRoaXMuY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5saW5lVG8oLi4uX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9sYXN0UG9pbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfbGFzdFBvaW50LCBudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHdpbmRvdy5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZXF1ZXN0RnJhbWVDYWxsYmFjaykpOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHdpbmRvdy5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZXF1ZXN0RnJhbWVDYWxsYmFjaykpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2RyYXcyKHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBbbGFzdFgsIGxhc3RZXSA9IHRoaXMuY3VycmVudFBhdGguYXQoLTEpOwogICAgICAgICAgICAgICAgICAgIGlmICh4ID09PSBsYXN0WCAmJiB5ID09PSBsYXN0WSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudFBhdGgucHVzaChbeCwgeV0pOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfbGFzdFBvaW50LCBbeCwgeV0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3N0b3BEcmF3aW5nMih4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9yZXF1ZXN0RnJhbWVDYWxsYmFjaywgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgeCA9IE1hdGgubWluKE1hdGgubWF4KHgsIDApLCB0aGlzLmNhbnZhcy53aWR0aCk7CiAgICAgICAgICAgICAgICAgICAgeSA9IE1hdGgubWluKE1hdGgubWF4KHksIDApLCB0aGlzLmNhbnZhcy5oZWlnaHQpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IFtsYXN0WCwgbGFzdFldID0gdGhpcy5jdXJyZW50UGF0aC5hdCgtMSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHggIT09IGxhc3RYIHx8IHkgIT09IGxhc3RZKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudFBhdGgucHVzaChbeCwgeV0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBsZXQgYmV6aWVyOwogICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmN1cnJlbnRQYXRoLmxlbmd0aCAhPT0gMSkgewogICAgICAgICAgICAgICAgICAgICAgICBiZXppZXIgPSAoMCwgX3BkZmpzRml0Q3VydmUuZml0Q3VydmUpKHRoaXMuY3VycmVudFBhdGgsIDMwLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4eSA9IFt4LCB5XTsKICAgICAgICAgICAgICAgICAgICAgICAgYmV6aWVyID0gW1t4eSwgeHkuc2xpY2UoKSwgeHkuc2xpY2UoKSwgeHldXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGF0aDJEID0gX2NsYXNzU3RhdGljUHJpdmF0ZU1ldGhvZEdldChJbmtFZGl0b3IsIElua0VkaXRvciwgX2J1aWxkUGF0aDJEKS5jYWxsKElua0VkaXRvciwgYmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnRQYXRoLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhdGhzLnB1c2goYmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5iZXppZXJQYXRoMkQucHVzaChwYXRoMkQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJlYnVpbGQoKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHVuZG8gPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGF0aHMucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmV6aWVyUGF0aDJELnBvcCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5wYXRocy5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY2FudmFzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlQ2FudmFzLCBfY3JlYXRlQ2FudmFzMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jcmVhdGVPYnNlcnZlciwgX2NyZWF0ZU9ic2VydmVyMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2ZpdFRvQ29udGVudCwgX2ZpdFRvQ29udGVudDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgIHVuZG8sCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RFeGVjOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfcmVkcmF3MigpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlVHJhbnNmb3JtLCBfdXBkYXRlVHJhbnNmb3JtMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRTdHJva2UsIF9zZXRTdHJva2UyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLAogICAgICAgICAgICAgICAgICAgICAgICBjdHgKICAgICAgICAgICAgICAgICAgICB9ID0gdGhpczsKICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDEsIDAsIDAsIDEsIDAsIDApOwogICAgICAgICAgICAgICAgICAgIGN0eC5jbGVhclJlY3QoMCwgMCwgY2FudmFzLndpZHRoLCBjYW52YXMuaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF91cGRhdGVUcmFuc2Zvcm0sIF91cGRhdGVUcmFuc2Zvcm0yKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcGF0aCBvZiB0aGlzLmJlemllclBhdGgyRCkgewogICAgICAgICAgICAgICAgICAgICAgICBjdHguc3Ryb2tlKHBhdGgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9lbmREcmF3aW5nMihldmVudCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3N0b3BEcmF3aW5nLCBfc3RvcERyYXdpbmcyKS5jYWxsKHRoaXMsIGV2ZW50Lm9mZnNldFgsIGV2ZW50Lm9mZnNldFkpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJsZWF2ZSIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVybGVhdmUpKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5yZW1vdmVFdmVudExpc3RlbmVyKCJwb2ludGVybW92ZSIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVybW92ZSkpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkVG9Bbm5vdGF0aW9uU3RvcmFnZSgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NyZWF0ZUNhbnZhczIoKSB7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy53aWR0aCA9IHRoaXMuY2FudmFzLmhlaWdodCA9IDA7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMuY2xhc3NOYW1lID0gImlua0VkaXRvckNhbnZhcyI7CiAgICAgICAgICAgICAgICAgICAgSW5rRWRpdG9yLl9sMTBuUHJvbWlzZS5nZXQoImVkaXRvcl9pbmtfY2FudmFzX2FyaWFfbGFiZWwiKS50aGVuKG1zZyA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRjYW52YXM7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoX3RoaXMkY2FudmFzID0gdGhpcy5jYW52YXMpID09PSBudWxsIHx8IF90aGlzJGNhbnZhcyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkY2FudmFzLnNldEF0dHJpYnV0ZSgiYXJpYS1sYWJlbCIsIG1zZyk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYXBwZW5kKHRoaXMuY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eCA9IHRoaXMuY2FudmFzLmdldENvbnRleHQoIjJkIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY3JlYXRlT2JzZXJ2ZXIyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfb2JzZXJ2ZXIsIG5ldyBSZXNpemVPYnNlcnZlcihlbnRyaWVzID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IGVudHJpZXNbMF0uY29udGVudFJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZWN0LndpZHRoICYmIHJlY3QuaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldERpbWVuc2lvbnMocmVjdC53aWR0aCwgcmVjdC5oZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfb2JzZXJ2ZXIpLm9ic2VydmUodGhpcy5kaXYpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3NldENhbnZhc0RpbXMyKCkgewogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0NhbnZhc0luaXRpYWxpemVkKSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYXJlbnRXaWR0aCwgcGFyZW50SGVpZ2h0XSA9IHRoaXMucGFyZW50RGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy53aWR0aCA9IE1hdGguY2VpbCh0aGlzLndpZHRoICogcGFyZW50V2lkdGgpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmhlaWdodCA9IE1hdGguY2VpbCh0aGlzLmhlaWdodCAqIHBhcmVudEhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlVHJhbnNmb3JtLCBfdXBkYXRlVHJhbnNmb3JtMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9zZXRTY2FsZUZhY3RvcjIod2lkdGgsIGhlaWdodCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZGRpbmcgPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9nZXRQYWRkaW5nLCBfZ2V0UGFkZGluZzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVGYWN0b3JXID0gKHdpZHRoIC0gcGFkZGluZykgLyBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Jhc2VXaWR0aCk7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVGYWN0b3JIID0gKGhlaWdodCAtIHBhZGRpbmcpIC8gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9iYXNlSGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICB0aGlzLnNjYWxlRmFjdG9yID0gTWF0aC5taW4oc2NhbGVGYWN0b3JXLCBzY2FsZUZhY3RvckgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3VwZGF0ZVRyYW5zZm9ybTIoKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFkZGluZyA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2dldFBhZGRpbmcsIF9nZXRQYWRkaW5nMikuY2FsbCh0aGlzKSAvIDI7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc2V0VHJhbnNmb3JtKHRoaXMuc2NhbGVGYWN0b3IsIDAsIDAsIHRoaXMuc2NhbGVGYWN0b3IsIHRoaXMudHJhbnNsYXRpb25YICogdGhpcy5zY2FsZUZhY3RvciArIHBhZGRpbmcsIHRoaXMudHJhbnNsYXRpb25ZICogdGhpcy5zY2FsZUZhY3RvciArIHBhZGRpbmcpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2J1aWxkUGF0aDJEKGJlemllcikgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdGgyRCA9IG5ldyBQYXRoMkQoKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBiZXppZXIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbZmlyc3QsIGNvbnRyb2wxLCBjb250cm9sMiwgc2Vjb25kXSA9IGJlemllcltpXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgyRC5tb3ZlVG8oLi4uZmlyc3QpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgyRC5iZXppZXJDdXJ2ZVRvKGNvbnRyb2wxWzBdLCBjb250cm9sMVsxXSwgY29udHJvbDJbMF0sIGNvbnRyb2wyWzFdLCBzZWNvbmRbMF0sIHNlY29uZFsxXSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBwYXRoMkQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2VyaWFsaXplUGF0aHMyKHMsIHR4LCB0eSwgaCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IE5VTUJFUl9PRl9QT0lOVFNfT05fQkVaSUVSX0NVUlZFID0gNDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRocyA9IFtdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZGRpbmcgPSB0aGlzLnRoaWNrbmVzcyAvIDI7CiAgICAgICAgICAgICAgICAgICAgbGV0IGJ1ZmZlciwgcG9pbnRzOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgYmV6aWVyIG9mIHRoaXMucGF0aHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50cyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBiZXppZXIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW2ZpcnN0LCBjb250cm9sMSwgY29udHJvbDIsIHNlY29uZF0gPSBiZXppZXJbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMTAgPSBzICogKGZpcnN0WzBdICsgdHgpICsgcGFkZGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAxMSA9IGggLSBzICogKGZpcnN0WzFdICsgdHkpIC0gcGFkZGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAyMCA9IHMgKiAoY29udHJvbDFbMF0gKyB0eCkgKyBwYWRkaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDIxID0gaCAtIHMgKiAoY29udHJvbDFbMV0gKyB0eSkgLSBwYWRkaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDMwID0gcyAqIChjb250cm9sMlswXSArIHR4KSArIHBhZGRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMzEgPSBoIC0gcyAqIChjb250cm9sMlsxXSArIHR5KSAtIHBhZGRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwNDAgPSBzICogKHNlY29uZFswXSArIHR4KSArIHBhZGRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwNDEgPSBoIC0gcyAqIChzZWNvbmRbMV0gKyB0eSkgLSBwYWRkaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBidWZmZXIucHVzaChwMTAsIHAxMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzLnB1c2gocDEwLCBwMTEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyLnB1c2gocDIwLCBwMjEsIHAzMCwgcDMxLCBwNDAsIHA0MSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9leHRyYWN0UG9pbnRzT25CZXppZXIsIF9leHRyYWN0UG9pbnRzT25CZXppZXIyKS5jYWxsKHRoaXMsIHAxMCwgcDExLCBwMjAsIHAyMSwgcDMwLCBwMzEsIHA0MCwgcDQxLCBOVU1CRVJfT0ZfUE9JTlRTX09OX0JFWklFUl9DVVJWRSwgcG9pbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwYXRocy5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlemllcjogYnVmZmVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGF0aHM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZXh0cmFjdFBvaW50c09uQmV6aWVyMihwMTAsIHAxMSwgcDIwLCBwMjEsIHAzMCwgcDMxLCBwNDAsIHA0MSwgbiwgcG9pbnRzKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2lzQWxtb3N0RmxhdCwgX2lzQWxtb3N0RmxhdDIpLmNhbGwodGhpcywgcDEwLCBwMTEsIHAyMCwgcDIxLCBwMzAsIHAzMSwgcDQwLCBwNDEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50cy5wdXNoKHA0MCwgcDQxKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8IG4gLSAxOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdCA9IGkgLyBuOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtdCA9IDEgLSB0OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTEwID0gdCAqIHAxMCArIG10ICogcDIwOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTExID0gdCAqIHAxMSArIG10ICogcDIxOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTIwID0gdCAqIHAyMCArIG10ICogcDMwOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTIxID0gdCAqIHAyMSArIG10ICogcDMxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBxMzAgPSB0ICogcDMwICsgbXQgKiBwNDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHEzMSA9IHQgKiBwMzEgKyBtdCAqIHA0MTsKICAgICAgICAgICAgICAgICAgICAgICAgcTEwID0gdCAqIHExMCArIG10ICogcTIwOwogICAgICAgICAgICAgICAgICAgICAgICBxMTEgPSB0ICogcTExICsgbXQgKiBxMjE7CiAgICAgICAgICAgICAgICAgICAgICAgIHEyMCA9IHQgKiBxMjAgKyBtdCAqIHEzMDsKICAgICAgICAgICAgICAgICAgICAgICAgcTIxID0gdCAqIHEyMSArIG10ICogcTMxOwogICAgICAgICAgICAgICAgICAgICAgICBxMTAgPSB0ICogcTEwICsgbXQgKiBxMjA7CiAgICAgICAgICAgICAgICAgICAgICAgIHExMSA9IHQgKiBxMTEgKyBtdCAqIHEyMTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzLnB1c2gocTEwLCBxMTEpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwb2ludHMucHVzaChwNDAsIHA0MSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfaXNBbG1vc3RGbGF0MihwMTAsIHAxMSwgcDIwLCBwMjEsIHAzMCwgcDMxLCBwNDAsIHA0MSkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRvbCA9IDEwOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGF4ID0gKDMgKiBwMjAgLSAyICogcDEwIC0gcDQwKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGF5ID0gKDMgKiBwMjEgLSAyICogcDExIC0gcDQxKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJ4ID0gKDMgKiBwMzAgLSBwMTAgLSAyICogcDQwKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJ5ID0gKDMgKiBwMzEgLSBwMTEgLSAyICogcDQxKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBNYXRoLm1heChheCwgYngpICsgTWF0aC5tYXgoYXksIGJ5KSA8PSB0b2w7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZ2V0QmJveDIoKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IHhNaW4gPSBJbmZpbml0eTsKICAgICAgICAgICAgICAgICAgICBsZXQgeE1heCA9IC1JbmZpbml0eTsKICAgICAgICAgICAgICAgICAgICBsZXQgeU1pbiA9IEluZmluaXR5OwogICAgICAgICAgICAgICAgICAgIGxldCB5TWF4ID0gLUluZmluaXR5OwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcGF0aCBvZiB0aGlzLnBhdGhzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2ZpcnN0LCBjb250cm9sMSwgY29udHJvbDIsIHNlY29uZF0gb2YgcGF0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmJveCA9IF91dGlsLlV0aWwuYmV6aWVyQm91bmRpbmdCb3goLi4uZmlyc3QsIC4uLmNvbnRyb2wxLCAuLi5jb250cm9sMiwgLi4uc2Vjb25kKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhNaW4gPSBNYXRoLm1pbih4TWluLCBiYm94WzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHlNaW4gPSBNYXRoLm1pbih5TWluLCBiYm94WzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhNYXggPSBNYXRoLm1heCh4TWF4LCBiYm94WzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHlNYXggPSBNYXRoLm1heCh5TWF4LCBiYm94WzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3hNaW4sIHlNaW4sIHhNYXgsIHlNYXhdOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2dldFBhZGRpbmcyKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Rpc2FibGVFZGl0aW5nKSA/IE1hdGguY2VpbCh0aGlzLnRoaWNrbmVzcyAqIHRoaXMucGFyZW50U2NhbGUpIDogMDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9maXRUb0NvbnRlbnQyKCkgewogICAgICAgICAgICAgICAgICAgIGxldCBmaXJzdFRpbWUgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kaXNhYmxlRWRpdGluZykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVkcmF3LCBfcmVkcmF3MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBiYm94ID0gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZ2V0QmJveCwgX2dldEJib3gyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZGRpbmcgPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9nZXRQYWRkaW5nLCBfZ2V0UGFkZGluZzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9iYXNlV2lkdGgsIE1hdGgubWF4KFJFU0laRVJfU0laRSwgYmJveFsyXSAtIGJib3hbMF0pKTsKICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2Jhc2VIZWlnaHQsIE1hdGgubWF4KFJFU0laRVJfU0laRSwgYmJveFszXSAtIGJib3hbMV0pKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IE1hdGguY2VpbChwYWRkaW5nICsgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9iYXNlV2lkdGgpICogdGhpcy5zY2FsZUZhY3Rvcik7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gTWF0aC5jZWlsKHBhZGRpbmcgKyBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Jhc2VIZWlnaHQpICogdGhpcy5zY2FsZUZhY3Rvcik7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgIHRoaXMud2lkdGggPSB3aWR0aCAvIHBhcmVudFdpZHRoOwogICAgICAgICAgICAgICAgICAgIHRoaXMuaGVpZ2h0ID0gaGVpZ2h0IC8gcGFyZW50SGVpZ2h0OwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfYXNwZWN0UmF0aW8sIHdpZHRoIC8gaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRNaW5EaW1zLCBfc2V0TWluRGltczIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJldlRyYW5zbGF0aW9uWCA9IHRoaXMudHJhbnNsYXRpb25YOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHByZXZUcmFuc2xhdGlvblkgPSB0aGlzLnRyYW5zbGF0aW9uWTsKICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zbGF0aW9uWCA9IC1iYm94WzBdOwogICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNsYXRpb25ZID0gLWJib3hbMV07CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0Q2FudmFzRGltcywgX3NldENhbnZhc0RpbXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9yZWFsV2lkdGgsIHdpZHRoKTsKICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3JlYWxIZWlnaHQsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1zKHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHVuc2NhbGVkUGFkZGluZyA9IGZpcnN0VGltZSA/IHBhZGRpbmcgLyB0aGlzLnNjYWxlRmFjdG9yIC8gMiA6IDA7CiAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2xhdGUocHJldlRyYW5zbGF0aW9uWCAtIHRoaXMudHJhbnNsYXRpb25YIC0gdW5zY2FsZWRQYWRkaW5nLCBwcmV2VHJhbnNsYXRpb25ZIC0gdGhpcy50cmFuc2xhdGlvblkgLSB1bnNjYWxlZFBhZGRpbmcpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3NldE1pbkRpbXMyKCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICB9ID0gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pID49IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUubWluSGVpZ2h0ID0gYCR7UkVTSVpFUl9TSVpFfXB4YDsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUubWluV2lkdGggPSBgJHtNYXRoLnJvdW5kKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pICogUkVTSVpFUl9TSVpFKX1weGA7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUubWluV2lkdGggPSBgJHtSRVNJWkVSX1NJWkV9cHhgOwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5taW5IZWlnaHQgPSBgJHtNYXRoLnJvdW5kKFJFU0laRVJfU0laRSAvIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pKX1weGA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgX2RlZmluZVByb3BlcnR5KElua0VkaXRvciwgIl9kZWZhdWx0Q29sb3IiLCBudWxsKTsKICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShJbmtFZGl0b3IsICJfZGVmYXVsdE9wYWNpdHkiLCAxKTsKICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShJbmtFZGl0b3IsICJfZGVmYXVsdFRoaWNrbmVzcyIsIDEpOwogICAgICAgICAgICAgICAgX2RlZmluZVByb3BlcnR5KElua0VkaXRvciwgIl9sMTBuUHJvbWlzZSIsIHZvaWQgMCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoSW5rRWRpdG9yLCAiX3R5cGUiLCAiaW5rIik7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2NSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLmZpdEN1cnZlID0gdm9pZCAwOwogICAgICAgICAgICAgICAgY29uc3QgZml0Q3VydmUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE2Nik7CiAgICAgICAgICAgICAgICBleHBvcnRzLmZpdEN1cnZlID0gZml0Q3VydmU7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2NiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgZnVuY3Rpb24gZml0Q3VydmUocG9pbnRzLCBtYXhFcnJvciwgcHJvZ3Jlc3NDYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShwb2ludHMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoIkZpcnN0IGFyZ3VtZW50IHNob3VsZCBiZSBhbiBhcnJheSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwb2ludHMuZm9yRWFjaChwb2ludCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShwb2ludCkgfHwgcG9pbnQuc29tZShpdGVtID0+IHR5cGVvZiBpdGVtICE9PSAnbnVtYmVyJykgfHwgcG9pbnQubGVuZ3RoICE9PSBwb2ludHNbMF0ubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBFcnJvcigiRWFjaCBwb2ludCBzaG91bGQgYmUgYW4gYXJyYXkgb2YgbnVtYmVycy4gRWFjaCBwb2ludCBzaG91bGQgaGF2ZSB0aGUgc2FtZSBhbW91bnQgb2YgbnVtYmVycy4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHBvaW50cyA9IHBvaW50cy5maWx0ZXIoKHBvaW50LCBpKSA9PiBpID09PSAwIHx8ICFwb2ludC5ldmVyeSgodmFsLCBqKSA9PiB2YWwgPT09IHBvaW50c1tpIC0gMV1bal0pKTsKICAgICAgICAgICAgICAgICAgICBpZiAocG9pbnRzLmxlbmd0aCA8IDIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBsZW4gPSBwb2ludHMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxlZnRUYW5nZW50ID0gY3JlYXRlVGFuZ2VudChwb2ludHNbMV0sIHBvaW50c1swXSk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcmlnaHRUYW5nZW50ID0gY3JlYXRlVGFuZ2VudChwb2ludHNbbGVuIC0gMl0sIHBvaW50c1tsZW4gLSAxXSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZpdEN1YmljKHBvaW50cywgbGVmdFRhbmdlbnQsIHJpZ2h0VGFuZ2VudCwgbWF4RXJyb3IsIHByb2dyZXNzQ2FsbGJhY2spOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZml0Q3ViaWMocG9pbnRzLCBsZWZ0VGFuZ2VudCwgcmlnaHRUYW5nZW50LCBlcnJvciwgcHJvZ3Jlc3NDYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IE1heEl0ZXJhdGlvbnMgPSAyMDsKICAgICAgICAgICAgICAgICAgICB2YXIgYmV6Q3VydmUsIHUsIHVQcmltZSwgbWF4RXJyb3IsIHByZXZFcnIsIHNwbGl0UG9pbnQsIHByZXZTcGxpdCwgY2VudGVyVmVjdG9yLCB0b0NlbnRlclRhbmdlbnQsIGZyb21DZW50ZXJUYW5nZW50LCBiZXppZXJzLCBkaXN0LCBpOwogICAgICAgICAgICAgICAgICAgIGlmIChwb2ludHMubGVuZ3RoID09PSAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpc3QgPSBtYXRocy52ZWN0b3JMZW4obWF0aHMuc3VidHJhY3QocG9pbnRzWzBdLCBwb2ludHNbMV0pKSAvIDMuMDsKICAgICAgICAgICAgICAgICAgICAgICAgYmV6Q3VydmUgPSBbcG9pbnRzWzBdLCBtYXRocy5hZGRBcnJheXMocG9pbnRzWzBdLCBtYXRocy5tdWxJdGVtcyhsZWZ0VGFuZ2VudCwgZGlzdCkpLCBtYXRocy5hZGRBcnJheXMocG9pbnRzWzFdLCBtYXRocy5tdWxJdGVtcyhyaWdodFRhbmdlbnQsIGRpc3QpKSwgcG9pbnRzWzFdXTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtiZXpDdXJ2ZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHUgPSBjaG9yZExlbmd0aFBhcmFtZXRlcml6ZShwb2ludHMpOwogICAgICAgICAgICAgICAgICAgIFtiZXpDdXJ2ZSwgbWF4RXJyb3IsIHNwbGl0UG9pbnRdID0gZ2VuZXJhdGVBbmRSZXBvcnQocG9pbnRzLCB1LCB1LCBsZWZ0VGFuZ2VudCwgcmlnaHRUYW5nZW50LCBwcm9ncmVzc0NhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICBpZiAobWF4RXJyb3IgPT09IDAgfHwgbWF4RXJyb3IgPCBlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW2JlekN1cnZlXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKG1heEVycm9yIDwgZXJyb3IgKiBlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICB1UHJpbWUgPSB1OwogICAgICAgICAgICAgICAgICAgICAgICBwcmV2RXJyID0gbWF4RXJyb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIHByZXZTcGxpdCA9IHNwbGl0UG9pbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBNYXhJdGVyYXRpb25zOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVQcmltZSA9IHJlcGFyYW1ldGVyaXplKGJlekN1cnZlLCBwb2ludHMsIHVQcmltZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBbYmV6Q3VydmUsIG1heEVycm9yLCBzcGxpdFBvaW50XSA9IGdlbmVyYXRlQW5kUmVwb3J0KHBvaW50cywgdSwgdVByaW1lLCBsZWZ0VGFuZ2VudCwgcmlnaHRUYW5nZW50LCBwcm9ncmVzc0NhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXhFcnJvciA8IGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtiZXpDdXJ2ZV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNwbGl0UG9pbnQgPT09IHByZXZTcGxpdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBlcnJDaGFuZ2UgPSBtYXhFcnJvciAvIHByZXZFcnI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVyckNoYW5nZSA+IC45OTk5ICYmIGVyckNoYW5nZSA8IDEuMDAwMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2RXJyID0gbWF4RXJyb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2U3BsaXQgPSBzcGxpdFBvaW50OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJlemllcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICBjZW50ZXJWZWN0b3IgPSBtYXRocy5zdWJ0cmFjdChwb2ludHNbc3BsaXRQb2ludCAtIDFdLCBwb2ludHNbc3BsaXRQb2ludCArIDFdKTsKICAgICAgICAgICAgICAgICAgICBpZiAoY2VudGVyVmVjdG9yLmV2ZXJ5KHZhbCA9PiB2YWwgPT09IDApKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNlbnRlclZlY3RvciA9IG1hdGhzLnN1YnRyYWN0KHBvaW50c1tzcGxpdFBvaW50IC0gMV0sIHBvaW50c1tzcGxpdFBvaW50XSk7CiAgICAgICAgICAgICAgICAgICAgICAgIFtjZW50ZXJWZWN0b3JbMF0sIGNlbnRlclZlY3RvclsxXV0gPSBbLWNlbnRlclZlY3RvclsxXSwgY2VudGVyVmVjdG9yWzBdXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdG9DZW50ZXJUYW5nZW50ID0gbWF0aHMubm9ybWFsaXplKGNlbnRlclZlY3Rvcik7CiAgICAgICAgICAgICAgICAgICAgZnJvbUNlbnRlclRhbmdlbnQgPSBtYXRocy5tdWxJdGVtcyh0b0NlbnRlclRhbmdlbnQsIC0xKTsKICAgICAgICAgICAgICAgICAgICBiZXppZXJzID0gYmV6aWVycy5jb25jYXQoZml0Q3ViaWMocG9pbnRzLnNsaWNlKDAsIHNwbGl0UG9pbnQgKyAxKSwgbGVmdFRhbmdlbnQsIHRvQ2VudGVyVGFuZ2VudCwgZXJyb3IsIHByb2dyZXNzQ2FsbGJhY2spKTsKICAgICAgICAgICAgICAgICAgICBiZXppZXJzID0gYmV6aWVycy5jb25jYXQoZml0Q3ViaWMocG9pbnRzLnNsaWNlKHNwbGl0UG9pbnQpLCBmcm9tQ2VudGVyVGFuZ2VudCwgcmlnaHRUYW5nZW50LCBlcnJvciwgcHJvZ3Jlc3NDYWxsYmFjaykpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBiZXppZXJzOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2VuZXJhdGVBbmRSZXBvcnQocG9pbnRzLCBwYXJhbXNPcmlnLCBwYXJhbXNQcmltZSwgbGVmdFRhbmdlbnQsIHJpZ2h0VGFuZ2VudCwgcHJvZ3Jlc3NDYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgIHZhciBiZXpDdXJ2ZSwgbWF4RXJyb3IsIHNwbGl0UG9pbnQ7CiAgICAgICAgICAgICAgICAgICAgYmV6Q3VydmUgPSBnZW5lcmF0ZUJlemllcihwb2ludHMsIHBhcmFtc1ByaW1lLCBsZWZ0VGFuZ2VudCwgcmlnaHRUYW5nZW50LCBwcm9ncmVzc0NhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICBbbWF4RXJyb3IsIHNwbGl0UG9pbnRdID0gY29tcHV0ZU1heEVycm9yKHBvaW50cywgYmV6Q3VydmUsIHBhcmFtc09yaWcpOwogICAgICAgICAgICAgICAgICAgIGlmIChwcm9ncmVzc0NhbGxiYWNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHByb2dyZXNzQ2FsbGJhY2soewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmV6OiBiZXpDdXJ2ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50czogcG9pbnRzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zOiBwYXJhbXNPcmlnLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4RXJyOiBtYXhFcnJvciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1heFBvaW50OiBzcGxpdFBvaW50CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gW2JlekN1cnZlLCBtYXhFcnJvciwgc3BsaXRQb2ludF07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZW5lcmF0ZUJlemllcihwb2ludHMsIHBhcmFtZXRlcnMsIGxlZnRUYW5nZW50LCByaWdodFRhbmdlbnQpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgYmV6Q3VydmUsCiAgICAgICAgICAgICAgICAgICAgICAgIEEsCiAgICAgICAgICAgICAgICAgICAgICAgIGEsCiAgICAgICAgICAgICAgICAgICAgICAgIEMsCiAgICAgICAgICAgICAgICAgICAgICAgIFgsCiAgICAgICAgICAgICAgICAgICAgICAgIGRldF9DMF9DMSwKICAgICAgICAgICAgICAgICAgICAgICAgZGV0X0MwX1gsCiAgICAgICAgICAgICAgICAgICAgICAgIGRldF9YX0MxLAogICAgICAgICAgICAgICAgICAgICAgICBhbHBoYV9sLAogICAgICAgICAgICAgICAgICAgICAgICBhbHBoYV9yLAogICAgICAgICAgICAgICAgICAgICAgICBlcHNpbG9uLAogICAgICAgICAgICAgICAgICAgICAgICBzZWdMZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgIGksCiAgICAgICAgICAgICAgICAgICAgICAgIGxlbiwKICAgICAgICAgICAgICAgICAgICAgICAgdG1wLAogICAgICAgICAgICAgICAgICAgICAgICB1LAogICAgICAgICAgICAgICAgICAgICAgICB1eCwKICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3RQb2ludCA9IHBvaW50c1swXSwKICAgICAgICAgICAgICAgICAgICAgICAgbGFzdFBvaW50ID0gcG9pbnRzW3BvaW50cy5sZW5ndGggLSAxXTsKICAgICAgICAgICAgICAgICAgICBiZXpDdXJ2ZSA9IFtmaXJzdFBvaW50LCBudWxsLCBudWxsLCBsYXN0UG9pbnRdOwogICAgICAgICAgICAgICAgICAgIEEgPSBtYXRocy56ZXJvc19YeDJ4MihwYXJhbWV0ZXJzLmxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMCwgbGVuID0gcGFyYW1ldGVycy5sZW5ndGg7IGkgPCBsZW47IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICB1ID0gcGFyYW1ldGVyc1tpXTsKICAgICAgICAgICAgICAgICAgICAgICAgdXggPSAxIC0gdTsKICAgICAgICAgICAgICAgICAgICAgICAgYSA9IEFbaV07CiAgICAgICAgICAgICAgICAgICAgICAgIGFbMF0gPSBtYXRocy5tdWxJdGVtcyhsZWZ0VGFuZ2VudCwgMyAqIHUgKiAodXggKiB1eCkpOwogICAgICAgICAgICAgICAgICAgICAgICBhWzFdID0gbWF0aHMubXVsSXRlbXMocmlnaHRUYW5nZW50LCAzICogdXggKiAodSAqIHUpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgQyA9IFtbMCwgMF0sIFswLCAwXV07CiAgICAgICAgICAgICAgICAgICAgWCA9IFswLCAwXTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBsZW4gPSBwb2ludHMubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgdSA9IHBhcmFtZXRlcnNbaV07CiAgICAgICAgICAgICAgICAgICAgICAgIGEgPSBBW2ldOwogICAgICAgICAgICAgICAgICAgICAgICBDWzBdWzBdICs9IG1hdGhzLmRvdChhWzBdLCBhWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ1swXVsxXSArPSBtYXRocy5kb3QoYVswXSwgYVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIENbMV1bMF0gKz0gbWF0aHMuZG90KGFbMF0sIGFbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICBDWzFdWzFdICs9IG1hdGhzLmRvdChhWzFdLCBhWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wID0gbWF0aHMuc3VidHJhY3QocG9pbnRzW2ldLCBiZXppZXIucShbZmlyc3RQb2ludCwgZmlyc3RQb2ludCwgbGFzdFBvaW50LCBsYXN0UG9pbnRdLCB1KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIFhbMF0gKz0gbWF0aHMuZG90KGFbMF0sIHRtcCk7CiAgICAgICAgICAgICAgICAgICAgICAgIFhbMV0gKz0gbWF0aHMuZG90KGFbMV0sIHRtcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRldF9DMF9DMSA9IENbMF1bMF0gKiBDWzFdWzFdIC0gQ1sxXVswXSAqIENbMF1bMV07CiAgICAgICAgICAgICAgICAgICAgZGV0X0MwX1ggPSBDWzBdWzBdICogWFsxXSAtIENbMV1bMF0gKiBYWzBdOwogICAgICAgICAgICAgICAgICAgIGRldF9YX0MxID0gWFswXSAqIENbMV1bMV0gLSBYWzFdICogQ1swXVsxXTsKICAgICAgICAgICAgICAgICAgICBhbHBoYV9sID0gZGV0X0MwX0MxID09PSAwID8gMCA6IGRldF9YX0MxIC8gZGV0X0MwX0MxOwogICAgICAgICAgICAgICAgICAgIGFscGhhX3IgPSBkZXRfQzBfQzEgPT09IDAgPyAwIDogZGV0X0MwX1ggLyBkZXRfQzBfQzE7CiAgICAgICAgICAgICAgICAgICAgc2VnTGVuZ3RoID0gbWF0aHMudmVjdG9yTGVuKG1hdGhzLnN1YnRyYWN0KGZpcnN0UG9pbnQsIGxhc3RQb2ludCkpOwogICAgICAgICAgICAgICAgICAgIGVwc2lsb24gPSAxLjBlLTYgKiBzZWdMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgaWYgKGFscGhhX2wgPCBlcHNpbG9uIHx8IGFscGhhX3IgPCBlcHNpbG9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJlekN1cnZlWzFdID0gbWF0aHMuYWRkQXJyYXlzKGZpcnN0UG9pbnQsIG1hdGhzLm11bEl0ZW1zKGxlZnRUYW5nZW50LCBzZWdMZW5ndGggLyAzLjApKTsKICAgICAgICAgICAgICAgICAgICAgICAgYmV6Q3VydmVbMl0gPSBtYXRocy5hZGRBcnJheXMobGFzdFBvaW50LCBtYXRocy5tdWxJdGVtcyhyaWdodFRhbmdlbnQsIHNlZ0xlbmd0aCAvIDMuMCkpOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJlekN1cnZlWzFdID0gbWF0aHMuYWRkQXJyYXlzKGZpcnN0UG9pbnQsIG1hdGhzLm11bEl0ZW1zKGxlZnRUYW5nZW50LCBhbHBoYV9sKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGJlekN1cnZlWzJdID0gbWF0aHMuYWRkQXJyYXlzKGxhc3RQb2ludCwgbWF0aHMubXVsSXRlbXMocmlnaHRUYW5nZW50LCBhbHBoYV9yKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBiZXpDdXJ2ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHJlcGFyYW1ldGVyaXplKGJlemllciwgcG9pbnRzLCBwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhcmFtZXRlcnMubWFwKChwLCBpKSA9PiBuZXd0b25SYXBoc29uUm9vdEZpbmQoYmV6aWVyLCBwb2ludHNbaV0sIHApKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG5ld3RvblJhcGhzb25Sb290RmluZChiZXosIHBvaW50LCB1KSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGQgPSBtYXRocy5zdWJ0cmFjdChiZXppZXIucShiZXosIHUpLCBwb2ludCksCiAgICAgICAgICAgICAgICAgICAgICAgIHFwcmltZSA9IGJlemllci5xcHJpbWUoYmV6LCB1KSwKICAgICAgICAgICAgICAgICAgICAgICAgbnVtZXJhdG9yID0gbWF0aHMubXVsTWF0cml4KGQsIHFwcmltZSksCiAgICAgICAgICAgICAgICAgICAgICAgIGRlbm9taW5hdG9yID0gbWF0aHMuc3VtKG1hdGhzLnNxdWFyZUl0ZW1zKHFwcmltZSkpICsgMiAqIG1hdGhzLm11bE1hdHJpeChkLCBiZXppZXIucXByaW1lcHJpbWUoYmV6LCB1KSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGRlbm9taW5hdG9yID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1IC0gbnVtZXJhdG9yIC8gZGVub21pbmF0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gY2hvcmRMZW5ndGhQYXJhbWV0ZXJpemUocG9pbnRzKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHUgPSBbXSwKICAgICAgICAgICAgICAgICAgICAgICAgY3VyclUsCiAgICAgICAgICAgICAgICAgICAgICAgIHByZXZVLAogICAgICAgICAgICAgICAgICAgICAgICBwcmV2UDsKICAgICAgICAgICAgICAgICAgICBwb2ludHMuZm9yRWFjaCgocCwgaSkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICBjdXJyVSA9IGkgPyBwcmV2VSArIG1hdGhzLnZlY3RvckxlbihtYXRocy5zdWJ0cmFjdChwLCBwcmV2UCkpIDogMDsKICAgICAgICAgICAgICAgICAgICAgICAgdS5wdXNoKGN1cnJVKTsKICAgICAgICAgICAgICAgICAgICAgICAgcHJldlUgPSBjdXJyVTsKICAgICAgICAgICAgICAgICAgICAgICAgcHJldlAgPSBwOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHUgPSB1Lm1hcCh4ID0+IHggLyBwcmV2VSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICA7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjb21wdXRlTWF4RXJyb3IocG9pbnRzLCBiZXosIHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgZGlzdCwgbWF4RGlzdCwgc3BsaXRQb2ludCwgdiwgaSwgY291bnQsIHBvaW50LCB0OwogICAgICAgICAgICAgICAgICAgIG1heERpc3QgPSAwOwogICAgICAgICAgICAgICAgICAgIHNwbGl0UG9pbnQgPSBNYXRoLmZsb29yKHBvaW50cy5sZW5ndGggLyAyKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB0X2Rpc3RNYXAgPSBtYXBUdG9SZWxhdGl2ZURpc3RhbmNlcyhiZXosIDEwKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBjb3VudCA9IHBvaW50cy5sZW5ndGg7IGkgPCBjb3VudDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50ID0gcG9pbnRzW2ldOwogICAgICAgICAgICAgICAgICAgICAgICB0ID0gZmluZF90KGJleiwgcGFyYW1ldGVyc1tpXSwgdF9kaXN0TWFwLCAxMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHYgPSBtYXRocy5zdWJ0cmFjdChiZXppZXIucShiZXosIHQpLCBwb2ludCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpc3QgPSB2WzBdICogdlswXSArIHZbMV0gKiB2WzFdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGlzdCA+IG1heERpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1heERpc3QgPSBkaXN0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3BsaXRQb2ludCA9IGk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFttYXhEaXN0LCBzcGxpdFBvaW50XTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIHZhciBtYXBUdG9SZWxhdGl2ZURpc3RhbmNlcyA9IGZ1bmN0aW9uIChiZXosIEJfcGFydHMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgQl90X2N1cnI7CiAgICAgICAgICAgICAgICAgICAgdmFyIEJfdF9kaXN0ID0gWzBdOwogICAgICAgICAgICAgICAgICAgIHZhciBCX3RfcHJldiA9IGJlelswXTsKICAgICAgICAgICAgICAgICAgICB2YXIgc3VtTGVuID0gMDsKICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMTsgaSA8PSBCX3BhcnRzOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgQl90X2N1cnIgPSBiZXppZXIucShiZXosIGkgLyBCX3BhcnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VtTGVuICs9IG1hdGhzLnZlY3RvckxlbihtYXRocy5zdWJ0cmFjdChCX3RfY3VyciwgQl90X3ByZXYpKTsKICAgICAgICAgICAgICAgICAgICAgICAgQl90X2Rpc3QucHVzaChzdW1MZW4pOwogICAgICAgICAgICAgICAgICAgICAgICBCX3RfcHJldiA9IEJfdF9jdXJyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBCX3RfZGlzdCA9IEJfdF9kaXN0Lm1hcCh4ID0+IHggLyBzdW1MZW4pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBCX3RfZGlzdDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBmaW5kX3QoYmV6LCBwYXJhbSwgdF9kaXN0TWFwLCBCX3BhcnRzKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmFtIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmFtID4gMSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdmFyIGxlbk1heCwgbGVuTWluLCB0TWF4LCB0TWluLCB0OwogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAxOyBpIDw9IEJfcGFydHM7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFyYW0gPD0gdF9kaXN0TWFwW2ldKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0TWluID0gKGkgLSAxKSAvIEJfcGFydHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0TWF4ID0gaSAvIEJfcGFydHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5NaW4gPSB0X2Rpc3RNYXBbaSAtIDFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVuTWF4ID0gdF9kaXN0TWFwW2ldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdCA9IChwYXJhbSAtIGxlbk1pbikgLyAobGVuTWF4IC0gbGVuTWluKSAqICh0TWF4IC0gdE1pbikgKyB0TWluOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjcmVhdGVUYW5nZW50KHBvaW50QSwgcG9pbnRCKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hdGhzLm5vcm1hbGl6ZShtYXRocy5zdWJ0cmFjdChwb2ludEEsIHBvaW50QikpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgbWF0aHMgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB6ZXJvc19YeDJ4Mih4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB6cyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoeC0tKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB6cy5wdXNoKFswLCAwXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHpzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgbXVsSXRlbXMoaXRlbXMsIG11bHRpcGxpZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW1zLm1hcCh4ID0+IHggKiBtdWx0aXBsaWVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIG11bE1hdHJpeChtMSwgbTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG0xLnJlZHVjZSgoc3VtLCB4MSwgaSkgPT4gc3VtICsgeDEgKiBtMltpXSwgMCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBzdWJ0cmFjdChhcnIxLCBhcnIyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcnIxLm1hcCgoeDEsIGkpID0+IHgxIC0gYXJyMltpXSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBhZGRBcnJheXMoYXJyMSwgYXJyMikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYXJyMS5tYXAoKHgxLCBpKSA9PiB4MSArIGFycjJbaV0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgYWRkSXRlbXMoaXRlbXMsIGFkZGl0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtcy5tYXAoeCA9PiB4ICsgYWRkaXRpb24pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgc3VtKGl0ZW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtcy5yZWR1Y2UoKHN1bSwgeCkgPT4gc3VtICsgeCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBkb3QobTEsIG0yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBtYXRocy5tdWxNYXRyaXgobTEsIG0yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHZlY3Rvckxlbih2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBNYXRoLmh5cG90KC4uLnYpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgZGl2SXRlbXMoaXRlbXMsIGRpdmlzb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW1zLm1hcCh4ID0+IHggLyBkaXZpc29yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHNxdWFyZUl0ZW1zKGl0ZW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtcy5tYXAoeCA9PiB4ICogeCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBub3JtYWxpemUodikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXZJdGVtcyh2LCB0aGlzLnZlY3Rvckxlbih2KSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgYmV6aWVyIHsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgcShjdHJsUG9seSwgdCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdHggPSAxLjAgLSB0OwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgcEEgPSBtYXRocy5tdWxJdGVtcyhjdHJsUG9seVswXSwgdHggKiB0eCAqIHR4KSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBCID0gbWF0aHMubXVsSXRlbXMoY3RybFBvbHlbMV0sIDMgKiB0eCAqIHR4ICogdCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwQyA9IG1hdGhzLm11bEl0ZW1zKGN0cmxQb2x5WzJdLCAzICogdHggKiB0ICogdCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwRCA9IG1hdGhzLm11bEl0ZW1zKGN0cmxQb2x5WzNdLCB0ICogdCAqIHQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbWF0aHMuYWRkQXJyYXlzKG1hdGhzLmFkZEFycmF5cyhwQSwgcEIpLCBtYXRocy5hZGRBcnJheXMocEMsIHBEKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBxcHJpbWUoY3RybFBvbHksIHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHR4ID0gMS4wIC0gdDsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHBBID0gbWF0aHMubXVsSXRlbXMobWF0aHMuc3VidHJhY3QoY3RybFBvbHlbMV0sIGN0cmxQb2x5WzBdKSwgMyAqIHR4ICogdHgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcEIgPSBtYXRocy5tdWxJdGVtcyhtYXRocy5zdWJ0cmFjdChjdHJsUG9seVsyXSwgY3RybFBvbHlbMV0pLCA2ICogdHggKiB0KSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBDID0gbWF0aHMubXVsSXRlbXMobWF0aHMuc3VidHJhY3QoY3RybFBvbHlbM10sIGN0cmxQb2x5WzJdKSwgMyAqIHQgKiB0KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hdGhzLmFkZEFycmF5cyhtYXRocy5hZGRBcnJheXMocEEsIHBCKSwgcEMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgcXByaW1lcHJpbWUoY3RybFBvbHksIHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hdGhzLmFkZEFycmF5cyhtYXRocy5tdWxJdGVtcyhtYXRocy5hZGRBcnJheXMobWF0aHMuc3VidHJhY3QoY3RybFBvbHlbMl0sIG1hdGhzLm11bEl0ZW1zKGN0cmxQb2x5WzFdLCAyKSksIGN0cmxQb2x5WzBdKSwgNiAqICgxLjAgLSB0KSksIG1hdGhzLm11bEl0ZW1zKG1hdGhzLmFkZEFycmF5cyhtYXRocy5zdWJ0cmFjdChjdHJsUG9seVszXSwgbWF0aHMubXVsSXRlbXMoY3RybFBvbHlbMl0sIDIpKSwgY3RybFBvbHlbMV0pLCA2ICogdCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZml0Q3VydmU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cy5maXRDdWJpYyA9IGZpdEN1YmljOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMuY3JlYXRlVGFuZ2VudCA9IGNyZWF0ZVRhbmdlbnQ7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2NyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICA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XRpb25FbGVtZW50RmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGNyZWF0ZShwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN1YnR5cGUgPSBwYXJhbWV0ZXJzLmRhdGEuYW5ub3RhdGlvblR5cGU7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoc3VidHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5MSU5LOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgTGlua0Fubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5URVhUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgVGV4dEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5XSURHRVQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmllbGRUeXBlID0gcGFyYW1ldGVycy5kYXRhLmZpZWxkVHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGZpZWxkVHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJUeCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFRleHRXaWRnZXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiQnRuIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYXJhbWV0ZXJzLmRhdGEucmFkaW9CdXR0b24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFJhZGlvQnV0dG9uV2lkZ2V0QW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHBhcmFtZXRlcnMuZGF0YS5jaGVja0JveCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgQ2hlY2tib3hXaWRnZXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHVzaEJ1dHRvbldpZGdldEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJDaCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IENob2ljZVdpZGdldEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFdpZGdldEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5QT1BVUDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFBvcHVwQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkZSRUVURVhUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgRnJlZVRleHRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuTElORToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IExpbmVBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuU1FVQVJFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgU3F1YXJlQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkNJUkNMRToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IENpcmNsZUFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5QT0xZTElORToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFBvbHlsaW5lQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkNBUkVUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgQ2FyZXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuSU5LOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgSW5rQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLlBPTFlHT046CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBQb2x5Z29uQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkhJR0hMSUdIVDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEhpZ2hsaWdodEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5VTkRFUkxJTkU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBVbmRlcmxpbmVBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuU1FVSUdHTFk6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBTcXVpZ2dseUFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5TVFJJS0VPVVQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBTdHJpa2VPdXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuU1RBTVA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBTdGFtcEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5GSUxFQVRUQUNITUVOVDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEZpbGVBdHRhY2htZW50QW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXIgPSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZVF1YWRyaWxhdGVyYWxzID0gZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNSZW5kZXJhYmxlID0gaXNSZW5kZXJhYmxlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRhdGEgPSBwYXJhbWV0ZXJzLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGF5ZXIgPSBwYXJhbWV0ZXJzLmxheWVyOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhZ2UgPSBwYXJhbWV0ZXJzLnBhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudmlld3BvcnQgPSBwYXJhbWV0ZXJzLnZpZXdwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmtTZXJ2aWNlID0gcGFyYW1ldGVycy5saW5rU2VydmljZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kb3dubG9hZE1hbmFnZXIgPSBwYXJhbWV0ZXJzLmRvd25sb2FkTWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pbWFnZVJlc291cmNlc1BhdGggPSBwYXJhbWV0ZXJzLmltYWdlUmVzb3VyY2VzUGF0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZW5kZXJGb3JtcyA9IHBhcmFtZXRlcnMucmVuZGVyRm9ybXM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3ZnRmFjdG9yeSA9IHBhcmFtZXRlcnMuc3ZnRmFjdG9yeTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbm5vdGF0aW9uU3RvcmFnZSA9IHBhcmFtZXRlcnMuYW5ub3RhdGlvblN0b3JhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlU2NyaXB0aW5nID0gcGFyYW1ldGVycy5lbmFibGVTY3JpcHRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaGFzSlNBY3Rpb25zID0gcGFyYW1ldGVycy5oYXNKU0FjdGlvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZpZWxkT2JqZWN0cyA9IHBhcmFtZXRlcnMuZmllbGRPYmplY3RzOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNSZW5kZXJhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lciA9IHRoaXMuX2NyZWF0ZUNvbnRhaW5lcihpZ25vcmVCb3JkZXIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjcmVhdGVRdWFkcmlsYXRlcmFscykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5xdWFkcmlsYXRlcmFscyA9IHRoaXMuX2NyZWF0ZVF1YWRyaWxhdGVyYWxzKGlnbm9yZUJvcmRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NyZWF0ZUNvbnRhaW5lcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGlnbm9yZUJvcmRlciA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRhaW5lciA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInNlY3Rpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnNldEF0dHJpYnV0ZSgiZGF0YS1hbm5vdGF0aW9uLWlkIiwgZGF0YS5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLm5vUm90YXRlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuY2xhc3NMaXN0LmFkZCgibm9yb3RhdGUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlV2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlSGVpZ2h0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlWQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdmlld3BvcnQucmF3RGltczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSBfdXRpbC5VdGlsLm5vcm1hbGl6ZVJlY3QoW2RhdGEucmVjdFswXSwgcGFnZS52aWV3WzNdIC0gZGF0YS5yZWN0WzFdICsgcGFnZS52aWV3WzFdLCBkYXRhLnJlY3RbMl0sIHBhZ2Uudmlld1szXSAtIGRhdGEucmVjdFszXSArIHBhZ2Uudmlld1sxXV0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlnbm9yZUJvcmRlciAmJiBkYXRhLmJvcmRlclN0eWxlLndpZHRoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLmJvcmRlcldpZHRoID0gYCR7ZGF0YS5ib3JkZXJTdHlsZS53aWR0aH1weGA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBob3Jpem9udGFsUmFkaXVzID0gZGF0YS5ib3JkZXJTdHlsZS5ob3Jpem9udGFsQ29ybmVyUmFkaXVzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmVydGljYWxSYWRpdXMgPSBkYXRhLmJvcmRlclN0eWxlLnZlcnRpY2FsQ29ybmVyUmFkaXVzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGhvcml6b250YWxSYWRpdXMgPiAwIHx8IHZlcnRpY2FsUmFkaXVzID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJhZGl1cyA9IGBjYWxjKCR7aG9yaXpvbnRhbFJhZGl1c31weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpIC8gY2FsYygke3ZlcnRpY2FsUmFkaXVzfXB4ICogdmFyKC0tc2NhbGUtZmFjdG9yKSlgOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lci5zdHlsZS5ib3JkZXJSYWRpdXMgPSByYWRpdXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMgaW5zdGFuY2VvZiBSYWRpb0J1dHRvbldpZGdldEFubm90YXRpb25FbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFkaXVzID0gYGNhbGMoJHt3aWR0aH1weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpIC8gY2FsYygke2hlaWdodH1weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpYDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyUmFkaXVzID0gcmFkaXVzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChkYXRhLmJvcmRlclN0eWxlLnN0eWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlLlNPTElEOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyU3R5bGUgPSAic29saWQiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25Cb3JkZXJTdHlsZVR5cGUuREFTSEVEOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyU3R5bGUgPSAiZGFzaGVkIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlLkJFVkVMRUQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5pbXBsZW1lbnRlZCBib3JkZXIgc3R5bGU6IGJldmVsZWQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlLklOU0VUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlVuaW1wbGVtZW50ZWQgYm9yZGVyIHN0eWxlOiBpbnNldCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25Cb3JkZXJTdHlsZVR5cGUuVU5ERVJMSU5FOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyQm90dG9tU3R5bGUgPSAic29saWQiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJvcmRlckNvbG9yID0gZGF0YS5ib3JkZXJDb2xvciB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJvcmRlckNvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLmJvcmRlckNvbG9yID0gX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IoYm9yZGVyQ29sb3JbMF0gfCAwLCBib3JkZXJDb2xvclsxXSB8IDAsIGJvcmRlckNvbG9yWzJdIHwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lci5zdHlsZS5ib3JkZXJXaWR0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLmxlZnQgPSBgJHsxMDAgKiAocmVjdFswXSAtIHBhZ2VYKSAvIHBhZ2VXaWR0aH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLnRvcCA9IGAkezEwMCAqIChyZWN0WzFdIC0gcGFnZVkpIC8gcGFnZUhlaWdodH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb24KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmhhc093bkNhbnZhcyB8fCByb3RhdGlvbiA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLndpZHRoID0gYCR7MTAwICogd2lkdGggLyBwYWdlV2lkdGh9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuaGVpZ2h0ID0gYCR7MTAwICogaGVpZ2h0IC8gcGFnZUhlaWdodH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0Um90YXRpb24ocm90YXRpb24sIGNvbnRhaW5lcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0Um90YXRpb24oYW5nbGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnRhaW5lciA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VXaWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VIZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMudmlld3BvcnQucmF3RGltczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKHRoaXMuZGF0YS5yZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGVsZW1lbnRXaWR0aCwgZWxlbWVudEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFuZ2xlICUgMTgwID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50V2lkdGggPSAxMDAgKiB3aWR0aCAvIHBhZ2VXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnRIZWlnaHQgPSAxMDAgKiBoZWlnaHQgLyBwYWdlSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudFdpZHRoID0gMTAwICogaGVpZ2h0IC8gcGFnZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudEhlaWdodCA9IDEwMCAqIHdpZHRoIC8gcGFnZUhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUud2lkdGggPSBgJHtlbGVtZW50V2lkdGh9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lci5zdHlsZS5oZWlnaHQgPSBgJHtlbGVtZW50SGVpZ2h0fSVgOwogICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc2V0QXR0cmlidXRlKCJkYXRhLW1haW4tcm90YXRpb24iLCAoMzYwIC0gYW5nbGUpICUgMzYwKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IF9jb21tb25BY3Rpb25zKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzZXRDb2xvciA9IChqc05hbWUsIHN0eWxlTmFtZSwgZXZlbnQpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gZXZlbnQuZGV0YWlsW2pzTmFtZV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC50YXJnZXQuc3R5bGVbc3R5bGVOYW1lXSA9IF9zY3JpcHRpbmdfdXRpbHMuQ29sb3JDb252ZXJ0ZXJzW2Ake2NvbG9yWzBdfV9IVE1MYF0oY29sb3Iuc2xpY2UoMSkpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIl9jb21tb25BY3Rpb25zIiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzcGxheTogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhpZGRlbiA9IGV2ZW50LmRldGFpbC5kaXNwbGF5ICUgMiA9PT0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5zdHlsZS52aXNpYmlsaXR5ID0gaGlkZGVuID8gImhpZGRlbiIgOiAidmlzaWJsZSI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbm5vdGF0aW9uU3RvcmFnZS5zZXRWYWx1ZSh0aGlzLmRhdGEuaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGlkZGVuLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmludDogZXZlbnQuZGV0YWlsLmRpc3BsYXkgPT09IDAgfHwgZXZlbnQuZGV0YWlsLmRpc3BsYXkgPT09IDMKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmludDogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvblN0b3JhZ2Uuc2V0VmFsdWUodGhpcy5kYXRhLmlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50OiBldmVudC5kZXRhaWwucHJpbnQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaWRkZW46IGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5zdHlsZS52aXNpYmlsaXR5ID0gZXZlbnQuZGV0YWlsLmhpZGRlbiA/ICJoaWRkZW4iIDogInZpc2libGUiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvblN0b3JhZ2Uuc2V0VmFsdWUodGhpcy5kYXRhLmlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhpZGRlbjogZXZlbnQuZGV0YWlsLmhpZGRlbgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvY3VzOiBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0VGltZW91dCgoKSA9PiBldmVudC50YXJnZXQuZm9jdXMoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2ZW50U2Nyb2xsOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VyTmFtZTogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnRhcmdldC50aXRsZSA9IGV2ZW50LmRldGFpbC51c2VyTmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkb25seTogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5kZXRhaWwucmVhZG9ubHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnNldEF0dHJpYnV0ZSgicmVhZG9ubHkiLCAiIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnJlbW92ZUF0dHJpYnV0ZSgicmVhZG9ubHkiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWlyZWQ6IGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRSZXF1aXJlZChldmVudC50YXJnZXQsIGV2ZW50LmRldGFpbC5yZXF1aXJlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmdDb2xvcjogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldENvbG9yKCJiZ0NvbG9yIiwgImJhY2tncm91bmRDb2xvciIsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWxsQ29sb3I6IGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRDb2xvcigiZmlsbENvbG9yIiwgImJhY2tncm91bmRDb2xvciIsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmZ0NvbG9yOiBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0Q29sb3IoImZnQ29sb3IiLCAiY29sb3IiLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0Q29sb3IoInRleHRDb2xvciIsICJjb2xvciIsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBib3JkZXJDb2xvcjogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldENvbG9yKCJib3JkZXJDb2xvciIsICJib3JkZXJDb2xvciIsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJva2VDb2xvcjogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldENvbG9yKCJzdHJva2VDb2xvciIsICJib3JkZXJDb2xvciIsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbjogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFuZ2xlID0gZXZlbnQuZGV0YWlsLnJvdGF0aW9uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0Um90YXRpb24oYW5nbGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvblN0b3JhZ2Uuc2V0VmFsdWUodGhpcy5kYXRhLmlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uOiBhbmdsZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2Rpc3BhdGNoRXZlbnRGcm9tU2FuZGJveChhY3Rpb25zLCBqc0V2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbW1vbkFjdGlvbnMgPSB0aGlzLl9jb21tb25BY3Rpb25zOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG5hbWUgb2YgT2JqZWN0LmtleXMoanNFdmVudC5kZXRhaWwpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhY3Rpb24gPSBhY3Rpb25zW25hbWVdIHx8IGNvbW1vbkFjdGlvbnNbbmFtZV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY3Rpb24gPT09IG51bGwgfHwgYWN0aW9uID09PSB2b2lkIDAgPyB2b2lkIDAgOiBhY3Rpb24oanNFdmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldERlZmF1bHRQcm9wZXJ0aWVzRnJvbUpTKGVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmVuYWJsZVNjcmlwdGluZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0b3JlZERhdGEgPSB0aGlzLmFubm90YXRpb25TdG9yYWdlLmdldFJhd1ZhbHVlKHRoaXMuZGF0YS5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc3RvcmVkRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbW1vbkFjdGlvbnMgPSB0aGlzLl9jb21tb25BY3Rpb25zOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IFthY3Rpb25OYW1lLCBkZXRhaWxdIG9mIE9iamVjdC5lbnRyaWVzKHN0b3JlZERhdGEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhY3Rpb24gPSBjb21tb25BY3Rpb25zW2FjdGlvbk5hbWVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGV2ZW50UHJveHkgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbDogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgW2FjdGlvbk5hbWVdOiBkZXRhaWwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiBlbGVtZW50CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY3Rpb24oZXZlbnRQcm94eSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHN0b3JlZERhdGFbYWN0aW9uTmFtZV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NyZWF0ZVF1YWRyaWxhdGVyYWxzKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgaWdub3JlQm9yZGVyID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEucXVhZFBvaW50cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcXVhZHJpbGF0ZXJhbHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRSZWN0ID0gdGhpcy5kYXRhLnJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcXVhZFBvaW50IG9mIHRoaXMuZGF0YS5xdWFkUG9pbnRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRhdGEucmVjdCA9IFtxdWFkUG9pbnRbMl0ueCwgcXVhZFBvaW50WzJdLnksIHF1YWRQb2ludFsxXS54LCBxdWFkUG9pbnRbMV0ueV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBxdWFkcmlsYXRlcmFscy5wdXNoKHRoaXMuX2NyZWF0ZUNvbnRhaW5lcihpZ25vcmVCb3JkZXIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRhdGEucmVjdCA9IHNhdmVkUmVjdDsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHF1YWRyaWxhdGVyYWxzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY3JlYXRlUG9wdXAodHJpZ2dlciwgZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY29udGFpbmVyID0gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnF1YWRyaWxhdGVyYWxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmlnZ2VyID0gdHJpZ2dlciB8fCB0aGlzLnF1YWRyaWxhdGVyYWxzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyID0gdGhpcy5xdWFkcmlsYXRlcmFsc1swXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRyaWdnZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyaWdnZXIgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyaWdnZXIuY2xhc3NMaXN0LmFkZCgicG9wdXBUcmlnZ2VyQXJlYSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLmFwcGVuZCh0cmlnZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb3B1cEVsZW1lbnQgPSBuZXcgUG9wdXBFbGVtZW50KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyaWdnZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2xvcjogZGF0YS5jb2xvciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlT2JqOiBkYXRhLnRpdGxlT2JqLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9kaWZpY2F0aW9uRGF0ZTogZGF0YS5tb2RpZmljYXRpb25EYXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudHNPYmo6IGRhdGEuY29udGVudHNPYmosCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByaWNoVGV4dDogZGF0YS5yaWNoVGV4dCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhpZGVXcmFwcGVyOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb3B1cCA9IHBvcHVwRWxlbWVudC5yZW5kZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9wdXAuc3R5bGUubGVmdCA9ICIxMDAlIjsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLmFwcGVuZChwb3B1cCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9yZW5kZXJRdWFkcmlsYXRlcmFscyhjbGFzc05hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBxdWFkcmlsYXRlcmFsIG9mIHRoaXMucXVhZHJpbGF0ZXJhbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHF1YWRyaWxhdGVyYWwuY2xhc3NMaXN0LmFkZChjbGFzc05hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnF1YWRyaWxhdGVyYWxzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkFic3RyYWN0IG1ldGhvZCBgQW5ub3RhdGlvbkVsZW1lbnQucmVuZGVyYCBjYWxsZWQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2dldEVsZW1lbnRzQnlOYW1lKG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNraXBJZCA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmllbGRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9maWVsZE9iamVjdHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpZWxkT2JqID0gdGhpcy5fZmllbGRPYmplY3RzW25hbWVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpZWxkT2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHBvcnRWYWx1ZXMKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IG9mIGZpZWxkT2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYWdlID09PSAtMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlkID09PSBza2lwSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGV4cG9ydFZhbHVlID0gdHlwZW9mIGV4cG9ydFZhbHVlcyA9PT0gInN0cmluZyIgPyBleHBvcnRWYWx1ZXMgOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkb21FbGVtZW50ID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcihgW2RhdGEtZWxlbWVudC1pZD0iJHtpZH0iXWApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9tRWxlbWVudCAmJiAhR2V0RWxlbWVudHNCeU5hbWVTZXQuaGFzKGRvbUVsZW1lbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYF9nZXRFbGVtZW50c0J5TmFtZSAtIGVsZW1lbnQgbm90IGFsbG93ZWQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZHMucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4cG9ydFZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9tRWxlbWVudAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmllbGRzOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZG9tRWxlbWVudCBvZiBkb2N1bWVudC5nZXRFbGVtZW50c0J5TmFtZShuYW1lKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4cG9ydFZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZG9tRWxlbWVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gZG9tRWxlbWVudC5nZXRBdHRyaWJ1dGUoImRhdGEtZWxlbWVudC1pZCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlkID09PSBza2lwSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghR2V0RWxlbWVudHNCeU5hbWVTZXQuaGFzKGRvbUVsZW1lbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZHMucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXhwb3J0VmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9tRWxlbWVudAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZpZWxkczsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB2YXIgX3NldEludGVybmFsTGluayA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9iaW5kU2V0T0NHU3RhdGUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIExpbmtBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBvcHRpb25zID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlbmRlcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXI6ICEhKG9wdGlvbnMgIT09IG51bGwgJiYgb3B0aW9ucyAhPT0gdm9pZCAwICYmIG9wdGlvbnMuaWdub3JlQm9yZGVyKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZVF1YWRyaWxhdGVyYWxzOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2JpbmRTZXRPQ0dTdGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc2V0SW50ZXJuYWxMaW5rKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc1Rvb2x0aXBPbmx5ID0gcGFyYW1ldGVycy5kYXRhLmlzVG9vbHRpcE9ubHk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtTZXJ2aWNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsaW5rID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiYSIpOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5rLnNldEF0dHJpYnV0ZSgiZGF0YS1lbGVtZW50LWlkIiwgZGF0YS5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpc0JvdW5kID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnVybCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlua1NlcnZpY2UuYWRkTGlua0F0dHJpYnV0ZXMobGluaywgZGF0YS51cmwsIGRhdGEubmV3V2luZG93KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzQm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGRhdGEuYWN0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9iaW5kTmFtZWRBY3Rpb24obGluaywgZGF0YS5hY3Rpb24pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNCb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZGF0YS5hdHRhY2htZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9iaW5kQXR0YWNobWVudChsaW5rLCBkYXRhLmF0dGFjaG1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNCb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZGF0YS5zZXRPQ0dTdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfYmluZFNldE9DR1N0YXRlLCBfYmluZFNldE9DR1N0YXRlMikuY2FsbCh0aGlzLCBsaW5rLCBkYXRhLnNldE9DR1N0YXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzQm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGRhdGEuZGVzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmluZExpbmsobGluaywgZGF0YS5kZXN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzQm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEuYWN0aW9ucyAmJiAoZGF0YS5hY3Rpb25zLkFjdGlvbiB8fCBkYXRhLmFjdGlvbnNbIk1vdXNlIFVwIl0gfHwgZGF0YS5hY3Rpb25zWyJNb3VzZSBEb3duIl0pICYmIHRoaXMuZW5hYmxlU2NyaXB0aW5nICYmIHRoaXMuaGFzSlNBY3Rpb25zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmluZEpTQWN0aW9uKGxpbmssIGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzQm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEucmVzZXRGb3JtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmluZFJlc2V0Rm9ybUFjdGlvbihsaW5rLCBkYXRhLnJlc2V0Rm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNCb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuaXNUb29sdGlwT25seSAmJiAhaXNCb3VuZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2JpbmRMaW5rKGxpbmssICIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0JvdW5kID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5xdWFkcmlsYXRlcmFscykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3JlbmRlclF1YWRyaWxhdGVyYWxzKCJsaW5rQW5ub3RhdGlvbiIpLm1hcCgocXVhZHJpbGF0ZXJhbCwgaW5kZXgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsaW5rRWxlbWVudCA9IGluZGV4ID09PSAwID8gbGluayA6IGxpbmsuY2xvbmVOb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcXVhZHJpbGF0ZXJhbC5hcHBlbmQobGlua0VsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBxdWFkcmlsYXRlcmFsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCgibGlua0Fubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzQm91bmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChsaW5rKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9iaW5kTGluayhsaW5rLCBkZXN0aW5hdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICBsaW5rLmhyZWYgPSB0aGlzLmxpbmtTZXJ2aWNlLmdldERlc3RpbmF0aW9uSGFzaChkZXN0aW5hdGlvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmsub25jbGljayA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkZXN0aW5hdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGlua1NlcnZpY2UuZ29Ub0Rlc3RpbmF0aW9uKGRlc3RpbmF0aW9uKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRlc3RpbmF0aW9uIHx8IGRlc3RpbmF0aW9uID09PSAiIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0SW50ZXJuYWxMaW5rLCBfc2V0SW50ZXJuYWxMaW5rMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfYmluZE5hbWVkQWN0aW9uKGxpbmssIGFjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICBsaW5rLmhyZWYgPSB0aGlzLmxpbmtTZXJ2aWNlLmdldEFuY2hvclVybCgiIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmsub25jbGljayA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGlua1NlcnZpY2UuZXhlY3V0ZU5hbWVkQWN0aW9uKGFjdGlvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldEludGVybmFsTGluaywgX3NldEludGVybmFsTGluazIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9iaW5kQXR0YWNobWVudChsaW5rLCBhdHRhY2htZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmsuaHJlZiA9IHRoaXMubGlua1NlcnZpY2UuZ2V0QW5jaG9yVXJsKCIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluay5vbmNsaWNrID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGRvd25sb2FkTWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRkb3dubG9hZE1hbmFnZXIgPSB0aGlzLmRvd25sb2FkTWFuYWdlcikgPT09IG51bGwgfHwgX3RoaXMkZG93bmxvYWRNYW5hZ2VyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRkb3dubG9hZE1hbmFnZXIub3Blbk9yRG93bmxvYWREYXRhKHRoaXMuY29udGFpbmVyLCBhdHRhY2htZW50LmNvbnRlbnQsIGF0dGFjaG1lbnQuZmlsZW5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRJbnRlcm5hbExpbmssIF9zZXRJbnRlcm5hbExpbmsyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfYmluZEpTQWN0aW9uKGxpbmssIGRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGluay5ocmVmID0gdGhpcy5saW5rU2VydmljZS5nZXRBbmNob3JVcmwoIiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXAgPSBuZXcgTWFwKFtbIkFjdGlvbiIsICJvbmNsaWNrIl0sIFsiTW91c2UgVXAiLCAib25tb3VzZXVwIl0sIFsiTW91c2UgRG93biIsICJvbm1vdXNlZG93biJdXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbmFtZSBvZiBPYmplY3Qua2V5cyhkYXRhLmFjdGlvbnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBqc05hbWUgPSBtYXAuZ2V0KG5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFqc05hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtbanNOYW1lXSA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkbGlua1NlcnZpY2UkZXZlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRsaW5rU2VydmljZSRldmUgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmUgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGxpbmtTZXJ2aWNlJGV2ZS5kaXNwYXRjaCgiZGlzcGF0Y2hldmVudGluc2FuZGJveCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlOiB0aGlzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWw6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkOiBkYXRhLmlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWxpbmsub25jbGljaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluay5vbmNsaWNrID0gKCkgPT4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0SW50ZXJuYWxMaW5rLCBfc2V0SW50ZXJuYWxMaW5rMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2JpbmRSZXNldEZvcm1BY3Rpb24obGluaywgcmVzZXRGb3JtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG90aGVyQ2xpY2tBY3Rpb24gPSBsaW5rLm9uY2xpY2s7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb3RoZXJDbGlja0FjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluay5ocmVmID0gdGhpcy5saW5rU2VydmljZS5nZXRBbmNob3JVcmwoIiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldEludGVybmFsTGluaywgX3NldEludGVybmFsTGluazIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5fZmllbGRPYmplY3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYF9iaW5kUmVzZXRGb3JtQWN0aW9uIC0gInJlc2V0Rm9ybSIgYWN0aW9uIG5vdCBzdXBwb3J0ZWQsIGAgKyAiZW5zdXJlIHRoYXQgdGhlIGBmaWVsZE9iamVjdHNgIHBhcmFtZXRlciBpcyBwcm92aWRlZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb3RoZXJDbGlja0FjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmsub25jbGljayA9ICgpID0+IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmsub25jbGljayA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG90aGVyQ2xpY2tBY3Rpb24gPT09IG51bGwgfHwgb3RoZXJDbGlja0FjdGlvbiA9PT0gdm9pZCAwID8gdm9pZCAwIDogb3RoZXJDbGlja0FjdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpZWxkczogcmVzZXRGb3JtRmllbGRzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlZnM6IHJlc2V0Rm9ybVJlZnMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5jbHVkZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHJlc2V0Rm9ybTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFsbEZpZWxkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc2V0Rm9ybUZpZWxkcy5sZW5ndGggIT09IDAgfHwgcmVzZXRGb3JtUmVmcy5sZW5ndGggIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWVsZElkcyA9IG5ldyBTZXQocmVzZXRGb3JtUmVmcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBmaWVsZE5hbWUgb2YgcmVzZXRGb3JtRmllbGRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpZWxkcyA9IHRoaXMuX2ZpZWxkT2JqZWN0c1tmaWVsZE5hbWVdIHx8IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gb2YgZmllbGRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZElkcy5hZGQoaWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZmllbGRzIG9mIE9iamVjdC52YWx1ZXModGhpcy5fZmllbGRPYmplY3RzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGZpZWxkIG9mIGZpZWxkcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpZWxkSWRzLmhhcyhmaWVsZC5pZCkgPT09IGluY2x1ZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbGxGaWVsZHMucHVzaChmaWVsZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZmllbGRzIG9mIE9iamVjdC52YWx1ZXModGhpcy5fZmllbGRPYmplY3RzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbGxGaWVsZHMucHVzaCguLi5maWVsZHMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0b3JhZ2UgPSB0aGlzLmFubm90YXRpb25TdG9yYWdlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWxsSWRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGZpZWxkIG9mIGFsbEZpZWxkcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZmllbGQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxsSWRzLnB1c2goaWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZmllbGQudHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJ0ZXh0IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmFsdWUgPSBmaWVsZC5kZWZhdWx0VmFsdWUgfHwgIiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiY2hlY2tib3giOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJyYWRpb2J1dHRvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gZmllbGQuZGVmYXVsdFZhbHVlID09PSBmaWVsZC5leHBvcnRWYWx1ZXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiY29tYm9ib3giOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJsaXN0Ym94IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmFsdWUgPSBmaWVsZC5kZWZhdWx0VmFsdWUgfHwgIiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkb21FbGVtZW50ID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcihgW2RhdGEtZWxlbWVudC1pZD0iJHtpZH0iXWApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZG9tRWxlbWVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKCFHZXRFbGVtZW50c0J5TmFtZVNldC5oYXMoZG9tRWxlbWVudCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBfYmluZFJlc2V0Rm9ybUFjdGlvbiAtIGVsZW1lbnQgbm90IGFsbG93ZWQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb21FbGVtZW50LmRpc3BhdGNoRXZlbnQobmV3IEV2ZW50KCJyZXNldGZvcm0iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5lbmFibGVTY3JpcHRpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkbGlua1NlcnZpY2UkZXZlMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkbGlua1NlcnZpY2UkZXZlMiA9IHRoaXMubGlua1NlcnZpY2UuZXZlbnRCdXMpID09PSBudWxsIHx8IF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTIuZGlzcGF0Y2goImRpc3BhdGNoZXZlbnRpbnNhbmRib3giLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGV0YWlsOiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZDogImFwcCIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZHM6IGFsbElkcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6ICJSZXNldEZvcm0iCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0SW50ZXJuYWxMaW5rMigpIHsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5zZXRBdHRyaWJ1dGUoImRhdGEtaW50ZXJuYWwtbGluayIsICIiKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9iaW5kU2V0T0NHU3RhdGUyKGxpbmssIGFjdGlvbikgewogICAgICAgICAgICAgICAgICAgIGxpbmsuaHJlZiA9IHRoaXMubGlua1NlcnZpY2UuZ2V0QW5jaG9yVXJsKCIiKTsKICAgICAgICAgICAgICAgICAgICBsaW5rLm9uY2xpY2sgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGlua1NlcnZpY2UuZXhlY3V0ZVNldE9DR1N0YXRlKGFjdGlvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldEludGVybmFsTGluaywgX3NldEludGVybmFsTGluazIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBUZXh0QW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsLCBfcGFyYW1ldGVycyRkYXRhJGNvbnQsIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGwgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bCAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bC5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udCA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2ggIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2guc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInRleHRBbm5vdGF0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltYWdlID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiaW1nIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlLnNyYyA9IHRoaXMuaW1hZ2VSZXNvdXJjZXNQYXRoICsgImFubm90YXRpb24tIiArIHRoaXMuZGF0YS5uYW1lLnRvTG93ZXJDYXNlKCkgKyAiLnN2ZyI7CiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlLmFsdCA9ICJbe3t0eXBlfX0gQW5ub3RhdGlvbl0iOwogICAgICAgICAgICAgICAgICAgICAgICBpbWFnZS5kYXRhc2V0LmwxMG5JZCA9ICJ0ZXh0X2Fubm90YXRpb25fdHlwZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlLmRhdGFzZXQubDEwbkFyZ3MgPSBKU09OLnN0cmluZ2lmeSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiB0aGlzLmRhdGEubmFtZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKGltYWdlLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChpbWFnZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBXaWRnZXRBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEuYWx0ZXJuYXRpdmVUZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci50aXRsZSA9IHRoaXMuZGF0YS5hbHRlcm5hdGl2ZVRleHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZ2V0S2V5TW9kaWZpZXIoZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNXaW4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpc1dpbiAmJiBldmVudC5jdHJsS2V5IHx8IGlzTWFjICYmIGV2ZW50Lm1ldGFLZXk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zZXRFdmVudExpc3RlbmVyKGVsZW1lbnQsIGJhc2VOYW1lLCBldmVudE5hbWUsIHZhbHVlR2V0dGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChiYXNlTmFtZS5pbmNsdWRlcygibW91c2UiKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKGJhc2VOYW1lLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTMgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmUzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRsaW5rU2VydmljZSRldmUzLmRpc3BhdGNoKCJkaXNwYXRjaGV2ZW50aW5zYW5kYm94IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbDogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IHRoaXMuZGF0YS5pZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6IGV2ZW50TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2YWx1ZUdldHRlcihldmVudCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaGlmdDogZXZlbnQuc2hpZnRLZXksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb2RpZmllcjogdGhpcy5fZ2V0S2V5TW9kaWZpZXIoZXZlbnQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKGJhc2VOYW1lLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTQgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmU0ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRsaW5rU2VydmljZSRldmU0LmRpc3BhdGNoKCJkaXNwYXRjaGV2ZW50aW5zYW5kYm94IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbDogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IHRoaXMuZGF0YS5pZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6IGV2ZW50TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2YWx1ZUdldHRlcihldmVudCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldEV2ZW50TGlzdGVuZXJzKGVsZW1lbnQsIG5hbWVzLCBnZXR0ZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBbYmFzZU5hbWUsIGV2ZW50TmFtZV0gb2YgbmFtZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRkYXRhJGFjdGlvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnROYW1lID09PSAiQWN0aW9uIiB8fCAoX3RoaXMkZGF0YSRhY3Rpb25zID0gdGhpcy5kYXRhLmFjdGlvbnMpICE9PSBudWxsICYmIF90aGlzJGRhdGEkYWN0aW9ucyAhPT0gdm9pZCAwICYmIF90aGlzJGRhdGEkYWN0aW9uc1tldmVudE5hbWVdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RXZlbnRMaXN0ZW5lcihlbGVtZW50LCBiYXNlTmFtZSwgZXZlbnROYW1lLCBnZXR0ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zZXRCYWNrZ3JvdW5kQ29sb3IoZWxlbWVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xvciA9IHRoaXMuZGF0YS5iYWNrZ3JvdW5kQ29sb3IgfHwgbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zdHlsZS5iYWNrZ3JvdW5kQ29sb3IgPSBjb2xvciA9PT0gbnVsbCA/ICJ0cmFuc3BhcmVudCIgOiBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihjb2xvclswXSwgY29sb3JbMV0sIGNvbG9yWzJdKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldFRleHRTdHlsZShlbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFRFWFRfQUxJR05NRU5UID0gWyJsZWZ0IiwgImNlbnRlciIsICJyaWdodCJdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb250Q29sb3IKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZGF0YS5kZWZhdWx0QXBwZWFyYW5jZURhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRTaXplID0gdGhpcy5kYXRhLmRlZmF1bHRBcHBlYXJhbmNlRGF0YS5mb250U2l6ZSB8fCBERUZBVUxUX0ZPTlRfU0laRTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3R5bGUgPSBlbGVtZW50LnN0eWxlOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY29tcHV0ZWRGb250U2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQk9SREVSX1NJWkUgPSAyOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByb3VuZFRvT25lRGVjaW1hbCA9IHggPT4gTWF0aC5yb3VuZCgxMCAqIHgpIC8gMTA7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEubXVsdGlMaW5lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBNYXRoLmFicyh0aGlzLmRhdGEucmVjdFszXSAtIHRoaXMuZGF0YS5yZWN0WzFdIC0gQk9SREVSX1NJWkUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbnVtYmVyT2ZMaW5lcyA9IE1hdGgucm91bmQoaGVpZ2h0IC8gKF91dGlsLkxJTkVfRkFDVE9SICogZm9udFNpemUpKSB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGluZUhlaWdodCA9IGhlaWdodCAvIG51bWJlck9mTGluZXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wdXRlZEZvbnRTaXplID0gTWF0aC5taW4oZm9udFNpemUsIHJvdW5kVG9PbmVEZWNpbWFsKGxpbmVIZWlnaHQgLyBfdXRpbC5MSU5FX0ZBQ1RPUikpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gTWF0aC5hYnModGhpcy5kYXRhLnJlY3RbM10gLSB0aGlzLmRhdGEucmVjdFsxXSAtIEJPUkRFUl9TSVpFKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbXB1dGVkRm9udFNpemUgPSBNYXRoLm1pbihmb250U2l6ZSwgcm91bmRUb09uZURlY2ltYWwoaGVpZ2h0IC8gX3V0aWwuTElORV9GQUNUT1IpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5mb250U2l6ZSA9IGBjYWxjKCR7Y29tcHV0ZWRGb250U2l6ZX1weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpYDsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUuY29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihmb250Q29sb3JbMF0sIGZvbnRDb2xvclsxXSwgZm9udENvbG9yWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGF0YS50ZXh0QWxpZ25tZW50ICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS50ZXh0QWxpZ24gPSBURVhUX0FMSUdOTUVOVFt0aGlzLmRhdGEudGV4dEFsaWdubWVudF07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldFJlcXVpcmVkKGVsZW1lbnQsIGlzUmVxdWlyZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzUmVxdWlyZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc2V0QXR0cmlidXRlKCJyZXF1aXJlZCIsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5yZW1vdmVBdHRyaWJ1dGUoInJlcXVpcmVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGUoImFyaWEtcmVxdWlyZWQiLCBpc1JlcXVpcmVkKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBUZXh0V2lkZ2V0QW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBXaWRnZXRBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1JlbmRlcmFibGUgPSBwYXJhbWV0ZXJzLnJlbmRlckZvcm1zIHx8ICFwYXJhbWV0ZXJzLmRhdGEuaGFzQXBwZWFyYW5jZSAmJiAhIXBhcmFtZXRlcnMuZGF0YS5maWVsZFZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlbmRlcmFibGUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFByb3BlcnR5T25TaWJsaW5ncyhiYXNlLCBrZXksIHZhbHVlLCBrZXlJblN0b3JhZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RvcmFnZSA9IHRoaXMuYW5ub3RhdGlvblN0b3JhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWxlbWVudCBvZiB0aGlzLl9nZXRFbGVtZW50c0J5TmFtZShiYXNlLm5hbWUsIGJhc2UuaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWxlbWVudC5kb21FbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5kb21FbGVtZW50W2tleV0gPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoZWxlbWVudC5pZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFtrZXlJblN0b3JhZ2VdOiB2YWx1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdG9yYWdlID0gdGhpcy5hbm5vdGF0aW9uU3RvcmFnZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaWQgPSB0aGlzLmRhdGEuaWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInRleHRXaWRnZXRBbm5vdGF0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBlbGVtZW50ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucmVuZGVyRm9ybXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0b3JlZERhdGEgPSBzdG9yYWdlLmdldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuZGF0YS5maWVsZFZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0ZXh0Q29udGVudCA9IHN0b3JlZERhdGEuZm9ybWF0dGVkVmFsdWUgfHwgc3RvcmVkRGF0YS52YWx1ZSB8fCAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1heExlbiA9IHN0b3JhZ2UuZ2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGFyTGltaXQ6IHRoaXMuZGF0YS5tYXhMZW4KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pLmNoYXJMaW1pdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXhMZW4gJiYgdGV4dENvbnRlbnQubGVuZ3RoID4gbWF4TGVuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dENvbnRlbnQgPSB0ZXh0Q29udGVudC5zbGljZSgwLCBtYXhMZW4pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudERhdGEgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXNlclZhbHVlOiB0ZXh0Q29udGVudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JtYXR0ZWRWYWx1ZTogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXN0Q29tbWl0dGVkVmFsdWU6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tbWl0S2V5OiAxCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGF0YS5tdWx0aUxpbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgidGV4dGFyZWEiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnRleHRDb250ZW50ID0gdGV4dENvbnRlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGF0YS5kb05vdFNjcm9sbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnN0eWxlLm92ZXJmbG93WSA9ICJoaWRkZW4iOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImlucHV0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50eXBlID0gInRleHQiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc2V0QXR0cmlidXRlKCJ2YWx1ZSIsIHRleHRDb250ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kYXRhLmRvTm90U2Nyb2xsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc3R5bGUub3ZlcmZsb3dYID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgR2V0RWxlbWVudHNCeU5hbWVTZXQuYWRkKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGUoImRhdGEtZWxlbWVudC1pZCIsIGlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuZGlzYWJsZWQgPSB0aGlzLmRhdGEucmVhZE9ubHk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50Lm5hbWUgPSB0aGlzLmRhdGEuZmllbGROYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50YWJJbmRleCA9IERFRkFVTFRfVEFCX0lOREVYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0UmVxdWlyZWQoZWxlbWVudCwgdGhpcy5kYXRhLnJlcXVpcmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXhMZW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50Lm1heExlbmd0aCA9IG1heExlbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigiaW5wdXQiLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZXZlbnQudGFyZ2V0LnZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRQcm9wZXJ0eU9uU2libGluZ3MoZWxlbWVudCwgInZhbHVlIiwgZXZlbnQudGFyZ2V0LnZhbHVlLCAidmFsdWUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJyZXNldGZvcm0iLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGVmYXVsdFZhbHVlID0gdGhpcy5kYXRhLmRlZmF1bHRGaWVsZFZhbHVlID8/ICIiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQudmFsdWUgPSBlbGVtZW50RGF0YS51c2VyVmFsdWUgPSBkZWZhdWx0VmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEuZm9ybWF0dGVkVmFsdWUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgYmx1ckxpc3RlbmVyID0gZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9ybWF0dGVkVmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZWxlbWVudERhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZvcm1hdHRlZFZhbHVlICE9PSBudWxsICYmIGZvcm1hdHRlZFZhbHVlICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnZhbHVlID0gZm9ybWF0dGVkVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnRhcmdldC5zY3JvbGxMZWZ0ID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5lbmFibGVTY3JpcHRpbmcgJiYgdGhpcy5oYXNKU0FjdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZGF0YSRhY3Rpb25zMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoImZvY3VzIiwgZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGV2ZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWxlbWVudERhdGEudXNlclZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXQudmFsdWUgPSBlbGVtZW50RGF0YS51c2VyVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEubGFzdENvbW1pdHRlZFZhbHVlID0gdGFyZ2V0LnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50RGF0YS5jb21taXRLZXkgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigidXBkYXRlZnJvbXNhbmRib3giLCBqc0V2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWN0aW9ucyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEudXNlclZhbHVlID0gZXZlbnQuZGV0YWlsLnZhbHVlID8/ICIiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGVsZW1lbnREYXRhLnVzZXJWYWx1ZS50b1N0cmluZygpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnZhbHVlID0gZWxlbWVudERhdGEudXNlclZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcm1hdHRlZFZhbHVlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JtYXR0ZWRWYWx1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBldmVudC5kZXRhaWw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEuZm9ybWF0dGVkVmFsdWUgPSBmb3JtYXR0ZWRWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9ybWF0dGVkVmFsdWUgIT09IG51bGwgJiYgZm9ybWF0dGVkVmFsdWUgIT09IHVuZGVmaW5lZCAmJiBldmVudC50YXJnZXQgIT09IGRvY3VtZW50LmFjdGl2ZUVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnZhbHVlID0gZm9ybWF0dGVkVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9ybWF0dGVkVmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxSYW5nZShldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnRhcmdldC5zZXRTZWxlY3Rpb25SYW5nZSguLi5ldmVudC5kZXRhaWwuc2VsUmFuZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYXJMaW1pdDogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmU1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hhckxpbWl0CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGV2ZW50LmRldGFpbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBldmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hhckxpbWl0ID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldC5yZW1vdmVBdHRyaWJ1dGUoIm1heExlbmd0aCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldC5zZXRBdHRyaWJ1dGUoIm1heExlbmd0aCIsIGNoYXJMaW1pdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHZhbHVlID0gZWxlbWVudERhdGEudXNlclZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdmFsdWUgfHwgdmFsdWUubGVuZ3RoIDw9IGNoYXJMaW1pdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlID0gdmFsdWUuc2xpY2UoMCwgY2hhckxpbWl0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXQudmFsdWUgPSBlbGVtZW50RGF0YS51c2VyVmFsdWUgPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTUgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmU1ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRsaW5rU2VydmljZSRldmU1LmRpc3BhdGNoKCJkaXNwYXRjaGV2ZW50aW5zYW5kYm94IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbDogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiAiS2V5c3Ryb2tlIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lsbENvbW1pdDogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1pdEtleTogMSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbFN0YXJ0OiB0YXJnZXQuc2VsZWN0aW9uU3RhcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxFbmQ6IHRhcmdldC5zZWxlY3Rpb25FbmQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kaXNwYXRjaEV2ZW50RnJvbVNhbmRib3goYWN0aW9ucywganNFdmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkbGlua1NlcnZpY2UkZXZlNjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEuY29tbWl0S2V5ID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbW1pdEtleSA9IC0xOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQua2V5ID09PSAiRXNjYXBlIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tbWl0S2V5ID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChldmVudC5rZXkgPT09ICJFbnRlciIgJiYgIXRoaXMuZGF0YS5tdWx0aUxpbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1pdEtleSA9IDI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZXZlbnQua2V5ID09PSAiVGFiIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEuY29tbWl0S2V5ID0gMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY29tbWl0S2V5ID09PSAtMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBldmVudC50YXJnZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbGVtZW50RGF0YS5sYXN0Q29tbWl0dGVkVmFsdWUgPT09IHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEubGFzdENvbW1pdHRlZFZhbHVlID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnREYXRhLnVzZXJWYWx1ZSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkbGlua1NlcnZpY2UkZXZlNiA9IHRoaXMubGlua1NlcnZpY2UuZXZlbnRCdXMpID09PSBudWxsIHx8IF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTYgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTYuZGlzcGF0Y2goImRpc3BhdGNoZXZlbnRpbnNhbmRib3giLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWw6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiAiS2V5c3Ryb2tlIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWxsQ29tbWl0OiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1pdEtleSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxTdGFydDogZXZlbnQudGFyZ2V0LnNlbGVjdGlvblN0YXJ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbEVuZDogZXZlbnQudGFyZ2V0LnNlbGVjdGlvbkVuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBfYmx1ckxpc3RlbmVyID0gYmx1ckxpc3RlbmVyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJsdXJMaXN0ZW5lciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJibHVyIiwgZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWV2ZW50LnJlbGF0ZWRUYXJnZXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZXZlbnQudGFyZ2V0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50RGF0YS51c2VyVmFsdWUgPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVsZW1lbnREYXRhLmxhc3RDb21taXR0ZWRWYWx1ZSAhPT0gdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmU3OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTcgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmU3ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRsaW5rU2VydmljZSRldmU3LmRpc3BhdGNoKCJkaXNwYXRjaGV2ZW50aW5zYW5kYm94IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWw6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6ICJLZXlzdHJva2UiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lsbENvbW1pdDogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tbWl0S2V5OiBlbGVtZW50RGF0YS5jb21taXRLZXksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbFN0YXJ0OiBldmVudC50YXJnZXQuc2VsZWN0aW9uU3RhcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbEVuZDogZXZlbnQudGFyZ2V0LnNlbGVjdGlvbkVuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9ibHVyTGlzdGVuZXIoZXZlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoX3RoaXMkZGF0YSRhY3Rpb25zMiA9IHRoaXMuZGF0YS5hY3Rpb25zKSAhPT0gbnVsbCAmJiBfdGhpcyRkYXRhJGFjdGlvbnMyICE9PSB2b2lkIDAgJiYgX3RoaXMkZGF0YSRhY3Rpb25zMi5LZXlzdHJva2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJiZWZvcmVpbnB1dCIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmU4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEubGFzdENvbW1pdHRlZFZhbHVlID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGV2ZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGlvblN0YXJ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGlvbkVuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRhcmdldDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzZWxTdGFydCA9IHNlbGVjdGlvblN0YXJ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbEVuZCA9IHNlbGVjdGlvbkVuZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZXZlbnQuaW5wdXRUeXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiZGVsZXRlV29yZEJhY2t3YXJkIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hdGNoID0gdmFsdWUuc3Vic3RyaW5nKDAsIHNlbGVjdGlvblN0YXJ0KS5tYXRjaCgvXHcqW15cd10qJC8pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobWF0Y2gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbFN0YXJ0IC09IG1hdGNoWzBdLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiZGVsZXRlV29yZEZvcndhcmQiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF0Y2ggPSB2YWx1ZS5zdWJzdHJpbmcoc2VsZWN0aW9uU3RhcnQpLm1hdGNoKC9eW15cd10qXHcqLyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXRjaCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsRW5kICs9IG1hdGNoWzBdLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiZGVsZXRlQ29udGVudEJhY2t3YXJkIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNlbGVjdGlvblN0YXJ0ID09PSBzZWxlY3Rpb25FbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbFN0YXJ0IC09IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiZGVsZXRlQ29udGVudEZvcndhcmQiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZWN0aW9uU3RhcnQgPT09IHNlbGVjdGlvbkVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsRW5kICs9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC5wcmV2ZW50RGVmYXVsdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTggPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmU4ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRsaW5rU2VydmljZSRldmU4LmRpc3BhdGNoKCJkaXNwYXRjaGV2ZW50aW5zYW5kYm94IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWw6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6ICJLZXlzdHJva2UiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hhbmdlOiBkYXRhIHx8ICIiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWxsQ29tbWl0OiBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsU3RhcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbEVuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RXZlbnRMaXN0ZW5lcnMoZWxlbWVudCwgW1siZm9jdXMiLCAiRm9jdXMiXSwgWyJibHVyIiwgIkJsdXIiXSwgWyJtb3VzZWRvd24iLCAiTW91c2UgRG93biJdLCBbIm1vdXNlZW50ZXIiLCAiTW91c2UgRW50ZXIiXSwgWyJtb3VzZWxlYXZlIiwgIk1vdXNlIEV4aXQiXSwgWyJtb3VzZXVwIiwgIk1vdXNlIFVwIl1dLCBldmVudCA9PiBldmVudC50YXJnZXQudmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJsdXJMaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigiYmx1ciIsIGJsdXJMaXN0ZW5lcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kYXRhLmNvbWIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWVsZFdpZHRoID0gdGhpcy5kYXRhLnJlY3RbMl0gLSB0aGlzLmRhdGEucmVjdFswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb21iV2lkdGggPSBmaWVsZFdpZHRoIC8gbWF4TGVuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuY2xhc3NMaXN0LmFkZCgiY29tYiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc3R5bGUubGV0dGVyU3BhY2luZyA9IGBjYWxjKCR7Y29tYldpZHRofXB4ICogdmFyKC0tc2NhbGUtZmFjdG9yKSAtIDFjaClgOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50ZXh0Q29udGVudCA9IHRoaXMuZGF0YS5maWVsZFZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zdHlsZS52ZXJ0aWNhbEFsaWduID0gIm1pZGRsZSI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnN0eWxlLmRpc3BsYXkgPSAidGFibGUtY2VsbCI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0VGV4dFN0eWxlKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRCYWNrZ3JvdW5kQ29sb3IoZWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldERlZmF1bHRQcm9wZXJ0aWVzRnJvbUpTKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoZWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDaGVja2JveFdpZGdldEFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgV2lkZ2V0QW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlOiBwYXJhbWV0ZXJzLnJlbmRlckZvcm1zCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0b3JhZ2UgPSB0aGlzLmFubm90YXRpb25TdG9yYWdlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gdGhpcy5kYXRhOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IGRhdGEuaWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2YWx1ZSA9IHN0b3JhZ2UuZ2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBkYXRhLmV4cG9ydFZhbHVlID09PSBkYXRhLmZpZWxkVmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgfSkudmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHZhbHVlICE9PSAiT2ZmIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCgiYnV0dG9uV2lkZ2V0QW5ub3RhdGlvbiIsICJjaGVja0JveCIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiaW5wdXQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgR2V0RWxlbWVudHNCeU5hbWVTZXQuYWRkKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZSgiZGF0YS1lbGVtZW50LWlkIiwgaWQpOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmRpc2FibGVkID0gZGF0YS5yZWFkT25seTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0UmVxdWlyZWQoZWxlbWVudCwgdGhpcy5kYXRhLnJlcXVpcmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50eXBlID0gImNoZWNrYm94IjsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5uYW1lID0gZGF0YS5maWVsZE5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGUoImNoZWNrZWQiLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZSgiZXhwb3J0VmFsdWUiLCBkYXRhLmV4cG9ydFZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50YWJJbmRleCA9IERFRkFVTFRfVEFCX0lOREVYOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoImNoYW5nZSIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrZWQKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBldmVudC50YXJnZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGNoZWNrYm94IG9mIHRoaXMuX2dldEVsZW1lbnRzQnlOYW1lKG5hbWUsIGlkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1ckNoZWNrZWQgPSBjaGVja2VkICYmIGNoZWNrYm94LmV4cG9ydFZhbHVlID09PSBkYXRhLmV4cG9ydFZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGVja2JveC5kb21FbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrYm94LmRvbUVsZW1lbnQuY2hlY2tlZCA9IGN1ckNoZWNrZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoY2hlY2tib3guaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGN1ckNoZWNrZWQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogY2hlY2tlZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoInJlc2V0Zm9ybSIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlZmF1bHRWYWx1ZSA9IGRhdGEuZGVmYXVsdEZpZWxkVmFsdWUgfHwgIk9mZiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC50YXJnZXQuY2hlY2tlZCA9IGRlZmF1bHRWYWx1ZSA9PT0gZGF0YS5leHBvcnRWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmVuYWJsZVNjcmlwdGluZyAmJiB0aGlzLmhhc0pTQWN0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJ1cGRhdGVmcm9tc2FuZGJveCIsIGpzRXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFjdGlvbnMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC50YXJnZXQuY2hlY2tlZCA9IGV2ZW50LmRldGFpbC52YWx1ZSAhPT0gIk9mZiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGV2ZW50LnRhcmdldC5jaGVja2VkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGlzcGF0Y2hFdmVudEZyb21TYW5kYm94KGFjdGlvbnMsIGpzRXZlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRFdmVudExpc3RlbmVycyhlbGVtZW50LCBbWyJjaGFuZ2UiLCAiVmFsaWRhdGUiXSwgWyJjaGFuZ2UiLCAiQWN0aW9uIl0sIFsiZm9jdXMiLCAiRm9jdXMiXSwgWyJibHVyIiwgIkJsdXIiXSwgWyJtb3VzZWRvd24iLCAiTW91c2UgRG93biJdLCBbIm1vdXNlZW50ZXIiLCAiTW91c2UgRW50ZXIiXSwgWyJtb3VzZWxlYXZlIiwgIk1vdXNlIEV4aXQiXSwgWyJtb3VzZXVwIiwgIk1vdXNlIFVwIl1dLCBldmVudCA9PiBldmVudC50YXJnZXQuY2hlY2tlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0QmFja2dyb3VuZENvbG9yKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXREZWZhdWx0UHJvcGVydGllc0Zyb21KUyhlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuYXBwZW5kKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUmFkaW9CdXR0b25XaWRnZXRBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIFdpZGdldEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHBhcmFtZXRlcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVuZGVyYWJsZTogcGFyYW1ldGVycy5yZW5kZXJGb3JtcwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJidXR0b25XaWRnZXRBbm5vdGF0aW9uIiwgInJhZGlvQnV0dG9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0b3JhZ2UgPSB0aGlzLmFubm90YXRpb25TdG9yYWdlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gdGhpcy5kYXRhOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IGRhdGEuaWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2YWx1ZSA9IHN0b3JhZ2UuZ2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBkYXRhLmZpZWxkVmFsdWUgPT09IGRhdGEuYnV0dG9uVmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgfSkudmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHZhbHVlICE9PSBkYXRhLmJ1dHRvblZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiaW5wdXQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgR2V0RWxlbWVudHNCeU5hbWVTZXQuYWRkKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZSgiZGF0YS1lbGVtZW50LWlkIiwgaWQpOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmRpc2FibGVkID0gZGF0YS5yZWFkT25seTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0UmVxdWlyZWQoZWxlbWVudCwgdGhpcy5kYXRhLnJlcXVpcmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50eXBlID0gInJhZGlvIjsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5uYW1lID0gZGF0YS5maWVsZE5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGUoImNoZWNrZWQiLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnRhYkluZGV4ID0gREVGQVVMVF9UQUJfSU5ERVg7CiAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigiY2hhbmdlIiwgZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hlY2tlZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGV2ZW50LnRhcmdldDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcmFkaW8gb2YgdGhpcy5fZ2V0RWxlbWVudHNCeU5hbWUobmFtZSwgaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShyYWRpby5pZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogY2hlY2tlZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoInJlc2V0Zm9ybSIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlZmF1bHRWYWx1ZSA9IGRhdGEuZGVmYXVsdEZpZWxkVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC50YXJnZXQuY2hlY2tlZCA9IGRlZmF1bHRWYWx1ZSAhPT0gbnVsbCAmJiBkZWZhdWx0VmFsdWUgIT09IHVuZGVmaW5lZCAmJiBkZWZhdWx0VmFsdWUgPT09IGRhdGEuYnV0dG9uVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5lbmFibGVTY3JpcHRpbmcgJiYgdGhpcy5oYXNKU0FjdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBkZkJ1dHRvblZhbHVlID0gZGF0YS5idXR0b25WYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigidXBkYXRlZnJvbXNhbmRib3giLCBqc0V2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhY3Rpb25zID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hlY2tlZCA9IHBkZkJ1dHRvblZhbHVlID09PSBldmVudC5kZXRhaWwudmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJhZGlvIG9mIHRoaXMuX2dldEVsZW1lbnRzQnlOYW1lKGV2ZW50LnRhcmdldC5uYW1lKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1ckNoZWNrZWQgPSBjaGVja2VkICYmIHJhZGlvLmlkID09PSBpZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmFkaW8uZG9tRWxlbWVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYWRpby5kb21FbGVtZW50LmNoZWNrZWQgPSBjdXJDaGVja2VkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKHJhZGlvLmlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjdXJDaGVja2VkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc3BhdGNoRXZlbnRGcm9tU2FuZGJveChhY3Rpb25zLCBqc0V2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RXZlbnRMaXN0ZW5lcnMoZWxlbWVudCwgW1siY2hhbmdlIiwgIlZhbGlkYXRlIl0sIFsiY2hhbmdlIiwgIkFjdGlvbiJdLCBbImZvY3VzIiwgIkZvY3VzIl0sIFsiYmx1ciIsICJCbHVyIl0sIFsibW91c2Vkb3duIiwgIk1vdXNlIERvd24iXSwgWyJtb3VzZWVudGVyIiwgIk1vdXNlIEVudGVyIl0sIFsibW91c2VsZWF2ZSIsICJNb3VzZSBFeGl0Il0sIFsibW91c2V1cCIsICJNb3VzZSBVcCJdXSwgZXZlbnQgPT4gZXZlbnQudGFyZ2V0LmNoZWNrZWQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldEJhY2tncm91bmRDb2xvcihlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RGVmYXVsdFByb3BlcnRpZXNGcm9tSlMoZWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFB1c2hCdXR0b25XaWRnZXRBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIExpbmtBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXI6IHBhcmFtZXRlcnMuZGF0YS5oYXNBcHBlYXJhbmNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRhaW5lciA9IHN1cGVyLnJlbmRlcigpOwogICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuY2xhc3NMaXN0LmFkZCgiYnV0dG9uV2lkZ2V0QW5ub3RhdGlvbiIsICJwdXNoQnV0dG9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEuYWx0ZXJuYXRpdmVUZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIudGl0bGUgPSB0aGlzLmRhdGEuYWx0ZXJuYXRpdmVUZXh0OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmtFbGVtZW50ID0gY29udGFpbmVyLmxhc3RDaGlsZDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZW5hYmxlU2NyaXB0aW5nICYmIHRoaXMuaGFzSlNBY3Rpb25zICYmIGxpbmtFbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXREZWZhdWx0UHJvcGVydGllc0Zyb21KUyhsaW5rRWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5rRWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJ1cGRhdGVmcm9tc2FuZGJveCIsIGpzRXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc3BhdGNoRXZlbnRGcm9tU2FuZGJveCh7fSwganNFdmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIENob2ljZVdpZGdldEFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgV2lkZ2V0QW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlOiBwYXJhbWV0ZXJzLnJlbmRlckZvcm1zCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoImNob2ljZVdpZGdldEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RvcmFnZSA9IHRoaXMuYW5ub3RhdGlvblN0b3JhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gdGhpcy5kYXRhLmlkOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdG9yZWREYXRhID0gc3RvcmFnZS5nZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuZGF0YS5maWVsZFZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzZWxlY3RFbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic2VsZWN0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIEdldEVsZW1lbnRzQnlOYW1lU2V0LmFkZChzZWxlY3RFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5zZXRBdHRyaWJ1dGUoImRhdGEtZWxlbWVudC1pZCIsIGlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5kaXNhYmxlZCA9IHRoaXMuZGF0YS5yZWFkT25seTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0UmVxdWlyZWQoc2VsZWN0RWxlbWVudCwgdGhpcy5kYXRhLnJlcXVpcmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5uYW1lID0gdGhpcy5kYXRhLmZpZWxkTmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC50YWJJbmRleCA9IERFRkFVTFRfVEFCX0lOREVYOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYWRkQW5FbXB0eUVudHJ5ID0gdGhpcy5kYXRhLmNvbWJvICYmIHRoaXMuZGF0YS5vcHRpb25zLmxlbmd0aCA+IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhLmNvbWJvKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LnNpemUgPSB0aGlzLmRhdGEub3B0aW9ucy5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kYXRhLm11bHRpU2VsZWN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5tdWx0aXBsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJyZXNldGZvcm0iLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZhdWx0VmFsdWUgPSB0aGlzLmRhdGEuZGVmYXVsdEZpZWxkVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG9wdGlvbiBvZiBzZWxlY3RFbGVtZW50Lm9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb24uc2VsZWN0ZWQgPSBvcHRpb24udmFsdWUgPT09IGRlZmF1bHRWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgb3B0aW9uIG9mIHRoaXMuZGF0YS5vcHRpb25zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvcHRpb25FbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgib3B0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25FbGVtZW50LnRleHRDb250ZW50ID0gb3B0aW9uLmRpc3BsYXlWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbkVsZW1lbnQudmFsdWUgPSBvcHRpb24uZXhwb3J0VmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RvcmVkRGF0YS52YWx1ZS5pbmNsdWRlcyhvcHRpb24uZXhwb3J0VmFsdWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uRWxlbWVudC5zZXRBdHRyaWJ1dGUoInNlbGVjdGVkIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRkQW5FbXB0eUVudHJ5ID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LmFwcGVuZChvcHRpb25FbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcmVtb3ZlRW1wdHlFbnRyeSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhZGRBbkVtcHR5RW50cnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vbmVPcHRpb25FbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgib3B0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub25lT3B0aW9uRWxlbWVudC52YWx1ZSA9ICIgIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vbmVPcHRpb25FbGVtZW50LnNldEF0dHJpYnV0ZSgiaGlkZGVuIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub25lT3B0aW9uRWxlbWVudC5zZXRBdHRyaWJ1dGUoInNlbGVjdGVkIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LnByZXBlbmQobm9uZU9wdGlvbkVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVtb3ZlRW1wdHlFbnRyeSA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBub25lT3B0aW9uRWxlbWVudC5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LnJlbW92ZUV2ZW50TGlzdGVuZXIoImlucHV0IiwgcmVtb3ZlRW1wdHlFbnRyeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVtb3ZlRW1wdHlFbnRyeSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJpbnB1dCIsIHJlbW92ZUVtcHR5RW50cnkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdldFZhbHVlID0gaXNFeHBvcnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbmFtZSA9IGlzRXhwb3J0ID8gInZhbHVlIiA6ICJ0ZXh0Q29udGVudCI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9ucywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdWx0aXBsZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHNlbGVjdEVsZW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIW11bHRpcGxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG9wdGlvbnMuc2VsZWN0ZWRJbmRleCA9PT0gLTEgPyBudWxsIDogb3B0aW9uc1tvcHRpb25zLnNlbGVjdGVkSW5kZXhdW25hbWVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEFycmF5LnByb3RvdHlwZS5maWx0ZXIuY2FsbChvcHRpb25zLCBvcHRpb24gPT4gb3B0aW9uLnNlbGVjdGVkKS5tYXAob3B0aW9uID0+IG9wdGlvbltuYW1lXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzZWxlY3RlZFZhbHVlcyA9IGdldFZhbHVlKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZ2V0SXRlbXMgPSBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvcHRpb25zID0gZXZlbnQudGFyZ2V0Lm9wdGlvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gQXJyYXkucHJvdG90eXBlLm1hcC5jYWxsKG9wdGlvbnMsIG9wdGlvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzcGxheVZhbHVlOiBvcHRpb24udGV4dENvbnRlbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4cG9ydFZhbHVlOiBvcHRpb24udmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmVuYWJsZVNjcmlwdGluZyAmJiB0aGlzLmhhc0pTQWN0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJ1cGRhdGVmcm9tc2FuZGJveCIsIGpzRXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFjdGlvbnMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3JlbW92ZUVtcHR5RW50cnk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3JlbW92ZUVtcHR5RW50cnkgPSByZW1vdmVFbXB0eUVudHJ5KSA9PT0gbnVsbCB8fCBfcmVtb3ZlRW1wdHlFbnRyeSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3JlbW92ZUVtcHR5RW50cnkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gZXZlbnQuZGV0YWlsLnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmFsdWVzID0gbmV3IFNldChBcnJheS5pc0FycmF5KHZhbHVlKSA/IHZhbHVlIDogW3ZhbHVlXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG9wdGlvbiBvZiBzZWxlY3RFbGVtZW50Lm9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb24uc2VsZWN0ZWQgPSB2YWx1ZXMuaGFzKG9wdGlvbi52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGdldFZhbHVlKHRydWUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdWx0aXBsZVNlbGVjdGlvbihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5tdWx0aXBsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlbW92ZShldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3B0aW9ucyA9IHNlbGVjdEVsZW1lbnQub3B0aW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGluZGV4ID0gZXZlbnQuZGV0YWlsLnJlbW92ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbnNbaW5kZXhdLnNlbGVjdGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LnJlbW92ZShpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3B0aW9ucy5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaSA9IEFycmF5LnByb3RvdHlwZS5maW5kSW5kZXguY2FsbChvcHRpb25zLCBvcHRpb24gPT4gb3B0aW9uLnNlbGVjdGVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaSA9PT0gLTEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uc1swXS5zZWxlY3RlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBnZXRWYWx1ZSh0cnVlKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtczogZ2V0SXRlbXMoZXZlbnQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhcihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHNlbGVjdEVsZW1lbnQubGVuZ3RoICE9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5yZW1vdmUoMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXM6IFtdCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnNlcnQoZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRleCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNwbGF5VmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXhwb3J0VmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBldmVudC5kZXRhaWwuaW5zZXJ0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2VsZWN0Q2hpbGQgPSBzZWxlY3RFbGVtZW50LmNoaWxkcmVuW2luZGV4XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9wdGlvbkVsZW1lbnQgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJvcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbkVsZW1lbnQudGV4dENvbnRlbnQgPSBkaXNwbGF5VmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25FbGVtZW50LnZhbHVlID0gZXhwb3J0VmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZWN0Q2hpbGQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RDaGlsZC5iZWZvcmUob3B0aW9uRWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdEVsZW1lbnQuYXBwZW5kKG9wdGlvbkVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBnZXRWYWx1ZSh0cnVlKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtczogZ2V0SXRlbXMoZXZlbnQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtcyhldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZXZlbnQuZGV0YWlsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHNlbGVjdEVsZW1lbnQubGVuZ3RoICE9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5yZW1vdmUoMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGl0ZW0gb2YgaXRlbXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc3BsYXlWYWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXhwb3J0VmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gaXRlbTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvcHRpb25FbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgib3B0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uRWxlbWVudC50ZXh0Q29udGVudCA9IGRpc3BsYXlWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25FbGVtZW50LnZhbHVlID0gZXhwb3J0VmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5hcHBlbmQob3B0aW9uRWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZWN0RWxlbWVudC5vcHRpb25zLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50Lm9wdGlvbnNbMF0uc2VsZWN0ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBnZXRWYWx1ZSh0cnVlKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtczogZ2V0SXRlbXMoZXZlbnQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRpY2VzKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbmRpY2VzID0gbmV3IFNldChldmVudC5kZXRhaWwuaW5kaWNlcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG9wdGlvbiBvZiBldmVudC50YXJnZXQub3B0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbi5zZWxlY3RlZCA9IGluZGljZXMuaGFzKG9wdGlvbi5pbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGdldFZhbHVlKHRydWUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0YWJsZShldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LmRpc2FibGVkID0gIWV2ZW50LmRldGFpbC5lZGl0YWJsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGlzcGF0Y2hFdmVudEZyb21TYW5kYm94KGFjdGlvbnMsIGpzRXZlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoImlucHV0IiwgZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmU5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGV4cG9ydFZhbHVlID0gZ2V0VmFsdWUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZXhwb3J0VmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC5wcmV2ZW50RGVmYXVsdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRsaW5rU2VydmljZSRldmU5ID0gdGhpcy5saW5rU2VydmljZS5ldmVudEJ1cykgPT09IG51bGwgfHwgX3RoaXMkbGlua1NlcnZpY2UkZXZlOSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkbGlua1NlcnZpY2UkZXZlOS5kaXNwYXRjaCgiZGlzcGF0Y2hldmVudGluc2FuZGJveCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlOiB0aGlzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWw6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZTogIktleXN0cm9rZSIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogc2VsZWN0ZWRWYWx1ZXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGFuZ2VFeDogZXhwb3J0VmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWxsQ29tbWl0OiBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1pdEtleTogMSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtleURvd246IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RXZlbnRMaXN0ZW5lcnMoc2VsZWN0RWxlbWVudCwgW1siZm9jdXMiLCAiRm9jdXMiXSwgWyJibHVyIiwgIkJsdXIiXSwgWyJtb3VzZWRvd24iLCAiTW91c2UgRG93biJdLCBbIm1vdXNlZW50ZXIiLCAiTW91c2UgRW50ZXIiXSwgWyJtb3VzZWxlYXZlIiwgIk1vdXNlIEV4aXQiXSwgWyJtb3VzZXVwIiwgIk1vdXNlIFVwIl0sIFsiaW5wdXQiLCAiQWN0aW9uIl0sIFsiaW5wdXQiLCAiVmFsaWRhdGUiXV0sIGV2ZW50ID0+IGV2ZW50LnRhcmdldC52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoImlucHV0IiwgZnVuY3Rpb24gKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZ2V0VmFsdWUodHJ1ZSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEuY29tYm8pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldFRleHRTdHlsZShzZWxlY3RFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHt9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldEJhY2tncm91bmRDb2xvcihzZWxlY3RFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RGVmYXVsdFByb3BlcnRpZXNGcm9tSlMoc2VsZWN0RWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChzZWxlY3RFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBvcHVwQW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIElHTk9SRV9UWVBFUyA9IG5ldyBTZXQoWyJMaW5lIiwgIlNxdWFyZSIsICJDaXJjbGUiLCAiUG9seUxpbmUiLCAiUG9seWdvbiIsICJJbmsiXSk7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2RhdGEkdGl0bGVPYmosIF9kYXRhJGNvbnRlbnRzT2JqLCBfZGF0YSRyaWNoVGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gcGFyYW1ldGVyczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gIVBvcHVwQW5ub3RhdGlvbkVsZW1lbnQuSUdOT1JFX1RZUEVTLmhhcyhkYXRhLnBhcmVudFR5cGUpICYmICEhKChfZGF0YSR0aXRsZU9iaiA9IGRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9kYXRhJHRpdGxlT2JqICE9PSB2b2lkIDAgJiYgX2RhdGEkdGl0bGVPYmouc3RyIHx8IChfZGF0YSRjb250ZW50c09iaiA9IGRhdGEuY29udGVudHNPYmopICE9PSBudWxsICYmIF9kYXRhJGNvbnRlbnRzT2JqICE9PSB2b2lkIDAgJiYgX2RhdGEkY29udGVudHNPYmouc3RyIHx8IChfZGF0YSRyaWNoVGV4dCA9IGRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9kYXRhJHJpY2hUZXh0ICE9PSB2b2lkIDAgJiYgX2RhdGEkcmljaFRleHQuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInBvcHVwQW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJlbnRFbGVtZW50cyA9IHRoaXMubGF5ZXIucXVlcnlTZWxlY3RvckFsbChgW2RhdGEtYW5ub3RhdGlvbi1pZD0iJHt0aGlzLmRhdGEucGFyZW50SWR9Il1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmVudEVsZW1lbnRzLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBvcHVwID0gbmV3IFBvcHVwRWxlbWVudCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXI6IHRoaXMuY29udGFpbmVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlcjogQXJyYXkuZnJvbShwYXJlbnRFbGVtZW50cyksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2xvcjogdGhpcy5kYXRhLmNvbG9yLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGVPYmo6IHRoaXMuZGF0YS50aXRsZU9iaiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGlmaWNhdGlvbkRhdGU6IHRoaXMuZGF0YS5tb2RpZmljYXRpb25EYXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudHNPYmo6IHRoaXMuZGF0YS5jb250ZW50c09iaiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJpY2hUZXh0OiB0aGlzLmRhdGEucmljaFRleHQKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZ2UgPSB0aGlzLnBhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSBfdXRpbC5VdGlsLm5vcm1hbGl6ZVJlY3QoW3RoaXMuZGF0YS5wYXJlbnRSZWN0WzBdLCBwYWdlLnZpZXdbM10gLSB0aGlzLmRhdGEucGFyZW50UmVjdFsxXSArIHBhZ2Uudmlld1sxXSwgdGhpcy5kYXRhLnBhcmVudFJlY3RbMl0sIHBhZ2Uudmlld1szXSAtIHRoaXMuZGF0YS5wYXJlbnRSZWN0WzNdICsgcGFnZS52aWV3WzFdXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBvcHVwTGVmdCA9IHJlY3RbMF0gKyB0aGlzLmRhdGEucGFyZW50UmVjdFsyXSAtIHRoaXMuZGF0YS5wYXJlbnRSZWN0WzBdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb3B1cFRvcCA9IHJlY3RbMV07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VXaWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VIZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlWCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VZCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLnZpZXdwb3J0LnJhd0RpbXM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLnN0eWxlLmxlZnQgPSBgJHsxMDAgKiAocG9wdXBMZWZ0IC0gcGFnZVgpIC8gcGFnZVdpZHRofSVgOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5zdHlsZS50b3AgPSBgJHsxMDAgKiAocG9wdXBUb3AgLSBwYWdlWSkgLyBwYWdlSGVpZ2h0fSVgOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQocG9wdXAucmVuZGVyKCkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUG9wdXBFbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyID0gcGFyYW1ldGVycy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJpZ2dlciA9IHBhcmFtZXRlcnMudHJpZ2dlcjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2xvciA9IHBhcmFtZXRlcnMuY29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGl0bGVPYmogPSBwYXJhbWV0ZXJzLnRpdGxlT2JqOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1vZGlmaWNhdGlvbkRhdGUgPSBwYXJhbWV0ZXJzLm1vZGlmaWNhdGlvbkRhdGU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGVudHNPYmogPSBwYXJhbWV0ZXJzLmNvbnRlbnRzT2JqOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJpY2hUZXh0ID0gcGFyYW1ldGVycy5yaWNoVGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5oaWRlV3JhcHBlciA9IHBhcmFtZXRlcnMuaGlkZVdyYXBwZXIgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGlubmVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJHJpY2hUZXh0LCBfdGhpcyRjb250ZW50c09iajsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQkFDS0dST1VORF9FTkxJR0hUID0gMC43OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3cmFwcGVyID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIHdyYXBwZXIuY2xhc3NMaXN0LmFkZCgicG9wdXBXcmFwcGVyIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaGlkZUVsZW1lbnQgPSB0aGlzLmhpZGVXcmFwcGVyID8gd3JhcHBlciA6IHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmhpZGVFbGVtZW50LmhpZGRlbiA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBvcHVwID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvcHVwLmNsYXNzTGlzdC5hZGQoInBvcHVwIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gdGhpcy5jb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByID0gQkFDS0dST1VORF9FTkxJR0hUICogKDI1NSAtIGNvbG9yWzBdKSArIGNvbG9yWzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZyA9IEJBQ0tHUk9VTkRfRU5MSUdIVCAqICgyNTUgLSBjb2xvclsxXSkgKyBjb2xvclsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGIgPSBCQUNLR1JPVU5EX0VOTElHSFQgKiAoMjU1IC0gY29sb3JbMl0pICsgY29sb3JbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb3B1cC5zdHlsZS5iYWNrZ3JvdW5kQ29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihyIHwgMCwgZyB8IDAsIGIgfCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0aXRsZSA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImgxIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlLmRpciA9IHRoaXMudGl0bGVPYmouZGlyOwogICAgICAgICAgICAgICAgICAgICAgICB0aXRsZS50ZXh0Q29udGVudCA9IHRoaXMudGl0bGVPYmouc3RyOwogICAgICAgICAgICAgICAgICAgICAgICBwb3B1cC5hcHBlbmQodGl0bGUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRlT2JqZWN0ID0gX2Rpc3BsYXlfdXRpbHMuUERGRGF0ZVN0cmluZy50b0RhdGVPYmplY3QodGhpcy5tb2RpZmljYXRpb25EYXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGVPYmplY3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1vZGlmaWNhdGlvbkRhdGUgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJzcGFuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb2RpZmljYXRpb25EYXRlLmNsYXNzTGlzdC5hZGQoInBvcHVwRGF0ZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9kaWZpY2F0aW9uRGF0ZS50ZXh0Q29udGVudCA9ICJ7e2RhdGV9fSwge3t0aW1lfX0iOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9kaWZpY2F0aW9uRGF0ZS5kYXRhc2V0LmwxMG5JZCA9ICJhbm5vdGF0aW9uX2RhdGVfc3RyaW5nIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGlmaWNhdGlvbkRhdGUuZGF0YXNldC5sMTBuQXJncyA9IEpTT04uc3RyaW5naWZ5KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRlOiBkYXRlT2JqZWN0LnRvTG9jYWxlRGF0ZVN0cmluZygpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpbWU6IGRhdGVPYmplY3QudG9Mb2NhbGVUaW1lU3RyaW5nKCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9wdXAuYXBwZW5kKG1vZGlmaWNhdGlvbkRhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoX3RoaXMkcmljaFRleHQgPSB0aGlzLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfdGhpcyRyaWNoVGV4dCAhPT0gdm9pZCAwICYmIF90aGlzJHJpY2hUZXh0LnN0ciAmJiAoISgoX3RoaXMkY29udGVudHNPYmogPSB0aGlzLmNvbnRlbnRzT2JqKSAhPT0gbnVsbCAmJiBfdGhpcyRjb250ZW50c09iaiAhPT0gdm9pZCAwICYmIF90aGlzJGNvbnRlbnRzT2JqLnN0cikgfHwgdGhpcy5jb250ZW50c09iai5zdHIgPT09IHRoaXMucmljaFRleHQuc3RyKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX3hmYV9sYXllci5YZmFMYXllci5yZW5kZXIoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhmYUh0bWw6IHRoaXMucmljaFRleHQuaHRtbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnQ6ICJyaWNoVGV4dCIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2OiBwb3B1cAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb3B1cC5sYXN0Q2hpbGQuY2xhc3NMaXN0LmFkZCgicmljaFRleHQiLCAicG9wdXBDb250ZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb250ZW50cyA9IHRoaXMuX2Zvcm1hdENvbnRlbnRzKHRoaXMuY29udGVudHNPYmopOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9wdXAuYXBwZW5kKGNvbnRlbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIUFycmF5LmlzQXJyYXkodGhpcy50cmlnZ2VyKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmlnZ2VyID0gW3RoaXMudHJpZ2dlcl07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlbGVtZW50IG9mIHRoaXMudHJpZ2dlcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJjbGljayIsIHRoaXMuX3RvZ2dsZS5iaW5kKHRoaXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigibW91c2VvdmVyIiwgdGhpcy5fc2hvdy5iaW5kKHRoaXMsIGZhbHNlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoIm1vdXNlb3V0IiwgdGhpcy5faGlkZS5iaW5kKHRoaXMsIGZhbHNlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcG9wdXAuYWRkRXZlbnRMaXN0ZW5lcigiY2xpY2siLCB0aGlzLl9oaWRlLmJpbmQodGhpcywgdHJ1ZSkpOwogICAgICAgICAgICAgICAgICAgICAgICB3cmFwcGVyLmFwcGVuZChwb3B1cCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB3cmFwcGVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZm9ybWF0Q29udGVudHMoX3JlZikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlyCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgicCIpOwogICAgICAgICAgICAgICAgICAgICAgICBwLmNsYXNzTGlzdC5hZGQoInBvcHVwQ29udGVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBwLmRpciA9IGRpcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGluZXMgPSBzdHIuc3BsaXQoLyg/OlxyXG4/fFxuKS8pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBsaW5lcy5sZW5ndGg7IGkgPCBpaTsgKytpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsaW5lID0gbGluZXNbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwLmFwcGVuZChkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZShsaW5lKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaSA8IGlpIC0gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHAuYXBwZW5kKGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImJyIikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfdG9nZ2xlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5waW5uZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hpZGUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zaG93KHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zaG93KCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGluID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBpbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5waW5uZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmhpZGVFbGVtZW50LmhpZGRlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5oaWRlRWxlbWVudC5oaWRkZW4gPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLnN0eWxlLnpJbmRleCA9IHBhcnNlSW50KHRoaXMuY29udGFpbmVyLnN0eWxlLnpJbmRleCkgKyAxMDAwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9oaWRlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgdW5waW4gPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh1bnBpbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5waW5uZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaGlkZUVsZW1lbnQuaGlkZGVuICYmICF0aGlzLnBpbm5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5oaWRlRWxlbWVudC5oaWRkZW4gPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuc3R5bGUuekluZGV4ID0gcGFyc2VJbnQodGhpcy5jb250YWluZXIuc3R5bGUuekluZGV4KSAtIDEwMDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBGcmVlVGV4dEFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgQW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDIsIF9wYXJhbWV0ZXJzJGRhdGEkY29udDIsIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzUmVuZGVyYWJsZSA9ICEhKHBhcmFtZXRlcnMuZGF0YS5oYXNQb3B1cCB8fCAoX3BhcmFtZXRlcnMkZGF0YSR0aXRsMiA9IHBhcmFtZXRlcnMuZGF0YS50aXRsZU9iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMiAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDIuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJGNvbnQyID0gcGFyYW1ldGVycy5kYXRhLmNvbnRlbnRzT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQyICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250Mi5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkcmljaDIgPSBwYXJhbWV0ZXJzLmRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDIgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2gyLnN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHBhcmFtZXRlcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVuZGVyYWJsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlnbm9yZUJvcmRlcjogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50ZXh0Q29udGVudCA9IHBhcmFtZXRlcnMuZGF0YS50ZXh0Q29udGVudDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJmcmVlVGV4dEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMudGV4dENvbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRlbnQgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQuY2xhc3NMaXN0LmFkZCgiYW5ub3RhdGlvblRleHRDb250ZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50LnNldEF0dHJpYnV0ZSgicm9sZSIsICJjb21tZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpbmUgb2YgdGhpcy50ZXh0Q29udGVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmVTcGFuID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic3BhbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVTcGFuLnRleHRDb250ZW50ID0gbGluZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50LmFwcGVuZChsaW5lU3Bhbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoY29udGVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIExpbmVBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGFyYW1ldGVycyRkYXRhJHRpdGwzLCBfcGFyYW1ldGVycyRkYXRhJGNvbnQzLCBfcGFyYW1ldGVycyRkYXRhJHJpY2gzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1JlbmRlcmFibGUgPSAhIShwYXJhbWV0ZXJzLmRhdGEuaGFzUG9wdXAgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDMgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDMgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGwzLnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRjb250MyA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250MyAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDMuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJHJpY2gzID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2gzICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMy5zdHIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlbmRlcmFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXI6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCgibGluZUFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHRoaXMuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUod2lkdGgsIGhlaWdodCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmUgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOmxpbmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluZS5zZXRBdHRyaWJ1dGUoIngxIiwgZGF0YS5yZWN0WzJdIC0gZGF0YS5saW5lQ29vcmRpbmF0ZXNbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5lLnNldEF0dHJpYnV0ZSgieTEiLCBkYXRhLnJlY3RbM10gLSBkYXRhLmxpbmVDb29yZGluYXRlc1sxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmUuc2V0QXR0cmlidXRlKCJ4MiIsIGRhdGEucmVjdFsyXSAtIGRhdGEubGluZUNvb3JkaW5hdGVzWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluZS5zZXRBdHRyaWJ1dGUoInkyIiwgZGF0YS5yZWN0WzNdIC0gZGF0YS5saW5lQ29vcmRpbmF0ZXNbM10pOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlLXdpZHRoIiwgZGF0YS5ib3JkZXJTdHlsZS53aWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluZS5zZXRBdHRyaWJ1dGUoInN0cm9rZSIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5lLnNldEF0dHJpYnV0ZSgiZmlsbCIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuYXBwZW5kKGxpbmUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoc3ZnKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAobGluZSwgZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBTcXVhcmVBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGFyYW1ldGVycyRkYXRhJHRpdGw0LCBfcGFyYW1ldGVycyRkYXRhJGNvbnQ0LCBfcGFyYW1ldGVycyRkYXRhJHJpY2g0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1JlbmRlcmFibGUgPSAhIShwYXJhbWV0ZXJzLmRhdGEuaGFzUG9wdXAgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDQgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDQgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw0LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRjb250NCA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250NCAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDQuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJHJpY2g0ID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2g0ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNC5zdHIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlbmRlcmFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXI6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCgic3F1YXJlQW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gdGhpcy5kYXRhOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gZ2V0UmVjdERpbXMoZGF0YS5yZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ZnID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZSh3aWR0aCwgaGVpZ2h0LCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYm9yZGVyV2lkdGggPSBkYXRhLmJvcmRlclN0eWxlLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcXVhcmUgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOnJlY3QiKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3F1YXJlLnNldEF0dHJpYnV0ZSgieCIsIGJvcmRlcldpZHRoIC8gMik7CiAgICAgICAgICAgICAgICAgICAgICAgIHNxdWFyZS5zZXRBdHRyaWJ1dGUoInkiLCBib3JkZXJXaWR0aCAvIDIpOwogICAgICAgICAgICAgICAgICAgICAgICBzcXVhcmUuc2V0QXR0cmlidXRlKCJ3aWR0aCIsIHdpZHRoIC0gYm9yZGVyV2lkdGgpOwogICAgICAgICAgICAgICAgICAgICAgICBzcXVhcmUuc2V0QXR0cmlidXRlKCJoZWlnaHQiLCBoZWlnaHQgLSBib3JkZXJXaWR0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHNxdWFyZS5zZXRBdHRyaWJ1dGUoInN0cm9rZS13aWR0aCIsIGJvcmRlcldpZHRoIHx8IDEpOwogICAgICAgICAgICAgICAgICAgICAgICBzcXVhcmUuc2V0QXR0cmlidXRlKCJzdHJva2UiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3F1YXJlLnNldEF0dHJpYnV0ZSgiZmlsbCIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuYXBwZW5kKHNxdWFyZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChzdmcpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cChzcXVhcmUsIGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgQ2lyY2xlQW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNSwgX3BhcmFtZXRlcnMkZGF0YSRjb250NSwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGw1ID0gcGFyYW1ldGVycy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw1ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNS5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDUgPSBwYXJhbWV0ZXJzLmRhdGEuY29udGVudHNPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDUgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQ1LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoNSA9IHBhcmFtZXRlcnMuZGF0YS5yaWNoVGV4dCkgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNSAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDUuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoImNpcmNsZUFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHRoaXMuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUod2lkdGgsIGhlaWdodCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJvcmRlcldpZHRoID0gZGF0YS5ib3JkZXJTdHlsZS53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2lyY2xlID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzplbGxpcHNlIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNpcmNsZS5zZXRBdHRyaWJ1dGUoImN4Iiwgd2lkdGggLyAyKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2lyY2xlLnNldEF0dHJpYnV0ZSgiY3kiLCBoZWlnaHQgLyAyKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2lyY2xlLnNldEF0dHJpYnV0ZSgicngiLCB3aWR0aCAvIDIgLSBib3JkZXJXaWR0aCAvIDIpOwogICAgICAgICAgICAgICAgICAgICAgICBjaXJjbGUuc2V0QXR0cmlidXRlKCJyeSIsIGhlaWdodCAvIDIgLSBib3JkZXJXaWR0aCAvIDIpOwogICAgICAgICAgICAgICAgICAgICAgICBjaXJjbGUuc2V0QXR0cmlidXRlKCJzdHJva2Utd2lkdGgiLCBib3JkZXJXaWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2lyY2xlLnNldEF0dHJpYnV0ZSgic3Ryb2tlIiwgInRyYW5zcGFyZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNpcmNsZS5zZXRBdHRyaWJ1dGUoImZpbGwiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLmFwcGVuZChjaXJjbGUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoc3ZnKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAoY2lyY2xlLCBkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBvbHlsaW5lQW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNiwgX3BhcmFtZXRlcnMkZGF0YSRjb250NiwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGw2ID0gcGFyYW1ldGVycy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw2ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNi5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDYgPSBwYXJhbWV0ZXJzLmRhdGEuY29udGVudHNPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDYgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQ2LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoNiA9IHBhcmFtZXRlcnMuZGF0YS5yaWNoVGV4dCkgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNiAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDYuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lckNsYXNzTmFtZSA9ICJwb2x5bGluZUFubm90YXRpb24iOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN2Z0VsZW1lbnROYW1lID0gInN2Zzpwb2x5bGluZSI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCh0aGlzLmNvbnRhaW5lckNsYXNzTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSB0aGlzLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVpZ2h0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBnZXRSZWN0RGltcyhkYXRhLnJlY3QpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdmcgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlKHdpZHRoLCBoZWlnaHQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcG9pbnRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgY29vcmRpbmF0ZSBvZiBkYXRhLnZlcnRpY2VzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4ID0gY29vcmRpbmF0ZS54IC0gZGF0YS5yZWN0WzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeSA9IGRhdGEucmVjdFszXSAtIGNvb3JkaW5hdGUueTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50cy5wdXNoKHggKyAiLCIgKyB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMgPSBwb2ludHMuam9pbigiICIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb2x5bGluZSA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KHRoaXMuc3ZnRWxlbWVudE5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICBwb2x5bGluZS5zZXRBdHRyaWJ1dGUoInBvaW50cyIsIHBvaW50cyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlLXdpZHRoIiwgZGF0YS5ib3JkZXJTdHlsZS53aWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9seWxpbmUuc2V0QXR0cmlidXRlKCJzdHJva2UiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9seWxpbmUuc2V0QXR0cmlidXRlKCJmaWxsIiwgInRyYW5zcGFyZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5hcHBlbmQocG9seWxpbmUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoc3ZnKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAocG9seWxpbmUsIGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUG9seWdvbkFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgUG9seWxpbmVBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXJDbGFzc05hbWUgPSAicG9seWdvbkFubm90YXRpb24iOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN2Z0VsZW1lbnROYW1lID0gInN2Zzpwb2x5Z29uIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDYXJldEFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgQW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDcsIF9wYXJhbWV0ZXJzJGRhdGEkY29udDcsIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDc7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzUmVuZGVyYWJsZSA9ICEhKHBhcmFtZXRlcnMuZGF0YS5oYXNQb3B1cCB8fCAoX3BhcmFtZXRlcnMkZGF0YSR0aXRsNyA9IHBhcmFtZXRlcnMuZGF0YS50aXRsZU9iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNyAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDcuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJGNvbnQ3ID0gcGFyYW1ldGVycy5kYXRhLmNvbnRlbnRzT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQ3ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250Ny5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkcmljaDcgPSBwYXJhbWV0ZXJzLmRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDcgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2g3LnN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHBhcmFtZXRlcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVuZGVyYWJsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlnbm9yZUJvcmRlcjogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJjYXJldEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIElua0Fubm90YXRpb25FbGVtZW50IGV4dGVuZ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b250YWluZXJDbGFzc05hbWUgPSAiaW5rQW5ub3RhdGlvbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3ZnRWxlbWVudE5hbWUgPSAic3ZnOnBvbHlsaW5lIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKHRoaXMuY29udGFpbmVyQ2xhc3NOYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHRoaXMuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUod2lkdGgsIGhlaWdodCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW5rTGlzdCBvZiBkYXRhLmlua0xpc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcG9pbnRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGNvb3JkaW5hdGUgb2YgaW5rTGlzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHggPSBjb29yZGluYXRlLnggLSBkYXRhLnJlY3RbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeSA9IGRhdGEucmVjdFszXSAtIGNvb3JkaW5hdGUueTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMucHVzaChgJHt4fSwke3l9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMgPSBwb2ludHMuam9pbigiICIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcG9seWxpbmUgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCh0aGlzLnN2Z0VsZW1lbnROYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgicG9pbnRzIiwgcG9pbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlLXdpZHRoIiwgZGF0YS5ib3JkZXJTdHlsZS53aWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlIiwgInRyYW5zcGFyZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2x5bGluZS5zZXRBdHRyaWJ1dGUoImZpbGwiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKHBvbHlsaW5lLCBkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5hcHBlbmQocG9seWxpbmUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChzdmcpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgSGlnaGxpZ2h0QW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsOSwgX3BhcmFtZXRlcnMkZGF0YSRjb250OSwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoOTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGw5ID0gcGFyYW1ldGVycy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw5ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsOS5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDkgPSBwYXJhbWV0ZXJzLmRhdGEuY29udGVudHNPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDkgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQ5LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoOSA9IHBhcmFtZXRlcnMuZGF0YS5yaWNoVGV4dCkgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoOSAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDkuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUXVhZHJpbGF0ZXJhbHM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucXVhZHJpbGF0ZXJhbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9yZW5kZXJRdWFkcmlsYXRlcmFscygiaGlnaGxpZ2h0QW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoImhpZ2hsaWdodEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFVuZGVybGluZUFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgQW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDEwLCBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMCwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzUmVuZGVyYWJsZSA9ICEhKHBhcmFtZXRlcnMuZGF0YS5oYXNQb3B1cCB8fCAoX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTAgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDEwICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTAuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJGNvbnQxMCA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250MTAgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMC5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkcmljaDEwID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2gxMCAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDEwLnN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHBhcmFtZXRlcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVuZGVyYWJsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlnbm9yZUJvcmRlcjogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZVF1YWRyaWxhdGVyYWxzOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhLmhhc1BvcHVwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cChudWxsLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnF1YWRyaWxhdGVyYWxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcmVuZGVyUXVhZHJpbGF0ZXJhbHMoInVuZGVybGluZUFubm90YXRpb24iKTsKIC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RkYXRhJHJpY2gxMSAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDExLnN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHBhcmFtZXRlcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVuZGVyYWJsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlnbm9yZUJvcmRlcjogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZVF1YWRyaWxhdGVyYWxzOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhLmhhc1BvcHVwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cChudWxsLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnF1YWRyaWxhdGVyYWxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcmVuZGVyUXVhZHJpbGF0ZXJhbHMoInNxdWlnZ2x5QW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInNxdWlnZ2x5QW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgU3RyaWtlT3V0QW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTIsIF9wYXJhbWV0ZXJzJGRhdGEkY29udDEyLCBfcGFyYW1ldGVycyRkYXRhJHJpY2gxMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGwxMiA9IHBhcmFtZXRlcnMuZGF0YS50aXRsZU9iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTIgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGwxMi5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDEyID0gcGFyYW1ldGVycy5kYXRhLmNvbnRlbnRzT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMiAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDEyLnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTIgPSBwYXJhbWV0ZXJzLmRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDEyICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTIuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUXVhZHJpbGF0ZXJhbHM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucXVhZHJpbGF0ZXJhbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9yZW5kZXJRdWFkcmlsYXRlcmFscygic3RyaWtlb3V0QW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInN0cmlrZW91dEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFN0YW1wQW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTMsIF9wYXJhbWV0ZXJzJGRhdGEkY29udDEzLCBfcGFyYW1ldGVycyRkYXRhJHJpY2gxMzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGwxMyA9IHBhcmFtZXRlcnMuZGF0YS50aXRsZU9iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTMgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGwxMy5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDEzID0gcGFyYW1ldGVycy5kYXRhLmNvbnRlbnRzT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMyAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDEzLnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTMgPSBwYXJhbWV0ZXJzLmRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDEzICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTMuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInN0YW1wQW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuZGF0YS5oYXNQb3B1cCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAobnVsbCwgdGhpcy5kYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgRmlsZUF0dGFjaG1lbnRBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmUxMDsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWxlbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZGF0YS5maWxlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGVuYW1lID0gKDAsIF9kaXNwbGF5X3V0aWxzLmdldEZpbGVuYW1lRnJvbVVybCkoZmlsZW5hbWUsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRlbnQgPSBjb250ZW50OwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkbGlua1NlcnZpY2UkZXZlMTAgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmUxMCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkbGlua1NlcnZpY2UkZXZlMTAuZGlzcGF0Y2goImZpbGVhdHRhY2htZW50YW5ub3RhdGlvbiIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVuYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZGF0YSR0aXRsZU9iaiwgX3RoaXMkZGF0YSRjb250ZW50c09iOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJmaWxlQXR0YWNobWVudEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRyaWdnZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEuaGFzQXBwZWFyYW5jZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlciA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlciA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImltZyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlci5zcmMgPSBgJHt0aGlzLmltYWdlUmVzb3VyY2VzUGF0aH1hbm5vdGF0aW9uLSR7L3BhcGVyY2xpcC9pLnRlc3QodGhpcy5kYXRhLm5hbWUpID8gInBhcGVyY2xpcCIgOiAicHVzaHBpbiJ9LnN2Z2A7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlci5jbGFzc0xpc3QuYWRkKCJwb3B1cFRyaWdnZXJBcmVhIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyaWdnZXIuYWRkRXZlbnRMaXN0ZW5lcigiZGJsY2xpY2siLCB0aGlzLl9kb3dubG9hZC5iaW5kKHRoaXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXAgJiYgKChfdGhpcyRkYXRhJHRpdGxlT2JqID0gdGhpcy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfdGhpcyRkYXRhJHRpdGxlT2JqICE9PSB2b2lkIDAgJiYgX3RoaXMkZGF0YSR0aXRsZU9iai5zdHIgfHwgKF90aGlzJGRhdGEkY29udGVudHNPYiA9IHRoaXMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3RoaXMkZGF0YSRjb250ZW50c09iICE9PSB2b2lkIDAgJiYgX3RoaXMkZGF0YSRjb250ZW50c09iLnN0ciB8fCB0aGlzLmRhdGEucmljaFRleHQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cCh0cmlnZ2VyLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZCh0cmlnZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZG93bmxvYWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRkb3dubG9hZE1hbmFnZXIyOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkZG93bmxvYWRNYW5hZ2VyMiA9IHRoaXMuZG93bmxvYWRNYW5hZ2VyKSA9PT0gbnVsbCB8fCBfdGhpcyRkb3dubG9hZE1hbmFnZXIyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRkb3dubG9hZE1hbmFnZXIyLm9wZW5PckRvd25sb2FkRGF0YSh0aGlzLmNvbnRhaW5lciwgdGhpcy5jb250ZW50LCB0aGlzLmZpbGVuYW1lKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uTGF5ZXIgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyByZW5kZXIocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY2Nlc3NpYmlsaXR5TWFuYWdlcgogICAgICAgICAgICAgICAgICAgICAgICB9ID0gcGFyYW1zOwogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuc2V0TGF5ZXJEaW1lbnNpb25zKShkaXYsIHZpZXdwb3J0KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudFBhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGE6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllcjogZGl2LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZTogcGFyYW1zLnBhZ2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtTZXJ2aWNlOiBwYXJhbXMubGlua1NlcnZpY2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb3dubG9hZE1hbmFnZXI6IHBhcmFtcy5kb3dubG9hZE1hbmFnZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWFnZVJlc291cmNlc1BhdGg6IHBhcmFtcy5pbWFnZVJlc291cmNlc1BhdGggfHwgIiIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJGb3JtczogcGFyYW1zLnJlbmRlckZvcm1zICE9PSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN2Z0ZhY3Rvcnk6IG5ldyBfZGlzcGxheV91dGlscy5ET01TVkdGYWN0b3J5KCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uU3RvcmFnZTogcGFyYW1zLmFubm90YXRpb25TdG9yYWdlIHx8IG5ldyBfYW5ub3RhdGlvbl9zdG9yYWdlLkFubm90YXRpb25TdG9yYWdlKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmFibGVTY3JpcHRpbmc6IHBhcmFtcy5lbmFibGVTY3JpcHRpbmcgPT09IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNKU0FjdGlvbnM6IHBhcmFtcy5oYXNKU0FjdGlvbnMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZE9iamVjdHM6IHBhcmFtcy5maWVsZE9iamVjdHMKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHpJbmRleCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZGF0YSBvZiBhbm5vdGF0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEubm9IVE1MKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5hbm5vdGF0aW9uVHlwZSAhPT0gX3V0aWwuQW5ub3RhdGlvblR5cGUuUE9QVVApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZ2V0UmVjdERpbXMoZGF0YS5yZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAod2lkdGggPD0gMCB8fCBoZWlnaHQgPD0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50UGFyYW1zLmRhdGEgPSBkYXRhOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudCA9IEFubm90YXRpb25FbGVtZW50RmFjdG9yeS5jcmVhdGUoZWxlbWVudFBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWVsZW1lbnQuaXNSZW5kZXJhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZW5kZXJlZCA9IGVsZW1lbnQucmVuZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5oaWRkZW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJlZC5zdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShyZW5kZXJlZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlbmRlcmVkRWxlbWVudCBvZiByZW5kZXJlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJlZEVsZW1lbnQuc3R5bGUuekluZGV4ID0gekluZGV4Kys7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1N0YXRpY1ByaXZhdGVNZXRob2RHZXQoQW5ub3RhdGlvbkxheWVyLCBBbm5vdGF0aW9uTGF5ZXIsIF9hcHBlbmRFbGVtZW50KS5jYWxsKEFubm90YXRpb25MYXllciwgcmVuZGVyZWRFbGVtZW50LCBkYXRhLmlkLCBkaXYsIGFjY2Vzc2liaWxpdHlNYW5hZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlcmVkLnN0eWxlLnpJbmRleCA9IHpJbmRleCsrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbGVtZW50IGluc3RhbmNlb2YgUG9wdXBBbm5vdGF0aW9uRWxlbWVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXYucHJlcGVuZChyZW5kZXJlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzU3RhdGljUHJpdmF0ZU1ldGhvZEdldChBbm5vdGF0aW9uTGF5ZXIsIEFubm90YXRpb25MYXllciwgX2FwcGVuZEVsZW1lbnQpLmNhbGwoQW5ub3RhdGlvbkxheWVyLCByZW5kZXJlZCwgZGF0YS5pZCwgZGl2LCBhY2Nlc3NpYmlsaXR5TWFuYWdlcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1N0YXRpY1ByaXZhdGVNZXRob2RHZXQodGhpcywgQW5ub3RhdGlvbkxheWVyLCBfc2V0QW5ub3RhdGlvbkNhbnZhc01hcCkuY2FsbCh0aGlzLCBkaXYsIHBhcmFtcy5hbm5vdGF0aW9uQ2FudmFzTWFwKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHVwZGF0ZShwYXJhbXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvbkNhbnZhc01hcCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpdiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBwYXJhbXM7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfZGlzcGxheV91dGlscy5zZXRMYXllckRpbWVuc2lvbnMpKGRpdiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb246IHZpZXdwb3J0LnJvdGF0aW9uCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NTdGF0aWNQcml2YXRlTWV0aG9kR2V0KHRoaXMsIEFubm90YXRpb25MYXllciwgX3NldEFubm90YXRpb25DYW52YXNNYXApLmNhbGwodGhpcywgZGl2LCBhbm5vdGF0aW9uQ2FudmFzTWFwKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LmhpZGRlbiA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkxheWVyID0gQW5ub3RhdGlvbkxheWVyOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2FwcGVuZEVsZW1lbnQoZWxlbWVudCwgaWQsIGRpdiwgYWNjZXNzaWJpbGl0eU1hbmFnZXIpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjb250ZW50RWxlbWVudCA9IGVsZW1lbnQuZmlyc3RDaGlsZCB8fCBlbGVtZW50OwogICAgICAgICAgICAgICAgICAgIGNvbnRlbnRFbGVtZW50LmlkID0gYCR7X2Rpc3BsYXlfdXRpbHMuQW5ub3RhdGlvblByZWZpeH0ke2lkfWA7CiAgICAgICAgICAgICAgICAgICAgZGl2LmFwcGVuZChlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICBhY2Nlc3NpYmlsaXR5TWFuYWdlciA9PT0gbnVsbCB8fCBhY2Nlc3NpYmlsaXR5TWFuYWdlciA9PT0gdm9pZCAwID8gdm9pZCAwIDogYWNjZXNzaWJpbGl0eU1hbmFnZXIubW92ZUVsZW1lbnRJbkRPTShkaXYsIGVsZW1lbnQsIGNvbnRlbnRFbGVtZW50LCBmYWxzZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0QW5ub3RhdGlvbkNhbnZhc01hcChkaXYsIGFubm90YXRpb25DYW52YXNNYXApIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWFubm90YXRpb25DYW52YXNNYXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IFtpZCwgY2FudmFzXSBvZiBhbm5vdGF0aW9uQ2FudmFzTWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVsZW1lbnQgPSBkaXYucXVlcnlTZWxlY3RvcihgW2RhdGEtYW5ub3RhdGlvbi1pZD0iJHtpZH0iXWApOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpcnN0Q2hpbGQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGVsZW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZmlyc3RDaGlsZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hcHBlbmQoY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChmaXJzdENoaWxkLm5vZGVOYW1lID09PSAiQ0FOVkFTIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3RDaGlsZC5yZXBsYWNlV2l0aChjYW52YXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3RDaGlsZC5iZWZvcmUoY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uQ2FudmFzTWFwLmNsZWFyKCk7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2OCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkNvbG9yQ29udmVydGVycyA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG1ha2VDb2xvckNvbXAobikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBNYXRoLmZsb29yKE1hdGgubWF4KDAsIE1hdGgubWluKDEsIG4pKSAqIDI1NSkudG9TdHJpbmcoMTYpLnBhZFN0YXJ0KDIsICIwIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDb2xvckNvbnZlcnRlcnMgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBDTVlLX0coX3JlZikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW2MsIHksIG0sIGtdID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsiRyIsIDEgLSBNYXRoLm1pbigxLCAwLjMgKiBjICsgMC41OSAqIG0gKyAwLjExICogeSArIGspXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIEdfQ01ZSyhfcmVmMikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW2ddID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIkNNWUsiLCAwLCAwLCAwLCAxIC0gZ107CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBHX1JHQihfcmVmMykgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW2ddID0gX3JlZjM7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIlJHQiIsIGcsIGcsIGddOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgR19IVE1MKF9yZWY0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBbZ10gPSBfcmVmNDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgRyA9IG1ha2VDb2xvckNvbXAoZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgIyR7R30ke0d9JHtHfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBSR0JfRyhfcmVmNSkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW3IsIGcsIGJdID0gX3JlZjU7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIkciLCAwLjMgKiByICsgMC41OSAqIGcgKyAwLjExICogYl07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBSR0JfSFRNTChfcmVmNikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW3IsIGcsIGJdID0gX3JlZjY7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFIgPSBtYWtlQ29sb3JDb21wKHIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBHID0gbWFrZUNvbG9yQ29tcChnKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQiA9IG1ha2VDb2xvckNvbXAoYik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgIyR7Un0ke0d9JHtCfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBUX0hUTUwoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAiIzAwMDAwMDAwIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIENNWUtfUkdCKF9yZWY3KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBbYywgeSwgbSwga10gPSBfcmVmNzsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsiUkdCIiwgMSAtIE1hdGgubWluKDEsIGMgKyBrKSwgMSAtIE1hdGgubWluKDEsIG0gKyBrKSwgMSAtIE1hdGgubWluKDEsIHkgKyBrKV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBDTVlLX0hUTUwoY29tcG9uZW50cykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZ2IgPSB0aGlzLkNNWUtfUkdCKGNvbXBvbmVudHMpLnNsaWNlKDEpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5SR0JfSFRNTChyZ2IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgUkdCX0NNWUsoX3JlZjgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IFtyLCBnLCBiXSA9IF9yZWY4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjID0gMSAtIHI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG0gPSAxIC0gZzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeSA9IDEgLSBiOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBrID0gTWF0aC5taW4oYywgbSwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIkNNWUsiLCBjLCBtLCB5LCBrXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkNvbG9yQ29udmVydGVycyA9IENvbG9yQ29udmVydGVyczsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTY5ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuWGZhTGF5ZXIgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3hmYV90ZXh0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTQpOwogICAgICAgICAgICAgICAgY2xhc3MgWGZhTGF5ZXIgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBzZXR1cFN0b3JhZ2UoaHRtbCwgaWQsIGVsZW1lbnQsIHN0b3JhZ2UsIGludGVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdG9yZWREYXRhID0gc3RvcmFnZS5nZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZWxlbWVudC5uYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJ0ZXh0YXJlYSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0b3JlZERhdGEudmFsdWUgIT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC50ZXh0Q29udGVudCA9IHN0b3JlZERhdGEudmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlbnQgPT09ICJwcmludCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGh0bWwuYWRkRXZlbnRMaXN0ZW5lcigiaW5wdXQiLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBldmVudC50YXJnZXQudmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJpbnB1dCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVsZW1lbnQuYXR0cmlidXRlcy50eXBlID09PSAicmFkaW8iIHx8IGVsZW1lbnQuYXR0cmlidXRlcy50eXBlID09PSAiY2hlY2tib3giKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdG9yZWREYXRhLnZhbHVlID09PSBlbGVtZW50LmF0dHJpYnV0ZXMueGZhT24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGh0bWwuc2V0QXR0cmlidXRlKCJjaGVja2VkIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoc3RvcmVkRGF0YS52YWx1ZSA9PT0gZWxlbWVudC5hdHRyaWJ1dGVzLnhmYU9mZikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5yZW1vdmVBdHRyaWJ1dGUoImNoZWNrZWQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW50ZW50ID09PSAicHJpbnQiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBodG1sLmFkZEV2ZW50TGlzdGVuZXIoImNoYW5nZSIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZXZlbnQudGFyZ2V0LmNoZWNrZWQgPyBldmVudC50YXJnZXQuZ2V0QXR0cmlidXRlKCJ4ZmFPbiIpIDogZXZlbnQudGFyZ2V0LmdldEF0dHJpYnV0ZSgieGZhT2ZmIikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RvcmVkRGF0YS52YWx1ZSAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5zZXRBdHRyaWJ1dGUoInZhbHVlIiwgc3RvcmVkRGF0YS52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGludGVudCA9PT0gInByaW50IikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5hZGRFdmVudExpc3RlbmVyKCJpbnB1dCIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZXZlbnQudGFyZ2V0LnZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAic2VsZWN0IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RvcmVkRGF0YS52YWx1ZSAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG9wdGlvbiBvZiBlbGVtZW50LmNoaWxkcmVuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3B0aW9uLmF0dHJpYnV0ZXMudmFsdWUgPT09IHN0b3JlZERhdGEudmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb24uYXR0cmlidXRlcy5zZWxlY3RlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5hZGRFdmVudExpc3RlbmVyKCJpbnB1dCIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3B0aW9ucyA9IGV2ZW50LnRhcmdldC5vcHRpb25zOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IG9wdGlvbnMuc2VsZWN0ZWRJbmRleCA9PT0gLTEgPyAiIiA6IG9wdGlvbnNbb3B0aW9ucy5zZWxlY3RlZEluZGV4XS52YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHNldEF0dHJpYnV0ZXMoX3JlZikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlID0gbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtTZXJ2aWNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdHRyaWJ1dGVzCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBlbGVtZW50OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc0hUTUxBbmNob3JFbGVtZW50ID0gaHRtbCBpbnN0YW5jZW9mIEhUTUxBbmNob3JFbGVtZW50OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXR0cmlidXRlcy50eXBlID09PSAicmFkaW8iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdHRyaWJ1dGVzLm5hbWUgPSBgJHthdHRyaWJ1dGVzLm5hbWV9LSR7aW50ZW50fWA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBba2V5LCB2YWx1ZV0gb2YgT2JqZWN0LmVudHJpZXMoYXR0cmlidXRlcykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSA9PT0gbnVsbCB8fCB2YWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImNsYXNzIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5zZXRBdHRyaWJ1dGUoa2V5LCB2YWx1ZS5qb2luKCIgIikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImRhdGFJZCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImlkIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5zZXRBdHRyaWJ1dGUoImRhdGEtZWxlbWVudC1pZCIsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAic3R5bGUiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPYmplY3QuYXNzaWduKGh0bWwuc3R5bGUsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAidGV4dENvbnRlbnQiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBodG1sLnRleHRDb250ZW50ID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNIVE1MQW5jaG9yRWxlbWVudCB8fCBrZXkgIT09ICJocmVmIiAmJiBrZXkgIT09ICJuZXdXaW5kb3ciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBodG1sLnNldEF0dHJpYnV0ZShrZXksIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc0hUTUxBbmNob3JFbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5rU2VydmljZS5hZGRMaW5rQXR0cmlidXRlcyhodG1sLCBhdHRyaWJ1dGVzLmhyZWYsIGF0dHJpYnV0ZXMubmV3V2luZG93KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RvcmFnZSAmJiBhdHRyaWJ1dGVzLmRhdGFJZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXR1cFN0b3JhZ2UoaHRtbCwgYXR0cmlidXRlcy5kYXRhSWQsIGVsZW1lbnQsIHN0b3JhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyByZW5kZXIocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdG9yYWdlID0gcGFyYW1ldGVycy5hbm5vdGF0aW9uU3RvcmFnZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGlua1NlcnZpY2UgPSBwYXJhbWV0ZXJzLmxpbmtTZXJ2aWNlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByb290ID0gcGFyYW1ldGVycy54ZmFIdG1sOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnRlbnQgPSBwYXJhbWV0ZXJzLmludGVudCB8fCAiZGlzcGxheSI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvb3RIdG1sID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudChyb290Lm5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocm9vdC5hdHRyaWJ1dGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldEF0dHJpYnV0ZXMoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGh0bWw6IHJvb3RIdG1sLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQ6IHJvb3QsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtTZXJ2aWNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGFjayA9IFtbcm9vdCwgLTEsIHJvb3RIdG1sXV07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvb3REaXYgPSBwYXJhbWV0ZXJzLmRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgcm9vdERpdi5hcHBlbmQocm9vdEh0bWwpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFyYW1ldGVycy52aWV3cG9ydCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHJhbnNmb3JtID0gYG1hdHJpeCgke3BhcmFtZXRlcnMudmlld3BvcnQudHJhbnNmb3JtLmpvaW4oIiwiKX0pYDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvb3REaXYuc3R5bGUudHJhbnNmb3JtID0gdHJhbnNmb3JtOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlbnQgIT09ICJyaWNoVGV4dCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvb3REaXYuc2V0QXR0cmlidXRlKCJjbGFzcyIsICJ4ZmFMYXllciB4ZmFGb250Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dERpdnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfY2hpbGQkYXR0cmlidXRlczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYXJlbnQsIGksIGh0bWxdID0gc3RhY2suYXQoLTEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgKyAxID09PSBwYXJlbnQuY2hpbGRyZW4ubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGlsZCA9IHBhcmVudC5jaGlsZHJlblsrK3N0YWNrLmF0KC0xKVsxXV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGQgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gY2hpbGQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobmFtZSA9PT0gIiN0ZXh0IikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vZGUgPSBkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZShjaGlsZC52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dERpdnMucHVzaChub2RlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBodG1sLmFwcGVuZChub2RlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjaGlsZEh0bWw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGQgIT09IG51bGwgJiYgY2hpbGQgIT09IHZvaWQgMCAmJiAoX2NoaWxkJGF0dHJpYnV0ZXMgPSBjaGlsZC5hdHRyaWJ1dGVzKSAhPT0gbnVsbCAmJiBfY2hpbGQkYXR0cmlidXRlcyAhPT0gdm9pZCAwICYmIF9jaGlsZCRhdHRyaWJ1dGVzLnhtbG5zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hpbGRIdG1sID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudE5TKGNoaWxkLmF0dHJpYnV0ZXMueG1sbnMsIG5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGlsZEh0bWwgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KG5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5hcHBlbmQoY2hpbGRIdG1sKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGlsZC5hdHRyaWJ1dGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRBdHRyaWJ1dGVzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbDogY2hpbGRIdG1sLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50OiBjaGlsZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5rU2VydmljZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNoaWxkLmNoaWxkcmVuICYmIGNoaWxkLmNoaWxkcmVuLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFjay5wdXNoKFtjaGlsZCwgLTEsIGNoaWxkSHRtbF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGlsZC52YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vZGUgPSBkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZShjaGlsZC52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF94ZmFfdGV4dC5YZmFUZXh0LnNob3VsZEJ1aWxkVGV4dChuYW1lKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0RGl2cy5wdXNoKG5vZGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGlsZEh0bWwuYXBwZW5kKG5vZGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWwgb2Ygcm9vdERpdi5xdWVyeVNlbGVjdG9yQWxsKCIueGZhTm9uSW50ZXJhY3RpdmUgaW5wdXQsIC54ZmFOb25JbnRlcmFjdGl2ZSB0ZXh0YXJlYSIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbC5zZXRBdHRyaWJ1dGUoInJlYWRPbmx5IiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHREaXZzCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB1cGRhdGUocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0cmFuc2Zvcm0gPSBgbWF0cml4KCR7cGFyYW1ldGVycy52aWV3cG9ydC50cmFuc2Zvcm0uam9pbigiLCIpfSlgOwogICAgICAgICAgICAgICAgICAgICAgICBwYXJhbWV0ZXJzLmRpdi5zdHlsZS50cmFuc2Zvcm0gPSB0cmFuc2Zvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtZXRlcnMuZGl2LmhpZGRlbiA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuWGZhTGF5ZXIgPSBYZmFMYXllcjsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTcwICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuU1ZHR3JhcGhpY3MgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX2Rpc3BsYXlfdXRpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0Mik7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9pc19ub2RlID0gX193X3BkZmpzX3JlcXVpcmVfXygzKTsKICAgICAgICAgICAgICAgIGxldCBTVkdHcmFwaGljcyA9IGNsYXNzIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiTm90IGltcGxlbWVudGVkOiBTVkdHcmFwaGljcyIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLlNWR0dyYXBoaWNzID0gU1ZHR3JhcGhpY3M7CiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgU1ZHX0RFRkFVTFRTID0gewogICAgICAgICAgICAgICAgICAgICAgICBmb250U3R5bGU6ICJub3JtYWwiLAogICAgICAgICAgICAgICAgICAgICAgICBmb250V2VpZ2h0OiAibm9ybWFsIiwKICAgICAgICAgICAgICAgICAgICAgICAgZmlsbENvbG9yOiAiIzAwMDAwMCIKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IFhNTF9OUyA9ICJodHRwOi8vd3d3LnczLm9yZy9YTUwvMTk5OC9uYW1lc3BhY2UiOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IFhMSU5LX05TID0gImh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IExJTkVfQ0FQX1NUWUxFUyA9IFsiYnV0dCIsICJyb3VuZCIsICJzcXVhcmUiXTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0pPSU5fU1RZTEVTID0gWyJtaXRlciIsICJyb3VuZCIsICJiZXZlbCJdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGNyZWF0ZU9iamVjdFVSTCA9IGZ1bmN0aW9uIChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjb250ZW50VHlwZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogIiI7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmb3JjZURhdGFTY2hlbWEgPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoVVJMLmNyZWF0ZU9iamVjdFVSTCAmJiB0eXBlb2YgQmxvYiAhPT0gInVuZGVmaW5lZCIgJiYgIWZvcmNlRGF0YVNjaGVtYSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFVSTC5jcmVhdGVPYmplY3RVUkwobmV3IEJsb2IoW2RhdGFdLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogY29udGVudFR5cGUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkaWdpdHMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLz0iOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYnVmZmVyID0gYGRhdGE6JHtjb250ZW50VHlwZX07YmFzZTY0LGA7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGRhdGEubGVuZ3RoOyBpIDwgaWk7IGkgKz0gMykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYjEgPSBkYXRhW2ldICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGIyID0gZGF0YVtpICsgMV0gJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYjMgPSBkYXRhW2kgKyAyXSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkMSA9IGIxID4+IDIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZDIgPSAoYjEgJiAzKSA8PCA0IHwgYjIgPj4gNDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQzID0gaSArIDEgPCBpaSA/IChiMiAmIDB4ZikgPDwgMiB8IGIzID4+IDYgOiA2NDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQ0ID0gaSArIDIgPCBpaSA/IGIzICYgMHgzZiA6IDY0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyICs9IGRpZ2l0c1tkMV0gKyBkaWdpdHNbZDJdICsgZGlnaXRzW2QzXSArIGRpZ2l0c1tkNF07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGJ1ZmZlcjsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnZlcnRJbWdEYXRhVG9QbmcgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFBOR19IRUFERVIgPSBuZXcgVWludDhBcnJheShbMHg4OSwgMHg1MCwgMHg0ZSwgMHg0NywgMHgwZCwgMHgwYSwgMHgxYSwgMHgwYV0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDSFVOS19XUkFQUEVSX1NJWkUgPSAxMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3JjVGFibGUgPSBuZXcgSW50MzJBcnJheSgyNTYpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI1NjsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgYyA9IGk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBoID0gMDsgaCA8IDg7IGgrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjICYgMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjID0gMHhlZGI4ODMyMCBeIGMgPj4gMSAmIDB4N2ZmZmZmZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYyA9IGMgPj4gMSAmIDB4N2ZmZmZmZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JjVGFibGVbaV0gPSBjOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNyYzMyKGRhdGEsIHN0YXJ0LCBlbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjcmMgPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSBzdGFydDsgaSA8IGVuZDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYSA9IChjcmMgXiBkYXRhW2ldKSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYiA9IGNyY1RhYmxlW2FdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyYyA9IGNyYyA+Pj4gOCBeIGI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JjIF4gLTE7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gd3JpdGVQbmdDaHVuayh0eXBlLCBib2R5LCBkYXRhLCBvZmZzZXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwID0gb2Zmc2V0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuID0gYm9keS5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhW3BdID0gbGVuID4+IDI0ICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFbcCArIDFdID0gbGVuID4+IDE2ICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFbcCArIDJdID0gbGVuID4+IDggJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtwICsgM10gPSBsZW4gJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcCArPSA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtwXSA9IHR5cGUuY2hhckNvZGVBdCgwKSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhW3AgKyAxXSA9IHR5cGUuY2hhckNvZGVBdCgxKSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhW3AgKyAyXSA9IHR5cGUuY2hhckNvZGVBdCgyKSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhW3AgKyAzXSA9IHR5cGUuY2hhckNvZGVBdCgzKSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwICs9IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLnNldChib2R5LCBwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHAgKz0gYm9keS5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjcmMgPSBjcmMzMihkYXRhLCBvZmZzZXQgKyA0LCBwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFbcF0gPSBjcmMgPj4gMjQgJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtwICsgMV0gPSBjcmMgPj4gMTYgJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtwICsgMl0gPSBjcmMgPj4gOCAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhW3AgKyAzXSA9IGNyYyAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gYWRsZXIzMihkYXRhLCBzdGFydCwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgYSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgYiA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gc3RhcnQ7IGkgPCBlbmQ7ICsraSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGEgPSAoYSArIChkYXRhW2ldICYgMHhmZikpICUgNjU1MjE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYiA9IChiICsgYSkgJSA2NTUyMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBiIDw8IDE2IHwgYTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBkZWZsYXRlU3luYyhsaXRlcmFscykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfaXNfbm9kZS5pc05vZGVKUykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBkZWZsYXRlU3luY1VuY29tcHJlc3NlZChsaXRlcmFscyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpbnB1dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFyc2VJbnQocHJvY2Vzcy52ZXJzaW9ucy5ub2RlKSA+PSA4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlucHV0ID0gbGl0ZXJhbHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5wdXQgPSBCdWZmZXIuZnJvbShsaXRlcmFscyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG91dHB1dCA9IHJlcXVpcmUoInpsaWIiKS5kZWZsYXRlU3luYyhpbnB1dCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXZlbDogOQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBvdXRwdXQgaW5zdGFuY2VvZiBVaW50OEFycmF5ID8gb3V0cHV0IDogbmV3IFVpbnQ4QXJyYXkob3V0cHV0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIk5vdCBjb21wcmVzc2luZyBQTkcgYmVjYXVzZSB6bGliLmRlZmxhdGVTeW5jIGlzIHVuYXZhaWxhYmxlOiAiICsgZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZGVmbGF0ZVN5bmNVbmNvbXByZXNzZWQobGl0ZXJhbHMpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGRlZmxhdGVTeW5jVW5jb21wcmVzc2VkKGxpdGVyYWxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgbGVuID0gbGl0ZXJhbHMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF4QmxvY2tMZW5ndGggPSAweGZmZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZsYXRlQmxvY2tzID0gTWF0aC5jZWlsKGxlbiAvIG1heEJsb2NrTGVuZ3RoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkYXQgPSBuZXcgVWludDhBcnJheSgyICsgbGVuICsgZGVmbGF0ZUJsb2NrcyAqIDUgKyA0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwaSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHg3ODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSAweDljOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHBvcyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAobGVuID4gbWF4QmxvY2tMZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHgwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHgwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHgwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0LnNldChsaXRlcmFscy5zdWJhcnJheShwb3MsIHBvcyArIG1heEJsb2NrTGVuZ3RoKSwgcGkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBpICs9IG1heEJsb2NrTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvcyArPSBtYXhCbG9ja0xlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW4gLT0gbWF4QmxvY2tMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHgwMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSBsZW4gJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWRhdFtwaSsrXSA9IGxlbiA+PiA4ICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSB+bGVuICYgMHhmZmZmICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSAofmxlbiAmIDB4ZmZmZikgPj4gOCAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0LnNldChsaXRlcmFscy5zdWJhcnJheShwb3MpLCBwaSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwaSArPSBsaXRlcmFscy5sZW5ndGggLSBwb3M7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhZGxlciA9IGFkbGVyMzIobGl0ZXJhbHMsIDAsIGxpdGVyYWxzLmxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gYWRsZXIgPj4gMjQgJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWRhdFtwaSsrXSA9IGFkbGVyID4+IDE2ICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSBhZGxlciA+PiA4ICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSBhZGxlciAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaWRhdDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBlbmNvZGUoaW1nRGF0YSwga2luZCwgZm9yY2VEYXRhU2NoZW1hLCBpc01hc2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gaW1nRGF0YS53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGltZ0RhdGEuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJpdERlcHRoLCBjb2xvclR5cGUsIGxpbmVTaXplOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnl0ZXMgPSBpbWdEYXRhLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGtpbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkltYWdlS2luZC5HUkFZU0NBTEVfMUJQUDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sb3JUeXBlID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYml0RGVwdGggPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5lU2l6ZSA9IHdpZHRoICsgNyA+PiAzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkltYWdlS2luZC5SR0JfMjRCUFA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbG9yVHlwZSA9IDI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJpdERlcHRoID0gODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVNpemUgPSB3aWR0aCAqIDM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuSW1hZ2VLaW5kLlJHQkFfMzJCUFA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbG9yVHlwZSA9IDY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJpdERlcHRoID0gODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVNpemUgPSB3aWR0aCAqIDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiaW52YWxpZCBmb3JtYXQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpdGVyYWxzID0gbmV3IFVpbnQ4QXJyYXkoKDEgKyBsaW5lU2l6ZSkgKiBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG9mZnNldExpdGVyYWxzID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRCeXRlcyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCB5ID0gMDsgeSA8IGhlaWdodDsgKyt5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGl0ZXJhbHNbb2Zmc2V0TGl0ZXJhbHMrK10gPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpdGVyYWxzLnNldChieXRlcy5zdWJhcnJheShvZmZzZXRCeXRlcywgb2Zmc2V0Qnl0ZXMgKyBsaW5lU2l6ZSksIG9mZnNldExpdGVyYWxzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRCeXRlcyArPSBsaW5lU2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRMaXRlcmFscyArPSBsaW5lU2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09PSBfdXRpbC5JbWFnZUtpbmQuR1JBWVNDQUxFXzFCUFAgJiYgaXNNYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0TGl0ZXJhbHMgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IHkgPSAwOyB5IDwgaGVpZ2h0OyB5KyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0TGl0ZXJhbHMrKzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsaW5lU2l6ZTsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaXRlcmFsc1tvZmZzZXRMaXRlcmFscysrXSBePSAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaWhkciA9IG5ldyBVaW50OEFycmF5KFt3aWR0aCA+PiAyNCAmIDB4ZmYsIHdpZHRoID4+IDE2ICYgMHhmZiwgd2lkdGggPj4gOCAmIDB4ZmYsIHdpZHRoICYgMHhmZiwgaGVpZ2h0ID4+IDI0ICYgMHhmZiwgaGVpZ2h0ID4+IDE2ICYgMHhmZiwgaGVpZ2h0ID4+IDggJiAweGZmLCBoZWlnaHQgJiAweGZmLCBiaXREZXB0aCwgY29sb3JUeXBlLCAweDAwLCAweDAwLCAweDAwXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZGF0ID0gZGVmbGF0ZVN5bmMobGl0ZXJhbHMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcG5nTGVuZ3RoID0gUE5HX0hFQURFUi5sZW5ndGggKyBDSFVOS19XUkFQUEVSX1NJWkUgKiAzICsgaWhkci5sZW5ndGggKyBpZGF0Lmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSBuZXcgVWludDhBcnJheShwbmdMZW5ndGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG9mZnNldCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLnNldChQTkdfSEVBREVSLCBvZmZzZXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0ICs9IFBOR19IRUFERVIubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGVQbmdDaHVuaygiSUhEUiIsIGloZHIsIGRhdGEsIG9mZnNldCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXQgKz0gQ0hVTktfV1JBUFBFUl9TSVpFICsgaWhkci5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0ZVBuZ0NodW5rKCJJREFUQSIsIGlkYXQsIGRhdGEsIG9mZnNldCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXQgKz0gQ0hVTktfV1JBUFBFUl9TSVpFICsgaWRhdC5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0ZVBuZ0NodW5rKCJJRU5EIiwgbmV3IFVpbnQ4QXJyYXkoMCksIGRhdGEsIG9mZnNldCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlT2JqZWN0VVJMKGRhdGEsICJpbWFnZS9wbmciLCBmb3JjZURhdGFTY2hlbWEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBjb252ZXJ0SW1nRGF0YVRvUG5nKGltZ0RhdGEsIGZvcmNlRGF0YVNjaGVtYSwgaXNNYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBraW5kID0gaW1nRGF0YS5raW5kID09PSB1bmRlZmluZWQgPyBfdXRpbC5JbWFnZUtpbmQuR1JBWVNDQUxFXzFCUFAgOiBpbWdEYXRhLmtpbmQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZW5jb2RlKGltZ0RhdGEsIGtpbmQsIGZvcmNlRGF0YVNjaGVtYSwgaXNNYXNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9KCk7CiAgICAgICAgICAgICAgICAgICAgY2xhc3MgU1ZHRXh0cmFTdGF0ZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5mb250U2l6ZVNjYWxlID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZm9udFdlaWdodCA9IFNWR19ERUZBVUxUUy5mb250V2VpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5mb250U2l6ZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRNYXRyaXggPSBfdXRpbC5JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZvbnRNYXRyaXggPSBfdXRpbC5GT05UX0lERU5USVRZX01BVFJJWDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGVhZGluZyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRSZW5kZXJpbmdNb2RlID0gX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuRklMTDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGV4dE1hdHJpeFNjYWxlID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnkgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5saW5lWCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmVZID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2hhclNwYWNpbmcgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy53b3JkU3BhY2luZyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRIU2NhbGUgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50ZXh0UmlzZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGxDb2xvciA9IFNWR19ERUZBVUxUUy5maWxsQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cm9rZUNvbG9yID0gIiMwMDAwMDAiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5maWxsQWxwaGEgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJva2VBbHBoYSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmVXaWR0aCA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmVKb2luID0gIiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmVDYXAgPSAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWl0ZXJMaW1pdCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRhc2hBcnJheSA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kYXNoUGhhc2UgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kZXBlbmRlbmNpZXMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWN0aXZlQ2xpcFVybCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXBHcm91cCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hc2tJZCA9ICIiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE9iamVjdC5jcmVhdGUodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0Q3VycmVudFBvaW50KHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCA9IHg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnkgPSB5OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG9wTGlzdFRvVHJlZShvcExpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG9wVHJlZSA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bXAgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvcExpc3RFbGVtZW50IG9mIG9wTGlzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wTGlzdEVsZW1lbnQuZm4gPT09ICJzYXZlIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wVHJlZS5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm5JZDogOTIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZuOiAiZ3JvdXAiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtczogW10KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXAucHVzaChvcFRyZWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wVHJlZSA9IG9wVHJlZS5hdCgtMSkuaXRlbXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3BMaXN0RWxlbWVudC5mbiA9PT0gInJlc3RvcmUiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3BUcmVlID0gdG1wLnBvcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcFRyZWUucHVzaChvcExpc3RFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gb3BUcmVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBwZih2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcih2YWx1ZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZS50b1N0cmluZygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHMgPSB2YWx1ZS50b0ZpeGVkKDEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGkgPSBzLmxlbmd0aCAtIDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzW2ldICE9PSAiMCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGktLTsKICAgICAgICAgICAgICAgICAgICAgICAgfSB3aGlsZSAoc1tpXSA9PT0gIjAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHMuc3Vic3RyaW5nKDAsIHNbaV0gPT09ICIuIiA/IGkgOiBpICsgMSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHBtKG0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1bNF0gPT09IDAgJiYgbVs1XSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1bMV0gPT09IDAgJiYgbVsyXSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtWzBdID09PSAxICYmIG1bM10gPT09IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICIiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYHNjYWxlKCR7cGYobVswXSl9ICR7cGYobVszXSl9KWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobVswXSA9PT0gbVszXSAmJiBtWzFdID09PSAtbVsyXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGEgPSBNYXRoLmFjb3MobVswXSkgKiAxODAgLyBNYXRoLlBJOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgcm90YXRlKCR7cGYoYSl9KWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobVswXSA9PT0gMSAmJiBtWzFdID09PSAwICYmIG1bMl0gPT09IDAgJiYgbVszXSA9PT0gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgdHJhbnNsYXRlKCR7cGYobVs0XSl9ICR7cGYobVs1XSl9KWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGBtYXRyaXgoJHtwZihtWzBdKX0gJHtwZihtWzFdKX0gJHtwZihtWzJdKX0gJHtwZihtWzNdKX0gJHtwZihtWzRdKX0gYCArIGAke3BmKG1bNV0pfSlgOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBsZXQgY2xpcENvdW50ID0gMDsKICAgICAgICAgICAgICAgICAgICBsZXQgbWFza0NvdW50ID0gMDsKICAgICAgICAgICAgICAgICAgICBsZXQgc2hhZGluZ0NvdW50ID0gMDsKICAgICAgICAgICAgICAgICAgICBleHBvcnRzLlNWR0dyYXBoaWNzID0gU1ZHR3JhcGhpY3MgPSBjbGFzcyB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKGNvbW1vbk9ianMsIG9ianMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmb3JjZURhdGFTY2hlbWEgPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF9kaXNwbGF5X3V0aWxzLmRlcHJlY2F0ZWQpKCJUaGUgU1ZHIGJhY2stZW5kIGlzIG5vIGxvbmdlciBtYWludGFpbmVkIGFuZCAqbWF5KiBiZSByZW1vdmVkIGluIHRoZSBmdXR1cmUuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN2Z0ZhY3RvcnkgPSBuZXcgX2Rpc3BsYXlfdXRpbHMuRE9NU1ZHRmFjdG9yeSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50ID0gbmV3IFNWR0V4dHJhU3RhdGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNmb3JtTWF0cml4ID0gX3V0aWwuSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm1TdGFjayA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leHRyYVN0YWNrID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbW1vbk9ianMgPSBjb21tb25PYmpzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vYmpzID0gb2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0NsaXAgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nRU9GaWxsID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVtYmVkRm9udHMgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW1iZWRkZWRGb250cyA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNzc1N0eWxlID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZm9yY2VEYXRhU2NoZW1hID0gISFmb3JjZURhdGFTY2hlbWE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9vcGVyYXRvcklkTWFwcGluZyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvcCBpbiBfdXRpbC5PUFMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9vcGVyYXRvcklkTWFwcGluZ1tfdXRpbC5PUFNbb3BdXSA9IG9wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGdldE9iamVjdChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZmFsbGJhY2sgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGRhdGEgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGEuc3RhcnRzV2l0aCgiZ18iKSA/IHRoaXMuY29tbW9uT2Jqcy5nZXQoZGF0YSkgOiB0aGlzLm9ianMuZ2V0KGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbGxiYWNrOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNhdmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zZm9ybVN0YWNrLnB1c2godGhpcy50cmFuc2Zvcm1NYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2xkID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leHRyYVN0YWNrLnB1c2gob2xkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudCA9IG9sZC5jbG9uZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3RvcmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zZm9ybU1hdHJpeCA9IHRoaXMudHJhbnNmb3JtU3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQgPSB0aGlzLmV4dHJhU3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBlbmRpbmdDbGlwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGdycCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZ3JvdXAoaXRlbXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leGVjdXRlT3BUcmVlKGl0ZW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxvYWREZXBlbmRlbmNpZXMob3BlcmF0b3JMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmbkFycmF5ID0gb3BlcmF0b3JMaXN0LmZuQXJyYXk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhcmdzQXJyYXkgPSBvcGVyYXRvckxpc3QuYXJnc0FycmF5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZm5BcnJheS5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZuQXJyYXlbaV0gIT09IF91dGlsLk9QUy5kZXBlbmRlbmN5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG9iaiBvZiBhcmdzQXJyYXlbaV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2Jqc1Bvb2wgPSBvYmouc3RhcnRzV2l0aCgiZ18iKSA/IHRoaXMuY29tbW9uT2JqcyA6IHRoaXMub2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJvbWlzZSA9IG5ldyBQcm9taXNlKHJlc29sdmUgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Jqc1Bvb2wuZ2V0KG9iaiwgcmVzb2x2ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuZGVwZW5kZW5jaWVzLnB1c2gocHJvbWlzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFByb21pc2UuYWxsKHRoaXMuY3VycmVudC5kZXBlbmRlbmNpZXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0cmFuc2Zvcm1NYXRyaXggPSBbYSwgYiwgYywgZCwgZSwgZl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zZm9ybU1hdHJpeCA9IF91dGlsLlV0aWwudHJhbnNmb3JtKHRoaXMudHJhbnNmb3JtTWF0cml4LCB0cmFuc2Zvcm1NYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50Z3JwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBnZXRTVkcob3BlcmF0b3JMaXN0LCB2aWV3cG9ydCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52aWV3cG9ydCA9IHZpZXdwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ZnRWxlbWVudCA9IHRoaXMuX2luaXRpYWxpemUodmlld3BvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubG9hZERlcGVuZGVuY2llcyhvcGVyYXRvckxpc3QpLnRoZW4oKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNmb3JtTWF0cml4ID0gX3V0aWwuSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZXhlY3V0ZU9wVHJlZSh0aGlzLmNvbnZlcnRPcExpc3Qob3BlcmF0b3JMaXN0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN2Z0VsZW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb252ZXJ0T3BMaXN0KG9wZXJhdG9yTGlzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3BlcmF0b3JJZE1hcHBpbmcgPSB0aGlzLl9vcGVyYXRvcklkTWFwcGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3NBcnJheSA9IG9wZXJhdG9yTGlzdC5hcmdzQXJyYXk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmbkFycmF5ID0gb3BlcmF0b3JMaXN0LmZuQXJyYXk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvcExpc3QgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGZuQXJyYXkubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZuSWQgPSBmbkFycmF5W2ldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wTGlzdC5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm5JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm46IG9wZXJhdG9ySWRNYXBwaW5nW2ZuSWRdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmdzOiBhcmdzQXJyYXlbaV0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBvcExpc3RUb1RyZWUob3BMaXN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBleGVjdXRlT3BUcmVlKG9wVHJlZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvcFRyZWVFbGVtZW50IG9mIG9wVHJlZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZuID0gb3BUcmVlRWxlbWVudC5mbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmbklkID0gb3BUcmVlRWxlbWVudC5mbklkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3MgPSBvcFRyZWVFbGVtZW50LmFyZ3M7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChmbklkIHwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5iZWdpblRleHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmJlZ2luVGV4dCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmRlcGVuZGVuY3k6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0TGVhZGluZzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGVhZGluZyhhcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRMZWFkaW5nTW92ZVRleHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldExlYWRpbmdNb3ZlVGV4dChhcmdzWzBdLCBhcmdzWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRGb250OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGb250KGFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNob3dUZXh0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zaG93VGV4dChhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zaG93U3BhY2VkVGV4dDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2hvd1RleHQoYXJnc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kVGV4dDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kVGV4dCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm1vdmVUZXh0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb3ZlVGV4dChhcmdzWzBdLCBhcmdzWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRDaGFyU3BhY2luZzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0Q2hhclNwYWNpbmcoYXJnc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0V29yZFNwYWNpbmc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFdvcmRTcGFjaW5nKGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEhTY2FsZToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SFNjYWxlKGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFRleHRNYXRyaXg6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFRleHRNYXRyaXgoYXJnc1swXSwgYXJnc1sxXSwgYXJnc1syXSwgYXJnc1szXSwgYXJnc1s0XSwgYXJnc1s1XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0VGV4dFJpc2U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFRleHRSaXNlKGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFRleHRSZW5kZXJpbmdNb2RlOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRUZXh0UmVuZGVyaW5nTW9kZShhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRMaW5lV2lkdGg6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldExpbmVXaWR0aChhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRMaW5lSm9pbjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGluZUpvaW4oYXJnc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0TGluZUNhcDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGluZUNhcChhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRNaXRlckxpbWl0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRNaXRlckxpbWl0KGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZpbGxSR0JDb2xvcjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RmlsbFJHQkNvbG9yKGFyZ3NbMF0sIGFyZ3NbMV0sIGFyZ3NbMl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFN0cm9rZVJHQkNvbG9yOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRTdHJva2VSR0JDb2xvcihhcmdzWzBdLCBhcmdzWzFdLCBhcmdzWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRTdHJva2VDb2xvck46CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFN0cm9rZUNvbG9yTihhcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRGaWxsQ29sb3JOOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGaWxsQ29sb3JOKGFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNoYWRpbmdGaWxsOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zaGFkaW5nRmlsbChhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXREYXNoOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREYXNoKGFyZ3NbMF0sIGFyZ3NbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFJlbmRlcmluZ0ludGVudDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0UmVuZGVyaW5nSW50ZW50KGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZsYXRuZXNzOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGbGF0bmVzcyhhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRHU3RhdGU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldEdTdGF0ZShhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5maWxsOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5maWxsKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW9GaWxsOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lb0ZpbGwoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zdHJva2U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmZpbGxTdHJva2U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGxTdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5lb0ZpbGxTdHJva2U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVvRmlsbFN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmNsaXA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoIm5vbnplcm8iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5lb0NsaXA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoImV2ZW5vZGQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5wYWludFNvbGlkQ29sb3JJbWFnZU1hc2s6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhaW50U29saWRDb2xvckltYWdlTWFzaygpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnBhaW50SW1hZ2VYT2JqZWN0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludEltYWdlWE9iamVjdChhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5wYWludElubGluZUltYWdlWE9iamVjdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFpbnRJbmxpbmVJbWFnZVhPYmplY3QoYXJnc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMucGFpbnRJbWFnZU1hc2tYT2JqZWN0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludEltYWdlTWFza1hPYmplY3QoYXJnc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMucGFpbnRGb3JtWE9iamVjdEJlZ2luOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludEZvcm1YT2JqZWN0QmVnaW4oYXJnc1swXSwgYXJnc1sxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMucGFpbnRGb3JtWE9iamVjdEVuZDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFpbnRGb3JtWE9iamVjdEVuZCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmNsb3NlUGF0aDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY2xvc2VTdHJva2U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsb3NlU3Ryb2tlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY2xvc2VGaWxsU3Ryb2tlOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbG9zZUZpbGxTdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jbG9zZUVPRmlsbFN0cm9rZToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xvc2VFT0ZpbGxTdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5uZXh0TGluZToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmV4dExpbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy50cmFuc2Zvcm06CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zZm9ybShhcmdzWzBdLCBhcmdzWzFdLCBhcmdzWzJdLCBhcmdzWzNdLCBhcmdzWzRdLCBhcmdzWzVdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jb25zdHJ1Y3RQYXRoOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb25zdHJ1Y3RQYXRoKGFyZ3NbMF0sIGFyZ3NbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmVuZFBhdGg6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDkyOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5ncm91cChvcFRyZWVFbGVtZW50Lml0ZW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBVbmltcGxlbWVudGVkIG9wZXJhdG9yICR7Zm59YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0V29yZFNwYWNpbmcod29yZFNwYWNpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC53b3JkU3BhY2luZyA9IHdvcmRTcGFjaW5nOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldENoYXJTcGFjaW5nKGNoYXJTcGFjaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuY2hhclNwYWNpbmcgPSBjaGFyU3BhY2luZzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBuZXh0TGluZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubW92ZVRleHQoMCwgdGhpcy5jdXJyZW50LmxlYWRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldFRleHRNYXRyaXgoYSwgYiwgYywgZCwgZSwgZikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudGV4dE1hdHJpeCA9IGN1cnJlbnQubGluZU1hdHJpeCA9IFthLCBiLCBjLCBkLCBlLCBmXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudGV4dE1hdHJpeFNjYWxlID0gTWF0aC5oeXBvdChhLCBiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueCA9IGN1cnJlbnQubGluZVggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55ID0gY3VycmVudC5saW5lWSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Lnhjb29yZHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueWNvb3JkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3BhbiA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6dHNwYW4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgImZvbnQtZmFtaWx5IiwgY3VycmVudC5mb250RmFtaWx5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgImZvbnQtc2l6ZSIsIGAke3BmKGN1cnJlbnQuZm9udFNpemUpfXB4YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgcGYoLWN1cnJlbnQueSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50eHRFbGVtZW50ID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2Zzp0ZXh0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnR4dEVsZW1lbnQuYXBwZW5kKGN1cnJlbnQudHNwYW4pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGJlZ2luVGV4dCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLmN1cnJlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnggPSBjdXJyZW50LmxpbmVYID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueSA9IGN1cnJlbnQubGluZVkgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50ZXh0TWF0cml4ID0gX3V0aWwuSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5saW5lTWF0cml4ID0gX3V0aWwuSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50ZXh0TWF0cml4U2NhbGUgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3BhbiA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6dHNwYW4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHh0RWxlbWVudCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6dGV4dCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50eHRncnAgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOmciKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueGNvb3JkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55Y29vcmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbW92ZVRleHQoeCwgeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueCA9IGN1cnJlbnQubGluZVggKz0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueSA9IGN1cnJlbnQubGluZVkgKz0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueGNvb3JkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55Y29vcmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2Zzp0c3BhbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3Bhbi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZm9udC1mYW1pbHkiLCBjdXJyZW50LmZvbnRGYW1pbHkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3Bhbi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZm9udC1zaXplIiwgYCR7cGYoY3VycmVudC5mb250U2l6ZSl9cHhgKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCBwZigtY3VycmVudC55KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2hvd1RleHQoZ2x5cGhzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udCA9IGN1cnJlbnQuZm9udDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRTaXplID0gY3VycmVudC5mb250U2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250U2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRTaXplU2NhbGUgPSBjdXJyZW50LmZvbnRTaXplU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyU3BhY2luZyA9IGN1cnJlbnQuY2hhclNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3b3JkU3BhY2luZyA9IGN1cnJlbnQud29yZFNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250RGlyZWN0aW9uID0gY3VycmVudC5mb250RGlyZWN0aW9uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dEhTY2FsZSA9IGN1cnJlbnQudGV4dEhTY2FsZSAqIGZvbnREaXJlY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2ZXJ0aWNhbCA9IGZvbnQudmVydGljYWw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcGFjaW5nRGlyID0gdmVydGljYWwgPyAxIDogLTE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZhdWx0Vk1ldHJpY3MgPSBmb250LmRlZmF1bHRWTWV0cmljczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoQWR2YW5jZVNjYWxlID0gZm9udFNpemUgKiBjdXJyZW50LmZvbnRNYXRyaXhbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgeCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGdseXBoIG9mIGdseXBocykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChnbHlwaCA9PT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ICs9IGZvbnREaXJlY3Rpb24gKiB3b3JkU3BhY2luZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgZ2x5cGggPT09ICJudW1iZXIiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHggKz0gc3BhY2luZ0RpciAqIGdseXBoICogZm9udFNpemUgLyAxMDAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3BhY2luZyA9IChnbHlwaC5pc1NwYWNlID8gd29yZFNwYWNpbmcgOiAwKSArIGNoYXJTcGFjaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoYXJhY3RlciA9IGdseXBoLmZvbnRDaGFyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzY2FsZWRYLCBzY2FsZWRZOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB3aWR0aCA9IGdseXBoLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2ZXJ0aWNhbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgdng7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZtZXRyaWMgPSBnbHlwaC52bWV0cmljIHx8IGRlZmF1bHRWTWV0cmljczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdnggPSBnbHlwaC52bWV0cmljID8gdm1ldHJpY1sxXSA6IHdpZHRoICogMC41OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2eCA9IC12eCAqIHdpZHRoQWR2YW5jZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2eSA9IHZtZXRyaWNbMl0gKiB3aWR0aEFkdmFuY2VTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGggPSB2bWV0cmljID8gLXZtZXRyaWNbMF0gOiB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVkWCA9IHZ4IC8gZm9udFNpemVTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVkWSA9ICh4ICsgdnkpIC8gZm9udFNpemVTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWRYID0geCAvIGZvbnRTaXplU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZFkgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ2x5cGguaXNJbkZvbnQgfHwgZm9udC5taXNzaW5nRmlsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Lnhjb29yZHMucHVzaChjdXJyZW50LnggKyBzY2FsZWRYKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZlcnRpY2FsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Lnljb29yZHMucHVzaCgtY3VycmVudC55ICsgc2NhbGVkWSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3Bhbi50ZXh0Q29udGVudCArPSBjaGFyYWN0ZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHt9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNoYXJXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmVydGljYWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hhcldpZHRoID0gd2lkdGggKiB3aWR0aEFkdmFuY2VTY2FsZSAtIHNwYWNpbmcgKiBmb250RGlyZWN0aW9uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYXJXaWR0aCA9IHdpZHRoICogd2lkdGhBZHZhbmNlU2NhbGUgKyBzcGFjaW5nICogZm9udERpcmVjdGlvbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCArPSBjaGFyV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ4IiwgY3VycmVudC54Y29vcmRzLm1hcChwZikuam9pbigiICIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2ZXJ0aWNhbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCBjdXJyZW50Lnljb29yZHMubWFwKHBmKS5qb2luKCIgIikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgcGYoLWN1cnJlbnQueSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZlcnRpY2FsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55IC09IHg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueCArPSB4ICogdGV4dEhTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgImZvbnQtZmFtaWx5IiwgY3VycmVudC5mb250RmFtaWx5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgImZvbnQtc2l6ZSIsIGAke3BmKGN1cnJlbnQuZm9udFNpemUpfXB4YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudC5mb250U3R5bGUgIT09IFNWR19ERUZBVUxUUy5mb250U3R5bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJmb250LXN0eWxlIiwgY3VycmVudC5mb250U3R5bGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQuZm9udFdlaWdodCAhPT0gU1ZHX0RFRkFVTFRTLmZvbnRXZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJmb250LXdlaWdodCIsIGN1cnJlbnQuZm9udFdlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxsU3Ryb2tlTW9kZSA9IGN1cnJlbnQudGV4dFJlbmRlcmluZ01vZGUgJiBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRV9NQVNLOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMIHx8IGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LmZpbGxDb2xvciAhPT0gU1ZHX0RFRkFVTFRTLmZpbGxDb2xvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgY3VycmVudC5maWxsQ29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudC5maWxsQWxwaGEgPCAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgImZpbGwtb3BhY2l0eSIsIGN1cnJlbnQuZmlsbEFscGhhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGN1cnJlbnQudGV4dFJlbmRlcmluZ01vZGUgPT09IF91dGlsLlRleHRSZW5kZXJpbmdNb2RlLkFERF9UT19QQVRIKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3Bhbi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZmlsbCIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgIm5vbmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmaWxsU3Ryb2tlTW9kZSA9PT0gX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuU1RST0tFIHx8IGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmVXaWR0aFNjYWxlID0gMSAvIChjdXJyZW50LnRleHRNYXRyaXhTY2FsZSB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRTdHJva2VBdHRyaWJ1dGVzKGN1cnJlbnQudHNwYW4sIGxpbmVXaWR0aFNjYWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0ZXh0TWF0cml4ID0gY3VycmVudC50ZXh0TWF0cml4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQudGV4dFJpc2UgIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0TWF0cml4ID0gdGV4dE1hdHJpeC5zbGljZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHRNYXRyaXhbNV0gKz0gY3VycmVudC50ZXh0UmlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHh0RWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAidHJhbnNmb3JtIiwgYCR7cG0odGV4dE1hdHJpeCl9IHNjYWxlKCR7cGYodGV4dEhTY2FsZSl9LCAtMSlgKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHh0RWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhYTUxfTlMsICJ4bWw6c3BhY2UiLCAicHJlc2VydmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHh0RWxlbWVudC5hcHBlbmQoY3VycmVudC50c3Bhbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnR4dGdycC5hcHBlbmQoY3VycmVudC50eHRFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Vuc3VyZVRyYW5zZm9ybUdyb3VwKCkuYXBwZW5kKGN1cnJlbnQudHh0RWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0TGVhZGluZ01vdmVUZXh0KHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGVhZGluZygteSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1vdmVUZXh0KHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGFkZEZvbnRTdHlsZShmb250T2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWZvbnRPYmouZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiYWRkRm9udFN0eWxlOiBObyBmb250IGRhdGEgYXZhaWxhYmxlLCAiICsgJ2Vuc3VyZSB0aGF0IHRoZSAiZm9udEV4dHJhUHJvcGVydGllcyIgQVBJIHBhcmFtZXRlciBpcyBzZXQuJyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY3NzU3R5bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNzc1N0eWxlID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpzdHlsZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3NzU3R5bGUuc2V0QXR0cmlidXRlTlMobnVsbCwgInR5cGUiLCAidGV4dC9jc3MiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlZnMuYXBwZW5kKHRoaXMuY3NzU3R5bGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdXJsID0gY3JlYXRlT2JqZWN0VVJMKGZvbnRPYmouZGF0YSwgZm9udE9iai5taW1ldHlwZSwgdGhpcy5mb3JjZURhdGFTY2hlbWEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jc3NTdHlsZS50ZXh0Q29udGVudCArPSBgQGZvbnQtZmFjZSB7IGZvbnQtZmFtaWx5OiAiJHtmb250T2JqLmxvYWRlZE5hbWV9IjtgICsgYCBzcmM6IHVybCgke3VybH0pOyB9XG5gOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldEZvbnQoZGV0YWlscykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRPYmogPSB0aGlzLmNvbW1vbk9ianMuZ2V0KGRldGFpbHNbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNpemUgPSBkZXRhaWxzWzFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5mb250ID0gZm9udE9iajsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmVtYmVkRm9udHMgJiYgIWZvbnRPYmoubWlzc2luZ0ZpbGUgJiYgIXRoaXMuZW1iZWRkZWRGb250c1tmb250T2JqLmxvYWRlZE5hbWVdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRGb250U3R5bGUoZm9udE9iaik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbWJlZGRlZEZvbnRzW2ZvbnRPYmoubG9hZGVkTmFtZV0gPSBmb250T2JqOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5mb250TWF0cml4ID0gZm9udE9iai5mb250TWF0cml4IHx8IF91dGlsLkZPTlRfSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJvbGQgPSAibm9ybWFsIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250T2JqLmJsYWNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9sZCA9ICI5MDAiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChmb250T2JqLmJvbGQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib2xkID0gImJvbGQiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXRhbGljID0gZm9udE9iai5pdGFsaWMgPyAiaXRhbGljIiA6ICJub3JtYWwiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNpemUgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZSA9IC1zaXplOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuZm9udERpcmVjdGlvbiA9IC0xOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmZvbnREaXJlY3Rpb24gPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5mb250U2l6ZSA9IHNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmZvbnRGYW1pbHkgPSBmb250T2JqLmxvYWRlZE5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmZvbnRXZWlnaHQgPSBib2xkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5mb250U3R5bGUgPSBpdGFsaWM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2Zzp0c3BhbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3Bhbi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAieSIsIHBmKC1jdXJyZW50LnkpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueGNvb3JkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55Y29vcmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZW5kVGV4dCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfY3VycmVudCR0eHRFbGVtZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LnRleHRSZW5kZXJpbmdNb2RlICYgX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuQUREX1RPX1BBVEhfRkxBRyAmJiAoX2N1cnJlbnQkdHh0RWxlbWVudCA9IGN1cnJlbnQudHh0RWxlbWVudCkgIT09IG51bGwgJiYgX2N1cnJlbnQkdHh0RWxlbWVudCAhPT0gdm9pZCAwICYmIF9jdXJyZW50JHR4dEVsZW1lbnQuaGFzQ2hpbGROb2RlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5lbGVtZW50ID0gY3VycmVudC50eHRFbGVtZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xpcCgibm9uemVybyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldExpbmVXaWR0aCh3aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5saW5lV2lkdGggPSB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzZXRMaW5lQ2FwKHN0eWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQubGluZUNhcCA9IExJTkVfQ0FQX1NUWUxFU1tzdHlsZV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0TGluZUpvaW4oc3R5bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5saW5lSm9pbiA9IExJTkVfSk9JTl9TVFlMRVNbc3R5bGVdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldE1pdGVyTGltaXQobGltaXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5taXRlckxpbWl0ID0gbGltaXQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0U3Ryb2tlQWxwaGEoc3Ryb2tlQWxwaGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5zdHJva2VBbHBoYSA9IHN0cm9rZUFscGhhOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZVJHQkNvbG9yKHIsIGcsIGIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5zdHJva2VDb2xvciA9IF91dGlsLlV0aWwubWFrZUhleENvbG9yKHIsIGcsIGIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldEZpbGxBbHBoYShmaWxsQWxwaGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5maWxsQWxwaGEgPSBmaWxsQWxwaGE7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0RmlsbFJHQkNvbG9yKHIsIGcsIGIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5maWxsQ29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihyLCBnLCBiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC50c3BhbiA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6dHNwYW4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC54Y29vcmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQueWNvb3JkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZUNvbG9yTihhcmdzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuc3Ryb2tlQ29sb3IgPSB0aGlzLl9tYWtlQ29sb3JOX1BhdHRlcm4oYXJncyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0RmlsbENvbG9yTihhcmdzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuZmlsbENvbG9yID0gdGhpcy5fbWFrZUNvbG9yTl9QYXR0ZXJuKGFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNoYWRpbmdGaWxsKGFyZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gdGhpcy52aWV3cG9ydC53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IHRoaXMudmlld3BvcnQuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW52ID0gX3V0aWwuVXRpbC5pbnZlcnNlVHJhbnNmb3JtKHRoaXMudHJhbnNmb3JtTWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJsID0gX3V0aWwuVXRpbC5hcHBseVRyYW5zZm9ybShbMCwgMF0sIGludik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiciA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oWzAsIGhlaWdodF0sIGludik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bCA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oW3dpZHRoLCAwXSwgaW52KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVyID0gX3V0aWwuVXRpbC5hcHBseVRyYW5zZm9ybShbd2lkdGgsIGhlaWdodF0sIGludik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4MCA9IE1hdGgubWluKGJsWzBdLCBiclswXSwgdWxbMF0sIHVyWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHkwID0gTWF0aC5taW4oYmxbMV0sIGJyWzFdLCB1bFsxXSwgdXJbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeDEgPSBNYXRoLm1heChibFswXSwgYnJbMF0sIHVsWzBdLCB1clswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5MSA9IE1hdGgubWF4KGJsWzFdLCBiclsxXSwgdWxbMV0sIHVyWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOnJlY3QiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIngiLCB4MCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgeTApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAid2lkdGgiLCB4MSAtIHgwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgImhlaWdodCIsIHkxIC0geTApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZmlsbCIsIHRoaXMuX21ha2VTaGFkaW5nUGF0dGVybihhcmdzKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jdXJyZW50LmZpbGxBbHBoYSA8IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsLW9wYWNpdHkiLCB0aGlzLmN1cnJlbnQuZmlsbEFscGhhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Vuc3VyZVRyYW5zZm9ybUdyb3VwKCkuYXBwZW5kKHJlY3QpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9tYWtlQ29sb3JOX1BhdHRlcm4oYXJncykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFyZ3NbMF0gPT09ICJUaWxpbmdQYXR0ZXJuIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9tYWtlVGlsaW5nUGF0dGVybihhcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9tYWtlU2hhZGluZ1BhdHRlcm4oYXJncyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX21ha2VUaWxpbmdQYXR0ZXJuKGFyZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gYXJnc1sxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9wZXJhdG9yTGlzdCA9IGFyZ3NbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXRyaXggPSBhcmdzWzNdIHx8IF91dGlsLklERU5USVRZX01BVFJJWDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFt4MCwgeTAsIHgxLCB5MV0gPSBhcmdzWzRdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeHN0ZXAgPSBhcmdzWzVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeXN0ZXAgPSBhcmdzWzZdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFpbnRUeXBlID0gYXJnc1s3XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRpbGluZ0lkID0gYHNoYWRpbmcke3NoYWRpbmdDb3VudCsrfWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbdHgwLCB0eTAsIHR4MSwgdHkxXSA9IF91dGlsLlV0aWwubm9ybWFsaXplUmVjdChbLi4uX3V0aWwuVXRpbC5hcHBseVRyYW5zZm9ybShbeDAsIHkwXSwgbWF0cml4KSwgLi4uX3V0aWwuVXRpbC5hcHBseVRyYW5zZm9ybShbeDEsIHkxXSwgbWF0cml4KV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3hzY2FsZSwgeXNjYWxlXSA9IF91dGlsLlV0aWwuc2luZ3VsYXJWYWx1ZURlY29tcG9zZTJkU2NhbGUobWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHR4c3RlcCA9IHhzdGVwICogeHNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHlzdGVwID0geXN0ZXAgKiB5c2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0aWxpbmcgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOnBhdHRlcm4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpbGluZy5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaWQiLCB0aWxpbmdJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aWxpbmcuc2V0QXR0cmlidXRlTlMobnVsbCwgInBhdHRlcm5Vbml0cyIsICJ1c2VyU3BhY2VPblVzZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGlsaW5nLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ3aWR0aCIsIHR4c3RlcCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aWxpbmcuc2V0QXR0cmlidXRlTlMobnVsbCwgImhlaWdodCIsIHR5c3RlcCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aWxpbmcuc2V0QXR0cmlidXRlTlMobnVsbCwgIngiLCBgJHt0eDB9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aWxpbmcuc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCBgJHt0eTB9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdmcgPSB0aGlzLnN2ZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zZm9ybU1hdHJpeCA9IHRoaXMudHJhbnNmb3JtTWF0cml4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbENvbG9yID0gdGhpcy5jdXJyZW50LmZpbGxDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0cm9rZUNvbG9yID0gdGhpcy5jdXJyZW50LnN0cm9rZUNvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmJveCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUodHgxIC0gdHgwLCB0eTEgLSB0eTApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdmcgPSBiYm94OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm1NYXRyaXggPSBtYXRyaXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFpbnRUeXBlID09PSAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3NzQ29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvciguLi5jb2xvcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmZpbGxDb2xvciA9IGNzc0NvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5zdHJva2VDb2xvciA9IGNzc0NvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leGVjdXRlT3BUcmVlKHRoaXMuY29udmVydE9wTGlzdChvcGVyYXRvckxpc3QpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3ZnID0gc3ZnOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm1NYXRyaXggPSB0cmFuc2Zvcm1NYXRyaXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuZmlsbENvbG9yID0gZmlsbENvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnN0cm9rZUNvbG9yID0gc3Ryb2tlQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aWxpbmcuYXBwZW5kKGJib3guY2hpbGROb2Rlc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlZnMuYXBwZW5kKHRpbGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYHVybCgjJHt0aWxpbmdJZH0pYDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfbWFrZVNoYWRpbmdQYXR0ZXJuKGFyZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgYXJncyA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmdzID0gdGhpcy5vYmpzLmdldChhcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoYXJnc1swXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlJhZGlhbEF4aWFsIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2hhZGluZ0lkID0gYHNoYWRpbmcke3NoYWRpbmdDb3VudCsrfWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yU3RvcHMgPSBhcmdzWzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZ3JhZGllbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoYXJnc1sxXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiYXhpYWwiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBvaW50MCA9IGFyZ3NbNF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcG9pbnQxID0gYXJnc1s1XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6bGluZWFyR3JhZGllbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaWQiLCBzaGFkaW5nSWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJncmFkaWVudFVuaXRzIiwgInVzZXJTcGFjZU9uVXNlIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgIngxIiwgcG9pbnQwWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAieTEiLCBwb2ludDBbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ4MiIsIHBvaW50MVswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgInkyIiwgcG9pbnQxWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgInJhZGlhbCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9jYWxQb2ludCA9IGFyZ3NbNF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2lyY2xlUG9pbnQgPSBhcmdzWzVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvY2FsUmFkaXVzID0gYXJnc1s2XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaXJjbGVSYWRpdXMgPSBhcmdzWzddOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50ID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpyYWRpYWxHcmFkaWVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJpZCIsIHNoYWRpbmdJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImdyYWRpZW50VW5pdHMiLCAidXNlclNwYWNlT25Vc2UiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiY3giLCBjaXJjbGVQb2ludFswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImN5IiwgY2lyY2xlUG9pbnRbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJyIiwgY2lyY2xlUmFkaXVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZngiLCBmb2NhbFBvaW50WzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZnkiLCBmb2NhbFBvaW50WzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZnIiLCBmb2NhbFJhZGl1cyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5rbm93biBSYWRpYWxBeGlhbCB0eXBlOiAke2FyZ3NbMV19YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBjb2xvclN0b3Agb2YgY29sb3JTdG9wcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RvcCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6c3RvcCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAib2Zmc2V0IiwgY29sb3JTdG9wWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3Auc2V0QXR0cmlidXRlTlMobnVsbCwgInN0b3AtY29sb3IiLCBjb2xvclN0b3BbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuYXBwZW5kKHN0b3ApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVmcy5hcHBlbmQoZ3JhZGllbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYHVybCgjJHtzaGFkaW5nSWR9KWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTWVzaCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5pbXBsZW1lbnRlZCBwYXR0ZXJuIE1lc2giKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiRHVtbXkiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gImhvdHBpbmsiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5rbm93biBJUiB0eXBlOiAke2FyZ3NbMF19YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0RGFzaChkYXNoQXJyYXksIGRhc2hQaGFzZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmRhc2hBcnJheSA9IGRhc2hBcnJheTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5kYXNoUGhhc2UgPSBkYXNoUGhhc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0UGF0aChvcHMsIGFyZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLmN1cnJlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgeCA9IGN1cnJlbnQueCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5ID0gY3VycmVudC55OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGQgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBqID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgb3Agb2Ygb3BzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChvcCB8IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMucmVjdGFuZ2xlOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHh3ID0geCArIHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeWggPSB5ICsgaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZC5wdXNoKCJNIiwgcGYoeCksIHBmKHkpLCAiTCIsIHBmKHh3KSwgcGYoeSksICJMIiwgcGYoeHcpLCBwZih5aCksICJMIiwgcGYoeCksIHBmKHloKSwgIloiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tb3ZlVG86CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ID0gYXJnc1tqKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGQucHVzaCgiTSIsIHBmKHgpLCBwZih5KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMubGluZVRvOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkLnB1c2goIkwiLCBwZih4KSwgcGYoeSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmN1cnZlVG86CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ID0gYXJnc1tqICsgNF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5ID0gYXJnc1tqICsgNV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkLnB1c2goIkMiLCBwZihhcmdzW2pdKSwgcGYoYXJnc1tqICsgMV0pLCBwZihhcmdzW2ogKyAyXSksIHBmKGFyZ3NbaiArIDNdKSwgcGYoeCksIHBmKHkpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGogKz0gNjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jdXJ2ZVRvMjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGQucHVzaCgiQyIsIHBmKHgpLCBwZih5KSwgcGYoYXJnc1tqXSksIHBmKGFyZ3NbaiArIDFdKSwgcGYoYXJnc1tqICsgMl0pLCBwZihhcmdzW2ogKyAzXSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaiArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaiArIDNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaiArPSA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmN1cnZlVG8zOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaiArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaiArIDNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZC5wdXNoKCJDIiwgcGYoYXJnc1tqXSksIHBmKGFyZ3NbaiArIDFdKSwgcGYoeCksIHBmKHkpLCBwZih4KSwgcGYoeSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaiArPSA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmNsb3NlUGF0aDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGQucHVzaCgiWiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZCA9IGQuam9pbigiICIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQucGF0aCAmJiBvcHMubGVuZ3RoID4gMCAmJiBvcHNbMF0gIT09IF91dGlsLk9QUy5yZWN0YW5nbGUgJiYgb3BzWzBdICE9PSBfdXRpbC5PUFMubW92ZVRvKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZCA9IGN1cnJlbnQucGF0aC5nZXRBdHRyaWJ1dGVOUyhudWxsLCAiZCIpICsgZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5wYXRoID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpwYXRoIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZW5zdXJlVHJhbnNmb3JtR3JvdXAoKS5hcHBlbmQoY3VycmVudC5wYXRoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQucGF0aC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZCIsIGQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5wYXRoLnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgIm5vbmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuZWxlbWVudCA9IGN1cnJlbnQucGF0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuc2V0Q3VycmVudFBvaW50KHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGVuZFBhdGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5wYXRoID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5wZW5kaW5nQ2xpcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghY3VycmVudC5lbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nQ2xpcCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xpcElkID0gYGNsaXBwYXRoJHtjbGlwQ291bnQrK31gOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xpcFBhdGggPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOmNsaXBQYXRoIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwUGF0aC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaWQiLCBjbGlwSWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcFBhdGguc2V0QXR0cmlidXRlTlMobnVsbCwgInRyYW5zZm9ybSIsIHBtKHRoaXMudHJhbnNmb3JtTWF0cml4KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjbGlwRWxlbWVudCA9IGN1cnJlbnQuZWxlbWVudC5jbG9uZU5vZGUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5wZW5kaW5nQ2xpcCA9PT0gImV2ZW5vZGQiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcEVsZW1lbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImNsaXAtcnVsZSIsICJldmVub2RkIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsaXBFbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJjbGlwLXJ1bGUiLCAibm9uemVybyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nQ2xpcCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwUGF0aC5hcHBlbmQoY2xpcEVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kZWZzLmFwcGVuZChjbGlwUGF0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudC5hY3RpdmVDbGlwVXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5jbGlwR3JvdXAgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcHJldiBvZiB0aGlzLmV4dHJhU3RhY2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldi5jbGlwR3JvdXAgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwUGF0aC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiY2xpcC1wYXRoIiwgY3VycmVudC5hY3RpdmVDbGlwVXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuYWN0aXZlQ2xpcFVybCA9IGB1cmwoIyR7Y2xpcElkfSlgOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50Z3JwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjbGlwKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0NsaXAgPSB0eXBlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNsb3NlUGF0aCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLmN1cnJlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudC5wYXRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZCA9IGAke2N1cnJlbnQucGF0aC5nZXRBdHRyaWJ1dGVOUyhudWxsLCAiZCIpfVpgOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQucGF0aC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZCIsIGQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldExlYWRpbmcobGVhZGluZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmxlYWRpbmcgPSAtbGVhZGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzZXRUZXh0UmlzZSh0ZXh0UmlzZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnRleHRSaXNlID0gdGV4dFJpc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0VGV4dFJlbmRlcmluZ01vZGUodGV4dFJlbmRlcmluZ01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC50ZXh0UmVuZGVyaW5nTW9kZSA9IHRleHRSZW5kZXJpbmdNb2RlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldEhTY2FsZShzY2FsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnRleHRIU2NhbGUgPSBzY2FsZSAvIDEwMDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzZXRSZW5kZXJpbmdJbnRlbnQoaW50ZW50KSB7fQogICAgICAgICAgICAgICAgICAgICAgICBzZXRGbGF0bmVzcyhmbGF0bmVzcykge30KICAgICAgICAgICAgICAgICAgICAgICAgc2V0R1N0YXRlKHN0YXRlcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBba2V5LCB2YWx1ZV0gb2Ygc3RhdGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTFciOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRMaW5lV2lkdGgodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkxDIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGluZUNhcCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTEoiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRMaW5lSm9pbih2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTUwiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRNaXRlckxpbWl0KHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJEIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RGFzaCh2YWx1ZVswXSwgdmFsdWVbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlJJIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0UmVuZGVyaW5nSW50ZW50KHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJGTCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldEZsYXRuZXNzKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJGb250IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0Rm9udCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiQ0EiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRTdHJva2VBbHBoYSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiY2EiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGaWxsQWxwaGEodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYFVuaW1wbGVtZW50ZWQgZ3JhcGhpYyBzdGF0ZSBvcGVyYXRvciAke2tleX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmaWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LmVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmVsZW1lbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImZpbGwiLCBjdXJyZW50LmZpbGxDb2xvcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5lbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsLW9wYWNpdHkiLCBjdXJyZW50LmZpbGxBbHBoYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmRQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LmVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRTdHJva2VBdHRyaWJ1dGVzKGN1cnJlbnQuZWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5lbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgIm5vbmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfc2V0U3Ryb2tlQXR0cmlidXRlcyhlbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgbGluZVdpZHRoU2NhbGUgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhc2hBcnJheSA9IGN1cnJlbnQuZGFzaEFycmF5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxpbmVXaWR0aFNjYWxlICE9PSAxICYmIGRhc2hBcnJheS5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGFzaEFycmF5ID0gZGFzaEFycmF5Lm1hcChmdW5jdGlvbiAodmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGxpbmVXaWR0aFNjYWxlICogdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJzdHJva2UiLCBjdXJyZW50LnN0cm9rZUNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgInN0cm9rZS1vcGFjaXR5IiwgY3VycmVudC5zdHJva2VBbHBoYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJzdHJva2UtbWl0ZXJsaW1pdCIsIHBmKGN1cnJlbnQubWl0ZXJMaW1pdCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAic3Ryb2tlLWxpbmVjYXAiLCBjdXJyZW50LmxpbmVDYXApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAic3Ryb2tlLWxpbmVqb2luIiwgY3VycmVudC5saW5lSm9pbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJzdHJva2Utd2lkdGgiLCBwZihsaW5lV2lkdGhTY2FsZSAqIGN1cnJlbnQubGluZVdpZHRoKSArICJweCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAic3Ryb2tlLWRhc2hhcnJheSIsIGRhc2hBcnJheS5tYXAocGYpLmpvaW4oIiAiKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJzdHJva2UtZGFzaG9mZnNldCIsIHBmKGxpbmVXaWR0aFNjYWxlICogY3VycmVudC5kYXNoUGhhc2UpICsgInB4Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZW9GaWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGN1cnJlbnQkZWxlbWVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRjdXJyZW50JGVsZW1lbnQgPSB0aGlzLmN1cnJlbnQuZWxlbWVudCkgPT09IG51bGwgfHwgX3RoaXMkY3VycmVudCRlbGVtZW50ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRjdXJyZW50JGVsZW1lbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImZpbGwtcnVsZSIsICJldmVub2RkIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGwoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGVvRmlsbFN0cm9rZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRjdXJyZW50JGVsZW1lbnQyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGN1cnJlbnQkZWxlbWVudDIgPSB0aGlzLmN1cnJlbnQuZWxlbWVudCkgPT09IG51bGwgfHwgX3RoaXMkY3VycmVudCRlbGVtZW50MiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkY3VycmVudCRlbGVtZW50Mi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZmlsbC1ydWxlIiwgImV2ZW5vZGQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbFN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNsb3NlU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbG9zZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3Ryb2tlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY2xvc2VGaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbG9zZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbFN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNsb3NlRU9GaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbG9zZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW9GaWxsU3Ryb2tlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRTb2xpZENvbG9ySW1hZ2VNYXNrKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6cmVjdCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAieCIsICIwIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgIjAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIndpZHRoIiwgIjFweCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaGVpZ2h0IiwgIjFweCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZmlsbCIsIHRoaXMuY3VycmVudC5maWxsQ29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZW5zdXJlVHJhbnNmb3JtR3JvdXAoKS5hcHBlbmQocmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRJbWFnZVhPYmplY3Qob2JqSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltZ0RhdGEgPSB0aGlzLmdldE9iamVjdChvYmpJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYERlcGVuZGVudCBpbWFnZSB3aXRoIG9iamVjdCBJRCAke29iaklkfSBpcyBub3QgcmVhZHkgeWV0YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludElubGluZUltYWdlWE9iamVjdChpbWdEYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwYWludElubGluZUltYWdlWE9iamVjdChpbWdEYXRhLCBtYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGltZ0RhdGEud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBpbWdEYXRhLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltZ1NyYyA9IGNvbnZlcnRJbWdEYXRhVG9QbmcoaW1nRGF0YSwgdGhpcy5mb3JjZURhdGFTY2hlbWEsICEhbWFzayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjbGlwcmVjdCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6cmVjdCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIngiLCAiMCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCAiMCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIndpZHRoIiwgcGYod2lkdGgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsaXByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJoZWlnaHQiLCBwZihoZWlnaHQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5lbGVtZW50ID0gY2xpcHJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoIm5vbnplcm8iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltZ0VsID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzppbWFnZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nRWwuc2V0QXR0cmlidXRlTlMoWExJTktfTlMsICJ4bGluazpocmVmIiwgaW1nU3JjKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZ0VsLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ4IiwgIjAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZ0VsLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgcGYoLWhlaWdodCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nRWwuc2V0QXR0cmlidXRlTlMobnVsbCwgIndpZHRoIiwgcGYod2lkdGgpICsgInB4Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWdFbC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaGVpZ2h0IiwgcGYoaGVpZ2h0KSArICJweCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nRWwuc2V0QXR0cmlidXRlTlMobnVsbCwgInRyYW5zZm9ybSIsIGBzY2FsZSgke3BmKDEgLyB3aWR0aCl9ICR7cGYoLTEgLyBoZWlnaHQpfSlgKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFzay5hcHBlbmQoaW1nRWwpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbnN1cmVUcmFuc2Zvcm1Hcm91cCgpLmFwcGVuZChpbWdFbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRJbWFnZU1hc2tYT2JqZWN0KGltZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW1nRGF0YSA9IHRoaXMuZ2V0T2JqZWN0KGltZy5kYXRhLCBpbWcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGltZ0RhdGEuYml0bWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJwYWludEltYWdlTWFza1hPYmplY3Q6IEltYWdlQml0bWFwIHN1cHBvcnQgaXMgbm90IGltcGxlbWVudGVkLCAiICsgImVuc3VyZSB0aGF0IHRoZSBgaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWRgIEFQSSBwYXJhbWV0ZXIgaXMgZGlzYWJsZWQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gaW1nRGF0YS53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGltZ0RhdGEuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbENvbG9yID0gY3VycmVudC5maWxsQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Lm1hc2tJZCA9IGBtYXNrJHttYXNrQ291bnQrK31gOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFzayA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6bWFzayIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFzay5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaWQiLCBjdXJyZW50Lm1hc2tJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWN0ID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpyZWN0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ4IiwgIjAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCAiMCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAid2lkdGgiLCBwZih3aWR0aCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaGVpZ2h0IiwgcGYoaGVpZ2h0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgZmlsbENvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIm1hc2siLCBgdXJsKCMke2N1cnJlbnQubWFza0lkfSlgKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVmcy5hcHBlbmQobWFzayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbnN1cmVUcmFuc2Zvcm1Hcm91cCgpLmFwcGVuZChyZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFpbnRJbmxpbmVJbWFnZVhPYmplY3QoaW1nRGF0YSwgbWFzayk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRGb3JtWE9iamVjdEJlZ2luKG1hdHJpeCwgYmJveCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkobWF0cml4KSAmJiBtYXRyaXgubGVuZ3RoID09PSA2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm0obWF0cml4WzBdLCBtYXRyaXhbMV0sIG1hdHJpeFsyXSwgbWF0cml4WzNdLCBtYXRyaXhbNF0sIG1hdHJpeFs1XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmJveCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gYmJveFsyXSAtIGJib3hbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gYmJveFszXSAtIGJib3hbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xpcHJlY3QgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOnJlY3QiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAieCIsIGJib3hbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsaXByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgYmJveFsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIndpZHRoIiwgcGYod2lkdGgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaGVpZ2h0IiwgcGYoaGVpZ2h0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmVsZW1lbnQgPSBjbGlwcmVjdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoIm5vbnplcm8iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwYWludEZvcm1YT2JqZWN0RW5kKCkge30KICAgICAgICAgICAgICAgICAgICAgICAgX2luaXRpYWxpemUodmlld3BvcnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUodmlld3BvcnQud2lkdGgsIHZpZXdwb3J0LmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZpbml0aW9ucyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6ZGVmcyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLmFwcGVuZChkZWZpbml0aW9ucyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlZnMgPSBkZWZpbml0aW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvb3RHcm91cCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6ZyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm9vdEdyb3VwLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ0cmFuc2Zvcm0iLCBwbSh2aWV3cG9ydC50cmFuc2Zvcm0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5hcHBlbmQocm9vdEdyb3VwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3ZnID0gcm9vdEdyb3VwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN2ZzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfZW5zdXJlQ2xpcEdyb3VwKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmN1cnJlbnQuY2xpcEdyb3VwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xpcEdyb3VwID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpnIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcEdyb3VwLnNldEF0dHJpYnV0ZU5TKG51bGwsICJjbGlwLXBhdGgiLCB0aGlzLmN1cnJlbnQuYWN0aXZlQ2xpcFVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdmcuYXBwZW5kKGNsaXBHcm91cCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmNsaXBHcm91cCA9IGNsaXBHcm91cDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmN1cnJlbnQuY2xpcEdyb3VwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9lbnN1cmVUcmFuc2Zvcm1Hcm91cCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy50Z3JwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50Z3JwID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpnIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50Z3JwLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ0cmFuc2Zvcm0iLCBwbSh0aGlzLnRyYW5zZm9ybU1hdHJpeCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmN1cnJlbnQuYWN0aXZlQ2xpcFVybCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbnN1cmVDbGlwR3JvdXAoKS5hcHBlbmQodGhpcy50Z3JwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN2Zy5hcHBlbmQodGhpcy50Z3JwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50Z3JwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KQogICAgICAgICAgICAvKioqKioqLyAJXSk7CiAgICAgICAgLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KICAgICAgICAvKioqKioqLyAJLy8gVGhlIG1vZHVsZSBjYWNoZQogICAgICAgIC8qKioqKiovIAl2YXIgX193ZWJwYWNrX21vZHVsZV9jYWNoZV9fID0ge307CiAgICAgICAgLyoqKioqKi8KICAgICAgICAvKioqKioqLyAJLy8gVGhlIHJlcXVpcmUgZnVuY3Rpb24KICAgICAgICAvKioqKioqLyAJZnVuY3Rpb24gX193X3BkZmpzX3JlcXVpcmVfXyhtb2R1bGVJZCkgewogICAgICAgICAgICAvKioqKioqLyAJCS8vIENoZWNrIGlmIG1vZHVsZSBpcyBpbiBjYWNoZQogICAgICAgICAgICAvKioqKioqLyAJCXZhciBjYWNoZWRNb2R1bGUgPSBfX3dlYnBhY2tfbW9kdWxlX2NhY2hlX19bbW9kdWxlSWRdOwogICAgICAgICAgICAvKioqKioqLyAJCWlmIChjYWNoZWRNb2R1bGUgIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgLyoqKioqKi8gCQkJcmV0dXJuIGNhY2hlZE1vZHVsZS5leHBvcnRzOwogICAgICAgICAgICAgICAgLyoqKioqKi8gCQl9CiAgICAgICAgICAgIC8qKioqKiovIAkJLy8gQ3JlYXRlIGEgbmV3IG1vZHVsZSAoYW5kIHB1dCBpdCBpbnRvIHRoZSBjYWNoZSkKICAgICAgICAgICAgLyoqKioqKi8gCQl2YXIgbW9kdWxlID0gX193ZWJwYWNrX21vZHVsZV9jYWNoZV9fW21vZHVsZUlkXSA9IHsKICAgICAgICAgICAgICAgIC8qKioqKiovIAkJCS8vIG5vIG1vZHVsZS5pZCBuZWVkZWQKICAgICAgICAgICAgICAgIC8qKioqKiovIAkJCS8vIG5vIG1vZHVsZS5sb2FkZWQgbmVlZGVkCiAgICAgICAgICAgICAgICAvKioqKioqLyAJCQlleHBvcnRzOiB7fQogICAgICAgICAgICAgICAgLyoqKioqKi8gCQl9OwogICAgICAgICAgICAvKioqKioqLwogICAgICAgICAgICAvKioqKioqLyAJCS8vIEV4ZWN1dGUgdGhlIG1vZHVsZSBmdW5jdGlvbgogICAgICAgICAgICAvKioqKioqLyAJCV9fd2VicGFja19tb2R1bGVzX19bbW9kdWxlSWRdKG1vZHVsZSwgbW9kdWxlLmV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pOwogICAgICAgICAgICAvKioqKioqLwogICAgICAgICAgICAvKioqKioqLyAJCS8vIFJldHVybiB0aGUgZXhwb3J0cyBvZiB0aGUgbW9kdWxlCiAgICAgICAgICAgIC8qKioqKiovIAkJcmV0dXJuIG1vZHVsZS5leHBvcnRzOwogICAgICAgICAgICAvKioqKioqLyAJfQogICAgICAgIC8qKioqKiovCiAgICAgICAgLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KICAgICAgICB2YXIgX193ZWJwYWNrX2V4cG9ydHNfXyA9IHt9OwovLyBUaGlzIGVudHJ5IG5lZWQgdG8gYmUgd3JhcHBlZCBpbiBhbiBJSUZFIGJlY2F1c2UgaXQgbmVlZCB0byBiZSBpbiBzdHJpY3QgbW9kZS4KICAgICAgICAoKCkgPT4gewogICAgICAgICAgICAidXNlIHN0cmljdCI7CiAgICAgICAgICAgIHZhciBleHBvcnRzID0gX193ZWJwYWNrX2V4cG9ydHNfXzsKCgogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIkFib3J0RXhjZXB0aW9uIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuQWJvcnRFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJBbm5vdGF0aW9uRWRpdG9yTGF5ZXIiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfYW5ub3RhdGlvbl9lZGl0b3JfbGF5ZXIuQW5ub3RhdGlvbkVkaXRvckxheWVyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIkFubm90YXRpb25FZGl0b3JUeXBlIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJBbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3Rvb2xzLkFubm90YXRpb25FZGl0b3JVSU1hbmFnZXI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJBbm5vdGF0aW9uTGF5ZXIiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfYW5ub3RhdGlvbl9sYXllci5Bbm5vdGF0aW9uTGF5ZXI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJBbm5vdGF0aW9uTW9kZSIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLkFubm90YXRpb25Nb2RlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiQ01hcENvbXByZXNzaW9uVHlwZSIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLkNNYXBDb21wcmVzc2lvblR5cGU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJGZWF0dXJlVGVzdCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLkZlYXR1cmVUZXN0OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiR2xvYmFsV29ya2VyT3B0aW9ucyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF93b3JrZXJfb3B0aW9ucy5HbG9iYWxXb3JrZXJPcHRpb25zOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiSW52YWxpZFBERkV4Y2VwdGlvbiIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLkludmFsaWRQREZFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJNaXNzaW5nUERGRXhjZXB0aW9uIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuTWlzc2luZ1BERkV4Y2VwdGlvbjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIk9QUyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLk9QUzsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIlBERkRhdGFSYW5nZVRyYW5zcG9ydCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9hcGkuUERGRGF0YVJhbmdlVHJhbnNwb3J0OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiUERGRGF0ZVN0cmluZyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9kaXNwbGF5X3V0aWxzLlBERkRhdGVTdHJpbmc7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJQREZXb3JrZXIiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfYXBpLlBERldvcmtlcjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIlBhc3N3b3JkUmVzcG9uc2VzIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuUGFzc3dvcmRSZXNwb25zZXM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJQZXJtaXNzaW9uRmxhZyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLlBlcm1pc3Npb25GbGFnOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiUGl4ZWxzUGVySW5jaCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9kaXNwbGF5X3V0aWxzLlBpeGVsc1BlckluY2g7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJSZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb24iLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5SZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJTVkdHcmFwaGljcyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9zdmcuU1ZHR3JhcGhpY3M7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJVbmV4cGVjdGVkUmVzcG9uc2VFeGNlcHRpb24iLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfdXRpbC5VbmV4cGVjdGVkUmVzcG9uc2VFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJVdGlsIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuVXRpbDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIlZlcmJvc2l0eUxldmVsIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuVmVyYm9zaXR5TGV2ZWw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJYZmFMYXllciIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF94ZmFfbGF5ZXIuWGZhTGF5ZXI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJidWlsZCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9hcGkuYnVpbGQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJjcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiY3JlYXRlVmFsaWRBYnNvbHV0ZVVybCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLmNyZWF0ZVZhbGlkQWJzb2x1dGVVcmw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJnZXREb2N1bWVudCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9hcGkuZ2V0RG9jdW1lbnQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJnZXRGaWxlbmFtZUZyb21VcmwiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5nZXRGaWxlbmFtZUZyb21Vcmw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJnZXRQZGZGaWxlbmFtZUZyb21VcmwiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5nZXRQZGZGaWxlbmFtZUZyb21Vcmw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJnZXRYZmFQYWdlVmlld3BvcnQiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5nZXRYZmFQYWdlVmlld3BvcnQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJpc0RhdGFTY2hlbWUiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5pc0RhdGFTY2hlbWU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJpc1BkZkZpbGUiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5pc1BkZkZpbGU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJsb2FkU2NyaXB0IiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2Rpc3BsYXlfdXRpbHMubG9hZFNjcmlwdDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInJlbmRlclRleHRMYXllciIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF90ZXh0X2xheWVyLnJlbmRlclRleHRMYXllcjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInNldExheWVyRGltZW5zaW9ucyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9kaXNwbGF5X3V0aWxzLnNldExheWVyRGltZW5zaW9uczsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInNoYWRvdyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLnNoYWRvdzsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInVwZGF0ZVRleHRMYXllciIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF90ZXh0X2xheWVyLnVwZGF0ZVRleHRMYXllcjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInZlcnNpb24iLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfYXBpLnZlcnNpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgdmFyIF9hcGkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzOCk7CiAgICAgICAgICAgIHZhciBfZGlzcGxheV91dGlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQyKTsKICAgICAgICAgICAgdmFyIF90ZXh0X2xheWVyID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjEpOwogICAgICAgICAgICB2YXIgX2Fubm90YXRpb25fZWRpdG9yX2xheWVyID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjIpOwogICAgICAgICAgICB2YXIgX3Rvb2xzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDEpOwogICAgICAgICAgICB2YXIgX2Fubm90YXRpb25fbGF5ZXIgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE2Nyk7CiAgICAgICAgICAgIHZhciBfd29ya2VyX29wdGlvbnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0OSk7CiAgICAgICAgICAgIHZhciBfc3ZnID0gX193X3BkZmpzX3JlcXVpcmVfXygxNzApOwogICAgICAgICAgICB2YXIgX3hmYV9sYXllciA9IF9fd19wZGZqc19yZXF1aXJlX18oMTY5KTsKICAgICAgICAgICAgY29uc3QgcGRmanNWZXJzaW9uID0gJzMuNS4xMjInOwogICAgICAgICAgICBjb25zdCBwZGZqc0J1aWxkID0gJzYyMjQ2NWRjMic7CiAgICAgICAgfSkoKTsKCiAgICAgICAgLyoqKioqKi8gCXJldHVybiBfX3dlYnBhY2tfZXhwb3J0c19fOwogICAgICAgIC8qKioqKiovIH0pKCkKICAgICAgICA7Cn0pOwovLyMgc291cmNlTWFwcGluZ1VSTD1wZGYuanMubWFw",h="LyoqCiAqIEBsaWNzdGFydCBUaGUgZm9sbG93aW5nIGlzIHRoZSBlbnRpcmUgbGljZW5zZSBub3RpY2UgZm9yIHRoZQogKiBKYXZhU2NyaXB0IGNvZGUgaW4gdGhpcyBwYWdlCiAqCiAqIENvcHlyaWdodCAyMDIzIE1vemlsbGEgRm91bmRhdGlvbgogKgogKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB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FuZGxlciwgdGFzaykuY2F0Y2gocmVhc29uID0+IHt9KS50aGVuKCgpID0+IGZpbmlzaFdvcmtlclRhc2sodGFzaykpLCBwZGZNYW5hZ2VyLmxvYWRYZmFJbWFnZXMoKV0pOwogICAgICB9CiAgICAgIGNvbnN0IFtudW1QYWdlcywgZmluZ2VycHJpbnRzXSA9IGF3YWl0IFByb21pc2UuYWxsKFtwZGZNYW5hZ2VyLmVuc3VyZURvYygibnVtUGFnZXMiKSwgcGRmTWFuYWdlci5lbnN1cmVEb2MoImZpbmdlcnByaW50cyIpXSk7CiAgICAgIGNvbnN0IGh0bWxGb3JYZmEgPSBpc1B1cmVYZmEgPyBhd2FpdCBwZGZNYW5hZ2VyLmVuc3VyZURvYygiaHRtbEZvclhmYSIpIDogbnVsbDsKICAgICAgcmV0dXJuIHsKICAgICAgICBudW1QYWdlcywKICAgICAgICBmaW5nZXJwcmludHMsCiAgICAgICAgaHRtbEZvclhmYQogICAgICB9OwogICAgfQogICAgZnVuY3Rpb24gZ2V0UGRmTWFuYWdlcihfcmVmKSB7CiAgICAgIGxldCB7CiAgICAgICAgZGF0YSwKICAgICAgICBwYXNzd29yZCwKICAgICAgICBkaXNhYmxlQXV0b0ZldGNoLAogICAgICAgIHJhbmdlQ2h1bmtTaXplLAogICAgICAgIGxlbmd0aCwKICAgICAgICBkb2NCYXNlVXJsLAogICAgICAgIGVuYWJsZVhmYSwKICAgICAgICBldmFsdWF0b3JPcHRpb25zCiAgICAgIH0gPSBfcmVmOwogICAgICBjb25zdCBwZGZNYW5hZ2VyQXJncyA9IHsKICAgICAgICBzb3VyY2U6IG51bGwsCiAgICAgICAgZGlzYWJsZUF1dG9GZXRjaCwKICAgICAgICBkb2NCYXNlVXJsLAogICAgICAgIGRvY0lkLAogICAgICAgIGVuYWJsZVhmYSwKICAgICAgICBldmFsdWF0b3JPcHRpb25zLAogICAgICAgIGhhbmRsZXIsCiAgICAgICAgbGVuZ3RoLAogICAgICAgIHBhc3N3b3JkLAog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W5ndGggJiYgcGRmRmlsZS5sZW5ndGggIT09IGxlbmd0aCkgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJyZXBvcnRlZCBIVFRQIGxlbmd0aCBpcyBkaWZmZXJlbnQgZnJvbSBhY3R1YWwiKTsKICAgICAgICB9CiAgICAgICAgdHJ5IHsKICAgICAgICAgIHBkZk1hbmFnZXJBcmdzLnNvdXJjZSA9IHBkZkZpbGU7CiAgICAgICAgICBuZXdQZGZNYW5hZ2VyID0gbmV3IF9wZGZfbWFuYWdlci5Mb2NhbFBkZk1hbmFnZXIocGRmTWFuYWdlckFyZ3MpOwogICAgICAgICAgcGRmTWFuYWdlckNhcGFiaWxpdHkucmVzb2x2ZShuZXdQZGZNYW5hZ2VyKTsKICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgcGRmTWFuYWdlckNhcGFiaWxpdHkucmVqZWN0KGV4KTsKICAgICAgICB9CiAgICAgICAgY2FjaGVkQ2h1bmtzID0gW107CiAgICAgIH07CiAgICAgIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlLCByZWplY3QpIHsKICAgICAgICBjb25zdCByZWFkQ2h1bmsgPSBmdW5jdGlvbiAoX3JlZjIpIHsKICAgICAgICAgIGxldCB7CiAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICBkb25lCiAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICB0cnkgewogICAgICAgICAgICBlbnN1cmVOb3RUZXJtaW5hdGVkKCk7CiAgICAgICAgICAgIGlmIChkb25lKSB7CiAgICAgICAgICAgICAgaWYgKCFuZXdQZGZNYW5hZ2VyKSB7CiAgICAgICAgICAgICAgICBmbHVzaENodW5rcygpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjYW5jZWxYSFJzID0gbnVsbDsKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbG9hZGVkICs9IHZhbHVlLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgIGlmICghZnVsbFJlcXVlc3QuaXNTdHJlYW1pbmdTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICBoYW5kbGVyLnNlbmQoIkRvY1Byb2dyZXNzIiwgewogICAgICAgICAgICAgICAgbG9hZGVkLAogICAgICAgICAgICAgICAgdG90YWw6IE1hdGgubWF4KGxvYWRlZCwgZnVsbFJlcXVlc3QuY29udGVudExlbmd0aCB8fCAwKQogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChuZXdQZGZNYW5hZ2VyKSB7CiAgICAgICAgICAgICAgbmV3UGRmTWFuYWdlci5zZW5kUHJvZ3Jlc3NpdmVEYXRhKHZhbHVlKTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjYWNoZWRDaHVua3MucHVzaCh2YWx1ZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZnVsbFJlcXVlc3QucmVhZCgpLnRoZW4ocmVhZENodW5rLCByZWplY3QpOwogICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICByZWplY3QoZSk7CiAgICAgICAgICB9CiAgICAgICAgfTsKICAgICAgICBmdWxsUmVxdWVzdC5yZWFkKCkudGhlbihyZWFkQ2h1bmssIHJlamVjdCk7CiAgICAgIH0pLmNhdGNoKGZ1bmN0aW9uIChlKSB7CiAgICAgICAgcGRmTWFuYWdlckNhcGFiaWxpdHkucmVqZWN0KGUpOwogICAgICAgIGNhbmNlbFhIUnMgPSBudWxsOwogICAgICB9KTsKICAgICAgY2FuY2VsWEhScyA9IGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICBwZGZTdHJlYW0uY2FuY2VsQWxsUmVxdWVzdHMocmVhc29uKTsKICAgICAgfTsKICAgICAgcmV0dXJuIHBkZk1hbmFnZXJDYXBhYmlsaXR5LnByb21pc2U7CiAgICB9CiAgICBmdW5jdGlvbiBzZXR1cERvYyhkYXRhKSB7CiAgICAgIGZ1bmN0aW9uIG9uU3VjY2Vzcyhkb2MpIHsKICAgICAgICBlbnN1cmVOb3RUZXJtaW5hdGVkKCk7CiAgICAgICAgaGFuZGxlci5zZW5kKCJHZXREb2MiLCB7CiAgICAgICAgICBwZGZJbmZvOiBkb2MKICAgICAgICB9KTsKICAgICAgfQogICAgICBmdW5jdGlvbiBvbkZhaWx1cmUoZXgpIHsKICAgICAgICBlbnN1cmVOb3RUZXJtaW5hdGVkKCk7CiAgICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX3V0aWwuUGFzc3dvcmRFeGNlcHRpb24pIHsKICAgICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgV29ya2VyVGFzayhgUGFzc3dvcmRFeGNlcHRpb246IHJlc3BvbnNlICR7ZXguY29kZX1gKTsKICAgICAgICAgIHN0YXJ0V29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgIGhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJQYXNzd29yZFJlcXVlc3QiLCBleCkudGhlbihmdW5jdGlvbiAoX3JlZjMpIHsKICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICBwYXNzd29yZAogICAgICAgICAgICB9ID0gX3JlZjM7CiAgICAgICAgICAgIGZpbmlzaFdvcmtlclRhc2sodGFzayk7CiAgICAgICAgICAgIHBkZk1hbmFnZXIudXBkYXRlUGFzc3dvcmQocGFzc3dvcmQpOwogICAgICAgICAgICBwZGZNYW5hZ2VyUmVhZHkoKTsKICAgICAgICAgIH0pLmNhdGNoKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgZmluaXNoV29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgICAgaGFuZGxlci5zZW5kKCJEb2NFeGNlcHRpb24iLCBleCk7CiAgICAgICAgICB9KTsKICAgICAgICB9IGVsc2UgaWYgKGV4IGluc3RhbmNlb2YgX3V0aWwuSW52YWxpZFBERkV4Y2VwdGlvbiB8fCBleCBpbnN0YW5jZW9mIF91dGlsLk1pc3NpbmdQREZFeGNlcHRpb24gf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GlvbiAoKSB7CiAgICAgICAgICAgICAgZmluaXNoV29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9KSk7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChpc1B1cmVYZmEpIHsKICAgICAgICBwcm9taXNlcy5wdXNoKHBkZk1hbmFnZXIuc2VyaWFsaXplWGZhRGF0YShhbm5vdGF0aW9uU3RvcmFnZSkpOwogICAgICB9IGVsc2UgewogICAgICAgIGZvciAobGV0IHBhZ2VJbmRleCA9IDA7IHBhZ2VJbmRleCA8IG51bVBhZ2VzOyBwYWdlSW5kZXgrKykgewogICAgICAgICAgcHJvbWlzZXMucHVzaChwZGZNYW5hZ2VyLmdldFBhZ2UocGFnZUluZGV4KS50aGVuKGZ1bmN0aW9uIChwYWdlKSB7CiAgICAgICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgV29ya2VyVGFzayhgU2F2ZTogcGFnZSAke3BhZ2VJbmRleH1gKTsKICAgICAgICAgICAgcmV0dXJuIHBhZ2Uuc2F2ZShoYW5kbGVyLCB0YXNrLCBhbm5vdGF0aW9uU3RvcmFnZSkuZmluYWxseShmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgZmluaXNoV29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9KSk7CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiBQcm9taXNlLmFsbChwcm9taXNlcykudGhlbihmdW5jdGlvbiAoX3JlZjgpIHsKICAgICAgICBsZXQgW3N0cmVhbSwgYWNyb0Zvcm0sIGFjcm9Gb3JtUmVmLCB4cmVmLCBzdGFydFhSZWYsIC4uLnJlZnNdID0gX3JlZjg7CiAgICAgICAgbGV0IG5ld1JlZnMgPSBbXTsKICAgICAgICBsZXQgeGZhRGF0YSA9IG51bGw7CiAgICAgICAgaWYgKGlzUHVyZVhmYSkgewogICAgICAgICAgeGZhRGF0YSA9IHJlZnNbMF07CiAgICAgICAgICBpZiAoIXhmYURhdGEpIHsKICAgICAgICAgICAgcmV0dXJuIHN0cmVhbS5ieXRlczsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgbmV3UmVmcyA9IHJlZnMuZmxhdCgyKTsKICAgICAgICAgIGlmIChuZXdSZWZzLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICByZXR1cm4gc3RyZWFtLmJ5dGVzOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjb25zdCBuZWVkQXBwZWFyYW5jZXMgPSBhY3JvRm9ybVJlZiAmJiBhY3JvRm9ybSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QgJiYgbmV3UmVmcy5zb21lKHJlZiA9PiByZWYubmVlZEFwcGVhcmFuY2VzKTsKICAgICAgICBjb25zdCB4ZmEgPSBhY3JvRm9ybSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QgJiYgYWNyb0Zvcm0uZ2V0KCJYRkEiKSB8fCBudWxsOwogICAgICAgIGxldCB4ZmFEYXRhc2V0c1JlZiA9IG51bGw7CiAgICAgICAgbGV0IGhhc1hmYURhdGFzZXRzRW50cnkgPSBmYWxzZTsKICAgICAgICBpZiAoQXJyYXkuaXNBcnJheSh4ZmEpKSB7CiAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSB4ZmEubGVuZ3RoOyBpIDwgaWk7IGkgKz0gMikgewogICAgICAgICAgICBpZiAoeGZhW2ldID09PSAiZGF0YXNldHMiKSB7CiAgICAgICAgICAgICAgeGZhRGF0YXNldHNSZWYgPSB4ZmFbaSArIDFdOwogICAgICAgICAgICAgIGhhc1hmYURhdGFzZXRzRW50cnkgPSB0cnVlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoeGZhRGF0YXNldHNSZWYgPT09IG51bGwpIHsKICAgICAgICAgICAgeGZhRGF0YXNldHNSZWYgPSB4cmVmLmdldE5ld1RlbXBvcmFyeVJlZigpOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoeGZhKSB7CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlVuc3VwcG9ydGVkIFhGQSB0eXBlLiIpOwogICAgICAgIH0KICAgICAgICBsZXQgbmV3WHJlZkluZm8gPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgIGlmICh4cmVmLnRyYWlsZXIpIHsKICAgICAgICAgIGNvbnN0IGluZm9PYmogPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgY29uc3QgeHJlZkluZm8gPSB4cmVmLnRyYWlsZXIuZ2V0KCJJbmZvIikgfHwgbnVsbDsKICAgICAgICAgIGlmICh4cmVmSW5mbyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgICAgICAgeHJlZkluZm8uZm9yRWFjaCgoa2V5LCB2YWx1ZSkgPT4gewogICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICBpbmZvT2JqW2tleV0gPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHZhbHVlKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQogICAgICAgICAgY29uc3QgbGFzdFhSZWZTdHJlYW1Qb3MgPSB4cmVmLmxhc3RYUmVmU3RyZWFtUG9zOwogICAgICAgICAgbmV3WHJlZkluZm8gPSB7CiAgICAgICAgICAgIHJvb3RSZWY6IHhyZWYudHJhaWxlci5nZXRSYXcoIlJvb3QiKSB8fCBudWxsLAogICAgICAgICAgICBlbmNyeXB0UmVmOiB4cmVmLnRyYWlsZXIuZ2V0UmF3KCJFbmNyeXB0IikgfHwgbnVsbCwKICAgICAgICAgICAgbmV3UmVmOiB4cmVmLmdldE5ld1RlbXBvcmFyeVJlZigpLAogICAgICAgICAgICBpbmZvUmVmOiB4cmVmLnRyYWlsZXIuZ2V0UmF3KCJJbmZvIikgfHwgbnVsbCwKICAgICAgICAgICAgaW5mbzogaW5mb09iaiwKICAgICAgICAgICAgZmlsZUlkczogeHJlZi50cmFpbGVyLmdldCgiSUQiKSB8fCBudWxsLAogICAgICAgICAgICBzdGFydFhSZWY6IGxhc3RYUmVmU3RyZWFtUG9zID09PSBudWxsID8gc3RhcnRYUmVmIDogbGFzdFhSZWZTdHJlYW1Qb3MsCiAgICAgICAgICAgIGZpbGVuYW1lCiAgICAgICAgICB9OwogICAgICAgIH0KICAgICAgICB0cnkgewogICAgICAgICAgcmV0dXJuICgwLCBfd3JpdGVyLmluY3JlbWVudGFsVXBkYXRlKSh7CiAgICAgICAgICAgIG9yaWdpbmFsRGF0YTogc3RyZWFtLmJ5dGVzLAogICAgICAgICAgICB4cmVmSW5mbzogbmV3WHJlZkluZm8sCiAgICAgICAgICAgIG5ld1JlZnMsCiAgICAgICAgICAgIHhyZWYsCiAgICAgICAgICAgIGhhc1hmYTogISF4ZmEsCiAgICAgICAgICAgIHhmYURhdGFzZXRzUmVmLAogICAgICAgICAgICBoYXNYZmFEYXRhc2V0c0VudHJ5LAogICAgICAgICAgICBuZWVkQXBwZWFyYW5jZXMsCiAgICAgICAgICAgIGFjcm9Gb3JtUmVmLAogICAgICAgICAgICBhY3JvRm9ybSwKICAgICAgICAgICAgeGZhRGF0YQogICAgICAgICAgfSk7CiAgICAgICAgfSBmaW5hbGx5IHsKICAgICAgICAgIHhyZWYucmVzZXROZXdUZW1wb3JhcnlSZWYoKTsKICAgICAgICB9CiAgICAgIH0pOwogICAgfSk7CiAgICBoYW5kbGVyLm9uKCJHZXRPcGVyYXRvckxpc3QiLCBmdW5jdGlvbiAoZGF0YSwgc2luaykgewogICAgICBjb25zdCBwYWdlSW5kZXggPSBkYXRhLnBhZ2VJbmRleDsKICAgICAgcGRmTWFuYWdlci5nZXRQYWdlKHBhZ2VJbmRleCkudGhlbihmdW5jdGlvbiAocGFnZSkgewogICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgV29ya2VyVGFzayhgR2V0T3BlcmF0b3JMaXN0OiBwYWdlICR7cGFnZUluZGV4fWApOwogICAgICAgIHN0YXJ0V29ya2VyVGFzayh0YXNrKTsKICAgICAgICBjb25zdCBzdGFydCA9IHZlcmJvc2l0eSA+PSBfdXRpbC5WZXJib3NpdHlMZXZlbC5JTkZPUyA/IERhdGUubm93KCkgOiAwOwogICAgICAgIHBhZ2UuZ2V0T3BlcmF0b3JMaXN0KHsKICAgICAgICAgIGhhbmRsZXIsCiAgICAgICAgICBzaW5rLAogICAgICAgICAgdGFzaywKICAgICAgICAgIGludGVudDogZGF0YS5pbnRlbnQsCiAgICAgICAgICBjYWNoZUtleTogZGF0YS5jYWNoZUtleSwKICAgICAgICAgIGFubm90YXRpb25TdG9yYWdlOiBkYXRhLmFubm90YXRpb25TdG9yYWdlCiAgICAgICAgfSkudGhlbihmdW5jdGlvbiAob3BlcmF0b3JMaXN0SW5mbykgewogICAgICAgICAgZmluaXNoV29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgIGlmIChzdGFydCkgewogICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoYHBhZ2U9JHtwYWdlSW5kZXggKyAxfSAtIGdldE9wZXJhdG9yTGlzdDogdGltZT1gICsgYCR7RGF0ZS5ub3coKSAtIHN0YXJ0fW1zLCBsZW49JHtvcGVyYXRvckxpc3RJbmZvLmxlbmd0aH1gKTsKICAgICAgICAgIH0KICAgICAgICAgIHNpbmsuY2xvc2UoKTsKICAgICAgICB9LCBmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICBmaW5pc2hXb3JrZXJUYXNrKHRhc2spOwogICAgICAgICAgaWYgKHRhc2sudGVybWluYXRlZCkgewogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICB9CiAgICAgICAgICBzaW5rLmVycm9yKHJlYXNvbik7CiAgICAgICAgfSk7CiAgICAgIH0pOwogICAgfSk7CiAgICBoYW5kbGVyLm9uKCJHZXRUZXh0Q29udGVudCIsIGZ1bmN0aW9uIChkYXRhLCBzaW5rKSB7CiAgICAgIGNvbnN0IHBhZ2VJbmRleCA9IGRhdGEucGFnZUluZGV4OwogICAgICBwZGZNYW5hZ2VyLmdldFBhZ2UocGFnZUluZGV4KS50aGVuKGZ1bmN0aW9uIChwYWdlKSB7CiAgICAgICAgY29uc3QgdGFzayA9IG5ldyBXb3JrZXJUYXNrKCJHZXRUZXh0Q29udGVudDogcGFnZSAiICsgcGFnZUluZGV4KTsKICAgICAgICBzdGFydFdvcmtlclRhc2sodGFzayk7CiAgICAgICAgY29uc3Qgc3RhcnQgPSB2ZXJib3NpdHkgPj0gX3V0aWwuVmVyYm9zaXR5TGV2ZWwuSU5GT1MgPyBEYXRlLm5vdygpIDogMDsKICAgICAgICBwYWdlLmV4dHJhY3RUZXh0Q29udGVudCh7CiAgICAgICAgICBoYW5kbGVyLAogICAgICAgICAgdGFzaywKICAgICAgICAgIHNpbmssCiAgICAgICAgICBpbmNsdWRlTWFya2VkQ29udGVudDogZGF0YS5pbmNsdWRlTWFya2VkQ29udGVudCwKICAgICAgICAgIGNvbWJpbmVUZXh0SXRlbXM6IGRhdGEuY29tYmluZVRleHRJdGVtcwogICAgICAgIH0pLnRoZW4oZnVuY3Rpb24gKCkgewogICAgICAgICAgZmluaXNoV29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgIGlmIChzdGFydCkgewogICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoYHBhZ2U9JHtwYWdlSW5kZXggKyAxfSAtIGdldFRleHRDb250ZW50OiB0aW1lPWAgKyBgJHtEYXRlLm5vdygpIC0gc3RhcnR9bXNgKTsKICAgICAgICAgIH0KICAgICAgICAgIHNpbmsuY2xvc2UoKTsKICAgICAgICB9LCBmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICBmaW5pc2hXb3JrZXJUYXNrKHRhc2spOwogICAgICAgICAgaWYgKHRhc2sudGVybWluYXRlZCkgewogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICB9CiAgICAgICA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k1heFswXSA9IG1pbk1heFsxXTsKICAgICAgICBtaW5NYXhbMV0gPSB0ZW1wOwogICAgICB9CiAgICAgIG1pbk1heFswXSAqPSB0cmFuc2Zvcm1bMF07CiAgICAgIG1pbk1heFsxXSAqPSB0cmFuc2Zvcm1bMF07CiAgICAgIGlmICh0cmFuc2Zvcm1bM10gPCAwKSB7CiAgICAgICAgdGVtcCA9IG1pbk1heFsyXTsKICAgICAgICBtaW5NYXhbMl0gPSBtaW5NYXhbM107CiAgICAgICAgbWluTWF4WzNdID0gdGVtcDsKICAgICAgfQogICAgICBtaW5NYXhbMl0gKj0gdHJhbnNmb3JtWzNdOwogICAgICBtaW5NYXhbM10gKj0gdHJhbnNmb3JtWzNdOwogICAgfSBlbHNlIHsKICAgICAgdGVtcCA9IG1pbk1heFswXTsKICAgICAgbWluTWF4WzBdID0gbWluTWF4WzJdOwogICAgICBtaW5NYXhbMl0gPSB0ZW1wOwogICAgICB0ZW1wID0gbWluTWF4WzFdOwogICAgICBtaW5NYXhbMV0gPSBtaW5NYXhbM107CiAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgIGlmICh0cmFuc2Zvcm1bMV0gPCAwKSB7CiAgICAgICAgdGVtcCA9IG1pbk1heFsyXTsKICAgICAgICBtaW5NYXhbMl0gPSBtaW5NYXhbM107CiAgICAgICAgbWluTWF4WzNdID0gdGVtcDsKICAgICAgfQogICAgICBtaW5NYXhbMl0gKj0gdHJhbnNmb3JtWzFdOwogICAgICBtaW5NYXhbM10gKj0gdHJhbnNmb3JtWzFdOwogICAgICBpZiAodHJhbnNmb3JtWzJdIDwgMCkgewogICAgICAgIHRlbXAgPSBtaW5NYXhbMF07CiAgICAgICAgbWluTWF4WzBdID0gbWluTWF4WzFdOwogICAgICAgIG1pbk1heFsxXSA9IHRlbXA7CiAgICAgIH0KICAgICAgbWluTWF4WzBdICo9IHRyYW5zZm9ybVsyXTsKICAgICAgbWluTWF4WzFdICo9IHRyYW5zZm9ybVsyXTsKICAg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YWx1ZXMucHVzaCh0KTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgYjJhYyA9IGIgKiBiIC0gNCAqIGMgKiBhOwogICAgICBzcXJ0YjJhYyA9IE1hdGguc3FydChiMmFjKTsKICAgICAgaWYgKGIyYWMgPCAwKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdDEgPSAoLWIgKyBzcXJ0YjJhYykgLyAoMiAqIGEpOwogICAgICBpZiAoMCA8IHQxICYmIHQxIDwgMSkgewogICAgICAgIHR2YWx1ZXMucHVzaCh0MSk7CiAgICAgIH0KICAgICAgdDIgPSAoLWIgLSBzcXJ0YjJhYykgLyAoMiAqIGEpOwogICAgICBpZiAoMCA8IHQyICYmIHQyIDwgMSkgewogICAgICAgIHR2YWx1ZXMucHVzaCh0Mik7CiAgICAgIH0KICAgIH0KICAgIGxldCBqID0gdHZhbHVlcy5sZW5ndGgsCiAgICAgIG10OwogICAgY29uc3QgamxlbiA9IGo7CiAgICB3aGlsZSAoai0tKSB7CiAgICAgIHQgPSB0dmFsdWVzW2pdOwogICAgICBtdCA9IDEgLSB0OwogICAgICBib3VuZHNbMF1bal0gPSBtdCAqIG10ICogbXQgKiB4MCArIDMgKiBtdCAqIG10ICogdCAqIHgxICsgMyAqIG10ICogdCAqIHQgKiB4MiArIHQgKiB0ICogdCAqIHgzOwogICAgICBib3VuZHNbMV1bal0gPSBtdCAqIG10ICogbXQgKiB5MCArIDMgKiBtdCAqIG10ICogdCAqIHkxICsgMyAqIG10ICogdCAqIHQgKiB5MiArIHQgKiB0ICogdCAqIHkzOwogICAgfQogICAgYm91bmRzWzBdW2psZW5dID0geDA7CiAgICBib3VuZHNbMV1bamxlbl0gPSB5MDsKICAgIGJvdW5kc1swXVtqbGVuICsgMV0gPSB4MzsKICAgIGJvdW5kc1sxXVtqbGVuICsgMV0gPSB5MzsKICAgIGJvdW5kc1swXS5sZW5ndGggPSBib3VuZHNbMV0ubGVuZ3RoID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KTsKICAgIH07CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgImVtcHR5IiwgZW1wdHlEaWN0KTsKICB9CiAgc3RhdGljIG1lcmdlKF9yZWYpIHsKICAgIGxldCB7CiAgICAgIHhyZWYsCiAgICAgIGRpY3RBcnJheSwKICAgICAgbWVyZ2VTdWJEaWN0cyA9IGZhbHNlCiAgICB9ID0gX3JlZjsKICAgIGNvbnN0IG1lcmdlZERpY3QgPSBuZXcgRGljdCh4cmVmKSwKICAgICAgcHJvcGVydGllcyA9IG5ldyBNYXAoKTsKICAgIGZvciAoY29uc3QgZGljdCBvZiBkaWN0QXJyYXkpIHsKICAgICAgaWYgKCEoZGljdCBpbnN0YW5jZW9mIERpY3QpKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgZm9yIChjb25zdCBba2V5LCB2YWx1ZV0gb2YgT2JqZWN0LmVudHJpZXMoZGljdC5fbWFwKSkgewogICAgICAgIGxldCBwcm9wZXJ0eSA9IHByb3BlcnRpZXMuZ2V0KGtleSk7CiAgICAgICAgaWYgKHByb3BlcnR5ID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgIHByb3BlcnR5ID0gW107CiAgICAgICAgICBwcm9wZXJ0aWVzLnNldChrZXksIHByb3BlcnR5KTsKICAgICAgICB9IGVsc2UgaWYgKCFtZXJnZVN1YkRpY3RzIHx8ICEodmFsdWUgaW5zdGFuY2VvZiBEaWN0KSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIHByb3BlcnR5LnB1c2godmFsdWUpOwogICAgICB9CiAgICB9CiAgICBmb3IgKGNvbnN0IFtuYW1lLCB2YWx1ZXNdIG9mIHByb3BlcnRpZXMpIHsKICAgICAgaWYgKHZhbHVlcy5sZW5ndGggPT09IDEgfHwgISh2YWx1ZXNbMF0gaW5zdGFuY2VvZiBEaWN0KSkgewogICAgICAgIG1lcmdlZERpY3QuX21hcFtuYW1lXSA9IHZhbHVlc1swXTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBzdWJEaWN0ID0gbmV3IERpY3QoeHJlZik7CiAgICAgIGZvciAoY29uc3QgZGljdCBvZiB2YWx1ZXMpIHsKICAgICAgICBmb3IgKGNvbnN0IFtrZXksIHZhbHVlXSBvZiBPYmplY3QuZW50cmllcyhkaWN0Ll9tYXApKSB7CiAgICAgICAgICBpZiAoc3ViRGljdC5fbWFwW2tleV0gPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICBzdWJEaWN0Ll9tYXBba2V5XSA9IHZhbHVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoc3ViRGljdC5zaXplID4gMCkgewogICAgICAgIG1lcmdlZERpY3QuX21hcFtuYW1lXSA9IHN1YkRpY3Q7CiAgICAgIH0KICAgIH0KICAgIHByb3BlcnRpZXMuY2xlYXIoKTsKICAgIHJldHVybiBtZXJnZWREaWN0LnNpemUgPiAwID8gbWVyZ2VkRGljdCA6IERpY3QuZW1wdHk7CiAgfQp9CmV4cG9ydHMuRGljdCA9IERpY3Q7CmNvbnN0IFJlZiA9IGZ1bmN0aW9uIFJlZkNsb3N1cmUoKSB7CiAgbGV0IHJlZkNhY2hlID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICBjbGFzcyBSZWYgewogICAgY29uc3RydWN0b3IobnVtLCBnZW4pIHsKICAgICAgdGhpcy5udW0gPSBudW07CiAgICAgIHRoaXMuZ2VuID0gZ2VuOwogICAgfQogICAgdG9TdHJpbmcoKSB7CiAgICAgIGlmICh0aGlzLmdlbiA9PT0gMCkgewogICAgICAgIHJldHVybiBgJHt0aGlzLm51bX1SYDsKICAgICAgfQogICAgICByZXR1cm4gYCR7dGhpcy5udW19UiR7dGhpcy5nZW59YDsKICAgIH0KICAgIHN0YXRpYyBnZXQobnVtLCBnZW4pIHsKICAgICAgY29uc3Qga2V5ID0gZ2VuID09PSAwID8gYCR7bnVtfVJgIDogYCR7bnVtfVIke2dlb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CBlbmQpIHsKICAgIGlmIChiZWdpbiA+PSBlbmQpIHsKICAgICAgcmV0dXJuOwogICAgfQogICAgaWYgKGVuZCA8PSB0aGlzLnByb2dyZXNzaXZlRGF0YUxlbmd0aCkgewogICAgICByZXR1cm47CiAgICB9CiAgICBjb25zdCBiZWdpbkNodW5rID0gTWF0aC5mbG9vcihiZWdpbiAvIHRoaXMuY2h1bmtTaXplKTsKICAgIGlmIChiZWdpbkNodW5rID4gdGhpcy5udW1DaHVua3MpIHsKICAgICAgcmV0dXJuOwogICAgfQogICAgY29uc3QgZW5kQ2h1bmsgPSBNYXRoLm1pbihNYXRoLmZsb29yKChlbmQgLSAxKSAvIHRoaXMuY2h1bmtTaXplKSArIDEsIHRoaXMubnVtQ2h1bmtzKTsKICAgIGZvciAobGV0IGNodW5rID0gYmVnaW5DaHVuazsgY2h1bmsgPCBlbmRDaHVuazsgKytjaHVuaykgewogICAgICBpZiAoIXRoaXMuX2xvYWRlZENodW5rcy5oYXMoY2h1bmspKSB7CiAgICAgICAgdGhyb3cgbmV3IF9jb3JlX3V0aWxzLk1pc3NpbmdEYXRhRXhjZXB0aW9uKGJlZ2luLCBlbmQpOwogICAgICB9CiAgICB9CiAgfQogIG5leHRFbXB0eUNodW5rKGJlZ2luQ2h1bmspIHsKICAgIGNvbnN0IG51bUNodW5rcyA9IHRoaXMubnVtQ2h1bmtzOwogICAgZm9yIChsZXQgaSA9IDA7IGkgPCBudW1DaHVua3M7ICsraSkgewogICAgICBjb25zdCBjaHVuayA9IChiZWdpbkNodW5rICsgaSkgJSBudW1DaHVua3M7CiAgICAgIGlmICghdGhpcy5fbG9hZGVkQ2h1bmtzLmhhcyhjaHVuaykpIHsKICAgICAgICByZXR1cm4gY2h1bms7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBudWxsOwogIH0KICBoYXNDaHVuayhjaHVuaykgewogICAgcmV0dXJuIHRoaXMuX2xvYWRlZENodW5rcy5oYXMoY2h1bmspOwogIH0KICBnZXRCeXR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ZGVyLm9uUHJvZ3Jlc3MgPSB0aGlzLm9uUHJvZ3Jlc3MuYmluZCh0aGlzKTsKICAgIH0KICAgIGxldCBjaHVua3MgPSBbXSwKICAgICAgbG9hZGVkID0gMDsKICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CiAgICAgIGNvbnN0IHJlYWRDaHVuayA9IF9yZWYgPT4gewogICAgICAgIGxldCB7CiAgICAgICAgICB2YWx1ZSwKICAgICAgICAgIGRvbmUKICAgICAgICB9ID0gX3JlZjsKICAgICAgICB0cnkgewogICAgICAgICAgaWYgKGRvbmUpIHsKICAgICAgICAgICAgY29uc3QgY2h1bmtEYXRhID0gKDAsIF9jb3JlX3V0aWxzLmFycmF5QnVmZmVyc1RvQnl0ZXMpKGNodW5rcyk7CiAgICAgICAgICAgIGNodW5rcyA9IG51bGw7CiAgICAgICAgICAgIHJlc29sdmUoY2h1bmtEYXRhKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfQogICAgICAgICAgbG9hZGVkICs9IHZhbHVlLmJ5dGVMZW5ndGg7CiAgICAgICAgICBpZiAocmFuZ2VSZWFkZXIuaXNTdHJlYW1pbmdTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgdGhpcy5vblByb2dyZXNzKHsKICAgICAgICAgICAgICBsb2FkZWQKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9CiAgICAgICAgICBjaHVua3MucHVzaCh2YWx1ZSk7CiAgICAgICAgICByYW5nZVJlYWRlci5yZWFkKCkudGhlbihyZWFkQ2h1bmssIHJlamVjdCk7CiAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgcmVqZWN0KGUpOwogICAgICAgIH0KICAgICAgfTsKICAgICAgcmFuZ2VSZWFkZXIucmVhZCgpLnRoZW4ocmVhZENodW5rLCByZWplY3QpOwogICAgfSkudGhlbihkYXRhID0+IHsKICAgICAgaWYgKHRoaXMuYWJvcnRlZCkgewogICAgICAgIHJ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aykpIHsKICAgICAgICAgIGNodW5rc1RvUmVxdWVzdC5wdXNoKGNodW5rKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGNodW5rc1RvUmVxdWVzdC5zb3J0KGZ1bmN0aW9uIChhLCBiKSB7CiAgICAgIHJldHVybiBhIC0gYjsKICAgIH0pOwogICAgcmV0dXJuIHRoaXMuX3JlcXVlc3RDaHVua3MoY2h1bmtzVG9SZXF1ZXN0KTsKICB9CiAgZ3JvdXBDaHVua3MoY2h1bmtzKSB7CiAgICBjb25zdCBncm91cGVkQ2h1bmtzID0gW107CiAgICBsZXQgYmVnaW5DaHVuayA9IC0xOwogICAgbGV0IHByZXZDaHVuayA9IC0xOwogICAgZm9yIChsZXQgaSA9IDAsIGlpID0gY2h1bmtzLmxlbmd0aDsgaSA8IGlpOyArK2kpIHsKICAgICAgY29uc3QgY2h1bmsgPSBjaHVua3NbaV07CiAgICAgIGlmIChiZWdpbkNodW5rIDwgMCkgewogICAgICAgIGJlZ2luQ2h1bmsgPSBjaHVuazsKICAgICAgfQogICAgICBpZiAocHJldkNodW5rID49IDAgJiYgcHJldkNodW5rICsgMSAhPT0gY2h1bmspIHsKICAgICAgICBncm91cGVkQ2h1bmtzLnB1c2goewogICAgICAgICAgYmVnaW5DaHVuaywKICAgICAgICAgIGVuZENodW5rOiBwcmV2Q2h1bmsgKyAxCiAgICAgICAgfSk7CiAgICAgICAgYmVnaW5DaHVuayA9IGNodW5rOwogICAgICB9CiAgICAgIGlmIChpICsgMSA9PT0gY2h1bmtzLmxlbmd0aCkgewogICAgICAgIGdyb3VwZWRDaHVua3MucHVzaCh7CiAgICAgICAgICBiZWdpbkNodW5rLAogICAgICAgICAgZW5kQ2h1bms6IGNodW5rICsgMQogICAgICAgIH0pOwogICAgICB9CiAgICAgIHByZXZDaHVuayA9IGNodW5rOwogICAgfQogICAgcmV0dXJuIGdyb3VwZWRDaHVua3M7CiAgfQogIG9uUHJvZ3Jlc3MoYXJncykgewogICAgdGhpc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mdCb3goIk1lZGlhQm94IikgfHwgTEVUVEVSX1NJWkVfTUVESUFCT1gpOwogIH0KICBnZXQgY3JvcEJveCgpIHsKICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiY3JvcEJveCIsIHRoaXMuX2dldEJvdW5kaW5nQm94KCJDcm9wQm94IikgfHwgdGhpcy5tZWRpYUJveCk7CiAgfQogIGdldCB1c2VyVW5pdCgpIHsKICAgIGxldCBvYmogPSB0aGlzLnBhZ2VEaWN0LmdldCgiVXNlclVuaXQiKTsKICAgIGlmICh0eXBlb2Ygb2JqICE9PSAibnVtYmVyIiB8fCBvYmogPD0gMCkgewogICAgICBvYmogPSBERUZBVUxUX1VTRVJfVU5JVDsKICAgIH0KICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAidXNlclVuaXQiLCBvYmopOwogIH0KICBnZXQgdmlldygpIHsKICAgIGNvbnN0IHsKICAgICAgY3JvcEJveCwKICAgICAgbWVkaWFCb3gKICAgIH0gPSB0aGlzOwogICAgaWYgKGNyb3BCb3ggIT09IG1lZGlhQm94ICYmICEoMCwgX3V0aWwuaXNBcnJheUVxdWFsKShjcm9wQm94LCBtZWRpYUJveCkpIHsKICAgICAgY29uc3QgYm94ID0gX3V0aWwuVXRpbC5pbnRlcnNlY3QoY3JvcEJveCwgbWVkaWFCb3gpOwogICAgICBpZiAoYm94ICYmIGJveFsyXSAtIGJveFswXSA+IDAgJiYgYm94WzNdIC0gYm94WzFdID4gMCkgewogICAgICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAidmlldyIsIGJveCk7CiAgICAgIH0KICAgICAgKDAsIF91dGlsLndhcm4pKCJFbXB0eSAvQ3JvcEJveCBhbmQgL01lZGlhQm94IGludGVyc2VjdGlvbi4iKTsKICAgIH0KICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAidmlldyIsIG1lZGlhQm94KTsKICB9CiAgZ2V0IHJv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bmcgYW5ub3RhdGlvbiBkYXRhIGR1cmluZyAiICsgYCIke3Rhc2submFtZX0iIHRhc2s6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfSkpOwogICAgICB9CiAgICAgIHJldHVybiBQcm9taXNlLmFsbChuZXdSZWZzUHJvbWlzZXMpLnRoZW4oZnVuY3Rpb24gKG5ld1JlZnMpIHsKICAgICAgICByZXR1cm4gbmV3UmVmcy5maWx0ZXIobmV3UmVmID0+ICEhbmV3UmVmKTsKICAgICAgfSk7CiAgICB9KTsKICB9CiAgbG9hZFJlc291cmNlcyhrZXlzKSB7CiAgICBpZiAoIXRoaXMucmVzb3VyY2VzUHJvbWlzZSkgewogICAgICB0aGlzLnJlc291cmNlc1Byb21pc2UgPSB0aGlzLnBkZk1hbmFnZXIuZW5zdXJlKHRoaXMsICJyZXNvdXJjZXMiKTsKICAgIH0KICAgIHJldHVybiB0aGlzLnJlc291cmNlc1Byb21pc2UudGhlbigoKSA9PiB7CiAgICAgIGNvbnN0IG9iamVjdExvYWRlciA9IG5ldyBfb2JqZWN0X2xvYWRlci5PYmplY3RMb2FkZXIodGhpcy5yZXNvdXJjZXMsIGtleXMsIHRoaXMueHJlZik7CiAgICAgIHJldHVybiBvYmplY3RMb2FkZXIubG9hZCgpOwogICAgfSk7CiAgfQogIGdldE9wZXJhdG9yTGlzdChfcmVmMikgewogICAgbGV0IHsKICAgICAgaGFuZGxlciwKICAgICAgc2luaywKICAgICAgdGFzaywKICAgICAgaW50ZW50LAogICAgICBjYWNoZUtleSwKICAgICAgYW5ub3RhdGlvblN0b3JhZ2UgPSBudWxsCiAgICB9ID0gX3JlZjI7CiAgICBjb25zdCBjb250ZW50U3RyZWFtUHJvbWlzZSA9IHRoaXMuZ2V0Q29udGVudFN0cmVhbSgpOwogICAgY29uc3QgcmVzb3VyY2VzUHJvbWlzZSA9IHRoaXMubG9hZFJlc291cmNlcyhbIkNvbG9yU3BhY2UiLCAiR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BpbnRlbnRQcmludCAmJiBhbm5vdGF0aW9uLm11c3RCZVByaW50ZWQoYW5ub3RhdGlvblN0b3JhZ2UpKSB7CiAgICAgICAgICBvcExpc3RQcm9taXNlcy5wdXNoKGFubm90YXRpb24uZ2V0T3BlcmF0b3JMaXN0KHBhcnRpYWxFdmFsdWF0b3IsIHRhc2ssIGludGVudCwgcmVuZGVyRm9ybXMsIGFubm90YXRpb25TdG9yYWdlKS5jYXRjaChmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiZ2V0T3BlcmF0b3JMaXN0IC0gaWdub3JpbmcgYW5ub3RhdGlvbiBkYXRhIGR1cmluZyAiICsgYCIke3Rhc2submFtZX0iIHRhc2s6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgIG9wTGlzdDogbnVsbCwKICAgICAgICAgICAgICBzZXBhcmF0ZUZvcm06IGZhbHNlLAogICAgICAgICAgICAgIHNlcGFyYXRlQ2FudmFzOiBmYWxzZQogICAgICAgICAgICB9OwogICAgICAgICAgfSkpOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gUHJvbWlzZS5hbGwob3BMaXN0UHJvbWlzZXMpLnRoZW4oZnVuY3Rpb24gKG9wTGlzdHMpIHsKICAgICAgICBsZXQgZm9ybSA9IGZhbHNlLAogICAgICAgICAgY2FudmFzID0gZmFsc2U7CiAgICAgICAgZm9yIChjb25zdCB7CiAgICAgICAgICBvcExpc3QsCiAgICAgICAgICBzZXBhcmF0ZUZvcm0sCiAgICAgICAgICBzZXBhcmF0ZUNhbnZhcwogICAgICAgIH0gb2Ygb3BMaXN0cykgewogICAgICAgICAgcGFnZU9wTGlzdC5hZGRPcExpc3Qob3BMaXN0KTsKICAgICAgICAgIGlmIChzZXBhcmF0ZUZvcm0pIHsKICAgICAgICAgICAgZm9ybSA9IHNlcGFyYXRlRm9ybTsKICAgICAgICAgIH0KICAgICAgICAgIGl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YXRhKTsKICAgICAgfQogICAgICBpZiAoYW5ub3RhdGlvbi5oYXNUZXh0Q29udGVudCAmJiBpc1Zpc2libGUpIHsKICAgICAgICBpZiAoIXBhcnRpYWxFdmFsdWF0b3IpIHsKICAgICAgICAgIHBhcnRpYWxFdmFsdWF0b3IgPSBuZXcgX2V2YWx1YXRvci5QYXJ0aWFsRXZhbHVhdG9yKHsKICAgICAgICAgICAgeHJlZjogdGhpcy54cmVmLAogICAgICAgICAgICBoYW5kbGVyLAogICAgICAgICAgICBwYWdlSW5kZXg6IHRoaXMucGFnZUluZGV4LAogICAgICAgICAgICBpZEZhY3Rvcnk6IHRoaXMuX2xvY2FsSWRGYWN0b3J5LAogICAgICAgICAgICBmb250Q2FjaGU6IHRoaXMuZm9udENhY2hlLAogICAgICAgICAgICBidWlsdEluQ01hcENhY2hlOiB0aGlzLmJ1aWx0SW5DTWFwQ2FjaGUsCiAgICAgICAgICAgIHN0YW5kYXJkRm9udERhdGFDYWNoZTogdGhpcy5zdGFuZGFyZEZvbnREYXRhQ2FjaGUsCiAgICAgICAgICAgIGdsb2JhbEltYWdlQ2FjaGU6IHRoaXMuZ2xvYmFsSW1hZ2VDYWNoZSwKICAgICAgICAgICAgb3B0aW9uczogdGhpcy5ldmFsdWF0b3JPcHRpb25zCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgdGV4dENvbnRlbnRQcm9taXNlcy5wdXNoKGFubm90YXRpb24uZXh0cmFjdFRleHRDb250ZW50KHBhcnRpYWxFdmFsdWF0b3IsIHRhc2ssIHRoaXMudmlldykuY2F0Y2goZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBnZXRBbm5vdGF0aW9uc0RhdGEgLSBpZ25vcmluZyB0ZXh0Q29udGVudCBkdXJpbmcgIiR7dGFzay5uYW1lfSIgdGFzazogIiR7cmVhc29ufSIuYCk7CiAgICAgICAgfSkpOwogICAgICB9CiAgICB9CiAgICBhd2FpdCBQ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IHJldHVybiBhbm5vdGF0aW9uczsKICAgICAgICB9CiAgICAgICAgY29uc3Qgc29ydGVkQW5ub3RhdGlvbnMgPSBbXTsKICAgICAgICBsZXQgcG9wdXBBbm5vdGF0aW9uczsKICAgICAgICBmb3IgKGNvbnN0IGFubm90YXRpb24gb2YgYW5ub3RhdGlvbnMpIHsKICAgICAgICAgIGlmICghYW5ub3RhdGlvbikgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChhbm5vdGF0aW9uIGluc3RhbmNlb2YgX2Fubm90YXRpb24uUG9wdXBBbm5vdGF0aW9uKSB7CiAgICAgICAgICAgIGlmICghcG9wdXBBbm5vdGF0aW9ucykgewogICAgICAgICAgICAgIHBvcHVwQW5ub3RhdGlvbnMgPSBbXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBwb3B1cEFubm90YXRpb25zLnB1c2goYW5ub3RhdGlvbik7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgc29ydGVkQW5ub3RhdGlvbnMucHVzaChhbm5vdGF0aW9uKTsKICAgICAgICB9CiAgICAgICAgaWYgKHBvcHVwQW5ub3RhdGlvbnMpIHsKICAgICAgICAgIHNvcnRlZEFubm90YXRpb25zLnB1c2goLi4ucG9wdXBBbm5vdGF0aW9ucyk7CiAgICAgICAgfQogICAgICAgIHJldHVybiBzb3J0ZWRBbm5vdGF0aW9uczsKICAgICAgfSk7CiAgICB9KTsKICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiX3BhcnNlZEFubm90YXRpb25zIiwgcGFyc2VkQW5ub3RhdGlvbnMpOwogIH0KICBnZXQganNBY3Rpb25zKCkgewogICAgY29uc3QgYWN0aW9ucyA9ICgwLCBfY29yZV91dGlscy5jb2xsZWN0QWN0aW9ucykodGhpcy54cmVmLCB0aGlzLnBhZ2VEaWN0LCBfdXRpbC5QYWdlQWN0aW9uRXZlbnRUeXBlKTsKICAgIH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ID0geGZhW2ldOwogICAgICB9CiAgICAgIGlmICghZW50cmllcy5oYXNPd25Qcm9wZXJ0eShuYW1lKSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IGRhdGEgPSB0aGlzLnhyZWYuZmV0Y2hJZlJlZih4ZmFbaSArIDFdKTsKICAgICAgaWYgKCEoZGF0YSBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSB8fCBkYXRhLmlzRW1wdHkpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBlbnRyaWVzW25hbWVdID0gZGF0YTsKICAgIH0KICAgIHJldHVybiBlbnRyaWVzOwogIH0KICBnZXQgeGZhRGF0YXNldHMoKSB7CiAgICBjb25zdCBzdHJlYW1zID0gdGhpcy5feGZhU3RyZWFtczsKICAgIGlmICghc3RyZWFtcykgewogICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInhmYURhdGFzZXRzIiwgbnVsbCk7CiAgICB9CiAgICBmb3IgKGNvbnN0IGtleSBvZiBbImRhdGFzZXRzIiwgInhkcDp4ZHAiXSkgewogICAgICBjb25zdCBzdHJlYW0gPSBzdHJlYW1zW2tleV07CiAgICAgIGlmICghc3RyZWFtKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdHJ5IHsKICAgICAgICBjb25zdCBzdHIgPSAoMCwgX3V0aWwuc3RyaW5nVG9VVEY4U3RyaW5nKShzdHJlYW0uZ2V0U3RyaW5nKCkpOwogICAgICAgIGNvbnN0IGRhdGEgPSB7CiAgICAgICAgICBba2V5XTogc3RyCiAgICAgICAgfTsKICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInhmYURhdGFzZXRzIiwgbmV3IF9kYXRhc2V0X3JlYWRlci5EYXRhc2V0UmVhZGVyKGRhdGEpKTsKICAgICAgfSBjYXRjaCAoXykgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiWEZ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LmNhdGFsb2cuYnVpbHRJbkNNYXBDYWNoZSwKICAgICAgc3RhbmRhcmRGb250RGF0YUNhY2hlOiB0aGlzLmNhdGFsb2cuc3RhbmRhcmRGb250RGF0YUNhY2hlLAogICAgICBvcHRpb25zCiAgICB9KTsKICAgIGNvbnN0IG9wZXJhdG9yTGlzdCA9IG5ldyBfb3BlcmF0b3JfbGlzdC5PcGVyYXRvckxpc3QoKTsKICAgIGNvbnN0IHBkZkZvbnRzID0gW107CiAgICBjb25zdCBpbml0aWFsU3RhdGUgPSB7CiAgICAgIGdldCBmb250KCkgewogICAgICAgIHJldHVybiBwZGZGb250cy5hdCgtMSk7CiAgICAgIH0sCiAgICAgIHNldCBmb250KGZvbnQpIHsKICAgICAgICBwZGZGb250cy5wdXNoKGZvbnQpOwogICAgICB9LAogICAgICBjbG9uZSgpIHsKICAgICAgICByZXR1cm4gdGhpczsKICAgICAgfQogICAgfTsKICAgIGNvbnN0IGZvbnRzID0gbmV3IE1hcCgpOwogICAgZm9udFJlcy5mb3JFYWNoKChmb250TmFtZSwgZm9udCkgPT4gewogICAgICBmb250cy5zZXQoZm9udE5hbWUsIGZvbnQpOwogICAgfSk7CiAgICBjb25zdCBwcm9taXNlcyA9IFtdOwogICAgZm9yIChjb25zdCBbZm9udE5hbWUsIGZvbnRdIG9mIGZvbnRzKSB7CiAgICAgIGNvbnN0IGRlc2NyaXB0b3IgPSBmb250LmdldCgiRm9udERlc2NyaXB0b3IiKTsKICAgICAgaWYgKCEoZGVzY3JpcHRvciBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgbGV0IGZvbnRGYW1pbHkgPSBkZXNjcmlwdG9yLmdldCgiRm9udEZhbWlseSIpOwogICAgICBmb250RmFtaWx5ID0gZm9udEZhbWlseS5yZXBsYWNlQWxsKC9bIF0rKFxkKS9nLCAiJDEiKTsKICAgICAgY29uc3QgZm9udFdlaWdodCA9IGRlc2NyaXB0b3IuZ2V0KCJGb250V2VpZ2h0Iik7CiAgICAgIGNvbnN0IGl0YWxpY0FuZ2xlID0gLWRlc2NyaXB0b3IuZ2V0KCJJdGFsaWNBbmdsZSIpOwogICAgICBjb25zdCBjc3NGb250SW5mbyA9IHsKICAgICAgICBmb250RmFtaWx5LAogICAgICAgIGZvbnRXZWlnaHQsCiAgICAgICAgaXRhbGljQW5nbGUKICAgICAgfTsKICAgICAgaWYgKCEoMCwgX2NvcmVfdXRpbHMudmFsaWRhdGVDU1NGb250KShjc3NGb250SW5mbykpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBwcm9taXNlcy5wdXNoKHBhcnRpYWxFdmFsdWF0b3IuaGFuZGxlU2V0Rm9udChyZXNvdXJjZXMsIFtfcHJpbWl0aXZlcy5OYW1lLmdldChmb250TmFtZSksIDFdLCBudWxsLCBvcGVyYXRvckxpc3QsIHRhc2ssIGluaXRpYWxTdGF0ZSwgbnVsbCwgY3NzRm9udEluZm8pLmNhdGNoKGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYGxvYWRYZmFGb250czogIiR7cmVhc29ufSIuYCk7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0pKTsKICAgIH0KICAgIGF3YWl0IFByb21pc2UuYWxsKHByb21pc2VzKTsKICAgIGNvbnN0IG1pc3NpbmdGb250cyA9IHRoaXMueGZhRmFjdG9yeS5zZXRGb250cyhwZGZGb250cyk7CiAgICBpZiAoIW1pc3NpbmdGb250cykgewogICAgICByZXR1cm47CiAgICB9CiAgICBvcHRpb25zLmlnbm9yZUVycm9ycyA9IHRydWU7CiAgICBwcm9taXNlcy5sZW5ndGggPSAwOwogICAgcGRmRm9udHMubGVuZ3RoID0gMDsKICAgIGNvbnN0IHJlYWxseU1pc3NpbmdGb250cyA9IG5ldyBTZXQoKTsKICAgIGZvciAoY29uc3QgbWlzc2luZyBvZiBtaXNzaW5nRm9udHMpIHsKICAgICAgaWYgKCEoMCwgX3hmYV9mb250cy5nZXRYZmFGb250TmFtZSkoYCR7bWlzc2luZ30tUmVndWxhcmApKSB7CiAgICAgICAgcmVhbGx5TWlzc2luZ0ZvbnRzLmFkZChtaXNzaW5nKTsKICAgICAgfQogICAgfQogICAgaWYgKHJlYWxseU1pc3NpbmdGb250cy5zaXplKSB7CiAgICAgIG1pc3NpbmdGb250cy5wdXNoKCJQZGZKUy1GYWxsYmFjayIpOwogICAgfQogICAgZm9yIChjb25zdCBtaXNzaW5nIG9mIG1pc3NpbmdGb250cykgewogICAgICBpZiAocmVhbGx5TWlzc2luZ0ZvbnRzLmhhcyhtaXNzaW5nKSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGZvciAoY29uc3QgZm9udEluZm8gb2YgW3sKICAgICAgICBuYW1lOiAiUmVndWxhciIsCiAgICAgICAgZm9udFdlaWdodDogNDAwLAogICAgICAgIGl0YWxpY0FuZ2xlOiAwCiAgICAgIH0sIHsKICAgICAgICBuYW1lOiAiQm9sZCIsCiAgICAgICAgZm9udFdlaWdodDogNzAwLAogICAgICAgIGl0YWxpY0FuZ2xlOiAwCiAgICAgIH0sIHsKICAgICAgICBuYW1lOiAiSXRhbGljIiwKICAgICAgICBmb250V2VpZ2h0OiA0MDAsCiAgICAgICAgaXRhbGljQW5nbGU6IDEyCiAgICAgIH0sIHsKICAgICAgICBuYW1lOiAiQm9sZEl0YWxpYyIsCiAgICAgICAgZm9udFdlaWdodDogNzAwLAogICAgICAgIGl0YWxpY0FuZ2xlOiAxMgogICAgICB9XSkgewogICAgICAgIGNvbnN0IG5hbWUgPSBgJHttaXNzaW5nfS0ke2ZvbnRJbmZvLm5hbWV9YDsKICAgICAgICBjb25zdCBkaWN0ID0gKDAsIF94ZmFfZm9udHMuZ2V0WGZhRm9udERpY3QpKG5hbWUpOwogICAgICAgIHByb21pc2VzLnB1c2gocGFydGlhbEV2YWx1YXRvci5oYW5kbGVTZXRGb250KHJlc291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vcm1hdGlvbiBkaWN0aW9uYXJ5IGlzIGludmFsaWQuIik7CiAgICB9CiAgICBpZiAoIShpbmZvRGljdCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiZG9jdW1lbnRJbmZvIiwgZG9jSW5mbyk7CiAgICB9CiAgICBmb3IgKGNvbnN0IGtleSBvZiBpbmZvRGljdC5nZXRLZXlzKCkpIHsKICAgICAgY29uc3QgdmFsdWUgPSBpbmZvRGljdC5nZXQoa2V5KTsKICAgICAgc3dpdGNoIChrZXkpIHsKICAgICAgICBjYXNlICJUaXRsZSI6CiAgICAgICAgY2FzZSAiQXV0aG9yIjoKICAgICAgICBjYXNlICJTdWJqZWN0IjoKICAgICAgICBjYXNlICJLZXl3b3JkcyI6CiAgICAgICAgY2FzZSAiQ3JlYXRvciI6CiAgICAgICAgY2FzZSAiUHJvZHVjZXIiOgogICAgICAgIGNhc2UgIkNyZWF0aW9uRGF0ZSI6CiAgICAgICAgY2FzZSAiTW9kRGF0ZSI6CiAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlID09PSAic3RyaW5nIikgewogICAgICAgICAgICBkb2NJbmZvW2tleV0gPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHZhbHVlKTsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJUcmFwcGVkIjoKICAgICAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgZG9jSW5mb1trZXldID0gdmFsdWU7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIGxldCBjdXN0b21WYWx1ZTsKICAgICAgICAgIHN3aXRjaCAodHlwZW9mIHZhbHVlKSB7CiAgICAgICAgICAgIGNhc2UgInN0cmluZyI6CiAgICAgICAgICAgICAgY3VzdG9tVmFsdWUgPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHZhbHVlKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAibnVtYmVyIjoKICAgICAgICAgICAgY2FzZSAiYm9vbGVhbiI6CiAgICAgICAgICAgICAgY3VzdG9tVmFsdWUgPSB2YWx1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgICBjdXN0b21WYWx1ZSA9IHZhbHVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChjdXN0b21WYWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgQmFkIHZhbHVlLCBmb3IgY3VzdG9tIGtleSAiJHtrZXl9IiwgaW4gSW5mbzogJHt2YWx1ZX0uYCk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKCFkb2NJbmZvLkN1c3RvbSkgewogICAgICAgICAgICBkb2NJbmZvLkN1c3RvbSA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgICAgICB9CiAgICAgICAgICBkb2NJbmZvLkN1c3RvbVtrZXldID0gY3VzdG9tVmFsdWU7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICAoMCwgX3V0aWwud2FybikoYEJhZCB2YWx1ZSwgZm9yIGtleSAiJHtrZXl9IiwgaW4gSW5mbzogJHt2YWx1ZX0uYCk7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgImRvY3VtZW50SW5mbyIsIGRvY0luZm8pO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2cuc2V0QWN0dWFsTnVtUGFnZXMoMSk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGZvciAoY29uc3QgW3BhZ2VJbmRleCwgW3BhZ2VEaWN0LCByZWZdXSBvZiBwYWdlc1RyZWUpIHsKICAgICAgICBsZXQgcHJvbWlzZTsKICAgICAgICBpZiAocGFnZURpY3QgaW5zdGFuY2VvZiBFcnJvcikgewogICAgICAgICAgcHJvbWlzZSA9IFByb21pc2UucmVqZWN0KHBhZ2VEaWN0KTsKICAgICAgICAgIHByb21pc2UuY2F0Y2goKCkgPT4ge30pOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBwcm9taXNlID0gUHJvbWlzZS5yZXNvbHZlKG5ldyBQYWdlKHsKICAgICAgICAgICAgcGRmTWFuYWdlciwKICAgICAgICAgICAgeHJlZjogdGhpcy54cmVmLAogICAgICAgICAgICBwYWdlSW5kZXgsCiAgICAgICAgICAgIHBhZ2VEaWN0LAogICAgICAgICAgICByZWYsCiAgICAgICAgICAgIGdsb2JhbElkRmFjdG9yeTogdGhpcy5fZ2xvYmFsSWRGYWN0b3J5LAogICAgICAgICAgICBmb250Q2FjaGU6IGNhdGFsb2cuZm9udENhY2hlLAogICAgICAgICAgICBidWlsdEluQ01hcENhY2hlOiBjYXRhbG9nLmJ1aWx0SW5DTWFwQ2FjaGUsCiAgICAgICAgICAgIHN0YW5kYXJkRm9udERhdGFDYWNoZTogY2F0YWxvZy5zdGFuZGFyZEZvbnREYXRhQ2FjaGUsCiAgICAgICAgICAgIGdsb2JhbEltYWdlQ2FjaGU6IGNhdGFsb2cuZ2xvYmFsSW1hZ2VDYWNoZSwKICAgICAgICAgICAgbm9uQmxlbmRNb2Rlc1NldDogY2F0YWxvZy5ub25CbGVuZE1vZGVzU2V0LAogICAgICAgICAgICB4ZmFGYWN0b3J5OiBudWxsCiAgICAgICAgICB9KSk7CiAgICAgICAgfQogICAgICAgIHRoaXMuX3BhZ2VQcm9taXNlcy5zZXQocGFn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gZm9yIChsZXQgaiA9IGkgKiA4LCBqaiA9IGkgKiA4ICsgODsgaiA8IGpqOyBqICs9IDIpIHsKICAgICAgY29uc3QgeCA9IHF1YWRQb2ludHNbal07CiAgICAgIGNvbnN0IHkgPSBxdWFkUG9pbnRzW2ogKyAxXTsKICAgICAgbWluWCA9IE1hdGgubWluKHgsIG1pblgpOwogICAgICBtYXhYID0gTWF0aC5tYXgoeCwgbWF4WCk7CiAgICAgIG1pblkgPSBNYXRoLm1pbih5LCBtaW5ZKTsKICAgICAgbWF4WSA9IE1hdGgubWF4KHksIG1heFkpOwogICAgfQogICAgaWYgKHJlY3QgIT09IG51bGwgJiYgKG1pblggPCByZWN0WzBdIHx8IG1heFggPiByZWN0WzJdIHx8IG1pblkgPCByZWN0WzFdIHx8IG1heFkgPiByZWN0WzNdKSkgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIHF1YWRQb2ludHNMaXN0cy5wdXNoKFt7CiAgICAgIHg6IG1pblgsCiAgICAgIHk6IG1heFkKICAgIH0sIHsKICAgICAgeDogbWF4WCwKICAgICAgeTogbWF4WQogICAgfSwgewogICAgICB4OiBtaW5YLAogICAgICB5OiBtaW5ZCiAgICB9LCB7CiAgICAgIHg6IG1heFgsCiAgICAgIHk6IG1pblkKICAgIH1dKTsKICB9CiAgcmV0dXJuIHF1YWRQb2ludHNMaXN0czsKfQpmdW5jdGlvbiBnZXRUcmFuc2Zvcm1NYXRyaXgocmVjdCwgYmJveCwgbWF0cml4KSB7CiAgY29uc3QgW21pblgsIG1pblksIG1heFgsIG1heFldID0gX3V0aWwuVXRpbC5nZXRBeGlhbEFsaWduZWRCb3VuZGluZ0JveChiYm94LCBtYXRyaXgpOwogIGlmIChtaW5YID09PSBtYXhYIHx8IG1pblkgPT09IG1heFkpIHsKICAgIHJldHVybiBbMSwgMCwgMCwgMSwgcmVjdFswXSwgcmVjdFsxXV07CiAgfQogIGNvbnN0IHhSYXRpbyA9IChyZWN0WzJdIC0gcmVjdFsw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GluZ3MpICYmIGxpbmVFbmRpbmdzLmxlbmd0aCA9PT0gMikgewogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI7IGkrKykgewogICAgICAgIGNvbnN0IG9iaiA9IGxpbmVFbmRpbmdzW2ldOwogICAgICAgIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICBzd2l0Y2ggKG9iai5uYW1lKSB7CiAgICAgICAgICAgIGNhc2UgIk5vbmUiOgogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICBjYXNlICJTcXVhcmUiOgogICAgICAgICAgICBjYXNlICJDaXJjbGUiOgogICAgICAgICAgICBjYXNlICJEaWFtb25kIjoKICAgICAgICAgICAgY2FzZSAiT3BlbkFycm93IjoKICAgICAgICAgICAgY2FzZSAiQ2xvc2VkQXJyb3ciOgogICAgICAgICAgICBjYXNlICJCdXR0IjoKICAgICAgICAgICAgY2FzZSAiUk9wZW5BcnJvdyI6CiAgICAgICAgICAgIGNhc2UgIlJDbG9zZWRBcnJvdyI6CiAgICAgICAgICAgIGNhc2UgIlNsYXNoIjoKICAgICAgICAgICAgICB0aGlzLmxpbmVFbmRpbmdzW2ldID0gb2JqLm5hbWU7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgICgwLCBfdXRpbC53YXJuKShgSWdub3JpbmcgaW52YWxpZCBsaW5lRW5kaW5nOiAke29ian1gKTsKICAgICAgfQogICAgfQogIH0KICBzZXRSb3RhdGlvbihtaykgewogICAgdGhpcy5yb3RhdGlvbiA9IDA7CiAgICBpZiAobWsgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgIGxldCBhbmdsZSA9IG1rLmdldCgiUiIpIHx8IDA7CiAgICAgIGlmIChOdW1iZXIuaXNJbnRlZ2VyKGFuZ2xlKSAmJiBhbmdsZSAhPT0gMCkgewogICAgICAgIGFuZ2xlICU9IDM2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wZWFyYW5jZSk7CiAgICBjb25zdCB0ZXh0ID0gW107CiAgICBjb25zdCBidWZmZXIgPSBbXTsKICAgIGNvbnN0IHNpbmsgPSB7CiAgICAgIGRlc2lyZWRTaXplOiBNYXRoLkluZmluaXR5LAogICAgICByZWFkeTogdHJ1ZSwKICAgICAgZW5xdWV1ZShjaHVuaywgc2l6ZSkgewogICAgICAgIGZvciAoY29uc3QgaXRlbSBvZiBjaHVuay5pdGVtcykgewogICAgICAgICAgYnVmZmVyLnB1c2goaXRlbS5zdHIpOwogICAgICAgICAgaWYgKGl0ZW0uaGFzRU9MKSB7CiAgICAgICAgICAgIHRleHQucHVzaChidWZmZXIuam9pbigiIikpOwogICAgICAgICAgICBidWZmZXIubGVuZ3RoID0gMDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH07CiAgICBhd2FpdCBldmFsdWF0b3IuZ2V0VGV4dENvbnRlbnQoewogICAgICBzdHJlYW06IHRoaXMuYXBwZWFyYW5jZSwKICAgICAgdGFzaywKICAgICAgcmVzb3VyY2VzLAogICAgICBpbmNsdWRlTWFya2VkQ29udGVudDogdHJ1ZSwKICAgICAgY29tYmluZVRleHRJdGVtczogdHJ1ZSwKICAgICAgc2luaywKICAgICAgdmlld0JveAogICAgfSk7CiAgICB0aGlzLnJlc2V0KCk7CiAgICBpZiAoYnVmZmVyLmxlbmd0aCkgewogICAgICB0ZXh0LnB1c2goYnVmZmVyLmpvaW4oIiIpKTsKICAgIH0KICAgIGlmICh0ZXh0Lmxlbmd0aCA+IDApIHsKICAgICAgdGhpcy5kYXRhLnRleHRDb250ZW50ID0gdGV4dDsKICAgIH0KICB9CiAgZ2V0RmllbGRPYmplY3QoKSB7CiAgICBpZiAodGhpcy5kYXRhLmtpZElkcykgewogICAgICByZXR1cm4gewogICAgICAgIGlkOiB0aGlzLmRhdGEuaWQsCiAgICAgICAgYWN0aW9uczogdGhpcy5kYXRhLmFjdGlvbnMsCiAgICAgICAgbmFtZTogdGhpcy5kYXRhLmZpZWxkTmFtZSwKICAgICAgICBzdHJva2VDb2xvcjogdGhpcy5kYXRhLmJvcmRlckNvbG9yLAogICAgICAgIGZpbGxDb2xvcjogdGhpcy5kYXRhLmJhY2tncm91bmRDb2xvciwKICAgICAgICB0eXBlOiAiIiwKICAgICAgICBraWRJZHM6IHRoaXMuZGF0YS5raWRJZHMsCiAgICAgICAgcGFnZTogdGhpcy5kYXRhLnBhZ2VJbmRleCwKICAgICAgICByb3RhdGlvbjogdGhpcy5yb3RhdGlvbgogICAgICB9OwogICAgfQogICAgcmV0dXJuIG51bGw7CiAgfQogIHJlc2V0KCkgewogICAgZm9yIChjb25zdCBzdHJlYW0gb2YgdGhpcy5fc3RyZWFtcykgewogICAgICBzdHJlYW0ucmVzZXQoKTsKICAgIH0KICB9CiAgX2NvbnN0cnVjdEZpZWxkTmFtZShkaWN0KSB7CiAgICBpZiAoIWRpY3QuaGFzKCJUIikgJiYgIWRpY3QuaGFzKCJQYXJlbnQiKSkgewogICAgICAoMCwgX3V0aWwud2FybikoIlVua25vd24gZmllbGQgbmFtZSwgZmFsbGluZyBiYWNrIHRvIGVtcHR5IGZpZWxkIG5hbWUuIik7CiAgICAgIHJldHVybiAiIjsKICAgIH0KICAgIGlmICghZGljdC5oYXMoIlBhcmVudCIpKSB7CiAgICAgIHJldHVybiAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKGRpY3QuZ2V0KCJUIikpOwogICAgfQogICAgY29uc3QgZmllbGROYW1lID0gW107CiAgICBpZiAoZGljdC5oYXMoIlQiKSkgewogICAgICBmaWVsZE5hbWUudW5zaGlmdCgoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKGRpY3QuZ2V0KCJUIikpKTsKICAgIH0KICAgIGxldCBsb29wRGljdCA9IGRpY3Q7CiAgICBjb25zdCB2aXNpdGVkID0gbmV3IF9wcmltaXRpdmVzLlJlZlNldCgpOwogICAgaWYgKGRpY3Qub2JqSWQpIHsKICAgICAg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2tlQ29sb3IsCiAgICAgIGZpbGxDb2xvciwKICAgICAgYmxlbmRNb2RlLAogICAgICBzdHJva2VBbHBoYSwKICAgICAgZmlsbEFscGhhLAogICAgICBwb2ludHNDYWxsYmFjawogICAgfSA9IF9yZWYyOwogICAgbGV0IG1pblggPSBOdW1iZXIuTUFYX1ZBTFVFOwogICAgbGV0IG1pblkgPSBOdW1iZXIuTUFYX1ZBTFVFOwogICAgbGV0IG1heFggPSBOdW1iZXIuTUlOX1ZBTFVFOwogICAgbGV0IG1heFkgPSBOdW1iZXIuTUlOX1ZBTFVFOwogICAgY29uc3QgYnVmZmVyID0gWyJxIl07CiAgICBpZiAoZXh0cmEpIHsKICAgICAgYnVmZmVyLnB1c2goZXh0cmEpOwogICAgfQogICAgaWYgKHN0cm9rZUNvbG9yKSB7CiAgICAgIGJ1ZmZlci5wdXNoKGAke3N0cm9rZUNvbG9yWzBdfSAke3N0cm9rZUNvbG9yWzFdfSAke3N0cm9rZUNvbG9yWzJdfSBSR2ApOwogICAgfQogICAgaWYgKGZpbGxDb2xvcikgewogICAgICBidWZmZXIucHVzaChgJHtmaWxsQ29sb3JbMF19ICR7ZmlsbENvbG9yWzFdfSAke2ZpbGxDb2xvclsyXX0gcmdgKTsKICAgIH0KICAgIGxldCBwb2ludHNBcnJheSA9IHRoaXMuZGF0YS5xdWFkUG9pbnRzOwogICAgaWYgKCFwb2ludHNBcnJheSkgewogICAgICBwb2ludHNBcnJheSA9IFtbewogICAgICAgIHg6IHRoaXMucmVjdGFuZ2xlWzBdLAogICAgICAgIHk6IHRoaXMucmVjdGFuZ2xlWzNdCiAgICAgIH0sIHsKICAgICAgICB4OiB0aGlzLnJlY3RhbmdsZVsyXSwKICAgICAgICB5OiB0aGlzLnJlY3RhbmdsZVszXQogICAgICB9LCB7CiAgICAgICAgeDogdGhpcy5yZWN0YW5nbGVbMF0sCiAgICAgICAgeTogdGhpcy5yZWN0YW5nbGVbMV0KICAgICAgfSwgewogICAgICAgIHg6IHRo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WZvbnRTaXplKSB7CiAgICAgIGNvbnN0IHJvdW5kV2l0aFR3b0RpZ2l0cyA9IHggPT4gTWF0aC5mbG9vcih4ICogMTAwKSAvIDEwMDsKICAgICAgaWYgKGxpbmVDb3VudCA9PT0gLTEpIHsKICAgICAgICBjb25zdCB0ZXh0V2lkdGggPSB0aGlzLl9nZXRUZXh0V2lkdGgodGV4dCwgZm9udCk7CiAgICAgICAgZm9udFNpemUgPSByb3VuZFdpdGhUd29EaWdpdHMoTWF0aC5taW4oaGVpZ2h0IC8gX3V0aWwuTElORV9GQUNUT1IsIHRleHRXaWR0aCA+IHdpZHRoID8gd2lkdGggLyB0ZXh0V2lkdGggOiBJbmZpbml0eSkpOwogICAgICAgIG51bWJlck9mTGluZXMgPSAxOwogICAgICB9IGVsc2UgewogICAgICAgIGNvbnN0IGxpbmVzID0gdGV4dC5zcGxpdCgvXHJcbj98XG4vKTsKICAgICAgICBjb25zdCBjYWNoZWRMaW5lcyA9IFtdOwogICAgICAgIGZvciAoY29uc3QgbGluZSBvZiBsaW5lcykgewogICAgICAgICAgY29uc3QgZW5jb2RlZCA9IGZvbnQuZW5jb2RlU3RyaW5nKGxpbmUpLmpvaW4oIiIpOwogICAgICAgICAgY29uc3QgZ2x5cGhzID0gZm9udC5jaGFyc1RvR2x5cGhzKGVuY29kZWQpOwogICAgICAgICAgY29uc3QgcG9zaXRpb25zID0gZm9udC5nZXRDaGFyUG9zaXRpb25zKGVuY29kZWQpOwogICAgICAgICAgY2FjaGVkTGluZXMucHVzaCh7CiAgICAgICAgICAgIGxpbmU6IGVuY29kZWQsCiAgICAgICAgICAgIGdseXBocywKICAgICAgICAgICAgcG9zaXRpb25zCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgY29uc3QgaXNUb29CaWcgPSBmc2l6ZSA9PiB7CiAgICAgICAgICBsZXQgdG90YWxIZWlnaHQgPSAwOwogICAgICAgICAgZm9yIChjb25zdCBjYWNoZSBvZiBjYWNoZWRMaW5lcykgewogICAgICAgICAgICBjb25zdCBjaHVua3MgPSB0aGlzLl9zcGxpdExpbmUobnVsbCwgZm9udCwgZnNpemUsIHdpZHRoLCBjYWNoZSk7CiAgICAgICAgICAgIHRvdGFsSGVpZ2h0ICs9IGNodW5rcy5sZW5ndGggKiBmc2l6ZTsKICAgICAgICAgICAgaWYgKHRvdGFsSGVpZ2h0ID4gaGVpZ2h0KSB7CiAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9OwogICAgICAgIG51bWJlck9mTGluZXMgPSBNYXRoLm1heChudW1iZXJPZkxpbmVzLCBsaW5lQ291bnQpOwogICAgICAgIHdoaWxlICh0cnVlKSB7CiAgICAgICAgICBsaW5lSGVpZ2h0ID0gaGVpZ2h0IC8gbnVtYmVyT2ZMaW5lczsKICAgICAgICAgIGZvbnRTaXplID0gcm91bmRXaXRoVHdvRGlnaXRzKGxpbmVIZWlnaHQgLyBfdXRpbC5MSU5FX0ZBQ1RPUik7CiAgICAgICAgICBpZiAoaXNUb29CaWcoZm9udFNpemUpKSB7CiAgICAgICAgICAgIG51bWJlck9mTGluZXMrKzsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0KICAgICAgY29uc3QgewogICAgICAgIGZvbnROYW1lLAogICAgICAgIGZvbnRDb2xvcgogICAgICB9ID0gdGhpcy5kYXRhLmRlZmF1bHRBcHBlYXJhbmNlRGF0YTsKICAgICAgdGhpcy5fZGVmYXVsdEFwcGVhcmFuY2UgPSAoMCwgX2RlZmF1bHRfYXBwZWFyYW5jZS5jcmVhdGVEZWZhdWx0QXBwZWFyYW5jZSkoewogICAgICAgIGZvbnRTaXplLAogICAgICAgIGZvbnROYW1lLAogICAgICAgIGZvbnRDb2xvcgogICAgICB9KTsKICAgIH0KICAgIHJldHVybiBbdGhpcy5fZGV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50V2lkdGggKyBnbHlwaFdpZHRoID4gd2lkdGgpIHsKICAgICAgICAgIGNodW5rcy5wdXNoKGxpbmUuc3Vic3RyaW5nKHN0YXJ0Q2h1bmssIHN0YXJ0KSk7CiAgICAgICAgICBzdGFydENodW5rID0gc3RhcnQ7CiAgICAgICAgICBjdXJyZW50V2lkdGggPSBnbHlwaFdpZHRoOwogICAgICAgICAgbGFzdFNwYWNlUG9zSW5TdHJpbmdTdGFydCA9IC0xOwogICAgICAgICAgbGFzdFNwYWNlUG9zID0gLTE7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGN1cnJlbnRXaWR0aCArPSBnbHlwaFdpZHRoOwogICAgICAgICAgbGFzdFNwYWNlUG9zSW5TdHJpbmdTdGFydCA9IHN0YXJ0OwogICAgICAgICAgbGFzdFNwYWNlUG9zSW5TdHJpbmdFbmQgPSBlbmQ7CiAgICAgICAgICBsYXN0U3BhY2VQb3MgPSBpOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICBpZiAoY3VycmVudFdpZHRoICsgZ2x5cGhXaWR0aCA+IHdpZHRoKSB7CiAgICAgICAgICBpZiAobGFzdFNwYWNlUG9zSW5TdHJpbmdTdGFydCAhPT0gLTEpIHsKICAgICAgICAgICAgY2h1bmtzLnB1c2gobGluZS5zdWJzdHJpbmcoc3RhcnRDaHVuaywgbGFzdFNwYWNlUG9zSW5TdHJpbmdFbmQpKTsKICAgICAgICAgICAgc3RhcnRDaHVuayA9IGxhc3RTcGFjZVBvc0luU3RyaW5nRW5kOwogICAgICAgICAgICBpID0gbGFzdFNwYWNlUG9zICsgMTsKICAgICAgICAgICAgbGFzdFNwYWNlUG9zSW5TdHJpbmdTdGFydCA9IC0xOwogICAgICAgICAgICBjdXJyZW50V2lkdGggPSAwOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY2h1bmtzLnB1c2gobGluZS5zdWJzdHJpbmcoc3RhcnRDaHVuaywgc3RhcnQpKTsKICAgICAgICAgIC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yU3R5bGUud2lkdGggfHwgMSwKICAgICAgICBib3JkZXJBZGp1c3QgPSAyICogYm9yZGVyV2lkdGg7CiAgICAgIGNvbnN0IGJib3ggPSBbdGhpcy5kYXRhLmxpbmVDb29yZGluYXRlc1swXSAtIGJvcmRlckFkanVzdCwgdGhpcy5kYXRhLmxpbmVDb29yZGluYXRlc1sxXSAtIGJvcmRlckFkanVzdCwgdGhpcy5kYXRhLmxpbmVDb29yZGluYXRlc1syXSArIGJvcmRlckFkanVzdCwgdGhpcy5kYXRhLmxpbmVDb29yZGluYXRlc1szXSArIGJvcmRlckFkanVzdF07CiAgICAgIGlmICghX3V0aWwuVXRpbC5pbnRlcnNlY3QodGhpcy5yZWN0YW5nbGUsIGJib3gpKSB7CiAgICAgICAgdGhpcy5yZWN0YW5nbGUgPSBiYm94OwogICAgICB9CiAgICAgIHRoaXMuX3NldERlZmF1bHRBcHBlYXJhbmNlKHsKICAgICAgICB4cmVmLAogICAgICAgIGV4dHJhOiBgJHtib3JkZXJXaWR0aH0gd2AsCiAgICAgICAgc3Ryb2tlQ29sb3IsCiAgICAgICAgZmlsbENvbG9yLAogICAgICAgIHN0cm9rZUFscGhhLAogICAgICAgIGZpbGxBbHBoYSwKICAgICAgICBwb2ludHNDYWxsYmFjazogKGJ1ZmZlciwgcG9pbnRzKSA9PiB7CiAgICAgICAgICBidWZmZXIucHVzaChgJHtsaW5lQ29vcmRpbmF0ZXNbMF19ICR7bGluZUNvb3JkaW5hdGVzWzFdfSBtYCwgYCR7bGluZUNvb3JkaW5hdGVzWzJdfSAke2xpbmVDb29yZGluYXRlc1szXX0gbGAsICJTIik7CiAgICAgICAgICByZXR1cm4gW3BvaW50c1swXS54IC0gYm9yZGVyV2lkdGgsIHBvaW50c1sxXS54ICsgYm9yZGVyV2lkdGgsIHBvaW50c1szXS55IC0gYm9yZGVyV2lkdGgsIHBvaW50c1sxXS55ICsgYm9yZGVyV2lkdGhdOwogICAgICAgIH0KICAgICAgfSk7CiAgICB9Ci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sbENvbG9yLAogICAgICAgIHN0cm9rZUFscGhhLAogICAgICAgIGZpbGxBbHBoYSwKICAgICAgICBwb2ludHNDYWxsYmFjazogKGJ1ZmZlciwgcG9pbnRzKSA9PiB7CiAgICAgICAgICBjb25zdCB4ID0gcG9pbnRzWzJdLnggKyB0aGlzLmJvcmRlclN0eWxlLndpZHRoIC8gMjsKICAgICAgICAgIGNvbnN0IHkgPSBwb2ludHNbMl0ueSArIHRoaXMuYm9yZGVyU3R5bGUud2lkdGggLyAyOwogICAgICAgICAgY29uc3Qgd2lkdGggPSBwb2ludHNbM10ueCAtIHBvaW50c1syXS54IC0gdGhpcy5ib3JkZXJTdHlsZS53aWR0aDsKICAgICAgICAgIGNvbnN0IGhlaWdodCA9IHBvaW50c1sxXS55IC0gcG9pbnRzWzNdLnkgLSB0aGlzLmJvcmRlclN0eWxlLndpZHRoOwogICAgICAgICAgYnVmZmVyLnB1c2goYCR7eH0gJHt5fSAke3dpZHRofSAke2hlaWdodH0gcmVgKTsKICAgICAgICAgIGlmIChmaWxsQ29sb3IpIHsKICAgICAgICAgICAgYnVmZmVyLnB1c2goIkIiKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGJ1ZmZlci5wdXNoKCJTIik7CiAgICAgICAgICB9CiAgICAgICAgICByZXR1cm4gW3BvaW50c1swXS54LCBwb2ludHNbMV0ueCwgcG9pbnRzWzNdLnksIHBvaW50c1sxXS55XTsKICAgICAgICB9CiAgICAgIH0pOwogICAgfQogIH0KfQpjbGFzcyBDaXJjbGVBbm5vdGF0aW9uIGV4dGVuZHMgTWFya3VwQW5ub3RhdGlvbiB7CiAgY29uc3RydWN0b3IocGFyYW1zKSB7CiAgICBzdXBlcihwYXJhbXMpOwogICAgY29uc3QgewogICAgICBkaWN0LAogICAgICB4cmVmCiAgICB9ID0gcGFyYW1zOwogICAgdGhpcy5kYXRhLmFubm90YXRpb25UeXBlID0gX3V0aWwuQW5ub3RhdGlvblR5cGUuQ0lSQ0xF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BnZXRQZGZDb2xvckFycmF5KHRoaXMuY29sb3IpIDogWzAsIDAsIDBdOwogICAgICBjb25zdCBzdHJva2VBbHBoYSA9IGRpY3QuZ2V0KCJDQSIpOwogICAgICBjb25zdCBib3JkZXJXaWR0aCA9IHRoaXMuYm9yZGVyU3R5bGUud2lkdGggfHwgMSwKICAgICAgICBib3JkZXJBZGp1c3QgPSAyICogYm9yZGVyV2lkdGg7CiAgICAgIGNvbnN0IGJib3ggPSBbSW5maW5pdHksIEluZmluaXR5LCAtSW5maW5pdHksIC1JbmZpbml0eV07CiAgICAgIGZvciAoY29uc3QgdmVydGV4IG9mIHRoaXMuZGF0YS52ZXJ0aWNlcykgewogICAgICAgIGJib3hbMF0gPSBNYXRoLm1pbihiYm94WzBdLCB2ZXJ0ZXgueCAtIGJvcmRlckFkanVzdCk7CiAgICAgICAgYmJveFsxXSA9IE1hdGgubWluKGJib3hbMV0sIHZlcnRleC55IC0gYm9yZGVyQWRqdXN0KTsKICAgICAgICBiYm94WzJdID0gTWF0aC5tYXgoYmJveFsyXSwgdmVydGV4LnggKyBib3JkZXJBZGp1c3QpOwogICAgICAgIGJib3hbM10gPSBNYXRoLm1heChiYm94WzNdLCB2ZXJ0ZXgueSArIGJvcmRlckFkanVzdCk7CiAgICAgIH0KICAgICAgaWYgKCFfdXRpbC5VdGlsLmludGVyc2VjdCh0aGlzLnJlY3RhbmdsZSwgYmJveCkpIHsKICAgICAgICB0aGlzLnJlY3RhbmdsZSA9IGJib3g7CiAgICAgIH0KICAgICAgdGhpcy5fc2V0RGVmYXVsdEFwcGVhcmFuY2UoewogICAgICAgIHhyZWYsCiAgICAgICAgZXh0cmE6IGAke2JvcmRlcldpZHRofSB3YCwKICAgICAgICBzdHJva2VDb2xvciwKICAgICAgICBzdHJva2VBbHBoYSwKICAgICAgICBwb2ludHNDYWxsYmFjazogKGJ1ZmZlciwgcG9pbnRzKSA9PiB7CiAgICAgICAgICBjb25zdCB2ZXJ0aWNlcyA9IHRoaXMu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dGEuaW5rTGlzdHMpIHsKICAgICAgICBmb3IgKGNvbnN0IHZlcnRleCBvZiBpbmtMaXN0cykgewogICAgICAgICAgYmJveFswXSA9IE1hdGgubWluKGJib3hbMF0sIHZlcnRleC54IC0gYm9yZGVyQWRqdXN0KTsKICAgICAgICAgIGJib3hbMV0gPSBNYXRoLm1pbihiYm94WzFdLCB2ZXJ0ZXgueSAtIGJvcmRlckFkanVzdCk7CiAgICAgICAgICBiYm94WzJdID0gTWF0aC5tYXgoYmJveFsyXSwgdmVydGV4LnggKyBib3JkZXJBZGp1c3QpOwogICAgICAgICAgYmJveFszXSA9IE1hdGgubWF4KGJib3hbM10sIHZlcnRleC55ICsgYm9yZGVyQWRqdXN0KTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCFfdXRpbC5VdGlsLmludGVyc2VjdCh0aGlzLnJlY3RhbmdsZSwgYmJveCkpIHsKICAgICAgICB0aGlzLnJlY3RhbmdsZSA9IGJib3g7CiAgICAgIH0KICAgICAgdGhpcy5fc2V0RGVmYXVsdEFwcGVhcmFuY2UoewogICAgICAgIHhyZWYsCiAgICAgICAgZXh0cmE6IGAke2JvcmRlcldpZHRofSB3YCwKICAgICAgICBzdHJva2VDb2xvciwKICAgICAgICBzdHJva2VBbHBoYSwKICAgICAgICBwb2ludHNDYWxsYmFjazogKGJ1ZmZlciwgcG9pbnRzKSA9PiB7CiAgICAgICAgICBmb3IgKGNvbnN0IGlua0xpc3Qgb2YgdGhpcy5kYXRhLmlua0xpc3RzKSB7CiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGlua0xpc3QubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgIGJ1ZmZlci5wdXNoKGAke2lua0xpc3RbaV0ueH0gJHtpbmtMaXN0W2ldLnl9ICR7aSA9PT0gMCA/ICJtIiA6ICJsIn1gKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBidWZmZXIucHVzaCgiUyIpOwogICAgICAgICA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U5ld0FwcGVhcmFuY2VTdHJlYW0oYW5ub3RhdGlvbiwgeHJlZiwgcGFyYW1zKSB7CiAgICBjb25zdCB7CiAgICAgIGNvbG9yLAogICAgICByZWN0LAogICAgICByb3RhdGlvbiwKICAgICAgcGF0aHMsCiAgICAgIHRoaWNrbmVzcywKICAgICAgb3BhY2l0eQogICAgfSA9IGFubm90YXRpb247CiAgICBjb25zdCBbeDEsIHkxLCB4MiwgeTJdID0gcmVjdDsKICAgIGxldCB3ID0geDIgLSB4MTsKICAgIGxldCBoID0geTIgLSB5MTsKICAgIGlmIChyb3RhdGlvbiAlIDE4MCAhPT0gMCkgewogICAgICBbdywgaF0gPSBbaCwgd107CiAgICB9CiAgICBjb25zdCBhcHBlYXJhbmNlQnVmZmVyID0gW2Ake3RoaWNrbmVzc30gdyAxIEogMSBqYCwgYCR7KDAsIF9kZWZhdWx0X2FwcGVhcmFuY2UuZ2V0UGRmQ29sb3IpKGNvbG9yLCBmYWxzZSl9YF07CiAgICBpZiAob3BhY2l0eSAhPT0gMSkgewogICAgICBhcHBlYXJhbmNlQnVmZmVyLnB1c2goIi9SMCBncyIpOwogICAgfQogICAgY29uc3QgYnVmZmVyID0gW107CiAgICBmb3IgKGNvbnN0IHsKICAgICAgYmV6aWVyCiAgICB9IG9mIHBhdGhzKSB7CiAgICAgIGJ1ZmZlci5sZW5ndGggPSAwOwogICAgICBidWZmZXIucHVzaChgJHsoMCwgX2NvcmVfdXRpbHMubnVtYmVyVG9TdHJpbmcpKGJlemllclswXSl9ICR7KDAsIF9jb3JlX3V0aWxzLm51bWJlclRvU3RyaW5nKShiZXppZXJbMV0pfSBtYCk7CiAgICAgIGZvciAobGV0IGkgPSAyLCBpaSA9IGJlemllci5sZW5ndGg7IGkgPCBpaTsgaSArPSA2KSB7CiAgICAgICAgY29uc3QgY3VydmUgPSBiZXppZXIuc2xpY2UoaSwgaSArIDYpLm1hcChfY29yZV91dGlscy5udW1iZXJUb1N0cmluZykuam9pbigiICIpOwogIC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ydWN0b3IocGFyYW1zKSB7CiAgICBzdXBlcihwYXJhbXMpOwogICAgY29uc3QgewogICAgICBkaWN0LAogICAgICB4cmVmCiAgICB9ID0gcGFyYW1zOwogICAgdGhpcy5kYXRhLmFubm90YXRpb25UeXBlID0gX3V0aWwuQW5ub3RhdGlvblR5cGUuVU5ERVJMSU5FOwogICAgY29uc3QgcXVhZFBvaW50cyA9IHRoaXMuZGF0YS5xdWFkUG9pbnRzID0gZ2V0UXVhZFBvaW50cyhkaWN0LCBudWxsKTsKICAgIGlmIChxdWFkUG9pbnRzKSB7CiAgICAgIGlmICghdGhpcy5hcHBlYXJhbmNlKSB7CiAgICAgICAgY29uc3Qgc3Ryb2tlQ29sb3IgPSB0aGlzLmNvbG9yID8gZ2V0UGRmQ29sb3JBcnJheSh0aGlzLmNvbG9yKSA6IFswLCAwLCAwXTsKICAgICAgICBjb25zdCBzdHJva2VBbHBoYSA9IGRpY3QuZ2V0KCJDQSIpOwogICAgICAgIHRoaXMuX3NldERlZmF1bHRBcHBlYXJhbmNlKHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBleHRyYTogIltdIDAgZCAxIHciLAogICAgICAgICAgc3Ryb2tlQ29sb3IsCiAgICAgICAgICBzdHJva2VBbHBoYSwKICAgICAgICAgIHBvaW50c0NhbGxiYWNrOiAoYnVmZmVyLCBwb2ludHMpID0+IHsKICAgICAgICAgICAgYnVmZmVyLnB1c2goYCR7cG9pbnRzWzJdLnh9ICR7cG9pbnRzWzJdLnl9IG1gLCBgJHtwb2ludHNbM10ueH0gJHtwb2ludHNbM10ueX0gbGAsICJTIik7CiAgICAgICAgICAgIHJldHVybiBbcG9pbnRzWzBdLngsIHBvaW50c1sxXS54LCBwb2ludHNbM10ueSwgcG9pbnRzWzFdLnldOwogICAgICAgICAgfQogICAgICAgIH0pOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICB0aGlzLmRhdGEuaGFzUG9wdXAgPSBmYWxzZTsKICAgIH0KICB9Cn0KY2xhc3MgU3F1aWdnbHlBbm5vdGF0aW9uIGV4dGVuZHMgTWFya3VwQW5ub3RhdGlvbiB7CiAgY29uc3RydWN0b3IocGFyYW1zKSB7CiAgICBzdXBlcihwYXJhbXMpOwogICAgY29uc3QgewogICAgICBkaWN0LAogICAgICB4cmVmCiAgICB9ID0gcGFyYW1zOwogICAgdGhpcy5kYXRhLmFubm90YXRpb25UeXBlID0gX3V0aWwuQW5ub3RhdGlvblR5cGUuU1FVSUdHTFk7CiAgICBjb25zdCBxdWFkUG9pbnRzID0gdGhpcy5kYXRhLnF1YWRQb2ludHMgPSBnZXRRdWFkUG9pbnRzKGRpY3QsIG51bGwpOwogICAgaWYgKHF1YWRQb2ludHMpIHsKICAgICAgaWYgKCF0aGlzLmFwcGVhcmFuY2UpIHsKICAgICAgICBjb25zdCBzdHJva2VDb2xvciA9IHRoaXMuY29sb3IgPyBnZXRQZGZDb2xvckFycmF5KHRoaXMuY29sb3IpIDogWzAsIDAsIDBdOwogICAgICAgIGNvbnN0IHN0cm9rZUFscGhhID0gZGljdC5nZXQoIkNBIik7CiAgICAgICAgdGhpcy5fc2V0RGVmYXVsdEFwcGVhcmFuY2UoewogICAgICAgICAgeHJlZiwKICAgICAgICAgIGV4dHJhOiAiW10gMCBkIDEgdyIsCiAgICAgICAgICBzdHJva2VDb2xvciwKICAgICAgICAgIHN0cm9rZUFscGhhLAogICAgICAgICAgcG9pbnRzQ2FsbGJhY2s6IChidWZmZXIsIHBvaW50cykgPT4gewogICAgICAgICAgICBjb25zdCBkeSA9IChwb2ludHNbMF0ueSAtIHBvaW50c1syXS55KSAvIDY7CiAgICAgICAgICAgIGxldCBzaGlmdCA9IGR5OwogICAgICAgICAgICBsZXQgeCA9IHBvaW50c1syXS54OwogICAgICAgICAgICBjb25zdCB5ID0gcG9pbnRzWzJdLnk7CiAgICAgICAgICAgIGNvbnN0IHhFbmQgPSBwb2ludHNbM10ueDsKICAgICAgICAgICAgYnVmZmVyLnB1c2goYCR7eH0gJHt5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9jb3JlX3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMzkpOwp2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIpOwp2YXIgX2NvbG9yc3BhY2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0OCk7CnZhciBfZXZhbHVhdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDkpOwp2YXIgX3N0cmVhbSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQ0KTsKY2xhc3MgRGVmYXVsdEFwcGVhcmFuY2VFdmFsdWF0b3IgZXh0ZW5kcyBfZXZhbHVhdG9yLkV2YWx1YXRvclByZXByb2Nlc3NvciB7CiAgY29uc3RydWN0b3Ioc3RyKSB7CiAgICBzdXBlcihuZXcgX3N0cmVhbS5TdHJpbmdTdHJlYW0oc3RyKSk7CiAgfQogIHBhcnNlKCkgewogICAgY29uc3Qgb3BlcmF0aW9uID0gewogICAgICBmbjogMCwKICAgICAgYXJnczogW10KICAgIH07CiAgICBjb25zdCByZXN1bHQgPSB7CiAgICAgIGZvbnRTaXplOiAwLAogICAgICBmb250TmFtZTogIiIsCiAgICAgIGZvbnRDb2xvcjogbmV3IFVpbnQ4Q2xhbXBlZEFycmF5KDMpCiAgICB9OwogICAgdHJ5IHsKICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICBvcGVyYXRpb24uYXJncy5sZW5ndGggPSAwOwogICAgICAgIGlmICghdGhpcy5yZWFkKG9wZXJhdGlvbikpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBpZiAodGhpcy5zYXZlZFN0YXRlc0RlcHRoICE9PSAwKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgY29uc3QgewogICAgICAgICAgZm4sCiAgICAgICAgICBhcmdzCiAgICAgICAgfSA9IG9wZXJhdGlvbjsKICAgICAgICBzd2l0Y2ggKGZuIHwgMCkgewogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0Rm9udDoKICAgICAgICAgICAgY29uc3QgW2ZvbnROYW1lLCBmb250U2l6ZV0gPSBhcmdzOwogICAgICAgICAgICBpZiAoZm9udE5hbWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgcmVzdWx0LmZvbnROYW1lID0gZm9udE5hbWUubmFtZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodHlwZW9mIGZvbnRTaXplID09PSAibnVtYmVyIiAmJiBmb250U2l6ZSA+IDApIHsKICAgICAgICAgICAgICByZXN1bHQuZm9udFNpemUgPSBmb250U2l6ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZpbGxSR0JDb2xvcjoKICAgICAgICAgICAgX2NvbG9yc3BhY2UuQ29sb3JTcGFjZS5zaW5nbGV0b25zLnJnYi5nZXRSZ2JJdGVtKGFyZ3MsIDAsIHJlc3VsdC5mb250Q29sb3IsIDApOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZpbGxHcmF5OgogICAgICAgICAgICBfY29sb3JzcGFjZS5Db2xvclNwYWNlLnNpbmdsZXRvbnMuZ3JheS5nZXRSZ2JJdGVtKGFyZ3MsIDAsIHJlc3VsdC5mb250Q29sb3IsIDApOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZpbGxDb2xvclNwYWNlOgogICAgICAgICAgICBfY29sb3JzcGFjZS5Db2xvclNwYWNlLnNpbmdsZXRvbnMuY215ay5nZXRSZ2JJdGVtKGFyZ3MsIDAsIHJlc3VsdC5mb250Q29sb3IsIDApOwogICAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0KICAgIH0gY2F0Y2ggKHJlYXNvbikgewogICAgICAoMCwgX3V0aWwud2FybikoYHBhcnNlRGVmYXVsdEFwcGVhcmFuY2UgLSB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pIHsKICAgICAgbGluZXMucHVzaChsaW5lKTsKICAgICAgY29uc3QgbGluZVdpZHRoID0gY3R4Lm1lYXN1cmVUZXh0KGxpbmUpLndpZHRoOwogICAgICBtYXhXaWR0aCA9IE1hdGgubWF4KG1heFdpZHRoLCBsaW5lV2lkdGgpOwogICAgICBmb3IgKGNvbnN0IGNoYXIgb2YgbGluZS5zcGxpdCgiIikpIHsKICAgICAgICBjb25zdCBjb2RlID0gY2hhci5jaGFyQ29kZUF0KDApOwogICAgICAgIGxldCB3aWR0aCA9IHRoaXMud2lkdGhzLmdldChjb2RlKTsKICAgICAgICBpZiAod2lkdGggPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgY29uc3QgbWV0cmljcyA9IGN0eC5tZWFzdXJlVGV4dChjaGFyKTsKICAgICAgICAgIHdpZHRoID0gTWF0aC5jZWlsKG1ldHJpY3Mud2lkdGgpOwogICAgICAgICAgdGhpcy53aWR0aHMuc2V0KGNvZGUsIHdpZHRoKTsKICAgICAgICAgIHRoaXMuZmlyc3RDaGFyID0gTWF0aC5taW4oY29kZSwgdGhpcy5maXJzdENoYXIpOwogICAgICAgICAgdGhpcy5sYXN0Q2hhciA9IE1hdGgubWF4KGNvZGUsIHRoaXMubGFzdENoYXIpOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgbWF4V2lkdGggKj0gZm9udFNpemUgLyAxMDAwOwogICAgY29uc3QgW3gxLCB5MSwgeDIsIHkyXSA9IHJlY3Q7CiAgICBsZXQgdyA9IHgyIC0geDE7CiAgICBsZXQgaCA9IHkyIC0geTE7CiAgICBpZiAocm90YXRpb24gJSAxODAgIT09IDApIHsKICAgICAgW3csIGhdID0gW2gsIHddOwogICAgfQogICAgbGV0IGhzY2FsZSA9IDE7CiAgICBpZiAobWF4V2lkdGggPiB3KSB7CiAgICAgIGhzY2FsZSA9IHcgLyBtYXhXaWR0aDsKICAgIH0KICAgIGxldCB2c2NhbGUgPSAxOwogICAgY29uc3QgbGluZUhlaWdodCA9I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PCBjb3VudDsgKytpKSB7CiAgICAgICAgICBjb25zdCBrZXkgPSBjb21wc1tpXSAqIDM7CiAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBjb2xvck1hcFtrZXldOwogICAgICAgICAgZGVzdFtkZXN0UG9zKytdID0gY29sb3JNYXBba2V5ICsgMV07CiAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBjb2xvck1hcFtrZXkgKyAyXTsKICAgICAgICAgIGRlc3RQb3MgKz0gYWxwaGEwMTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcmdiQnVmID0gbmV3IFVpbnQ4QXJyYXkoY291bnQgKiAzKTsKICAgICAgICBsZXQgcmdiUG9zID0gMDsKICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGNvdW50OyArK2kpIHsKICAgICAgICAgIGNvbnN0IGtleSA9IGNvbXBzW2ldICogMzsKICAgICAgICAgIHJnYkJ1ZltyZ2JQb3MrK10gPSBjb2xvck1hcFtrZXldOwogICAgICAgICAgcmdiQnVmW3JnYlBvcysrXSA9IGNvbG9yTWFwW2tleSArIDFdOwogICAgICAgICAgcmdiQnVmW3JnYlBvcysrXSA9IGNvbG9yTWFwW2tleSArIDJdOwogICAgICAgIH0KICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgaWYgKCFuZWVkc1Jlc2l6aW5nKSB7CiAgICAgICAgdGhpcy5nZXRSZ2JCdWZmZXIoY29tcHMsIDAsIHdpZHRoICogYWN0dWFsSGVpZ2h0LCBkZXN0LCAwLCBicGMsIGFscGhhMDEpOwogICAgICB9IGVsc2UgewogICAgICAgIHJnYkJ1ZiA9IG5ldyBVaW50OENsYW1wZWRBcnJheShjb3VudCAqIDMpOwogICAgICAgIHRoaXMuZ2V0UmdiQnVmZmVyKGNvbXBzLCAwLCBjb3VudCwgcmdiQnVmLCAwLCBicGMsIDApOwogICAgICB9CiAgICB9CiAgICBpZiAocmdiQnVmKSB7CiAgICAgIGlmIChuZWVkc1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ucy5jbXlrOwogICAgICAgIGNhc2UgIlBhdHRlcm4iOgogICAgICAgICAgcmV0dXJuIG5ldyBQYXR0ZXJuQ1MobnVsbCk7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIGlmIChyZXNvdXJjZXMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgICAgICAgIGNvbnN0IGNvbG9yU3BhY2VzID0gcmVzb3VyY2VzLmdldCgiQ29sb3JTcGFjZSIpOwogICAgICAgICAgICBpZiAoY29sb3JTcGFjZXMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgICAgICAgICAgY29uc3QgcmVzb3VyY2VzQ1MgPSBjb2xvclNwYWNlcy5nZXQoY3MubmFtZSk7CiAgICAgICAgICAgICAgaWYgKHJlc291cmNlc0NTKSB7CiAgICAgICAgICAgICAgICBpZiAocmVzb3VyY2VzQ1MgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9wYXJzZShyZXNvdXJjZXNDUywgeHJlZiwgcmVzb3VyY2VzLCBwZGZGdW5jdGlvbkZhY3RvcnkpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY3MgPSByZXNvdXJjZXNDUzsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBVbnJlY29nbml6ZWQgQ29sb3JTcGFjZTogJHtjcy5uYW1lfWApOwogICAgICB9CiAgICB9CiAgICBpZiAoQXJyYXkuaXNBcnJheShjcykpIHsKICAgICAgY29uc3QgbW9kZSA9IHhyZWYuZmV0Y2hJZlJlZihjc1swXSkubmFtZTsKICAgICAgbGV0IHBhcmFtcywgbnVtQ29tcHMsIGJhc2VDUywgd2hpdGVQb2ludCwgYmxhY2tQb2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ICAgIHJldHVybiBuZXcgQ2FsUkdCQ1Mod2hpdGVQb2ludCwgYmxhY2tQb2ludCwgZ2FtbWEsIG1hdHJpeCk7CiAgICAgICAgY2FzZSAiSUNDQmFzZWQiOgogICAgICAgICAgY29uc3Qgc3RyZWFtID0geHJlZi5mZXRjaElmUmVmKGNzWzFdKTsKICAgICAgICAgIGNvbnN0IGRpY3QgPSBzdHJlYW0uZGljdDsKICAgICAgICAgIG51bUNvbXBzID0gZGljdC5nZXQoIk4iKTsKICAgICAgICAgIGNvbnN0IGFsdCA9IGRpY3QuZ2V0KCJBbHRlcm5hdGUiKTsKICAgICAgICAgIGlmIChhbHQpIHsKICAgICAgICAgICAgY29uc3QgYWx0Q1MgPSB0aGlzLl9wYXJzZShhbHQsIHhyZWYsIHJlc291cmNlcywgcGRmRnVuY3Rpb25GYWN0b3J5KTsKICAgICAgICAgICAgaWYgKGFsdENTLm51bUNvbXBzID09PSBudW1Db21wcykgewogICAgICAgICAgICAgIHJldHVybiBhbHRDUzsKICAgICAgICAgICAgfQogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIklDQ0Jhc2VkIGNvbG9yIHNwYWNlOiBJZ25vcmluZyBpbmNvcnJlY3QgL0FsdGVybmF0ZSBlbnRyeS4iKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChudW1Db21wcyA9PT0gMSkgewogICAgICAgICAgICByZXR1cm4gdGhpcy5zaW5nbGV0b25zLmdyYXk7CiAgICAgICAgICB9IGVsc2UgaWYgKG51bUNvbXBzID09PSAzKSB7CiAgICAgICAgICAgIHJldHVybiB0aGlzLnNpbmdsZXRvbnMucmdiOwogICAgICAgICAgfSBlbHNlIGlmIChudW1Db21wcyA9PT0gNCkgewogICAgICAgICAgICByZXR1cm4gdGhpcy5zaW5nbGV0b25zLmNteWs7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJQYXR0ZXJuIjoKICAgICAgICAgIGJhc2VDUyA9IGNzWzFdIHx8I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ICAgIGNhc2UgIk11bHRpcGx5IjoKICAgICAgcmV0dXJuICJtdWx0aXBseSI7CiAgICBjYXNlICJTY3JlZW4iOgogICAgICByZXR1cm4gInNjcmVlbiI7CiAgICBjYXNlICJPdmVybGF5IjoKICAgICAgcmV0dXJuICJvdmVybGF5IjsKICAgIGNhc2UgIkRhcmtlbiI6CiAgICAgIHJldHVybiAiZGFya2VuIjsKICAgIGNhc2UgIkxpZ2h0ZW4iOgogICAgICByZXR1cm4gImxpZ2h0ZW4iOwogICAgY2FzZSAiQ29sb3JEb2RnZSI6CiAgICAgIHJldHVybiAiY29sb3ItZG9kZ2UiOwogICAgY2FzZSAiQ29sb3JCdXJuIjoKICAgICAgcmV0dXJuICJjb2xvci1idXJuIjsKICAgIGNhc2UgIkhhcmRMaWdodCI6CiAgICAgIHJldHVybiAiaGFyZC1saWdodCI7CiAgICBjYXNlICJTb2Z0TGlnaHQiOgogICAgICByZXR1cm4gInNvZnQtbGlnaHQiOwogICAgY2FzZSAiRGlmZmVyZW5jZSI6CiAgICAgIHJldHVybiAiZGlmZmVyZW5jZSI7CiAgICBjYXNlICJFeGNsdXNpb24iOgogICAgICByZXR1cm4gImV4Y2x1c2lvbiI7CiAgICBjYXNlICJIdWUiOgogICAgICByZXR1cm4gImh1ZSI7CiAgICBjYXNlICJTYXR1cmF0aW9uIjoKICAgICAgcmV0dXJuICJzYXR1cmF0aW9uIjsKICAgIGNhc2UgIkNvbG9yIjoKICAgICAgcmV0dXJuICJjb2xvciI7CiAgICBjYXNlICJMdW1pbm9zaXR5IjoKICAgICAgcmV0dXJuICJsdW1pbm9zaXR5IjsKICB9CiAgaWYgKHBhcnNpbmdBcnJheSkgewogICAgcmV0dXJuIG51bGw7CiAgfQogICgwLCBfdXRpbC53YXJuKShgVW5zdXBwb3J0ZWQgYmxlbmQgbW9kZTogJHt2YWx1ZS5uYW1lfWApOwogIHJldHVybiAic291cmNlLW92ZXIiOwp9CmZ1bmN0aW9uIGluY3JlbWVudENhY2h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9kZXMubGVuZ3RoKSB7CiAgICAgIGNvbnN0IG5vZGUgPSBub2Rlcy5zaGlmdCgpOwogICAgICBjb25zdCBncmFwaGljU3RhdGVzID0gbm9kZS5nZXQoIkV4dEdTdGF0ZSIpOwogICAgICBpZiAoZ3JhcGhpY1N0YXRlcyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgICBmb3IgKGxldCBncmFwaGljU3RhdGUgb2YgZ3JhcGhpY1N0YXRlcy5nZXRSYXdWYWx1ZXMoKSkgewogICAgICAgICAgaWYgKGdyYXBoaWNTdGF0ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICBpZiAocHJvY2Vzc2VkLmhhcyhncmFwaGljU3RhdGUpKSB7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICBncmFwaGljU3RhdGUgPSB4cmVmLmZldGNoKGdyYXBoaWNTdGF0ZSk7CiAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgcHJvY2Vzc2VkLnB1dChncmFwaGljU3RhdGUpOwogICAgICAgICAgICAgICgwLCBfdXRpbC5pbmZvKShgaGFzQmxlbmRNb2RlcyAtIGlnbm9yaW5nIEV4dEdTdGF0ZTogIiR7ZXh9Ii5gKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKCEoZ3JhcGhpY1N0YXRlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoZ3JhcGhpY1N0YXRlLm9iaklkKSB7CiAgICAgICAgICAgIHByb2Nlc3NlZC5wdXQoZ3JhcGhpY1N0YXRlLm9iaklkKTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IGJtID0gZ3JhcGhpY1N0YXRlLmdldCgiQk0iKTsKICAgICAgICAgIGlmIChibSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgaWYgKGJtLm5hbWUgIT09ICJOb3JtYWwiKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYm0gIT09IHVuZGVmaW5lZCAmJiBBcnJheS5pc0FycmF5KGJtKSkgewogICAgICAgICAgICBmb3IgKGNvbnN0IGVsZW1lbnQgb2YgYm0pIHsKICAgICAgICAgICAgICBpZiAoZWxlbWVudCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUgJiYgZWxlbWVudC5uYW1lICE9PSAiTm9ybWFsIikgewogICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIGNvbnN0IHhPYmplY3RzID0gbm9kZS5nZXQoIlhPYmplY3QiKTsKICAgICAgaWYgKCEoeE9iamVjdHMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGZvciAobGV0IHhPYmplY3Qgb2YgeE9iamVjdHMuZ2V0UmF3VmFsdWVzKCkpIHsKICAgICAgICBpZiAoeE9iamVjdCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgaWYgKHByb2Nlc3NlZC5oYXMoeE9iamVjdCkpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICB0cnkgewogICAgICAgICAgICB4T2JqZWN0ID0geHJlZi5mZXRjaCh4T2JqZWN0KTsKICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgIHByb2Nlc3NlZC5wdXQoeE9iamVjdCk7CiAgICAgICAgICAgICgwLCBfdXRpbC5pbmZvKShgaGFzQmxlbmRNb2RlcyAtIGlnbm9yaW5nIFhPYmplY3Q6ICIke2V4fSIuYCk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoISh4T2JqZWN0IGluc3RhbmNlb2YgX2Jhc2Vfc3RyZWFtLkJhc2VTdHJlYW0pKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYgKHhPYmplY3QuZGljdC5vYmpJZCkgewogICAgICAgICAgcHJvY2Vzc2VkLnB1dCh4T2JqZWN0LmRpY3Qub2JqSWQpOwogICAgICAgIH0KICAgICAgICBjb25zdCB4UmVzb3VyY2VzID0geE9iamVjdC5kaWN0LmdldCgiUmVzb3VyY2VzIik7CiAgICAgICAgaWYgKCEoeFJlc291cmNlcyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYgKHhSZXNvdXJjZXMub2JqSWQgJiYgcHJvY2Vzc2VkLmhhcyh4UmVzb3VyY2VzLm9iaklkKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIG5vZGVzLnB1c2goeFJlc291cmNlcyk7CiAgICAgICAgaWYgKHhSZXNvdXJjZXMub2JqSWQpIHsKICAgICAgICAgIHByb2Nlc3NlZC5wdXQoeFJlc291cmNlcy5vYmpJZCk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBmb3IgKGNvbnN0IHJlZiBvZiBwcm9jZXNzZWQpIHsKICAgICAgbm9uQmxlbmRNb2Rlc1NldC5wdXQocmVmKTsKICAgIH0KICAgIHJldHVybiBmYWxzZTsKICB9CiAgYXN5bmMgZmV0Y2hCdWlsdEluQ01hcChuYW1lKSB7CiAgICBjb25zdCBjYWNoZWREYXRhID0gdGhpcy5idWlsdEluQ01hcENhY2h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pcy5wYXJzZUNvbG9yU3BhY2UoewogICAgICAgICAgICAgIGNzLAogICAgICAgICAgICAgIHJlc291cmNlcywKICAgICAgICAgICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKHNtYXNrICYmIHNtYXNrLmJhY2tkcm9wKSB7CiAgICAgICAgY29sb3JTcGFjZSA9IGNvbG9yU3BhY2UgfHwgX2NvbG9yc3BhY2UuQ29sb3JTcGFjZS5zaW5nbGV0b25zLnJnYjsKICAgICAgICBzbWFzay5iYWNrZHJvcCA9IGNvbG9yU3BhY2UuZ2V0UmdiKHNtYXNrLmJhY2tkcm9wLCAwKTsKICAgICAgfQogICAgICBvcGVyYXRvckxpc3QuYWRkT3AoX3V0aWwuT1BTLmJlZ2luR3JvdXAsIFtncm91cE9wdGlvbnNdKTsKICAgIH0KICAgIGNvbnN0IGFyZ3MgPSBncm91cCA/IFttYXRyaXgsIG51bGxdIDogW21hdHJpeCwgYmJveF07CiAgICBvcGVyYXRvckxpc3QuYWRkT3AoX3V0aWwuT1BTLnBhaW50Rm9ybVhPYmplY3RCZWdpbiwgYXJncyk7CiAgICByZXR1cm4gdGhpcy5nZXRPcGVyYXRvckxpc3QoewogICAgICBzdHJlYW06IHhvYmosCiAgICAgIHRhc2ssCiAgICAgIHJlc291cmNlczogZGljdC5nZXQoIlJlc291cmNlcyIpIHx8IHJlc291cmNlcywKICAgICAgb3BlcmF0b3JMaXN0LAogICAgICBpbml0aWFsU3RhdGUKICAgIH0pLnRoZW4oZnVuY3Rpb24gKCkgewogICAgICBvcGVyYXRvckxpc3QuYWRkT3AoX3V0aWwuT1BTLnBhaW50Rm9ybVhPYmplY3RFbmQsIFtdKTsKICAgICAgaWYgKGdyb3VwKSB7CiAgICAgICAgb3BlcmF0b3JMaXN0LmFkZE9wKF91dGlsLk9QUy5lbmRHcm91cCwgW2dyb3VwT3B0aW9uc10pOwog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RlID0gZGljdC5nZXQoIkkiLCAiSW50ZXJwb2xhdGUiKTsKICAgICAgY29uc3QgYml0U3RyaWRlTGVuZ3RoID0gdyArIDcgPj4gMzsKICAgICAgY29uc3QgaW1nQXJyYXkgPSBpbWFnZS5nZXRCeXRlcyhiaXRTdHJpZGVMZW5ndGggKiBoKTsKICAgICAgY29uc3QgZGVjb2RlID0gZGljdC5nZXRBcnJheSgiRCIsICJEZWNvZGUiKTsKICAgICAgaWYgKHRoaXMucGFyc2luZ1R5cGUzRm9udCkgewogICAgICAgIGltZ0RhdGEgPSBfaW1hZ2UuUERGSW1hZ2UuY3JlYXRlUmF3TWFzayh7CiAgICAgICAgICBpbWdBcnJheSwKICAgICAgICAgIHdpZHRoOiB3LAogICAgICAgICAgaGVpZ2h0OiBoLAogICAgICAgICAgaW1hZ2VJc0Zyb21EZWNvZGVTdHJlYW06IGltYWdlIGluc3RhbmNlb2YgX2RlY29kZV9zdHJlYW0uRGVjb2RlU3RyZWFtLAogICAgICAgICAgaW52ZXJzZURlY29kZTogISFkZWNvZGUgJiYgZGVjb2RlWzBdID4gMCwKICAgICAgICAgIGludGVycG9sYXRlCiAgICAgICAgfSk7CiAgICAgICAgaW1nRGF0YS5jYWNoZWQgPSAhIWNhY2hlS2V5OwogICAgICAgIGFyZ3MgPSBbaW1nRGF0YV07CiAgICAgICAgb3BlcmF0b3JMaXN0LmFkZEltYWdlT3BzKF91dGlsLk9QUy5wYWludEltYWdlTWFza1hPYmplY3QsIGFyZ3MsIG9wdGlvbmFsQ29udGVudCk7CiAgICAgICAgaWYgKGNhY2hlS2V5KSB7CiAgICAgICAgICBsb2NhbEltYWdlQ2FjaGUuc2V0KGNhY2hlS2V5LCBpbWFnZVJlZiwgewogICAgICAgICAgICBmbjogX3V0aWwuT1BTLnBhaW50SW1hZ2VNYXNrWE9iamVjdCwKICAgICAgICAgICAgYXJncywKICAgICAgICAgICAgb3B0aW9uYWxDb250ZW50CiAgICAgICAgICB9KTsKICAgICAgICB9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AobG9hZGVkTmFtZSkgewogICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGREZXBlbmRlbmN5KGxvYWRlZE5hbWUpOwogICAgICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIFtsb2FkZWROYW1lLCB2YWx1ZVsxXV1dKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkJNIjoKICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIG5vcm1hbGl6ZUJsZW5kTW9kZSh2YWx1ZSldKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIlNNYXNrIjoKICAgICAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKSh2YWx1ZSwgIk5vbmUiKSkgewogICAgICAgICAgICBnU3RhdGVPYmoucHVzaChba2V5LCBmYWxzZV0pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgICAgICAgaXNTaW1wbGVHU3RhdGUgPSBmYWxzZTsKICAgICAgICAgICAgcHJvbWlzZSA9IHByb21pc2UudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuaGFuZGxlU01hc2sodmFsdWUsIHJlc291cmNlcywgb3BlcmF0b3JMaXN0LCB0YXNrLCBzdGF0ZU1hbmFnZXIsIGxvY2FsQ29sb3JTcGFjZUNhY2hlKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIHRydWVdKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5zdXBwb3J0ZWQgU01hc2sgdHlwZSIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiVFIiOgogICAg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UsIGZvbnQsIHJlc291cmNlcykgewogICAgbGV0IGZhbGxiYWNrRm9udERpY3QgPSBhcmd1bWVudHMubGVuZ3RoID4gMyAmJiBhcmd1bWVudHNbM10gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1szXSA6IG51bGw7CiAgICBsZXQgY3NzRm9udEluZm8gPSBhcmd1bWVudHMubGVuZ3RoID4gNCAmJiBhcmd1bWVudHNbNF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1s0XSA6IG51bGw7CiAgICBjb25zdCBlcnJvckZvbnQgPSBhc3luYyAoKSA9PiB7CiAgICAgIHJldHVybiBuZXcgVHJhbnNsYXRlZEZvbnQoewogICAgICAgIGxvYWRlZE5hbWU6ICJnX2ZvbnRfZXJyb3IiLAogICAgICAgIGZvbnQ6IG5ldyBfZm9udHMuRXJyb3JGb250KGBGb250ICIke2ZvbnROYW1lfSIgaXMgbm90IGF2YWlsYWJsZS5gKSwKICAgICAgICBkaWN0OiBmb250LAogICAgICAgIGV2YWx1YXRvck9wdGlvbnM6IHRoaXMub3B0aW9ucwogICAgICB9KTsKICAgIH07CiAgICBjb25zdCB4cmVmID0gdGhpcy54cmVmOwogICAgbGV0IGZvbnRSZWY7CiAgICBpZiAoZm9udCkgewogICAgICBpZiAoZm9udCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIGZvbnRSZWYgPSBmb250OwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBmb250UmVzID0gcmVzb3VyY2VzLmdldCgiRm9udCIpOwogICAgICBpZiAoZm9udFJlcykgewogICAgICAgIGZvbnRSZWYgPSBmb250UmVzLmdldFJhdyhmb250TmFtZSk7CiAgICAgIH0KICAgIH0KICAgIGlmICghZm9udFJlZikgewogICAgICBjb25zdCBwYXJ0aWFsTXNnID0gYEZvbnQgIiR7Zm9udE5hbWUgfHwgZm9udCAmJiBmb250LnRvU3RyaW5nKCl9IiBpcyBub3QgYXZhaWxhYmxl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WN0UGF0aCwgW1tmbl0sIGFyZ3MsIG1pbk1heF0pOwogICAgICBpZiAocGFyc2luZ1RleHQpIHsKICAgICAgICBvcGVyYXRvckxpc3QuYWRkT3AoX3V0aWwuT1BTLnJlc3RvcmUsIG51bGwpOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBvcEFyZ3MgPSBvcGVyYXRvckxpc3QuYXJnc0FycmF5W2xhc3RJbmRleF07CiAgICAgIG9wQXJnc1swXS5wdXNoKGZuKTsKICAgICAgb3BBcmdzWzFdLnB1c2goLi4uYXJncyk7CiAgICAgIGNvbnN0IG1pbk1heCA9IG9wQXJnc1syXTsKICAgICAgc3dpdGNoIChmbikgewogICAgICAgIGNhc2UgX3V0aWwuT1BTLnJlY3RhbmdsZToKICAgICAgICAgIGNvbnN0IHggPSBhcmdzWzBdICsgYXJnc1syXTsKICAgICAgICAgIGNvbnN0IHkgPSBhcmdzWzFdICsgYXJnc1szXTsKICAgICAgICAgIG1pbk1heFswXSA9IE1hdGgubWluKG1pbk1heFswXSwgYXJnc1swXSwgeCk7CiAgICAgICAgICBtaW5NYXhbMV0gPSBNYXRoLm1heChtaW5NYXhbMV0sIGFyZ3NbMF0sIHgpOwogICAgICAgICAgbWluTWF4WzJdID0gTWF0aC5taW4obWluTWF4WzJdLCBhcmdzWzFdLCB5KTsKICAgICAgICAgIG1pbk1heFszXSA9IE1hdGgubWF4KG1pbk1heFszXSwgYXJnc1sxXSwgeSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIF91dGlsLk9QUy5tb3ZlVG86CiAgICAgICAgY2FzZSBfdXRpbC5PUFMubGluZVRvOgogICAgICAgICAgbWluTWF4WzBdID0gTWF0aC5taW4obWluTWF4WzBdLCBhcmdzWzBdKTsKICAgICAgICAgIG1pbk1heFsxXSA9IE1hdGgubWF4KG1pbk1heFsxXSwgYXJnc1swXSk7CiAgICAgICAgICBtaW5NYXhbMl0gPSBNYXRoLm1pbihtaW5NYXhbMl0sIGFyZ3NbMV0pOwogICAgICAgICAgbWluTWF4WzNdID0gTWF0aC5tYXgobWluTWF4WzNdLCBhcmdzWzFdKTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgfQogIHBhcnNlQ29sb3JTcGFjZShfcmVmNCkgewogICAgbGV0IHsKICAgICAgY3MsCiAgICAgIHJlc291cmNlcywKICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUKICAgIH0gPSBfcmVmNDsKICAgIHJldHVybiBfY29sb3JzcGFjZS5Db2xvclNwYWNlLnBhcnNlQXN5bmMoewogICAgICBjcywKICAgICAgeHJlZjogdGhpcy54cmVmLAogICAgICByZXNvdXJjZXMsCiAgICAgIHBkZkZ1bmN0aW9uRmFjdG9yeTogdGhpcy5fcGRmRnVuY3Rpb25GYWN0b3J5LAogICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgfSkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0KICAgICAgaWYgKHRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhcnNlQ29sb3JTcGFjZSAtIGlnbm9yaW5nIENvbG9yU3BhY2U6ICIke3JlYXNvbn0iLmApOwogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAgIHRocm93IHJlYXNvbjsKICAgIH0pOwogIH0KICBwYXJzZVNoYWRpbmcoX3JlZjUpIHsKICAgIGxldCB7CiAgICAgIHNoYWRpbmcsCiAgICAgIHJlc291cmNlcywKICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUsCiAgICAgIGxvY2FsU2hhZGluZ1BhdHRlcm5DYWNoZQogICAgfSA9IF9yZWY1OwogICAgbGV0IGlkID0gbG9jYWxTaGFkaW5nUGF0dGVybkNhY2hlLmdldChzaGFk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bmVzdGVkUmVzdWx0ID0gW107CiAgICAgICAgY3VycmVudFJlc3VsdC5wdXNoKG5lc3RlZFJlc3VsdCk7CiAgICAgICAgdGhpcy5fcGFyc2VWaXNpYmlsaXR5RXhwcmVzc2lvbihvYmplY3QsIG5lc3RpbmdDb3VudGVyLCBuZXN0ZWRSZXN1bHQpOwogICAgICB9IGVsc2UgaWYgKHJhdyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIGN1cnJlbnRSZXN1bHQucHVzaChyYXcudG9TdHJpbmcoKSk7CiAgICAgIH0KICAgIH0KICB9CiAgYXN5bmMgcGFyc2VNYXJrZWRDb250ZW50UHJvcHMoY29udGVudFByb3BlcnRpZXMsIHJlc291cmNlcykgewogICAgbGV0IG9wdGlvbmFsQ29udGVudDsKICAgIGlmIChjb250ZW50UHJvcGVydGllcyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgY29uc3QgcHJvcGVydGllcyA9IHJlc291cmNlcy5nZXQoIlByb3BlcnRpZXMiKTsKICAgICAgb3B0aW9uYWxDb250ZW50ID0gcHJvcGVydGllcy5nZXQoY29udGVudFByb3BlcnRpZXMubmFtZSk7CiAgICB9IGVsc2UgaWYgKGNvbnRlbnRQcm9wZXJ0aWVzIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICBvcHRpb25hbENvbnRlbnQgPSBjb250ZW50UHJvcGVydGllczsKICAgIH0gZWxzZSB7CiAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiT3B0aW9uYWwgY29udGVudCBwcm9wZXJ0aWVzIG1hbGZvcm1lZC4iKTsKICAgIH0KICAgIGNvbnN0IG9wdGlvbmFsQ29udGVudFR5cGUgPSBvcHRpb25hbENvbnRlbnQuZ2V0KCJUeXBlIikubmFtZTsKICAgIGlmIChvcHRpb25hbENvbnRlbnRUeXBlID09PSAiT0NHIikgewogICAgICByZXR1cm4gewogICAgICAgIHR5cGU6IG9wdGlvbmFsQ29udGVudFR5cGUsCiAgICAgICAgaWQ6IG9wdGlvbmFsQ29udGVudC5vYmpJZAogICAgICB9OwogICAgfSBlbHNlIGlmIChvcHRpb25hbENvbnRlbnRUeXBlID09PSAiT0NNRCIpIHsKICAgICAgY29uc3QgZXhwcmVzc2lvbiA9IG9wdGlvbmFsQ29udGVudC5nZXQoIlZFIik7CiAgICAgIGlmIChBcnJheS5pc0FycmF5KGV4cHJlc3Npb24pKSB7CiAgICAgICAgY29uc3QgcmVzdWx0ID0gW107CiAgICAgICAgdGhpcy5fcGFyc2VWaXNpYmlsaXR5RXhwcmVzc2lvbihleHByZXNzaW9uLCAwLCByZXN1bHQpOwogICAgICAgIGlmIChyZXN1bHQubGVuZ3RoID4gMCkgewogICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgdHlwZTogIk9DTUQiLAogICAgICAgICAgICBleHByZXNzaW9uOiByZXN1bHQKICAgICAgICAgIH07CiAgICAgICAgfQogICAgICB9CiAgICAgIGNvbnN0IG9wdGlvbmFsQ29udGVudEdyb3VwcyA9IG9wdGlvbmFsQ29udGVudC5nZXQoIk9DR3MiKTsKICAgICAgaWYgKEFycmF5LmlzQXJyYXkob3B0aW9uYWxDb250ZW50R3JvdXBzKSB8fCBvcHRpb25hbENvbnRlbnRHcm91cHMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgICAgY29uc3QgZ3JvdXBJZHMgPSBbXTsKICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShvcHRpb25hbENvbnRlbnRHcm91cHMpKSB7CiAgICAgICAgICBmb3IgKGNvbnN0IG9jZyBvZiBvcHRpb25hbENvbnRlbnRHcm91cHMpIHsKICAgICAgICAgICAgZ3JvdXBJZHMucHVzaChvY2cudG9TdHJpbmcoKSk7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGdyb3VwSWRzLnB1c2gob3B0aW9uYWxDb250Z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dpdGNoIChmbiB8IDApIHsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnBhaW50WE9iamVjdDoKICAgICAgICAgICAgaXNWYWxpZE5hbWUgPSBhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZTsKICAgICAgICAgICAgbmFtZSA9IGFyZ3NbMF0ubmFtZTsKICAgICAgICAgICAgaWYgKGlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgY29uc3QgbG9jYWxJbWFnZSA9IGxvY2FsSW1hZ2VDYWNoZS5nZXRCeU5hbWUobmFtZSk7CiAgICAgICAgICAgICAgaWYgKGxvY2FsSW1hZ2UpIHsKICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRJbWFnZU9wcyhsb2NhbEltYWdlLmZuLCBsb2NhbEltYWdlLmFyZ3MsIGxvY2FsSW1hZ2Uub3B0aW9uYWxDb250ZW50KTsKICAgICAgICAgICAgICAgIGluY3JlbWVudENhY2hlZEltYWdlTWFza0NvdW50KGxvY2FsSW1hZ2UpOwogICAgICAgICAgICAgICAgYXJncyA9IG51bGw7CiAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbmV4dChuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZVhPYmplY3QsIHJlamVjdFhPYmplY3QpIHsKICAgICAgICAgICAgICBpZiAoIWlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlhPYmplY3QgbXVzdCBiZSByZWZlcnJlZCB0byBieSBuYW1lLiIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBsZXQgeG9iaiA9IHhvYmpzLmdldFJhdyhuYW1lKTsKICAgICAgICAgICAgICBpZiAoeG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICAgICAgY29uc3QgbG9jYWxJbWFnZSA9IGxvY2FsSW1hZ2VDYWNoZS5nZXRCeVJlZih4b2JqKTsKICAgICAgICAgICAgICAgIGlmIChsb2NhbEltYWdlKSB7CiAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRJbWFnZU9wcyhsb2NhbEltYWdlLmZuLCBsb2NhbEltYWdlLmFyZ3MsIGxvY2FsSW1hZ2Uub3B0aW9uYWxDb250ZW50KTsKICAgICAgICAgICAgICAgICAgaW5jcmVtZW50Q2FjaGVkSW1hZ2VNYXNrQ291bnQobG9jYWxJbWFnZSk7CiAgICAgICAgICAgICAgICAgIHJlc29sdmVYT2JqZWN0KCk7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbnN0IGdsb2JhbEltYWdlID0gc2VsZi5nbG9iYWxJbWFnZUNhY2hlLmdldERhdGEoeG9iaiwgc2VsZi5wYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgaWYgKGdsb2JhbEltYWdlKSB7CiAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGREZXBlbmRlbmN5KGdsb2JhbEltYWdlLm9iaklkKTsKICAgICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZEltYWdlT3BzKGdsb2JhbEltYWdlLmZuLCBnbG9iYWxJbWFnZS5hcmdzLCBnbG9iYWxJbWFnZS5vcHRpb25hbENvbnRlbnQpOwogICAgICAgICAgICAgICAgICByZXNvbHZlWE9iamVjdCgpOwogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB4b2JqID0geHJlZi5mZXRjaCh4b2JqKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKCEoeG9iaiBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSkgewogICAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJYT2JqZWN0IHNob3VsZCBiZSBhIHN0cmVhbSIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb25zdCB0eXBlID0geG9iai5kaWN0LmdldCgiU3VidHlwZSIpOwogICAgICAgICAgICAgIGlmICghKHR5cGUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSkgewogICAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJYT2JqZWN0IHNob3VsZCBoYXZlIGEgTmFtZSBzdWJ0eXBlIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmICh0eXBlLm5hbWUgPT09ICJGb3JtIikgewogICAgICAgICAgICAgICAgc3RhdGVNYW5hZ2VyLnNhdmUoKTsKICAgICAgICAgICAgICAgIHNlbGYuYnVpbGRGb3JtWE9iamVjdChyZXNvdXJjZXMsIHhvYmosIG51bGwsIG9wZXJhdG9yTGlzdCwgdGFzaywgc3RhdGVNYW5hZ2VyLnN0YXRlLmNsb25lKCksIGxvY2FsQ29sb3JTcGFjZUNhY2hlKS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgc3RhdGVNYW5hZ2VyLnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgIH0sIHJlamVjdFhPYmplY3QpOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZS5uYW1lID09PSAiSW1hZ2UiKSB7CiAgICAgICAgICAgICAgICBzZWxmLmJ1aWxkUGFpbnRJbWFnZVhPYmplY3QoewogICAgICAgICAgICAgICAgICByZXNvdXJjZXMsCiAgICAgICAgICAgICAgICAgIGltYWdlOiB4b2JqLAogICAgICAgICAgICAgICAgICBvcGVyYXRvckxpc3QsCiAgICAgICAgICAgICAgICAgIGNhY2hlS2V5OiBuYW1lLAogICAgICAgICAgICAgICAgICBsb2NhbEltYWdlQ2FjaGUsCiAgICAgICAgICAgICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgICAgICAgICAgICB9KS50aGVuKHJlc29sdmVYT2JqZWN0LCByZWplY3RYT2JqZWN0KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGUubmFtZSA9PT0gIlBTIikgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJJZ25vcmVkIFhPYmplY3Qgc3VidHlwZSBQUyIpOwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYFVuaGFuZGxlZCBYT2JqZWN0IHN1YnR5cGUgJHt0eXBlLm5hbWV9YCk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHJlc29sdmVYT2JqZWN0KCk7CiAgICAgICAgICAgIH0pLmNhdGNoKGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICBpZiAocmVhc29uIGluc3RhbmNlb2YgX3V0aWwuQWJvcnRFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHNlbGYub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0T3BlcmF0b3JMaXN0IC0gaWdub3JpbmcgWE9iamVjdDogIiR7cmVhc29ufSIuYCk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHRocm93IHJlYXNvbjsKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRGb250OgogICAgICAgICAgICB2YXIgZm9udFNpemUgPSBhcmdzWzFdOwogICAgICAgICAgICBuZXh0KHNlbGYuaGFuZGxlU2V0Rm9udChyZXNvdXJjZXMsIGFyZ3MsIG51bGwsIG9wZXJhdG9yTGlzdCwgdGFzaywgc3RhdGVNYW5hZ2VyLnN0YXRlLCBmYWxsYmFja0ZvbnREaWN0KS50aGVuKGZ1bmN0aW9uIChsb2FkZWROYW1lKSB7CiAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZERlcGVuZGVuY3kobG9hZGVkTmFtZSk7CiAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZE9wKF91dGlsLk9QUy5zZXRGb250LCBbbG9hZGVkTmFtZSwgZm9udFNpemVdKTsKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5iZWdpblRleHQ6CiAgICAgICAgICAgIHBhcnNpbmdUZXh0ID0gdHJ1ZTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5lbmRUZXh0OgogICAgICAgICAgICBwYXJzaW5nVGV4dCA9IGZhbHNlOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmVuZElubGluZUltYWdlOgogICAgICAgICAgICB2YXIgY2FjaGVLZXkgPSBhcmdzWzBdLmNhY2hlS2V5OwogICAgICAgICAgICBpZiAoY2FjaGVLZXkpIHsKICAgICAgICAgICAgICBjb25zdCBsb2NhbEltYWdlID0gbG9jYWxJbWFnZUNhY2hlLmdldEJ5TmFtZShjYWNoZUtleSk7CiAgICAgICAgICAgICAgaWYgKGxvY2FsSW1hZ2UpIHsKICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRJbWFnZU9wcyhsb2NhbEltYWdlLmZuLCBsb2NhbEltYWdlLmFyZ3MsIGxvY2FsSW1hZ2Uub3B0aW9uYWxDb250ZW50KTsKICAgICAgICAgICAgICAgIGluY3JlbWVudENhY2hlZEltYWdlTWFza0NvdW50KGxvY2FsSW1hZ2UpOwogICAgICAgICAgICAgICAgYXJncyA9IG51bGw7CiAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbmV4dChzZWxmLmJ1aWxkUGFpbnRJbWFnZVhPYmplY3QoewogICAgICAgICAgICAgIHJlc291cmNlcywKICAgICAgICAgICAgICBpbWFnZTogYXJnc1swXSwKICAgICAgICAgICAgICBpc0lubGluZTogdHJ1ZSwKICAgICAgICAgICAgICBvcGVyYXRvckxpc3QsCiAgICAgICAgICAgICAgY2FjaGVLZXksCiAgICAgICAgICAgICAgbG9jYWxJbWFnZUNhY2hlLAogICAgICAgICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2hvd1RleHQ6CiAgICAgICAgICAgIGlmICghc3RhdGVNYW5hZ2VyLnN0YXRlLmZvbnQpIHsKICAgICAgICAgICAgICBzZWxmLmVuc3VyZVN0YXRlRm9udChzdGF0ZU1hbmFnZXIuc3RhdGUpOwogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGFyZ3NbMF0gPSBzZWxmLmhhbmRsZVRleHQoYXJnc1swXSwgc3RhdGVNYW5hZ2VyLnN0YXRlKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zaG93U3BhY2VkVGV4dDoKICAgICAgICAgICAgaWYgKCFzdGF0ZU1hbmFnZXIuc3RhdGUuZm9udCkgewogICAgICAgICAgICAgIHNlbGYuZW5zdXJlU3RhdGVGb250KHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdmFyIGNvbWJpbmVkR2x5cGhzID0gW107CiAgICAgICAgICAgIHZhciBzdGF0ZSA9IHN0YXRlTWFuYWdlci5zdGF0ZTsKICAgICAgICAgICAgZm9yIChjb25zdCBhcnJJdGVtIG9mIGFyZ3NbMF0pIHsKICAgICAgICAgICAgICBpZiAodHlwZW9mIGFyckl0ZW0gPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICBjb21iaW5lZEdseXBocy5wdXNoKC4uLnNlbGYuaGFuZGxlVGV4dChhcnJJdGVtLCBzdGF0ZSkpOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIGFyckl0ZW0gPT09ICJudW1iZXIiKSB7CiAgICAgICAgICAgICAgICBjb21iaW5lZEdseXBocy5wdXNoKGFyckl0ZW0pOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBhcmdzWzBdID0gY29tYmluZWRHbHlwaHM7CiAgICAgICAgICAgIGZuID0gX3V0aWwuT1BTLnNob3dUZXh0OwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm5leHRMaW5lU2hvd1RleHQ6CiAgICAgICAgICAgIGlmICghc3RhdGVNYW5hZ2VyLnN0YXRlLmZvbnQpIHsKICAgICAgICAgICAgICBzZWxmLmVuc3VyZVN0YXRlRm9udChzdGF0ZU1hbmFnZXIuc3RhdGUpOwogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRPcChfdXRpbC5PUFMubmV4dExpbmUpOwogICAgICAgICAgICBhcmdzWzBdID0gc2VsZi5oYW5kbGVUZXh0KGFyZ3NbMF0sIHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgIGZuID0gX3V0aWwuT1BTLnNob3dUZXh0OwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm5leHRMaW5lU2V0U3BhY2luZ1Nob3dUZXh0OgogICAgICAgICAgICBpZiAoIXN0YXRlTWFuYWdlci5zdGF0ZS5mb250KSB7CiAgICAgICAgICAgIC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gICAgICAgICAgfQogICAgICAgICAgICAgIG5leHQoc2VsZi5wYXJzZUNvbG9yU3BhY2UoewogICAgICAgICAgICAgICAgY3M6IGFyZ3NbMF0sCiAgICAgICAgICAgICAgICByZXNvdXJjZXMsCiAgICAgICAgICAgICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgICAgICAgICAgIH0pLnRoZW4oZnVuY3Rpb24gKGNvbG9yU3BhY2UpIHsKICAgICAgICAgICAgICAgIGlmIChjb2xvclNwYWNlKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlTWFuYWdlci5zdGF0ZS5maWxsQ29sb3JTcGFjZSA9IGNvbG9yU3BhY2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0U3Ryb2tlQ29sb3JTcGFjZToKICAgICAgICAgICAgewogICAgICAgICAgICAgIGNvbnN0IGNhY2hlZENvbG9yU3BhY2UgPSBfY29sb3JzcGFjZS5Db2xvclNwYWNlLmdldENhY2hlZChhcmdzWzBdLCB4cmVmLCBsb2NhbENvbG9yU3BhY2VDYWNoZSk7CiAgICAgICAgICAgICAgaWYgKGNhY2hlZENvbG9yU3BhY2UpIHsKICAgICAgICAgICAgICAgIHN0YXRlTWFuYWdlci5zdGF0ZS5zdHJva2VDb2xvclNwYWNlID0gY2FjaGVkQ29sb3JTcGFjZTsKICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBuZXh0KHNlbGYucGFyc2VDb2xvclNwYWNlKHsKICAgICAgICAgICAgICAgIGNzOiBhcmdzWzBdLAogICAgICAgICAgICAgICAgcmVzb3VyY2VzLAogICAgICAgICAgICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUKICAgICAgICAgICAgICB9KS50aGVuKGZ1bmN0aW9uIChjb2xvclNwYWNlKSB7CiAgICAgICAgICAgICAgICBpZiAoY29sb3JTcGFjZSkgewogICAgICAgICAgICAgICAgICBzdGF0ZU1hbmFnZXIuc3RhdGUuc3Ryb2tlQ29sb3JTcGFjZSA9IGNvbG9yU3BhY2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0RmlsbENvbG9yOgogICAgICAgICAgICBjcyA9IHN0YXRlTWFuYWdlci5zdGF0ZS5maWxsQ29sb3JTcGFjZTsKICAgICAgICAgICAgYXJncyA9IGNzLmdldFJnYihhcmdzLCAwKTsKICAgICAgICAgICAgZm4gPSBfdXRpbC5PUFMuc2V0RmlsbFJHQkNvbG9yOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFN0cm9rZUNvbG9yOgogICAgICAgICAgICBjcyA9IHN0YXRlTWFuYWdlci5zdGF0ZS5zdHJva2VDb2xvclNwYWNlOwogICAgICAgICAgICBhcmdzID0gY3MuZ2V0UmdiKGFyZ3MsIDApOwogICAgICAgICAgICBmbiA9IF91dGlsLk9QUy5zZXRTdHJva2VSR0JDb2xvcjsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRGaWxsR3JheToKICAgICAgICAgICAgc3RhdGVNYW5hZ2VyLnN0YXRlLmZpbGxDb2xvclNwYWNlID0gX2NvbG9yc3BhY2UuQ29sb3JTcGFjZS5zaW5nbGV0b25zLmdyYXk7CiAgICAgICAgICAgIGFyZ3MgPSBfY29sb3JzcGFjZS5Db2xvclNwYWNlLnNpbmdsZXRvbnMuZ3JheS5nZXRSZ2IoYXJncywgMCk7CiAgICAgICAgICAgIGZuID0gX3V0aWwuT1BTLnNldEZpbGxSR0JDb2xvcjsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRTd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yBvYmplY3QgZm91bmQiKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBwYXR0ZXJuSWQgPSBzZWxmLnBhcnNlU2hhZGluZyh7CiAgICAgICAgICAgICAgc2hhZGluZywKICAgICAgICAgICAgICByZXNvdXJjZXMsCiAgICAgICAgICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUsCiAgICAgICAgICAgICAgbG9jYWxTaGFkaW5nUGF0dGVybkNhY2hlCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBhcmdzID0gW3BhdHRlcm5JZF07CiAgICAgICAgICAgIGZuID0gX3V0aWwuT1BTLnNoYWRpbmdGaWxsOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEdTdGF0ZToKICAgICAgICAgICAgaXNWYWxpZE5hbWUgPSBhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZTsKICAgICAgICAgICAgbmFtZSA9IGFyZ3NbMF0ubmFtZTsKICAgICAgICAgICAgaWYgKGlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgY29uc3QgbG9jYWxHU3RhdGVPYmogPSBsb2NhbEdTdGF0ZUNhY2hlLmdldEJ5TmFtZShuYW1lKTsKICAgICAgICAgICAgICBpZiAobG9jYWxHU3RhdGVPYmopIHsKICAgICAgICAgICAgICAgIGlmIChsb2NhbEdTdGF0ZU9iai5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRPcChfdXRpbC5PUFMuc2V0R1N0YXRlLCBbbG9jYWxHU3RhdGVPYmpdKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGFyZ3MgPSBudWxsOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIG5leHQobmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmVHU3RhdGUsIHJlamVjdEdTdGF0ZSkgewogICAgICAgICAgICAgIGlmICghaXNWYWxpZE5hbWUpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiR1N0YXRlIG11c3QgYmUgcmVmZXJyZWQgdG8gYnkgbmFtZS4iKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgZXh0R1N0YXRlID0gcmVzb3VyY2VzLmdldCgiRXh0R1N0YXRlIik7CiAgICAgICAgICAgICAgaWYgKCEoZXh0R1N0YXRlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiRXh0R1N0YXRlIHNob3VsZCBiZSBhIGRpY3Rpb25hcnkuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNvbnN0IGdTdGF0ZSA9IGV4dEdTdGF0ZS5nZXQobmFtZSk7CiAgICAgICAgICAgICAgaWYgKCEoZ1N0YXRlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiR1N0YXRlIHNob3VsZCBiZSBhIGRpY3Rpb25hcnkuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNlbGYuc2V0R1N0YXRlKHsKICAgICAgICAgICAgICAgIHJlc291cmNlcywKICAgICAgICAgICAgICAgIGdTdGF0ZSwKICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdCwKICAgICAgICAgICAgICAgIGNhY2hlS2V5OiBuYW1lLAogICAgICAgICAgICAgICAgdGFzaywKICAgICAgICAgICAgICAgIHN0YXRlTWFuYWdlciwKICAgICAgICAgICAgICAgIGxvY2FsR1N0YXRlQ2FjaGUsCiAgICAgICAgICAgICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgICAgICAgICAgIH0pLnRoZW4ocmVzb2x2ZUdTdGF0ZSwgcmVqZWN0R1N0YXRlKTsKICAgICAgICAgICAgfSkuY2F0Y2goZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgICAgIGlmIChyZWFzb24gaW5zdGFuY2VvZiBfdXRpbC5BYm9ydEV4Y2VwdGlvbikgewogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAoc2VsZi5vcHRpb25zLmlnbm9yZUVycm9ycykgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBnZXRPcGVyYXRvckxpc3QgLSBpZ25vcmluZyBFeHRHU3RhdGU6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMubW92ZVRvOgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMubGluZVRvOgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY3VydmVUbzoKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmN1cnZlVG8yOgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY3VydmVUbzM6CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jbG9zZVBhdGg6CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5yZWN0YW5nbGU6CiAgICAgICAgICAgIHNlbGYuYnVpbGRQYXRoKG9wZXJhdG9yTGlzdCwgZm4sIGFyZ3MsIHBhcnNpbmdUZXh0KTsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tYXJrUG9pbnQ6CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tYXJrUG9pbnRQcm9wczoKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmJlZ2luQ29tcGF0OgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kQ29tcGF0OgogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmJlZ2luTWFya2VkQ29udGVudFByb3BzOgogICAgICAgICAgICBpZiAoIShhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkpIHsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYEV4cGVjdGVkIG5hbWUgZm9yIGJlZ2luTWFya2VkQ29udGVudFByb3BzIGFyZzA9JHthcmdzWzBdfWApOwogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChhcmdzWzBdLm5hbWUgPT09ICJPQyIpIHsKICAgICAgICAgICAgICBuZXh0KHNlbGYucGFyc2VNYXJrZWRDb250ZW50UHJvcHMoYXJnc1sxXSwgcmVzb3VyY2VzKS50aGVuKGRhdGEgPT4gewogICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZE9wKF91dGlsLk9QUy5iZWdpbk1hcmtlZENvbnRlbnRQcm9wcywgWyJPQyIsIGRhdGFdKTsKICAgICAgICAgICAgICB9KS5jYXRjaChyZWFzb24gPT4gewogICAgICAgICAgICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChzZWxmLm9wdGlvbnMuaWdub3JlRXJyb3JzKSB7CiAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0T3BlcmF0b3JMaXN0IC0gaWdub3JpbmcgYmVnaW5NYXJrZWRDb250ZW50UHJvcHM6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBhcmdzID0gW2FyZ3NbMF0ubmFtZSwgYXJnc1sxXSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QgPyBhcmdzWzFdLmdldCgiTUNJRCIpIDogbnVsbF07CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuYmVnaW5NYXJrZWRDb250ZW50OgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kTWFya2VkQ29udGVudDoKICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIGlmIChhcmdzICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgZm9yIChpID0gMCwgaWkgPSBhcmdzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgICAgIGlmIChhcmdzW2ldIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKGkgPCBpaSkgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJnZXRPcGVyYXRvckxpc3QgLSBpZ25vcmluZyBvcGVyYXRvcjogIiArIGZuKTsKICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBvcGVyYXRvckxpc3QuYWRkT3AoZm4sIGFyZ3MpOwogICAgICB9CiAgICAgIGlmIChzdG9wKSB7CiAgICAgICAgbmV4dChkZWZlcnJlZCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGNsb3NlUGVuZGluZ1Jlc3RvcmVPUFMoKTsKICAgICAgcmVzb2x2ZSgpOwogICAgfSkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91d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GZvbnQuYXNjZW50LAogICAgICAgICAgZGVzY2VudDogZm9udC5kZXNjZW50LAogICAgICAgICAgdmVydGljYWw6IGZvbnQudmVydGljYWwKICAgICAgICB9OwogICAgICB9CiAgICAgIHRleHRDb250ZW50SXRlbS5mb250TmFtZSA9IGxvYWRlZE5hbWU7CiAgICAgIGNvbnN0IHRybSA9IHRleHRDb250ZW50SXRlbS50cmFuc2Zvcm0gPSBnZXRDdXJyZW50VGV4dFRyYW5zZm9ybSgpOwogICAgICBpZiAoIWZvbnQudmVydGljYWwpIHsKICAgICAgICB0ZXh0Q29udGVudEl0ZW0ud2lkdGggPSB0ZXh0Q29udGVudEl0ZW0udG90YWxXaWR0aCA9IDA7CiAgICAgICAgdGV4dENvbnRlbnRJdGVtLmhlaWdodCA9IHRleHRDb250ZW50SXRlbS50b3RhbEhlaWdodCA9IE1hdGguaHlwb3QodHJtWzJdLCB0cm1bM10pOwogICAgICAgIHRleHRDb250ZW50SXRlbS52ZXJ0aWNhbCA9IGZhbHNlOwogICAgICB9IGVsc2UgewogICAgICAgIHRleHRDb250ZW50SXRlbS53aWR0aCA9IHRleHRDb250ZW50SXRlbS50b3RhbFdpZHRoID0gTWF0aC5oeXBvdCh0cm1bMF0sIHRybVsxXSk7CiAgICAgICAgdGV4dENvbnRlbnRJdGVtLmhlaWdodCA9IHRleHRDb250ZW50SXRlbS50b3RhbEhlaWdodCA9IDA7CiAgICAgICAgdGV4dENvbnRlbnRJdGVtLnZlcnRpY2FsID0gdHJ1ZTsKICAgICAgfQogICAgICBjb25zdCBzY2FsZUxpbmVYID0gTWF0aC5oeXBvdCh0ZXh0U3RhdGUudGV4dExpbmVNYXRyaXhbMF0sIHRleHRTdGF0ZS50ZXh0TGluZU1hdHJpeFsxXSk7CiAgICAgIGNvbnN0IHNjYWxlQ3RtWCA9IE1hdGguaHlwb3QodGV4dFN0YXRlLmN0bVswXSwgdGV4dFN0YXRlLmN0bVsxXSk7CiAgICAgIHRleHRDb250ZW50SXRlbS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gICAgICAgIFtsYXN0UG9zWCwgbGFzdFBvc1ldID0gYXBwbHlJbnZlcnNlUm90YXRpb24obGFzdFBvc1gsIGxhc3RQb3NZLCB0ZXh0Q29udGVudEl0ZW0ucHJldlRyYW5zZm9ybSk7CiAgICAgIH0KICAgICAgaWYgKHRleHRTdGF0ZS5mb250LnZlcnRpY2FsKSB7CiAgICAgICAgY29uc3QgYWR2YW5jZVkgPSAobGFzdFBvc1kgLSBwb3NZKSAvIHRleHRDb250ZW50SXRlbS50ZXh0QWR2YW5jZVNjYWxlOwogICAgICAgIGNvbnN0IGFkdmFuY2VYID0gcG9zWCAtIGxhc3RQb3NYOwogICAgICAgIGNvbnN0IHRleHRPcmllbnRhdGlvbiA9IE1hdGguc2lnbih0ZXh0Q29udGVudEl0ZW0uaGVpZ2h0KTsKICAgICAgICBpZiAoYWR2YW5jZVkgPCB0ZXh0T3JpZW50YXRpb24gKiB0ZXh0Q29udGVudEl0ZW0ubmVnYXRpdmVTcGFjZU1heCkgewogICAgICAgICAgaWYgKE1hdGguYWJzKGFkdmFuY2VYKSA+IDAuNSAqIHRleHRDb250ZW50SXRlbS53aWR0aCkgewogICAgICAgICAgICBhcHBlbmRFT0woKTsKICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICB9CiAgICAgICAgICByZXNldExhc3RDaGFycygpOwogICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KICAgICAgICBpZiAoTWF0aC5hYnMoYWR2YW5jZVgpID4gdGV4dENvbnRlbnRJdGVtLndpZHRoKSB7CiAgICAgICAgICBhcHBlbmRFT0woKTsKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KICAgICAgICBpZiAoYWR2YW5jZVkgPD0gdGV4dE9yaWVudGF0aW9uICogdGV4dENvbnRlbnRJdGVtLm5vdEFTcGFjZSkgewogICAgICAgICAgcmVzZXRMYXN0Q2hhcnMoKTsKICAgICAgICB9CiAgICAgICAgaWYgKGFkdmFuY2VZIDw9IHRleHRPcmllbnRhdGlvbiAqIHRleHRDb250ZW50SXRlbS50cmFja2luZ1NwYWNlTWluKSB7CiAgICAgICAgICB0ZXh0Q29udGVudEl0ZW0uaGVpZ2h0ICs9IGFkdmFuY2VZOwogICAgICAgIH0gZWxzZSBpZiAoIWFkZEZha2VTcGFjZXMoYWR2YW5jZVksIHRleHRDb250ZW50SXRlbS5wcmV2VHJhbnNmb3JtLCB0ZXh0T3JpZW50YXRpb24pKSB7CiAgICAgICAgICBpZiAodGV4dENvbnRlbnRJdGVtLnN0ci5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgcmVzZXRMYXN0Q2hhcnMoKTsKICAgICAgICAgICAgdGV4dENvbnRlbnQuaXRlbXMucHVzaCh7CiAgICAgICAgICAgICAgc3RyOiAiICIsCiAgICAgICAgICAgICAgZGlyOiAibHRyIiwKICAgICAgICAgICAgICB3aWR0aDogMCwKICAgICAgICAgICAgICBoZWlnaHQ6IE1hdGguYWJzKGFkdmFuY2VZKSwKICAgICAgICAgICAgICB0cmFuc2Zvcm06IHRleHRDb250ZW50SXRlbS5wcmV2VHJhbnNmb3JtLAogICAgICAgICAgICAgIGZvbnROYW1lOiB0ZXh0Q29udGVudEl0ZW0uZm9udE5hbWUsCiAgICAgICAgICAgICAgaGFzRU9MOiBmYWxzZQogICAgICAgICAgICB9KTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRleHRDb250ZW50SXRlbS5oZWlnaHQgKz0gYWR2YW5jZVk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChNYXRoLmFicyhhZHZhbmNlWCkgPiB0ZXh0Q29udGVudEl0ZW0ud2lkdGggKiBWRVJUSUNBTF9TSElGVF9SQVRJTykgewogICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIH0KICAgICA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50SXRlbS5wcmV2VHJhbnNmb3JtLCB0ZXh0T3JpZW50YXRpb24pKSB7CiAgICAgICAgaWYgKHRleHRDb250ZW50SXRlbS5zdHIubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICByZXNldExhc3RDaGFycygpOwogICAgICAgICAgdGV4dENvbnRlbnQuaXRlbXMucHVzaCh7CiAgICAgICAgICAgIHN0cjogIiAiLAogICAgICAgICAgICBkaXI6ICJsdHIiLAogICAgICAgICAgICB3aWR0aDogTWF0aC5hYnMoYWR2YW5jZVgpLAogICAgICAgICAgICBoZWlnaHQ6IDAsCiAgICAgICAgICAgIHRyYW5zZm9ybTogdGV4dENvbnRlbnRJdGVtLnByZXZUcmFuc2Zvcm0sCiAgICAgICAgICAgIGZvbnROYW1lOiB0ZXh0Q29udGVudEl0ZW0uZm9udE5hbWUsCiAgICAgICAgICAgIGhhc0VPTDogZmFsc2UKICAgICAgICAgIH0pOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB0ZXh0Q29udGVudEl0ZW0ud2lkdGggKz0gYWR2YW5jZVg7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChNYXRoLmFicyhhZHZhbmNlWSkgPiB0ZXh0Q29udGVudEl0ZW0uaGVpZ2h0ICogVkVSVElDQUxfU0hJRlRfUkFUSU8pIHsKICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICB9CiAgICAgIHJldHVybiB0cnVlOwogICAgfQogICAgZnVuY3Rpb24gYnVpbGRUZXh0Q29udGVudEl0ZW0oX3JlZjgpIHsKICAgICAgbGV0IHsKICAgICAgICBjaGFycywKICAgICAgICBleHRyYVNwYWNpbmcKICAgICAgfSA9IF9yZWY4OwogICAgICBjb25zdCBmb250ID0gdGV4dFN0YXRlLmZvbnQ7CiAgICAgIGlmICghY2hhcnMpIHsKICAgICAgICBjb25zdCBjaGFyU3BhY2luZyA9IHRleHRTdGF0ZS5jaGFyU3BhY2luZyArIGV4dHJhU3BhY2luZzsKICAgICAgICBpZiAoY2hhclNwYWNpbmcpIHsKICAgICAgICAgIGlmICghZm9udC52ZXJ0aWNhbCkgewogICAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeChjaGFyU3BhY2luZyAqIHRleHRTdGF0ZS50ZXh0SFNjYWxlLCAwKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRleHRTdGF0ZS50cmFuc2xhdGVUZXh0TWF0cml4KDAsIC1jaGFyU3BhY2luZyk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBjb25zdCBnbHlwaHMgPSBmb250LmNoYXJzVG9HbHlwaHMoY2hhcnMpOwogICAgICBjb25zdCBzY2FsZSA9IHRleHRTdGF0ZS5mb250TWF0cml4WzBdICogdGV4dFN0YXRlLmZvbnRTaXplOwogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBnbHlwaHMubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgIGNvbnN0IGdseXBoID0gZ2x5cGhzW2ldOwogICAgICAgIGNvbnN0IHsKICAgICAgICAgIGNhdGVnb3J5CiAgICAgICAgfSA9IGdseXBoOwogICAgICAgIGlmIChjYXRlZ29yeS5pc0ludmlzaWJsZUZvcm1hdE1hcmspIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBsZXQgY2hhclNwYWNpbmcgPSB0ZXh0U3RhdGUuY2hhclNwYWNpbmcgKyAoaSArIDEgPT09IGlpID8gZXh0cmFTcGFjaW5nIDogMCk7CiAgICAgICAgbGV0IGdseXBoV2lkdGggPSBnbHlwaC53aWR0aDsKICAgICAgICBpZiAoZm9udC52ZXJ0aWNhbCkgewogICAgICAgICAgZ2x5cGhXaWR0aCA9IGdseXBoLnZtZXRyaWMgPyBnbHlwaC52bWV0cmljWzBdIDogLWdseXBoV2lkdGg7CiAgICAgICAgfQogICAgICAgIGxldCBzY2FsZWREaW0gPSBnbHlwaFdpZHRoICogc2NhbGU7CiAgICAgICAgaWYgKGNhdGVnb3J5LmlzV2hpdGVzcGFjZSkgewogICAgICAgICAgaWYgKCFmb250LnZlcnRpY2FsKSB7CiAgICAgICAgICAgIGNoYXJTcGFjaW5nICs9IHNjYWxlZERpbSArIHRleHRTdGF0ZS53b3JkU3BhY2luZzsKICAgICAgICAgICAgdGV4dFN0YXRlLnRyYW5zbGF0ZVRleHRNYXRyaXgoY2hhclNwYWNpbmcgKiB0ZXh0U3RhdGUudGV4dEhTY2FsZSwgMCk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBjaGFyU3BhY2luZyArPSAtc2NhbGVkRGltICsgdGV4dFN0YXRlLndvcmRTcGFjaW5nOwogICAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeCgwLCAtY2hhclNwYWNpbmcpOwogICAgICAgICAgfQogICAgICAgICAgc2F2ZUxhc3RDaGFyKCIgIik7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYgKCFjYXRlZ29yeS5pc1plcm9XaWR0aERpYWNyaXRpYyAmJiAhY29tcGFyZVdpdGhMYXN0UG9zaXRpb24oKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHRleHRDaHVuayA9IGVuc3VyZVRleHRDb250ZW50SXRlbSgpOwogICAgICAgIGlmIChjYXRlZ29yeS5pc1plcm9XaWR0aERpYWNyaXRpYykgewogICAgICAgICAgc2NhbGVkRGltID0gMDsKICAgICAgICB9CiAgICAgICAgaWYgKCFmb250LnZlcnRpY2FsKSB7CiAgICAgICAgICBzY2FsZWREaW0gKj0gdGV4dFN0YXRlLnRleHRIU2NhbGU7CiAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeChzY2FsZWREaW0sIDApOwogICAgICAgICAgdGV4dENodW5rLndpZHRoICs9IHNjYWxlZERpbTsKICAgICAgICB9IGVsc2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W50SXRlbSgpOwogICAgICB9IGVsc2UgewogICAgICAgIHRleHRDb250ZW50Lml0ZW1zLnB1c2goewogICAgICAgICAgc3RyOiAiIiwKICAgICAgICAgIGRpcjogImx0ciIsCiAgICAgICAgICB3aWR0aDogMCwKICAgICAgICAgIGhlaWdodDogMCwKICAgICAgICAgIHRyYW5zZm9ybTogZ2V0Q3VycmVudFRleHRUcmFuc2Zvcm0oKSwKICAgICAgICAgIGZvbnROYW1lOiB0ZXh0U3RhdGUubG9hZGVkTmFtZSwKICAgICAgICAgIGhhc0VPTDogdHJ1ZQogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgICBmdW5jdGlvbiBhZGRGYWtlU3BhY2VzKHdpZHRoLCB0cmFuc2YsIHRleHRPcmllbnRhdGlvbikgewogICAgICBpZiAodGV4dE9yaWVudGF0aW9uICogdGV4dENvbnRlbnRJdGVtLnNwYWNlSW5GbG93TWluIDw9IHdpZHRoICYmIHdpZHRoIDw9IHRleHRPcmllbnRhdGlvbiAqIHRleHRDb250ZW50SXRlbS5zcGFjZUluRmxvd01heCkgewogICAgICAgIGlmICh0ZXh0Q29udGVudEl0ZW0uaW5pdGlhbGl6ZWQpIHsKICAgICAgICAgIHJlc2V0TGFzdENoYXJzKCk7CiAgICAgICAgICB0ZXh0Q29udGVudEl0ZW0uc3RyLnB1c2goIiAiKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICB9CiAgICAgIGNvbnN0IGZvbnROYW1lID0gdGV4dENvbnRlbnRJdGVtLmZvbnROYW1lOwogICAgICBsZXQgaGVpZ2h0ID0gMDsKICAgICAgaWYgKHRleHRDb250ZW50SXRlbS52ZXJ0aWNhbCkgewogICAgICAgIGhlaWdodCA9IHdpZHRoOwogICAgICAgIHdpZHRoID0gMDsKICAgICAgfQogICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICByZXNldExhc3RDaGFycygpOwogICAgICB0ZXh0Q29udGVudC5pdGVtcy5wdXNo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IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBmYWxzZTsKICAgICAgY29uc3QgbGVuZ3RoID0gdGV4dENvbnRlbnQuaXRlbXMubGVuZ3RoOwogICAgICBpZiAobGVuZ3RoID09PSAwKSB7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGlmIChiYXRjaCAmJiBsZW5ndGggPCBURVhUX0NIVU5LX0JBVENIX1NJWkUpIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgc2luay5lbnF1ZXVlKHRleHRDb250ZW50LCBsZW5ndGgpOwogICAgICB0ZXh0Q29udGVudC5pdGVtcyA9IFtdOwogICAgICB0ZXh0Q29udGVudC5zdHlsZXMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgfQogICAgY29uc3QgdGltZVNsb3RNYW5hZ2VyID0gbmV3IFRpbWVTbG90TWFuYWdlcigpOwogICAgcmV0dXJuIG5ldyBQcm9taXNlKGZ1bmN0aW9uIHByb21pc2VCb2R5KHJlc29sdmUsIHJlamVjdCkgewogICAgICBjb25zdCBuZXh0ID0gZnVuY3Rpb24gKHByb21pc2UpIHsKICAgICAgICBlbnF1ZXVlQ2h1bmsodHJ1ZSk7CiAgICAgICAgUHJvbWlzZS5hbGwoW3Byb21pc2UsIHNpbmsucmVhZHldKS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIHByb21pc2VCb2R5KHJlc29sdmUsIHJlamVjdCk7CiAgICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgICByZWplY3QoZXgpOwogICAgICAgICAgfQogICAgICAgIH0sIHJlamVjdCk7CiAgICAgIH07CiAgICAgIHRhc2suZW5zdXJlTm90VGVybWluYXRlZCgpOwogICAgICB0aW1lU2xvdE1hbmFnZXIucmVzZXQoKTsKICAgICAgY29uc3Qgb3BlcmF0aW9uID0ge307CiAgICAgIGxldCBzdG9wLAogICAgICAgIGFyZ3MgPSBbXTsKICAgICAgd2hpbGUgKCEoc3RvcCA9IHRpbWVTbG90TWFuYWdlci5jaGVjaygpKSkgewogICAgICAgIGFyZ3MubGVuZ3RoID0gMDsKICAgICAgICBvcGVyYXRpb24uYXJncyA9IGFyZ3M7CiAgICAgICAgaWYgKCFwcmVwcm9jZXNzb3IucmVhZChvcGVyYXRpb24pKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgdGV4dFN0YXRlID0gc3RhdGVNYW5hZ2VyLnN0YXRlOwogICAgICAgIGNvbnN0IGZuID0gb3BlcmF0aW9uLmZuOwogICAgICAgIGFyZ3MgPSBvcGVyYXRpb24uYXJnczsKICAgICAgICBzd2l0Y2ggKGZuIHwgMCkgewogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0Rm9udDoKICAgICAgICAgICAgdmFyIGZvbnROYW1lQXJnID0gYXJnc1swXS5uYW1lLAogICAgICAgICAgICAgIGZvbnRTaXplQXJnID0gYXJnc1sxXTsKICAgICAgICAgICAgaWYgKHRleHRTdGF0ZS5mb250ICYmIGZvbnROYW1lQXJnID09PSB0ZXh0U3RhdGUuZm9udE5hbWUgJiYgZm9udFNpemVBcmcgPT09IHRleHRTdGF0ZS5mb250U2l6ZSkgewogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgICAgICAgIHRleHRTdGF0ZS5mb250TmFtZSA9IGZvbnROYW1lQXJnOwogICAgICAgICAgICB0ZXh0U3RhdGUuZm9udFNpemUgPSBmb250U2l6ZUFyZzsKICAgICAgICAgICAgbmV4dChoYW5kbGVTZXRGb250KGZvbnROYW1lQXJnLCBudWxsKSk7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFRleHRSaXNlOgogICAgICAgICAgICB0ZXh0U3RhdGUudGV4dFJpc2UgPSBhcmdzWzBdOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEhTY2FsZToKICAgICAgICAgICAgdGV4dFN0YXRlLnRleHRIU2NhbGUgPSBhcmdzWzBdIC8gMTAwOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldExlYWRpbmc6CiAgICAgICAgICAgIHRleHRTdGF0ZS5sZWFkaW5nID0gYXJnc1swXTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tb3ZlVGV4dDoKICAgICAgICAgICAgdGV4dFN0YXRlLnRyYW5zbGF0ZVRleHRMaW5lTWF0cml4KGFyZ3NbMF0sIGFyZ3NbMV0pOwogICAgICAgICAgICB0ZXh0U3RhdGUudGV4dE1hdHJpeCA9IHRleHRTdGF0ZS50ZXh0TGluZU1hdHJpeC5zbGljZSgpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldExlYWRpbmdNb3ZlVGV4dDoKICAgICAgICAgICAgdGV4dFN0YXRlLmxlYWRpbmcgPSAtYXJnc1sxXTsKICAgICAgICAgICAgdGV4dFN0YXRlLnRyYW5zbGF0ZVRleHRMaW5lTWF0cml4KGFyZ3NbMF0sIGFyZ3NbMV0pOwogICAgICAgICAgICB0ZXh0U3RhdGUudGV4dE1hdHJpeCA9IHRleHRTdGF0ZS50ZXh0TGluZU1hdHJpeC5zbGljZSgpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm5leHRMaW5lOgogICAgICAgICAgICB0ZXh0U3RhdGUuY2FycmlhZ2VSZXR1cm4oKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRUZXh0TWF0cml4OgogICAgICAgICAgICB0ZXh0U3RhdGUuc2V0VGV4dE1hdHJpeChhcmdzWzBdLCBhcmdzWzFdLCBhcmdzWz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NpemUgLyAxMDAwOwogICAgICAgICAgICBjb25zdCBlbGVtZW50cyA9IGFyZ3NbMF07CiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGVsZW1lbnRzLmxlbmd0aDsgaSA8IGlpIC0gMTsgaSsrKSB7CiAgICAgICAgICAgICAgY29uc3QgaXRlbSA9IGVsZW1lbnRzW2ldOwogICAgICAgICAgICAgIGlmICh0eXBlb2YgaXRlbSA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgIHNob3dTcGFjZWRUZXh0QnVmZmVyLnB1c2goaXRlbSk7CiAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgaXRlbSA9PT0gIm51bWJlciIgJiYgaXRlbSAhPT0gMCkgewogICAgICAgICAgICAgICAgY29uc3Qgc3RyID0gc2hvd1NwYWNlZFRleHRCdWZmZXIuam9pbigiIik7CiAgICAgICAgICAgICAgICBzaG93U3BhY2VkVGV4dEJ1ZmZlci5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgYnVpbGRUZXh0Q29udGVudEl0ZW0oewogICAgICAgICAgICAgICAgICBjaGFyczogc3RyLAogICAgICAgICAgICAgICAgICBleHRyYVNwYWNpbmc6IGl0ZW0gKiBzcGFjZUZhY3RvcgogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGl0ZW0gPSBlbGVtZW50cy5hdCgtMSk7CiAgICAgICAgICAgIGlmICh0eXBlb2YgaXRlbSA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICBzaG93U3BhY2VkVGV4dEJ1ZmZlci5wdXNoKGl0ZW0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzaG93U3BhY2VkVGV4dEJ1ZmZlci5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3RyID0gc2hvd1NwYWNlZFRleHRCdWZmZXIuam9pbigiIik7CiAgICAgICAgICAgICAgc2hvd1NwYWNlZFRleHRCdWZmZXIubGVuZ3RoID0gMDsKICAgICAgICAgICAgICBidWlsZFRleHRDb250ZW50SXRlbSh7CiAgICAgICAgICAgICAgICBjaGFyczogc3RyLAogICAgICAgICAgICAgICAgZXh0cmFTcGFjaW5nOiAwCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zaG93VGV4dDoKICAgICAgICAgICAgaWYgKCFzdGF0ZU1hbmFnZXIuc3RhdGUuZm9udCkgewogICAgICAgICAgICAgIHNlbGYuZW5zdXJlU3RhdGVGb250KHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnVpbGRUZXh0Q29udGVudEl0ZW0oewogICAgICAgICAgICAgIGNoYXJzOiBhcmdzWzBdLAogICAgICAgICAgICAgIGV4dHJhU3BhY2luZzogMAogICAgICAgICAgICB9KTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5uZXh0TGluZVNob3dUZXh0OgogICAgICAgICAgICBpZiAoIXN0YXRlTWFuYWdlci5zdGF0ZS5mb250KSB7CiAgICAgICAgICAgICAgc2VsZi5lbnN1cmVTdGF0ZUZvbnQoc3RhdGVNYW5hZ2VyLnN0YXRlKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICB0ZXh0U3RhdGUuY2FycmlhZ2VSZXR1cm4oKTsKICAgICAgICAgICAgYnVpbGRUZXh0Q29udGVudEl0ZW0oewogICAgICAgICAgICAgIGNoYXJzOiBhcmdzWzBdLAogICAgICAgICAgICAgIGV4dHJhU3BhY2luZzogMAogICAgICAgICAgICB9KTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5uZXh0TGluZVNldFNwYWNpbmdTaG93VGV4dDoKICAgICAgICAgICAgaWYgKCFzdGF0ZU1hbmFnZXIuc3RhdGUuZm9udCkgewogICAgICAgICAgICAgIHNlbGYuZW5zdXJlU3RhdGVGb250KHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGV4dFN0YXRlLndvcmRTcGFjaW5nID0gYXJnc1swXTsKICAgICAgICAgICAgdGV4dFN0YXRlLmNoYXJTcGFjaW5nID0gYXJnc1sxXTsKICAgICAgICAgICAgdGV4dFN0YXRlLmNhcnJpYWdlUmV0dXJuKCk7CiAgICAgICAgICAgIGJ1aWxkVGV4dENvbnRlbnRJdGVtKHsKICAgICAgICAgICAgICBjaGFyczogYXJnc1syXSwKICAgICAgICAgICAgICBleHRyYVNwYWNpbmc6IDAKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMucGFpbnRYT2JqZWN0OgogICAgICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICAgICAgICBpZiAoIXhvYmpzKSB7CiAgICAgICAgICAgICAgeG9ianMgPSByZXNvdXJjZXMuZ2V0KCJYT2JqZWN0IikgfHwgX3ByaW1pdGl2ZXMuRGljdC5lbXB0eTsKICAgICAgICAgICAgfQogICAgICAgICAgICB2YXIgaXNWYWxpZE5hbWUgPSBhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZTsKICAgICAgICAgICAgdmFyIG5hbWUgPSBhcmdzWzBdLm5hbWU7CiAgICAgICAgICAgIGlmIChpc1ZhbGlkTmFtZSAmJiBlbXB0eVhPYmplY3RDYWNoZS5nZXRCeU5hbWUobmFtZSkpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBuZXh0KG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlWE9iamVjdCwgcmVqZWN0WE9iamVjdCkgewogICAgICAgICAgICAgIGlmICghaXNWYWxpZE5hbWUpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiWE9iamVjdCBtdXN0IGJlIHJlZmVycmVkIHRvIGJ5IG5hbWUuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGxldCB4b2JqID0geG9ianMuZ2V0UmF3KG5hbWUpOwogICAgICAgICAgICAgIGlmICh4b2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmKSB7CiAgICAgICAgICAgICAgICBpZiAoZW1wdHlYT2JqZWN0Q2FjaGUuZ2V0QnlSZWYoeG9iaikpIHsKICAgICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY29uc3QgZ2xvYmFsSW1hZ2UgPSBzZWxmLmdsb2JhbEltYWdlQ2FjaGUuZ2V0RGF0YSh4b2JqLCBzZWxmLnBhZ2VJbmRleCk7CiAgICAgICAgICAgICAgICBpZiAoZ2xvYmFsSW1hZ2UpIHsKICAgICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgeG9iaiA9IHhyZWYuZmV0Y2goeG9iaik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmICghKHhvYmogaW5zdGFuY2VvZiBfYmFzZV9zdHJlYW0uQmFzZVN0cmVhbSkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiWE9iamVjdCBzaG91bGQgYmUgYSBzdHJlYW0iKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgdHlwZSA9IHhvYmouZGljdC5nZXQoIlN1YnR5cGUiKTsKICAgICAgICAgICAgICBpZiAoISh0eXBlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiWE9iamVjdCBzaG91bGQgaGF2ZSBhIE5hbWUgc3VidHlwZSIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAodHlwZS5uYW1lICE9PSAiRm9ybSIpIHsKICAgICAgICAgICAgICAgIGVtcHR5WE9iamVjdENhY2hlLnNldChuYW1lLCB4b2JqLmRpY3Qub2JqSWQsIHRydWUpOwogICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgY3VycmVudFN0YXRlID0gc3RhdGVNYW5hZ2VyLnN0YXRlLmNsb25lKCk7CiAgICAgICAgICAgICAgY29uc3QgeE9ialN0YXRlTWFuYWdlciA9IG5ldyBTdGF0ZU1hbmFnZXIoY3VycmVudFN0YXRlKTsKICAgICAgICAgICAgICBjb25zdCBtYXRyaXggPSB4b2JqLmRpY3QuZ2V0QXJyYXkoIk1hdHJpeCIpOwogICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KG1hdHJpeCkgJiYgbWF0cml4Lmxlbmd0aCA9PT0gNikgewogICAgICAgICAgICAgICAgeE9ialN0YXRlTWFuYWdlci50cmFuc2Zvcm0obWF0cml4KTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgZW5xdWV1ZUNodW5rKCk7CiAgICAgICAgICAgICAgY29uc3Qgc2lua1dyYXBwZXIgPSB7CiAgICAgICAgICAgICAgICBlbnF1ZXVlSW52b2tlZDogZmFsc2UsCiAgICAgICAgICAgICAgICBlbnF1ZXVlKGNodW5rLCBzaXplKSB7CiAgICAgICAgICAgICAgICAgIHRoaXMuZW5xdWV1ZUludm9rZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICBzaW5rLmVucXVldWUoY2h1bmssIHNpemUpOwogICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgIGdldCBkZXNpcmVkU2l6ZSgpIHsKICAgICAgICAgICAgICAgICAgcmV0dXJuIHNpbmsuZGVzaXJlZFNpemU7CiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgZ2V0IHJlYWR5KCkgewogICAgICAgICAgICAgICAgICByZXR1cm4gc2luay5yZWFkeTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgIHNlbGYuZ2V0VGV4dENvbnRlbnQoewogICAgICAgICAgICAgICAgc3RyZWFtOiB4b2JqLAogICAgICAgICAgICAgICAgdGFzaywKICAgICAgICAgICAgICAgIHJlc291cmNlczogeG9iai5kaWN0LmdldCgiUmVzb3VyY2VzIikgfHwgcmVzb3VyY2VzLAogICAgICAgICAgICAgICAgc3RhdGVNYW5hZ2VyOiB4T2JqU3RhdGVNYW5hZ2VyLAogICAgICAgICAgICAgICAgY29tYmluZVRleHRJdGVtcywKICAgICAgICAgICAgICAgIGluY2x1ZGVNYXJrZWRDb250ZW50LAogICAgICAgICAgICAgICAgc2luazogc2lua1dyYXBwZXIsCiAgICAgICAgICAgICAgICBzZWVuU3R5bGVzLAogICAgICAgICAgICAgICAgdmlld0JveCwKICAgICAgICAgICAgICAgIG1hcmtlZENvbnRlbnREYXRhCiAgICAgICAgICAgICAgfSkudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICBpZiAoIXNpbmtXcmFwcGVyLmVucXVldWVJbnZva2VkKSB7CiAgICAgICAgICAgICAgICAgIGVtcHR5WE9iamVjdENhY2hlLnNldChuYW1lLCB4b2JqLmRpY3Qub2JqSWQsIHRydWUpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICB9LCByZWplY3RYT2JqZWN0KTsKICAgICAgICAgICAgfSkuY2F0Y2goZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgICAgIGlmIChyZWFzb24gaW5zdGFuY2VvZiBfdXRpbC5BYm9ydEV4Y2VwdGlvbikgewogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAoc2VsZi5vcHRpb25zLmlnbm9yZUVycm9ycykgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBnZXRUZXh0Q29udGVudCAtIGlnbm9yaW5nIFhPYmplY3Q6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0R1N0YXRlOgogICAgICAgICAgICBpc1ZhbGlkTmFtZSA9IGFyZ3NbMF0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lOwogICAgICAgICAgICBuYW1lID0gYXJnc1swXS5uYW1lOwogICAgICAgICAgICBpZiAoaXNWYWxpZE5hbWUgJiYgZW1wdHlHU3RhdGVDYWNoZS5nZXRCeU5hbWUobmFtZSkpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBuZXh0KG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlR1N0YXRlLCByZWplY3RHU3RhdGUpIHsKICAgICAgICAgICAgICBpZiAoIWlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIkdTdGF0ZSBtdXN0IGJlIHJlZmVycmVkIHRvIGJ5IG5hbWUuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNvbnN0IGV4dEdTdGF0ZSA9IHJlc291cmNlcy5nZXQoIkV4dEdTdGF0ZSIpOwogICAgICAgICAgICAgIGlmICghKGV4dEdTdGF0ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIkV4dEdTdGF0ZSBzaG91bGQgYmUgYSBkaWN0aW9uYXJ5LiIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb25zdCBnU3RhdGUgPSBleHRHU3RhdGUuZ2V0KG5hbWUpOwogICAgICAgICAgICAgIGlmICghKGdTdGF0ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIkdTdGF0ZSBzaG91bGQgYmUgYSBkaWN0aW9uYXJ5LiIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb25zdCBnU3RhdGVGb250ID0gZ1N0YXRlLmdldCgiRm9udCIpOwogICAgICAgICAgICAgIGlmICghZ1N0YXRlRm9udCkgewogICAgICAgICAgICAgICAgZW1wdHlHU3RhdGVDYWNoZS5zZXQobmFtZSwgZ1N0YXRlLm9iaklkLCB0cnVlKTsKICAgICAgICAgICAgICAgIHJlc29sdmVHU3RhdGUoKTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICAgICAgICB0ZXh0U3RhdGUuZm9udE5hbWUgPSBudWxsOwogICAgICAgICAgICAgIHRleHRTdGF0ZS5mb250U2l6ZSA9IGdTdGF0ZUZvbnRbMV07CiAgICAgICAgICAgICAgaGFuZGxlU2V0Rm9udChudWxsLCBnU3RhdGVGb250WzBdKS50aGVuKHJlc29sdmVHU3RhdGUsIHJlamVjdEdTdGF0ZSk7CiAgICAgICAgICAgIH0pLmNhdGNoKGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICBpZiAocmVhc29uIGluc3RhbmNlb2YgX3V0aWwuQWJvcnRFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHNlbGYub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0VGV4dENvbnRlbnQgLSBpZ25vcmluZyBFeHRHU3RhdGU6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuYmVnaW5NYXJrZWRDb250ZW50OgogICAgICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICAgICAgICBpZiAoaW5jbHVkZU1hcmtlZENvbnRlbnQpIHsKICAgICAgICAgICAgICBtYXJrZWRDb250ZW50RGF0YS5sZXZlbCsrOwogICAgICAgICAgICAgIHRleHRDb250ZW50Lml0ZW1zLnB1c2goewogICAgICAgICAgICAgICAgdHlwZTogImJlZ2luTWFya2VkQ29udGVudCIsCiAgICAgICAgICAgICAgICB0YWc6IGFyZ3NbMF0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lID8gYXJnc1swXS5uYW1lIDogbnVsbAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuYmVnaW5NYXJrZWRDb250ZW50UHJvcHM6CiAgICAgICAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgICAgICAgIGlmIChpbmNsdWRlTWFya2VkQ29udGVudCkgewogICAgICAgICAgICAgIG1hcmtlZENvbnRlbnREYXRhLmxldmVsKys7CiAgICAgICAgICAgICAgbGV0IG1jaWQgPSBudWxsOwogICAgICAgICAgICAgIGlmIChhcmdzWzFdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICAgICAgbWNpZCA9IGFyZ3NbMV0uZ2V0KCJNQ0lEIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHRleHRDb250ZW50Lml0ZW1zLnB1c2goewogICAgICAgICAgICAgICAgdHlwZTogImJlZ2luTWFya2VkQ29udGVudFByb3BzIiwKICAgICAgICAgICAgICAgIGlkOiBOdW1iZXIuaXNJbnRlZ2VyKG1jaWQpID8gYCR7c2VsZi5pZEZhY3RvcnkuZ2V0UGFnZU9iaklkKCl9X21jaWQke21jaWR9YCA6IG51bGwsCiAgICAgICAgICAgICAgICB0YWc6IGFyZ3NbMF0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lID8gYXJnc1swXS5uYW1lIDogbnVsbAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kTWFya2VkQ29udGVudDoKICAgICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICAgICAgaWYgKGluY2x1ZGVNYXJrZWRDb250ZW50KSB7CiAgICAgICAgICAgICAgaWYgKG1hcmtlZENvbnRlbnREYXRhLmxldmVsID09PSAwKSB7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgbWFya2VkQ29udGVudERhdGEubGV2ZWwtLTsKICAgICAgICAgICAgICB0ZXh0Q29udGVudC5pdGVtcy5wdXNoKHsKICAgICAgICAgICAgICAgIHR5cGU6ICJlbmRNYXJrZWRDb250ZW50IgogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBpZiAodGV4dENvbnRlbnQuaXRlbXMubGVuZ3RoID49IHNpbmsuZGVzaXJlZFNpemUpIHsKICAgICAgICAgIHN0b3AgPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChzdG9wKSB7CiAgICAgICAgbmV4dChkZWZlcnJlZCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgIGVucXVldWVDaHVuaygpOwogICAgICByZXNvbHZlKCk7CiAgICB9KS5jYXRjaChyZWFzb24gPT4gewogICAgICBpZiAocmVhc29uIGluc3RhbmNlb2YgX3V0aWwuQWJvcnRFeGNlcHRpb24pIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgaWYgKHRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYGdldFRleHRDb250ZW50IC0gaWdub3JpbmcgZXJyb3JzIGR1cmluZyAiJHt0YXNrLm5hbWV9IiBgICsgYHRhc2s6ICIke3JlYXNvbn0iLmApOwogICAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgICAgZW5xdWV1ZUNodW5rKCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIHRocm93IHJlYXNvbjsKICAgIH0pOwogIH0KICBleHRyYWN0RGF0YVN0cnVjdHVyZXMoZGljdCwgYmFzZURpY3QsIHByb3BlcnRpZXMpIHsKICAgIGNvbnN0IHhyZWYgPSB0aGlzLnhyZWY7CiAgICBsZXQgY2lkVG9HaWRCeXRlczsKICAgIGNvbnN0IHRvVW5pY29kZVByb21pc2UgPSB0aGlzLnJlYWRUb1VuaWNvZGUocHJvcGVydGllcy50b1VuaWNvZGUgfHwgZGljdC5nZXQoIlRvVW5pY29kZSIpIHx8IGJhc2VEaWN0LmdldCgiVG9Vbmljb2RlIikpOwogICAgaWYgKHByb3BlcnRpZXMuY29tcG9zaXRlKSB7CiAgICAgIGNvbnN0IGNpZFN5c3RlbUluZm8gPSBkaWN0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GluZ1tjaGFyY29kZV0gPSBnbHlwaE5hbWU7CiAgICB9CiAgICBjb25zdCBnbHlwaHNVbmljb2RlTWFwID0gKDAsIF9nbHlwaGxpc3QuZ2V0R2x5cGhzVW5pY29kZSkoKTsKICAgIGZvciAoY29uc3QgY2hhcmNvZGUgaW4gZW5jb2RpbmcpIHsKICAgICAgbGV0IGdseXBoTmFtZSA9IGVuY29kaW5nW2NoYXJjb2RlXTsKICAgICAgaWYgKGdseXBoTmFtZSA9PT0gIiIpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBsZXQgdW5pY29kZSA9IGdseXBoc1VuaWNvZGVNYXBbZ2x5cGhOYW1lXTsKICAgICAgaWYgKHVuaWNvZGUgIT09IHVuZGVmaW5lZCkgewogICAgICAgIHRvVW5pY29kZVtjaGFyY29kZV0gPSBTdHJpbmcuZnJvbUNoYXJDb2RlKHVuaWNvZGUpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGxldCBjb2RlID0gMDsKICAgICAgc3dpdGNoIChnbHlwaE5hbWVbMF0pIHsKICAgICAgICBjYXNlICJHIjoKICAgICAgICAgIGlmIChnbHlwaE5hbWUubGVuZ3RoID09PSAzKSB7CiAgICAgICAgICAgIGNvZGUgPSBwYXJzZUludChnbHlwaE5hbWUuc3Vic3RyaW5nKDEpLCAxNik7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJnIjoKICAgICAgICAgIGlmIChnbHlwaE5hbWUubGVuZ3RoID09PSA1KSB7CiAgICAgICAgICAgIGNvZGUgPSBwYXJzZUludChnbHlwaE5hbWUuc3Vic3RyaW5nKDEpLCAxNik7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJDIjoKICAgICAgICBjYXNlICJjIjoKICAgICAgICAgIGlmIChnbHlwaE5hbWUubGVuZ3RoID49IDMgJiYgZ2x5cGhOYW1lLmxlbmd0aCA8PSA0KSB7CiAgICAgICAgICAgIGNvbnN0IGNvZGVTdHIgPSBnbHlwaE5hbWUuc3Vic3RyaW5nKDEpOwogICAgICAgICAgICBpZiAoZm9yY2VHbHlwaHMpIHsKICAgICAgICAgICAgICBjb2RlID0gcGFyc2VJbnQoY29kZVN0ciwgMTYpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvZGUgPSArY29kZVN0cjsKICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihjb2RlKSAmJiBOdW1iZXIuaXNJbnRlZ2VyKHBhcnNlSW50KGNvZGVTdHIsIDE2KSkpIHsKICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fc2ltcGxlRm9udFRvVW5pY29kZShwcm9wZXJ0aWVzLCB0cnVlKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAidSI6CiAgICAgICAgICB1bmljb2RlID0gKDAsIF91bmljb2RlLmdldFVuaWNvZGVGb3JHbHlwaCkoZ2x5cGhOYW1lLCBnbHlwaHNVbmljb2RlTWFwKTsKICAgICAgICAgIGlmICh1bmljb2RlICE9PSAtMSkgewogICAgICAgICAgICBjb2RlID0gdW5pY29kZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICBzd2l0Y2ggKGdseXBoTmFtZSkgewogICAgICAgICAgICBjYXNlICJmX2giOgogICAgICAgICAgICBjYXNlICJmX3QiOgogICAgICAgICAgICBjYXNlICJUX2giOgogICAgICAgICAgICAgIHRvVW5pY29kZVtjaGFyY29kZV0gPSBnbHlwaE5hbWUucmVwbGFjZUFsbCgiXyIsICIiKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGlmIChjb2RlID4gMCAmJiBjb2RlIDw9IDB4MTBmZmZmICYmIE51bWJlci5pc0ludGVnZXIoY29kZSkpIHsK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aWNvZGUgPSBbXSwKICAgICAgICBidWYgPSBbXTsKICAgICAgcHJvcGVydGllcy5jTWFwLmZvckVhY2goZnVuY3Rpb24gKGNoYXJjb2RlLCBjaWQpIHsKICAgICAgICBpZiAoY2lkID4gMHhmZmZmKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIk1heCBzaXplIG9mIENJRCBpcyA2NSw1MzUiKTsKICAgICAgICB9CiAgICAgICAgY29uc3QgdWNzMiA9IHVjczJDTWFwLmxvb2t1cChjaWQpOwogICAgICAgIGlmICh1Y3MyKSB7CiAgICAgICAgICBidWYubGVuZ3RoID0gMDsKICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IHVjczIubGVuZ3RoOyBpIDwgaWk7IGkgKz0gMikgewogICAgICAgICAgICBidWYucHVzaCgodWNzMi5jaGFyQ29kZUF0KGkpIDw8IDgpICsgdWNzMi5jaGFyQ29kZUF0KGkgKyAxKSk7CiAgICAgICAgICB9CiAgICAgICAgICB0b1VuaWNvZGVbY2hhcmNvZGVdID0gU3RyaW5nLmZyb21DaGFyQ29kZSguLi5idWYpOwogICAgICAgIH0KICAgICAgfSk7CiAgICAgIHJldHVybiBuZXcgX3RvX3VuaWNvZGVfbWFwLlRvVW5pY29kZU1hcCh0b1VuaWNvZGUpOwogICAgfQogICAgcmV0dXJuIG5ldyBfdG9fdW5pY29kZV9tYXAuSWRlbnRpdHlUb1VuaWNvZGVNYXAocHJvcGVydGllcy5maXJzdENoYXIsIHByb3BlcnRpZXMubGFzdENoYXIpOwogIH0KICByZWFkVG9Vbmljb2RlKGNtYXBPYmopIHsKICAgIGlmICghY21hcE9iaikgewogICAgICByZXR1cm4gUHJvbWlzZS5yZXNvbHZlKG51bGwpOwogICAgfQogICAgaWYgKGNtYXBPYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgIHJldHVybiBfY21hcC5DTWFwRmFjdG9yeS5jcmVhdGUoew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Im51bWJlciIpIHsKICAgICAgICAgICAgbWFwW2NoYXJDb2RlXSA9IFN0cmluZy5mcm9tQ29kZVBvaW50KHRva2VuKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfQogICAgICAgICAgY29uc3Qgc3RyID0gW107CiAgICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IHRva2VuLmxlbmd0aDsgayArPSAyKSB7CiAgICAgICAgICAgIGNvbnN0IHcxID0gdG9rZW4uY2hhckNvZGVBdChrKSA8PCA4IHwgdG9rZW4uY2hhckNvZGVBdChrICsgMSk7CiAgICAgICAgICAgIGlmICgodzEgJiAweGY4MDApICE9PSAweGQ4MDApIHsKICAgICAgICAgICAgICBzdHIucHVzaCh3MSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgayArPSAyOwogICAgICAgICAgICBjb25zdCB3MiA9IHRva2VuLmNoYXJDb2RlQXQoaykgPDwgOCB8IHRva2VuLmNoYXJDb2RlQXQoayArIDEpOwogICAgICAgICAgICBzdHIucHVzaCgoKHcxICYgMHgzZmYpIDw8IDEwKSArICh3MiAmIDB4M2ZmKSArIDB4MTAwMDApOwogICAgICAgICAgfQogICAgICAgICAgbWFwW2NoYXJDb2RlXSA9IFN0cmluZy5mcm9tQ29kZVBvaW50KC4uLnN0cik7CiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIG5ldyBfdG9fdW5pY29kZV9tYXAuVG9Vbmljb2RlTWFwKG1hcCk7CiAgICAgIH0sIHJlYXNvbiA9PiB7CiAgICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9CiAgICAgICAgaWYgKHRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgcmVhZFRvVW5pY29kZSAtIGlnbm9yaW5nIFRvVW5pY29kZSBkYXRhOiAiJHtyZWFzb259Ii5gKTsKICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgIH0KICAgICAgICB0aHJvdyByZWFzb247CiAgICAgIH0pOwogICAgfQogICAgcmV0dXJuIFByb21pc2UucmVzb2x2ZShudWxsKTsKICB9CiAgcmVhZENpZFRvR2lkTWFwKGdseXBoc0RhdGEsIHRvVW5pY29kZSkgewogICAgY29uc3QgcmVzdWx0ID0gW107CiAgICBmb3IgKGxldCBqID0gMCwgamogPSBnbHlwaHNEYXRhLmxlbmd0aDsgaiA8IGpqOyBqKyspIHsKICAgICAgY29uc3QgZ2x5cGhJRCA9IGdseXBoc0RhdGFbaisrXSA8PCA4IHwgZ2x5cGhzRGF0YVtqXTsKICAgICAgY29uc3QgY29kZSA9IGogPj4gMTsKICAgICAgaWYgKGdseXBoSUQgPT09IDAgJiYgIXRvVW5pY29kZS5oYXMoY29kZSkpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICByZXN1bHRbY29kZV0gPSBnbHlwaElEOwogICAgfQogICAgcmV0dXJuIHJlc3VsdDsKICB9CiAgZXh0cmFjdFdpZHRocyhkaWN0LCBkZXNjcmlwdG9yLCBwcm9wZXJ0aWVzKSB7CiAgICBjb25zdCB4cmVmID0gdGhpcy54cmVmOwogICAgbGV0IGdseXBoc1dpZHRocyA9IFtdOwogICAgbGV0IGRlZmF1bHRXaWR0aCA9IDA7CiAgICBjb25zdCBnbHlwaHNWTWV0cmljcyA9IFtdOwogICAgbGV0IGRlZmF1bHRWTWV0cmljczsKICAgIGxldCBpLCBpaSwgaiwgamosIHN0YXJ0LCBjb2RlLCB3aWR0aHM7CiAgICBpZiAocHJvcGVydGllcy5jb21wb3NpdGUpIHsKICAgICAgZGVmYXVsdFdpZHRoID0gZGljdC5oYXMoIkRXIikgPyBkaWN0LmdldCgiRFciKSA6IDEwMDA7CiAgICAgIHdpZHRocyA9IGRpY3QuZ2V0KCJXIik7CiAgICAgIGlmICh3aWR0aHMpIHsKICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IHdpZHRocy5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICBzdGFydCA9IHhyZWYuZmV0Y2hJZlJlZih3aWR0aHNbaSsrXSk7CiAgICAgICAgICBjb2RlID0geHJlZi5mZXRjaElmUmVmKHdpZHRoc1tpXSk7CiAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShjb2RlKSkgewogICAgICAgICAgICBmb3IgKGogPSAwLCBqaiA9IGNvZGUubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgICAgICAgIGdseXBoc1dpZHRoc1tzdGFydCsrXSA9IHhyZWYuZmV0Y2hJZlJlZihjb2RlW2pdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY29uc3Qgd2lkdGggPSB4cmVmLmZldGNoSWZSZWYod2lkdGhzWysraV0pOwogICAgICAgICAgICBmb3IgKGogPSBzdGFydDsgaiA8PSBjb2RlOyBqKyspIHsKICAgICAgICAgICAgICBnbHlwaHNXaWR0aHNbal0gPSB3aWR0aDsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAocHJvcGVydGllcy52ZXJ0aWNhbCkgewogICAgICAgIGxldCB2bWV0cmljcyA9IGRpY3QuZ2V0QXJyYXkoIkRXMiIpIHx8IFs4ODAsIC0xMDAwXTsKICAgICAgICBkZWZhdWx0Vk1ldHJpY3MgPSBbdm1ldHJpY3NbMV0sIGRlZmF1bHRXaWR0aCAqIDAuNSwgdm1ldHJpY3NbMF1dOwogICAgICAgIHZtZXRyaWNzID0gZGljdC5nZXQoIlcyIik7CiAgICAgICAgaWYgKHZtZXRyaWNzKSB7CiAgICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IHZtZXRyaWNzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgc3RhcnQgPSB4cmVmLmZldGNoSWZSZWYodm1ldHJpY3NbaSsrXSk7CiAgICAgICAgICAgIGNvZGUgPSB4cmVmLmZldGNoSWZSZWYodm1ldHJpY3NbaV0pOwogICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShjb2RlKSkgewogICAgICAgICAgICAgIGZvciAoaiA9IDAsIGpqID0gY29kZS5sZW5ndGg7IGogPCBqajsgaisrKSB7CiAgICAgICAgICAgICAgICBnbHlwaHNWTWV0cmljc1tzdGFydCsrXSA9IFt4cmVmLmZldGNoSWZSZWYoY29kZVtqKytdKSwgeHJlZi5mZXRjaElmUmVmKGNvZGVbaisrXSksIHhyZWYuZmV0Y2hJZlJlZihjb2RlW2pdKV07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGNvbnN0IHZtZXRyaWMgPSBbeHJlZi5mZXRjaElmUmVmKHZtZXRyaWNzWysraV0pLCB4cmVmLmZldGNoSWZSZWYodm1ldHJpY3NbKytpXSksIHhyZWYuZmV0Y2hJZlJlZih2bWV0cmljc1srK2ldKV07CiAgICAgICAgICAgICAgZm9yIChqID0gc3RhcnQ7IGogPD0gY29kZTsgaisrKSB7CiAgICAgICAgICAgICAgICBnbHlwaHNWTWV0cmljc1tqXSA9IHZtZXRyaWM7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBmaXJzdENoYXIgPSBwcm9wZXJ0aWVzLmZpcnN0Q2hhcjsKICAgICAgd2lkdGhzID0gZGljdC5nZXQoIldpZHRocyIpOwogICAgICBpZiAod2lkdGhzKSB7CiAgICAgICAgaiA9IGZpcnN0Q2hhcjsKICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IHdpZHRocy5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICBnbHlwaHNXaWR0aHNbaisrXSA9IHhyZWYuZmV0Y2hJZlJlZih3aWR0aHNbaV0pOwogICAgICAgIH0KICAgICAgICBkZWZhdWx0V2lkdGggPSBwYXJzZUZsb2F0KGRlc2NyaXB0b3IuZ2V0KCJNaXNzaW5nV2lkdGgiKSkgfHwgMDsKICAgICAgfSBlbHNlIHsKICAgICAgICBjb25zdCBiYXNlRm9udE5hbWUgPSBkaWN0LmdldCgiQmFzZUZvbnQiKTsKICAgICAgICBpZiAoYmFzZUZvbnROYW1lIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkgewogICAgICAgICAgY29uc3QgbWV0cmljcyA9IHRoaXMuZ2V0QmFzZUZvbnRNZXRyaWNzKGJhc2VGb250TmFtZS5uYW1lKTsKICAgICAgICAgIGdseXBoc1dpZHRocyA9IHRoaXMuYnVpbGRDaGFyQ29kZVRvV2lkdGgobWV0cmljcy53aWR0aHMsIHByb3BlcnRpZXMpOwogICAgICAgICAgZGVmYXVsdFdpZHRoID0gbWV0cmljcy5kZWZhdWx0V2lkdGg7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBsZXQgaXNNb25vc3BhY2UgPSB0cnVlOwogICAgbGV0IGZpcnN0V2lkdGggPSBkZWZhdWx0V2lkdGg7CiAgICBmb3IgKGNvbnN0IGdseXBoIGluIGdseXBoc1dpZHRocykgewogICAgICBjb25zdCBnbHlwaFdpZHRoID0gZ2x5cGhzV2lkdGhzW2dseXBoXTsKICAgICAgaWYgKCFnbHlwaFdpZHRoKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKCFmaXJzdFdpZHRoKSB7CiAgICAgICAgZmlyc3RXaWR0aCA9IGdseXBoV2lkdGg7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKGZpcnN0V2lkdGggIT09IGdseXBoV2lkdGgpIHsKICAgICAgICBpc01vbm9zcGFjZSA9IGZhbHNlOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBpZiAoaXNNb25vc3BhY2UpIHsKICAgICAgcHJvcGVydGllcy5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iAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoY29tcG9zaXRlV2lkdGhzKSkgewogICAgICAgICAgY29uc3Qgd2lkdGhzQnVmID0gW107CiAgICAgICAgICBmb3IgKGNvbnN0IGVudHJ5IG9mIGNvbXBvc2l0ZVdpZHRocykgewogICAgICAgICAgICBpZiAodHlwZW9mIGVudHJ5ID09PSAibnVtYmVyIiB8fCBlbnRyeSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICAgIHdpZHRoc0J1Zi5wdXNoKGVudHJ5LnRvU3RyaW5nKCkpOwogICAgICAgICAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkoZW50cnkpKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3ViV2lkdGhzQnVmID0gW107CiAgICAgICAgICAgICAgZm9yIChjb25zdCBlbGVtZW50IG9mIGVudHJ5KSB7CiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGVsZW1lbnQgPT09ICJudW1iZXIiIHx8IGVsZW1lbnQgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICAgICAgICAgICAgc3ViV2lkdGhzQnVmLnB1c2goZWxlbWVudC50b1N0cmluZygpKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgd2lkdGhzQnVmLnB1c2goYFske3N1YldpZHRoc0J1Zi5qb2luKCl9XWApOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBoYXNoLnVwZGF0ZSh3aWR0aHNCdWYuam9pbigpKTsKICAgICAgICB9CiAgICAgICAgY29uc3QgY2lkVG9HaWRNYXAgPSBkaWN0LmdldFJhdygiQ0lEVG9HSURNYXAiKSB8fCBiYXNlRGljdC5nZXRSYXcoIkNJRFRvR0lETWFwIik7CiAgICAgICAgaWYgKGNpZFRvR2lkTWFwIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkgewogICAgICAgICAgaGFzaC51cGRhdGUoY2lkVG9HaWRNYXAubmFtZSk7CiAgICAgICAgfSBlbHNlIGlmIChjaWRUb0dpZE1hcCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgaGFzaC51cGRhdGUoY2lkVG9HaWRNYXAudG9TdHJpbmcoKSk7CiAgICAgICAgfSBlbHNlIGlmIChjaWRUb0dpZE1hcCBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSB7CiAgICAgICAgICBoYXNoLnVwZGF0ZShjaWRUb0dpZE1hcC5wZWVrQnl0ZXMoKSk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gewogICAgICBkZXNjcmlwdG9yLAogICAgICBkaWN0LAogICAgICBiYXNlRGljdCwKICAgICAgY29tcG9zaXRlLAogICAgICB0eXBlOiB0eXBlLm5hbWUsCiAgICAgIGZpcnN0Q2hhciwKICAgICAgbGFzdENoYXIsCiAgICAgIHRvVW5pY29kZSwKICAgICAgaGFzaDogaGFzaCA/IGhhc2guaGV4ZGlnZXN0KCkgOiAiIgogICAgfTsKICB9CiAgYXN5bmMgdHJhbnNsYXRlRm9udChfcmVmOSkgewogICAgbGV0IHsKICAgICAgZGVzY3JpcHRvciwKICAgICAgZGljdCwKICAgICAgYmFzZURpY3QsCiAgICAgIGNvbXBvc2l0ZSwKICAgICAgdHlwZSwKICAgICAgZmlyc3RDaGFyLAogICAgICBsYXN0Q2hhciwKICAgICAgdG9Vbmljb2RlLAogICAgICBjc3NGb250SW5mbwogICAgfSA9IF9yZWY5OwogICAgY29uc3QgaXNUeXBlM0ZvbnQgPSB0eXBlID09PSAiVHlwZTMiOwogICAgbGV0IHByb3BlcnRpZXM7CiAgICBpZiAoIWRlc2NyaXB0b3IpIHsKICAgICAgaWYgKGlzVHlwZTNGb250KSB7CiAgICAgICAgZGVzY3JpcHRvciA9IG5ldyBfcHJpbWl0aXZlcy5EaWN0KG51bGwpOwogICAgICAgIGR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CiAgICAgICAgICB0eXBlLAogICAgICAgICAgbmFtZTogYmFzZUZvbnROYW1lLAogICAgICAgICAgbG9hZGVkTmFtZTogYmFzZURpY3QubG9hZGVkTmFtZSwKICAgICAgICAgIHdpZHRoczogbWV0cmljcy53aWR0aHMsCiAgICAgICAgICBkZWZhdWx0V2lkdGg6IG1ldHJpY3MuZGVmYXVsdFdpZHRoLAogICAgICAgICAgaXNTaW11bGF0ZWRGbGFnczogdHJ1ZSwKICAgICAgICAgIGZsYWdzLAogICAgICAgICAgZmlyc3RDaGFyLAogICAgICAgICAgbGFzdENoYXIsCiAgICAgICAgICB0b1VuaWNvZGUsCiAgICAgICAgICB4SGVpZ2h0OiAwLAogICAgICAgICAgY2FwSGVpZ2h0OiAwLAogICAgICAgICAgaXRhbGljQW5nbGU6IDAsCiAgICAgICAgICBpc1R5cGUzRm9udAogICAgICAgIH07CiAgICAgICAgY29uc3Qgd2lkdGhzID0gZGljdC5nZXQoIldpZHRocyIpOwogICAgICAgIGNvbnN0IHN0YW5kYXJkRm9udE5hbWUgPSAoMCwgX3N0YW5kYXJkX2ZvbnRzLmdldFN0YW5kYXJkRm9udE5hbWUpKGJhc2VGb250TmFtZSk7CiAgICAgICAgbGV0IGZpbGUgPSBudWxsOwogICAgICAgIGlmIChzdGFuZGFyZEZvbnROYW1lKSB7CiAgICAgICAgICBwcm9wZXJ0aWVzLmlzU3RhbmRhcmRGb250ID0gdHJ1ZTsKICAgICAgICAgIGZpbGUgPSBhd2FpdCB0aGlzLmZldGNoU3RhbmRhcmRGb250RGF0YShzdGFuZGFyZEZvbnROYW1lKTsKICAgICAgICAgIHByb3BlcnRpZXMuaXNJbnRlcm5hbEZvbnQgPSAhIWZpbGU7CiAgICAgICAgfQogICAgICAgIHJldHVybiB0aGlzLmV4dHJhY3REYXRhU3RydWN0dXJlcyhkaWN0LCBkaWN0LCBwcm9wZXJ0aWVzKS50aGVuKG5ld1Byb3BlcnRpZXMgPT4gewogICAgICAgICAgaWYgKHdpZHRocykgewogICAgICAgICAgICBjb25zdCBnbHlwaFdpZHRocyA9IFtdOwogICAgICAgICAgICBsZXQgaiA9IGZpcnN0Q2hhcjsKICAgICAgICAgICAgZm9yIChjb25zdCB3aWR0aCBvZiB3aWR0aHMpIHsKICAgICAgICAgICAgICBnbHlwaFdpZHRoc1tqKytdID0gdGhpcy54cmVmLmZldGNoSWZSZWYod2lkdGgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG5ld1Byb3BlcnRpZXMud2lkdGhzID0gZ2x5cGhXaWR0aHM7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBuZXdQcm9wZXJ0aWVzLndpZHRocyA9IHRoaXMuYnVpbGRDaGFyQ29kZVRvV2lkdGgobWV0cmljcy53aWR0aHMsIG5ld1Byb3BlcnRpZXMpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG5ldyBfZm9udHMuRm9udChiYXNlRm9udE5hbWUsIGZpbGUsIG5ld1Byb3BlcnRpZXMpOwogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgICBsZXQgZm9udE5hbWUgPSBkZXNjcmlwdG9yLmdldCgiRm9udE5hbWUiKTsKICAgIGxldCBiYXNlRm9udCA9IGRpY3QuZ2V0KCJCYXNlRm9udCIpOwogICAgaWYgKHR5cGVvZiBmb250TmFtZSA9PT0gInN0cmluZyIpIHsKICAgICAgZm9udE5hbWUgPSBfcHJpbWl0aXZlcy5OYW1lLmdldChmb250TmFtZSk7CiAgICB9CiAgICBpZiAodHlwZW9mIGJhc2VGb250ID09PSAic3RyaW5nIikgewogICAgICBiYXNlRm9udCA9IF9wcmltaXRpdmVzLk5hbWUuZ2V0KGJhc2VGb250KTsKICAgIH0KICAgIGlmICghaXNUeXBlM0ZvbnQpIHsKICAgICAgY29uc3QgZm9udE5hbWVTdHIgPSBmb250TmFtZSAmJiBmb250TmFtZS5uYW1lOwogICAgICBjb25zdCBiYXNlRm9udFN0ciA9IGJhc2VGb250ICYmIGJhc2VGb250L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kRm9udERhdGEoc3RhbmRhcmRGb250TmFtZS5uYW1lKTsKICAgICAgICBpc0ludGVybmFsRm9udCA9ICEhZm9udEZpbGU7CiAgICAgICAgYmFzZURpY3QgPSBkaWN0ID0gKDAsIF94ZmFfZm9udHMuZ2V0WGZhRm9udERpY3QpKGZvbnROYW1lLm5hbWUpOwogICAgICAgIGNvbXBvc2l0ZSA9IHRydWU7CiAgICAgIH0KICAgIH0gZWxzZSBpZiAoIWlzVHlwZTNGb250KSB7CiAgICAgIGNvbnN0IHN0YW5kYXJkRm9udE5hbWUgPSAoMCwgX3N0YW5kYXJkX2ZvbnRzLmdldFN0YW5kYXJkRm9udE5hbWUpKGZvbnROYW1lLm5hbWUpOwogICAgICBpZiAoc3RhbmRhcmRGb250TmFtZSkgewogICAgICAgIGlzU3RhbmRhcmRGb250ID0gdHJ1ZTsKICAgICAgICBmb250RmlsZSA9IGF3YWl0IHRoaXMuZmV0Y2hTdGFuZGFyZEZvbnREYXRhKHN0YW5kYXJkRm9udE5hbWUpOwogICAgICAgIGlzSW50ZXJuYWxGb250ID0gISFmb250RmlsZTsKICAgICAgfQogICAgfQogICAgcHJvcGVydGllcyA9IHsKICAgICAgdHlwZSwKICAgICAgbmFtZTogZm9udE5hbWUubmFtZSwKICAgICAgc3VidHlwZSwKICAgICAgZmlsZTogZm9udEZpbGUsCiAgICAgIGxlbmd0aDEsCiAgICAgIGxlbmd0aDIsCiAgICAgIGxlbmd0aDMsCiAgICAgIGlzU3RhbmRhcmRGb250LAogICAgICBpc0ludGVybmFsRm9udCwKICAgICAgbG9hZGVkTmFtZTogYmFzZURpY3QubG9hZGVkTmFtZSwKICAgICAgY29tcG9zaXRlLAogICAgICBmaXhlZFBpdGNoOiBmYWxzZSwKICAgICAgZm9udE1hdHJpeDogZGljdC5nZXRBcnJheSgiRm9udE1hdHJpeCIpIHx8IF91dGlsLkZPTlRfSURFTlRJVFlfTUFUUklYLAogICAgICBmaXJzdENoYXIsCiAgICAgIGxhc3RDaG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RhdGVPYmoubGVuZ3RoOwogICAgICAgICAgd2hpbGUgKGogPCBqaikgewogICAgICAgICAgICBjb25zdCBbZ1N0YXRlS2V5XSA9IGdTdGF0ZU9ialtqXTsKICAgICAgICAgICAgc3dpdGNoIChnU3RhdGVLZXkpIHsKICAgICAgICAgICAgICBjYXNlICJUUiI6CiAgICAgICAgICAgICAgY2FzZSAiVFIyIjoKICAgICAgICAgICAgICBjYXNlICJIVCI6CiAgICAgICAgICAgICAgY2FzZSAiQkciOgogICAgICAgICAgICAgIGNhc2UgIkJHMiI6CiAgICAgICAgICAgICAgY2FzZSAiVUNSIjoKICAgICAgICAgICAgICBjYXNlICJVQ1IyIjoKICAgICAgICAgICAgICAgIGdTdGF0ZU9iai5zcGxpY2UoaiwgMSk7CiAgICAgICAgICAgICAgICBqai0tOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaisrOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaSsrOwogICAgfQogIH0KfQpjbGFzcyBTdGF0ZU1hbmFnZXIgewogIGNvbnN0cnVjdG9yKCkgewogICAgbGV0IGluaXRpYWxTdGF0ZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogbmV3IEV2YWxTdGF0ZSgpOwogICAgdGhpcy5zdGF0ZSA9IGluaXRpYWxTdGF0ZTsKICAgIHRoaXMuc3RhdGVTdGFjayA9IFtdOwogIH0KICBzYXZlKCkgewogICAgY29uc3Qgb2xkID0gdGhpcy5zdGF0ZTsKICAgIHRoaXMuc3RhdGVTdGFjay5wdXNoKHRoaXMuc3RhdGUpOwogICAgdGhpcy5zdGF0ZSA9IG9sZC5jbG9uZSgpOwogIH0KICByZXN0b3JlKCkgewogICAgY29uc3QgcHJldiA9IHRoaXMuc3RhdGVTdGFjay5wb3AoKTsKICAgIGlmIChw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AgICB9OwogICAgICB0LmQgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXREYXNoLAogICAgICAgIG51bUFyZ3M6IDIsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnJpID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0UmVuZGVyaW5nSW50ZW50LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRGbGF0bmVzcywKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5ncyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldEdTdGF0ZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5xID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2F2ZSwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5RID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMucmVzdG9yZSwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5jbSA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnRyYW5zZm9ybSwKICAgICAgICBudW1BcmdzOiA2LAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5tID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMubW92ZVRvLAogICAgICAgIG51bUFyZ3M6IDIsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmwgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5saW5lVG8sCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuYyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmN1cnZlVG8sCiAgICAgICAgbnVtQXJnczogNiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQudiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmN1cnZlVG8yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5jdXJ2ZVRvMywKICAgICAgICBudW1BcmdzOiA0LAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5oID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuY2xvc2VQYXRoLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnJlID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMucmVjdGFuZ2xlLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zdHJva2UsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQucyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmNsb3NlU3Ryb2tlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmYgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5maWxsLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkYgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5maWxsLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyJmKiJdID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuZW9GaWxsLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkIgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5maWxsU3Ryb2tlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyJCKiJdID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuZW9GaWxsU3Ryb2tlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmIgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5jbG9zZUZpbGxTdHJva2UsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHRbImIqIl0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5jbG9zZUVPRmlsbFN0cm9rZSwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5uID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuZW5kUGF0aCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5XID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuY2xpcCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdFsiVyoiXSA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmVvQ2xpcCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5CVCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmJlZ2luVGV4dCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5FVCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmVuZFRleHQsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVGMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRDaGFyU3BhY2luZywKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5UdyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFdvcmRTcGFjaW5nLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlR6ID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0SFNjYWxlLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlRMID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0TGVhZGluZywKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5UZiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldEZvbnQsCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVHIgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRUZXh0UmVuZGVyaW5nTW9kZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5UcyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFRleHRSaXNlLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlRkID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMubW92ZVRleHQsCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVEQgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRMZWFkaW5nTW92ZVRleHQsCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVG0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRUZXh0TWF0cml4LAogICAgICAgIG51bUFyZ3M6IDYsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyJUKiJdID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMubmV4dExpbmUsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVGogPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zaG93VGV4dCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5USiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNob3dTcGFjZWRUZXh0LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyInIl0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5uZXh0TGluZVNob3dUZXh0LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyciJ10gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5uZXh0TGluZVNldFNwYWNpbmdTaG93VGV4dCwKICAgICAgICBudW1BcmdzOiAzLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5kMCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldENoYXJXaWR0aCwKICAgICAgICBudW1BcmdzOiAyLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5kMSA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldENoYXJXaWR0aEFuZEJvdW5kcywKICAgICAgICBudW1BcmdzOiA2LAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5DUyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFN0cm9rZUNvbG9yU3BhY2UsCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuY3MgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRGaWxsQ29sb3JTcGFjZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5TQyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFN0cm9rZUNvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiB0cnVlCiAgICAgIH07CiAgICAgIHQuU0NOID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0U3Ryb2tlQ29sb3JOLAogICAgICAgIG51bUFyZ3M6IDMzLAogICAgICAgIHZhcmlhYmxlQXJnczogdHJ1ZQogICAgICB9OwogICAgICB0LnNjID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0RmlsbENvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiB0cnVlCiAgICAgIH07CiAgICAgIHQuc2NuID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0RmlsbENvbG9yTiwKICAgICAgICBudW1BcmdzOiAzMywKICAgICAgICB2YXJpYWJsZUFyZ3M6IHRydWUKICAgICAgfTsKICAgICAgdC5HID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0U3Ryb2tlR3JheSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5nID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0RmlsbEdyYXksCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuUkcgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRTdHJva2VSR0JDb2xvciwKICAgICAgICBudW1BcmdzOiAzLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5yZyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldEZpbGxSR0JDb2xvciwKICAgICAgICBudW1BcmdzOiAzLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5LID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0U3Ryb2tlQ01ZS0NvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmsgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRGaWxsQ01ZS0NvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnNoID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2hhZGluZ0ZpbGwsCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuQkkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5iZWdpbklubGluZUltYWdlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LklEID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuYmVnaW5JbWFnZURhdGEsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuRUkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5lbmRJbmxpbmVJbWFnZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5EbyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnBhaW50WE9iamVjdCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5NUCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLm1hcmtQb2ludCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5EUCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLm1hcmtQb2ludFByb3BzLAogICAgICAgIG51bUFyZ3M6IDIsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkJNQyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmJlZ2luTWFya2VkQ29udGVudCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5CREMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5iZWdpbk1hcmtlZENvbnRlbnRQcm9wcywKICAgICAgICBudW1BcmdzOiAyLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5FTUMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5lbmRNYXJrZWRDb250ZW50LAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkJYID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuYmVnaW5Db21wYXQsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuRVggPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5lbmRDb21wYXQsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuQk0gPSBudWxsOwogICAgICB0LkJEID0gbnVsbDsKICAgICAgdC50cnVlID0gbnVsbDsKICAgICAgdC5mYSA9IG51bGw7CiAgICAgIHQuZmFsID0gbnVsbDsKICAgICAgdC5mYWxzID0gbnVsbDsKICAgICAgdC5mYWxzZSA9IG51bGw7CiAgICAgIHQubnUgPSBudWxsOwogICAgICB0Lm51bCA9IG51bGw7CiAgICAgIHQubnVsbCA9IG51bGw7CiAgICB9KTsKICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAib3BNYXAiLCBnZXRPUE1hcCgpKTsKICB9CiAgc3RhdGljIGdldCBNQVhfSU5WQUxJRF9QQVRIX09QUygpIHsKICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAi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tZH0iLmApOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IGZuID0gb3BTcGVjLmlkOwogICAgICAgIGNvbnN0IG51bUFyZ3MgPSBvcFNwZWMubnVtQXJnczsKICAgICAgICBsZXQgYXJnc0xlbmd0aCA9IGFyZ3MgIT09IG51bGwgPyBhcmdzLmxlbmd0aCA6IDA7CiAgICAgICAgaWYgKCF0aGlzLl9pc1BhdGhPcCkgewogICAgICAgICAgdGhpcy5fbnVtSW52YWxpZFBhdGhPUFMgPSAwOwogICAgICAgIH0KICAgICAgICB0aGlzLl9pc1BhdGhPcCA9IGZuID49IF91dGlsLk9QUy5tb3ZlVG8gJiYgZm4gPD0gX3V0aWwuT1BTLmVuZFBhdGg7CiAgICAgICAgaWYgKCFvcFNwZWMudmFyaWFibGVBcmdzKSB7CiAgICAgICAgICBpZiAoYXJnc0xlbmd0aCAhPT0gbnVtQXJncykgewogICAgICAgICAgICBjb25zdCBub25Qcm9jZXNzZWRBcmdzID0gdGhpcy5ub25Qcm9jZXNzZWRBcmdzOwogICAgICAgICAgICB3aGlsZSAoYXJnc0xlbmd0aCA+IG51bUFyZ3MpIHsKICAgICAgICAgICAgICBub25Qcm9jZXNzZWRBcmdzLnB1c2goYXJncy5zaGlmdCgpKTsKICAgICAgICAgICAgICBhcmdzTGVuZ3RoLS07CiAgICAgICAgICAgIH0KICAgICAgICAgICAgd2hpbGUgKGFyZ3NMZW5ndGggPCBudW1BcmdzICYmIG5vblByb2Nlc3NlZEFyZ3MubGVuZ3RoICE9PSAwKSB7CiAgICAgICAgICAgICAgaWYgKGFyZ3MgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgIGFyZ3MgPSBbXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYXJncy51bnNoaWZ0KG5vblByb2Nlc3NlZEFyZ3MucG9wKCkpOwogICAgICAgICAgICAgIGFyZ3NMZW5ndGgrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKGFyZ3NMZW5ndGggPCBudW1BcmdzKSB7CiAgICAgICAgICAgIGNvbnN0IHBhcnRpYWxNc2cgPSBgY29tbWFuZCAke2NtZH06IGV4cGVjdGVkICR7bnVtQXJnc30gYXJncywgYCArIGBidXQgcmVjZWl2ZWQgJHthcmdzTGVuZ3RofSBhcmdzLmA7CiAgICAgICAgICAgIGlmICh0aGlzLl9pc1BhdGhPcCAmJiArK3RoaXMuX251bUludmFsaWRQYXRoT1BTID4gRXZhbHVhdG9yUHJlcHJvY2Vzc29yLk1BWF9JTlZBTElEX1BBVEhfT1BTKSB7CiAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBJbnZhbGlkICR7cGFydGlhbE1zZ31gKTsKICAgICAgICAgICAgfQogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYFNraXBwaW5nICR7cGFydGlhbE1zZ31gKTsKICAgICAgICAgICAgaWYgKGFyZ3MgIT09IG51bGwpIHsKICAgICAgICAgICAgICBhcmdzLmxlbmd0aCA9IDA7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIGlmIChhcmdzTGVuZ3RoID4gbnVtQXJncykgewogICAgICAgICAgKDAsIF91dGlsLmluZm8pKGBDb21tYW5kICR7Y21kfTogZXhwZWN0ZWQgWzAsICR7bnVtQXJnc31dIGFyZ3MsIGAgKyBgYnV0IHJlY2VpdmVkICR7YXJnc0xlbmd0aH0gYXJncy5gKTsKICAgICAgICB9CiAgICAgICAgdGhpcy5wcmVwcm9jZXNzQ29tbWFuZChmbiwgYXJncyk7CiAgICAgICAgb3BlcmF0aW9uLmZuID0gZm47CiAgICAgICAgb3BlcmF0aW9uLmFyZ3MgPSBhcmdzOwogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9CiAgICAgIGlmIChvYmogPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgIHJldHVybiBmYWxzZ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ICAgICAgZG8gewogICAgICAgIGNvbnN0IGIgPSB0aGlzLnJlYWRCeXRlKCk7CiAgICAgICAgaWYgKGIgPCAwKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoInVuZXhwZWN0ZWQgRU9GIGluIGJjbWFwIik7CiAgICAgICAgfQogICAgICAgIGxhc3QgPSAhKGIgJiAweDgwKTsKICAgICAgICBuID0gbiA8PCA3IHwgYiAmIDB4N2Y7CiAgICAgIH0gd2hpbGUgKCFsYXN0KTsKICAgICAgcmV0dXJuIG47CiAgICB9CiAgICByZWFkU2lnbmVkKCkgewogICAgICBjb25zdCBuID0gdGhpcy5yZWFkTnVtYmVyKCk7CiAgICAgIHJldHVybiBuICYgMSA/IH4obiA+Pj4gMSkgOiBuID4+PiAxOwogICAgfQogICAgcmVhZEhleChudW0sIHNpemUpIHsKICAgICAgbnVtLnNldCh0aGlzLmJ1ZmZlci5zdWJhcnJheSh0aGlzLnBvcywgdGhpcy5wb3MgKyBzaXplICsgMSkpOwogICAgICB0aGlzLnBvcyArPSBzaXplICsgMTsKICAgIH0KICAgIHJlYWRIZXhOdW1iZXIobnVtLCBzaXplKSB7CiAgICAgIGxldCBsYXN0OwogICAgICBjb25zdCBzdGFjayA9IHRoaXMudG1wQnVmOwogICAgICBsZXQgc3AgPSAwOwogICAgICBkbyB7CiAgICAgICAgY29uc3QgYiA9IHRoaXMucmVhZEJ5dGUoKTsKICAgICAgICBpZiAoYiA8IDApIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigidW5leHBlY3RlZCBFT0YgaW4gYmNtYXAiKTsKICAgICAgICB9CiAgICAgICAgbGFzdCA9ICEoYiAmIDB4ODApOwogICAgICAgIHN0YWNrW3NwKytdID0gYiAmIDB4N2Y7CiAgICAgIH0gd2hpbGUgKCFsYXN0KTsKICAgICAgbGV0IGkgPSBzaXplLAogICAgICAgIGJ1ZmZlciA9IDAsCiAgICAgICAgYnVmZmVyU2l6ZSA9IDA7CiAgICAgIHdoaWxlIChpID49IDApIHsKICAgICAgICB3aGlsZSAoYnVmZmVyU2l6ZSA8IDggJiYgc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgYnVmZmVyIHw9IHN0YWNrWy0tc3BdIDw8IGJ1ZmZlclNpemU7CiAgICAgICAgICBidWZmZXJTaXplICs9IDc7CiAgICAgICAgfQogICAgICAgIG51bVtpXSA9IGJ1ZmZlciAmIDI1NTsKICAgICAgICBpLS07CiAgICAgICAgYnVmZmVyID4+PSA4OwogICAgICAgIGJ1ZmZlclNpemUgLT0gODsKICAgICAgfQogICAgfQogICAgcmVhZEhleFNpZ25lZChudW0sIHNpemUpIHsKICAgICAgdGhpcy5yZWFkSGV4TnVtYmVyKG51bSwgc2l6ZSk7CiAgICAgIGNvbnN0IHNpZ24gPSBudW1bc2l6ZV0gJiAxID8gMjU1IDogMDsKICAgICAgbGV0IGMgPSAwOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8PSBzaXplOyBpKyspIHsKICAgICAgICBjID0gKGMgJiAxKSA8PCA4IHwgbnVtW2ldOwogICAgICAgIG51bVtpXSA9IGMgPj4gMSBeIHNpZ247CiAgICAgIH0KICAgIH0KICAgIHJlYWRTdHJpbmcoKSB7CiAgICAgIGNvbnN0IGxlbiA9IHRoaXMucmVhZE51bWJlcigpOwogICAgICBsZXQgcyA9ICIiOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgcyArPSBTdHJpbmcuZnJvbUNoYXJDb2RlKHRoaXMucmVhZE51bWJlcigpKTsKICAgICAgfQogICAgICByZXR1cm4gczsKICAgIH0KICB9CiAgY2xhc3MgQmluYXJ5Q01hcFJlYWRlciB7CiAgICBhc3luYyBwcm9jZXNzKGRhdGEsIGNNYXAsIGV4dGVuZCkgewogICAgICBjb25zdCBzdHJlYW0gPSBuZXcgQmluYXJ5Q01hcFN0cmVhbShkYXRhKTsKICAgICAgY29uc3QgaGVhZGVyID0gc3RyZWFtLnJlYWRCeXRlKCk7CiAgICAgIGNNYXAudmVydGljYWwgPSAhIShoZWFkZXIgJiAxKTsKICAgICAgbGV0IHVzZUNNYXAgPSBudWxsOwogICAgICBjb25zdCBzdGFydCA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGNvbnN0IGVuZCA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGNvbnN0IGNoYXIgPSBuZXcgVWludDhBcnJheShNQVhfTlVNX1NJWkUpOwogICAgICBjb25zdCBjaGFyQ29kZSA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGNvbnN0IHRtcCA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGxldCBjb2RlOwogICAgICBsZXQgYjsKICAgICAgd2hpbGUgKChiID0gc3RyZWFtLnJlYWRCeXRlKCkpID49IDApIHsKICAgICAgICBjb25zdCB0eXBlID0gYiA+PiA1OwogICAgICAgIGlmICh0eXBlID09PSA3KSB7CiAgICAgICAgICBzd2l0Y2ggKGIgJiAweDFmKSB7CiAgICAgICAgICAgIGNhc2UgMDoKICAgICAgICAgICAgICBzdHJlYW0ucmVhZFN0cmluZygpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgdXNlQ01hcCA9IHN0cmVhbS5yZWFkU3RyaW5nKCk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgY29uc3Qgc2VxdWVuY2UgPSAhIShiICYgMHgxMCk7CiAgICAgICAgY29uc3QgZGF0YVNpemUgPSBiICYgMTU7CiAgICAgICAgaWYgKGRhdGFTaXplICsgMSA+IE1BWF9OVU1fU0laRSkgewogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJCaW5hcnlDTWF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zZSAxOgogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChzdGFydCwgZGF0YVNpemUpOwogICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcihlbmQsIGRhdGFTaXplKTsKICAgICAgICAgICAgYWRkSGV4KGVuZCwgc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWROdW1iZXIoKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoc3RhcnQsIGVuZCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKGVuZCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGFkZEhleChlbmQsIHN0YXJ0LCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgc3RyZWFtLnJlYWROdW1iZXIoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMjoKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXgoY2hhciwgZGF0YVNpemUpOwogICAgICAgICAgICBjb2RlID0gc3RyZWFtLnJlYWROdW1iZXIoKTsKICAgICAgICAgICAgY01hcC5tYXBPbmUoaGV4VG9JbnQoY2hhciwgZGF0YVNpemUpLCBjb2RlKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoY2hhciwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGlmICghc2VxdWVuY2UpIHsKICAgICAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKHRtcCwgZGF0YVNpemUpOwogICAgICAgICAgICAgICAgYWRkSGV4KGNoYXIsIHRtcCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb2RlID0gc3RyZWFtLnJlYWRTaWduZWQoKSArIChjb2RlICsgMSk7CiAgICAgICAgICAgICAgY01hcC5tYXBPbmUoaGV4VG9JbnQoY2hhciwgZGF0YVNpemUpLCBjb2RlKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMzoKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXgoc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgIGFkZEhleChlbmQsIHN0YXJ0LCBkYXRhU2l6ZSk7CiAgICAgICAgICAgIGNvZGUgPSBzdHJlYW0ucmVhZE51bWJlcigpOwogICAgICAgICAgICBjTWFwLm1hcENpZFJhbmdlKGhleFRvSW50KHN0YXJ0LCBkYXRhU2l6ZSksIGhleFRvSW50KGVuZCwgZGF0YVNpemUpLCBjb2RlKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgaWYgKCFzZXF1ZW5jZSkgewogICAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICAgIGFkZEhleChzdGFydCwgZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHN0YXJ0LnNldChlbmQpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcihlbmQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGNvZGUgPSBzdHJlYW0ucmVhZE51bWJlcigpOwogICAgICAgICAgICAgIGNNYXAubWFwQ2lkUmFuZ2UoaGV4VG9JbnQoc3RhcnQsIGRhdGFTaXplKSwgaGV4VG9JbnQoZW5kLCBkYXRhU2l6ZSksIGNvZGUpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSA0OgogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChjaGFyLCB1Y3MyRGF0YVNpemUpOwogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChjaGFyQ29kZSwgZGF0YVNpemUpOwogICAgICAgICAgICBjTWFwLm1hcE9uZShoZXhUb0ludChjaGFyLCB1Y3MyRGF0YVNpemUpLCBoZXhUb1N0cihjaGFyQ29kZSwgZGF0YVNpemUpKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoY2hhciwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICBpZiAoIXNlcXVlbmNlKSB7CiAgICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcih0bXAsIHVjczJEYXRhU2l6ZSk7CiAgICAgICAgICAgICAgICBhZGRIZXgoY2hhciwgdG1wLCB1Y3MyRGF0YVNpemUpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpbmNIZXgoY2hhckNvZGUsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleFNpZ25lZCh0bXAsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoY2hhckNvZGUsIHRtcCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGNNYXAubWFwT25lKGhleFRvSW50KGNoYXIsIHVjczJEYXRhU2l6ZSksIGhleFRvU3RyKGNoYXJDb2RlLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSA1OgogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChzdGFydCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoZW5kLCB1Y3MyRGF0YVNpemUpOwogICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXgoY2hhckNvZGUsIGRhdGFTaXplKTsKICAgICAgICAgICAgY01hcC5tYXBCZlJhbmdlKGhleFRvSW50KHN0YXJ0LCB1Y3MyRGF0YVNpemUpLCBoZXhUb0ludChlbmQsIHVjczJEYXRhU2l6ZSksIGhleFRvU3RyKGNoYXJDb2RlLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8IHN1Yml0ZW1zQ291bnQ7IGkrKykgewogICAgICAgICAgICAgIGluY0hleChlbmQsIHVjczJEYXRhU2l6ZSk7CiAgICAgICAgICAgICAgaWYgKCFzZXF1ZW5jZSkgewogICAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoc3RhcnQsIHVjczJEYXRhU2l6ZSk7CiAgICAgICAgICAgICAgICBhZGRIZXgoc3RhcnQsIGVuZCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgc3RhcnQuc2V0KGVuZCk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKGVuZCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleChjaGFyQ29kZSwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGNNYXAubWFwQmZSYW5nZShoZXhUb0ludChzdG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LiIpOwogICAgfQogIH0KICBmdW5jdGlvbiBwYXJzZUJmQ2hhcihjTWFwLCBsZXhlcikgewogICAgd2hpbGUgKHRydWUpIHsKICAgICAgbGV0IG9iaiA9IGxleGVyLmdldE9iaigpOwogICAgICBpZiAob2JqID09PSBfcHJpbWl0aXZlcy5FT0YpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoKDAsIF9wcmltaXRpdmVzLmlzQ21kKShvYmosICJlbmRiZmNoYXIiKSkgewogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBleHBlY3RTdHJpbmcob2JqKTsKICAgICAgY29uc3Qgc3JjID0gc3RyVG9JbnQob2JqKTsKICAgICAgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGV4cGVjdFN0cmluZyhvYmopOwogICAgICBjb25zdCBkc3QgPSBvYmo7CiAgICAgIGNNYXAubWFwT25lKHNyYywgZHN0KTsKICAgIH0KICB9CiAgZnVuY3Rpb24gcGFyc2VCZlJhbmdlKGNNYXAsIGxleGVyKSB7CiAgICB3aGlsZSAodHJ1ZSkgewogICAgICBsZXQgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGlmIChvYmogPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNDbWQpKG9iaiwgImVuZGJmcmFuZ2UiKSkgewogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBleHBlY3RTdHJpbmcob2JqKTsKICAgICAgY29uc3QgbG93ID0gc3RyVG9JbnQob2JqKTsKICAgICAgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGV4cGVjdFN0cmluZyhvYmopOwogICAgICBjb25zdCBoaWdoID0gc3RyVG9JbnQob2JqKTsKICAgICAgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGlmIChOdW1iZXIuaXNJbnRlZ2VyKG9iaikgfHwgdH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TsKICAgICAgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGV4cGVjdEludChvYmopOwogICAgICBjb25zdCBkc3QgPSBvYmo7CiAgICAgIGNNYXAubWFwT25lKHNyYywgZHN0KTsKICAgIH0KICB9CiAgZnVuY3Rpb24gcGFyc2VDaWRSYW5nZShjTWFwLCBsZXhlcikgewogICAgd2hpbGUgKHRydWUpIHsKICAgICAgbGV0IG9iaiA9IGxleGVyLmdldE9iaigpOwogICAgICBpZiAob2JqID09PSBfcHJpbWl0aXZlcy5FT0YpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoKDAsIF9wcmltaXRpdmVzLmlzQ21kKShvYmosICJlbmRjaWRyYW5nZSIpKSB7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGV4cGVjdFN0cmluZyhvYmopOwogICAgICBjb25zdCBsb3cgPSBzdHJUb0ludChvYmopOwogICAgICBvYmogPSBsZXhlci5nZXRPYmooKTsKICAgICAgZXhwZWN0U3RyaW5nKG9iaik7CiAgICAgIGNvbnN0IGhpZ2ggPSBzdHJUb0ludChvYmopOwogICAgICBvYmogPSBsZXhlci5nZXRPYmooKTsKICAgICAgZXhwZWN0SW50KG9iaik7CiAgICAgIGNvbnN0IGRzdExvdyA9IG9iajsKICAgICAgY01hcC5tYXBDaWRSYW5nZShsb3csIGhpZ2gsIGRzdExvdyk7CiAgICB9CiAgfQogIGZ1bmN0aW9uIHBhcnNlQ29kZXNwYWNlUmFuZ2UoY01hcCwgbGV4ZXIpIHsKICAgIHdoaWxlICh0cnVlKSB7CiAgICAgIGxldCBvYmogPSBsZXhlci5nZXRPYmooKTsKICAgICAgaWYgKG9iaiA9PT0gX3ByaW1pdGl2ZXMuRU9GKSB7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKCgwLCBfcHJpbWl0aXZlcy5pc0NtZCkob2JqLCAiZW5kY29kZXNwYWNlcmFuZ2UiKSkgewogICAgICAgIHJldHVyb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9wcmltaXRpdmVzLkVPRikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfSBlbHNlIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICBpZiAob2JqLm5hbWUgPT09ICJXTW9kZSIpIHsKICAgICAgICAgICAgcGFyc2VXTW9kZShjTWFwLCBsZXhlcik7CiAgICAgICAgICB9IGVsc2UgaWYgKG9iai5uYW1lID09PSAiQ01hcE5hbWUiKSB7CiAgICAgICAgICAgIHBhcnNlQ01hcE5hbWUoY01hcCwgbGV4ZXIpOwogICAgICAgICAgfQogICAgICAgICAgcHJldmlvdXMgPSBvYmo7CiAgICAgICAgfSBlbHNlIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5DbWQpIHsKICAgICAgICAgIHN3aXRjaCAob2JqLmNtZCkgewogICAgICAgICAgICBjYXNlICJlbmRjbWFwIjoKICAgICAgICAgICAgICBicmVhayBvYmpMb29wOwogICAgICAgICAgICBjYXNlICJ1c2VjbWFwIjoKICAgICAgICAgICAgICBpZiAocHJldmlvdXMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgICBlbWJlZGRlZFVzZUNNYXAgPSBwcmV2aW91cy5uYW1lOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAiYmVnaW5jb2Rlc3BhY2VyYW5nZSI6CiAgICAgICAgICAgICAgcGFyc2VDb2Rlc3BhY2VSYW5nZShjTWFwLCBsZXhlcik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgImJlZ2luYmZjaGFyIjoKICAgICAgICAgICAgICBwYXJzZUJmQ2hhcihjTWFwLCBsZXhlcik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgImJlZ2luY2lkY2hhciI6CiAgICAgICAgICAgICAgcGFyc2VDaWRDaGFyKG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9CiAgICAgICAgICB0aGlzLnNoaWZ0KCk7CiAgICAgICAgICByZXR1cm4gYXJyYXk7CiAgICAgICAgY2FzZSAiPDwiOgogICAgICAgICAgY29uc3QgZGljdCA9IG5ldyBfcHJpbWl0aXZlcy5EaWN0KHRoaXMueHJlZik7CiAgICAgICAgICB3aGlsZSAoISgwLCBfcHJpbWl0aXZlcy5pc0NtZCkodGhpcy5idWYxLCAiPj4iKSAmJiB0aGlzLmJ1ZjEgIT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgICAgICBpZiAoISh0aGlzLmJ1ZjEgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSkgewogICAgICAgICAgICAgICgwLCBfdXRpbC5pbmZvKSgiTWFsZm9ybWVkIGRpY3Rpb25hcnk6IGtleSBtdXN0IGJlIGEgbmFtZSBvYmplY3QiKTsKICAgICAgICAgICAgICB0aGlzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29uc3Qga2V5ID0gdGhpcy5idWYxLm5hbWU7CiAgICAgICAgICAgIHRoaXMuc2hpZnQoKTsKICAgICAgICAgICAgaWYgKHRoaXMuYnVmMSA9PT0gX3ByaW1pdGl2ZXMuRU9GKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZGljdC5zZXQoa2V5LCB0aGlzLmdldE9iaihjaXBoZXJUcmFuc2Zvcm0pKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh0aGlzLmJ1ZjEgPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgICAgICBpZiAodGhpcy5yZWNvdmVyeU1vZGUpIHsKICAgICAgICAgICAgICByZXR1cm4gZGljdDsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aHJvdyBuZXcgX2NvcmVfdXRpbHMuUGFyc2VyRU9GRXhjZXB0aW9uKCJFbmQgb2YgZmlsZSBpbnNpZGUgZGljdGlv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gICAgIENSID0gMHhkLAogICAgICBOVUwgPSAweDA7CiAgICBjb25zdCBsZXhlciA9IHRoaXMubGV4ZXIsCiAgICAgIHN0YXJ0UG9zID0gc3RyZWFtLnBvcywKICAgICAgbiA9IDEwOwogICAgbGV0IHN0YXRlID0gMCwKICAgICAgY2gsCiAgICAgIG1heWJlRUlQb3M7CiAgICB3aGlsZSAoKGNoID0gc3RyZWFtLmdldEJ5dGUoKSkgIT09IC0xKSB7CiAgICAgIGlmIChzdGF0ZSA9PT0gMCkgewogICAgICAgIHN0YXRlID0gY2ggPT09IEUgPyAxIDogMDsKICAgICAgfSBlbHNlIGlmIChzdGF0ZSA9PT0gMSkgewogICAgICAgIHN0YXRlID0gY2ggPT09IEkgPyAyIDogMDsKICAgICAgfSBlbHNlIHsKICAgICAgICBpZiAoY2ggPT09IFNQQUNFIHx8IGNoID09PSBMRiB8fCBjaCA9PT0gQ1IpIHsKICAgICAgICAgIG1heWJlRUlQb3MgPSBzdHJlYW0ucG9zOwogICAgICAgICAgY29uc3QgZm9sbG93aW5nQnl0ZXMgPSBzdHJlYW0ucGVla0J5dGVzKG4pOwogICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZm9sbG93aW5nQnl0ZXMubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICBjaCA9IGZvbGxvd2luZ0J5dGVzW2ldOwogICAgICAgICAgICBpZiAoY2ggPT09IE5VTCAmJiBmb2xsb3dpbmdCeXRlc1tpICsgMV0gIT09IE5VTCkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChjaCAhPT0gTEYgJiYgY2ggIT09IENSICYmIChjaCA8IFNQQUNFIHx8IGNoID4gMHg3ZikpIHsKICAgICAgICAgICAgICBzdGF0ZSA9IDA7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzdGF0ZSAhPT0gMikgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChsZXhlci5rbm93bkNvbW1hbmRzKSB7CiAgICAgICAgICAgIGNvbnN0IG5leHRPYmogPSBsZXhlci5wZWVrT2JqKCk7CiAgICAgICAgICAgIGlmIChuZXh0T2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuQ21kICYmICFsZXhlci5rbm93bkNvbW1hbmRzW25leHRPYmouY21kXSkgewogICAgICAgICAgICAgIHN0YXRlID0gMDsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJmaW5kRGVmYXVsdElubGluZVN0cmVhbUVuZCAtIGBsZXhlci5rbm93bkNvbW1hbmRzYCBpcyB1bmRlZmluZWQuIik7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoc3RhdGUgPT09IDIpIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHN0YXRlID0gMDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGlmIChjaCA9PT0gLTEpIHsKICAgICAgKDAsIF91dGlsLndhcm4pKCJmaW5kRGVmYXVsdElubGluZVN0cmVhbUVuZDogIiArICJSZWFjaGVkIHRoZSBlbmQgb2YgdGhlIHN0cmVhbSB3aXRob3V0IGZpbmRpbmcgYSB2YWxpZCBFSSBtYXJrZXIiKTsKICAgICAgaWYgKG1heWJlRUlQb3MpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoJy4uLiB0cnlpbmcgdG8gcmVjb3ZlciBieSB1c2luZyB0aGUgbGFzdCAiRUkiIG9jY3VycmVuY2UuJyk7CiAgICAgICAgc3RyZWFtLnNraXAoLShzdHJlYW0ucG9zIC0gbWF5YmVFSVBvcykpOwogICAgICB9CiAgICB9CiAgICBsZXQgZW5kT2Zmc2V0ID0gNDsKICAgIHN0cmVhbS5za2lwKC1lbmRPZmZzZXQpOwogICAgY2ggPSBzdHJlYW0ucGVla0J5dGUoKTsKICAgIHN0cmVhbS5za2lwKGVuZE9mZnNldCk7CiAgICBpZiAoISgwLCBfY29yZV91dGlscy5pc1doaXRlU3BhY2UpKGNoKSkgewogICAgICBlbmRPZmZzZXQtLTsKICAgIH0KICAgIHJldHVybiBzdHJlYW0ucG9zIC0gZW5kT2Zmc2V0IC0gc3RhcnRQb3M7CiAgfQogIGZpbmREQ1REZWNvZGVJbmxpbmVTdHJlYW1FbmQoc3RyZWFtKSB7CiAgICBjb25zdCBzdGFydFBvcyA9IHN0cmVhbS5wb3M7CiAgICBsZXQgZm91bmRFT0kgPSBmYWxzZSwKICAgICAgYiwKICAgICAgbWFya2VyTGVuZ3RoOwogICAgd2hpbGUgKChiID0gc3RyZWFtLmdldEJ5dGUoKSkgIT09IC0xKSB7CiAgICAgIGlmIChiICE9PSAweGZmKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgc3dpdGNoIChzdHJlYW0uZ2V0Qnl0ZSgpKSB7CiAgICAgICAgY2FzZSAweDAwOgogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmOgogICAgICAgICAgc3RyZWFtLnNraXAoLTEpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGQ5OgogICAgICAgICAgZm91bmRFT0kgPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGMwOgogICAgICAgIGNhc2UgMHhjMToKICAgICAgICBjYXNlIDB4YzI6CiAgICAgICAgY2FzZSAweGMzOgogICAgICAgIGNhc2UgMHhjNToKICAgICAgICBjYXNlIDB4YzY6CiAgICAgICAgY2FzZSAweGM3OgogICAgICAgIGNhc2UgMHhjOToKICAgICAgICBjYXNlIDB4Y2E6CiAgICAgICAgY2FzZSAweGNiOgogICAgICAgIGNhc2UgMHhjZDoKICAgICAgICBjYXNlIDB4Y2U6CiAgICAgICAgY2FzZSAweGNmOgogICAgICAgIGNhc2UgMHhjNDoKICAgICAgICBjYXNlIDB4Y2M6CiAgICAgICAgY2FzZSAweGRhOgogICAgICAgIGNhc2UgMHhkYjoKICAgICAgICBjYXNlIDB4ZGM6CiAgICAgICAgY2FzZSAweGRkOgogICAgICAgIGNhc2UgMHhkZToKICAgICAgICBjYXNlIDB4ZGY6CiAgICAgICAgY2FzZSAweGUwOgogICAgICAgIGNhc2UgMHhlMToKICAgICAgICBjYXNlIDB4ZTI6CiAgICAgICAgY2FzZSAweGUzOgogICAgICAgIGNhc2UgMHhlNDoKICAgICAgICBjYXNlIDB4ZTU6CiAgICAgICAgY2FzZSAweGU2OgogICAgICAgIGNhc2UgMHhlNzoKICAgICAgICBjYXNlIDB4ZTg6CiAgICAgICAgY2FzZSAweGU5OgogICAgICAgIGNhc2UgMHhlYToKICAgICAgICBjYXNlIDB4ZWI6CiAgICAgICAgY2FzZSAweGVjOgogICAgICAgIGNhc2UgMHhlZDoKICAgICAgICBjYXNlIDB4ZWU6CiAgICAgICAgY2FzZSAweGVmOgogICAgICAgIGNhc2UgMHhmZToKICAgICAgICAgIG1hcmtlckxlbmd0aCA9IHN0cmVhbS5nZXRVaW50MTYoKTsKICAgICAgICAgIGlmIChtYXJrZXJMZW5ndGggPiAyKSB7CiAgICAgICAgICAgIHN0cmVhbS5za2lwKG1hcmtlckxlbmd0aCAtIDIpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RyZWFtLnNraXAoLTIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKGZvdW5kRU9JKSB7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIH0KICAgIGNvbnN0IGxlbmd0aCA9IHN0cmVhbS5wb3MgLSBzdGFydFBvczsKICAgIGlmIChiID09PSAtMSkgewogICAgICAoMCwgX3V0aWwud2FybikoIklubGluZSBEQ1REZWNvZGUgaW1hZ2Ugc3RyZWFtOiAiICsgIkVPSSBtYXJrZXIgbm90IGZ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l2aWRlQnkgKj0gMTA7CiAgICAgICAgICB9CiAgICAgICAgICBiYXNlVmFsdWUgPSBiYXNlVmFsdWUgKiAxMCArIGN1cnJlbnREaWdpdDsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoY2ggPT09IDB4MmUpIHsKICAgICAgICBpZiAoZGl2aWRlQnkgPT09IDApIHsKICAgICAgICAgIGRpdmlkZUJ5ID0gMTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGNoID09PSAweDJkKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJCYWRseSBmb3JtYXR0ZWQgbnVtYmVyOiBtaW51cyBzaWduIGluIHRoZSBtaWRkbGUiKTsKICAgICAgfSBlbHNlIGlmIChjaCA9PT0gMHg0NSB8fCBjaCA9PT0gMHg2NSkgewogICAgICAgIGNoID0gdGhpcy5wZWVrQ2hhcigpOwogICAgICAgIGlmIChjaCA9PT0gMHgyYiB8fCBjaCA9PT0gMHgyZCkgewogICAgICAgICAgcG93ZXJWYWx1ZVNpZ24gPSBjaCA9PT0gMHgyZCA/IC0xIDogMTsKICAgICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICB9IGVsc2UgaWYgKGNoIDwgMHgzMCB8fCBjaCA+IDB4MzkpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBlTm90YXRpb24gPSB0cnVlOwogICAgICB9IGVsc2UgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBpZiAoZGl2aWRlQnkgIT09IDApIHsKICAgICAgYmFzZVZhbHVlIC89IGRpdmlkZUJ5OwogICAgfQogICAgaWYgKGVOb3RhdGlvbikgewogICAgICBiYXNlVmFsdWUgKj0gMTAgKiogKHBvd2VyVmFsdWVTaWduICogcG93ZXJWYWx1ZSk7CiAgICB9CiAgICByZXR1cm4gc2lnbiAqIGJhc2VWYWx1ZTsKICB9CiAgZ2V0U3RyaW5nKCkgewogICAgbGV0IG51bVBhcmVuID0gMTsKICAgIGxldCBkb25lID0gZmFsc2U7CiAgICBjb25zdCBzdHJCdWYgPSB0aGlzLnN0ckJ1ZjsKICAgIHN0ckJ1Zi5sZW5ndGggPSAwOwogICAgbGV0IGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgd2hpbGUgKHRydWUpIHsKICAgICAgbGV0IGNoYXJCdWZmZXJlZCA9IGZhbHNlOwogICAgICBzd2l0Y2ggKGNoIHwgMCkgewogICAgICAgIGNhc2UgLTE6CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlVudGVybWluYXRlZCBzdHJpbmciKTsKICAgICAgICAgIGRvbmUgPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDI4OgogICAgICAgICAgKytudW1QYXJlbjsKICAgICAgICAgIHN0ckJ1Zi5wdXNoKCIoIik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4Mjk6CiAgICAgICAgICBpZiAoLS1udW1QYXJlbiA9PT0gMCkgewogICAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICAgIGRvbmUgPSB0cnVlOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RyQnVmLnB1c2goIikiKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHg1YzoKICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgc3dpdGNoIChjaCkgewogICAgICAgICAgICBjYXNlIC0xOgogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW50ZXJtaW5hdGVkIHN0cmluZyIpOwogICAgICAgICAgICAgIGRvbmUgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDB4NmU6CiAgICAgICAgICAgICAgc3RyQnVmLnB1c2goIlxuIik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHg3MjoKICAgICAgICAgICAgICBzdHJCdWYucHVzaCgiXHIiKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAweDc0OgogICAgICAgICAgICAgIHN0ckJ1Zi5wdXNoKCJcdCIpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDB4NjI6CiAgICAgICAgICAgICAgc3RyQnVmLnB1c2goIlxiIik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHg2NjoKICAgICAgICAgICAgICBzdHJCdWYucHVzaCgiXGYiKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAweDVjOgogICAgICAgICAgICBjYXNlIDB4Mjg6CiAgICAgICAgICAgIGNhc2UgMHgyOToKICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKGNoKSk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHgzMDoKICAgICAgICAgICAgY2FzZSAweDMxOgogICAgICAgICAgICBjYXNlIDB4MzI6CiAgICAgICAgICAgIGNhc2UgMHgzMzoKICAgICAgICAgICAgY2FzZSAweDM0OgogICAgICAgICAgICBjYXNlIDB4MzU6CiAgICAgICAgICAgIGNhc2UgMHgzNjoKICAgICAgICAgICAgY2FzZSAweDM3OgogICAgICAgICAgICAgIGxldCB4ID0gY2ggJiAweDBmOwogICAgICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgICAgIGNoYXJCdWZmZXJlZCA9IHRydWU7CiAgICAgICAgICAgICAgaWYgKGNoID49IDB4MzAgJiYgY2ggPD0gMHgzNykgewogICAgICAgICAgICAgICAgeCA9ICh4IDw8IDMpICsgKGNoICYgMHgwZik7CiAgICAgICAgICAgICAgICBjaCA9IHRoaXMubmV4dENoYXIoKTsKICAgICAgICAgICAgICAgIGlmIChjaCA+PSAweDMwICYmIGNoIDw9IDB4MzcpIHsKICAgICAgICAgICAgICAgICAgY2hhckJ1ZmZlcmVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgIHggPSAoeCA8PCAzKSArIChjaCAmIDB4MGYpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKHgpKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAweDBkOgogICAgICAgICAgICAgIGlmICh0aGlzLnBlZWtDaGFyKCkgPT09IDB4MGEpIHsKICAgICAgICAgICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHgwYToKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKGNoKSk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBkZWZhdWx0OgogICAgICAgICAgc3RyQnVmLnB1c2goU3RyaW5nLmZyb21DaGFyQ29kZShjaCkpOwogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKGRvbmUpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoIWNoYXJCdWZmZXJlZCkgewogICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gc3RyQnVmLmpvaW4oIiIpOwogIH0KICBnZXROYW1lKCkgewogICAgbGV0IGNoLCBwcmV2aW91c0NoOwogICAgY29uc3Qgc3RyQnVmID0gdGhpcy5zdHJCdWY7CiAgICBzdHJCdWYubGVuZ3RoID0gMDsKICAgIHdoaWxlICgoY2ggPSB0aGlzLm5leHRDaGFyKCkpID49IDAgJiYgIXNwZWNpYWxDaGFyc1tjaF0pIHsKICAgICAgaWYgKGNoID09PSAweDIzKSB7CiAgICAgICAgY2ggPSB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgaWYgKHNwZWNpYWxDaGFyc1tjaF0pIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiTGV4ZXJfZ2V0TmFtZTogIiArICJOVU1CRVIgU0lHTiAoIykgc2hvdWxkIGJlIGZvbGxvd2VkIGJ5IGEgaGV4YWRlY2ltYWwgbnVtYmVyLiIpOwogICAgICAgICAgc3RyQnVmLnB1c2goIiMiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBjb25zdCB4ID0gdG9IZXhEaWdpdChjaCk7CiAgICAgICAgaWYgKHggIT09IC0xKSB7CiAgICAgICAgICBwcmV2aW91c0NoID0gY2g7CiAgICAgICAgICBjaCA9IHRoaXMubmV4dENoYXIoKTsKICAgICAgICAgIGNvbnN0IHgyID0gdG9IZXhEaWdpdChjaCk7CiAgICAgICAgICBpZiAoeDIgPT09IC0xKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgTGV4ZXJfZ2V0TmFtZTogSWxsZWdhbCBkaWdpdCAoJHtTdHJpbmcuZnJvbUNoYXJDb2RlKGNoKX0pIGAgKyAiaW4gaGV4YWRlY2ltYWwgbnVtYmVyLiIpOwogICAgICAgICAgICBzdHJCdWYucHVzaCgiIyIsIFN0cmluZy5mcm9tQ2hhckNvZGUocHJldmlvdXNDaCkpOwogICAgICAgICAgICBpZiAoc3BlY2lhbENoYXJzW2NoXSkgewogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHN0ckJ1Zi5wdXNoKFN0cmluZy5mcm9tQ2hhckNvZGUoY2gpKTsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKHggPDwgNCB8IHgyKSk7CiAgICAgIC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CiAgICBsZXQgaXNGaXJzdEhleCA9IHRydWU7CiAgICBsZXQgZmlyc3REaWdpdCwgc2Vjb25kRGlnaXQ7CiAgICB0aGlzLl9oZXhTdHJpbmdOdW1XYXJuID0gMDsKICAgIHdoaWxlICh0cnVlKSB7CiAgICAgIGlmIChjaCA8IDApIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoIlVudGVybWluYXRlZCBoZXggc3RyaW5nIik7CiAgICAgICAgYnJlYWs7CiAgICAgIH0gZWxzZSBpZiAoY2ggPT09IDB4M2UpIHsKICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgYnJlYWs7CiAgICAgIH0gZWxzZSBpZiAoc3BlY2lhbENoYXJzW2NoXSA9PT0gMSkgewogICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgewogICAgICAgIGlmIChpc0ZpcnN0SGV4KSB7CiAgICAgICAgICBmaXJzdERpZ2l0ID0gdG9IZXhEaWdpdChjaCk7CiAgICAgICAgICBpZiAoZmlyc3REaWdpdCA9PT0gLTEpIHsKICAgICAgICAgICAgdGhpcy5faGV4U3RyaW5nV2FybihjaCk7CiAgICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgc2Vjb25kRGlnaXQgPSB0b0hleERpZ2l0KGNoKTsKICAgICAgICAgIGlmIChzZWNvbmREaWdpdCA9PT0gLTEpIHsKICAgICAgICAgICAgdGhpcy5faGV4U3RyaW5nV2FybihjaCk7CiAgICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHN0ckJ1Zi5wdXNoKFN0cmluZy5mcm9tQ2hhckNvZGUoZmlyc3REaWdpdCA8PCA0IHwgc2Vjb25kRGlnaXQpKTsKICAgICAgICB9CiAgICAgICAgaXNGaXJzdEhleCA9ICFpc0ZpcnN0SGV4OwogICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gc3RyQnVmLmpvaW4oIiIpOwogIH0KICBnZXRPYmooKSB7CiAgICBsZXQgY29tbWVudCA9IGZhbHNlOwogICAgbGV0IGNoID0gdGhpcy5jdXJyZW50Q2hhcjsKICAgIHdoaWxlICh0cnVlKSB7CiAgICAgIGlmIChjaCA8IDApIHsKICAgICAgICByZXR1cm4gX3ByaW1pdGl2ZXMuRU9GOwogICAgICB9CiAgICAgIGlmIChjb21tZW50KSB7CiAgICAgICAgaWYgKGNoID09PSAweDBhIHx8IGNoID09PSAweDBkKSB7CiAgICAgICAgICBjb21tZW50ID0gZmFsc2U7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGNoID09PSAweDI1KSB7CiAgICAgICAgY29tbWVudCA9IHRydWU7CiAgICAgIH0gZWxzZSBpZiAoc3BlY2lhbENoYXJzW2NoXSAhPT0gMSkgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgfQogICAgc3dpdGNoIChjaCB8IDApIHsKICAgICAgY2FzZSAweDMwOgogICAgICBjYXNlIDB4MzE6CiAgICAgIGNhc2UgMHgzMjoKICAgICAgY2FzZSAweDMzOgogICAgICBjYXNlIDB4MzQ6CiAgICAgIGNhc2UgMHgzNToKICAgICAgY2FzZSAweDM2OgogICAgICBjYXNlIDB4Mzc6CiAgICAgIGNhc2UgMHgzODoKICAgICAgY2FzZSAweDM5OgogICAgICBjYXNlIDB4MmI6CiAgICAgIGNhc2UgMHgyZDoKICAgICAgY2FzZSAweDJlOgogICAgICAgIHJldHVybiB0aGlzLmdldE51bWJlcigpOwogICAgICBjYXNlIDB4Mjg6CiAgICAgICAgcmV0dXJuIHRoaXMuZ2V0U3RyaW5nKCk7CiAgICAgIGNhc2UgM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hcmFjdGVyOiAke2NofWApOwogICAgfQogICAgbGV0IHN0ciA9IFN0cmluZy5mcm9tQ2hhckNvZGUoY2gpOwogICAgaWYgKGNoIDwgMHgyMCB8fCBjaCA+IDB4N2YpIHsKICAgICAgY29uc3QgbmV4dENoID0gdGhpcy5wZWVrQ2hhcigpOwogICAgICBpZiAobmV4dENoID49IDB4MjAgJiYgbmV4dENoIDw9IDB4N2YpIHsKICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgcmV0dXJuIF9wcmltaXRpdmVzLkNtZC5nZXQoc3RyKTsKICAgICAgfQogICAgfQogICAgY29uc3Qga25vd25Db21tYW5kcyA9IHRoaXMua25vd25Db21tYW5kczsKICAgIGxldCBrbm93bkNvbW1hbmRGb3VuZCA9IGtub3duQ29tbWFuZHMgJiYga25vd25Db21tYW5kc1tzdHJdICE9PSB1bmRlZmluZWQ7CiAgICB3aGlsZSAoKGNoID0gdGhpcy5uZXh0Q2hhcigpKSA+PSAwICYmICFzcGVjaWFsQ2hhcnNbY2hdKSB7CiAgICAgIGNvbnN0IHBvc3NpYmxlQ29tbWFuZCA9IHN0ciArIFN0cmluZy5mcm9tQ2hhckNvZGUoY2gpOwogICAgICBpZiAoa25vd25Db21tYW5kRm91bmQgJiYga25vd25Db21tYW5kc1twb3NzaWJsZUNvbW1hbmRdID09PSB1bmRlZmluZWQpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoc3RyLmxlbmd0aCA9PT0gMTI4KSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBDb21tYW5kIHRva2VuIHRvbyBsb25nOiAke3N0ci5sZW5ndGh9YCk7CiAgICAgIH0KICAgICAgc3RyID0gcG9zc2libGVDb21tYW5kOwogICAgICBrbm93bkNvbW1hbmRGb3VuZCA9IGtub3duQ29tbWFuZHMgJiYga25vd25Db21tYW5kc1tzdHJdICE9PSB1bmRlZmluZWQ7CiAgICB9CiAgICBpZiAoc3RyID09PSAidHJ1ZSIpIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBpZiAoc3RyID09PSAiZmFsc2UiKSB7CiAgICAgIHJldHVybiBmYWxzZTsKICAgIH0KICAgIGlmIChzdHIgPT09ICJudWxsIikgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIGlmIChzdHIgPT09ICJCSSIpIHsKICAgICAgdGhpcy5iZWdpbklubGluZUltYWdlUG9zID0gdGhpcy5zdHJlYW0ucG9zOwogICAgfQogICAgcmV0dXJuIF9wcmltaXRpdmVzLkNtZC5nZXQoc3RyKTsKICB9CiAgcGVla09iaigpIHsKICAgIGNvbnN0IHN0cmVhbVBvcyA9IHRoaXMuc3RyZWFtLnBvcywKICAgICAgY3VycmVudENoYXIgPSB0aGlzLmN1cnJlbnRDaGFyLAogICAgICBiZWdpbklubGluZUltYWdlUG9zID0gdGhpcy5iZWdpbklubGluZUltYWdlUG9zOwogICAgbGV0IG5leHRPYmo7CiAgICB0cnkgewogICAgICBuZXh0T2JqID0gdGhpcy5nZXRPYmooKTsKICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgIGlmIChleCBpbnN0YW5jZW9mIF9jb3JlX3V0aWxzLk1pc3NpbmdEYXRhRXhjZXB0aW9uKSB7CiAgICAgICAgdGhyb3cgZXg7CiAgICAgIH0KICAgICAgKDAsIF91dGlsLndhcm4pKGBwZWVrT2JqOiAke2V4fWApOwogICAgfQogICAgdGhpcy5zdHJlYW0ucG9zID0gc3RyZWFtUG9zOwogICAgdGhpcy5jdXJyZW50Q2hhciA9IGN1cnJlbnRDaGFyOwogICAgdGhpcy5iZWdpbklubGluZUltYWdlUG9zID0gYmVnaW5JbmxpbmVJbWFnZVBvczsKICAgIHJldHVybiBuZXh0T2JqOwogIH0KICBza2lwVG9OZXh0TGluZSgpIHsKICAgIGxldCBjaCA9IHRoaXMuY3VycmVudENoYXI7CiAgICB3aGlsZSAoY2ggPj0gMCkgewogICAgICBpZiAoY2ggPT09ID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VyW2J1ZmZlckxlbmd0aCArIGldID0gMDsKICAgICAgfQogICAgICB0aGlzLmJ1ZmZlckxlbmd0aCArPSA0OwogICAgfSBlbHNlIHsKICAgICAgY29uc3QgaW5wdXQgPSB0aGlzLmlucHV0OwogICAgICBpbnB1dFswXSA9IGM7CiAgICAgIGZvciAoaSA9IDE7IGkgPCA1OyArK2kpIHsKICAgICAgICBjID0gc3RyLmdldEJ5dGUoKTsKICAgICAgICB3aGlsZSAoKDAsIF9jb3JlX3V0aWxzLmlzV2hpdGVTcGFjZSkoYykpIHsKICAgICAgICAgIGMgPSBzdHIuZ2V0Qnl0ZSgpOwogICAgICAgIH0KICAgICAgICBpbnB1dFtpXSA9IGM7CiAgICAgICAgaWYgKGMgPT09IEVPRiB8fCBjID09PSBUSUxEQV9DSEFSKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0KICAgICAgYnVmZmVyID0gdGhpcy5lbnN1cmVCdWZmZXIoYnVmZmVyTGVuZ3RoICsgaSAtIDEpOwogICAgICB0aGlzLmJ1ZmZlckxlbmd0aCArPSBpIC0gMTsKICAgICAgaWYgKGkgPCA1KSB7CiAgICAgICAgZm9yICg7IGkgPCA1OyArK2kpIHsKICAgICAgICAgIGlucHV0W2ldID0gMHgyMSArIDg0OwogICAgICAgIH0KICAgICAgICB0aGlzLmVvZiA9IHRydWU7CiAgICAgIH0KICAgICAgbGV0IHQgPSAwOwogICAgICBmb3IgKGkgPSAwOyBpIDwgNTsgKytpKSB7CiAgICAgICAgdCA9IHQgKiA4NSArIChpbnB1dFtpXSAtIDB4MjEpOwogICAgICB9CiAgICAgIGZvciAoaSA9IDM7IGkgPj0gMDsgLS1pKSB7CiAgICAgICAgYnVmZmVyW2J1ZmZlckxlbmd0aCArIGldID0gdCAmIDB4ZmY7CiAgICAgICAgdCA+Pj0gODsKICAgICAgfQogICAgfQogIH0KfQpleHBvcnRzLkFzY2lpODVTdHJlYW0gPSBBc2NpaTg1U3RyZWFtOwoKL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dExpbmUyRCA9IHRoaXMuZW5jb2RpbmcgPCAwOwogICAgdGhpcy5pbnB1dEJpdHMgPSAwOwogICAgdGhpcy5pbnB1dEJ1ZiA9IDA7CiAgICB0aGlzLm91dHB1dEJpdHMgPSAwOwogICAgdGhpcy5yb3dzRG9uZSA9IGZhbHNlOwogICAgbGV0IGNvZGUxOwogICAgd2hpbGUgKChjb2RlMSA9IHRoaXMuX2xvb2tCaXRzKDEyKSkgPT09IDApIHsKICAgICAgdGhpcy5fZWF0Qml0cygxKTsKICAgIH0KICAgIGlmIChjb2RlMSA9PT0gMSkgewogICAgICB0aGlzLl9lYXRCaXRzKDEyKTsKICAgIH0KICAgIGlmICh0aGlzLmVuY29kaW5nID4gMCkgewogICAgICB0aGlzLm5leHRMaW5lMkQgPSAhdGhpcy5fbG9va0JpdHMoMSk7CiAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICB9CiAgfQogIHJlYWROZXh0Q2hhcigpIHsKICAgIGlmICh0aGlzLmVvZikgewogICAgICByZXR1cm4gLTE7CiAgICB9CiAgICBjb25zdCByZWZMaW5lID0gdGhpcy5yZWZMaW5lOwogICAgY29uc3QgY29kaW5nTGluZSA9IHRoaXMuY29kaW5nTGluZTsKICAgIGNvbnN0IGNvbHVtbnMgPSB0aGlzLmNvbHVtbnM7CiAgICBsZXQgcmVmUG9zLCBibGFja1BpeGVscywgYml0cywgaTsKICAgIGlmICh0aGlzLm91dHB1dEJpdHMgPT09IDApIHsKICAgICAgaWYgKHRoaXMucm93c0RvbmUpIHsKICAgICAgICB0aGlzLmVvZiA9IHRydWU7CiAgICAgIH0KICAgICAgaWYgKHRoaXMuZW9mKSB7CiAgICAgICAgcmV0dXJuIC0xOwogICAgICB9CiAgICAgIHRoaXMuZXJyID0gZmFsc2U7CiAgICAgIGxldCBjb2RlMSwgY29kZTIsIGNvZGUzOwogICAgICBpZiAodGhpcy5uZXh0TGluZTJEKSB7CiAgICAgICAgZm9yIChpID0gMDsgY29kaW5nTGluZVtpXSA8IGNvbHVtbnM7ICsraSkgewogICAgICAgICAgcmVmTGluZVtpXSA9IGNvZGluZ0xpbmVbaV07CiAgICAgICAgfQogICAgICAgIHJlZkxpbmVbaSsrXSA9IGNvbHVtbnM7CiAgICAgICAgcmVmTGluZVtpXSA9IGNvbHVtbnM7CiAgICAgICAgY29kaW5nTGluZVswXSA9IDA7CiAgICAgICAgdGhpcy5jb2RpbmdQb3MgPSAwOwogICAgICAgIHJlZlBvcyA9IDA7CiAgICAgICAgYmxhY2tQaXhlbHMgPSAwOwogICAgICAgIHdoaWxlIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgIGNvZGUxID0gdGhpcy5fZ2V0VHdvRGltQ29kZSgpOwogICAgICAgICAgc3dpdGNoIChjb2RlMSkgewogICAgICAgICAgICBjYXNlIHR3b0RpbVBhc3M6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zICsgMV0sIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBpZiAocmVmTGluZVtyZWZQb3MgKyAxXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1Ib3JpejoKICAgICAgICAgICAgICBjb2RlMSA9IGNvZGUyID0gMDsKICAgICAgICAgICAgICBpZiAoYmxhY2tQaXhlbHMpIHsKICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgY29kZTEgKz0gY29kZTMgPSB0aGlzLl9nZXRCbGFja0NvZGUoKTsKICAgICAgICAgICAgICAgIH0gd2hpbGUgKGNvZGUzID49IDY0KTsKICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgY29kZTIgKz0gY29kZTMgPSB0aGlzLl9nZXRXaGl0ZUNvZGUoKTsKICAgICAgICAgICAgICAgIH0gd2hpbGUgKGNvZGUzID49IDY0KTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICBjb2RlMSArPSBjb2RlMyA9IHRoaXMuX2dldFdoaXRlQ29kZSgpOwogICAgICAgICAgICAgICAgfSB3aGlsZSAoY29kZTMgPj0gNjQpOwogICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICBjb2RlMiArPSBjb2RlMyA9IHRoaXMuX2dldEJsYWNrQ29kZSgpOwogICAgICAgICAgICAgICAgfSB3aGlsZSAoY29kZTMgPj0gNjQpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aGlzLl9hZGRQaXhlbHMoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gKyBjb2RlMSwgYmxhY2tQaXhlbHMpOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIHRoaXMuX2FkZFBpeGVscyhjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSArIGNvZGUyLCBibGFja1BpeGVscyBeIDEpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB3aGlsZSAocmVmTGluZVtyZWZQb3NdIDw9IGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdICYmIHJlZkxpbmVbcmVmUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0UjM6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zXSArIDMsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0UjI6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zXSArIDIsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0UjE6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zXSArIDEsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0MDoKICAgICAgICAgICAgICB0aGlzLl9hZGRQaXhlbHMocmVmTGluZVtyZWZQb3NdLCBibGFja1BpeGVscyk7CiAgICAgICAgICAgICAgYmxhY2tQaXhlbHMgXj0gMTsKICAgICAgICAgICAgICBpZiAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICArK3JlZlBvczsKICAgICAgICAgICAgICAgIHdoaWxlIChyZWZMaW5lW3JlZlBvc10gPD0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gJiYgcmVmTGluZVtyZWZQb3NdIDwgY29sdW1ucykgewogICAgICAgICAgICAgICAgICByZWZQb3MgKz0gMjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgdHdvRGltVmVydEwzOgogICAgICAgICAgICAgIHRoaXMuX2FkZFBpeGVsc05lZyhyZWZMaW5lW3JlZlBvc10gLSAzLCBibGFja1BpeGVscyk7CiAgICAgICAgICAgICAgYmxhY2tQaXhlbHMgXj0gMTsKICAgICAgICAgICAgICBpZiAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICBpZiAocmVmUG9zID4gMCkgewogICAgICAgICAgICAgICAgICAtLXJlZlBvczsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0TDI6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzTmVnKHJlZkxpbmVbcmVmUG9zXSAtIDIsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIGlmIChyZWZQb3MgPiAwKSB7CiAgICAgICAgICAgICAgICAgIC0tcmVmUG9zOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgKytyZWZQb3M7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB3aGlsZSAocmVmTGluZVtyZWZQb3NdIDw9IGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdICYmIHJlZkxpbmVbcmVmUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICAgcmVmUG9zICs9IDI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIHR3b0RpbVZlcnRMMToKICAgICAgICAgICAgICB0aGlzLl9hZGRQaXhlbHNOZWcocmVmTGluZVtyZWZQb3NdIC0gMSwgYmxhY2tQaXhlbHMpOwogICAgICAgICAgICAgIGJsYWNrUGl4ZWxzIF49IDE7CiAgICAgICAgICAgICAgaWYgKGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdIDwgY29sdW1ucykgewogICAgICAgICAgICAgICAgaWYgKHJlZlBvcyA+IDApIHsKICAgICAgICAgICAgICAgICAgLS1yZWZQb3M7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICArK3JlZlBvczsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHdoaWxlIChyZWZMaW5lW3JlZlBvc10gPD0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gJiYgcmVmTGluZVtyZWZQb3NdIDwgY29sdW1ucykgewogICAgICAgICAgICAgICAgICByZWZQb3MgKz0gMjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgY2NpdHRFT0Y6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKGNvbHVtbnMsIDApOwogICAgICAgICAgICAgIHRoaXMuZW9mID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoImJhZCAyZCBjb2RlIik7CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKGNvbHVtbnMsIDApOwogICAgICAgICAgICAgIHRoaXMuZXJyID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29kaW5nTGluZVswXSA9IDA7CiAgICAgICAgdGhpcy5jb2RpbmdQb3MgPSAwOwogICAgICAgIGJsYWNrUGl4ZWxzID0gMDsKICAgICAgICB3aGlsZSAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICBjb2RlMSA9IDA7CiAgICAgICAgICBpZiAoYmxhY2tQaXhlbHMpIHsKICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgIGNvZGUxICs9IGNvZGUzID0gdGhpcy5fZ2V0QmxhY2tDb2RlKCk7CiAgICAgICAgICAgIH0gd2hpbGUgKGNvZGUzID49IDY0KTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICBjb2RlMSArPSBjb2RlMyA9IHRoaXMuX2dldFdoaXRlQ29kZSgpOwogICAgICAgICAgICB9IHdoaWxlIChjb2RlMyA+PSA2NCk7CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLl9hZGRQaXhlbHMoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gKyBjb2RlMSwgYmxhY2tQaXhlbHMpOwogICAgICAgICAgYmxhY2tQaXhlbHMgXj0gMTsKICAgICAgICB9CiAgICAgIH0KICAgICAgbGV0IGdvdEVPTCA9IGZhbHNlOwogICAgICBpZiAodGhpcy5ieXRlQWxpZ24pIHsKICAgICAgICB0aGlzLmlucHV0Qml0cyAmPSB+NzsKICAgICAgfQogICAgICBpZiAoIXRoaXMuZW9ibG9jayAmJiB0aGlzLnJvdyA9PT0gdGhpcy5yb3dzIC0gMSkgewogICAgICAgIHRoaXMucm93c0RvbmUgPSB0cnVlOwogICAgICB9IGVsc2UgewogICAgICAgIGNvZGUxID0gdGhpcy5fbG9va0JpdHMoMTIpOwogICAgICAgIGlmICh0aGlzLmVvbGluZSkgewogICAgICAgICAgd2hpbGUgKGNvZGUxICE9PSBjY2l0dEVPRiAmJiBjb2RlMSAhPT0gMSkgewogICAgICAgICAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgICAgICAgICBjb2RlMSA9IHRoaXMuX2xvb2tCaXRzKDEyKTsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgd2hpbGUgKGNvZGUxID09PSAwKSB7CiAgICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICAgICAgICAgIGNvZGUxID0gdGhpcy5fbG9va0JpdHMoMTIpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoY29kZTEgPT09IDEpIHsKICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMTIpOwogICAgICAgICAgZ290RU9MID0gdHJ1ZTsKICAgICAgICB9IGVsc2UgaWYgKGNvZGUxID09PSBjY2l0dEVPRikgewogICAgICAgICAgdGhpcy5lb2YgPSB0cnVlOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoIXRoaXMuZW9mICYmIHRoaXMuZW5jb2RpbmcgPiAwICYmICF0aGlzLnJvd3NEb25lKSB7CiAgICAgICAgdGhpcy5uZXh0TGluZTJEID0gIXRoaXMuX2xvb2tCaXRzKDEpOwogICAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICAgIH0KICAgICAgaWYgKHRoaXMuZW9ibG9jayAmJiBnb3RFT0wgJiYgdGhpcy5ieXRlQWxpZ24pIHsKICAgICAgICBjb2RlMSA9IHRoaXMuX2xvb2tCaXRzKDEyKTsKICAgICAgICBpZiAoY29kZTEgPT09IDEpIHsKICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMTIpOwogICAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPiAwKSB7CiAgICAgICAgICAgIHRoaXMuX2xvb2tCaXRzKDEpOwogICAgICAgICAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPj0gMCkgewogICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgNDsgKytpKSB7CiAgICAgICAgICAgICAgY29kZTEgPSB0aGlzLl9sb29rQml0cygxMik7CiAgICAgICAgICAgICAgaWYgKGNvZGUxICE9PSAxKSB7CiAgICAgICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoImJhZCBydGMgY29kZTogIiArIGNvZGUxKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgdGhpcy5fZWF0Qml0cygxMik7CiAgICAgICAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPiAwKSB7CiAgICAgICAgICAgICAgICB0aGlzLl9sb29rQml0cygxKTsKICAgICAgICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLmVvZiA9IHRydWU7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKHRoaXMuZXJyICYmIHRoaXMuZW9saW5lKSB7CiAgICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICAgIGNvZGUxID0gdGhpcy5fbG9va0JpdHMoMTMpOwogICAgICAgICAgaWYgKGNvZGUxID09PSBjY2l0dEVPRikgewogICAgICAgICAgICB0aGlzLmVvZiA9IHRydWU7CiAgICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChjb2RlMSA+PiAxID09PSAxKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgdGhpcy5fZWF0Qml0cygxKTsKICAgICAgICB9CiAgICAgICAgdGhpcy5fZWF0Qml0cygxMik7CiAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPiAwKSB7CiAgICAgICAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgICAgICAgdGhpcy5uZXh0TGluZTJEID0gIShjb2RlMSAmIDEpOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoY29kaW5nTGluZVswXSA+IDApIHsKICAgICAgICB0aGlzLm91dHB1dEJpdHMgPSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zID0gMF07CiAgICAgIH0gZWxzZSB7CiAgICAgICAgdGhpcy5vdXRwdXRCaXRzID0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1BvcyA9IDFdOwogICAgICB9CiAgICAgIHRoaXMucm93Kys7CiAgICB9CiAgICBsZXQgYzsKICAgIGlmICh0aGlzLm91dHB1dEJpdHMgPj0gOCkgewogICAgICBjID0gdGhpcy5jb2RpbmdQb3MgJiAxID8gMCA6IDB4ZmY7CiAgICAgIHRoaXMub3V0cHV0Qml0cyAtPSA4OwogICAgICBpZiAodGhpcy5vdXRwdXRCaXRzID09PSAwICYmIGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdIDwgY29sdW1ucykgewogICAgICAgIHRoaXMuY29kaW5nUG9zKys7CiAgICAgICAgdGhpcy5vdXRwdXRCaXRzID0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gLSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zIC0gMV07CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGJpdHMgPSA4OwogICAgICBjID0gMDsKICAgICAgZG8gewogICAgICAgIGlmICh0eXBlb2YgdGhpcy5vdXRwdXRCaXRzICE9PSAibnVtYmVyIikgewogICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCdJbnZhbGlkIC9DQ0lUVEZheERlY29kZSBkYXRhLCAib3V0cHV0Qml0cyIgbXVzdCBiZSBhIG51bWJlci4nKTsKICAgICAgICB9CiAgICAgICAgaWYgKHRoaXMub3V0cHV0Qml0cyA+IGJpdHMpIHsKICAgICAgICAgIGMgPDw9IGJpdHM7CiAgICAgICAgICBpZiAoISh0aGlzLmNvZGluZ1BvcyAmIDEpKSB7CiAgICAgICAgICAgIGMgfD0gMHhmZiA+PiA4IC0gYml0czsKICAgICAgICAgIH0KICAgICAgICAgIHRoaXMub3V0cHV0Qml0cyAtPSBiaXRzOwogICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGMgPDw9IHRoaXMub3V0cHV0Qml0czsKICAgICAgICAgIGlmICghKHRoaXMuY29kaW5nUG9zICYgMSkpIHsKICAgICAgICAgICAgYyB8PSAweGZmID4+IDggLSB0aGlzLm91dHB1dEJpdHM7CiAgICAgICAgICB9CiAgICAgICAgICBiaXRzIC09IHRoaXMub3V0cHV0Qml0czsKICAgICAgICAgIHRoaXMub3V0cHV0Qml0cyA9IDA7CiAgICAgICAgICBpZiAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgIHRoaXMuY29kaW5nUG9zKys7CiAgICAgICAgICAgIHRoaXMub3V0cHV0Qml0cyA9IGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdIC0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1BvcyAtIDFdOwogICAgICAgICAgfSBlbHNlIGlmIChiaXRzID4gMCkgewogICAgICAgICAgICBjIDw8PSBiaXRzOwogICAgICAgICAgICBiaXRzID0gMDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gd2hpbGUgKGJpdHMpOwogICAgfQogICAgaWYgKHRoaXMuYmxhY2spIHsKICAgICAgYyBePSAweGZmOwogICAgfQogICAgcmV0dXJuIGM7CiAgfQogIF9hZGRQaXhlbHMoYTEsIGJsYWNrUGl4ZWxzKSB7CiAgICBjb25zdCBjb2RpbmdMaW5lID0gdGhpcy5jb2RpbmdMaW5lOwogICAgbGV0IGNvZGluZ1BvcyA9IHRoaXMuY29kaW5nUG9zOwogICAgaWYgKGExID4gY29kaW5nTGluZVtjb2RpbmdQb3NdKSB7CiAgICAgIGlmIChhMSA+IHRoaXMuY29sdW1ucykgewogICAgICAgICgwLCBfdXRpbC5pbmZvKSgicm93IGlzIHdyb25nIGxlbmd0aCIpOwogICAgICAgIHRoaXMuZXJyID0gdHJ1ZTsKICAgICAgICBhMSA9IHRoaXMuY29sdW1uczsKICAgICAgfQogICAgICBpZiAoY29kaW5nUG9zICYgMSBeIGJsYWNrUGl4ZWxzKSB7CiAgICAgICAgKytjb2RpbmdQb3M7CiAgICAgIH0KICAgICAgY29kaW5nTGluZVtjb2RpbmdQb3NdID0gYTE7CiAgICB9CiAgICB0aGlzLmNvZGluZ1BvcyA9IGNvZGluZ1BvczsKICB9CiAgX2FkZFBpeGVsc05lZyhhMSwgYmxhY2tQaXhlbHMpIHsKICAgIGNvbnN0IGNvZGluZ0xpbmUgPSB0aGlzLmNvZGluZ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AgICAgIGNvZGUgPSB0aGlzLl9sb29rQml0cygxMik7CiAgICAgIGlmIChjb2RlID09PSBjY2l0dEVPRikgewogICAgICAgIHJldHVybiAxOwogICAgICB9CiAgICAgIGlmIChjb2RlID4+IDUgPT09IDApIHsKICAgICAgICBwID0gd2hpdGVUYWJsZTFbY29kZV07CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcCA9IHdoaXRlVGFibGUyW2NvZGUgPj4gM107CiAgICAgIH0KICAgICAgaWYgKHBbMF0gPiAwKSB7CiAgICAgICAgdGhpcy5fZWF0Qml0cyhwWzBdKTsKICAgICAgICByZXR1cm4gcFsxXTsKICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgbGV0IHJlc3VsdCA9IHRoaXMuX2ZpbmRUYWJsZUNvZGUoMSwgOSwgd2hpdGVUYWJsZTIpOwogICAgICBpZiAocmVzdWx0WzBdKSB7CiAgICAgICAgcmV0dXJuIHJlc3VsdFsxXTsKICAgICAgfQogICAgICByZXN1bHQgPSB0aGlzLl9maW5kVGFibGVDb2RlKDExLCAxMiwgd2hpdGVUYWJsZTEpOwogICAgICBpZiAocmVzdWx0WzBdKSB7CiAgICAgICAgcmV0dXJuIHJlc3VsdFsxXTsKICAgICAgfQogICAgfQogICAgKDAsIF91dGlsLmluZm8pKCJiYWQgd2hpdGUgY29kZSIpOwogICAgdGhpcy5fZWF0Qml0cygxKTsKICAgIHJldHVybiAxOwogIH0KICBfZ2V0QmxhY2tDb2RlKCkgewogICAgbGV0IGNvZGUsIHA7CiAgICBpZiAodGhpcy5lb2Jsb2NrKSB7CiAgICAgIGNvZGUgPSB0aGlzLl9sb29rQml0cygxMyk7CiAgICAgIGlmIChjb2RlID09PSBjY2l0dEVPRikgewogICAgICAgIHJldHVybiAxOwogICAgICB9CiAgICAgIGlmIChjb2RlID4+IDcgPT09IDApIHsKICAgICAgICBwID0gYmxhY2tUYWJsZTFbY29kZV07CiAgICAgIH0gZWxzZSBpZiAoY29kZSA+PiA5ID09PSAwICYmIGNvZGUgPj4gNyAhPT0gMCkgewogICAgICAgIHAgPSBibGFja1RhYmxlMlsoY29kZSA+PiAxKSAtIDY0XTsKICAgICAgfSBlbHNlIHsKICAgICAgICBwID0gYmxhY2tUYWJsZTNbY29kZSA+PiA3XTsKICAgICAgfQogICAgICBpZiAocFswXSA+IDApIHsKICAgICAgICB0aGlzLl9lYXRCaXRzKHBbMF0pOwogICAgICAgIHJldHVybiBwWzFdOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBsZXQgcmVzdWx0ID0gdGhpcy5fZmluZFRhYmxlQ29kZSgyLCA2LCBibGFja1RhYmxlMyk7CiAgICAgIGlmIChyZXN1bHRbMF0pIHsKICAgICAgICByZXR1cm4gcmVzdWx0WzFdOwogICAgICB9CiAgICAgIHJlc3VsdCA9IHRoaXMuX2ZpbmRUYWJsZUNvZGUoNywgMTIsIGJsYWNrVGFibGUyLCA2NCk7CiAgICAgIGlmIChyZXN1bHRbMF0pIHsKICAgICAgICByZXR1cm4gcmVzdWx0WzFdOwogICAgICB9CiAgICAgIHJlc3VsdCA9IHRoaXMuX2ZpbmRUYWJsZUNvZGUoMTAsIDEzLCBibGFja1RhYmxlMSk7CiAgICAgIGlmIChyZXN1bHRbMF0pIHsKICAgICAgICByZXR1cm4gcmVzdWx0WzFdOwogICAgICB9CiAgICB9CiAgICAoMCwgX3V0aWwuaW5mbykoImJhZCBibGFjayBjb2RlIik7CiAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgcmV0dXJuIDE7CiAgfQogIF9sb29rQml0cyhuKSB7CiAgICBsZXQgYzsKICAgIHdoaWxlICh0aGlzLmlucHV0Qml0cyA8IG4pIHsKICAgICAgaWYgKChjID0gdGhpcy5zb3VyY2UubmV4dCgpKSA9PT0gLTEpIHsKICAgICAgICBpZiAodGhpcy5pbnB1dEJpdHMgPT09IDApIHsKICAgICAgICAgIHJldHVybiBjY2l0dEVPRjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRoaXMuaW5w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ICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47ICsraSkgewogICAgICAgICAgICBjb2RlMiA9IGNvZGUyIDw8IDEgfCB0ICYgMTsKICAgICAgICAgICAgdCA+Pj0gMTsKICAgICAgICAgIH0KICAgICAgICAgIGZvciAoaSA9IGNvZGUyOyBpIDwgc2l6ZTsgaSArPSBza2lwKSB7CiAgICAgICAgICAgIGNvZGVzW2ldID0gbGVuIDw8IDE2IHwgdmFsOwogICAgICAgICAgfQogICAgICAgICAgKytjb2RlOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIFtjb2RlcywgbWF4TGVuXTsKICB9CiAgcmVhZEJsb2NrKCkgewogICAgbGV0IGJ1ZmZlciwgbGVuOwogICAgY29uc3Qgc3RyID0gdGhpcy5zdHI7CiAgICBsZXQgaGRyID0gdGhpcy5nZXRCaXRzKDMpOwogICAgaWYgKGhkciAmIDEpIHsKICAgICAgdGhpcy5lb2YgPSB0cnVlOwogICAgfQogICAgaGRyID4+PSAxOwogICAgaWYgKGhkciA9PT0gMCkgewogICAgICBsZXQgYjsKICAgICAgaWYgKChiID0gc3RyLmdldEJ5dGUoKSkgPT09IC0xKSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJCYWQgYmxvY2sgaGVhZGVyIGluIGZsYXRlIHN0cmVhbSIpOwogICAgICB9CiAgICAgIGxldCBibG9ja0xlbiA9IGI7CiAgICAgIGlmICgoYiA9IHN0ci5nZXRCeXRlKCkpID09PSAtMSkgewogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiQmFkIGJsb2NrIGhlYWRlciBpbiBmbGF0ZSBzdHJlYW0iKTsKICAgICAgfQogICAgICBibG9ja0xlbiB8PSBiIDw8IDg7CiAgICAgIGlmICgoYiA9IHN0ci5nZXRCeXRlKCkpID09PSAtMSkgewogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiQmFkIGJsb2Nr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GUgKGkgPCBjb2RlcykgewogICAgICAgIGNvbnN0IGNvZGUgPSB0aGlzLmdldENvZGUoY29kZUxlbkNvZGVUYWIpOwogICAgICAgIGlmIChjb2RlID09PSAxNikgewogICAgICAgICAgYml0c0xlbmd0aCA9IDI7CiAgICAgICAgICBiaXRzT2Zmc2V0ID0gMzsKICAgICAgICAgIHdoYXQgPSBsZW47CiAgICAgICAgfSBlbHNlIGlmIChjb2RlID09PSAxNykgewogICAgICAgICAgYml0c0xlbmd0aCA9IDM7CiAgICAgICAgICBiaXRzT2Zmc2V0ID0gMzsKICAgICAgICAgIHdoYXQgPSBsZW4gPSAwOwogICAgICAgIH0gZWxzZSBpZiAoY29kZSA9PT0gMTgpIHsKICAgICAgICAgIGJpdHNMZW5ndGggPSA3OwogICAgICAgICAgYml0c09mZnNldCA9IDExOwogICAgICAgICAgd2hhdCA9IGxlbiA9IDA7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGNvZGVMZW5ndGhzW2krK10gPSBsZW4gPSBjb2RlOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGxldCByZXBlYXRMZW5ndGggPSB0aGlzLmdldEJpdHMoYml0c0xlbmd0aCkgKyBiaXRzT2Zmc2V0OwogICAgICAgIHdoaWxlIChyZXBlYXRMZW5ndGgtLSA+IDApIHsKICAgICAgICAgIGNvZGVMZW5ndGhzW2krK10gPSB3aGF0OwogICAgICAgIH0KICAgICAgfQogICAgICBsaXRDb2RlVGFibGUgPSB0aGlzLmdlbmVyYXRlSHVmZm1hblRhYmxlKGNvZGVMZW5ndGhzLnN1YmFycmF5KDAsIG51bUxpdENvZGVzKSk7CiAgICAgIGRpc3RDb2RlVGFibGUgPSB0aGlzLmdlbmVyYXRlSHVmZm1hblRhYmxlKGNvZGVMZW5ndGhzLnN1YmFycmF5KG51bUxpdENvZGVzLCBjb2RlcykpOwogICAgfSBlbHNlIHsKICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yK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B4OiAwLAogIHk6IC0xCn0sIHsKICB4OiAxLAogIHk6IC0xCn0sIHsKICB4OiAtMiwKICB5OiAwCn0sIHsKICB4OiAtMSwKICB5OiAwCn1dLCBbewogIHg6IC0zLAogIHk6IC0xCn0sIHsKICB4OiAtMiwKICB5OiAtMQp9LCB7CiAgeDogLTEsCiAgeTogLTEKfSwgewogIHg6IDAsCiAgeTogLTEKfSwgewogIHg6IDEsCiAgeTogLTEKfSwgewogIHg6IC00LAogIHk6IDAKfSwgewogIHg6IC0zLAogIHk6IDAKfSwgewogIHg6IC0yLAogIHk6IDAKfSwgewogIHg6IC0xLAogIHk6IDAKfV1dOwpjb25zdCBSZWZpbmVtZW50VGVtcGxhdGVzID0gW3sKICBjb2Rpbmc6IFt7CiAgICB4OiAwLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAxLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAtMSwKICAgIHk6IDAKICB9XSwKICByZWZlcmVuY2U6IFt7CiAgICB4OiAwLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAxLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAtMSwKICAgIHk6IDAKICB9LCB7CiAgICB4OiAwLAogICAgeTogMAogIH0sIHsKICAgIHg6IDEsCiAgICB5OiAwCiAgfSwgewogICAgeDogLTEsCiAgICB5OiAxCiAgfSwgewogICAgeDogMCwKICAgIHk6IDEKICB9LCB7CiAgICB4OiAxLAogICAgeTogMQogIH1dCn0sIHsKICBjb2Rpbmc6IFt7CiAgICB4OiAtMSwKICAgIHk6IC0xCiAgfSwgewogICAgeDogMCwKICAgIHk6IC0xCiAgfSwgewogICAgeDogMSwKICAgIHk6IC0xCiAgfSwgewogICAgeDogLTEsCiAgICB5OiAwCiAgfV0sCiAgcmVmZXJlbmNlOiBbewogICAgeDogMCwKICAgIHk6IC0xCiAgfSwgewogICAgeDogLTEsCiAgICB5OiAwCiAgfSwgewogICAgeDogMCwKICAgIHk6IDAKICB9LCB7CiAgICB4OiAxLAog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KICAgIGkwLAogICAgajAsCiAgICBjb250ZXh0TGFiZWwgPSAwLAogICAgYml0LAogICAgc2hpZnQ7CiAgZm9yIChsZXQgaSA9IDA7IGkgPCBoZWlnaHQ7IGkrKykgewogICAgaWYgKHByZWRpY3Rpb24pIHsKICAgICAgY29uc3Qgc2x0cCA9IGRlY29kZXIucmVhZEJpdChjb250ZXh0cywgcHNldWRvUGl4ZWxDb250ZXh0KTsKICAgICAgbHRwIF49IHNsdHA7CiAgICAgIGlmIChsdHApIHsKICAgICAgICBiaXRtYXAucHVzaChyb3cpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICB9CiAgICByb3cgPSBuZXcgVWludDhBcnJheShyb3cpOwogICAgYml0bWFwLnB1c2gocm93KTsKICAgIGZvciAoaiA9IDA7IGogPCB3aWR0aDsgaisrKSB7CiAgICAgIGlmICh1c2Vza2lwICYmIHNraXBbaV1bal0pIHsKICAgICAgICByb3dbal0gPSAwOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmIChqID49IHNiYl9sZWZ0ICYmIGogPCBzYmJfcmlnaHQgJiYgaSA+PSBzYmJfdG9wKSB7CiAgICAgICAgY29udGV4dExhYmVsID0gY29udGV4dExhYmVsIDw8IDEgJiByZXVzZU1hc2s7CiAgICAgICAgZm9yIChrID0gMDsgayA8IGNoYW5naW5nRW50cmllc0xlbmd0aDsgaysrKSB7CiAgICAgICAgICBpMCA9IGkgKyBjaGFuZ2luZ1RlbXBsYXRlWVtrXTsKICAgICAgICAgIGowID0gaiArIGNoYW5naW5nVGVtcGxhdGVYW2tdOwogICAgICAgICAgYml0ID0gYml0bWFwW2kwXVtqMF07CiAgICAgICAgICBpZiAoYml0KSB7CiAgICAgICAgICAgIGJpdCA9IGNoYW5naW5nVGVtcGxhdGVCaXRba107CiAgICAgICAgICAgIGNvbnRleHRMYWJlbCB8PSBiaXQ7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGNv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XRtYXAgPSBkZWNvZGVSZWZpbmVtZW50KHN5bWJvbFdpZHRoLCBzeW1ib2xIZWlnaHQsIHJlZmluZW1lbnRUZW1wbGF0ZUluZGV4LCBzeW1ib2xCaXRtYXAsIChyZHcgPj4gMSkgKyByZHgsIChyZGggPj4gMSkgKyByZHksIGZhbHNlLCByZWZpbmVtZW50QXQsIGRlY29kaW5nQ29udGV4dCk7CiAgICAgIH0KICAgICAgY29uc3Qgb2Zmc2V0VCA9IHQgLSAocmVmZXJlbmNlQ29ybmVyICYgMSA/IDAgOiBzeW1ib2xIZWlnaHQgLSAxKTsKICAgICAgY29uc3Qgb2Zmc2V0UyA9IGN1cnJlbnRTIC0gKHJlZmVyZW5jZUNvcm5lciAmIDIgPyBzeW1ib2xXaWR0aCAtIDEgOiAwKTsKICAgICAgbGV0IHMyLCB0Miwgc3ltYm9sUm93OwogICAgICBpZiAodHJhbnNwb3NlZCkgewogICAgICAgIGZvciAoczIgPSAwOyBzMiA8IHN5bWJvbEhlaWdodDsgczIrKykgewogICAgICAgICAgcm93ID0gYml0bWFwW29mZnNldFMgKyBzMl07CiAgICAgICAgICBpZiAoIXJvdykgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHN5bWJvbFJvdyA9IHN5bWJvbEJpdG1hcFtzMl07CiAgICAgICAgICBjb25zdCBtYXhXaWR0aCA9IE1hdGgubWluKHdpZHRoIC0gb2Zmc2V0VCwgc3ltYm9sV2lkdGgpOwogICAgICAgICAgc3dpdGNoIChjb21iaW5hdGlvbk9wZXJhdG9yKSB7CiAgICAgICAgICAgIGNhc2UgMDoKICAgICAgICAgICAgICBmb3IgKHQyID0gMDsgdDIgPCBtYXhXaWR0aDsgdDIrKykgewogICAgICAgICAgICAgICAgcm93W29mZnNldFQgKyB0Ml0gfD0gc3ltYm9sUm93W3QyXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMjoKICAgICAgICAgICAgICBmb3IgKHQyID0gMDsgdDIgPCBtYXhXaWR0aDsgdDIrKykgewogICAgICAgICAgICAgICAgcm93W29mZnNldFQgKyB0Ml0gXj0gc3ltYm9sUm93W3QyXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IEpiaWcyRXJyb3IoYG9wZXJhdG9yICR7Y29tYmluYXRpb25PcGVyYXRvcn0gaXMgbm90IHN1cHBvcnRlZGApOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjdXJyZW50UyArPSBzeW1ib2xIZWlnaHQgLSAxOwogICAgICB9IGVsc2UgewogICAgICAgIGZvciAodDIgPSAwOyB0MiA8IHN5bWJvbEhlaWdodDsgdDIrKykgewogICAgICAgICAgcm93ID0gYml0bWFwW29mZnNldFQgKyB0Ml07CiAgICAgICAgICBpZiAoIXJvdykgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHN5bWJvbFJvdyA9IHN5bWJvbEJpdG1hcFt0Ml07CiAgICAgICAgICBzd2l0Y2ggKGNvbWJpbmF0aW9uT3BlcmF0b3IpIHsKICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgIGZvciAoczIgPSAwOyBzMiA8IHN5bWJvbFdpZHRoOyBzMisrKSB7CiAgICAgICAgICAgICAgICByb3dbb2Zmc2V0UyArIHMyXSB8PSBzeW1ib2xSb3dbczJdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgIGZvciAoczIgPSAwOyBzMiA8IHN5bWJvbFdpZHRoOyBzMisrKSB7CiAgICAgICAgICAgICAgICByb3dbb2Zmc2V0UyArIHMyXSBePSBzeW1ib2xSb3dbczJdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICB0aHJvdyBuZXcgSmJpZzJFcnJvcihgb3BlcmF0b3IgJHtjb21iaW5hdGlvbk9wZXJhdG9yfSBpcyBub3Qgc3VwcG9ydGVkYCk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGN1cnJlbnRTICs9IHN5bWJvbFdpZHRoIC0gMTsKICAgICAgfQogICAgICBpKys7CiAgICAgIGNvbnN0IGRlbHRhUyA9IGh1ZmZtYW4gPyBodWZmbWFuVGFibGVzLnRhYmxlRGVsdGFTLmRlY29kZShodWZmbWFuSW5wdXQpIDogZGVjb2RlSW50ZWdlcihjb250ZXh0Q2FjaGUsICJJQURTIiwgZGVjb2Rlcik7CiAgICAgIGlmIChkZWx0YVMgPT09IG51bGwpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBjdXJyZW50UyArPSBkZWx0YVMgKyBkc09mZnNldDsKICAgIH0gd2hpbGUgKHRydWUpOwogIH0KICByZXR1cm4gYml0bWFwOwp9CmZ1bmN0aW9uIGRlY29kZVBhdHRlcm5EaWN0aW9uYXJ5KG1tciwgcGF0dGVybldpZHRoLCBwYXR0ZXJuSGVpZ2h0LCBtYXhQYXR0ZXJuSW5kZXgsIHRlbXBsYXRlLCBkZWNvZGluZ0NvbnRleHQpIHsKICBjb25zdCBhdCA9IFtdOwogIGlmICghbW1yKSB7CiAgICBhdC5wdXNoKHsKICAgICAgeDogLXBhdHRlcm5XaWR0aCwKICAgICAgeTogMAogICAgfSk7CiAgICBpZiAodGVtcGxhdGUgPT09IDApIHsKICAgICAgYXQucHVzaCh7CiAgICAgICAgeDogLTMsCiAgICAgICAgeTogLTEKICAgICAgfSwgewogICAgICAgIHg6IDIsCiAgICAgICAgeTogLTIKICAgICAgfSwgewogICAgICAgIHg6IC0yLAogICAgICAgIHk6IC0yCiAgICAgIH0pOwogICAgfQogIH0KICBjb25zdCBjb2xsZWN0aXZlV2lkdGggPSAobWF4UGF0dGVybkluZGV4ICsgMSkgKiBwY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IGRpY3Rpb25hcnlGbGFncyA+PiAxMiAmIDE7CiAgICAgIHBvc2l0aW9uICs9IDI7CiAgICAgIGlmICghZGljdGlvbmFyeS5odWZmbWFuKSB7CiAgICAgICAgYXRMZW5ndGggPSBkaWN0aW9uYXJ5LnRlbXBsYXRlID09PSAwID8gNCA6IDE7CiAgICAgICAgYXQgPSBbXTsKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgYXRMZW5ndGg7IGkrKykgewogICAgICAgICAgYXQucHVzaCh7CiAgICAgICAgICAgIHg6ICgwLCBfY29yZV91dGlscy5yZWFkSW50OCkoZGF0YSwgcG9zaXRpb24pLAogICAgICAgICAgICB5OiAoMCwgX2NvcmVfdXRpbHMucmVhZEludDgpKGRhdGEsIHBvc2l0aW9uICsgMSkKICAgICAgICAgIH0pOwogICAgICAgICAgcG9zaXRpb24gKz0gMjsKICAgICAgICB9CiAgICAgICAgZGljdGlvbmFyeS5hdCA9IGF0OwogICAgICB9CiAgICAgIGlmIChkaWN0aW9uYXJ5LnJlZmluZW1lbnQgJiYgIWRpY3Rpb25hcnkucmVmaW5lbWVudFRlbXBsYXRlKSB7CiAgICAgICAgYXQgPSBbXTsKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgMjsgaSsrKSB7CiAgICAgICAgICBhdC5wdXNoKHsKICAgICAgICAgICAgeDogKDAsIF9jb3JlX3V0aWxzLnJlYWRJbnQ4KShkYXRhLCBwb3NpdGlvbiksCiAgICAgICAgICAgIHk6ICgwLCBfY29yZV91dGlscy5yZWFkSW50OCkoZGF0YSwgcG9zaXRpb24gKyAxKQogICAgICAgICAgfSk7CiAgICAgICAgICBwb3NpdGlvbiArPSAyOwogICAgICAgIH0KICAgICAgICBkaWN0aW9uYXJ5LnJlZmluZW1lbnRBdCA9IGF0OwogICAgICB9CiAgICAgIGRpY3Rpb25hcnkubnVtYmVyT2ZFeHBvcnRlZFN5bWJvbHMgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0Y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kZsYWdzID4+IDggJiAzOwogICAgICAgIHRleHRSZWdpb24uaHVmZm1hblJlZmluZW1lbnREWCA9IHRleHRSZWdpb25IdWZmbWFuRmxhZ3MgPj4gMTAgJiAzOwogICAgICAgIHRleHRSZWdpb24uaHVmZm1hblJlZmluZW1lbnREWSA9IHRleHRSZWdpb25IdWZmbWFuRmxhZ3MgPj4gMTIgJiAzOwogICAgICAgIHRleHRSZWdpb24uaHVmZm1hblJlZmluZW1lbnRTaXplU2VsZWN0b3IgPSAhISh0ZXh0UmVnaW9uSHVmZm1hbkZsYWdzICYgMHg0MDAwKTsKICAgICAgfQogICAgICBpZiAodGV4dFJlZ2lvbi5yZWZpbmVtZW50ICYmICF0ZXh0UmVnaW9uLnJlZmluZW1lbnRUZW1wbGF0ZSkgewogICAgICAgIGF0ID0gW107CiAgICAgICAgZm9yIChpID0gMDsgaSA8IDI7IGkrKykgewogICAgICAgICAgYXQucHVzaCh7CiAgICAgICAgICAgIHg6ICgwLCBfY29yZV91dGlscy5yZWFkSW50OCkoZGF0YSwgcG9zaXRpb24pLAogICAgICAgICAgICB5OiAoMCwgX2NvcmVfdXRpbHMucmVhZEludDgpKGRhdGEsIHBvc2l0aW9uICsgMSkKICAgICAgICAgIH0pOwogICAgICAgICAgcG9zaXRpb24gKz0gMjsKICAgICAgICB9CiAgICAgICAgdGV4dFJlZ2lvbi5yZWZpbmVtZW50QXQgPSBhdDsKICAgICAgfQogICAgICB0ZXh0UmVnaW9uLm51bWJlck9mU3ltYm9sSW5zdGFuY2VzID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MzIpKGRhdGEsIHBvc2l0aW9uKTsKICAgICAgcG9zaXRpb24gKz0gNDsKICAgICAgYXJncyA9IFt0ZXh0UmVnaW9uLCBoZWFkZXIucmVmZXJyZWRUbywgZGF0YSwgcG9zaXRpb24sIGVuZF07CiAgICAgIGJyZWFrOwogICAgY2FzZSAxNjoKICAgICAgY29uc3QgcGF0dGVybkRpY3Rpb25hcnk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HRoID0gcmVnaW9uSW5mby53aWR0aCwKICAgICAgaGVpZ2h0ID0gcmVnaW9uSW5mby5oZWlnaHQ7CiAgICBjb25zdCByb3dTaXplID0gcGFnZUluZm8ud2lkdGggKyA3ID4+IDM7CiAgICBjb25zdCBjb21iaW5hdGlvbk9wZXJhdG9yID0gcGFnZUluZm8uY29tYmluYXRpb25PcGVyYXRvck92ZXJyaWRlID8gcmVnaW9uSW5mby5jb21iaW5hdGlvbk9wZXJhdG9yIDogcGFnZUluZm8uY29tYmluYXRpb25PcGVyYXRvcjsKICAgIGNvbnN0IGJ1ZmZlciA9IHRoaXMuYnVmZmVyOwogICAgY29uc3QgbWFzazAgPSAxMjggPj4gKHJlZ2lvbkluZm8ueCAmIDcpOwogICAgbGV0IG9mZnNldDAgPSByZWdpb25JbmZvLnkgKiByb3dTaXplICsgKHJlZ2lvbkluZm8ueCA+PiAzKTsKICAgIGxldCBpLCBqLCBtYXNrLCBvZmZzZXQ7CiAgICBzd2l0Y2ggKGNvbWJpbmF0aW9uT3BlcmF0b3IpIHsKICAgICAgY2FzZSAwOgogICAgICAgIGZvciAoaSA9IDA7IGkgPCBoZWlnaHQ7IGkrKykgewogICAgICAgICAgbWFzayA9IG1hc2swOwogICAgICAgICAgb2Zmc2V0ID0gb2Zmc2V0MDsKICAgICAgICAgIGZvciAoaiA9IDA7IGogPCB3aWR0aDsgaisrKSB7CiAgICAgICAgICAgIGlmIChiaXRtYXBbaV1bal0pIHsKICAgICAgICAgICAgICBidWZmZXJbb2Zmc2V0XSB8PSBtYXNrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG1hc2sgPj49IDE7CiAgICAgICAgICAgIGlmICghbWFzaykgewogICAgICAgICAgICAgIG1hc2sgPSAxMjg7CiAgICAgICAgICAgICAgb2Zmc2V0Kys7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIG9mZnNldDAgKz0gcm93U2l6ZTsKICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgMjoKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgaGVpZ2h0OyBpKyspIHsKICAgICAgICAgIG1hc2sgPSBtYXNrMDsKICAgICAgICAgIG9mZnNldCA9IG9mZnNldDA7CiAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgd2lkdGg7IGorKykgewogICAgICAgICAgICBpZiAoYml0bWFwW2ldW2pdKSB7CiAgICAgICAgICAgICAgYnVmZmVyW29mZnNldF0gXj0gbWFzazsKICAgICAgICAgICAgfQogICAgICAgICAgICBtYXNrID4+PSAxOwogICAgICAgICAgICBpZiAoIW1hc2spIHsKICAgICAgICAgICAgICBtYXNrID0gMTI4OwogICAgICAgICAgICAgIG9mZnNldCsrOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBvZmZzZXQwICs9IHJvd1NpemU7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBkZWZhdWx0OgogICAgICAgIHRocm93IG5ldyBKYmlnMkVycm9yKGBvcGVyYXRvciAke2NvbWJpbmF0aW9uT3BlcmF0b3J9IGlzIG5vdCBzdXBwb3J0ZWRgKTsKICAgIH0KICB9CiAgb25JbW1lZGlhdGVHZW5lcmljUmVnaW9uKHJlZ2lvbiwgZGF0YSwgc3RhcnQsIGVuZCkgewogICAgY29uc3QgcmVnaW9uSW5mbyA9IHJlZ2lvbi5pbmZvOwogICAgY29uc3QgZGVjb2RpbmdDb250ZXh0ID0gbmV3IERlY29kaW5nQ29udGV4dChkYXRhLCBzdGFydCwgZW5kKTsKICAgIGNvbnN0IGJpdG1hcCA9IGRlY29kZUJpdG1hcChyZWdpb24ubW1yLCByZWdpb25JbmZvLndpZHRoLCByZWdpb25JbmZvLmhlaWdodCwgcmVnaW9uLnRlbXBsYXRlLCByZWdpb24ucHJlZGljdGlvbiwgbnVsbCwgcmVnaW9uLmF0LCBkZWNvZGluZ0NvbnRleHQpOwogICAgdGhpcy5kcmF3Qml0bWFwKHJlZ2lvbkluZm8sIGJp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G9zKSB7CiAgICBsZXQgY3hfaW5kZXggPSBjb250ZXh0c1twb3NdID4+IDEsCiAgICAgIGN4X21wcyA9IGNvbnRleHRzW3Bvc10gJiAxOwogICAgY29uc3QgcWVUYWJsZUljeCA9IFFlVGFibGVbY3hfaW5kZXhdOwogICAgY29uc3QgcWVJY3ggPSBxZVRhYmxlSWN4LnFlOwogICAgbGV0IGQ7CiAgICBsZXQgYSA9IHRoaXMuYSAtIHFlSWN4OwogICAgaWYgKHRoaXMuY2hpZ2ggPCBxZUljeCkgewogICAgICBpZiAoYSA8IHFlSWN4KSB7CiAgICAgICAgYSA9IHFlSWN4OwogICAgICAgIGQgPSBjeF9tcHM7CiAgICAgICAgY3hfaW5kZXggPSBxZVRhYmxlSWN4Lm5tcHM7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgYSA9IHFlSWN4OwogICAgICAgIGQgPSAxIF4gY3hfbXBzOwogICAgICAgIGlmIChxZVRhYmxlSWN4LnN3aXRjaEZsYWcgPT09IDEpIHsKICAgICAgICAgIGN4X21wcyA9IGQ7CiAgICAgICAgfQogICAgICAgIGN4X2luZGV4ID0gcWVUYWJsZUljeC5ubHBzOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICB0aGlzLmNoaWdoIC09IHFlSWN4OwogICAgICBpZiAoKGEgJiAweDgwMDApICE9PSAwKSB7CiAgICAgICAgdGhpcy5hID0gYTsKICAgICAgICByZXR1cm4gY3hfbXBzOwogICAgICB9CiAgICAgIGlmIChhIDwgcWVJY3gpIHsKICAgICAgICBkID0gMSBeIGN4X21wczsKICAgICAgICBpZiAocWVUYWJsZUljeC5zd2l0Y2hGbGFnID09PSAxKSB7CiAgICAgICAgICBjeF9tcHMgPSBkOwogICAgICAgIH0KICAgICAgICBjeF9pbmRleCA9IHFlVGFibGVJY3gubmxwczsKICAgICAgfSBlbHNlIHsKICAgICAgICBkID0gY3hfbXBzOwogICAgICAgIGN4X2luZGV4ID0gcWVUYWJsZUljeC5ubXBzOwogICAgICB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V0IGsgPSAwLAogICAgaSwKICAgIGosCiAgICBsZW5ndGggPSAxNjsKICB3aGlsZSAobGVuZ3RoID4gMCAmJiAhY29kZUxlbmd0aHNbbGVuZ3RoIC0gMV0pIHsKICAgIGxlbmd0aC0tOwogIH0KICBjb25zdCBjb2RlID0gW3sKICAgIGNoaWxkcmVuOiBbXSwKICAgIGluZGV4OiAwCiAgfV07CiAgbGV0IHAgPSBjb2RlWzBdLAogICAgcTsKICBmb3IgKGkgPSAwOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgIGZvciAoaiA9IDA7IGogPCBjb2RlTGVuZ3Roc1tpXTsgaisrKSB7CiAgICAgIHAgPSBjb2RlLnBvcCgpOwogICAgICBwLmNoaWxkcmVuW3AuaW5kZXhdID0gdmFsdWVzW2tdOwogICAgICB3aGlsZSAocC5pbmRleCA+IDApIHsKICAgICAgICBwID0gY29kZS5wb3AoKTsKICAgICAgfQogICAgICBwLmluZGV4Kys7CiAgICAgIGNvZGUucHVzaChwKTsKICAgICAgd2hpbGUgKGNvZGUubGVuZ3RoIDw9IGkpIHsKICAgICAgICBjb2RlLnB1c2gocSA9IHsKICAgICAgICAgIGNoaWxkcmVuOiBbXSwKICAgICAgICAgIGluZGV4OiAwCiAgICAgICAgfSk7CiAgICAgICAgcC5jaGlsZHJlbltwLmluZGV4XSA9IHEuY2hpbGRyZW47CiAgICAgICAgcCA9IHE7CiAgICAgIH0KICAgICAgaysrOwogICAgfQogICAgaWYgKGkgKyAxIDwgbGVuZ3RoKSB7CiAgICAgIGNvZGUucHVzaChxID0gewogICAgICAgIGNoaWxkcmVuOiBbXSwKICAgICAgICBpbmRleDogMAogICAgICB9KTsKICAgICAgcC5jaGlsZHJlbltwLmluZGV4XSA9IHEuY2hpbGRyZW47CiAgICAgIHAgPSBxOwogICAgfQogIH0KICByZXR1cm4gY29kZVswXS5jaGlsZHJlbjsKfQpmdW5jdGlvbiBnZXRCbG9ja0J1ZmZlck9mZnNldChjb21wb25lbnQsIHJv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c2V0KTsKICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgaWYgKHNjYW5MaW5lcyA+IDAgJiYgc2NhbkxpbmVzICE9PSBmcmFtZS5zY2FuTGluZXMpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IEROTE1hcmtlckVycm9yKCJGb3VuZCBETkwgbWFya2VyICgweEZGREMpIHdoaWxlIHBhcnNpbmcgc2NhbiBkYXRhIiwgc2NhbkxpbmVzKTsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgaWYgKG5leHRCeXRlID09PSAweGQ5KSB7CiAgICAgICAgICBpZiAocGFyc2VETkxNYXJrZXIpIHsKICAgICAgICAgICAgY29uc3QgbWF5YmVTY2FuTGluZXMgPSBibG9ja1JvdyAqIChmcmFtZS5wcmVjaXNpb24gPT09IDggPyA4IDogMCk7CiAgICAgICAgICAgIGlmIChtYXliZVNjYW5MaW5lcyA+IDAgJiYgTWF0aC5yb3VuZChmcmFtZS5zY2FuTGluZXMgLyBtYXliZVNjYW5MaW5lcykgPj0gNSkgewogICAgICAgICAgICAgIHRocm93IG5ldyBETkxNYXJrZXJFcnJvcigiRm91bmQgRU9JIG1hcmtlciAoMHhGRkQ5KSB3aGlsZSBwYXJzaW5nIHNjYW4gZGF0YSwgIiArICJwb3NzaWJseSBjYXVzZWQgYnkgaW5jb3JyZWN0IGBzY2FuTGluZXNgIHBhcmFtZXRlciIsIG1heWJlU2NhbkxpbmVzKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgdGhyb3cgbmV3IEVPSU1hcmtlckVycm9yKCJGb3VuZCBFT0kgbWFya2VyICgweEZGRDkpIHdoaWxlIHBhcnNpbmcgc2NhbiBkYXRhIik7CiAgICAgICAgfQogICAgICAgIHRocm93IG5ldyBKcGVnRXJyb3IoYHVuZXhwZWN0ZWQgbWFya2VyICR7KGJpdHNEYXRhIDw8IDggfCBuZXh0Qnl0ZSkudG9TdHJpbmcoMTYpfWApOwogICAgICB9CiAgICB9Ci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B0ID09PSAwID8gMCA6IHJlY2VpdmVBbmRFeHRlbmQodCk7CiAgICBjb21wb25lbnQuYmxvY2tEYXRhW2Jsb2NrT2Zmc2V0XSA9IGNvbXBvbmVudC5wcmVkICs9IGRpZmY7CiAgICBsZXQgayA9IDE7CiAgICB3aGlsZSAoayA8IDY0KSB7CiAgICAgIGNvbnN0IHJzID0gZGVjb2RlSHVmZm1hbihjb21wb25lbnQuaHVmZm1hblRhYmxlQUMpOwogICAgICBjb25zdCBzID0gcnMgJiAxNSwKICAgICAgICByID0gcnMgPj4gNDsKICAgICAgaWYgKHMgPT09IDApIHsKICAgICAgICBpZiAociA8IDE1KSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgayArPSAxNjsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBrICs9IHI7CiAgICAgIGNvbnN0IHogPSBkY3RaaWdaYWdba107CiAgICAgIGNvbXBvbmVudC5ibG9ja0RhdGFbYmxvY2tPZmZzZXQgKyB6XSA9IHJlY2VpdmVBbmRFeHRlbmQocyk7CiAgICAgIGsrKzsKICAgIH0KICB9CiAgZnVuY3Rpb24gZGVjb2RlRENGaXJzdChjb21wb25lbnQsIGJsb2NrT2Zmc2V0KSB7CiAgICBjb25zdCB0ID0gZGVjb2RlSHVmZm1hbihjb21wb25lbnQuaHVmZm1hblRhYmxlREMpOwogICAgY29uc3QgZGlmZiA9IHQgPT09IDAgPyAwIDogcmVjZWl2ZUFuZEV4dGVuZCh0KSA8PCBzdWNjZXNzaXZlOwogICAgY29tcG9uZW50LmJsb2NrRGF0YVtibG9ja09mZnNldF0gPSBjb21wb25lbnQucHJlZCArPSBkaWZmOwogIH0KICBmdW5jdGlvbiBkZWNvZGVEQ1N1Y2Nlc3NpdmUoY29tcG9uZW50LCBibG9ja09mZnNldCkgewogICAgY29tcG9uZW50LmJsb2NrRGF0YVtibG9ja09mZnNldF0gfD0gcmVhZEJpdCgpIDw8IHN1Y2Nlc3NpdmU7CiAgfQogIGxldCBlb2JydW4gPSAwOwogIGZ1bmN0aW9uIGRlY29kZUFDRmlyc3QoY29tcG9uZW50LCBibG9ja09mZnNldCkgewogICAgaWYgKGVvYnJ1biA+IDApIHsKICAgICAgZW9icnVuLS07CiAgICAgIHJldHVybjsKICAgIH0KICAgIGxldCBrID0gc3BlY3RyYWxTdGFydDsKICAgIGNvbnN0IGUgPSBzcGVjdHJhbEVuZDsKICAgIHdoaWxlIChrIDw9IGUpIHsKICAgICAgY29uc3QgcnMgPSBkZWNvZGVIdWZmbWFuKGNvbXBvbmVudC5odWZmbWFuVGFibGVBQyk7CiAgICAgIGNvbnN0IHMgPSBycyAmIDE1LAogICAgICAgIHIgPSBycyA+PiA0OwogICAgICBpZiAocyA9PT0gMCkgewogICAgICAgIGlmIChyIDwgMTUpIHsKICAgICAgICAgIGVvYnJ1biA9IHJlY2VpdmUocikgKyAoMSA8PCByKSAtIDE7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgayArPSAxNjsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBrICs9IHI7CiAgICAgIGNvbnN0IHogPSBkY3RaaWdaYWdba107CiAgICAgIGNvbXBvbmVudC5ibG9ja0RhdGFbYmxvY2tPZmZzZXQgKyB6XSA9IHJlY2VpdmVBbmRFeHRlbmQocykgKiAoMSA8PCBzdWNjZXNzaXZlKTsKICAgICAgaysrOwogICAgfQogIH0KICBsZXQgc3VjY2Vzc2l2ZUFDU3RhdGUgPSAwLAogICAgc3VjY2Vzc2l2ZUFDTmV4dFZhbHVlOwogIGZ1bmN0aW9uIGRlY29kZUFDU3VjY2Vzc2l2ZShjb21wb25lbnQsIGJsb2NrT2Zmc2V0KSB7CiAgICBsZXQgayA9IHNwZWN0cmFsU3RhcnQ7CiAgICBjb25zdCBlID0gc3BlY3RyYWxFbmQ7CiAgICBsZXQgciA9IDA7CiAgICBsZXQgczsKICAgIGxldCByczsKICAgIHdoaWxlIChrIDw9IGUpIHsKICAgICAgY29uc3Qgb2Zmc2V0WiA9IGJsb2NrT2Zmc2V0ICsgZGN0WmlnWmFnW2tdOwogICAgICBjb25zdCBzaWduID0gY29tcG9uZW50LmJsb2NrRGF0YVtvZmZzZXRaXSA8IDAgPyAtMSA6IDE7CiAgICAgIHN3aXRjaCAoc3VjY2Vzc2l2ZUFDU3RhdGUpIHsKICAgICAgICBjYXNlIDA6CiAgICAgICAgICBycyA9IGRlY29kZUh1ZmZtYW4oY29tcG9uZW50Lmh1ZmZtYW5UYWJsZUFDKTsKICAgICAgICAgIHMgPSBycyAmIDE1OwogICAgICAgICAgciA9IHJzID4+IDQ7CiAgICAgICAgICBpZiAocyA9PT0gMCkgewogICAgICAgICAgICBpZiAociA8IDE1KSB7CiAgICAgICAgICAgICAgZW9icnVuID0gcmVjZWl2ZShyKSArICgxIDw8IHIpOwogICAgICAgICAgICAgIHN1Y2Nlc3NpdmVBQ1N0YXRlID0gNDsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICByID0gMTY7CiAgICAgICAgICAgICAgc3VjY2Vzc2l2ZUFDU3RhdGUgPSAxOwogICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBpZiAocyAhPT0gMSkgewogICAgICAgICAgICAgIHRocm93IG5ldyBKcGVnRXJyb3IoImludmFsaWQgQUNuIGVuY29kaW5nIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc3VjY2Vzc2l2ZUFDTmV4dFZhbHVlID0gcmVjZWl2ZUFuZEV4dGVuZChzKTsKICAgICAgICAgICAgc3VjY2Vzc2l2ZUFDU3RhdGUgPSByID8gMiA6IDM7CiAgICAgICAgICB9CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICBjYXNlIDE6CiAgICAgICAgY2FzZSAyOgogICAgICAgICAgaWYgKGNvbXBvbmVudC5ibG9ja0RhdGFbb2Zmc2V0Wl0pIHsKICAgICAgICAgICAgY29tcG9uZW50LmJsb2NrRGF0YVtvZmZzZXRaXSAr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ys7CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGZvciAobiA9IDA7IG4gPCBtY3VUb1JlYWQ7IG4rKykgewogICAgICAgICAgZm9yIChpID0gMDsgaSA8IGNvbXBvbmVudHNMZW5ndGg7IGkrKykgewogICAgICAgICAgICBjb21wb25lbnQgPSBjb21wb25lbnRzW2ldOwogICAgICAgICAgICBoID0gY29tcG9uZW50Lmg7CiAgICAgICAgICAgIHYgPSBjb21wb25lbnQudjsKICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IHY7IGorKykgewogICAgICAgICAgICAgIGZvciAoayA9IDA7IGsgPCBoOyBrKyspIHsKICAgICAgICAgICAgICAgIGRlY29kZU1jdShjb21wb25lbnQsIGRlY29kZUZuLCBtY3UsIGosIGspOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgbWN1Kys7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBiaXRzQ291bnQgPSAwOwogICAgZmlsZU1hcmtlciA9IGZpbmROZXh0RmlsZU1hcmtlcihkYXRhLCBvZmZzZXQpOwogICAgaWYgKCFmaWxlTWFya2VyKSB7CiAgICAgIGJyZWFrOwogICAgfQogICAgaWYgKGZpbGVNYXJrZXIuaW52YWxpZCkgewogICAgICBjb25zdCBwYXJ0aWFsTXNnID0gbWN1VG9SZWFkID4gMCA/ICJ1bmV4cGVjdGVkIiA6ICJleGNlc3NpdmUiOwogICAgICAoMCwgX3V0aWwud2FybikoYGRlY29kZVNjYW4gLSAke3BhcnRpYWxNc2d9IE1DVSBkYXRhLCBjdXJyZW50IG1hcmtlciBpczogJHtmaWxlTWFya2VyLmludmFsaWR9YCk7CiAgICAgIG9mZnNldCA9IGZpbGVNYXJrZXIub2Zmc2V0OwogICAgfQogICAgaWYgKGZpbGVNYXJrZXIubWFya2VyID49IDB4ZmZkMCAmJiBmaWxlTWFya2VyLm1hcmtlciA8PSAweGZmZDcpIHsKICAgICAgb2Zmc2V0ICs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gPj49IDQ7CiAgICB9CiAgICBpZiAocDEgPCAxNikgewogICAgICBwMSA9IDA7CiAgICB9IGVsc2UgaWYgKHAxID49IDQwODApIHsKICAgICAgcDEgPSAyNTU7CiAgICB9IGVsc2UgewogICAgICBwMSA+Pj0gNDsKICAgIH0KICAgIGlmIChwMiA8IDE2KSB7CiAgICAgIHAyID0gMDsKICAgIH0gZWxzZSBpZiAocDIgPj0gNDA4MCkgewogICAgICBwMiA9IDI1NTsKICAgIH0gZWxzZSB7CiAgICAgIHAyID4+PSA0OwogICAgfQogICAgaWYgKHAzIDwgMTYpIHsKICAgICAgcDMgPSAwOwogICAgfSBlbHNlIGlmIChwMyA+PSA0MDgwKSB7CiAgICAgIHAzID0gMjU1OwogICAgfSBlbHNlIHsKICAgICAgcDMgPj49IDQ7CiAgICB9CiAgICBpZiAocDQgPCAxNikgewogICAgICBwNCA9IDA7CiAgICB9IGVsc2UgaWYgKHA0ID49IDQwODApIHsKICAgICAgcDQgPSAyNTU7CiAgICB9IGVsc2UgewogICAgICBwNCA+Pj0gNDsKICAgIH0KICAgIGlmIChwNSA8IDE2KSB7CiAgICAgIHA1ID0gMDsKICAgIH0gZWxzZSBpZiAocDUgPj0gNDA4MCkgewogICAgICBwNSA9IDI1NTsKICAgIH0gZWxzZSB7CiAgICAgIHA1ID4+PSA0OwogICAgfQogICAgaWYgKHA2IDwgMTYpIHsKICAgICAgcDYgPSAwOwogICAgfSBlbHNlIGlmIChwNiA+PSA0MDgwKSB7CiAgICAgIHA2ID0gMjU1OwogICAgfSBlbHNlIHsKICAgICAgcDYgPj49IDQ7CiAgICB9CiAgICBpZiAocDcgPCAxNikgewogICAgICBwNyA9IDA7CiAgICB9IGVsc2UgaWYgKHA3ID49IDQwODApIHsKICAgICAgcDcgPSAyNTU7CiAgICB9IGVsc2UgewogICAgICBwNyA+Pj0gNDsKICAgIH0KICAgIGJsb2NrRGF0YVtibG9ja0J1ZmZlck9mZnNldCArIGNvbF0gPSBwMDsKICAgIGJ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gICAgICAgY2FzZSAweGZmZTA6CiAgICAgICAgY2FzZSAweGZmZTE6CiAgICAgICAgY2FzZSAweGZmZTI6CiAgICAgICAgY2FzZSAweGZmZTM6CiAgICAgICAgY2FzZSAweGZmZTQ6CiAgICAgICAgY2FzZSAweGZmZTU6CiAgICAgICAgY2FzZSAweGZmZTY6CiAgICAgICAgY2FzZSAweGZmZTc6CiAgICAgICAgY2FzZSAweGZmZTg6CiAgICAgICAgY2FzZSAweGZmZTk6CiAgICAgICAgY2FzZSAweGZmZWE6CiAgICAgICAgY2FzZSAweGZmZWI6CiAgICAgICAgY2FzZSAweGZmZWM6CiAgICAgICAgY2FzZSAweGZmZWQ6CiAgICAgICAgY2FzZSAweGZmZWU6CiAgICAgICAgY2FzZSAweGZmZWY6CiAgICAgICAgY2FzZSAweGZmZmU6CiAgICAgICAgICBjb25zdCBhcHBEYXRhID0gcmVhZERhdGFCbG9jaygpOwogICAgICAgICAgaWYgKGZpbGVNYXJrZXIgPT09IDB4ZmZlMCkgewogICAgICAgICAgICBpZiAoYXBwRGF0YVswXSA9PT0gMHg0YSAmJiBhcHBEYXRhWzFdID09PSAweDQ2ICYmIGFwcERhdGFbMl0gPT09IDB4NDkgJiYgYXBwRGF0YVszXSA9PT0gMHg0NiAmJiBhcHBEYXRhWzRdID09PSAwKSB7CiAgICAgICAgICAgICAgamZpZiA9IHsKICAgICAgICAgICAgICAgIHZlcnNpb246IHsKICAgICAgICAgICAgICAgICAgbWFqb3I6IGFwcERhdGFbNV0sCiAgICAgICAgICAgICAgICAgIG1pbm9yOiBhcHBEYXRhWzZdCiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgZGVuc2l0eVVuaXRzOiBhcHBEYXRhWzddLAogICAgICAgICAgICAgICAgeERlbnNpdHk6IGFwcERhdGFbOF0gPDwgOCB8IGFwcERhdGFbOV0sCiAgICAgICAgICAgICAgICB5RGVuc2l0eTogYXBwRGF0YVsxMF0gPDwgOCB8IGFwcERhdGFbMTFdLAogICAgICAgICAgICAgICAgdGh1bWJXaWR0aDogYXBwRGF0YVsxMl0sCiAgICAgICAgICAgICAgICB0aHVtYkhlaWdodDogYXBwRGF0YVsxM10sCiAgICAgICAgICAgICAgICB0aHVtYkRhdGE6IGFwcERhdGEuc3ViYXJyYXkoMTQsIDE0ICsgMyAqIGFwcERhdGFbMTJdICogYXBwRGF0YVsxM10pCiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKGZpbGVNYXJrZXIgPT09IDB4ZmZlZSkgewogICAgICAgICAgICBpZiAoYXBwRGF0YVswXSA9PT0gMHg0MSAmJiBhcHBEYXRhWzFdID09PSAweDY0ICYmIGFwcERhdGFbMl0gPT09IDB4NmYgJiYgYXBwRGF0YVszXSA9PT0gMHg2MiAmJiBhcHBEYXRhWzRdID09PSAweDY1KSB7CiAgICAgICAgICAgICAgYWRvYmUgPSB7CiAgICAgICAgICAgICAgICB2ZXJzaW9uOiBhcHBEYXRhWzVdIDw8IDggfCBhcHBEYXRhWzZdLAogICAgICAgICAgICAgICAgZmxhZ3MwOiBhcHBEYXRhWzddIDw8IDggfCBhcHBEYXRhWzhdLAogICAgICAgICAgICAgICAgZmxhZ3MxOiBhcHBEYXRhWzldIDw8IDggfCBhcHBEYXRhWzEwXSwKICAgICAgICAgICAgICAgIHRyYW5zZm9ybUNvZGU6IGFwcERhdGFbMTFdCiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmZGI6CiAgICAgICAgICBjb25zdCBxdWFudGl6YXRpb25UYWJsZXNMZW5ndGggPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgY29uc3QgcXVhbnRpemF0aW9uVGFibGVzRW5kID0gcXVhbnRpemF0aW9uVGFibGVzTGVuZ3RoICsgb2Zmc2V0IC0gMjsKICAgICAgICAgIGxldCB6OwogICAgICAgICAgd2hpbGUgKG9mZnNldCA8IHF1YW50aXphdGlvblRhYmxlc0VuZCkgewogICAgICAgICAgICBjb25zdCBxdWFudGl6YXRpb25UYWJsZVNwZWMgPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgICAgY29uc3QgdGFibGVEYXRhID0gbmV3IFVpbnQxNkFycmF5KDY0KTsKICAgICAgICAgICAgaWYgKHF1YW50aXphdGlvblRhYmxlU3BlYyA+PiA0ID09PSAwKSB7CiAgICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IDY0OyBqKyspIHsKICAgICAgICAgICAgICAgIHogPSBkY3RaaWdaYWdbal07CiAgICAgICAgICAgICAgICB0YWJsZURhdGFbel0gPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gZWxzZSBpZiAocXVhbnRpemF0aW9uVGFibGVTcGVjID4+IDQgPT09IDEpIHsKICAgICAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgNjQ7IGorKykgewogICAgICAgICAgICAgICAgeiA9IGRjdFppZ1phZ1tqXTsKICAgICAgICAgICAgICAgIHRhYmxlRGF0YVt6XSA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICAgICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRocm93IG5ldyBKcGVnRXJyb3IoIkRRVCAtIGludmFsaWQgdGFibGUgc3BlYyIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHF1YW50aXphdGlvblRhYmxlc1txdWFudGl6YXRpb25UYWJsZVNwZWMgJiAxNV0gPSB0YWJsZURhdGE7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4ZmZjMDoKICAgICAgICBjYXNlIDB4ZmZjMToKICAgICAgICBjYXNlIDB4ZmZjMjoKICAgICAgICAgIGlmIChmcmFtZSkgewogICAgICAgICAgICB0aHJvdyBuZXcgSnBlZ0Vycm9yKCJPbmx5IHNpbmdsZSBmcmFtZSBKUEVHcyBzdXBwb3J0ZWQiKTsKICAgICAgICAgIH0KICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgZnJhbWUgPSB7fTsKICAgICAgICAgIGZyYW1lLmV4dGVuZGVkID0gZmlsZU1hcmtlciA9PT0gMHhmZmMxOwogICAgICAgICAgZnJhbWUucHJvZ3Jlc3NpdmUgPSBmaWxlTWFya2VyID09PSAweGZmYzI7CiAgICAgICAgICBmcmFtZS5wcmVjaXNpb24gPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgIGNvbnN0IHNvZlNjYW5MaW5lcyA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICBmcmFtZS5zY2FuTGluZXMgPSBkbmxTY2FuTGluZXMgfHwgc29mU2NhbkxpbmVzOwogICAgICAgICAgZnJhbWUuc2FtcGxlc1BlckxpbmUgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgZnJhbWUuY29tcG9uZW50cyA9IFtdOwogICAgICAgICAgZnJhbWUuY29tcG9uZW50SWRzID0ge307CiAgICAgICAgICBjb25zdCBjb21wb25lbnRzQ291bnQgPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgIGxldCBtYXhIID0gMCwKICAgICAgICAgICAgbWF4ViA9IDA7CiAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgY29tcG9uZW50c0NvdW50OyBpKyspIHsKICAgICAgICAgICAgY29uc3QgY29tcG9uZW50SWQgPSBkYXRhW29mZnNldF07CiAgICAgICAgICAgIGNvbnN0IGggPSBkYXRhW29mZnNldCArIDFdID4+IDQ7CiAgICAgICAgICAgIGNvbnN0IHYgPSBkYXRhW29mZnNldCArIDFdICYgMTU7CiAgICAgICAgICAgIGlmIChtYXhIIDwgaCkgewogICAgICAgICAgICAgIG1heEggPSBoOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChtYXhWIDwgdikgewogICAgICAgICAgICAgIG1heFYgPSB2OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IHFJZCA9IGRhdGFbb2Zmc2V0ICsgMl07CiAgICAgICAgICAgIGwgPSBmcmFtZS5jb21wb25lbnRzLnB1c2goewogICAgICAgICAgICAgIGgsCiAgICAgICAgICAgICAgdiwKICAgICAgICAgICAgICBxdWFudGl6YXRpb25JZDogcUlkLAogICAgICAgICAgICAgIHF1YW50aXphdGlvblRhYmxlOiBudWxsCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBmcmFtZS5jb21wb25lbnRJZHNbY29tcG9uZW50SWRdID0gbCAtIDE7CiAgICAgICAgICAgIG9mZnNldCArPSAzOwogICAgICAgICAgfQogICAgICAgICAgZnJhbWUubWF4SCA9IG1heEg7CiAgICAgICAgICBmcmFtZS5tYXhWID0gbWF4VjsKICAgICAgICAgIHByZXBhcmVDb21wb25lbnRzKGZyYW1lKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHhmZmM0OgogICAgICAgICAgY29uc3QgaHVmZm1hbkxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICBmb3IgKGkgPSAyOyBpIDwgaHVmZm1hbkxlbmd0aDspIHsKICAgICAgICAgICAgY29uc3QgaHVmZm1hblRhYmxlU3BlYyA9IGRhdGFbb2Zmc2V0KytdOwogICAgICAgICAgICBjb25zdCBjb2RlTGVuZ3RocyA9IG5ldyBVaW50OEFycmF5KDE2KTsKICAgICAgICAgICAgbGV0IGNvZGVMZW5ndGhTdW0gPSAwOwogICAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgMTY7IGorKywgb2Zmc2V0KyspIHsKICAgICAgICAgICAgICBjb2RlTGVuZ3RoU3VtICs9IGNvZGVMZW5ndGhzW2pdID0gZGF0YVtvZmZzZXRdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGh1ZmZtYW5WYWx1ZXMgPSBuZXcgVWludDhBcnJheShjb2RlTGVuZ3RoU3VtKTsKICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IGNvZGVMZW5ndGhTdW07IGorKywgb2Zmc2V0KyspIHsKICAgICAgICAgICAgICBodWZmbWFuVmFsdWVzW2pdID0gZGF0YVtvZmZzZXRdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGkgKz0gMTcgKyBjb2RlTGVuZ3RoU3VtOwogICAgICAgICAgICAoaHVmZm1hblRhYmxlU3BlYyA+PiA0ID09PSAwID8gaHVmZm1hblRhYmxlc0RDIDogaHVmZm1hblRhYmxlc0FDKVtodWZmbWFuVGFibGVTcGVjICYgMTVdID0gYnVpbGRIdWZmbWFuVGFibGUoY29kZUxlbmd0aHMsIGh1ZmZtYW5WYWx1ZXMpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmZGQ6CiAgICAgICAgICBvZmZzZXQgKz0gMjsKICAgICAgICAgIHJlc2V0SW50ZXJ2YWwgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmZGE6CiAgICAgICAgICBjb25zdCBwYXJzZUROTE1hcmtlciA9ICsrbnVtU09TTWFya2VycyA9PT0gMSAmJiAhZG5sU2NhbkxpbmVzOwogICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICBjb25zdCBzZWxlY3RvcnNDb3VudCA9IGRhdGFbb2Zmc2V0KytdLAogICAgICAgICAgICBjb21wb25lbnRzID0gW107CiAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgc2VsZWN0b3JzQ291bnQ7IGkrKykgewogICAgICAgICAgICBjb25zdCBpbmRleCA9IGRhdGFbb2Zmc2V0KytdOwogICAgICAgICAgICBjb25zdCBjb21wb25lbnRJbmRleCA9IGZyYW1lLmNvbXBvbmVudElkc1tpbmRleF07CiAgICAgICAgICAgIGNvbnN0IGNvbXBvbmVudCA9IGZyYW1lLmNvbXBvbmVudHNbY29tcG9uZW50SW5kZXhdOwogICAgICAgICAgICBjb21wb25lbnQuaW5kZXggPSBpbmRleDsKICAgICAgICAgICAgY29uc3QgdGFibGVTcGVjID0gZGF0YVtvZmZzZXQrK107CiAgICAgICAgICAgIGNvbXBvbmVudC5odWZmbWFuVGFibGVEQyA9IGh1ZmZtYW5UYWJsZXNEQ1t0YWJsZVNwZWMgPj4gNF07CiAgICAgICAgICAgIGNvbXBvbmVudC5odWZmbWFuVGFibGVBQyA9IGh1ZmZtYW5UYWJsZXNBQ1t0YWJsZVNwZWMgJiAxNV07CiAgICAgICAgICAgIGNvbXBvbmVudHMucHVzaChjb21wb25lbnQpOwogICAgICAgICAgfQogICAgICAgICAgY29uc3Qgc3BlY3RyYWxTdGFydCA9IGRhdGFbb2Zmc2V0KytdLAogICAgICAgICAgICBzcGVjdHJhbEVuZCA9IGRhdGFbb2Zmc2V0KytdLAogICAgICAgICAgICBzdWNjZXNzaXZlQXBwcm94aW1hdGlvbiA9IGRhdGFbb2Zmc2V0KytdOwogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgY29uc3QgcHJvY2Vzc2VkID0gZGVjb2RlU2NhbihkYXRhLCBvZmZzZXQsIGZyYW1lLCBjb21wb25lbnRzLCByZXNldEludGVydmFsLCBzcGVjdHJhbFN0YXJ0LCBzcGVjdHJhbEVuZCwgc3VjY2Vzc2l2ZUFwcHJveGltYXRpb24gPj4gNCwgc3VjY2Vzc2l2ZUFwcHJveGltYXRpb24gJiAxNSwgcGFyc2VETkxNYXJrZXIpOwogICAgICAgICAgICBvZmZzZXQgKz0gcHJvY2Vzc2VkOwogICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgaWYgKGV4IGluc3RhbmNlb2YgRE5MTWFya2VyRXJyb3IpIHsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYCR7ZXgubWVzc2FnZX0gLS0gYXR0ZW1wdGluZyB0byByZS1wYXJzZSB0aGUgSlBFRyBpbWFnZS5gKTsKICAgICAgICAgICAgICByZXR1cm4gdGhpcy5wYXJzZShkYXRhLCB7CiAgICAgICAgICAgICAgICBkbmxTY2FuTGluZXM6IGV4LnNjYW5MaW5lcwogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9IGVsc2UgaWYgKGV4IGluc3RhbmNlb2YgRU9JTWFya2VyRXJyb3IpIHsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYCR7ZXgubWVzc2FnZX0gLS0gaWdub3JpbmcgdGhlIHJlc3Qgb2YgdGhlIGltYWdlIGRhdGEuYCk7CiAgICAgICAgICAgICAgYnJlYWsgbWFya2VyTG9vcDsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aHJvdyBleDsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHhmZmRjOgogICAgICAgICAgb2Zmc2V0ICs9IDQ7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4ZmZmZjoKICAgICAgICAgIGlmIChkYXRhW29mZnNldF0gIT09IDB4ZmYpIHsKICAgICAgICAgICAgb2Zmc2V0LS07CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBkZWZhdWx0OgogICAgICAgICAgY29uc3QgbmV4dEZpbGVNYXJrZXIgPSBmaW5kTmV4dEZpbGVNYXJrZXIoZGF0YSwgb2Zmc2V0IC0gMiwgb2Zmc2V0IC0gMyk7CiAgICAgICAgICBpZiAobm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cykgewogICAgICBjb25zdCBxdWFudGl6YXRpb25UYWJsZSA9IHF1YW50aXphdGlvblRhYmxlc1tjb21wb25lbnQucXVhbnRpemF0aW9uSWRdOwogICAgICBpZiAocXVhbnRpemF0aW9uVGFibGUpIHsKICAgICAgICBjb21wb25lbnQucXVhbnRpemF0aW9uVGFibGUgPSBxdWFudGl6YXRpb25UYWJsZTsKICAgICAgfQogICAgICB0aGlzLmNvbXBvbmVudHMucHVzaCh7CiAgICAgICAgaW5kZXg6IGNvbXBvbmVudC5pbmRleCwKICAgICAgICBvdXRwdXQ6IGJ1aWxkQ29tcG9uZW50RGF0YShmcmFtZSwgY29tcG9uZW50KSwKICAgICAgICBzY2FsZVg6IGNvbXBvbmVudC5oIC8gZnJhbWUubWF4SCwKICAgICAgICBzY2FsZVk6IGNvbXBvbmVudC52IC8gZnJhbWUubWF4ViwKICAgICAgICBibG9ja3NQZXJMaW5lOiBjb21wb25lbnQuYmxvY2tzUGVyTGluZSwKICAgICAgICBibG9ja3NQZXJDb2x1bW46IGNvbXBvbmVudC5ibG9ja3NQZXJDb2x1bW4KICAgICAgfSk7CiAgICB9CiAgICB0aGlzLm51bUNvbXBvbmVudHMgPSB0aGlzLmNvbXBvbmVudHMubGVuZ3RoOwogICAgcmV0dXJuIHVuZGVmaW5lZDsKICB9CiAgX2dldExpbmVhcml6ZWRCbG9ja0RhdGEod2lkdGgsIGhlaWdodCkgewogICAgbGV0IGlzU291cmNlUERGID0gYXJndW1lbnRzLmxlbmd0aCA+IDIgJiYgYXJndW1lbnRzWzJdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMl0gOiBmYWxzZTsKICAgIGNvbnN0IHNjYWxlWCA9IHRoaXMud2lkdGggLyB3aWR0aCwKICAgICAgc2NhbGVZID0gdGhpcy5oZWlnaHQgLyBoZWlnaHQ7CiAgICBsZXQgY29tcG9uZW50LCBjb21wb25lbnRTY2FsZVgsIGNvbXBvbmVudFNjYWxlWSwgYmxvY2tzUGVyU2NhbmxpbmU7CiAgICBsZXQgeCwgeSwgaSwgaiwgazsKICAgIGxldCBpbmRleDsKICAgIGxldCBvZmZzZXQgPSAwOwogICAgbGV0IG91dHB1dDsKICAgIGNvbnN0IG51bUNvbXBvbmVudHMgPSB0aGlzLmNvbXBvbmVudHMubGVuZ3RoOwogICAgY29uc3QgZGF0YUxlbmd0aCA9IHdpZHRoICogaGVpZ2h0ICogbnVtQ29tcG9uZW50czsKICAgIGNvbnN0IGRhdGEgPSBuZXcgVWludDhDbGFtcGVkQXJyYXkoZGF0YUxlbmd0aCk7CiAgICBjb25zdCB4U2NhbGVCbG9ja09mZnNldCA9IG5ldyBVaW50MzJBcnJheSh3aWR0aCk7CiAgICBjb25zdCBtYXNrM0xTQiA9IDB4ZmZmZmZmZjg7CiAgICBsZXQgbGFzdENvbXBvbmVudFNjYWxlWDsKICAgIGZvciAoaSA9IDA7IGkgPCBudW1Db21wb25lbnRzOyBpKyspIHsKICAgICAgY29tcG9uZW50ID0gdGhpcy5jb21wb25lbnRzW2ldOwogICAgICBjb21wb25lbnRTY2FsZVggPSBjb21wb25lbnQuc2NhbGVYICogc2NhbGVYOwogICAgICBjb21wb25lbnRTY2FsZVkgPSBjb21wb25lbnQuc2NhbGVZICogc2NhbGVZOwogICAgICBvZmZzZXQgPSBpOwogICAgICBvdXRwdXQgPSBjb21wb25lbnQub3V0cHV0OwogICAgICBibG9ja3NQZXJTY2FubGluZSA9IGNvbXBvbmVudC5ibG9ja3NQZXJMaW5lICsgMSA8PCAzOwogICAgICBpZiAoY29tcG9uZW50U2NhbGVYICE9PSBsYXN0Q29tcG9uZW50U2NhbGVYKSB7CiAgICAgICAgZm9yICh4ID0gMDsgeCA8IHdpZHRoOyB4KyspIHsKICAgICAgICAgIGogPSAwIHwgeCAqIGNvbXBvbmVudFNjYWxlWDsKICAgICAgICAgIHhTY2FsZUJsb2NrT2Zmc2V0W3hdID0gKGogJiBtYXNrM0xTQikgPDwgMyB8IGogJiA3OwogICAgICAgIH0KICAgICAgICBsYXN0Q29tcG9uZW50U2NhbGVYID0gY29tcG9uZW50U2NhbGVYOwogICAgICB9CiAgICAgIGZvciAoeSA9IDA7IHkgPCBoZWlnaHQ7IHkrKykgewogICAgICAgIGogPSAwIHwgeSAqIGNvbXBvbmVudFNjYWxlWTsKICAgICAgICBpbmRleCA9IGJsb2Nrc1BlclNjYW5saW5lICogKGogJiBtYXNrM0xTQikgfCAoaiAmIDcpIDw8IDM7CiAgICAgICAgZm9yICh4ID0gMDsgeCA8IHdpZHRoOyB4KyspIHsKICAgICAgICAgIGRhdGFbb2Zmc2V0XSA9IG91dHB1dFtpbmRleCArIHhTY2FsZUJsb2NrT2Zmc2V0W3hdXTsKICAgICAgICAgIG9mZnNldCArPSBudW1Db21wb25lbnRzOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgbGV0IHRyYW5zZm9ybSA9IHRoaXMuX2RlY29kZVRyYW5zZm9ybTsKICAgIGlmICghaXNTb3VyY2VQREYgJiYgbnVtQ29tcG9uZW50cyA9PT0gNCAmJiAhdHJhbnNmb3JtKSB7CiAgICAgIHRyYW5zZm9ybSA9IG5ldyBJbnQzMkFycmF5KFstMjU2LCAyNTUsIC0yNTYsIDI1NSwgLTI1NiwgMjU1LCAtMjU2LCAyNTVdKTsKICAgIH0KICAgIGlmICh0cmFuc2Zvcm0pIHsKICAgICAgZm9yIChpID0gMDsgaSA8IGRhdGFMZW5ndGg7KSB7CiAgICAgICAgZm9yIChqID0gMCwgayA9IDA7IGogPCBudW1Db21wb25lbnRzOyBqKyssIGkrKywgayArPSAyKSB7CiAgICAgICAgICBkYXRhW2ldID0gKGRhdGFbaV0gKiB0cmFuc2Zvcm1ba10gPj4gOCkgKyB0cmFuc2Zvcm1bayArIDFdOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIGRhdGE7CiAgfQogIGdldCBfaXNDb2xvckNvbnZlcnNpb25OZWVkZWQoKSB7CiAgICBpZiAodGhpcy5hZG9iZSkgewogIC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yBVaW50MzJBcnJheShyZ2JhRGF0YS5idWZmZXIpKTsKICAgICAgfSBlbHNlIHsKICAgICAgICBmb3IgKGNvbnN0IGdyYXlDb2xvciBvZiBkYXRhKSB7CiAgICAgICAgICByZ2JhRGF0YVtvZmZzZXQrK10gPSBncmF5Q29sb3I7CiAgICAgICAgICByZ2JhRGF0YVtvZmZzZXQrK10gPSBncmF5Q29sb3I7CiAgICAgICAgICByZ2JhRGF0YVtvZmZzZXQrK10gPSBncmF5Q29sb3I7CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiByZ2JhRGF0YTsKICAgIH0gZWxzZSBpZiAodGhpcy5udW1Db21wb25lbnRzID09PSAzICYmIHRoaXMuX2lzQ29sb3JDb252ZXJzaW9uTmVlZGVkKSB7CiAgICAgIGlmIChmb3JjZVJHQkEpIHsKICAgICAgICBjb25zdCByZ2JhRGF0YSA9IG5ldyBVaW50OENsYW1wZWRBcnJheShkYXRhLmxlbmd0aCAvIDMgKiA0KTsKICAgICAgICByZXR1cm4gdGhpcy5fY29udmVydFljY1RvUmdiYShkYXRhLCByZ2JhRGF0YSk7CiAgICAgIH0KICAgICAgcmV0dXJuIHRoaXMuX2NvbnZlcnRZY2NUb1JnYihkYXRhKTsKICAgIH0gZWxzZSBpZiAodGhpcy5udW1Db21wb25lbnRzID09PSA0KSB7CiAgICAgIGlmICh0aGlzLl9pc0NvbG9yQ29udmVyc2lvbk5lZWRlZCkgewogICAgICAgIGlmIChmb3JjZVJHQkEpIHsKICAgICAgICAgIHJldHVybiB0aGlzLl9jb252ZXJ0WWNja1RvUmdiYShkYXRhKTsKICAgICAgICB9CiAgICAgICAgaWYgKGZvcmNlUkdCKSB7CiAgICAgICAgICByZXR1cm4gdGhpcy5fY29udmVydFljY2tUb1JnYihkYXRhKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRoaXMuX2NvbnZlcnRZY2NrVG9DbXlrKGRhdGEpOwogICAgICB9IGVsc2UgaWYgKGZvcmNlUkdCQ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HRoaXMuYnVmZmVyID0ganB4SW1hZ2UudGlsZXNbMF0uaXRlbXM7CiAgICB9IGVsc2UgewogICAgICBjb25zdCBkYXRhID0gbmV3IFVpbnQ4Q2xhbXBlZEFycmF5KHdpZHRoICogaGVpZ2h0ICogY29tcG9uZW50c0NvdW50KTsKICAgICAgZm9yIChsZXQgayA9IDA7IGsgPCB0aWxlQ291bnQ7IGsrKykgewogICAgICAgIGNvbnN0IHRpbGVDb21wb25lbnRzID0ganB4SW1hZ2UudGlsZXNba107CiAgICAgICAgY29uc3QgdGlsZVdpZHRoID0gdGlsZUNvbXBvbmVudHMud2lkdGg7CiAgICAgICAgY29uc3QgdGlsZUhlaWdodCA9IHRpbGVDb21wb25lbnRzLmhlaWdodDsKICAgICAgICBjb25zdCB0aWxlTGVmdCA9IHRpbGVDb21wb25lbnRzLmxlZnQ7CiAgICAgICAgY29uc3QgdGlsZVRvcCA9IHRpbGVDb21wb25lbnRzLnRvcDsKICAgICAgICBjb25zdCBzcmMgPSB0aWxlQ29tcG9uZW50cy5pdGVtczsKICAgICAgICBsZXQgc3JjUG9zaXRpb24gPSAwOwogICAgICAgIGxldCBkYXRhUG9zaXRpb24gPSAod2lkdGggKiB0aWxlVG9wICsgdGlsZUxlZnQpICogY29tcG9uZW50c0NvdW50OwogICAgICAgIGNvbnN0IGltZ1Jvd1NpemUgPSB3aWR0aCAqIGNvbXBvbmVudHNDb3VudDsKICAgICAgICBjb25zdCB0aWxlUm93U2l6ZSA9IHRpbGVXaWR0aCAqIGNvbXBvbmVudHNDb3VudDsKICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IHRpbGVIZWlnaHQ7IGorKykgewogICAgICAgICAgY29uc3Qgcm93Qnl0ZXMgPSBzcmMuc3ViYXJyYXkoc3JjUG9zaXRpb24sIHNyY1Bvc2l0aW9uICsgdGlsZVJvd1NpemUpOwogICAgICAgICAgZGF0YS5zZXQocm93Qnl0ZXMsIGRhdGFQb3NpdGlvbik7CiAgICAgICAgICB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oZGF0YSkgewogICAgY29uc3QgaGVhZCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCAwKTsKICAgIGlmIChoZWFkID09PSAweGZmNGYpIHsKICAgICAgdGhpcy5wYXJzZUNvZGVzdHJlYW0oZGF0YSwgMCwgZGF0YS5sZW5ndGgpOwogICAgICByZXR1cm47CiAgICB9CiAgICBjb25zdCBsZW5ndGggPSBkYXRhLmxlbmd0aDsKICAgIGxldCBwb3NpdGlvbiA9IDA7CiAgICB3aGlsZSAocG9zaXRpb24gPCBsZW5ndGgpIHsKICAgICAgbGV0IGhlYWRlclNpemUgPSA4OwogICAgICBsZXQgbGJveCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbik7CiAgICAgIGNvbnN0IHRib3ggPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyA0KTsKICAgICAgcG9zaXRpb24gKz0gaGVhZGVyU2l6ZTsKICAgICAgaWYgKGxib3ggPT09IDEpIHsKICAgICAgICBsYm94ID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MzIpKGRhdGEsIHBvc2l0aW9uKSAqIDQyOTQ5NjcyOTYgKyAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyA0KTsKICAgICAgICBwb3NpdGlvbiArPSA4OwogICAgICAgIGhlYWRlclNpemUgKz0gODsKICAgICAgfQogICAgICBpZiAobGJveCA9PT0gMCkgewogICAgICAgIGxib3ggPSBsZW5ndGggLSBwb3NpdGlvbiArIGhlYWRlclNpemU7CiAgICAgIH0KICAgICAgaWYgKGxib3ggPCBoZWFkZXJTaXplKSB7CiAgICAgICAgdGhyb3cgbmV3IEpweEVycm9yKCJJbnZhbGlkIGJveCBmaWVsZCBzaXplIik7CiAgICAgIH0KICAgICAgY29uc3QgZGF0YUxlbmd0aCA9IGxib3ggLSBoZWFkZXJTaXplOwogICAgICBsZXQganVtcERhdGFMZW5ndGggPSB0cnVlOwogICAgICBzd2l0Y2ggKHRib3gpIHsKICAgICAgICBjYXNlIDB4NmE3MDMyNjg6CiAgICAgICAgICBqdW1wRGF0YUxlbmd0aCA9IGZhbHNlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDYzNmY2YzcyOgogICAgICAgICAgY29uc3QgbWV0aG9kID0gZGF0YVtwb3NpdGlvbl07CiAgICAgICAgICBpZiAobWV0aG9kID09PSAxKSB7CiAgICAgICAgICAgIGNvbnN0IGNvbG9yc3BhY2UgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAzKTsKICAgICAgICAgICAgc3dpdGNoIChjb2xvcnNwYWNlKSB7CiAgICAgICAgICAgICAgY2FzZSAxNjoKICAgICAgICAgICAgICBjYXNlIDE3OgogICAgICAgICAgICAgIGNhc2UgMTg6CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJVbmtub3duIGNvbG9yc3BhY2UgIiArIGNvbG9yc3BhY2UpOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSBpZiAobWV0aG9kID09PSAyKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC5pbmZvKSgiSUNDIHByb2ZpbGUgbm90IHN1cHBvcnRlZCIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDZhNzAzMjYzOgogICAgICAgICAgdGhpcy5wYXJzZUNvZGVzdHJlYW0oZGF0YSwgcG9zaXRpb24sIHBvc2l0aW9uICsgZGF0YUxlbmd0aCk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4NmE1MDIwMjA6CiAgICAgICAgICBpZiAoKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MzIp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NCk7CiAgICAgICAgY29uc3QgWHNpeiA9IHN0cmVhbS5nZXRJbnQzMigpID4+PiAwOwogICAgICAgIGNvbnN0IFlzaXogPSBzdHJlYW0uZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICBjb25zdCBYT3NpeiA9IHN0cmVhbS5nZXRJbnQzMigpID4+PiAwOwogICAgICAgIGNvbnN0IFlPc2l6ID0gc3RyZWFtLmdldEludDMyKCkgPj4+IDA7CiAgICAgICAgc3RyZWFtLnNraXAoMTYpOwogICAgICAgIGNvbnN0IENzaXogPSBzdHJlYW0uZ2V0VWludDE2KCk7CiAgICAgICAgdGhpcy53aWR0aCA9IFhzaXogLSBYT3NpejsKICAgICAgICB0aGlzLmhlaWdodCA9IFlzaXogLSBZT3NpejsKICAgICAgICB0aGlzLmNvbXBvbmVudHNDb3VudCA9IENzaXo7CiAgICAgICAgdGhpcy5iaXRzUGVyQ29tcG9uZW50ID0gODsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgIH0KICAgIHRocm93IG5ldyBKcHhFcnJvcigiTm8gc2l6ZSBtYXJrZXIgZm91bmQgaW4gSlBYIHN0cmVhbSIpOwogIH0KICBwYXJzZUNvZGVzdHJlYW0oZGF0YSwgc3RhcnQsIGVuZCkgewogICAgY29uc3QgY29udGV4dCA9IHt9OwogICAgbGV0IGRvTm90UmVjb3ZlciA9IGZhbHNlOwogICAgdHJ5IHsKICAgICAgbGV0IHBvc2l0aW9uID0gc3RhcnQ7CiAgICAgIHdoaWxlIChwb3NpdGlvbiArIDEgPCBlbmQpIHsKICAgICAgICBjb25zdCBjb2RlID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MTYpKGRhdGEsIHBvc2l0aW9uKTsKICAgICAgICBwb3NpdGlvbiArPSAyOwogICAgICAgIGxldCBsZW5ndGggPSAwLAogICAgICAgICAgaiwKICAgICAgICAgIHNxY2QsCiAgICAgICAgICBzcHFjZHMsCiAgICAgICAgICBzcHFjZFNpemUsCiAgICAgICAgICBzY2FsYXJFeHBvdW5kZWQsCiAgICAgICAgICB0aWxlOwogICAgICAgIHN3aXRjaCAoY29kZSkgewogICAgICAgICAgY2FzZSAweGZmNGY6CiAgICAgICAgICAgIGNvbnRleHQubWFpbkhlYWRlciA9IHRydWU7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmZDk6CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmNTE6CiAgICAgICAgICAgIGxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbik7CiAgICAgICAgICAgIGNvbnN0IHNpeiA9IHt9OwogICAgICAgICAgICBzaXouWHNpeiA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDQpOwogICAgICAgICAgICBzaXouWXNpeiA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDgpOwogICAgICAgICAgICBzaXouWE9zaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAxMik7CiAgICAgICAgICAgIHNpei5ZT3NpeiA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDE2KTsKICAgICAgICAgICAgc2l6LlhUc2l6ID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MzIpKGRhdGEsIHBvc2l0aW9uICsgMjApOwogICAgICAgICAgICBzaXouWVRzaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAyNCk7CiAgICAgICAgICAgIHNpei5YVE9zaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAyOCk7CiAgICAgICAgICAgIHNpei5ZVE9zaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAzMik7CiAgICAgICAgICAgIGNvbnN0IGNvbXBvbmVudHNDb3VudCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbiArIDM2KTsKICAgICAgICAgICAgc2l6LkNzaXogPSBjb21wb25lbnRzQ291bnQ7CiAgICAgICAgICAgIGNvbnN0IGNvbXBvbmVudHMgPSBbXTsKICAgICAgICAgICAgaiA9IHBvc2l0aW9uICsgMzg7CiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgY29tcG9uZW50c0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBjb25zdCBjb21wb25lbnQgPSB7CiAgICAgICAgICAgICAgICBwcmVjaXNpb246IChkYXRhW2pdICYgMHg3ZikgKyAxLAogICAgICAgICAgICAgICAgaXNTaWduZWQ6ICEhKGRhdGFbal0gJiAweDgwKSwKICAgICAgICAgICAgICAgIFhSc2l6OiBkYXRhW2ogKyAxXSwKICAgICAgICAgICAgICAgIFlSc2l6OiBkYXRhW2ogKyAyXQogICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgaiArPSAzOwogICAgICAgICAgICAgIGNhbGN1bGF0ZUNvbXBvbmVudERpbWVuc2lvbnMoY29tcG9uZW50LCBzaXopOwogICAgICAgICAgICAgIGNvbXBvbmVudHMucHVzaChjb21wb25lbnQpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnRleHQuU0laID0gc2l6OwogICAgICAgICAgICBjb250ZXh0LmNvbXBvbmVudHMgPSBjb21wb25lbnRzOwogICAgICAgICAgICBjYWxjdWxhdGVUaWxlR3JpZHMoY29udGV4dCwgY29tcG9uZW50cyk7CiAgICAgICAgICAgIGNvbnRleHQuUUNDID0gW107CiAgICAgICAgICAgIGNvbnRleHQuQ09DID0gW107CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmNWM6CiAgICAgICAgICAgIGxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbik7CiAgICAgICAgICAgIGNvbnN0IHFjZCA9IHt9OwogICAgICAgICAgICBqID0gcG9zaXRpb24gKyAyOwogICAgICAgICAgICBzcWNkID0gZGF0YVtqKytdOwogICAgICAgICAgICBzd2l0Y2ggKHNxY2QgJiAweDFmKSB7CiAgICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gODsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgICBzcHFjZFNpemUgPSAxNjsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gMTY7CiAgICAgICAgICAgICAgICBzY2FsYXJFeHBvdW5kZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiSW52YWxpZCBTUWNkIHZhbHVlICIgKyBzcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2Qubm9RdWFudGl6YXRpb24gPSBzcHFjZFNpemUgPT09IDg7CiAgICAgICAgICAgIHFjZC5zY2FsYXJFeHBvdW5kZWQgPSBzY2FsYXJFeHBvdW5kZWQ7CiAgICAgICAgICAgIHFjZC5ndWFyZEJpdHMgPSBzcWNkID4+IDU7CiAgICAgICAgICAgIHNwcWNkcyA9IFtdOwogICAgICAgICAgICB3aGlsZSAoaiA8IGxlbmd0aCArIHBvc2l0aW9uKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3BxY2QgPSB7fTsKICAgICAgICAgICAgICBpZiAoc3BxY2RTaXplID09PSA4KSB7CiAgICAgICAgICAgICAgICBzcHFjZC5lcHNpbG9uID0gZGF0YVtqKytdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IDA7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHNwcWNkLmVwc2lsb24gPSBkYXRhW2pdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IChkYXRhW2pdICYgMHg3KSA8PCA4IHwgZGF0YVtqICsgMV07CiAgICAgICAgICAgICAgICBqICs9IDI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNwcWNkcy5wdXNoKHNwcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2QuU1BxY2RzID0gc3BxY2RzOwogICAgICAgICAgICBpZiAoY29udGV4dC5tYWluSGVhZGVyKSB7CiAgICAgICAgICAgICAgY29udGV4dC5RQ0QgPSBxY2Q7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZS5RQ0QgPSBxY2Q7CiAgICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZS5RQ0MgPSBbXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMHhmZjVkOgogICAgICAgICAgICBsZW5ndGggPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgcG9zaXRpb24pOwogICAgICAgICAgICBjb25zdCBxY2MgPSB7fTsKICAgICAgICAgICAgaiA9IHBvc2l0aW9uICsgMjsKICAgICAgICAgICAgbGV0IGNxY2M7CiAgICAgICAgICAgIGlmIChjb250ZXh0LlNJWi5Dc2l6IDwgMjU3KSB7CiAgICAgICAgICAgICAgY3FjYyA9IGRhdGFbaisrXTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjcWNjID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MTYpKGRhdGEsIGopOwogICAgICAgICAgICAgIGogKz0gMjsKICAgICAgICAgICAgfQogICAgICAgICAgICBzcWNkID0gZGF0YVtqKytdOwogICAgICAgICAgICBzd2l0Y2ggKHNxY2QgJiAweDFmKSB7CiAgICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gODsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgICBzcHFjZFNpemUgPSAxNjsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gMTY7CiAgICAgICAgICAgICAgICBzY2FsYXJFeHBvdW5kZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiSW52YWxpZCBTUWNkIHZhbHVlICIgKyBzcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2Mubm9RdWFudGl6YXRpb24gPSBzcHFjZFNpemUgPT09IDg7CiAgICAgICAgICAgIHFjYy5zY2FsYXJFeHBvdW5kZWQgPSBzY2FsYXJFeHBvdW5kZWQ7CiAgICAgICAgICAgIHFjYy5ndWFyZEJpdHMgPSBzcWNkID4+IDU7CiAgICAgICAgICAgIHNwcWNkcyA9IFtdOwogICAgICAgICAgICB3aGlsZSAoaiA8IGxlbmd0aCArIHBvc2l0aW9uKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3BxY2QgPSB7fTsKICAgICAgICAgICAgICBpZiAoc3BxY2RTaXplID09PSA4KSB7CiAgICAgICAgICAgICAgICBzcHFjZC5lcHNpbG9uID0gZGF0YVtqKytdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IDA7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHNwcWNkLmVwc2lsb24gPSBkYXRhW2pdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IChkYXRhW2pdICYgMHg3KSA8PCA4IHwgZGF0YVtqICsgMV07CiAgICAgICAgICAgICAgICBqICs9IDI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNwcWNkcy5wdXNoKHNwcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2MuU1BxY2RzID0gc3BxY2RzOwogICAgICAgICAgICBpZiAoY29udGV4dC5tYWluSGVhZGVyKSB7CiAgICAgICAgICAgICAgY29udGV4dC5RQ0NbY3FjY10gPSBxY2M7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZS5RQ0NbY3FjY10gPSBxY2M7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDB4ZmY1MjoKICAgICAgICAgICAgbGVuZ3RoID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MTYpKGRhdGEsIHBvc2l0aW9uKTsKICAgICAgICAgICAgY29uc3QgY29kID0ge307CiAgICAgICAgICAgIGogPSBwb3NpdGlvbiArIDI7CiAgICAgICAgICAgIGNvbnN0IHNjb2QgPSBkYXRhW2orK107CiAgICAgICAgICAgIGNvZC5lbnRyb3B5Q29kZXJXaXRoQ3VzdG9tUHJlY2luY3RzID0gISEoc2NvZCAmIDEpOwogICAgICAgICAgICBjb2Quc29wTWFya2VyVXNlZCA9ICEhKHNjb2QgJiAyKTsKICAgICAgICAgICAgY29kLmVwaE1hcmtlclVzZWQgPSAhIShzY29kICYgNCk7CiAgICAgICAgICAgIGNvZC5wcm9ncmVzc2lvbk9yZGVyID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2QubGF5ZXJzQ291bnQgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgaik7CiAgICAgICAgICAgIGogKz0gMjsKICAgICAgICAgICAgY29kLm11bHRpcGxlQ29tcG9uZW50VHJhbnNmb3JtID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2QuZGVjb21wb3NpdGlvbkxldmVsc0NvdW50ID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2QueGNiID0gKGRhdGFbaisrXSAmIDB4ZikgKyAyOwogICAgICAgICAgICBjb2QueWNiID0gKGRhdGFbaisrXSAmIDB4ZikgKyAyOwogICAgICAgICAgICBjb25zdCBibG9ja1N0eWxlID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2Quc2VsZWN0aXZlQXJpdGhtZXRpY0NvZGluZ0J5cGFzcyA9ICEhKGJsb2NrU3R5bGUgJiAxKTsKICAgICAgICAgICAgY29kLnJlc2V0Q29udGV4dFByb2JhYmlsaXRpZXMgPSAhIShibG9ja1N0eWxlICYgMik7CiAgICAgICAgICAgIGNvZC50ZXJtaW5hdGlvbk9uRWFjaENvZGluZ1Bhc3MgPSAhIShibG9ja1N0eWxlICYgNCk7CiAgICAgICAgICAgIGNvZC52ZXJ0aWNhbGx5U3RyaXBlID0gISEoYmxvY2tTdHlsZSAmIDgpOwogICAgICAgICAgICBjb2QucHJlZGljdGFibGVUZXJtaW5hdGlvbiA9ICEhKGJsb2NrU3R5bGUgJiAxNik7CiAgICAgICAgICAgIGNvZC5zZWdtZW50YXRpb25TeW1ib2xVc2VkID0gISEoYmxvY2tTdHlsZSAmIDMyKTsKICAgICAgICAgICAgY29kLnJldmVyc2libGVUcmFuc2Zvcm1hdGlvbiA9IGRhdGFbaisrXTsKICAgICAgICAgICAgaWYgKGNvZC5lbnRyb3B5Q29kZXJXaXRoQ3VzdG9tUHJlY2luY3RzKSB7CiAgICAgICAgICAgICAgY29uc3QgcHJlY2luY3RzU2l6ZXMgPSBbXTsKICAgICAgICAgICAgICB3aGlsZSAoaiA8IGxlbmd0aCArIHBvc2l0aW9uKSB7CiAgICAgICAgICAgICAgICBjb25zdCBwcmVjaW5jdHNTaXplID0gZGF0YVtqKytdOwogICAgICAgICAgICAgICAgcHJlY2luY3RzU2l6ZXMucHVzaCh7CiAgICAgICAgICAgICAgICAgIFBQeDogcHJlY2luY3RzU2l6ZSAmIDB4ZiwKICAgICAgICAgICAgICAgICAgUFB5OiBwcmVjaW5jdHNTaXplID4+IDQKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb2QucHJlY2luY3RzU2l6ZXMgPSBwcmVjaW5jdHNTaXplczsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCB1bnN1cHBvcnRlZCA9IFtdOwogICAgICAgICAgICBpZiAoY29kLnNlbGVjdGl2ZUFyaXRobWV0aWNDb2RpbmdCeXBhc3MpIHsKICAgICAgICAgICAgICB1bnN1cHBvcnRlZC5wdXNoKCJzZWxlY3RpdmVBcml0aG1ldGljQ29kaW5nQnlwYXNzIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGNvZC50ZXJtaW5hdGlvbk9uRWFjaENvZGluZ1Bhc3MpIHsKICAgICAgICAgICAgICB1bnN1cHBvcnRlZC5wdXNoKCJ0ZXJtaW5hdGlvbk9uRWFjaENvZGluZ1Bhc3MiKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoY29kLnZlcnRpY2FsbHlTdHJpcGUpIHsKICAgICAgICAgICAgICB1bnN1cHBvcnRlZC5wdXNoKCJ2ZXJ0aWNhbGx5U3RyaXBlIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGNvZC5wcmVkaWN0YWJsZVRlcm1pbmF0aW9uKSB7CiAgICAgICAgICAgICAgdW5zdXBwb3J0ZWQucHVzaCgicHJlZGljdGFibGVUZXJtaW5hdGlvbiIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICh1bnN1cHBvcnRlZC5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgZG9Ob3RSZWNvdmVyID0gdHJ1ZTsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYEpQWDogVW5zdXBwb3J0ZWQgQ09EIG9wdGlvbnMgKCR7dW5zdXBwb3J0ZWQuam9pbigiLCAiKX0pLmApOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChjb250ZXh0Lm1haW5IZWFkZXIpIHsKICAgICAgICAgICAgICBjb250ZXh0LkNPRCA9IGNvZDsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjb250ZXh0LmN1cnJlbnRUaWxlLkNPRCA9IGNvZDsKICAgICAgICAgICAgICBjb250ZXh0LmN1cnJlbnRUaWxlLkNPQyA9IFtdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmOTA6CiAgICAgICAgICAgIGxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbik7CiAgICAgICAgICAgIHRpbGUgPSB7fTsKICAgICAgICAgICAgdGlsZS5pbmRleCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbiArIDIpOwogICAgICAgICAgICB0aWxlLmxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDQpOwogICAgICAgICAgICB0aWxlLmRhdGFFbmQgPSB0aWxlLmxlbmd0aCArIHBvc2l0aW9uIC0gMjsKICAgICAgICAgICAgdGlsZS5wYXJ0SW5kZXggPSBkYXRhW3Bvc2l0aW9uICsgOF07CiAgICAgICAgICAgIHRpbGUucGFydHNDb3VudCA9IGRhdGFbcG9zaXRpb24gKyA5XTsKICAgICAgICAgICAgY29udGV4dC5tYWluSGVhZGVyID0gZmFsc2U7CiAgICAgICAgICAgIGlmICh0aWxlLnBhcnRJbmRleCA9PT0gMCkgewogICAgICAgICAgICAgIHRpbGUuQ09EID0gY29udGV4dC5DT0Q7CiAgICAgICAgICAgICAgdGlsZS5DT0MgPSBjb250ZXh0LkNPQy5zbGljZSgwKTsKICAgICAgICAgICAgICB0aWxlLlFDRCA9IGNvbnRleHQuUUNEOwogICAgICAgICAgICAgIHRpbGUuUUNDID0gY29udGV4dC5RQ0Muc2xpY2UoMCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZSA9IHRpbGU7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmOTM6CiAgICAgICAgICAgIHRpbGUgPSBjb250ZXh0LmN1cnJlbnRUaWxlOwogICAgICAgICAgICBpZiAodGlsZS5wYXJ0SW5kZXggPT09IDApIHsKICAgICAgICAgICAgICBpbml0aWFsaXplVGlsZShjb250ZXh0LCB0aWxlLmluZGV4KTsKICAgICAgICAgICAgICBidWlsZFBhY2tldHMoY29udGV4dCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbGVuZ3RoID0gdGlsZS5kYXRhRW5kIC0gcG9zaXRpb247CiAgICAgICAgICAgIHBhcnNlVGlsZVBhY2tldHMoY29udGV4dCwgZGF0YSwgcG9zaXRpb24sIGxlbmd0aCk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmNTM6CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiSlBYOiBDb2Rlc3RyZWFtIGNvZGUgMHhGRjUzIChDT0MpIGlzIG5vdCBpbXBsZW1lbnRlZC4iKTsKICAgICAgICAgIGNhc2UgMHhmZjU1OgogICAgICAgICAgY2FzZSAweGZmNTc6CiAgICAgICAgICBjYXNlIDB4ZmY1ODoKICAgICAgICAgIGNhc2UgMHhmZjY0OgogICAgICAgICAgICBsZW5ndGggPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgcG9zaXRpb24pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGRlZmF1bHQ6CiAgIC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zdWJiYW5kLnRieTAgPj4geWNiXzsKICBjb25zdCBjYngxID0gc3ViYmFuZC50YngxICsgY29kZWJsb2NrV2lkdGggLSAxID4+IHhjYl87CiAgY29uc3QgY2J5MSA9IHN1YmJhbmQudGJ5MSArIGNvZGVibG9ja0hlaWdodCAtIDEgPj4geWNiXzsKICBjb25zdCBwcmVjaW5jdFBhcmFtZXRlcnMgPSBzdWJiYW5kLnJlc29sdXRpb24ucHJlY2luY3RQYXJhbWV0ZXJzOwogIGNvbnN0IGNvZGVibG9ja3MgPSBbXTsKICBjb25zdCBwcmVjaW5jdHMgPSBbXTsKICBsZXQgaSwgaiwgY29kZWJsb2NrLCBwcmVjaW5jdE51bWJlcjsKICBmb3IgKGogPSBjYnkwOyBqIDwgY2J5MTsgaisrKSB7CiAgICBmb3IgKGkgPSBjYngwOyBpIDwgY2J4MTsgaSsrKSB7CiAgICAgIGNvZGVibG9jayA9IHsKICAgICAgICBjYng6IGksCiAgICAgICAgY2J5OiBqLAogICAgICAgIHRieDA6IGNvZGVibG9ja1dpZHRoICogaSwKICAgICAgICB0YnkwOiBjb2RlYmxvY2tIZWlnaHQgKiBqLAogICAgICAgIHRieDE6IGNvZGVibG9ja1dpZHRoICogKGkgKyAxKSwKICAgICAgICB0YnkxOiBjb2RlYmxvY2tIZWlnaHQgKiAoaiArIDEpCiAgICAgIH07CiAgICAgIGNvZGVibG9jay50YngwXyA9IE1hdGgubWF4KHN1YmJhbmQudGJ4MCwgY29kZWJsb2NrLnRieDApOwogICAgICBjb2RlYmxvY2sudGJ5MF8gPSBNYXRoLm1heChzdWJiYW5kLnRieTAsIGNvZGVibG9jay50YnkwKTsKICAgICAgY29kZWJsb2NrLnRieDFfID0gTWF0aC5taW4oc3ViYmFuZC50YngxLCBjb2RlYmxvY2sudGJ4MSk7CiAgICAgIGNvZGVibG9jay50YnkxXyA9IE1hdGgubWluKHN1YmJhbmQudGJ5MSwgY29kZWJsb2NrLnRieTEpOwogICAgICBjb25zdCBwaSA9IE1hdGguZmxvb3IoKGNvZGVibG9jay50YngwXyAtIHN1YmJhbmQudGJ4MCkgLyBwcmVjaW5jdFBhcmFtZXRlcnMucHJlY2luY3RXaWR0aEluU3ViYmFuZCk7CiAgICAgIGNvbnN0IHBqID0gTWF0aC5mbG9vcigoY29kZWJsb2NrLnRieTBfIC0gc3ViYmFuZC50YnkwKSAvIHByZWNpbmN0UGFyYW1ldGVycy5wcmVjaW5jdEhlaWdodEluU3ViYmFuZCk7CiAgICAgIHByZWNpbmN0TnVtYmVyID0gcGkgKyBwaiAqIHByZWNpbmN0UGFyYW1ldGVycy5udW1wcmVjaW5jdHN3aWRlOwogICAgICBjb2RlYmxvY2sucHJlY2luY3ROdW1iZXIgPSBwcmVjaW5jdE51bWJlcjsKICAgICAgY29kZWJsb2NrLnN1YmJhbmRUeXBlID0gc3ViYmFuZC50eXBlOwogICAgICBjb2RlYmxvY2suTGJsb2NrID0gMzsKICAgICAgaWYgKGNvZGVibG9jay50YngxXyA8PSBjb2RlYmxvY2sudGJ4MF8gfHwgY29kZWJsb2NrLnRieTFfIDw9IGNvZGVibG9jay50YnkwXykgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvZGVibG9ja3MucHVzaChjb2RlYmxvY2spOwogICAgICBsZXQgcHJlY2luY3QgPSBwcmVjaW5jdHNbcHJlY2luY3ROdW1iZXJdOwogICAgICBpZiAocHJlY2luY3QgIT09IHVuZGVmaW5lZCkgewogICAgICAgIGlmIChpIDwgcHJlY2luY3QuY2J4TWluKSB7CiAgICAgICAgICBwcmVjaW5jdC5jYnhNaW4gPSBpOwogICAgICAgIH0gZWxzZSBpZiAoaSA+IHByZWNpbmN0LmNieE1heCkgewogICAgICAgICAgcHJlY2luY3QuY2J4TWF4ID0gaTsKICAgICAgICB9CiAgICAgICAgaWYgKGogPCBwcmVjaW5jdC5jYnlNaW4pIHsKICAgICAgICAgIHByZWNpbmN0LmNieE1pbiA9IGo7CiAgICAgICAgfSBlbHNlIG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X25leHRQYWNrZXQoKSB7CiAgICBmb3IgKDsgbCA8IGxheWVyc0NvdW50OyBsKyspIHsKICAgICAgZm9yICg7IHIgPD0gbWF4RGVjb21wb3NpdGlvbkxldmVsc0NvdW50OyByKyspIHsKICAgICAgICBmb3IgKDsgaSA8IGNvbXBvbmVudHNDb3VudDsgaSsrKSB7CiAgICAgICAgICBjb25zdCBjb21wb25lbnQgPSB0aWxlLmNvbXBvbmVudHNbaV07CiAgICAgICAgICBpZiAociA+IGNvbXBvbmVudC5jb2RpbmdTdHlsZVBhcmFtZXRlcnMuZGVjb21wb3NpdGlvbkxldmVsc0NvdW50KSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgY29uc3QgcmVzb2x1dGlvbiA9IGNvbXBvbmVudC5yZXNvbHV0aW9uc1tyXTsKICAgICAgICAgIGNvbnN0IG51bXByZWNpbmN0cyA9IHJlc29sdXRpb24ucHJlY2luY3RQYXJhbWV0ZXJzLm51bXByZWNpbmN0czsKICAgICAgICAgIGZvciAoOyBrIDwgbnVtcHJlY2luY3RzOykgewogICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgaywgbCk7CiAgICAgICAgICAgIGsrKzsKICAgICAgICAgICAgcmV0dXJuIHBhY2tldDsKICAgICAgICAgIH0KICAgICAgICAgIGsgPSAwOwogICAgICAgIH0KICAgICAgICBpID0gMDsKICAgICAgfQogICAgICByID0gMDsKICAgIH0KICAgIHRocm93IG5ldyBKcHhFcnJvcigiT3V0IG9mIHBhY2tldHMiKTsKICB9Owp9CmZ1bmN0aW9uIFJlc29sdXRpb25MYXllckNvbXBvbmVudFBvc2l0aW9uSXRlcmF0b3IoY29udGV4dCkgewogIGNvbnN0IHNpeiA9IGNvbnRleHQuU0laOwogIGNvbnN0IHRpbGVJbmRleCA9IGNvbnRleHQuY3VycmVudFRpbGUuaW5kZXg7CiAgY29uc3QgdGlsZSA9IGNvb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Rpb24ucHJlY2luY3RQYXJhbWV0ZXJzLm51bXByZWNpbmN0czsKICAgICAgICAgIGZvciAoOyBrIDwgbnVtcHJlY2luY3RzOykgewogICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgaywgbCk7CiAgICAgICAgICAgIGsrKzsKICAgICAgICAgICAgcmV0dXJuIHBhY2tldDsKICAgICAgICAgIH0KICAgICAgICAgIGsgPSAwOwogICAgICAgIH0KICAgICAgICBpID0gMDsKICAgICAgfQogICAgICBsID0gMDsKICAgIH0KICAgIHRocm93IG5ldyBKcHhFcnJvcigiT3V0IG9mIHBhY2tldHMiKTsKICB9Owp9CmZ1bmN0aW9uIFJlc29sdXRpb25Qb3NpdGlvbkNvbXBvbmVudExheWVySXRlcmF0b3IoY29udGV4dCkgewogIGNvbnN0IHNpeiA9IGNvbnRleHQuU0laOwogIGNvbnN0IHRpbGVJbmRleCA9IGNvbnRleHQuY3VycmVudFRpbGUuaW5kZXg7CiAgY29uc3QgdGlsZSA9IGNvbnRleHQudGlsZXNbdGlsZUluZGV4XTsKICBjb25zdCBsYXllcnNDb3VudCA9IHRpbGUuY29kaW5nU3R5bGVEZWZhdWx0UGFyYW1ldGVycy5sYXllcnNDb3VudDsKICBjb25zdCBjb21wb25lbnRzQ291bnQgPSBzaXouQ3NpejsKICBsZXQgbCwgciwgYywgcDsKICBsZXQgbWF4RGVjb21wb3NpdGlvbkxldmVsc0NvdW50ID0gMDsKICBmb3IgKGMgPSAwOyBjIDwgY29tcG9uZW50c0NvdW50OyBjKyspIHsKICAgIGNvbnN0IGNvbXBvbmVudCA9IHRpbGUuY29tcG9uZW50c1tjXTsKICAgIG1heERlY29tcG9zaXRpb25MZXZlbHNDb3VudCA9IE1hdGgubWF4KG1heERlY29tcG9zaXRpb25MZXZlbHNDb3VudCwgY29tcG9uZW50LmNvZGluZ1N0eWxlUGFyYW1ldGVycy5kZWNvbXBvc2l0aW9uTGV2ZWxzQ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VudCkgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IHJlc29sdXRpb24gPSBjb21wb25lbnQucmVzb2x1dGlvbnNbcl07CiAgICAgICAgICBjb25zdCBudW1wcmVjaW5jdHMgPSByZXNvbHV0aW9uLnByZWNpbmN0UGFyYW1ldGVycy5udW1wcmVjaW5jdHM7CiAgICAgICAgICBpZiAocCA+PSBudW1wcmVjaW5jdHMpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBmb3IgKDsgbCA8IGxheWVyc0NvdW50OykgewogICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgcCwgbCk7CiAgICAgICAgICAgIGwrKzsKICAgICAgICAgICAgcmV0dXJuIHBhY2tldDsKICAgICAgICAgIH0KICAgICAgICAgIGwgPSAwOwogICAgICAgIH0KICAgICAgICBjID0gMDsKICAgICAgfQogICAgICBwID0gMDsKICAgIH0KICAgIHRocm93IG5ldyBKcHhFcnJvcigiT3V0IG9mIHBhY2tldHMiKTsKICB9Owp9CmZ1bmN0aW9uIFBvc2l0aW9uQ29tcG9uZW50UmVzb2x1dGlvbkxheWVySXRlcmF0b3IoY29udGV4dCkgewogIGNvbnN0IHNpeiA9IGNvbnRleHQuU0laOwogIGNvbnN0IHRpbGVJbmRleCA9IGNvbnRleHQuY3VycmVudFRpbGUuaW5kZXg7CiAgY29uc3QgdGlsZSA9IGNvbnRleHQudGlsZXNbdGlsZUluZGV4XTsKICBjb25zdCBsYXllcnNDb3VudCA9IHRpbGUuY29kaW5nU3R5bGVEZWZhdWx0UGFyYW1ldGVycy5sYXllcnNDb3VudDsKICBjb25zdCBjb21wb25lbnRzQ291bnQgPSBzaXouQ3NpejsKICBjb25zdCBwcmVjaW5jdHNTaXplcyA9IGdldFByZWNpbmN0U2l6ZXNJbkltYWdlU2NhbGUodGlsZSk7CiAgY29uc3QgcHJlY2luY3RzSXRlcmF0aW9uU2l6ZXMgPSBwcmVjaW5jdHNTaXplczsKICBsZXQgbCA9IDAsCiAgICByID0gMCwKICAgIGMgPSAwLAogICAgcHggPSAwLAogICAgcHkgPSAwOwogIHRoaXMubmV4dFBhY2tldCA9IGZ1bmN0aW9uIEpweEltYWdlX25leHRQYWNrZXQoKSB7CiAgICBmb3IgKDsgcHkgPCBwcmVjaW5jdHNJdGVyYXRpb25TaXplcy5tYXhOdW1IaWdoOyBweSsrKSB7CiAgICAgIGZvciAoOyBweCA8IHByZWNpbmN0c0l0ZXJhdGlvblNpemVzLm1heE51bVdpZGU7IHB4KyspIHsKICAgICAgICBmb3IgKDsgYyA8IGNvbXBvbmVudHNDb3VudDsgYysrKSB7CiAgICAgICAgICBjb25zdCBjb21wb25lbnQgPSB0aWxlLmNvbXBvbmVudHNbY107CiAgICAgICAgICBjb25zdCBkZWNvbXBvc2l0aW9uTGV2ZWxzQ291bnQgPSBjb21wb25lbnQuY29kaW5nU3R5bGVQYXJhbWV0ZXJzLmRlY29tcG9zaXRpb25MZXZlbHNDb3VudDsKICAgICAgICAgIGZvciAoOyByIDw9IGRlY29tcG9zaXRpb25MZXZlbHNDb3VudDsgcisrKSB7CiAgICAgICAgICAgIGNvbnN0IHJlc29sdXRpb24gPSBjb21wb25lbnQucmVzb2x1dGlvbnNbcl07CiAgICAgICAgICAgIGNvbnN0IHNpemVJbkltYWdlU2NhbGUgPSBwcmVjaW5jdHNTaXplcy5jb21wb25lbnRzW2NdLnJlc29sdXRpb25zW3JdOwogICAgICAgICAgICBjb25zdCBrID0gZ2V0UHJlY2luY3RJbmRleElmRXhpc3QocHgsIHB5LCBzaXplSW5JbWFnZVNjYWxlLCBwcmVjaW5jdHNJdGVyYXRpb25TaXplcywgcmVzb2x1dGlvbik7CiAgICAgICAgICAgIGlmIChrID09PSBudWxsKSB7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZm9yICg7IGwgPCBsYXllcnNDb3VudDspIHsKICAgICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgaywgbCk7CiAgICAgICAgICAgICAgbCsrOwogICAgICAgICAgICAgIHJldHVybiBwYWNrZXQ7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbCA9IDA7CiAgICAgICAgICB9CiAgICAgICAgICByID0gMDsKICAgICAgICB9CiAgICAgICAgYyA9IDA7CiAgICAgIH0KICAgICAgcHggPSAwOwogICAgfQogICAgdGhyb3cgbmV3IEpweEVycm9yKCJPdXQgb2YgcGFja2V0cyIpOwogIH07Cn0KZnVuY3Rpb24gQ29tcG9uZW50UG9zaXRpb25SZXNvbHV0aW9uTGF5ZXJJdGVyYXRvcihjb250ZXh0KSB7CiAgY29uc3Qgc2l6ID0gY29udGV4dC5TSVo7CiAgY29uc3QgdGlsZUluZGV4ID0gY29udGV4dC5jdXJyZW50VGlsZS5pbmRleDsKICBjb25zdCB0aWxlID0gY29udGV4dC50aWxlc1t0aWxlSW5kZXhdOwogIGNvbnN0IGxheWVyc0NvdW50ID0gdGlsZS5jb2RpbmdTdHlsZURlZmF1bHRQYXJhbWV0ZXJzLmxheWVyc0NvdW50OwogIGNvbnN0IGNvbXBvbmVudHNDb3VudCA9IHNpei5Dc2l6OwogIGNvbnN0IHByZWNpbmN0c1NpemVzID0gZ2V0UHJlY2luY3RTaXplc0luSW1hZ2VTY2FsZSh0aWxlKTsKICBsZXQgbCA9IDAsCiAgICByID0gMCwKICAgIGMgPSAwLAogICAgcHggPSAwLAogICAgcHkgPSAwOwogIHRoaXMubmV4dFBhY2tldCA9IGZ1bmN0aW9uIEpweEltYWdlX25leHRQYWNrZXQoKSB7CiAgICBmb3IgKDsgYyA8IGNvbXBvbmVudHNDb3VudDsgKytjKSB7CiAgICAgIGNvbnN0IGNvbXBvbmVudCA9IHRpbGUuY29tcG9uZW50c1tjXTsKICAgICAgY29uc3QgcHJlY2luY3RzSXRlcmF0aW9uU2l6ZXMgPSBwcmVjaW5jdHNTaXplcy5jb21wb25lbnRzW2NdOwogICAgICBjb25zdCBkZWNvbXBvc2l0aW9uTGV2ZWxzQ291bnQgPSBjb21wb25lbnQuY29kaW5nU3R5bGVQYXJhbWV0ZXJzLmRlY29tcG9zaXRpb25MZXZlbHNDb3VudDsKICAgICAgZm9yICg7IHB5IDwgcHJlY2luY3RzSXRlcmF0aW9uU2l6ZXMubWF4TnVtSGlnaDsgcHkrKykgewogICAgICAgIGZvciAoOyBweCA8IHByZWNpbmN0c0l0ZXJhdGlvblNpemVzLm1heE51bVdpZGU7IHB4KyspIHsKICAgICAgICAgIGZvciAoOyByIDw9IGRlY29tcG9zaXRpb25MZXZlbHNDb3VudDsgcisrKSB7CiAgICAgICAgICAgIGNvbnN0IHJlc29sdXRpb24gPSBjb21wb25lbnQucmVzb2x1dGlvbnNbcl07CiAgICAgICAgICAgIGNvbnN0IHNpemVJbkltYWdlU2NhbGUgPSBwcmVjaW5jdHNJdGVyYXRpb25TaXplcy5yZXNvbHV0aW9uc1tyXTsKICAgICAgICAgICAgY29uc3QgayA9IGdldFByZWNpbmN0SW5kZXhJZkV4aXN0KHB4LCBweSwgc2l6ZUluSW1hZ2VTY2FsZSwgcHJlY2luY3RzSXRlcmF0aW9uU2l6ZXMsIHJlc29sdXRpb24pOwogICAgICAgICAgICBpZiAoayA9PT0gbnVsbCkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZvciAoOyBsIDwgbGF5ZXJzQ291bnQ7KSB7CiAgICAgICAgICAgICAgY29uc3QgcGFja2V0ID0gY3JlYXRlUGFja2V0KHJlc29sdXRpb24sIGssIGwpOwogICAgICAgICAgICAgIGwrKzsKICAgICAgICAgICAgICByZXR1cm4gcGFja2V0OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGwgPSAwOwogICAgICAgICAgfQogICAgICAgICAgciA9IDA7CiAgICAgICAgfQogICAgICAgIHB4ID0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b21wb25lbnQgPSBuZXcgQXJyYXkoY29tcG9uZW50c0NvdW50KTsKICBmb3IgKGxldCBjID0gMDsgYyA8IGNvbXBvbmVudHNDb3VudDsgYysrKSB7CiAgICBjb25zdCBjb21wb25lbnQgPSB0aWxlLmNvbXBvbmVudHNbY107CiAgICBjb25zdCBkZWNvbXBvc2l0aW9uTGV2ZWxzQ291bnQgPSBjb21wb25lbnQuY29kaW5nU3R5bGVQYXJhbWV0ZXJzLmRlY29tcG9zaXRpb25MZXZlbHNDb3VudDsKICAgIGNvbnN0IHNpemVQZXJSZXNvbHV0aW9uID0gbmV3IEFycmF5KGRlY29tcG9zaXRpb25MZXZlbHNDb3VudCArIDEpOwogICAgbGV0IG1pbldpZHRoQ3VycmVudENvbXBvbmVudCA9IE51bWJlci5NQVhfVkFMVUU7CiAgICBsZXQgbWluSGVpZ2h0Q3VycmVudENvbXBvbmVudCA9IE51bWJlci5NQVhfVkFMVUU7CiAgICBsZXQgbWF4TnVtV2lkZUN1cnJlbnRDb21wb25lbnQgPSAwOwogICAgbGV0IG1heE51bUhpZ2hDdXJyZW50Q29tcG9uZW50ID0gMDsKICAgIGxldCBzY2FsZSA9IDE7CiAgICBmb3IgKGxldCByID0gZGVjb21wb3NpdGlvbkxldmVsc0NvdW50OyByID49IDA7IC0tcikgewogICAgICBjb25zdCByZXNvbHV0aW9uID0gY29tcG9uZW50LnJlc29sdXRpb25zW3JdOwogICAgICBjb25zdCB3aWR0aEN1cnJlbnRSZXNvbHV0aW9uID0gc2NhbGUgKiByZXNvbHV0aW9uLnByZWNpbmN0UGFyYW1ldGVycy5wcmVjaW5jdFdpZHRoOwogICAgICBjb25zdCBoZWlnaHRDdXJyZW50UmVzb2x1dGlvbiA9IHNjYWxlICogcmVzb2x1dGlvbi5wcmVjaW5jdFBhcmFtZXRlcnMucHJlY2luY3RIZWlnaHQ7CiAgICAgIG1pbldpZHRoQ3VycmVudENvbXBvbmVudCA9IE1hdGgubWluKG1pbldpZHRoQ3VycmV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JbmNsdWRlZCA9ICEhcmVhZEJpdHMoMSk7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcHJlY2luY3QgPSBjb2RlYmxvY2sucHJlY2luY3Q7CiAgICAgICAgbGV0IGluY2x1c2lvblRyZWU7CiAgICAgICAgaWYgKHByZWNpbmN0LmluY2x1c2lvblRyZWUgIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgaW5jbHVzaW9uVHJlZSA9IHByZWNpbmN0LmluY2x1c2lvblRyZWU7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGNvbnN0IHdpZHRoID0gcHJlY2luY3QuY2J4TWF4IC0gcHJlY2luY3QuY2J4TWluICsgMTsKICAgICAgICAgIGNvbnN0IGhlaWdodCA9IHByZWNpbmN0LmNieU1heCAtIHByZWNpbmN0LmNieU1pbiArIDE7CiAgICAgICAgICBpbmNsdXNpb25UcmVlID0gbmV3IEluY2x1c2lvblRyZWUod2lkdGgsIGhlaWdodCwgbGF5ZXJOdW1iZXIpOwogICAgICAgICAgemVyb0JpdFBsYW5lc1RyZWUgPSBuZXcgVGFnVHJlZSh3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgIHByZWNpbmN0LmluY2x1c2lvblRyZWUgPSBpbmNsdXNpb25UcmVlOwogICAgICAgICAgcHJlY2luY3QuemVyb0JpdFBsYW5lc1RyZWUgPSB6ZXJvQml0UGxhbmVzVHJlZTsKICAgICAgICAgIGZvciAobGV0IGwgPSAwOyBsIDwgbGF5ZXJOdW1iZXI7IGwrKykgewogICAgICAgICAgICBpZiAocmVhZEJpdHMoMSkgIT09IDApIHsKICAgICAgICAgICAgICB0aHJvdyBuZXcgSnB4RXJyb3IoIkludmFsaWQgdGFnIHRyZWUiKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoaW5jbHVzaW9uVHJlZS5yZXNldChjb2RlYmxvY2tDb2x1bW4sIGNvZGVibG9ja1JvdywgbGF5ZXJOdW1iZXIpKSB7CiAgICAgICAgICB3aGlsZSAodHJ1ZSkgewogICAgICAgICAgICBpZiAocmVhZEJpdHMoMSkpIHsKICAgICAgICAgICAgICB2YWx1ZVJlYWR5ID0gIWluY2x1c2lvblRyZWUubmV4dExldmVsKCk7CiAgICAgICAgICAgICAgaWYgKHZhbHVlUmVhZHkpIHsKICAgICAgICAgICAgICAgIGNvZGVibG9jay5pbmNsdWRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICBjb2RlYmxvY2tJbmNsdWRlZCA9IGZpcnN0VGltZUluY2x1c2lvbiA9IHRydWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgaW5jbHVzaW9uVHJlZS5pbmNyZW1lbnRWYWx1ZShsYXllck51bWJlcik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCFjb2RlYmxvY2tJbmNsdWRlZCkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmIChmaXJzdFRpbWVJbmNsdXNpb24pIHsKICAgICAgICB6ZXJvQml0UGxhbmVzVHJlZSA9IHByZWNpbmN0Lnplcm9CaXRQbGFuZXNUcmVlOwogICAgICAgIHplcm9CaXRQbGFuZXNUcmVlLnJlc2V0KGNvZGVibG9ja0NvbHVtbiwgY29kZWJsb2NrUm93KTsKICAgICAgICB3aGlsZSAodHJ1ZSkgewogICAgICAgICAgaWYgKHJlYWRCaXRzKDEpKSB7CiAgICAgICAgICAgIHZhbHVlUmVhZHkgPSAhemVyb0JpdFBsYW5lc1RyZWUubmV4dExldmVsKCk7CiAgICAgICAgICAgIGlmICh2YWx1ZVJlYWR5KSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHplcm9CaXRQbGFuZXNUcmVlLmluY3JlbWVudFZhbHVlKCk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGNvZGVibG9jay56ZXJvQml0UGxhbmVzID0gemVyb0JpdFBsYW5lc1RyZWUudmFsdWU7CiAgICAgIH0KICAgICAgY29uc3QgY29kaW5ncGFzc2VzID0gcmVhZENvZGluZ3Bhc3NlcygpOwogICAgICB3aGlsZSAocmVhZEJpdHMoMSkpIHsKICAgICAgICBjb2RlYmxvY2suTGJsb2NrKys7CiAgICAgIH0KICAgICAgY29uc3QgY29kaW5ncGFzc2VzTG9nMiA9ICgwLCBfY29yZV91dGlscy5sb2cyKShjb2RpbmdwYXNzZXMpOwogICAgICBjb25zdCBiaXRzID0gKGNvZGluZ3Bhc3NlcyA8IDEgPDwgY29kaW5ncGFzc2VzTG9nMiA/IGNvZGluZ3Bhc3Nlc0xvZzIgLSAxIDogY29kaW5ncGFzc2VzTG9nMikgKyBjb2RlYmxvY2suTGJsb2NrOwogICAgICBjb25zdCBjb2RlZERhdGFMZW5ndGggPSByZWFkQml0cyhiaXRzKTsKICAgICAgcXVldWUucHVzaCh7CiAgICAgICAgY29kZWJsb2NrLAogICAgICAgIGNvZGluZ3Bhc3NlcywKICAgICAgICBkYXRhTGVuZ3RoOiBjb2RlZERhdGFMZW5ndGgKICAgICAgfSk7CiAgICB9CiAgICBhbGlnblRvQnl0ZSgpOwogICAgaWYgKGVwaE1hcmtlclVzZWQpIHsKICAgICAgc2tpcE1hcmtlcklmRXF1YWwoMHg5Mik7CiAgICB9CiAgICB3aGlsZSAocXVldWUubGVuZ3RoID4gMCkgewogICAgICBjb25zdCBwYWNrZXRJdGVtID0gcXVldWUuc2hpZnQoKTsKICAgICAgY29kZWJsb2NrID0gcGFja2V0SXRlbS5jb2RlYmxvY2s7CiAgICAgIGlmIChjb2RlYmxvY2suZGF0YSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgY29kZWJsb2NrLmRhdGEgPSBbXTsKICAgICAgfQogICAgICBjb2RlYmxvY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5kKTsKICAgICAgZW5jb2RlZERhdGEuc2V0KGNodW5rLCBwb3NpdGlvbik7CiAgICAgIHBvc2l0aW9uICs9IGNodW5rLmxlbmd0aDsKICAgIH0KICAgIGNvbnN0IGRlY29kZXIgPSBuZXcgX2FyaXRobWV0aWNfZGVjb2Rlci5Bcml0aG1ldGljRGVjb2RlcihlbmNvZGVkRGF0YSwgMCwgdG90YWxMZW5ndGgpOwogICAgYml0TW9kZWwuc2V0RGVjb2RlcihkZWNvZGVyKTsKICAgIGZvciAoaiA9IDA7IGogPCBjb2RpbmdwYXNzZXM7IGorKykgewogICAgICBzd2l0Y2ggKGN1cnJlbnRDb2RpbmdwYXNzVHlwZSkgewogICAgICAgIGNhc2UgMDoKICAgICAgICAgIGJpdE1vZGVsLnJ1blNpZ25pZmljYW5jZVByb3BhZ2F0aW9uUGFzcygpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAxOgogICAgICAgICAgYml0TW9kZWwucnVuTWFnbml0dWRlUmVmaW5lbWVudFBhc3MoKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjoKICAgICAgICAgIGJpdE1vZGVsLnJ1bkNsZWFudXBQYXNzKCk7CiAgICAgICAgICBpZiAoc2VnbWVudGF0aW9uU3ltYm9sVXNlZCkgewogICAgICAgICAgICBiaXRNb2RlbC5jaGVja1NlZ21lbnRhdGlvblN5bWJvbCgpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKHJlc2V0Q29udGV4dFByb2JhYmlsaXRpZXMpIHsKICAgICAgICBiaXRNb2RlbC5yZXNldCgpOwogICAgICB9CiAgICAgIGN1cnJlbnRDb2RpbmdwYXNzVHlwZSA9IChjdXJyZW50Q29kaW5ncGFzc1R5cGUgKyAxKSAlIDM7CiAgICB9CiAgICBsZXQgb2Zmc2V0ID0gY29kZWJsb2NrLnRieDBfIC0geDAgKyAoY29kZWJsb2NrLnRieTBfIC0geTApICogd2lkdGg7CiAgICBjb25zdCBzaWduID0gYml0TW9kZWwuY29lZmZpY2VudHNTaWduOwogICAgY29uc3QgbWFnbml0dWRlID0gYml0TW9kZWwuY29lZmZpY2VudHNNYWduaXR1ZGU7CiAgICBjb25zdCBiaXRzRGVjb2RlZCA9IGJpdE1vZGVsLmJpdHNEZWNvZGVkOwogICAgY29uc3QgbWFnbml0dWRlQ29ycmVjdGlvbiA9IHJldmVyc2libGUgPyAwIDogMC41OwogICAgbGV0IGssIG4sIG5iOwogICAgcG9zaXRpb24gPSAwOwogICAgY29uc3QgaW50ZXJsZWF2ZSA9IHN1YmJhbmQudHlwZSAhPT0gIkxMIjsKICAgIGZvciAoaiA9IDA7IGogPCBibG9ja0hlaWdodDsgaisrKSB7CiAgICAgIGNvbnN0IHJvdyA9IG9mZnNldCAvIHdpZHRoIHwgMDsKICAgICAgY29uc3QgbGV2ZWxPZmZzZXQgPSAyICogcm93ICogKGxldmVsV2lkdGggLSB3aWR0aCkgKyByaWdodCArIGJvdHRvbTsKICAgICAgZm9yIChrID0gMDsgayA8IGJsb2NrV2lkdGg7IGsrKykgewogICAgICAgIG4gPSBtYWduaXR1ZGVbcG9zaXRpb25dOwogICAgICAgIGlmIChuICE9PSAwKSB7CiAgICAgICAgICBuID0gKG4gKyBtYWduaXR1ZGVDb3JyZWN0aW9uKSAqIGRlbHRhOwogICAgICAgICAgaWYgKHNpZ25bcG9zaXRpb25dICE9PSAwKSB7CiAgICAgICAgICAgIG4gPSAtbjsKICAgICAgICAgIH0KICAgICAgICAgIG5iID0gYml0c0RlY29kZWRbcG9zaXRpb25dOwogICAgICAgICAgY29uc3QgcG9zID0gaW50ZXJsZWF2ZSA/IGxldmVsT2Zmc2V0ICsgKG9mZnNldCA8PCAxKSA6IG9mZnNldDsKICAgICAgICAgIGlmIChyZXZlcnNpYmxlICYmIG5iID49IG1iKSB7CiAgICAgICAgICAgIGNvZWZmaWNpZW50c1twb3NdID0gbjsKICAgICAgICAgIH0gZWxzZSB7CiA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ICAgICAgeTIgPSB5Mml0ZW1zW2pdOwogICAgICAgICAgY29uc3QgZyA9IHkwIC0gKHkyICsgeTEgPj4gMik7CiAgICAgICAgICBvdXRbcG9zKytdID0gZyArIHkyID4+IHNoaWZ0OwogICAgICAgICAgb3V0W3BvcysrXSA9IGcgPj4gc2hpZnQ7CiAgICAgICAgICBvdXRbcG9zKytdID0gZyArIHkxID4+IHNoaWZ0OwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoZm91ckNvbXBvbmVudHMpIHsKICAgICAgICBmb3IgKGogPSAwLCBwb3MgPSAzOyBqIDwgamo7IGorKywgcG9zICs9IDQpIHsKICAgICAgICAgIG91dFtwb3NdID0geTNpdGVtc1tqXSArIG9mZnNldCA+PiBzaGlmdDsKICAgICAgICB9CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGZvciAobGV0IGMgPSAwOyBjIDwgY29tcG9uZW50c0NvdW50OyBjKyspIHsKICAgICAgICBjb25zdCBpdGVtcyA9IHRyYW5zZm9ybWVkVGlsZXNbY10uaXRlbXM7CiAgICAgICAgc2hpZnQgPSBjb21wb25lbnRzW2NdLnByZWNpc2lvbiAtIDg7CiAgICAgICAgb2Zmc2V0ID0gKDEyOCA8PCBzaGlmdCkgKyAwLjU7CiAgICAgICAgZm9yIChwb3MgPSBjLCBqID0gMCwgamogPSBpdGVtcy5sZW5ndGg7IGogPCBqajsgaisrKSB7CiAgICAgICAgICBvdXRbcG9zXSA9IGl0ZW1zW2pdICsgb2Zmc2V0ID4+IHNoaWZ0OwogICAgICAgICAgcG9zICs9IGNvbXBvbmVudHNDb3VudDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJlc3VsdEltYWdlcy5wdXNoKHJlc3VsdCk7CiAgfQogIHJldHVybiByZXN1bHRJbWFnZXM7Cn0KZnVuY3Rpb24gaW5pdGlhbGl6ZVRpbGUoY29udGV4dCwgdGlsZUluZGV4KSB7CiAgY29uc3Qgc2l6ID0gY29udGV4dC5TSVo7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ogICAgICB9OwogICAgICB0aGlzLmxldmVscy5wdXNoKGxldmVsKTsKICAgICAgd2lkdGggPSBNYXRoLmNlaWwod2lkdGggLyAyKTsKICAgICAgaGVpZ2h0ID0gTWF0aC5jZWlsKGhlaWdodCAvIDIpOwogICAgfQogIH0KICByZXNldChpLCBqKSB7CiAgICBsZXQgY3VycmVudExldmVsID0gMCwKICAgICAgdmFsdWUgPSAwLAogICAgICBsZXZlbDsKICAgIHdoaWxlIChjdXJyZW50TGV2ZWwgPCB0aGlzLmxldmVscy5sZW5ndGgpIHsKICAgICAgbGV2ZWwgPSB0aGlzLmxldmVsc1tjdXJyZW50TGV2ZWxdOwogICAgICBjb25zdCBpbmRleCA9IGkgKyBqICogbGV2ZWwud2lkdGg7CiAgICAgIGlmIChsZXZlbC5pdGVtc1tpbmRleF0gIT09IHVuZGVmaW5lZCkgewogICAgICAgIHZhbHVlID0gbGV2ZWwuaXRlbXNbaW5kZXhdOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGxldmVsLmluZGV4ID0gaW5kZXg7CiAgICAgIGkgPj49IDE7CiAgICAgIGogPj49IDE7CiAgICAgIGN1cnJlbnRMZXZlbCsrOwogICAgfQogICAgY3VycmVudExldmVsLS07CiAgICBsZXZlbCA9IHRoaXMubGV2ZWxzW2N1cnJlbnRMZXZlbF07CiAgICBsZXZlbC5pdGVtc1tsZXZlbC5pbmRleF0gPSB2YWx1ZTsKICAgIHRoaXMuY3VycmVudExldmVsID0gY3VycmVudExldmVsOwogICAgZGVsZXRlIHRoaXMudmFsdWU7CiAgfQogIGluY3JlbWVudFZhbHVlKCkgewogICAgY29uc3QgbGV2ZWwgPSB0aGlzLmxldmVsc1t0aGlzLmN1cnJlbnRMZXZlbF07CiAgICBsZXZlbC5pdGVtc1tsZXZlbC5pbmRleF0rKzsKICB9CiAgbmV4dExldmVsKCkgewogICAgbGV0IGN1cnJlbnRMZXZlbCA9IHRoaXMuY3VycmVudExldmVsOwogICAgbGV0IGxldmVs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odCA9IGhlaWdodDsKICAgICAgbGV0IGNvbnRleHRMYWJlbFRhYmxlOwogICAgICBpZiAoc3ViYmFuZCA9PT0gIkhIIikgewogICAgICAgIGNvbnRleHRMYWJlbFRhYmxlID0gSEhDb250ZXh0TGFiZWw7CiAgICAgIH0gZWxzZSBpZiAoc3ViYmFuZCA9PT0gIkhMIikgewogICAgICAgIGNvbnRleHRMYWJlbFRhYmxlID0gSExDb250ZXh0TGFiZWw7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29udGV4dExhYmVsVGFibGUgPSBMTEFuZExIQ29udGV4dHNMYWJlbDsKICAgICAgfQogICAgICB0aGlzLmNvbnRleHRMYWJlbFRhYmxlID0gY29udGV4dExhYmVsVGFibGU7CiAgICAgIGNvbnN0IGNvZWZmaWNpZW50Q291bnQgPSB3aWR0aCAqIGhlaWdodDsKICAgICAgdGhpcy5uZWlnaGJvcnNTaWduaWZpY2FuY2UgPSBuZXcgVWludDhBcnJheShjb2VmZmljaWVudENvdW50KTsKICAgICAgdGhpcy5jb2VmZmljZW50c1NpZ24gPSBuZXcgVWludDhBcnJheShjb2VmZmljaWVudENvdW50KTsKICAgICAgbGV0IGNvZWZmaWNlbnRzTWFnbml0dWRlOwogICAgICBpZiAobWIgPiAxNCkgewogICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlID0gbmV3IFVpbnQzMkFycmF5KGNvZWZmaWNpZW50Q291bnQpOwogICAgICB9IGVsc2UgaWYgKG1iID4gNikgewogICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlID0gbmV3IFVpbnQxNkFycmF5KGNvZWZmaWNpZW50Q291bnQpOwogICAgICB9IGVsc2UgewogICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlID0gbmV3IFVpbnQ4QXJyYXkoY29lZmZpY2llbnRDb3VudCk7CiAgICAgIH0KICAgICAgdGhpcy5jb2VmZmljZW50c01hZ25pdHVkZSA9IGNvZWZmaWNlbnRzTWFnbml0dWRlOwogICAgICB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OwogICAgICBsZXQgaTsKICAgICAgaWYgKHJvdyA+IDApIHsKICAgICAgICBpID0gaW5kZXggLSB3aWR0aDsKICAgICAgICBpZiAobGVmdCkgewogICAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2kgLSAxXSArPSAweDEwOwogICAgICAgIH0KICAgICAgICBpZiAocmlnaHQpIHsKICAgICAgICAgIG5laWdoYm9yc1NpZ25pZmljYW5jZVtpICsgMV0gKz0gMHgxMDsKICAgICAgICB9CiAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2ldICs9IDB4MDQ7CiAgICAgIH0KICAgICAgaWYgKHJvdyArIDEgPCBoZWlnaHQpIHsKICAgICAgICBpID0gaW5kZXggKyB3aWR0aDsKICAgICAgICBpZiAobGVmdCkgewogICAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2kgLSAxXSArPSAweDEwOwogICAgICAgIH0KICAgICAgICBpZiAocmlnaHQpIHsKICAgICAgICAgIG5laWdoYm9yc1NpZ25pZmljYW5jZVtpICsgMV0gKz0gMHgxMDsKICAgICAgICB9CiAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2ldICs9IDB4MDQ7CiAgICAgIH0KICAgICAgaWYgKGxlZnQpIHsKICAgICAgICBuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXggLSAxXSArPSAweDAxOwogICAgICB9CiAgICAgIGlmIChyaWdodCkgewogICAgICAgIG5laWdoYm9yc1NpZ25pZmljYW5jZVtpbmRleCArIDFdICs9IDB4MDE7CiAgICAgIH0KICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2luZGV4XSB8PSAweDgwOwogICAgfQogICAgcnVuU2lnbmlmaWNhbmNlUHJvcGFnYXRpb25QYXNzKCkgewogICAgICBjb25zdCBkZWNvZGVyID0gdGhpcy5kZWNvZGVyOwogICAgICBjb25zdCB3aWR0aCA9IHRoaXMud2lkdGgsCiAgICAgICAgaGVpZ2h0ID0gd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ZmaWNlbnRzTWFnbml0dWRlW2luZGV4XSB8fCAhbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2luZGV4XSkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGNvbnRleHRMYWJlbCA9IGxhYmVsc1tuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXhdXTsKICAgICAgICAgICAgY29uc3QgZGVjaXNpb24gPSBkZWNvZGVyLnJlYWRCaXQoY29udGV4dHMsIGNvbnRleHRMYWJlbCk7CiAgICAgICAgICAgIGlmIChkZWNpc2lvbikgewogICAgICAgICAgICAgIGNvbnN0IHNpZ24gPSB0aGlzLmRlY29kZVNpZ25CaXQoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICAgIGNvZWZmaWNlbnRzU2lnbltpbmRleF0gPSBzaWduOwogICAgICAgICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlW2luZGV4XSA9IDE7CiAgICAgICAgICAgICAgdGhpcy5zZXROZWlnaGJvcnNTaWduaWZpY2FuY2UoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICAgIHByb2Nlc3NpbmdGbGFnc1tpbmRleF0gfD0gZmlyc3RNYWduaXR1ZGVCaXRNYXNrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJpdHNEZWNvZGVkW2luZGV4XSsrOwogICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIHw9IHByb2Nlc3NlZE1hc2s7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBkZWNvZGVTaWduQml0KHJvdywgY29sdW1uLCBpbmRleCkgewogICAgICBjb25zdCB3aWR0aCA9IHRoaXMud2lkdGgsCiAgICAgICAgaGVpZ2h0ID0gdGhpcy5oZWlnaHQ7CiAgICAgIGNvbnN0IGNvZWZmaWNlbnRzTWFnbml0dWRlID0gdGhpcy5jb2VmZmljZW50c01hZ25pdHVkZTsKICAgICAgY29uc3QgY29lZmZpY2VudHNTaWduID0gdGhpcy5jb2VmZmljZW50c1NpZ247CiAgICAgIGxldCBjb250cmlidXRpb24sIHNpZ24wLCBzaWduMSwgc2lnbmlmaWNhbmNlMTsKICAgICAgbGV0IGNvbnRleHRMYWJlbCwgZGVjb2RlZDsKICAgICAgc2lnbmlmaWNhbmNlMSA9IGNvbHVtbiA+IDAgJiYgY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXggLSAxXSAhPT0gMDsKICAgICAgaWYgKGNvbHVtbiArIDEgPCB3aWR0aCAmJiBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleCArIDFdICE9PSAwKSB7CiAgICAgICAgc2lnbjEgPSBjb2VmZmljZW50c1NpZ25baW5kZXggKyAxXTsKICAgICAgICBpZiAoc2lnbmlmaWNhbmNlMSkgewogICAgICAgICAgc2lnbjAgPSBjb2VmZmljZW50c1NpZ25baW5kZXggLSAxXTsKICAgICAgICAgIGNvbnRyaWJ1dGlvbiA9IDEgLSBzaWduMSAtIHNpZ24wOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb250cmlidXRpb24gPSAxIC0gc2lnbjEgLSBzaWduMTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoc2lnbmlmaWNhbmNlMSkgewogICAgICAgIHNpZ24wID0gY29lZmZpY2VudHNTaWduW2luZGV4IC0gMV07CiAgICAgICAgY29udHJpYnV0aW9uID0gMSAtIHNpZ24wIC0gc2lnbjA7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29udHJpYnV0aW9uID0gMDsKICAgICAgfQogICAgICBjb25zdCBob3Jpem9udGFsQ29udHJpYnV0aW9uID0gMyAqIGNvbnRyaWJ1dGlvbjsKICAgICAgc2lnbmlmaWNhbmNlMSA9IHJvdyA+IDAgJiYgY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXggLSB3aWR0aF0gIT09IDA7CiAgICAgIGlmIChyb3cgKyAxIDwgaGVpZ2h0ICYmIGNvZWZmaWNlbnRzTWFnbml0dWRlW2luZGV4ICsgd2lkdGhdICE9PSAwKSB7CiAgICAgICAgc2lnbjEgPSBjb2VmZmljZW50c1NpZ25baW5kZXggKyB3aWR0aF07CiAgICAgICAgaWYgKHNpZ25pZmljYW5jZTEpIHsKICAgICAgICAgIHNpZ24wID0gY29lZmZpY2VudHNTaWduW2luZGV4IC0gd2lkdGhdOwogICAgICAgICAgY29udHJpYnV0aW9uID0gMSAtIHNpZ24xIC0gc2lnbjAgKyBob3Jpem9udGFsQ29udHJpYnV0aW9uOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb250cmlidXRpb24gPSAxIC0gc2lnbjEgLSBzaWduMSArIGhvcml6b250YWxDb250cmlidXRpb247CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKHNpZ25pZmljYW5jZTEpIHsKICAgICAgICBzaWduMCA9IGNvZWZmaWNlbnRzU2lnbltpbmRleCAtIHdpZHRoXTsKICAgICAgICBjb250cmlidXRpb24gPSAxIC0gc2lnbjAgLSBzaWduMCArIGhvcml6b250YWxDb250cmlidXRpb247CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29udHJpYnV0aW9uID0gaG9yaXpvbnRhbENvbnRyaWJ1dGlvbjsKICAgICAgfQogICAgICBpZiAoY29udHJpYnV0aW9uID49IDApIHsKICAgICAgICBjb250ZXh0TGFiZWwgPSA5ICsgY29udHJpYnV0aW9uOwogICAgICAgIGRlY29kZWQgPSB0aGlzLmRlY29kZXIucmVhZEJpdCh0aGlzLmNvbnRleHRzLCBjb250ZXh0TGFiZWwpOwogICAgICB9IGVsc2UgewogICAgICAgIGNvbnRleHRMYWJlbCA9IDkgLSBjb250cmlidXRpb247CiAgICAgICAgZGVjb2RlZCA9IHRoaXMuZGVjb2Rlci5yZWFkQml0KHRoaXMuY29udGV4dHMsIGNvbnRleHRMYWJlbCkgXiAxOwogICAgICB9CiAgICAgIHJldHVybiBkZWNvZGVkOwogICAgfQogICAgcnVuTWFnbml0dWRl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hdICYgcHJvY2Vzc2VkTWFzaykgIT09IDApIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgY29udGV4dExhYmVsID0gMTY7CiAgICAgICAgICAgIGlmICgocHJvY2Vzc2luZ0ZsYWdzW2luZGV4XSAmIGZpcnN0TWFnbml0dWRlQml0TWFzaykgIT09IDApIHsKICAgICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIF49IGZpcnN0TWFnbml0dWRlQml0TWFzazsKICAgICAgICAgICAgICBjb25zdCBzaWduaWZpY2FuY2UgPSBuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXhdICYgMTI3OwogICAgICAgICAgICAgIGNvbnRleHRMYWJlbCA9IHNpZ25pZmljYW5jZSA9PT0gMCA/IDE1IDogMTQ7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29uc3QgYml0ID0gZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBjb250ZXh0TGFiZWwpOwogICAgICAgICAgICBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleF0gPSBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleF0gPDwgMSB8IGJpdDsKICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXhdKys7CiAgICAgICAgICAgIHByb2Nlc3NpbmdGbGFnc1tpbmRleF0gfD0gcHJvY2Vzc2VkTWFzazsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIHJ1bkNsZWFudXBQYXNzKCkgewogICAgICBjb25zdCBkZWNvZGVyID0gdGhpcy5kZWNvZGVyOwogICAgICBjb25zdCB3aWR0aCA9IHRoaXMud2lkdGgsCiAgICAgICAgaGVpZ2h0ID0gdGhpcy5oZWlnaHQ7CiAgICAgIGNvbnN0IG5laWdoYm9yc1NpZ25pZmljYW5jZSA9IHRoaXMubmVpZ2hib3JzU2lnbmlmaWNhbmNlOwogICAgICBjb25zdCBjb2VmZmljZW50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Eb3duXSA9PT0gMCAmJiBwcm9jZXNzaW5nRmxhZ3NbaW5kZXgwICsgdHdvUm93c0Rvd25dID09PSAwICYmIHByb2Nlc3NpbmdGbGFnc1tpbmRleDAgKyB0aHJlZVJvd3NEb3duXSA9PT0gMCAmJiBuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXgwXSA9PT0gMCAmJiBuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXgwICsgb25lUm93RG93bl0gPT09IDAgJiYgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2luZGV4MCArIHR3b1Jvd3NEb3duXSA9PT0gMCAmJiBuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXgwICsgdGhyZWVSb3dzRG93bl0gPT09IDA7CiAgICAgICAgICBsZXQgaTEgPSAwLAogICAgICAgICAgICBpbmRleCA9IGluZGV4MDsKICAgICAgICAgIGxldCBpID0gaTAsCiAgICAgICAgICAgIHNpZ247CiAgICAgICAgICBpZiAoYWxsRW1wdHkpIHsKICAgICAgICAgICAgY29uc3QgaGFzU2lnbmlmaWNhbnRDb2VmZmljZW50ID0gZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBSVU5MRU5HVEhfQ09OVEVYVCk7CiAgICAgICAgICAgIGlmICghaGFzU2lnbmlmaWNhbnRDb2VmZmljZW50KSB7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXgwXSsrOwogICAgICAgICAgICAgIGJpdHNEZWNvZGVkW2luZGV4MCArIG9uZVJvd0Rvd25dKys7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXgwICsgdHdvUm93c0Rvd25dKys7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXgwICsgdGhyZWVSb3dzRG93bl0rKzsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpMSA9IGRlY29kZXIucmVhZEJpdChjb250ZXh0cywgVU5JRk9STV9DT05URVhUKSA8PCAxIHwgZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBVTklGT1JNX0NPTlRFWFQpOwogICAgICAgICAgICBpZiAoaTEgIT09IDApIHsKICAgICAgICAgICAgICBpID0gaTAgKyBpMTsKICAgICAgICAgICAgICBpbmRleCArPSBpMSAqIHdpZHRoOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHNpZ24gPSB0aGlzLmRlY29kZVNpZ25CaXQoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICBjb2VmZmljZW50c1NpZ25baW5kZXhdID0gc2lnbjsKICAgICAgICAgICAgY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXhdID0gMTsKICAgICAgICAgICAgdGhpcy5zZXROZWlnaGJvcnNTaWduaWZpY2FuY2UoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIHw9IGZpcnN0TWFnbml0dWRlQml0TWFzazsKICAgICAgICAgICAgaW5kZXggPSBpbmRleDA7CiAgICAgICAgICAgIGZvciAobGV0IGkyID0gaTA7IGkyIDw9IGk7IGkyKyssIGluZGV4ICs9IHdpZHRoKSB7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXhdKys7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaTErKzsKICAgICAgICAgIH0KICAgICAgICAgIGZvciAoaSA9IGkwICsgaTE7IGkgPCBpTmV4dDsgaSsrLCBpbmRleCArPSB3aWR0aCkgewogICAgICAgICAgICBpZiAoY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXhdIHx8IChwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdICYgcHJvY2Vzc2VkTWFzaykgIT09IDApIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBjb250ZXh0TGFiZWwgPSBsYWJlbHNbbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2luZGV4XV07CiAgICAgICAgICAgIGNvbnN0IGRlY2lzaW9uID0gZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBjb250ZXh0TGFiZWwpOwogICAgICAgICAgICBpZiAoZGVjaXNpb24gPT09IDEpIHsKICAgICAgICAgICAgICBzaWduID0gdGhpcy5kZWNvZGVTaWduQml0KGksIGosIGluZGV4KTsKICAgICAgICAgICAgICBjb2VmZmljZW50c1NpZ25baW5kZXhdID0gc2lnbjsKICAgICAgICAgICAgICBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleF0gPSAxOwogICAgICAgICAgICAgIHRoaXMuc2V0TmVpZ2hib3JzU2lnbmlmaWNhbmNlKGksIGosIGluZGV4KTsKICAgICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIHw9IGZpcnN0TWFnbml0dWRlQml0TWFzazsKICAgICAgICAgICAgfQogICAgICAgICAgICBiaXRzRGVjb2RlZFtpbmRleF0rKzsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGNoZWNrU2VnbWVudGF0aW9uU3ltYm9sKCkgewogICAgICBjb25zdCBkZWNvZGVyID0gdGhpcy5kZWNvZGVyOwogICAgICBjb25zdCBjb250ZXh0cyA9IHRoaXMuY29udGV4dHM7CiAgICAgIGNvbnN0IHN5bWJvbCA9IGRlY29kZXIucmVhZEJpdChjb250ZXh0cywgVU5JRk9STV9DT05URVhUKSA8PCAzIHwgZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBVTklGT1JNX0NPTlRFWFQpIDw8IDIgfCBkZWNvZGVyLnJlYWRCaXQoY29udGV4dHMsIFVOSUZPUk1fQ09OVEVYVCkgPDwgMSB8IGRlY29kZXIucmVhZEJpdChjb250ZXh0cywgVU5JRk9STV9DT05URVhUKTsKICAgICAgaWYgKHN5bWJvbCAhPT0gMHhhKSB7CiAgICAgICAgdGhyb3cgbmV3IEpweEVycm9yKCJJbnZhbGlkIHNlZ21lbnRhdGlvbiBzeW1ib2wiKTsKICAgICAgfQogICAgfQogIH0K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MzQyMDU5OTI0OwogICAgY29uc3QgYmV0YSA9IC0wLjA1Mjk4MDExODU3Mjk2MTsKICAgIGNvbnN0IGdhbW1hID0gMC44ODI5MTEwNzU1MzA5MzQ7CiAgICBjb25zdCBkZWx0YSA9IDAuNDQzNTA2ODUyMDQzOTcxOwogICAgY29uc3QgSyA9IDEuMjMwMTc0MTA0OTE0MDAxOwogICAgY29uc3QgS18gPSAxIC8gSzsKICAgIGogPSBvZmZzZXQgLSAzOwogICAgZm9yIChuID0gbGVuICsgNDsgbi0tOyBqICs9IDIpIHsKICAgICAgeFtqXSAqPSBLXzsKICAgIH0KICAgIGogPSBvZmZzZXQgLSAyOwogICAgY3VycmVudCA9IGRlbHRhICogeFtqIC0gMV07CiAgICBmb3IgKG4gPSBsZW4gKyAzOyBuLS07IGogKz0gMikgewogICAgICBuZXh0ID0gZGVsdGEgKiB4W2ogKyAxXTsKICAgICAgeFtqXSA9IEsgKiB4W2pdIC0gY3VycmVudCAtIG5leHQ7CiAgICAgIGlmIChuLS0pIHsKICAgICAgICBqICs9IDI7CiAgICAgICAgY3VycmVudCA9IGRlbHRhICogeFtqICsgMV07CiAgICAgICAgeFtqXSA9IEsgKiB4W2pdIC0gY3VycmVudCAtIG5leHQ7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIH0KICAgIGogPSBvZmZzZXQgLSAxOwogICAgY3VycmVudCA9IGdhbW1hICogeFtqIC0gMV07CiAgICBmb3IgKG4gPSBsZW4gKyAyOyBuLS07IGogKz0gMikgewogICAgICBuZXh0ID0gZ2FtbWEgKiB4W2ogKyAxXTsKICAgICAgeFtqXSAtPSBjdXJyZW50ICsgbmV4dDsKICAgICAgaWYgKG4tLSkgewogICAgICAgIGogKz0gMjsKICAgICAgICBjdXJyZW50ID0gZ2FtbWEgKiB4W2ogKyAxXTsKICAgICAgICB4W2pdIC09IGN1cnJlbnQgKyBuZXh0OwogICAgICB9IGVsc2UgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBqID0gb2Zmc2V0OwogICAgY3VycmVudCA9IGJldGEgKiB4W2ogLSAxXTsKICAgIGZvciAobiA9IGxlbiArIDE7IG4tLTsgaiArPSAyKSB7CiAgICAgIG5leHQgPSBiZXRhICogeFtqICsgMV07CiAgICAgIHhbal0gLT0gY3VycmVudCArIG5leHQ7CiAgICAgIGlmIChuLS0pIHsKICAgICAgICBqICs9IDI7CiAgICAgICAgY3VycmVudCA9IGJldGEgKiB4W2ogKyAxXTsKICAgICAgICB4W2pdIC09IGN1cnJlbnQgKyBuZXh0OwogICAgICB9IGVsc2UgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBpZiAobGVuICE9PSAwKSB7CiAgICAgIGogPSBvZmZzZXQgKyAxOwogICAgICBjdXJyZW50ID0gYWxwaGEgKiB4W2ogLSAxXTsKICAgICAgZm9yIChuID0gbGVuOyBuLS07IGogKz0gMikgewogICAgICAgIG5leHQgPSBhbHBoYSAqIHhbaiArIDFdOwogICAgICAgIHhbal0gLT0gY3VycmVudCArIG5leHQ7CiAgICAgICAgaWYgKG4tLSkgewogICAgICAgICAgaiArPSAyOwogICAgICAgICAgY3VycmVudCA9IGFscGhhICogeFtqICsgMV07CiAgICAgICAgICB4W2pdIC09IGN1cnJlbnQgKyBuZXh0OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICB9Cn0KY2xhc3MgUmV2ZXJzaWJsZVRyYW5zZm9ybSBleHRlbmRzIFRyYW5zZm9ybSB7CiAgZmlsdGVyKHgsIG9mZnNldCwgbGVuZ3RoKSB7CiAgICBjb25zdCBsZW4gPSBsZW5ndGggPj4gMTsKICAgIG9mZnNldCB8PSAwOwogICAgbGV0IGosIG47CiAgICBmb3IgKGogPSBvZmZzZXQsIG4gPSBsZW4gKyAxOyBuLS07IGogKz0gMikgewogICAgICB4W2pdIC09IHhbaiAtIDFdICsgeFtqICs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vY2tTaXplOyBpKyspIHsKICAgICAgY29uc3QgY29kZSA9IHRoaXMucmVhZEJpdHMoY29kZUxlbmd0aCk7CiAgICAgIGNvbnN0IGhhc1ByZXYgPSBjdXJyZW50U2VxdWVuY2VMZW5ndGggPiAwOwogICAgICBpZiAoY29kZSA8IDI1NikgewogICAgICAgIGN1cnJlbnRTZXF1ZW5jZVswXSA9IGNvZGU7CiAgICAgICAgY3VycmVudFNlcXVlbmNlTGVuZ3RoID0gMTsKICAgICAgfSBlbHNlIGlmIChjb2RlID49IDI1OCkgewogICAgICAgIGlmIChjb2RlIDwgbmV4dENvZGUpIHsKICAgICAgICAgIGN1cnJlbnRTZXF1ZW5jZUxlbmd0aCA9IGRpY3Rpb25hcnlMZW5ndGhzW2NvZGVdOwogICAgICAgICAgZm9yIChqID0gY3VycmVudFNlcXVlbmNlTGVuZ3RoIC0gMSwgcSA9IGNvZGU7IGogPj0gMDsgai0tKSB7CiAgICAgICAgICAgIGN1cnJlbnRTZXF1ZW5jZVtqXSA9IGRpY3Rpb25hcnlWYWx1ZXNbcV07CiAgICAgICAgICAgIHEgPSBkaWN0aW9uYXJ5UHJldkNvZGVzW3FdOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjdXJyZW50U2VxdWVuY2VbY3VycmVudFNlcXVlbmNlTGVuZ3RoKytdID0gY3VycmVudFNlcXVlbmNlWzBdOwogICAgICAgIH0KICAgICAgfSBlbHNlIGlmIChjb2RlID09PSAyNTYpIHsKICAgICAgICBjb2RlTGVuZ3RoID0gOTsKICAgICAgICBuZXh0Q29kZSA9IDI1ODsKICAgICAgICBjdXJyZW50U2VxdWVuY2VMZW5ndGggPSAwOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgewogICAgICAgIHRoaXMuZW9mID0gdHJ1ZTsKICAgICAgICBkZWxldGUgdGhpcy5sendTdGF0ZTsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoaGFzUHJldikgewogIC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cmV2Um93ID0gYnVmZmVyLnN1YmFycmF5KGJ1ZmZlckxlbmd0aCAtIHJvd0J5dGVzLCBidWZmZXJMZW5ndGgpOwogICAgaWYgKHByZXZSb3cubGVuZ3RoID09PSAwKSB7CiAgICAgIHByZXZSb3cgPSBuZXcgVWludDhBcnJheShyb3dCeXRlcyk7CiAgICB9CiAgICBsZXQgaSwKICAgICAgaiA9IGJ1ZmZlckxlbmd0aCwKICAgICAgdXAsCiAgICAgIGM7CiAgICBzd2l0Y2ggKHByZWRpY3RvcikgewogICAgICBjYXNlIDA6CiAgICAgICAgZm9yIChpID0gMDsgaSA8IHJvd0J5dGVzOyArK2kpIHsKICAgICAgICAgIGJ1ZmZlcltqKytdID0gcmF3Qnl0ZXNbaV07CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBjYXNlIDE6CiAgICAgICAgZm9yIChpID0gMDsgaSA8IHBpeEJ5dGVzOyArK2kpIHsKICAgICAgICAgIGJ1ZmZlcltqKytdID0gcmF3Qnl0ZXNbaV07CiAgICAgICAgfQogICAgICAgIGZvciAoOyBpIDwgcm93Qnl0ZXM7ICsraSkgewogICAgICAgICAgYnVmZmVyW2pdID0gYnVmZmVyW2ogLSBwaXhCeXRlc10gKyByYXdCeXRlc1tpXSAmIDB4ZmY7CiAgICAgICAgICBqKys7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBjYXNlIDI6CiAgICAgICAgZm9yIChpID0gMDsgaSA8IHJvd0J5dGVzOyArK2kpIHsKICAgICAgICAgIGJ1ZmZlcltqKytdID0gcHJldlJvd1tpXSArIHJhd0J5dGVzW2ldICYgMHhmZjsKICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgMzoKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgcGl4Qnl0ZXM7ICsraSkgewogICAgICAgICAgYnVmZmVyW2orK10gPSAocHJldlJvd1tpXSA+PiAxKSArIHJhd0J5dGVzW2ldOwogICAgICAgIH0KICAgICAgICBmb3IgKDsgaSA8IHJvd0J5dGVzOyArK2kpIHsKICAgICAgICAgIGJ1ZmZlcltqXSA9IChwcmV2Um93W2ldICsgYnVmZmVyW2ogLSBwaXhCeXRlc10gPj4gMSkgKyByYXdCeXRlc1tpXSAmIDB4ZmY7CiAgICAgICAgICBqKys7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBjYXNlIDQ6CiAgICAgICAgZm9yIChpID0gMDsgaSA8IHBpeEJ5dGVzOyArK2kpIHsKICAgICAgICAgIHVwID0gcHJldlJvd1tpXTsKICAgICAgICAgIGMgPSByYXdCeXRlc1tpXTsKICAgICAgICAgIGJ1ZmZlcltqKytdID0gdXAgKyBjOwogICAgICAgIH0KICAgICAgICBmb3IgKDsgaSA8IHJvd0J5dGVzOyArK2kpIHsKICAgICAgICAgIHVwID0gcHJldlJvd1tpXTsKICAgICAgICAgIGNvbnN0IHVwTGVmdCA9IHByZXZSb3dbaSAtIHBpeEJ5dGVzXTsKICAgICAgICAgIGNvbnN0IGxlZnQgPSBidWZmZXJbaiAtIHBpeEJ5dGVzXTsKICAgICAgICAgIGNvbnN0IHAgPSBsZWZ0ICsgdXAgLSB1cExlZnQ7CiAgICAgICAgICBsZXQgcGEgPSBwIC0gbGVmdDsKICAgICAgICAgIGlmIChwYSA8IDApIHsKICAgICAgICAgICAgcGEgPSAtcGE7CiAgICAgICAgICB9CiAgICAgICAgICBsZXQgcGIgPSBwIC0gdXA7CiAgICAgICAgICBpZiAocGIgPCAwKSB7CiAgICAgICAgICAgIHBiID0gLXBiOwogICAgICAgICAgfQogICAgICAgICAgbGV0IHBjID0gcCAtIHVwTGVmdDsKICAgICAgICAgIGlmIChwYyA8IDApIHsKICAgICAgICAgICAgcGMgPSAtcGM7CiAgICAgICAgICB9CiAgICAgICAgICBjID0gcmF3Qnl0ZXNbaV07CiAgICAgICAgICBpZiAocGEgPD0gcGIgJiYgcGEgPD0gcGMpIHsKICAgICAgICAgICAgYnVmZmVyW2orK10gPSBs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ZSAiT3BlblR5cGUiOgogICAgICAgIGNhc2UgIlRydWVUeXBlIjoKICAgICAgICBjYXNlICJDSURGb250VHlwZTIiOgogICAgICAgICAgdGhpcy5taW1ldHlwZSA9ICJmb250L29wZW50eXBlIjsKICAgICAgICAgIGRhdGEgPSB0aGlzLmNoZWNrQW5kUmVwYWlyKG5hbWUsIGZpbGUsIHByb3BlcnRpZXMpOwogICAgICAgICAgaWYgKHRoaXMuaXNPcGVuVHlwZSkgewogICAgICAgICAgICBhZGp1c3RXaWR0aHMocHJvcGVydGllcyk7CiAgICAgICAgICAgIHR5cGUgPSAiT3BlblR5cGUiOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihgRm9udCAke3R5cGV9IGlzIG5vdCBzdXBwb3J0ZWRgKTsKICAgICAgfQogICAgfSBjYXRjaCAoZSkgewogICAgICAoMCwgX3V0aWwud2FybikoZSk7CiAgICAgIHRoaXMuZmFsbGJhY2tUb1N5c3RlbUZvbnQocHJvcGVydGllcyk7CiAgICAgIHJldHVybjsKICAgIH0KICAgIGFtZW5kRmFsbGJhY2tUb1VuaWNvZGUocHJvcGVydGllcyk7CiAgICB0aGlzLmRhdGEgPSBkYXRhOwogICAgdGhpcy50eXBlID0gdHlwZTsKICAgIHRoaXMuc3VidHlwZSA9IHN1YnR5cGU7CiAgICB0aGlzLmZvbnRNYXRyaXggPSBwcm9wZXJ0aWVzLmZvbnRNYXRyaXg7CiAgICB0aGlzLndpZHRocyA9IHByb3BlcnRpZXMud2lkdGhzOwogICAgdGhpcy5kZWZhdWx0V2lkdGggPSBwcm9wZXJ0aWVzLmRlZmF1bHRXaWR0aDsKICAgIHRoaXMudG9Vbmljb2RlID0gcHJvcGVydGllcy50b1VuaWNvZGU7CiAgICB0aGlzLnNlYWNNYXAgPSBwcm9wZXJ0aWVzLnNlYWNNYXA7CiAgfQogIGdldCByZ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3VwcGxlbWVudGFsR2x5cGhNYXBGb3JDYWxpYnJpKSgpKTsKICAgICAgfQogICAgICBpZiAoY2lkVG9HaWRNYXApIHsKICAgICAgICBmb3IgKGNvbnN0IGNoYXJDb2RlIGluIG1hcCkgewogICAgICAgICAgY29uc3QgY2lkID0gbWFwW2NoYXJDb2RlXTsKICAgICAgICAgIGlmIChjaWRUb0dpZE1hcFtjaWRdICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgbWFwWytjaGFyQ29kZV0gPSBjaWRUb0dpZE1hcFtjaWRdOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoY2lkVG9HaWRNYXAubGVuZ3RoICE9PSB0aGlzLnRvVW5pY29kZS5sZW5ndGggJiYgcHJvcGVydGllcy5oYXNJbmNsdWRlZFRvVW5pY29kZU1hcCAmJiB0aGlzLnRvVW5pY29kZSBpbnN0YW5jZW9mIF90b191bmljb2RlX21hcC5JZGVudGl0eVRvVW5pY29kZU1hcCkgewogICAgICAgICAgdGhpcy50b1VuaWNvZGUuZm9yRWFjaChmdW5jdGlvbiAoY2hhckNvZGUsIHVuaWNvZGVDaGFyQ29kZSkgewogICAgICAgICAgICBjb25zdCBjaWQgPSBtYXBbY2hhckNvZGVdOwogICAgICAgICAgICBpZiAoY2lkVG9HaWRNYXBbY2lkXSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgbWFwWytjaGFyQ29kZV0gPSB1bmljb2RlQ2hhckNvZGU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0pOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoISh0aGlzLnRvVW5pY29kZSBpbnN0YW5jZW9mIF90b191bmljb2RlX21hcC5JZGVudGl0eVRvVW5pY29kZU1hcCkpIHsKICAgICAgICB0aGlzLnRvVW5pY29kZS5mb3JFYWNoKGZ1bmN0aW9uIChjaGFyQ29kZSwgdW5pY29kZUNoYXJDb2RlKSB7CiAgICAgICAgICBtYXBbK2NoYXJDb2Rl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gICAgICBjb25zdCB0YWJsZSA9IHJlYWRUYWJsZUVudHJ5KGZpbGUpOwogICAgICAgIGlmICghVkFMSURfVEFCTEVTLmluY2x1ZGVzKHRhYmxlLnRhZykpIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBpZiAodGFibGUubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgdGFibGVzW3RhYmxlLnRhZ10gPSB0YWJsZTsKICAgICAgfQogICAgICByZXR1cm4gdGFibGVzOwogICAgfQogICAgZnVuY3Rpb24gcmVhZFRhYmxlRW50cnkoZmlsZSkgewogICAgICBjb25zdCB0YWcgPSBmaWxlLmdldFN0cmluZyg0KTsKICAgICAgY29uc3QgY2hlY2tzdW0gPSBmaWxlLmdldEludDMyKCkgPj4+IDA7CiAgICAgIGNvbnN0IG9mZnNldCA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgY29uc3QgbGVuZ3RoID0gZmlsZS5nZXRJbnQzMigpID4+PiAwOwogICAgICBjb25zdCBwcmV2aW91c1Bvc2l0aW9uID0gZmlsZS5wb3M7CiAgICAgIGZpbGUucG9zID0gZmlsZS5zdGFydCB8fCAwOwogICAgICBmaWxlLnNraXAob2Zmc2V0KTsKICAgICAgY29uc3QgZGF0YSA9IGZpbGUuZ2V0Qnl0ZXMobGVuZ3RoKTsKICAgICAgZmlsZS5wb3MgPSBwcmV2aW91c1Bvc2l0aW9uOwogICAgICBpZiAodGFnID09PSAiaGVhZCIpIHsKICAgICAgICBkYXRhWzhdID0gZGF0YVs5XSA9IGRhdGFbMTBdID0gZGF0YVsxMV0gPSAwOwogICAgICAgIGRhdGFbMTddIHw9IDB4MjA7CiAgICAgIH0KICAgICAgcmV0dXJuIHsKICAgICAgICB0YWcsCiAgICAgICAgY2hlY2tzdW0sCiAgICAgICAgbGVuZ3RoLAogICAgICAgIG9mZnNldCwKICAgICAgICBkYXRhCiAgICAgIH07CiAgICB9CiAgICBmdW5jdGlvbiByZWFkT3BlblR5cGVIZWFkZXIodHRmKSB7CiAgICAgIHJldHVybiB7CiAgICAgICAgdmVyc2lvbjogdHRmLmdldFN0cmluZyg0KSwKICAgICAgICBudW1UYWJsZXM6IHR0Zi5nZXRVaW50MTYoKSwKICAgICAgICBzZWFyY2hSYW5nZTogdHRmLmdldFVpbnQxNigpLAogICAgICAgIGVudHJ5U2VsZWN0b3I6IHR0Zi5nZXRVaW50MTYoKSwKICAgICAgICByYW5nZVNoaWZ0OiB0dGYuZ2V0VWludDE2KCkKICAgICAgfTsKICAgIH0KICAgIGZ1bmN0aW9uIHJlYWRUcnVlVHlwZUNvbGxlY3Rpb25IZWFkZXIodHRjKSB7CiAgICAgIGNvbnN0IHR0Y1RhZyA9IHR0Yy5nZXRTdHJpbmcoNCk7CiAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHR0Y1RhZyA9PT0gInR0Y2YiLCAiTXVzdCBiZSBhIFRydWVUeXBlIENvbGxlY3Rpb24gZm9udC4iKTsKICAgICAgY29uc3QgbWFqb3JWZXJzaW9uID0gdHRjLmdldFVpbnQxNigpOwogICAgICBjb25zdCBtaW5vclZlcnNpb24gPSB0dGMuZ2V0VWludDE2KCk7CiAgICAgIGNvbnN0IG51bUZvbnRzID0gdHRjLmdldEludDMyKCkgPj4+IDA7CiAgICAgIGNvbnN0IG9mZnNldFRhYmxlID0gW107CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbnVtRm9udHM7IGkrKykgewogICAgICAgIG9mZnNldFRhYmxlLnB1c2godHRjLmdldEludDMyKCkgPj4+IDApOwogICAgICB9CiAgICAgIGNvbnN0IGhlYWRlciA9IHsKICAgICAgICB0dGNUYWcsCiAgICAgICAgbWFqb3JWZXJzaW9uLAogICAgICAgIG1pbm9yVmVyc2lvbiwKICAgICAgICBudW1Gb250cywKICAgICAgICBvZmZzZXRUYWJsZQogICAgICB9OwogICAgICBzd2l0Y2ggKG1ham9yVmVyc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uYW1lKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoJ1RydWVUeXBlIENvbGxlY3Rpb24gZm9udCBtdXN0IGNvbnRhaW4gYSAibmFtZSIgdGFibGUuJyk7CiAgICAgICAgfQogICAgICAgIGNvbnN0IFtuYW1lVGFibGVdID0gcmVhZE5hbWVUYWJsZShwb3RlbnRpYWxUYWJsZXMubmFtZSk7CiAgICAgICAgZm9yIChsZXQgaiA9IDAsIGpqID0gbmFtZVRhYmxlLmxlbmd0aDsgaiA8IGpqOyBqKyspIHsKICAgICAgICAgIGZvciAobGV0IGsgPSAwLCBrayA9IG5hbWVUYWJsZVtqXS5sZW5ndGg7IGsgPCBrazsgaysrKSB7CiAgICAgICAgICAgIGNvbnN0IG5hbWVFbnRyeSA9IG5hbWVUYWJsZVtqXVtrXSAmJiBuYW1lVGFibGVbal1ba10ucmVwbGFjZUFsbCgvXHMvZywgIiIpOwogICAgICAgICAgICBpZiAoIW5hbWVFbnRyeSkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChuYW1lRW50cnkgPT09IGZvbnROYW1lKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgIGhlYWRlcjogcG90ZW50aWFsSGVhZGVyLAogICAgICAgICAgICAgICAgdGFibGVzOiBwb3RlbnRpYWxUYWJsZXMKICAgICAgICAgICAgICB9OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChmb250TmFtZVBhcnRzLmxlbmd0aCA8IDIpIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBmb3IgKGNvbnN0IHBhcnQgb2YgZm9udE5hbWVQYXJ0cykgewogICAgICAgICAgICAgIGlmIChuYW1lRW50cnkgPT09IHBhcnQpIHsKICAgICAgICAgICAgICAgIGZhbGxiYWNrRGF0YSA9IHsKICAgICAgICAgICAgICAgICAgbmFtZTogcGFydCwKICAgICAgICAgICAgICAgICAgaGVhZGVyOiBwb3RlbnRpYWxIZWFkZXIsCiAgICAgICAgICAgICAgICAgIHRhYmxlczogcG90ZW50aWFsVGFibGVzCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoZmFsbGJhY2tEYXRhKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKGBUcnVlVHlwZSBDb2xsZWN0aW9uIGRvZXMgbm90IGNvbnRhaW4gIiR7Zm9udE5hbWV9IiBmb250LCBgICsgYGZhbGxpbmcgYmFjayB0byAiJHtmYWxsYmFja0RhdGEubmFtZX0iIGZvbnQgaW5zdGVhZC5gKTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgaGVhZGVyOiBmYWxsYmFja0RhdGEuaGVhZGVyLAogICAgICAgICAgdGFibGVzOiBmYWxsYmFja0RhdGEudGFibGVzCiAgICAgICAgfTsKICAgICAgfQogICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYFRydWVUeXBlIENvbGxlY3Rpb24gZG9lcyBub3QgY29udGFpbiAiJHtmb250TmFtZX0iIGZvbnQuYCk7CiAgICB9CiAgICBmdW5jdGlvbiByZWFkQ21hcFRhYmxlKGNtYXAsIGZpbGUsIGlzU3ltYm9saWNGb250LCBoYXNFbmNvZGluZykgewogICAgICBpZiAoIWNtYXApIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoIk5vIGNtYXAgdGFibGUgYXZhaWxhYmxlLiIpOwogICAgICAgIHJldHVybiB7CiAgICAgICAgICBwbGF0Zm9ybUlkOiAtMSwKICAgICAgICAgIGVuY29kaW5nSWQ6IC0xLAogICAgICAgICAgbWFwcGluZ3M6IFtdLAogICAgICAgICAgaGFzU2hvcnRDbWFwOiBmYWxzZQogICAgICAgIH07CiAgICAgIH0KICAgICAgbGV0IHNlZ21lbnQ7CiAgICAgIGxldC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kpIHsKICAgICAgICAgIHVzZVRhYmxlID0gdHJ1ZTsKICAgICAgICAgIGlmICghaXNTeW1ib2xpY0ZvbnQpIHsKICAgICAgICAgICAgY2FuQnJlYWsgPSB0cnVlOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoaXNTeW1ib2xpY0ZvbnQgJiYgcGxhdGZvcm1JZCA9PT0gMyAmJiBlbmNvZGluZ0lkID09PSAwKSB7CiAgICAgICAgICB1c2VUYWJsZSA9IHRydWU7CiAgICAgICAgICBsZXQgY29ycmVjdGx5U29ydGVkID0gdHJ1ZTsKICAgICAgICAgIGlmIChpIDwgbnVtVGFibGVzIC0gMSkgewogICAgICAgICAgICBjb25zdCBuZXh0Qnl0ZXMgPSBmaWxlLnBlZWtCeXRlcygyKSwKICAgICAgICAgICAgICBuZXh0UGxhdGZvcm1JZCA9IGludDE2KG5leHRCeXRlc1swXSwgbmV4dEJ5dGVzWzFdKTsKICAgICAgICAgICAgaWYgKG5leHRQbGF0Zm9ybUlkIDwgcGxhdGZvcm1JZCkgewogICAgICAgICAgICAgIGNvcnJlY3RseVNvcnRlZCA9IGZhbHNlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoY29ycmVjdGx5U29ydGVkKSB7CiAgICAgICAgICAgIGNhbkJyZWFrID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHVzZVRhYmxlKSB7CiAgICAgICAgICBwb3RlbnRpYWxUYWJsZSA9IHsKICAgICAgICAgICAgcGxhdGZvcm1JZCwKICAgICAgICAgICAgZW5jb2RpbmdJZCwKICAgICAgICAgICAgb2Zmc2V0CiAgICAgICAgICB9OwogICAgICAgIH0KICAgICAgICBpZiAoY2FuQnJlYWspIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAocG90ZW50aWFsVGFibGUpIHsKICAgICAgICBmaWxlLnBvcyA9IHN0YXJ0ICsgcG90ZW50aWFsVGFibGUub2Zmc2V0OwogICAgICB9CiAgICAgIGlmICghcG90ZW50aWFsVGFibGUgfHwgZmlsZS5wZWVrQnl0ZSgpID09PSAtMSkgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiQ291bGQgbm90IGZpbmQgYSBwcmVmZXJyZWQgY21hcCB0YWJsZS4iKTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgcGxhdGZvcm1JZDogLTEsCiAgICAgICAgICBlbmNvZGluZ0lkOiAtMSwKICAgICAgICAgIG1hcHBpbmdzOiBbXSwKICAgICAgICAgIGhhc1Nob3J0Q21hcDogZmFsc2UKICAgICAgICB9OwogICAgICB9CiAgICAgIGNvbnN0IGZvcm1hdCA9IGZpbGUuZ2V0VWludDE2KCk7CiAgICAgIGxldCBoYXNTaG9ydENtYXAgPSBmYWxzZTsKICAgICAgY29uc3QgbWFwcGluZ3MgPSBbXTsKICAgICAgbGV0IGosIGdseXBoSWQ7CiAgICAgIGlmIChmb3JtYXQgPT09IDApIHsKICAgICAgICBmaWxlLnNraXAoMiArIDIpOwogICAgICAgIGZvciAoaiA9IDA7IGogPCAyNTY7IGorKykgewogICAgICAgICAgY29uc3QgaW5kZXggPSBmaWxlLmdldEJ5dGUoKTsKICAgICAgICAgIGlmICghaW5kZXgpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBtYXBwaW5ncy5wdXNoKHsKICAgICAgICAgICAgY2hhckNvZGU6IGosCiAgICAgICAgICAgIGdseXBoSWQ6IGluZGV4CiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgaGFzU2hvcnRDbWFwID0gdHJ1ZTsKICAgICAgfSBlbHNlIGlmIChmb3JtYXQgPT09IDIpIHsKICAgICAgICBmaWxlLnNraXAoMiArIDIpOwogICAgICAgIGNvbnN0IHN1YkhlYWRlcktleXMgPSBbXTsKICAgICAgICBsZXQgbWF4U3ViSGVhZGVyS2V5ID0gMDsKICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI1NjsgaSsrKSB7CiAgICAgICAgICBjb25zdCBzdWJIZWFkZXJLZXkgPSBmaWxlLmdldFVpbnQxNigpID4+IDM7CiAgICAgICAgICBzdWJIZWFkZXJLZXlzLnB1c2goc3ViSGVhZGVyS2V5KTsKICAgICAgICAgIG1heFN1YkhlYWRlcktleSA9IE1hdGgubWF4KHN1YkhlYWRlcktleSwgbWF4U3ViSGVhZGVyS2V5KTsKICAgICAgICB9CiAgICAgICAgY29uc3Qgc3ViSGVhZGVycyA9IFtdOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDw9IG1heFN1YkhlYWRlcktleTsgaSsrKSB7CiAgICAgICAgICBzdWJIZWFkZXJzLnB1c2goewogICAgICAgICAgICBmaXJzdENvZGU6IGZpbGUuZ2V0VWludDE2KCksCiAgICAgICAgICAgIGVudHJ5Q291bnQ6IGZpbGUuZ2V0VWludDE2KCksCiAgICAgICAgICAgIGlkRGVsdGE6IHNpZ25lZEludDE2KGZpbGUuZ2V0Qnl0ZSgpLCBmaWxlLmdldEJ5dGUoKSksCiAgICAgICAgICAgIGlkUmFuZ2VQb3M6IGZpbGUucG9zICsgZmlsZS5nZXRVaW50MTYoKQogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgMjU2OyBpKyspIHsKICAgICAgICAgIGlmIChzdWJIZWFkZXJLZXlzW2ldID09PSAwKSB7CiAgICAgICAgICAgIGZpbGUucG9zID0gc3ViSGVhZGVyc1swXS5pZFJhbmdlUG9zICsgMiAqIGk7CiAgICAgICAgICAgIGdseXBoSWQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgICAgICBtYXBwaW5ncy5wdXNoKHsKICAgICAgICAgICAgICBjaGFyQ29kZTogaSwKICAgICAgICAgICAgICBnbHlwaElkCiAgICAgICAgICAgIH0pOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY29uc3QgcyA9IHN1YkhlYWRlcnNbc3ViSGVhZGVyS2V5c1tpXV07CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBzLmVudHJ5Q291bnQ7IGorKykgewogICAgICAgICAgICAgIGNvbnN0IGNoYXJDb2RlID0gKGkgPDwgOCkgKyBqICsgcy5maXJzdENvZGU7CiAgICAgICAgICAgICAgZmlsZS5wb3MgPSBzLmlkUmFuZ2VQb3MgKyAyICogajsKICAgICAgICAgICAgICBnbHlwaElkID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgICAgICAgICBpZiAoZ2x5cGhJZCAhPT0gMCkgewogICAgICAgICAgICAgICAgZ2x5cGhJZCA9IChnbHlwaElkICsgcy5pZERlbHRhKSAlIDY1NTM2OwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBtYXBwaW5ncy5wdXNoKHsKICAgICAgICAgICAgICAgIGNoYXJDb2RlLAogICAgICAgICAgICAgICAgZ2x5cGhJZAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGZvcm1hdCA9PT0gNCkgewogICAgICAgIGZpbGUuc2tpcCgyICsgMik7CiAgICAgICAgY29uc3Qgc2VnQ291bnQgPSBmaWxlLmdldFVpbnQxNigpID4+IDE7CiAgICAgICAgZmlsZS5za2lwKDYpOwogICAgICAgIGNvbnN0IHNlZ21lbnRzID0gW107CiAgICAgICAgbGV0IHNlZ0luZGV4OwogICAgICAgIGZvciAoc2VnSW5kZXggPSAwOyBzZWdJbmRleCA8IHNlZ0NvdW50OyBzZWdJbmRleCsrKSB7CiAgICAgICAgICBzZWdtZW50cy5wdXNoKHsKICAgICAgICAgICAgZW5kOiBmaWxlLmdldFVpbnQxNigpCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgZmlsZS5za2lwKDIpOwogICAgICAgIGZvciAoc2VnSW5kZXggPSAwOyBzZWdJbmRleCA8IHNlZ0NvdW50OyBzZWdJbmRleCsrKSB7CiAgICAgICAgICBzZWdtZW50c1tzZWdJbmRleF0uc3RhcnQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIH0KICAgICAgICBmb3IgKHNlZ0luZGV4ID0gMDsgc2VnSW5kZXggPCBzZWdDb3VudDsgc2VnSW5kZXgrKykgewogICAgICAgICAgc2VnbWVudHNbc2VnSW5kZXhdLmRlbHRhID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgICB9CiAgICAgICAgbGV0IG9mZnNldHNDb3VudCA9IDAsCiAgICAgICAgICBvZmZzZXRJbmRleDsKICAgICAgICBmb3IgKHNlZ0luZGV4ID0gMDsgc2VnSW5kZXggPCBzZWdDb3VudDsgc2VnSW5kZXgrKykgewogICAgICAgICAgc2VnbWVudCA9IHNlZ21lbnRzW3NlZ0luZGV4XTsKICAgICAgICAgIGNvbnN0IHJhbmdlT2Zmc2V0ID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgICAgIGlmICghcmFuZ2VPZmZzZXQpIHsKICAgICAgICAgICAgc2VnbWVudC5vZmZzZXRJbmRleCA9IC0xOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIG9mZnNldEluZGV4ID0gKHJhbmdlT2Zmc2V0ID4+IDEpIC0gKHNlZ0NvdW50IC0gc2VnSW5kZXgpOwogICAgICAgICAgc2VnbWVudC5vZmZzZXRJbmRleCA9IG9mZnNldEluZGV4OwogICAgICAgICAgb2Zmc2V0c0NvdW50ID0gTWF0aC5tYXgob2Zmc2V0c0NvdW50LCBvZmZzZXRJbmRleCArIHNlZ21lbnQuZW5kIC0gc2VnbWVudC5zdGFydCArIDEpOwogICAgICAgIH0KICAgICAgICBjb25zdCBvZmZzZXRzID0gW107CiAgICAgICAgZm9yIChqID0gMDsgaiA8IG9mZnNldHNDb3VudDsgaisrKSB7CiAgICAgICAgICBvZmZzZXRzLnB1c2goZmlsZS5nZXRVaW50MTYoKSk7CiAgICAgICAgfQogICAgICAgIGZvciAoc2VnSW5kZXggPSAwOyBzZWdJbmRleCA8IHNlZ0NvdW50OyBzZWdJbmRleCsrKSB7CiAgICAgICAgICBzZWdtZW50ID0gc2VnbWVudHNbc2VnSW5kZXhdOwogICAgICAgICAgc3RhcnQgPSBzZWdtZW50LnN0YXJ0OwogICAgICAgICAgY29uc3QgZW5kID0gc2VnbWVudC5lbmQ7CiAgICAgICAgICBjb25zdCBkZWx0YSA9IHNlZ21lbnQuZGVsdGE7CiAgICAgICAgICBvZmZzZXRJbmRleCA9IHNlZ21lbnQub2Zmc2V0SW5kZXg7CiAgICAgICAgICBmb3IgKGogPSBzdGFydDsgaiA8PSBlbmQ7IGorKykgewogICAgICAgICAgICBpZiAoaiA9PT0gMHhmZmZmKSB7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZ2x5cGhJZCA9IG9mZnNldEluZGV4IDwgMCA/IGogOiBvZmZzZXRzW29mZnNldEluZGV4ICsgaiAtIHN0YXJ0XTsKICAgICAgICAgICAgZ2x5cGhJZCA9IGdseXBoSWQgKyBkZWx0YSAmIDB4ZmZmZjsKICAgICAgICAgICAgbWFwcGluZ3MucHVzaCh7CiAgICAgICAgICAgICAgY2hhckNvZGU6IGosCiAgICAgICAgICAgICAgZ2x5cGhJZAogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoZm9ybWF0ID09PSA2KSB7CiAgICAgICAgZmlsZS5za2lwKDIgKyAyKTsKICAgICAgICBjb25zdCBmaXJzdENvZGUgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIGNvbnN0IGVudHJ5Q291bnQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIGZvciAoaiA9IDA7IGogPCBlbnRyeUNvdW50OyBqKyspIHsKICAgICAgICAgIGdseXBoSWQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgICAgY29uc3QgY2hhckNvZGUgPSBmaXJzdENvZGUgKyBqOwogICAgICAgICAgbWFwcGluZ3MucHVzaCh7CiAgICAgICAgICAgIGNoYXJDb2RlLAogICAgICAgICAgICBnbHlwaElkCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoZm9ybWF0ID09PSAxMikgewogICAgICAgIGZpbGUuc2tpcCgyICsgNCArIDQpOwogICAgICAgIGNvbnN0IG5Hcm91cHMgPSBmaWxlLmdldEludDMyKCkgPj4+IDA7CiAgICAgICAgZm9yIChqID0gMDsgaiA8IG5Hcm91cHM7IGorKykgewogICAgICAgICAgY29uc3Qgc3RhcnRDaGFyQ29kZSA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICAgIGNvbnN0IGVuZENoYXJDb2RlID0gZmlsZS5nZXRJbnQzMigpID4+PiAwOwogICAgICAgICAgbGV0IGdseXBoQ29kZSA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICAgIGZvciAobGV0IGNoYXJDb2RlID0gc3RhcnRDaGFyQ29kZTsgY2hhckNvZGUgPD0gZW5kQ2hhckNvZGU7IGNoYXJDb2RlKyspIHsKICAgICAgICAgICAgbWFwcGluZ3MucHVzaCh7CiAgICAgICAgICAgICAgY2hhckNvZGUsCiAgICAgICAgICAgICAgZ2x5cGhJZDogZ2x5cGhDb2RlKysKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiY21hcCB0YWJsZSBoYXMgdW5zdXBwb3J0ZWQgZm9ybWF0OiAiICsgZm9ybWF0KTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgcGxhdGZvcm1JZDogLTEsCiAgICAgICAgICBlbmNvZGluZ0lkOiAtMSwKICAgICAgICAgIG1hcHBpbmdzOiBbXSwKICAgICAgICAgIGhhc1Nob3J0Q21hcDogZmFsc2UKICAgICAgICB9OwogICAgICB9CiAgICAgIG1hcHBpbmdzLnNvcnQoZnVuY3Rpb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nID4gMCkgewogICAgICAgIGNvbnN0IGVudHJpZXMgPSBuZXcgVWludDhBcnJheShtZXRyaWNzLmxlbmd0aCArIG51bU1pc3NpbmcgKiAyKTsKICAgICAgICBlbnRyaWVzLnNldChtZXRyaWNzLmRhdGEpOwogICAgICAgIGlmIChkdXBGaXJzdEVudHJ5KSB7CiAgICAgICAgICBlbnRyaWVzW21ldHJpY3MubGVuZ3RoXSA9IG1ldHJpY3MuZGF0YVsyXTsKICAgICAgICAgIGVudHJpZXNbbWV0cmljcy5sZW5ndGggKyAxXSA9IG1ldHJpY3MuZGF0YVszXTsKICAgICAgICB9CiAgICAgICAgbWV0cmljcy5kYXRhID0gZW50cmllczsKICAgICAgfQogICAgfQogICAgZnVuY3Rpb24gc2FuaXRpemVHbHlwaChzb3VyY2UsIHNvdXJjZVN0YXJ0LCBzb3VyY2VFbmQsIGRlc3QsIGRlc3RTdGFydCwgaGludHNWYWxpZCkgewogICAgICBjb25zdCBnbHlwaFByb2ZpbGUgPSB7CiAgICAgICAgbGVuZ3RoOiAwLAogICAgICAgIHNpemVPZkluc3RydWN0aW9uczogMAogICAgICB9OwogICAgICBpZiAoc291cmNlRW5kIC0gc291cmNlU3RhcnQgPD0gMTIpIHsKICAgICAgICByZXR1cm4gZ2x5cGhQcm9maWxlOwogICAgICB9CiAgICAgIGNvbnN0IGdseWYgPSBzb3VyY2Uuc3ViYXJyYXkoc291cmNlU3RhcnQsIHNvdXJjZUVuZCk7CiAgICAgIGxldCBjb250b3Vyc0NvdW50ID0gc2lnbmVkSW50MTYoZ2x5ZlswXSwgZ2x5ZlsxXSk7CiAgICAgIGlmIChjb250b3Vyc0NvdW50IDwgMCkgewogICAgICAgIGNvbnRvdXJzQ291bnQgPSAtMTsKICAgICAgICB3cml0ZVNpZ25lZEludDE2KGdseWYsIDAsIGNvbnRvdXJzQ291bnQpOwogICAgICAgIGRlc3Quc2V0KGdseWYsIGRlc3RTdGFydCk7CiAgICAgICAgZ2x5cGhQcm9maWxlLmxlbmd0aCA9IGdseWYubGVuZ3RoOwogICAgICAgIHJldHVybiBnbHlwaFByb2ZpbGU7CiAgICAgIH0KICAgICAgbGV0IGksCiAgICAgICAgaiA9IDEwLAogICAgICAgIGZsYWdzQ291bnQgPSAwOwogICAgICBmb3IgKGkgPSAwOyBpIDwgY29udG91cnNDb3VudDsgaSsrKSB7CiAgICAgICAgY29uc3QgZW5kUG9pbnQgPSBnbHlmW2pdIDw8IDggfCBnbHlmW2ogKyAxXTsKICAgICAgICBmbGFnc0NvdW50ID0gZW5kUG9pbnQgKyAxOwogICAgICAgIGogKz0gMjsKICAgICAgfQogICAgICBjb25zdCBpbnN0cnVjdGlvbnNTdGFydCA9IGo7CiAgICAgIGNvbnN0IGluc3RydWN0aW9uc0xlbmd0aCA9IGdseWZbal0gPDwgOCB8IGdseWZbaiArIDFdOwogICAgICBnbHlwaFByb2ZpbGUuc2l6ZU9mSW5zdHJ1Y3Rpb25zID0gaW5zdHJ1Y3Rpb25zTGVuZ3RoOwogICAgICBqICs9IDIgKyBpbnN0cnVjdGlvbnNMZW5ndGg7CiAgICAgIGNvbnN0IGluc3RydWN0aW9uc0VuZCA9IGo7CiAgICAgIGxldCBjb29yZGluYXRlc0xlbmd0aCA9IDA7CiAgICAgIGZvciAoaSA9IDA7IGkgPCBmbGFnc0NvdW50OyBpKyspIHsKICAgICAgICBjb25zdCBmbGFnID0gZ2x5ZltqKytdOwogICAgICAgIGlmIChmbGFnICYgMHhjMCkgewogICAgICAgICAgZ2x5ZltqIC0gMV0gPSBmbGFnICYgMHgzZjsKICAgICAgICB9CiAgICAgICAgbGV0IHhMZW5ndGggPSAyOwogICAgICAgIGlmIChmbGFnICYgMikgewogICAgICAgICAgeExlbmd0aCA9IDE7CiAgICAgICAgfSBlbHNlIGlmIChmbGFnICYgMTYpIHsKICAgICAgICAgIHhMZW5ndGggPSAwOwogICAgICAgIH0KICAgICAgICBsZXQgeUxlbmd0aCA9IDI7CiAgICAgICAgaWYgKGZsYWcgJ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ICAgICAgfSk7CiAgICAgIH0KICAgICAgbG9jYUVudHJpZXMuc29ydCgoYSwgYikgPT4gewogICAgICAgIHJldHVybiBhLm9mZnNldCAtIGIub2Zmc2V0OwogICAgICB9KTsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bUdseXBoczsgaSsrKSB7CiAgICAgICAgbG9jYUVudHJpZXNbaV0uZW5kT2Zmc2V0ID0gbG9jYUVudHJpZXNbaSArIDFdLm9mZnNldDsKICAgICAgfQogICAgICBsb2NhRW50cmllcy5zb3J0KChhLCBiKSA9PiB7CiAgICAgICAgcmV0dXJuIGEuaW5kZXggLSBiLmluZGV4OwogICAgICB9KTsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bUdseXBoczsgaSsrKSB7CiAgICAgICAgY29uc3QgewogICAgICAgICAgb2Zmc2V0LAogICAgICAgICAgZW5kT2Zmc2V0CiAgICAgICAgfSA9IGxvY2FFbnRyaWVzW2ldOwogICAgICAgIGlmIChvZmZzZXQgIT09IDAgfHwgZW5kT2Zmc2V0ICE9PSAwKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgY29uc3QgbmV4dE9mZnNldCA9IGxvY2FFbnRyaWVzW2kgKyAxXS5vZmZzZXQ7CiAgICAgICAgaWYgKG5leHRPZmZzZXQgPT09IDApIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBsb2NhRW50cmllc1tpXS5lbmRPZmZzZXQgPSBuZXh0T2Zmc2V0OwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGNvbnN0IG1pc3NpbmdHbHlwaHMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICBsZXQgd3JpdGVPZmZzZXQgPSAwOwogICAgICBpdGVtRW5jb2RlKGxvY2FEYXRhLCAwLCB3cml0ZU9mZnNldCk7CiAgICAgIGZvciAoaSA9IDAsIGogPSBpdGVtU2l6ZTsgaSA8IG51bUdseXBoczsgaSsrLCBqICs9IGl0ZW1TaXpl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gKGZvbnQuc3RhcnQgfHwgMCkgKyBwb3N0Lm9mZnNldDsKICAgICAgZm9udC5wb3MgPSBzdGFydDsKICAgICAgY29uc3QgbGVuZ3RoID0gcG9zdC5sZW5ndGgsCiAgICAgICAgZW5kID0gc3RhcnQgKyBsZW5ndGg7CiAgICAgIGNvbnN0IHZlcnNpb24gPSBmb250LmdldEludDMyKCk7CiAgICAgIGZvbnQuc2tpcCgyOCk7CiAgICAgIGxldCBnbHlwaE5hbWVzOwogICAgICBsZXQgdmFsaWQgPSB0cnVlOwogICAgICBsZXQgaTsKICAgICAgc3dpdGNoICh2ZXJzaW9uKSB7CiAgICAgICAgY2FzZSAweDAwMDEwMDAwOgogICAgICAgICAgZ2x5cGhOYW1lcyA9IF9mb250c191dGlscy5NYWNTdGFuZGFyZEdseXBoT3JkZXJpbmc7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4MDAwMjAwMDA6CiAgICAgICAgICBjb25zdCBudW1HbHlwaHMgPSBmb250LmdldFVpbnQxNigpOwogICAgICAgICAgaWYgKG51bUdseXBocyAhPT0gbWF4cE51bUdseXBocykgewogICAgICAgICAgICB2YWxpZCA9IGZhbHNlOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IGdseXBoTmFtZUluZGV4ZXMgPSBbXTsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBudW1HbHlwaHM7ICsraSkgewogICAgICAgICAgICBjb25zdCBpbmRleCA9IGZvbnQuZ2V0VWludDE2KCk7CiAgICAgICAgICAgIGlmIChpbmRleCA+PSAzMjc2OCkgewogICAgICAgICAgICAgIHZhbGlkID0gZmFsc2U7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZ2x5cGhOYW1lSW5kZXhlcy5wdXNoKGluZGV4KTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICghdmFsaWQpIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCBjdXN0b21OYW1lcyA9IFtdLAogICAgICAgICAgICBzdHJCdWYgPSBbXTsKICAgICAgICAgIHdoaWxlIChmb250LnBvcyA8IGVuZCkgewogICAgICAgICAgICBjb25zdCBzdHJpbmdMZW5ndGggPSBmb250LmdldEJ5dGUoKTsKICAgICAgICAgICAgc3RyQnVmLmxlbmd0aCA9IHN0cmluZ0xlbmd0aDsKICAgICAgICAgICAgZm9yIChpID0gMDsgaSA8IHN0cmluZ0xlbmd0aDsgKytpKSB7CiAgICAgICAgICAgICAgc3RyQnVmW2ldID0gU3RyaW5nLmZyb21DaGFyQ29kZShmb250LmdldEJ5dGUoKSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY3VzdG9tTmFtZXMucHVzaChzdHJCdWYuam9pbigiIikpOwogICAgICAgICAgfQogICAgICAgICAgZ2x5cGhOYW1lcyA9IFtdOwogICAgICAgICAgZm9yIChpID0gMDsgaSA8IG51bUdseXBoczsgKytpKSB7CiAgICAgICAgICAgIGNvbnN0IGogPSBnbHlwaE5hbWVJbmRleGVzW2ldOwogICAgICAgICAgICBpZiAoaiA8IDI1OCkgewogICAgICAgICAgICAgIGdseXBoTmFtZXMucHVzaChfZm9udHNfdXRpbHMuTWFjU3RhbmRhcmRHbHlwaE9yZGVyaW5nW2pdKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBnbHlwaE5hbWVzLnB1c2goY3VzdG9tTmFtZXNbaiAtIDI1OF0pOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDAwMDMwMDAwOgogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5rbm93bi91bnN1cHBvcnRlZCBwb3N0IHRhYmxlIHZlcnNpb24gIiArIHZlcnNpb24pOwogICAgICAgICAgdmFsaWQgPSBmYWxzZTsKICAgICAgICAgIGlmIChwcm9wZXJ0aWVzT2JqLmRlZmF1bHRFbmNvZGluZykgewogICAgICAgICAgICBnbHlwaE5hbWVzID0gcHJvcGVydGllc09iai5kZWZhdWx0RW5jb2Rpbmc7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgICBwcm9wZXJ0aWVzT2JqLmdseXBoTmFtZXMgPSBnbHlwaE5hbWVzOwogICAgICByZXR1cm4gdmFsaWQ7CiAgICB9CiAgICBmdW5jdGlvbiByZWFkTmFtZVRhYmxlKG5hbWVUYWJsZSkgewogICAgICBjb25zdCBzdGFydCA9IChmb250LnN0YXJ0IHx8IDApICsgbmFtZVRhYmxlLm9mZnNldDsKICAgICAgZm9udC5wb3MgPSBzdGFydDsKICAgICAgY29uc3QgbmFtZXMgPSBbW10sIFtdXSwKICAgICAgICByZWNvcmRzID0gW107CiAgICAgIGNvbnN0IGxlbmd0aCA9IG5hbWVUYWJsZS5sZW5ndGgsCiAgICAgICAgZW5kID0gc3RhcnQgKyBsZW5ndGg7CiAgICAgIGNvbnN0IGZvcm1hdCA9IGZvbnQuZ2V0VWludDE2KCk7CiAgICAgIGNvbnN0IEZPUk1BVF8wX0hFQURFUl9MRU5HVEggPSA2OwogICAgICBpZiAoZm9ybWF0ICE9PSAwIHx8IGxlbmd0aCA8IEZPUk1BVF8wX0hFQURFUl9MRU5HVEgpIHsKICAgICAgICByZXR1cm4gW25hbWVzLCByZWNvcmRzXTsKICAgICAgfQogICAgICBjb25zdCBudW1SZWNvcmRzID0gZm9udC5nZXRVaW50MTYoKTsKICAgICAgY29uc3Qgc3RyaW5nc1N0YXJ0ID0gZm9udC5nZXRVaW50MTYoKTsKICAgICAgY29uc3QgTkFNRV9SRUNPUkRfTEVOR1RIID0gMTI7CiAgICAgIGxldCBpLCBpaTsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bVJlY29yZHMgJiYgZm9udC5wb3MgKyBOQU1FX1JFQ09SRF9MRU5HVEggPD0gZW5kOyBpKyspIHsKICAgICAgICBjb25zdCByID0gewogICAgICAgICAgcGxhdGZvcm06IGZvbnQuZ2V0VWludDE2KCksCiAgICAgICAgICBlbmNvZGluZzogZm9udC5nZXRVaW50MTYoKSwKICAgICAgICAgIGxhbmd1YWdlOiBmb250LmdldFVpbnQxNigpLAogICAgICAgICAgbmFtZTogZm9udC5nZXRVaW50MTYoKSwKICAgICAgICAgIGxlbmd0aDogZm9udC5nZXRVaW50MTYoKSwKICAgICAgICAgIG9mZnNldDogZm9udC5nZXRVaW50MTYoKQogICAgICAgIH07CiAgICAgICAgaWYgKGlzTWFjTmFtZVJlY29yZChyKSB8fCBpc1dpbk5hbWVSZWNvcmQocikpIHsKICAgICAgICAgIHJlY29yZHMucHVzaChyKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgZm9yIChpID0gMCwgaWkgPSByZWNvcmRzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb25zdCByZWNvcmQgPSByZWNvcmRzW2ldOwogICAgICAgIGlmIChyZWNvcmQubGVuZ3RoIDw9IDApIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBjb25zdCBwb3MgPSBzdGFydCArIHN0cmluZ3NTdGFydCArIHJlY29yZC5vZmZzZXQ7CiAgICAgICAgaWYgKHBvcyArIHJlY29yZC5sZW5ndGggPiBlbmQpIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBmb250LnBvcyA9IHBvczsKICAgICAgICBjb25zdCBuYW1lSW5kZXggPSByZWNvcmQubmFtZTsKICAgICAgICBpZiAocmVjb3JkLmVuY29kaW5nKSB7CiAgICAgICAgICBsZXQgc3RyID0gIiI7CiAgICAgICAgICBmb3IgKGxldCBqID0gMCwgamogPSByZWNvcmQubGVuZ3RoOyBqIDwgamo7IGogKz0gMikgewogICAgICAgICAgICBzdHIgKz0gU3RyaW5nLmZyb21DaGFyQ29kZShmb250LmdldFVpbnQxNigpKTsKICAgICAgICAg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0KSB7CiAgICAgIGxldCBkYXRhID0gdGFibGUuZGF0YTsKICAgICAgbGV0IGkgPSAwLAogICAgICAgIGosCiAgICAgICAgbiwKICAgICAgICBiLAogICAgICAgIGZ1bmNJZCwKICAgICAgICBwYywKICAgICAgICBsYXN0RW5kZiA9IDAsCiAgICAgICAgbGFzdERlZmYgPSAwOwogICAgICBjb25zdCBzdGFjayA9IFtdOwogICAgICBjb25zdCBjYWxsc3RhY2sgPSBbXTsKICAgICAgY29uc3QgZnVuY3Rpb25zQ2FsbGVkID0gW107CiAgICAgIGxldCB0b29Db21wbGV4VG9Gb2xsb3dGdW5jdGlvbnMgPSB0dENvbnRleHQudG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zOwogICAgICBsZXQgaW5GREVGID0gZmFsc2UsCiAgICAgICAgaWZMZXZlbCA9IDAsCiAgICAgICAgaW5FTFNFID0gMDsKICAgICAgZm9yIChsZXQgaWkgPSBkYXRhLmxlbmd0aDsgaSA8IGlpOykgewogICAgICAgIGNvbnN0IG9wID0gZGF0YVtpKytdOwogICAgICAgIGlmIChvcCA9PT0gMHg0MCkgewogICAgICAgICAgbiA9IGRhdGFbaSsrXTsKICAgICAgICAgIGlmIChpbkZERUYgfHwgaW5FTFNFKSB7CiAgICAgICAgICAgIGkgKz0gbjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBuOyBqKyspIHsKICAgICAgICAgICAgICBzdGFjay5wdXNoKGRhdGFbaSsrXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgaWYgKG9wID09PSAweDQxKSB7CiAgICAgICAgICBuID0gZGF0YVtpKytdOwogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgaSArPSBuICogMjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBuOyBqKyspIHsKICAgICAgICAgICAgICBiID0gZGF0YVtpKytdOwogICAgICAgICAgICAgIHN0YWNrLnB1c2goYiA8PCA4IHwgZGF0YVtpKytdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoKG9wICYgMHhmOCkgPT09IDB4YjApIHsKICAgICAgICAgIG4gPSBvcCAtIDB4YjAgKyAxOwogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgaSArPSBuOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IG47IGorKykgewogICAgICAgICAgICAgIHN0YWNrLnB1c2goZGF0YVtpKytdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoKG9wICYgMHhmOCkgPT09IDB4YjgpIHsKICAgICAgICAgIG4gPSBvcCAtIDB4YjggKyAxOwogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgaSArPSBuICogMjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBuOyBqKyspIHsKICAgICAgICAgICAgICBiID0gZGF0YVtpKytdOwogICAgICAgICAgICAgIHN0YWNrLnB1c2goYiA8PCA4IHwgZGF0YVtpKytdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MmIgJiYgIXRvb0NvbXBsZXhUb0ZvbGxvd0Z1bmN0aW9ucykgewogICAgICAgICAgaWYgKCFpbkZERUYgJiYgIWluRUxTRSkgewogICAgICAgICAgICBmdW5jSWQgPSBzdGFjay5hdCgtMSk7CiAgICAgICAgICAgIGlmIChpc05hTihmdW5jSWQpKSB7CiAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJUVDogQ0FMTCBlbXB0eSBzdGFjayAob3IgaW52YWxpZCBlbnRyeSkuIik7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdHRDb250ZXh0LmZ1bmN0aW9uc1VzZWRbZnVuY0lkXSA9IHRydWU7CiAgICAgICAgICAgICAgaWYgKGZ1bmNJZCBpbiB0dENvbnRleHQuZnVuY3Rpb25zU3RhY2tEZWx0YXMpIHsKICAgICAgICAgICAgICAgIGNvbnN0IG5ld1N0YWNrTGVuZ3RoID0gc3RhY2subGVuZ3RoICsgdHRDb250ZXh0LmZ1bmN0aW9uc1N0YWNrRGVsdGFzW2Z1bmNJZF07CiAgICAgICAgICAgICAgICBpZiAobmV3U3RhY2tMZW5ndGggPCAwKSB7CiAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVFQ6IENBTEwgaW52YWxpZCBmdW5jdGlvbnMgc3RhY2sgZGVsdGEuIik7CiAgICAgICAgICAgICAgICAgIHR0Q29udGV4dC5oaW50c1ZhbGlkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YWNrLmxlbmd0aCA9IG5ld1N0YWNrTGVuZ3RoOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAoZnVuY0lkIGluIHR0Q29udGV4dC5mdW5jdGlvbnNEZWZpbmVkICYmICFmdW5jdGlvbnNDYWxsZWQuaW5jbHVkZXMoZnVuY0lkKSkgewogICAgICAgICAgICAgICAgY2FsbHN0YWNrLnB1c2goewogICAgICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgICAgICBpLAogICAgICAgICAgICAgICAgICBzdGFja1RvcDogc3RhY2subGVuZ3RoIC0gMQogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBmdW5jdGlvbnNDYWxsZWQucHVzaChmdW5jSWQpOwogICAgICAgICAgICAgICAgcGMgPSB0dENvbnRleHQuZnVuY3Rpb25zRGVmaW5lZFtmdW5jSWRdOwogICAgICAgICAgICAgICAgaWYgKCFwYykgewogICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlRUOiBDQUxMIG5vbi1leGlzdGVudCBmdW5jdGlvbiIpOwogICAgICAgICAgICAgICAgICB0dENvbnRleHQuaGludHNWYWxpZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBkYXRhID0gcGMuZGF0YTsKICAgICAgICAgICAgICAgIGkgPSBwYy5pOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MmMgJiYgIXRvb0NvbXBsZXhUb0ZvbGxvd0Z1bmN0aW9ucykgewogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogbmVzdGVkIEZERUZzIG5vdCBhbGxvd2VkIik7CiAgICAgICAgICAgIHRvb0NvbXBsZXhUb0ZvbGxvd0Z1bmN0aW9ucyA9IHRydWU7CiAgICAgICAgICB9CiAgICAgICAgICBpbkZERUYgPSB0cnVlOwogICAgICAgICAgbGFzdERlZmYgPSBpOwogICAgICAgICAgZnVuY0lkID0gc3RhY2sucG9wKCk7CiAgICAgICAgICB0dENvbnRleHQuZnVuY3Rpb25zRGVmaW5lZFtmdW5jSWRdID0gewogICAgICAgICAgICBkYXRhLAogICAgICAgICAgICBpCiAgICAgICAgICB9OwogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MmQpIHsKICAgICAgICAgIGlmIChpbkZERUYpIHsKICAgICAgICAgICAgaW5GREVGID0gZmFsc2U7CiAgICAgICAgICAgIGxhc3RFbmRmID0gaTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHBjID0gY2FsbHN0YWNrLnBvcCgpOwogICAgICAgICAgICBpZiAoIXBjKSB7CiAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogRU5ERiBiYWQgc3RhY2siKTsKICAgICAgICAgICAgICB0dENvbnRleHQuaGludHNWYWxpZCA9IGZhbHNlOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBmdW5jSWQgPSBmdW5jdGlvbnNDYWxsZWQucG9wKCk7CiAgICAgICAgICAgIGRhdGEgPSBwYy5kYXRhOwogICAgICAgICAgICBpID0gcGMuaTsKICAgICAgICAgICAgdHRDb250ZXh0LmZ1bmN0aW9uc1N0YWNrRGVsdGFzW2Z1bmNJZF0gPSBzdGFjay5sZW5ndGggLSBwYy5zdGFja1RvcDsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgaWYgKG9wID09PSAweDg5KSB7CiAgICAgICAgICBpZiAoaW5GREVGIHx8IGluRUxTRSkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlRUOiBuZXN0ZWQgSURFRnMgbm90IGFsbG93ZWQiKTsKICAgICAgICAgICAgdG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICAgIGluRkRFRiA9IHRydWU7CiAgICAgICAgICBsYXN0RGVmZiA9IGk7CiAgICAgICAgfSBlbHNlIGlmIChvcCA9PT0gMHg1OCkgewogICAgICAgICAgKytpZkxldmVsOwogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MWIpIHsKICAgICAgICAgIGluRUxTRSA9IGlmTGV2ZWw7CiAgICAgICAgfSBlbHNlIGlmIChvcCA9PT0gMHg1OSkgewogICAgICAgICAgaWYgKGluRUxTRSA9PT0gaWZMZXZlbCkgewogICAgICAgICAgICBpbkVMU0UgPSAwOwogICAgICAgICAgfQogICAgICAgICAgLS1pZkxldmVsOwogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MWMpIHsKICAgICAgICAgIGlmICghaW5GREVGICYmICFpbkVMU0UpIHsKICAgICAgICAgICAgY29uc3Qgb2Zmc2V0ID0gc3RhY2suYXQoLTEpOwogICAgICAgICAgICBpZiAob2Zmc2V0ID4gMCkgewogICAgICAgICAgICAgIGkgKz0gb2Zmc2V0IC0gMTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoIWluRkRFRiAmJiAhaW5FTFNFKSB7CiAgICAgICAgICBsZXQgc3RhY2tEZWx0YSA9IDA7CiAgICAgICAgICBpZiAob3AgPD0gMHg4ZSkgewogICAgICAgICAgICBzdGFja0RlbHRhID0gVFRPcHNTdGFja0RlbHRhc1tvcF07CiAgICAgICAgICB9IGVsc2UgaWYgKG9wID49IDB4YzAgJiYgb3AgPD0gMHhkZikgewogICAgICAgICAgICBzdGFja0RlbHRhID0gLTE7CiAgICAgICAgICB9IGVsc2UgaWYgKG9wID49IDB4ZTApIHsKICAgICAgICAgICAgc3RhY2tEZWx0YSA9IC0yOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG9wID49IDB4NzEgJiYgb3AgPD0gMHg3NSkgewogICAgICAgICAgICBuID0gc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGlmICghaXNOYU4obikpIHsKICAgICAgICAgICAgICBzdGFja0RlbHRhID0gLW4gKiAyOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3RhY2tEZWx0YSA8IDAgJiYgc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICBzdGFjay5wb3AoKTsKICAgICAgICAgICAgc3RhY2tEZWx0YSsrOwogICAgICAgICAgfQogICAgICAgICAgd2hpbGUgKHN0YWNrRGVsdGEgPiAwKSB7CiAgICAgICAgICAgIHN0YWNrLnB1c2goTmFOKTsKICAgICAgICAgICAgc3RhY2tEZWx0YS0tOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICB0dENvbnRleHQudG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zID0gdG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zOwogICAgICBjb25zdCBjb250ZW50ID0gW2RhdGFdOwogICAgICBpZiAoaSA+IGRhdGEubGVuZ3RoKSB7CiAgICAgICAgY29udGVudC5wdXNoKG5ldyBVaW50OEFycmF5KGkgLSBkYXRhLmxlbmd0aCkpOwogICAgICB9CiAgICAgIGlmIChsYXN0RGVmZiA+IGxhc3RFbmRmKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogY29tcGxlbWVudGluZyBhIG1pc3NpbmcgZnVuY3Rpb24gdGFpbCIpOwogICAgICAgIGNvbnRlbnQucHVzaChuZXcgVWludDhBcnJheShbMHgyMiwgMHgyZF0pKTsKICAgICAgfQogICAgICBmb2xkVFRUYWJsZSh0YWJsZSwgY29udGVudCk7CiAgICB9CiAgICBmdW5jdGlvbiBjaGVja0ludmFsaWRGdW5jdGlvbnModHRDb250ZXh0LCBtYXhGdW5jdGlvbkRlZnMpIHsKICAgICAgaWYgKHR0Q29udGV4dC50b29Db21wbGV4VG9Gb2xsb3dGdW5jdGlvbnMpIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgaWYgKHR0Q29udGV4dC5mdW5jdGlvbnNEZWZpbmVkLmxlbmd0aCA+IG1heEZ1bmN0aW9uRGVmcykgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiVFQ6IG1vcmUgZnVuY3Rpb25zIGRlZmluZWQgdGhhbiBleHBlY3RlZCIpOwogICAgICAgIHR0Q29udGV4dC5oaW50c1ZhbGlkID0gZmFsc2U7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGZvciAobGV0IGogPSAwLCBqaiA9IHR0Q29udGV4dC5mdW5jdGlvbnNVc2VkLmxlbmd0aDsgaiA8IGpqOyBqKyspIHsKICAgICAgICBpZiAoaiA+IG1heEZ1bmN0aW9uRGVmcykgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogaW52YWxpZCBmdW5jdGlvbiBpZDogIiArIGopOwogICAgICAgICAgdHRDb250ZXh0LmhpbnRzVmFsaWQgPSBmYWxzZTsKICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgaWYgKHR0Q29udGV4dC5mdW5jdGlvbnNVc2VkW2pdICYmICF0dENvbnRleHQuZnVuY3Rpb25zRGVmaW5lZFtqXSkgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogdW5kZWZpbmVkIGZ1bmN0aW9uOiAiICsgaik7CiAgICAgICAgICB0dENvbnRleHQuaGludHNWYWxpZCA9IGZhbHNlOwogICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgZnVuY3Rpb24gZm9sZFRUVGFibGUodGFibGUsIGNvbnRlbnQpIHsKICAgICAgaWYgKGNvbnRlbnQubGVuZ3RoID4gMSkgewogICAgICAgIGxldCBuZXdMZW5ndGggPSAwOwogICAgICAgIGxldCBqLCBqajsKICAgICAgICBmb3IgKGogPSAwLCBqaiA9IGNvbnRlbnQubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgICAgbmV3TGVuZ3RoICs9IGNvbnRlbnRbal0ubGVuZ3RoOwogICAgICAgIH0KICAgICAgICBuZXdMZW5ndGggPSBuZXdMZW5ndGggKyAzICYgfjM7CiAgICAgICAgY29uc3QgcmVzdWx0ID0gbmV3IFVpbnQ4QXJyYXkobmV3TGVuZ3RoKTsKICAgICAgICBsZXQgcG9zID0gMDsKICAgICAgICBmb3IgKGogPSAwLCBqaiA9IGNvbnRlbnQubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgICAgcmVzdWx0LnNldChjb250ZW50W2pdLCBwb3MpOwogICAgICAgICAgcG9zICs9IGNvbnRlbnRbal0ubGVuZ3RoOwogICAgICAgIH0KICAgICAgICB0YWJsZS5kYXRhID0gcmVzdWx0OwogICAgICAgIHRhYmxlLmxlbmd0aCA9IG5ld0xlbmd0aDsKICAgICAgfQogICAgfQogICAgZnVuY3Rpb24gc2FuaXRpemVUVFByb2dyYW1zKGZwZ20sIHByZXAsIGN2dCwgbWF4RnVuY3Rpb25EZWZzKSB7CiAgICAgIGNvbnN0IHR0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ICJdOwogICAgICB0aGlzLmlzT3BlblR5cGUgPSB0cnVlOwogICAgfSBlbHNlIHsKICAgICAgaWYgKCF0YWJsZXMubG9jYSkgewogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcignUmVxdWlyZWQgImxvY2EiIHRhYmxlIGlzIG5vdCBmb3VuZCcpOwogICAgICB9CiAgICAgIGlmICghdGFibGVzLmdseWYpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoJ1JlcXVpcmVkICJnbHlmIiB0YWJsZSBpcyBub3QgZm91bmQgLS0gdHJ5aW5nIHRvIHJlY292ZXIuJyk7CiAgICAgICAgdGFibGVzLmdseWYgPSB7CiAgICAgICAgICB0YWc6ICJnbHlmIiwKICAgICAgICAgIGRhdGE6IG5ldyBVaW50OEFycmF5KDApCiAgICAgICAgfTsKICAgICAgfQogICAgICB0aGlzLmlzT3BlblR5cGUgPSBmYWxzZTsKICAgIH0KICAgIGlmICghdGFibGVzLm1heHApIHsKICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCdSZXF1aXJlZCAibWF4cCIgdGFibGUgaXMgbm90IGZvdW5kJyk7CiAgICB9CiAgICBmb250LnBvcyA9IChmb250LnN0YXJ0IHx8IDApICsgdGFibGVzLm1heHAub2Zmc2V0OwogICAgY29uc3QgdmVyc2lvbiA9IGZvbnQuZ2V0SW50MzIoKTsKICAgIGNvbnN0IG51bUdseXBocyA9IGZvbnQuZ2V0VWludDE2KCk7CiAgICBpZiAocHJvcGVydGllcy5zY2FsZUZhY3RvcnMgJiYgcHJvcGVydGllcy5zY2FsZUZhY3RvcnMubGVuZ3RoID09PSBudW1HbHlwaHMgJiYgaXNUcnVlVHlwZSkgewogICAgICBjb25zdCB7CiAgICAgICAgc2NhbGVGYWN0b3JzCiAgICAgIH0gPSBwcm9wZXJ0aWVzOwogICAgICBjb25zdCBpc0dseXBoTG9jYXRpb25zTG9uZyA9IGludDE2KHRhYmxlcy5oZWFkLmRhdGF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iAgICAgICAgY29uc3QgbHNiID0gTWF0aC5yb3VuZChzY2FsZUZhY3RvcnNbaV0gKiBzaWduZWRJbnQxNihtZXRyaWNzW2ogKyAyXSwgbWV0cmljc1tqICsgM10pKTsKICAgICAgICB3cml0ZVNpZ25lZEludDE2KG1ldHJpY3MsIGogKyAyLCBsc2IpOwogICAgICB9CiAgICB9CiAgICBsZXQgbnVtR2x5cGhzT3V0ID0gbnVtR2x5cGhzICsgMTsKICAgIGxldCBkdXBGaXJzdEVudHJ5ID0gdHJ1ZTsKICAgIGlmIChudW1HbHlwaHNPdXQgPiAweGZmZmYpIHsKICAgICAgZHVwRmlyc3RFbnRyeSA9IGZhbHNlOwogICAgICBudW1HbHlwaHNPdXQgPSBudW1HbHlwaHM7CiAgICAgICgwLCBfdXRpbC53YXJuKSgiTm90IGVub3VnaCBzcGFjZSBpbiBnbHlmcyB0byBkdXBsaWNhdGUgZmlyc3QgZ2x5cGguIik7CiAgICB9CiAgICBsZXQgbWF4RnVuY3Rpb25EZWZzID0gMDsKICAgIGxldCBtYXhTaXplT2ZJbnN0cnVjdGlvbnMgPSAwOwogICAgaWYgKHZlcnNpb24gPj0gMHgwMDAxMDAwMCAmJiB0YWJsZXMubWF4cC5sZW5ndGggPj0gMjIpIHsKICAgICAgZm9udC5wb3MgKz0gODsKICAgICAgY29uc3QgbWF4Wm9uZXMgPSBmb250LmdldFVpbnQxNigpOwogICAgICBpZiAobWF4Wm9uZXMgPiAyKSB7CiAgICAgICAgdGFibGVzLm1heHAuZGF0YVsxNF0gPSAwOwogICAgICAgIHRhYmxlcy5tYXhwLmRhdGFbMTVdID0gMjsKICAgICAgfQogICAgICBmb250LnBvcyArPSA0OwogICAgICBtYXhGdW5jdGlvbkRlZnMgPSBmb250LmdldFVpbnQxNigpOwogICAgICBmb250LnBvcyArPSA0OwogICAgICBtYXhTaXplT2ZJbnN0cnVjdGlvbnMgPSBmb250LmdldFVpbnQxNigpOwogICAgfQogICAgdGFibGVzLm1heHAuZG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uTWFjUm9tYW5FbmNvZGluZy5pbmRleE9mKHN0YW5kYXJkR2x5cGhOYW1lKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh1bmljb2RlT3JDaGFyQ29kZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgIGlmICghcHJvcGVydGllcy5nbHlwaE5hbWVzICYmIHByb3BlcnRpZXMuaGFzSW5jbHVkZWRUb1VuaWNvZGVNYXAgJiYgISh0aGlzLnRvVW5pY29kZSBpbnN0YW5jZW9mIF90b191bmljb2RlX21hcC5JZGVudGl0eVRvVW5pY29kZU1hcCkpIHsKICAgICAgICAgICAgICBjb25zdCB1bmljb2RlID0gdGhpcy50b1VuaWNvZGUuZ2V0KGNoYXJDb2RlKTsKICAgICAgICAgICAgICBpZiAodW5pY29kZSkgewogICAgICAgICAgICAgICAgdW5pY29kZU9yQ2hhckNvZGUgPSB1bmljb2RlLmNvZGVQb2ludEF0KDApOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodW5pY29kZU9yQ2hhckNvZGUgPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBmb3IgKGNvbnN0IG1hcHBpbmcgb2YgY21hcE1hcHBpbmdzKSB7CiAgICAgICAgICAgIGlmIChtYXBwaW5nLmNoYXJDb2RlICE9PSB1bmljb2RlT3JDaGFyQ29kZSkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNoYXJDb2RlVG9HbHlwaElkW2NoYXJDb2RlXSA9IG1hcHBpbmcuZ2x5cGhJZDsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGNtYXBQbGF0Zm9ybUlkID09PSAwKSB7CiAgICAgICAgZm9yIChjb25zdCBtYXBwaW5nIG9mIGNtYXBNYXBwaW5nc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gaWYgKCFwcm9wZXJ0aWVzLmNvbXBvc2l0ZSkgewogICAgICAgIGFkanVzdFRydWVUeXBlVG9Vbmljb2RlKHByb3BlcnRpZXMsIHRoaXMuaXNTeW1ib2xpY0ZvbnQsIG5hbWVSZWNvcmRzKTsKICAgICAgfQogICAgfQogICAgY29uc3QgYnVpbGRlciA9IG5ldyBfb3BlbnR5cGVfZmlsZV9idWlsZGVyLk9wZW5UeXBlRmlsZUJ1aWxkZXIoaGVhZGVyLnZlcnNpb24pOwogICAgZm9yIChjb25zdCB0YWJsZVRhZyBpbiB0YWJsZXMpIHsKICAgICAgYnVpbGRlci5hZGRUYWJsZSh0YWJsZVRhZywgdGFibGVzW3RhYmxlVGFnXS5kYXRhKTsKICAgIH0KICAgIHJldHVybiBidWlsZGVyLnRvQXJyYXkoKTsKICB9CiAgY29udmVydChmb250TmFtZSwgZm9udCwgcHJvcGVydGllcykgewogICAgcHJvcGVydGllcy5maXhlZFBpdGNoID0gZmFsc2U7CiAgICBpZiAocHJvcGVydGllcy5idWlsdEluRW5jb2RpbmcpIHsKICAgICAgYWRqdXN0VHlwZTFUb1VuaWNvZGUocHJvcGVydGllcywgcHJvcGVydGllcy5idWlsdEluRW5jb2RpbmcpOwogICAgfQogICAgbGV0IGdseXBoWmVyb0lkID0gMTsKICAgIGlmIChmb250IGluc3RhbmNlb2YgX2NmZl9mb250LkNGRkZvbnQpIHsKICAgICAgZ2x5cGhaZXJvSWQgPSBmb250Lm51bUdseXBocyAtIDE7CiAgICB9CiAgICBjb25zdCBtYXBwaW5nID0gZm9udC5nZXRHbHlwaE1hcHBpbmcocHJvcGVydGllcyk7CiAgICBsZXQgbmV3TWFwcGluZyA9IG51bGw7CiAgICBsZXQgbmV3Q2hhckNvZGVUb0dseXBoSWQgPSBtYXBwaW5nOwogICAgbGV0IHRvVW5pY29kZUV4dHJhTWFwID0gbnVsbDsKICAgIGlmICghcHJvcGVydGllcy5jc3NGb250SW5mbykgewogICAgICBuZXdNYXBwaW5nID0gYWRqdXN0TWFwcGluZyhtYXBwaW5nLCBmb250Lmhhc0dseXBoSWQuYmluZChmb250KSwgZ2x5cGhaZXJvSWQsIHRoaXMudG9Vbmljb2RlKTsKICAgICAgdGhpcy50b0ZvbnRDaGFyID0gbmV3TWFwcGluZy50b0ZvbnRDaGFyOwogICAgICBuZXdDaGFyQ29kZVRvR2x5cGhJZCA9IG5ld01hcHBpbmcuY2hhckNvZGVUb0dseXBoSWQ7CiAgICAgIHRvVW5pY29kZUV4dHJhTWFwID0gbmV3TWFwcGluZy50b1VuaWNvZGVFeHRyYU1hcDsKICAgIH0KICAgIGNvbnN0IG51bUdseXBocyA9IGZvbnQubnVtR2x5cGhzOwogICAgZnVuY3Rpb24gZ2V0Q2hhckNvZGVzKGNoYXJDb2RlVG9HbHlwaElkLCBnbHlwaElkKSB7CiAgICAgIGxldCBjaGFyQ29kZXMgPSBudWxsOwogICAgICBmb3IgKGNvbnN0IGNoYXJDb2RlIGluIGNoYXJDb2RlVG9HbHlwaElkKSB7CiAgICAgICAgaWYgKGdseXBoSWQgPT09IGNoYXJDb2RlVG9HbHlwaElkW2NoYXJDb2RlXSkgewogICAgICAgICAgaWYgKCFjaGFyQ29kZXMpIHsKICAgICAgICAgICAgY2hhckNvZGVzID0gW107CiAgICAgICAgICB9CiAgICAgICAgICBjaGFyQ29kZXMucHVzaChjaGFyQ29kZSB8IDApOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gY2hhckNvZGVzOwogICAgfQogICAgZnVuY3Rpb24gY3JlYXRlQ2hhckNvZGUoY2hhckNvZGVUb0dseXBoSWQsIGdseXBoSWQpIHsKICAgICAgZm9yIChjb25zdCBjaGFyQ29kZSBpbiBjaGFyQ29kZVRvR2x5cGhJZCkgewogICAgICAgIGlmIChnbHlwaElkID09PSBjaGFyQ29kZVRvR2x5cGhJZFtjaGFyQ29kZV0pIHsKICAgICAgICAgIHJldHVybiBjaGFyQ29kZSB8IDA7CiAgICAgICAgfQogICAgICB9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ICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBjb25zdCBhY2NlbnRPZmZzZXQgPSB7CiAgICAgICAgICB4OiBzZWFjWzBdICogbWF0cml4WzBdICsgc2VhY1sxXSAqIG1hdHJpeFsyXSArIG1hdHJpeFs0XSwKICAgICAgICAgIHk6IHNlYWNbMF0gKiBtYXRyaXhbMV0gKyBzZWFjWzFdICogbWF0cml4WzNdICsgbWF0cml4WzVdCiAgICAgICAgfTsKICAgICAgICBjb25zdCBjaGFyQ29kZXMgPSBnZXRDaGFyQ29kZXMobWFwcGluZywgZ2x5cGhJZCk7CiAgICAgICAgaWYgKCFjaGFyQ29kZXMpIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBmb3IgKGNvbnN0IGNoYXJDb2RlIG9mIGNoYXJDb2RlcykgewogICAgICAgICAgY29uc3QgY2hhckNvZGVUb0dseXBoSWQgPSBuZXdNYXBwaW5nLmNoYXJDb2RlVG9HbHlwaElkOwogICAgICAgICAgY29uc3QgYmFzZUZvbnRDaGFyQ29kZSA9IGNyZWF0ZUNoYXJDb2RlKGNoYXJDb2RlVG9HbHlwaElkLCBiYXNlR2x5cGhJZCk7CiAgICAgICAgICBjb25zdCBhY2NlbnRGb250Q2hhckNvZGUgPSBjcmVhdGVDaGFyQ29kZShjaGFyQ29kZVRvR2x5cGhJZCwgYWNjZW50R2x5cGhJZCk7CiAgICAgICAgICBzZWFjTWFwW2NoYXJDb2RlXSA9IHsKICAgICAgICAgICAgYmFzZUZvbnRDaGFyQ29kZSwKICAgICAgICAgICAgYWNjZW50Rm9udENoYXJDb2RlLAogICAgICAgICAgICBhY2NlbnRPZmZzZXQKICAgICAgICAgIH07CiAgICAgICAgfQogICAgICB9CiAgICAgIHByb3BlcnRpZXMuc2VhY01hcCA9IHNlYWNNYXA7CiAgICB9CiAgICBjb25zdCB1bml0c1BlckVtID0gMSAvIChwcm9wZXJ0aWVzLmZvbnRNYXRyaXggfHwgX3V0aWw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2KHByb3BlcnRpZXMuYXNjZW50KSArIHNhZmVTdHJpbmcxNihwcm9wZXJ0aWVzLmRlc2NlbnQpICsgIlx4MDBceDAwIiArICJceEZGXHhGRiIgKyAiXHgwMFx4MDAiICsgIlx4MDBceDAwIiArICJceDAwXHgwMCIgKyBzYWZlU3RyaW5nMTYocHJvcGVydGllcy5jYXBIZWlnaHQpICsgc2FmZVN0cmluZzE2KE1hdGgudGFuKHByb3BlcnRpZXMuaXRhbGljQW5nbGUpICogcHJvcGVydGllcy54SGVpZ2h0KSArICJceDAwXHgwMCIgKyAiXHgwMFx4MDAiICsgIlx4MDBceDAwIiArICJceDAwXHgwMCIgKyAiXHgwMFx4MDAiICsgIlx4MDBceDAwIiArIHN0cmluZzE2KG51bUdseXBocykpOwogICAgYnVpbGRlci5hZGRUYWJsZSgiaG10eCIsIGZ1bmN0aW9uIGZvbnRGaWVsZHNIbXR4KCkgewogICAgICBjb25zdCBjaGFyc3RyaW5ncyA9IGZvbnQuY2hhcnN0cmluZ3M7CiAgICAgIGNvbnN0IGNmZldpZHRocyA9IGZvbnQuY2ZmID8gZm9udC5jZmYud2lkdGhzIDogbnVsbDsKICAgICAgbGV0IGhtdHggPSAiXHgwMFx4MDBceDAwXHgwMCI7CiAgICAgIGZvciAobGV0IGkgPSAxLCBpaSA9IG51bUdseXBoczsgaSA8IGlpOyBpKyspIHsKICAgICAgICBsZXQgd2lkdGggPSAwOwogICAgICAgIGlmIChjaGFyc3RyaW5ncykgewogICAgICAgICAgY29uc3QgY2hhcnN0cmluZyA9IGNoYXJzdHJpbmdzW2kgLSAxXTsKICAgICAgICAgIHdpZHRoID0gIndpZHRoIiBpbiBjaGFyc3RyaW5nID8gY2hhcnN0cmluZy53aWR0aCA6IDA7CiAgICAgICAgfSBlbHNlIGlmIChjZmZXaWR0aHMpIHsKICAgICAgICAgIHdpZHRoID0gTWF0aC5jZWlsKGNmZldpZHRoc1tpXSB8fCAwKTsKICAgICAgICB9CiAgICAgICAgaG10eCAr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TGlzdElkLCBpc1NwYWNlLCBpc0luRm9udCk7CiAgICByZXR1cm4gdGhpcy5fZ2x5cGhDYWNoZVtjaGFyY29kZV0gPSBnbHlwaDsKICB9CiAgY2hhcnNUb0dseXBocyhjaGFycykgewogICAgbGV0IGdseXBocyA9IHRoaXMuX2NoYXJzQ2FjaGVbY2hhcnNdOwogICAgaWYgKGdseXBocykgewogICAgICByZXR1cm4gZ2x5cGhzOwogICAgfQogICAgZ2x5cGhzID0gW107CiAgICBpZiAodGhpcy5jTWFwKSB7CiAgICAgIGNvbnN0IGMgPSBPYmplY3QuY3JlYXRlKG51bGwpLAogICAgICAgIGlpID0gY2hhcnMubGVuZ3RoOwogICAgICBsZXQgaSA9IDA7CiAgICAgIHdoaWxlIChpIDwgaWkpIHsKICAgICAgICB0aGlzLmNNYXAucmVhZENoYXJDb2RlKGNoYXJzLCBpLCBjKTsKICAgICAgICBjb25zdCB7CiAgICAgICAgICBjaGFyY29kZSwKICAgICAgICAgIGxlbmd0aAogICAgICAgIH0gPSBjOwogICAgICAgIGkgKz0gbGVuZ3RoOwogICAgICAgIGNvbnN0IGdseXBoID0gdGhpcy5fY2hhclRvR2x5cGgoY2hhcmNvZGUsIGxlbmd0aCA9PT0gMSAmJiBjaGFycy5jaGFyQ29kZUF0KGkgLSAxKSA9PT0gMHgyMCk7CiAgICAgICAgZ2x5cGhzLnB1c2goZ2x5cGgpOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBjaGFycy5sZW5ndGg7IGkgPCBpaTsgKytpKSB7CiAgICAgICAgY29uc3QgY2hhcmNvZGUgPSBjaGFycy5jaGFyQ29kZUF0KGkpOwogICAgICAgIGNvbnN0IGdseXBoID0gdGhpcy5fY2hhclRvR2x5cGgoY2hhcmNvZGUsIGNoYXJjb2RlID09PSAweDIwKTsKICAgICAgICBnbHlwaHMucHVzaChnbHlwaCk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiB0aGlzLl9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T4gdGhpcy50b1VuaWNvZGUuY2hhckNvZGVPZihTdHJpbmcuZnJvbUNvZGVQb2ludCh1bmljb2RlKSk7CiAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBzdHIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICBjb25zdCB1bmljb2RlID0gc3RyLmNvZGVQb2ludEF0KGkpOwogICAgICBpZiAodW5pY29kZSA+IDB4ZDdmZiAmJiAodW5pY29kZSA8IDB4ZTAwMCB8fCB1bmljb2RlID4gMHhmZmZkKSkgewogICAgICAgIGkrKzsKICAgICAgfQogICAgICBpZiAodGhpcy50b1VuaWNvZGUpIHsKICAgICAgICBjb25zdCBjaGFyQ29kZSA9IGdldENoYXJDb2RlKHVuaWNvZGUpOwogICAgICAgIGlmIChjaGFyQ29kZSAhPT0gLTEpIHsKICAgICAgICAgIGlmIChoYXNDdXJyZW50QnVmRXJyb3JzKCkpIHsKICAgICAgICAgICAgYnVmZmVycy5wdXNoKGN1cnJlbnRCdWYuam9pbigiIikpOwogICAgICAgICAgICBjdXJyZW50QnVmLmxlbmd0aCA9IDA7CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCBjaGFyQ29kZUxlbmd0aCA9IHRoaXMuY01hcCA/IHRoaXMuY01hcC5nZXRDaGFyQ29kZUxlbmd0aChjaGFyQ29kZSkgOiAxOwogICAgICAgICAgZm9yIChsZXQgaiA9IGNoYXJDb2RlTGVuZ3RoIC0gMTsgaiA+PSAwOyBqLS0pIHsKICAgICAgICAgICAgY3VycmVudEJ1Zi5wdXNoKFN0cmluZy5mcm9tQ2hhckNvZGUoY2hhckNvZGUgPj4gOCAqIGogJiAweGZmKSk7CiAgICAgICAgICB9CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCFoYXNDdXJyZW50QnVmRXJyb3JzKCkpIHsKICAgICAgICBidWZmZXJzLnB1c2goY3VycmVudEJ1Zi5qb2luKCIiKSk7CiAgICAgICAgY3VycmV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VlID49IDI0NyAmJiB2YWx1ZSA8PSAyNTApIHsKICAgICAgICByZXR1cm4gKHZhbHVlIC0gMjQ3KSAqIDI1NiArIGRpY3RbcG9zKytdICsgMTA4OwogICAgICB9IGVsc2UgaWYgKHZhbHVlID49IDI1MSAmJiB2YWx1ZSA8PSAyNTQpIHsKICAgICAgICByZXR1cm4gLSgodmFsdWUgLSAyNTEpICogMjU2KSAtIGRpY3RbcG9zKytdIC0gMTA4OwogICAgICB9CiAgICAgICgwLCBfdXRpbC53YXJuKSgnQ0ZGUGFyc2VyX3BhcnNlRGljdDogIicgKyB2YWx1ZSArICciIGlzIGEgcmVzZXJ2ZWQgY29tbWFuZC4nKTsKICAgICAgcmV0dXJuIE5hTjsKICAgIH0KICAgIGZ1bmN0aW9uIHBhcnNlRmxvYXRPcGVyYW5kKCkgewogICAgICBsZXQgc3RyID0gIiI7CiAgICAgIGNvbnN0IGVvZiA9IDE1OwogICAgICBjb25zdCBsb29rdXAgPSBbIjAiLCAiMSIsICIyIiwgIjMiLCAiNCIsICI1IiwgIjYiLCAiNyIsICI4IiwgIjkiLCAiLiIsICJFIiwgIkUtIiwgbnVsbCwgIi0iXTsKICAgICAgY29uc3QgbGVuZ3RoID0gZGljdC5sZW5ndGg7CiAgICAgIHdoaWxlIChwb3MgPCBsZW5ndGgpIHsKICAgICAgICBjb25zdCBiID0gZGljdFtwb3MrK107CiAgICAgICAgY29uc3QgYjEgPSBiID4+IDQ7CiAgICAgICAgY29uc3QgYjIgPSBiICYgMTU7CiAgICAgICAgaWYgKGIxID09PSBlb2YpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBzdHIgKz0gbG9va3VwW2IxXTsKICAgICAgICBpZiAoYjIgPT09IGVvZikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIHN0ciArPSBsb29rdXBbYjJdOwogICAgICB9CiAgICAgIHJldHVybiBwYXJzZUZsb2F0KHN0cik7CiAgICB9CiAgICBsZXQgb3BlcmFuZHMgPSBbXTsKICAgIGNvbnN0IGVudHJpZXMgPSBbXTsKICAgIHBvcyA9IDA7CiAgICBjb25zdCBlbmQgPSBkaWN0Lmxlbmd0aDsKICAgIHdoaWxlIChwb3MgPCBlbmQpIHsKICAgICAgbGV0IGIgPSBkaWN0W3Bvc107CiAgICAgIGlmIChiIDw9IDIxKSB7CiAgICAgICAgaWYgKGIgPT09IDEyKSB7CiAgICAgICAgICBiID0gYiA8PCA4IHwgZGljdFsrK3Bvc107CiAgICAgICAgfQogICAgICAgIGVudHJpZXMucHVzaChbYiwgb3BlcmFuZHNdKTsKICAgICAgICBvcGVyYW5kcyA9IFtdOwogICAgICAgICsrcG9zOwogICAgICB9IGVsc2UgewogICAgICAgIG9wZXJhbmRzLnB1c2gocGFyc2VPcGVyYW5kKCkpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gZW50cmllczsKICB9CiAgcGFyc2VJbmRleChwb3MpIHsKICAgIGNvbnN0IGNmZkluZGV4ID0gbmV3IENGRkluZGV4KCk7CiAgICBjb25zdCBieXRlcyA9IHRoaXMuYnl0ZXM7CiAgICBjb25zdCBjb3VudCA9IGJ5dGVzW3BvcysrXSA8PCA4IHwgYnl0ZXNbcG9zKytdOwogICAgY29uc3Qgb2Zmc2V0cyA9IFtdOwogICAgbGV0IGVuZCA9IHBvczsKICAgIGxldCBpLCBpaTsKICAgIGlmIChjb3VudCAhPT0gMCkgewogICAgICBjb25zdCBvZmZzZXRTaXplID0gYnl0ZXNbcG9zKytdOwogICAgICBjb25zdCBzdGFydFBvcyA9IHBvcyArIChjb3VudCArIDEpICogb2Zmc2V0U2l6ZSAtIDE7CiAgICAgIGZvciAoaSA9IDAsIGlpID0gY291bnQgKyAxOyBpIDwgaWk7ICsraSkgewogICAgICAgIGxldCBvZmZzZXQgPSAwOwogICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgb2Zmc2V0U2l6ZTsgKytqKSB7CiAgICAgICAgICBvZmZzZXQgPDw9IDg7C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ICAgICAgICBzdGFja1NpemUrKzsKICAgICAgfSBlbHNlIGlmICh2YWx1ZSA9PT0gMTkgfHwgdmFsdWUgPT09IDIwKSB7CiAgICAgICAgc3RhdGUuaGludHMgKz0gc3RhY2tTaXplID4+IDE7CiAgICAgICAgaiArPSBzdGF0ZS5oaW50cyArIDcgPj4gMzsKICAgICAgICBzdGFja1NpemUgJT0gMjsKICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZCA9IENoYXJzdHJpbmdWYWxpZGF0aW9uRGF0YVt2YWx1ZV07CiAgICAgIH0gZWxzZSBpZiAodmFsdWUgPT09IDEwIHx8IHZhbHVlID09PSAyOSkgewogICAgICAgIGxldCBzdWJyc0luZGV4OwogICAgICAgIGlmICh2YWx1ZSA9PT0gMTApIHsKICAgICAgICAgIHN1YnJzSW5kZXggPSBsb2NhbFN1YnJJbmRleDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgc3VicnNJbmRleCA9IGdsb2JhbFN1YnJJbmRleDsKICAgICAgICB9CiAgICAgICAgaWYgKCFzdWJyc0luZGV4KSB7CiAgICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZCA9IENoYXJzdHJpbmdWYWxpZGF0aW9uRGF0YVt2YWx1ZV07CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIk1pc3Npbmcgc3VicnNJbmRleCBmb3IgIiArIHZhbGlkYXRpb25Db21tYW5kLmlkKTsKICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgICAgbGV0IGJpYXMgPSAzMjc2ODsKICAgICAgICBpZiAoc3VicnNJbmRleC5jb3VudCA8IDEyNDApIHsKICAgICAgICAgIGJpYXMgPSAxMDc7CiAgICAgICAgfSBlbHNlIGlmIChzdWJyc0luZGV4LmNvdW50IDwgMzM5MDApIHsKICAgICAgICAgIGJpYXMgPSAxMTMxOwogICAgICAgIH0KICAgICAgICBjb25zdCBzdWJyTnVtYmVyID0gc3RhY2tbLS1zdGFja1NpemVdICsgYmlhczsKICAgICAgICBpZiAoc3Vick51bWJlciA8IDAgfHwgc3Vick51bWJlciA+PSBzdWJyc0luZGV4LmNvdW50IHx8IGlzTmFOKHN1YnJOdW1iZXIpKSB7CiAgICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZCA9IENoYXJzdHJpbmdWYWxpZGF0aW9uRGF0YVt2YWx1ZV07CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIk91dCBvZiBib3VuZHMgc3VickluZGV4IGZvciAiICsgdmFsaWRhdGlvbkNvbW1hbmQuaWQpOwogICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgICBzdGF0ZS5zdGFja1NpemUgPSBzdGFja1NpemU7CiAgICAgICAgc3RhdGUuY2FsbERlcHRoKys7CiAgICAgICAgY29uc3QgdmFsaWQgPSB0aGlzLnBhcnNlQ2hhclN0cmluZyhzdGF0ZSwgc3VicnNJbmRleC5nZXQoc3Vick51bWJlciksIGxvY2FsU3VickluZGV4LCBnbG9iYWxTdWJySW5kZXgpOwogICAgICAgIGlmICghdmFsaWQpIHsKICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgICAgc3RhdGUuY2FsbERlcHRoLS07CiAgICAgICAgc3RhY2tTaXplID0gc3RhdGUuc3RhY2tTaXplOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgaWYgKHZhbHVlID09PSAxMSkgewogICAgICAgIHN0YXRlLnN0YWNrU2l6ZSA9IHN0YWNrU2l6ZTsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfSBlbHNlIGlmICh2YWx1ZSA9PT0gMCAmJiBqID09PSBkYXRhLmxlbmd0aCkgewogICAgICAgIGRhdGFbaiAtIDFdID0gMTQ7CiAgICAgICAgdmFsaWRhdGlvbkNvbW1hbmQgPSBDaGFyc3RyaW5nVmFsaWRhdGlvbkRhdGFbMTRdOwogICAgICB9IGVsc2UgaWYgKHZhbHVlID09PSA5KSB7CiAgICAgICAgZGF0YS5jb3B5V2l0aGluKGogLSAxLCBqLCAtMSk7CiAgICAgICAgaiAtPSAxOwogICAgICAgIGxlbmd0aCAtPSAxOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgewogICAgICAgIHZhbGlkYXRpb25Db21tYW5kID0gQ2hhcnN0cmluZ1ZhbGlkYXRpb25EYXRhW3ZhbHVlXTsKICAgICAgfQogICAgICBpZiAodmFsaWRhdGlvbkNvbW1hbmQpIHsKICAgICAgICBpZiAodmFsaWRhdGlvbkNvbW1hbmQuc3RlbSkgewogICAgICAgICAgc3RhdGUuaGludHMgKz0gc3RhY2tTaXplID4+IDE7CiAgICAgICAgICBpZiAodmFsdWUgPT09IDMgfHwgdmFsdWUgPT09IDIzKSB7CiAgICAgICAgICAgIHN0YXRlLmhhc1ZTdGVtcyA9IHRydWU7CiAgICAgICAgICB9IGVsc2UgaWYgKHN0YXRlLmhhc1ZTdGVtcyAmJiAodmFsdWUgPT09IDEgfHwgdmFsdWUgPT09IDE4KSkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIkNGRiBzdGVtIGhpbnRzIGFyZSBpbiB3cm9uZyBvcmRlciIpOwogICAgICAgICAgICBkYXRhW2ogLSAxXSA9IHZhbHVlID09PSAxID8gMyA6IDIzOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoIm1pbiIgaW4gdmFsaWRhdGlvbkNvbW1hbmQpIHsKICAgICAgICAgIGlmICghc3RhdGUudW5kZWZTdGFjayAmJiBzdGFja1NpemUgPCB2YWxpZGF0aW9uQ29tbWFuZC5taW4pIHsKICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJOb3QgZW5vdWdoIHBhcmFtZXRlcnMgZm9yICIgKyB2YWxpZGF0aW9uQ29tbWFuZC5pZCArICI7IGFjdHVhbDogIiArIHN0YWNrU2l6ZSArICIsIGV4cGVjdGVkOiAiICsgdmFsaWRhdGlvbkNvbW1hbmQubWluKTsKICAgICAgICAgICAgaWYgKHN0YWNrU2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgIGRhdGFbaiAtIDFdID0gMTQ7CiAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc3RhdGUuZmlyc3RTdGFja0NsZWFyaW5nICYmIHZhbGlkYXRpb25Db21tYW5kLnN0YWNrQ2xlYXJpbmcpIHsKICAgICAgICAgIHN0YXRlLmZpcnN0U3RhY2tDbGVhcmluZyA9IGZhbHNlOwogICAgICAgICAgc3RhY2tTaXplIC09IHZhbGlkYXRpb25Db21tYW5kLm1pbjsKICAgICAgICAgIGlmIChzdGFja1NpemUgPj0gMiAmJiB2YWxpZGF0aW9uQ29tbWFuZC5zdGVtKSB7CiAgICAgICAgICAgIHN0YWNrU2l6ZSAlPSAyOwogICAgICAgICAgfSBlbHNlIGlmIChzdGFja1NpemUgPiAxKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiRm91bmQgdG9vIG1hbnkgcGFyYW1ldGVycyBmb3Igc3RhY2stY2xlYXJpbmcgY29tbWFuZCIpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHN0YWNrU2l6ZSA+IDApIHsKICAgICAgICAgICAgc3RhdGUud2lkdGggPSBzdGFja1tzdGFja1NpemUgLSAxXTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKCJzdGFja0RlbHRhIiBpbiB2YWxpZGF0aW9uQ29tbWFuZCkgewogICAgICAgICAgaWYgKCJzdGFja0ZuIiBpbiB2YWxpZGF0aW9uQ29tbWFuZCkgewogICAgICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZC5zdGFja0ZuKHN0YWNrLCBzdGFja1NpemUpOwogICAgICAgICAgfQogICAgICAgICAgc3RhY2tTaXplICs9IHZhbGlkYXRpb25Db21tYW5kLnN0YWNrRGVsdGE7CiAgICAgICAgfSBlbHNl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VwdGg6IDAsCiAgICAgICAgc3RhY2tTaXplOiAwLAogICAgICAgIHN0YWNrOiBbXSwKICAgICAgICB1bmRlZlN0YWNrOiB0cnVlLAogICAgICAgIGhpbnRzOiAwLAogICAgICAgIGZpcnN0U3RhY2tDbGVhcmluZzogdHJ1ZSwKICAgICAgICBzZWFjOiBudWxsLAogICAgICAgIHdpZHRoOiBudWxsLAogICAgICAgIGhhc1ZTdGVtczogZmFsc2UKICAgICAgfTsKICAgICAgbGV0IHZhbGlkID0gdHJ1ZTsKICAgICAgbGV0IGxvY2FsU3ViclRvVXNlID0gbnVsbDsKICAgICAgbGV0IHByaXZhdGVEaWN0VG9Vc2UgPSBwcml2YXRlRGljdDsKICAgICAgaWYgKGZkU2VsZWN0ICYmIGZkQXJyYXkubGVuZ3RoKSB7CiAgICAgICAgY29uc3QgZmRJbmRleCA9IGZkU2VsZWN0LmdldEZESW5kZXgoaSk7CiAgICAgICAgaWYgKGZkSW5kZXggPT09IC0xKSB7CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIkdseXBoIGluZGV4IGlzIG5vdCBpbiBmZCBzZWxlY3QuIik7CiAgICAgICAgICB2YWxpZCA9IGZhbHNlOwogICAgICAgIH0KICAgICAgICBpZiAoZmRJbmRleCA+PSBmZEFycmF5Lmxlbmd0aCkgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJJbnZhbGlkIGZkIGluZGV4IGZvciBnbHlwaCBpbmRleC4iKTsKICAgICAgICAgIHZhbGlkID0gZmFsc2U7CiAgICAgICAgfQogICAgICAgIGlmICh2YWxpZCkgewogICAgICAgICAgcHJpdmF0ZURpY3RUb1VzZSA9IGZkQXJyYXlbZmRJbmRleF0ucHJpdmF0ZURpY3Q7CiAgICAgICAgICBsb2NhbFN1YnJUb1VzZSA9IHByaXZhdGVEaWN0VG9Vc2Uuc3VicnNJbmRleDsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAobG9jYWxTdWJySW5kZXgpIHsKICAgICAgICBsb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KSArIChieXRlc1twb3MrK10gJiAweGZmKTsKICAgICAgICBlbmNvZGluZ1tjb2RlXSA9IGNoYXJzZXQuaW5kZXhPZihzdHJpbmdzLmdldChzaWQpKTsKICAgICAgfQogICAgfQogICAgaWYgKHBvcyA9PT0gMCB8fCBwb3MgPT09IDEpIHsKICAgICAgcHJlZGVmaW5lZCA9IHRydWU7CiAgICAgIGZvcm1hdCA9IHBvczsKICAgICAgY29uc3QgYmFzZUVuY29kaW5nID0gcG9zID8gX2VuY29kaW5ncy5FeHBlcnRFbmNvZGluZyA6IF9lbmNvZGluZ3MuU3RhbmRhcmRFbmNvZGluZzsKICAgICAgZm9yIChpID0gMCwgaWkgPSBjaGFyc2V0Lmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb25zdCBpbmRleCA9IGJhc2VFbmNvZGluZy5pbmRleE9mKGNoYXJzZXRbaV0pOwogICAgICAgIGlmIChpbmRleCAhPT0gLTEpIHsKICAgICAgICAgIGVuY29kaW5nW2luZGV4XSA9IGk7CiAgICAgICAgfQogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBkYXRhU3RhcnQgPSBwb3M7CiAgICAgIGZvcm1hdCA9IGJ5dGVzW3BvcysrXTsKICAgICAgc3dpdGNoIChmb3JtYXQgJiAweDdmKSB7CiAgICAgICAgY2FzZSAwOgogICAgICAgICAgY29uc3QgZ2x5cGhzQ291bnQgPSBieXRlc1twb3MrK107CiAgICAgICAgICBmb3IgKGkgPSAxOyBpIDw9IGdseXBoc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgZW5jb2RpbmdbYnl0ZXNbcG9zKytdXSA9IGk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDE6CiAgICAgICAgICBjb25zdCByYW5nZXNDb3VudCA9IGJ5dGVzW3BvcysrXTsKICAgICAgICAgIGxldCBnaWQgPSAxOwogICAgICAgICAgZm9yIChpID0gMDsgaSA8IHJhbmdlc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgY29uc3Qgc3RhcnQgPSBieXRlc1twb3MrK107CiAgICAgICAgICAgIGNvbnN0IGxlZnQgPSBieXRlc1twb3MrK107CiAgICAgICAgICAgIGZvciAobGV0IGogPSBzdGFydDsgaiA8PSBzdGFydCArIGxlZnQ7IGorKykgewogICAgICAgICAgICAgIGVuY29kaW5nW2pdID0gZ2lkKys7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYFVua25vd24gZW5jb2RpbmcgZm9ybWF0OiAke2Zvcm1hdH0gaW4gQ0ZGYCk7CiAgICAgIH0KICAgICAgY29uc3QgZGF0YUVuZCA9IHBvczsKICAgICAgaWYgKGZvcm1hdCAmIDB4ODApIHsKICAgICAgICBieXRlc1tkYXRhU3RhcnRdICY9IDB4N2Y7CiAgICAgICAgcmVhZFN1cHBsZW1lbnQoKTsKICAgICAgfQogICAgICByYXcgPSBieXRlcy5zdWJhcnJheShkYXRhU3RhcnQsIGRhdGFFbmQpOwogICAgfQogICAgZm9ybWF0ICY9IDB4N2Y7CiAgICByZXR1cm4gbmV3IENGRkVuY29kaW5nKHByZWRlZmluZWQsIGZvcm1hdCwgZW5jb2RpbmcsIHJhdyk7CiAgfQogIHBhcnNlRkRTZWxlY3QocG9zLCBsZW5ndGgpIHsKICAgIGNvbnN0IGJ5dGVzID0gdGhpcy5ieXRlczsKICAgIGNvbnN0IGZvcm1hdCA9IGJ5dGVzW3BvcysrXTsKICAgIGNvbnN0IGZkU2VsZWN0ID0gW107CiAgICBsZXQgaTsKICAgIHN3aXRjaCAoZm9ybWF0KSB7CiAgICAgIGNhc2UgMDoKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbGVuZ3RoOyArK2kpIHsKICAgICAgICAgIGNvbnN0IGlkID0gYnl0ZXNbcG9zKytdOwogICAgICAgICAgZm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Y3QucmVtb3ZlQnlOYW1lKCJDSURGb250UmV2aXNpb24iKTsKICAgICAgICBmb250RGljdC5yZW1vdmVCeU5hbWUoIkNJREZvbnRUeXBlIik7CiAgICAgICAgZm9udERpY3QucmVtb3ZlQnlOYW1lKCJDSURDb3VudCIpOwogICAgICAgIGZvbnREaWN0LnJlbW92ZUJ5TmFtZSgiVUlEQmFzZSIpOwogICAgICB9CiAgICAgIGNvbnN0IGZvbnREaWN0VHJhY2tlciA9IG5ldyBDRkZPZmZzZXRUcmFja2VyKCk7CiAgICAgIGNvbnN0IGZvbnREaWN0RGF0YSA9IHRoaXMuY29tcGlsZURpY3QoZm9udERpY3QsIGZvbnREaWN0VHJhY2tlcik7CiAgICAgIGZvbnREaWN0VHJhY2tlcnMucHVzaChmb250RGljdFRyYWNrZXIpOwogICAgICBmZEFycmF5SW5kZXguYWRkKGZvbnREaWN0RGF0YSk7CiAgICAgIGZvbnREaWN0VHJhY2tlci5vZmZzZXQobGVuZ3RoKTsKICAgIH0KICAgIGZkQXJyYXlJbmRleCA9IHRoaXMuY29tcGlsZUluZGV4KGZkQXJyYXlJbmRleCwgZm9udERpY3RUcmFja2Vycyk7CiAgICByZXR1cm4gewogICAgICB0cmFja2VyczogZm9udERpY3RUcmFja2VycywKICAgICAgb3V0cHV0OiBmZEFycmF5SW5kZXgKICAgIH07CiAgfQogIGNvbXBpbGVQcml2YXRlRGljdHMoZGljdHMsIHRyYWNrZXJzLCBvdXRwdXQpIHsKICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGRpY3RzLmxlbmd0aDsgaSA8IGlpOyArK2kpIHsKICAgICAgY29uc3QgZm9udERpY3QgPSBkaWN0c1tpXTsKICAgICAgY29uc3QgcHJpdmF0ZURpY3QgPSBmb250RGljdC5wcml2YXRlRGljdDsKICAgICAgaWYgKCFwcml2YXRlRGljdCB8fCAhZm9udERpY3QuaGFzTmFtZSgiUHJpdmF0ZSIpKSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsL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Y3Qub3JkZXIpIHsKICAgICAgaWYgKCEoa2V5IGluIGRpY3QudmFsdWVzKSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGxldCB2YWx1ZXMgPSBkaWN0LnZhbHVlc1trZXldOwogICAgICBsZXQgdHlwZXMgPSBkaWN0LnR5cGVzW2tleV07CiAgICAgIGlmICghQXJyYXkuaXNBcnJheSh0eXBlcykpIHsKICAgICAgICB0eXBlcyA9IFt0eXBlc107CiAgICAgIH0KICAgICAgaWYgKCFBcnJheS5pc0FycmF5KHZhbHVlcykpIHsKICAgICAgICB2YWx1ZXMgPSBbdmFsdWVzXTsKICAgICAgfQogICAgICBpZiAodmFsdWVzLmxlbmd0aCA9PT0gMCkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGZvciAobGV0IGogPSAwLCBqaiA9IHR5cGVzLmxlbmd0aDsgaiA8IGpqOyArK2opIHsKICAgICAgICBjb25zdCB0eXBlID0gdHlwZXNbal07CiAgICAgICAgY29uc3QgdmFsdWUgPSB2YWx1ZXNbal07CiAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICBjYXNlICJudW0iOgogICAgICAgICAgY2FzZSAic2lkIjoKICAgICAgICAgICAgb3V0LnB1c2goLi4udGhpcy5lbmNvZGVOdW1iZXIodmFsdWUpKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICJvZmZzZXQiOgogICAgICAgICAgICBjb25zdCBuYW1lID0gZGljdC5rZXlUb05hbWVNYXBba2V5XTsKICAgICAgICAgICAgaWYgKCFvZmZzZXRUcmFja2VyLmlzVHJhY2tpbmcobmFtZSkpIHsKICAgICAgICAgICAgICBvZmZzZXRUcmFja2VyLnRyYWNrKG5hbWUsIG91dC5sZW5ndGgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG91dC5wdXNoKDB4MWQsIDAsIDAsIDAsIDApOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgImFycmF5IjoKICAgICAgICAgIGNhc2UgImRlbHRhIjoKICAgICAgICAgICAgb3V0LnB1c2goLi4udGhpcy5lbmNvZGVOdW1iZXIodmFsdWUpKTsKICAgICAgICAgICAgZm9yIChsZXQgayA9IDEsIGtrID0gdmFsdWVzLmxlbmd0aDsgayA8IGtrOyArK2spIHsKICAgICAgICAgICAgICBvdXQucHVzaCguLi50aGlzLmVuY29kZU51bWJlcih2YWx1ZXNba10pKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihgVW5rbm93biBkYXRhIHR5cGUgb2YgJHt0eXBlfWApOwogICAgICAgIH0KICAgICAgfQogICAgICBvdXQucHVzaCguLi5kaWN0Lm9wY29kZXNba2V5XSk7CiAgICB9CiAgICByZXR1cm4gb3V0OwogIH0KICBjb21waWxlU3RyaW5nSW5kZXgoc3RyaW5ncykgewogICAgY29uc3Qgc3RyaW5nSW5kZXggPSBuZXcgQ0ZGSW5kZXgoKTsKICAgIGZvciAoY29uc3Qgc3RyaW5nIG9mIHN0cmluZ3MpIHsKICAgICAgc3RyaW5nSW5kZXguYWRkKCgwLCBfdXRpbC5zdHJpbmdUb0J5dGVzKShzdHJpbmcpKTsKICAgIH0KICAgIHJldHVybiB0aGlzLmNvbXBpbGVJbmRleChzdHJpbmdJbmRleCk7CiAgfQogIGNvbXBpbGVHbG9iYWxTdWJySW5kZXgoKSB7CiAgICBjb25zdCBnbG9iYWxTdWJySW5kZXggPSB0aGlzLmNmZi5nbG9iYWxTdWJySW5kZXg7CiAgICB0aGlzLm91dC53cml0ZUJ5dGVBcnJheSh0aGlzLmNvbXBpbGVJbmRleChnbG9iYWxTdWJySW5kZXgpKTsKICB9CiAgY29tcGlsZUNoYXJTdHJpbmdzKGNoYXJTdHJpbmdzKSB7CiAgICBjb25zdCBjaGFyU3RyaW5nc0luZGV4ID0gbmV3IENGRkluZGV4KCk7CiAgICBmb3IgKGxldCBpID0gMDsgaSA8IGNoYXJTdHJpbmdzLmNvdW50OyBpKyspIHsKICAgICAgY29uc3QgZ2x5cGggPSBjaGFyU3RyaW5ncy5nZXQoaSk7CiAgICAgIGlmIChnbHlwaC5sZW5ndGggPT09IDApIHsKICAgICAgICBjaGFyU3RyaW5nc0luZGV4LmFkZChuZXcgVWludDhBcnJheShbMHg4YiwgMHgwZV0pKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjaGFyU3RyaW5nc0luZGV4LmFkZChnbHlwaCk7CiAgICB9CiAgICByZXR1cm4gdGhpcy5jb21waWxlSW5kZXgoY2hhclN0cmluZ3NJbmRleCk7CiAgfQogIGNvbXBpbGVDaGFyc2V0KGNoYXJzZXQsIG51bUdseXBocywgc3RyaW5ncywgaXNDSURGb250KSB7CiAgICBsZXQgb3V0OwogICAgY29uc3QgbnVtR2x5cGhzTGVzc05vdERlZiA9IG51bUdseXBocyAtIDE7CiAgICBpZiAoaXNDSURGb250KSB7CiAgICAgIG91dCA9IG5ldyBVaW50OEFycmF5KFsyLCAwLCAwLCBudW1HbHlwaHNMZXNzTm90RGVmID4+IDggJiAweGZmLCBudW1HbHlwaHNMZXNzTm90RGVmICYgMHhmZl0pOwogICAgfSBlbHNlIHsKICAgICAgY29uc3QgbGVuZ3RoID0gMSArIG51bUdseXBoc0xlc3NOb3REZWYgKiAyOwogICAgICBvdXQgPSBuZXcgVWludDhBcnJheShsZW5ndGgpOwogICAgICBvdXRbMF0gPSAwOwogICAgICBsZXQgY2hhcnNldEluZGV4ID0gMDsKICAgICAgY29uc3QgbnVtQ2hhcnNldHMgPSBjaGFyc2V0LmNoYXJzZXQubGVuZ3RoOwogICAgICBsZXQgd2FybmVkID0gZmFsc2U7CiAgICAgIGZvciAobGV0IGkgPSAxOyBpIDwgb3V0Lmxlbmd0aDsgaSArPSAyKSB7CiAgICAgICAgbGV0IHNpZCA9IDA7CiAgICAgICAgaWYgKGNoYXJzZXRJbmRleCA8IG51bUNoYXJzZXRzKSB7CiAgICAgICAgICBjb25zdCBuYW1lID0gY2hhcnNldC5jaGFyc2V0W2NoYXJzZXRJbmRleCsrXTsKICAgICAgICAgIHNpZCA9IHN0cmluZ3MuZ2V0U0lEKG5hbWUpOwogICAgICAgICAgaWYgKHNpZCA9PT0gLTEpIHsKICAgICAgICAgICAgc2lkID0gMDsKICAgICAgICAgICAgaWYgKCF3YXJuZWQpIHsKICAgICAgICAgICAgICB3YXJuZWQgPSB0cnVlOwogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgQ291bGRuJ3QgZmluZCAke25hbWV9IGluIENGRiBzdHJpbmdzYCk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgb3V0W2ldID0gc2lkID4+IDggJiAweGZmOwogICAgICAgIG91dFtpICsgMV0gPSBzaWQgJiAweGZmOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5jb21waWxlVHlwZWRBcnJheShvdXQpOwogIH0KICBjb21waWxlRW5jb2RpbmcoZW5jb2RpbmcpIHsKICAgIHJldHVybiB0aGlzLmNvbXBpbGVUeXBlZEFycmF5KGVuY29kaW5nLnJhdyk7CiAgfQogIGNvbXBpbGVGRFNlbGVjdChmZFNlbGVjdCkgewogICAgY29uc3QgZm9ybWF0ID0gZmRTZWxlY3QuZm9ybWF0OwogICAgbGV0IG91dCwgaTsKICAgIHN3aXRjaCAoZm9ybWF0KSB7CiAgICAgIGNhc2UgMDoKICAgICAgICBvdXQgPSBuZXcgVWludDhBcnJheSgxICsgZmRTZWxlY3QuZmRTZWxlY3QubGVuZ3RoKTsKICAgICAgICBvdXRbMF0gPSBmb3JtYXQ7CiAgICAgICAgZm9yIChpID0gMDsgaSA8IGZkU2VsZWN0LmZkU2VsZWN0Lmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICBvdXRbaSArIDFdID0gZmRTZWxlY3QuZmRTZWxlY3RbaV07CiAgICAgICA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W2ldOwogICAgfQogICAgcmV0dXJuIG91dDsKICB9CiAgY29tcGlsZUluZGV4KGluZGV4KSB7CiAgICBsZXQgdHJhY2tlcnMgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IFtdOwogICAgY29uc3Qgb2JqZWN0cyA9IGluZGV4Lm9iamVjdHM7CiAgICBjb25zdCBjb3VudCA9IG9iamVjdHMubGVuZ3RoOwogICAgaWYgKGNvdW50ID09PSAwKSB7CiAgICAgIHJldHVybiBbMCwgMF07CiAgICB9CiAgICBjb25zdCBkYXRhID0gW2NvdW50ID4+IDggJiAweGZmLCBjb3VudCAmIDB4ZmZdOwogICAgbGV0IGxhc3RPZmZzZXQgPSAxLAogICAgICBpOwogICAgZm9yIChpID0gMDsgaSA8IGNvdW50OyArK2kpIHsKICAgICAgbGFzdE9mZnNldCArPSBvYmplY3RzW2ldLmxlbmd0aDsKICAgIH0KICAgIGxldCBvZmZzZXRTaXplOwogICAgaWYgKGxhc3RPZmZzZXQgPCAweDEwMCkgewogICAgICBvZmZzZXRTaXplID0gMTsKICAgIH0gZWxzZSBpZiAobGFzdE9mZnNldCA8IDB4MTAwMDApIHsKICAgICAgb2Zmc2V0U2l6ZSA9IDI7CiAgICB9IGVsc2UgaWYgKGxhc3RPZmZzZXQgPCAweDEwMDAwMDApIHsKICAgICAgb2Zmc2V0U2l6ZSA9IDM7CiAgICB9IGVsc2UgewogICAgICBvZmZzZXRTaXplID0gNDsKICAgIH0KICAgIGRhdGEucHVzaChvZmZzZXRTaXplKTsKICAgIGxldCByZWxhdGl2ZU9mZnNldCA9IDE7CiAgICBmb3IgKGkgPSAwOyBpIDwgY291bnQgKyAxOyBpKyspIHsKICAgICAgaWYgKG9mZnNldFNpemUgPT09IDEpIHsKICAgICAgICBkYXRhLnB1c2gocmVsYXRpdmVPZmZzZXQgJiAweGZmKTsKICAgICAgfSBlbHNlIGl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ub3NwYWNlIiwKICAweGZmMGMsCiAgImNvbW1hcmV2ZXJzZWRhYm92ZWNtYiIsCiAgMHgwMzE0LAogICJjb21tYXJldmVyc2VkbW9kIiwKICAweDAyYmQsCiAgImNvbW1hc21hbGwiLAogIDB4ZmU1MCwKICAiY29tbWFzdXBlcmlvciIsCiAgMHhmNmUyLAogICJjb21tYXR1cm5lZGFib3ZlY21iIiwKICAweDAzMTIsCiAgImNvbW1hdHVybmVkbW9kIiwKICAweDAyYmIsCiAgImNvbXBhc3MiLAogIDB4MjYzYywKICAiY29uZ3J1ZW50IiwKICAweDIyNDUsCiAgImNvbnRvdXJpbnRlZ3JhbCIsCiAgMHgyMjJlLAogICJjb250cm9sIiwKICAweDIzMDMsCiAgImNvbnRyb2xBQ0siLAogIDB4MDAwNiwKICAiY29udHJvbEJFTCIsCiAgMHgwMDA3LAogICJjb250cm9sQlMiLAogIDB4MDAwOCwKICAiY29udHJvbENBTiIsCiAgMHgwMDE4LAogICJjb250cm9sQ1IiLAogIDB4MDAwZCwKICAiY29udHJvbERDMSIsCiAgMHgwMDExLAogICJjb250cm9sREMyIiwKICAweDAwMTIsCiAgImNvbnRyb2xEQzMiLAogIDB4MDAxMywKICAiY29udHJvbERDNCIsCiAgMHgwMDE0LAogICJjb250cm9sREVMIiwKICAweDAwN2YsCiAgImNvbnRyb2xETEUiLAogIDB4MDAxMCwKICAiY29udHJvbEVNIiwKICAweDAwMTksCiAgImNvbnRyb2xFTlEiLAogIDB4MDAwNSwKICAiY29udHJvbEVPVCIsCiAgMHgwMDA0LAogICJjb250cm9sRVNDIiwKICAweDAwMWIsCiAgImNvbnRyb2xFVEIiLAogIDB4MDAxNywKICAiY29udHJvbEVUWCIsCiAgMHgwMDAzLAogICJjb250cm9sRkYiLAogIDB4MDAwYywKICAiY29udHJvbEZTIiwKICAweDAwMWMsCiAgImNvbnRyb2xHUyIsCiAgMHgwMDFkLAogICJjb250cm9sSFQiLAogIDB4MDAwOSwKICAiY29udHJvbExGIi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csCiAgImlncmF2ZSIsCiAgMHgwMGVjLAogICJpZ3VqYXJhdGkiLAogIDB4MGE4NywKICAiaWd1cm11a2hpIiwKICAweDBhMDcsCiAgImloaXJhZ2FuYSIsCiAgMHgzMDQ0LAogICJpaG9va2Fib3ZlIiwKICAweDFlYzksCiAgImlpYmVuZ2FsaSIsCiAgMHgwOTg4LAogICJpaWN5cmlsbGljIiwKICAweDA0MzgsCiAgImlpZGV2YSIsCiAgMHgwOTA4LAogICJpaWd1amFyYXRpIiwKICAweDBhODgsCiAgImlpZ3VybXVraGkiLAogIDB4MGEwOCwKICAiaWltYXRyYWd1cm11a2hpIiwKICAweDBhNDAsCiAgImlpbnZlcnRlZGJyZXZlIiwKICAweDAyMGIsCiAgImlpc2hvcnRjeXJpbGxpYyIsCiAgMHgwNDM5LAogICJpaXZvd2Vsc2lnbmJlbmdhbGkiLAogIDB4MDljMCwKICAiaWl2b3dlbHNpZ25kZXZhIiwKICAweDA5NDAsCiAgImlpdm93ZWxzaWduZ3VqYXJhdGkiLAogIDB4MGFjMCwKICAiaWoiLAogIDB4MDEzMywKICAiaWthdGFrYW5hIiwKICAweDMwYTQsCiAgImlrYXRha2FuYWhhbGZ3aWR0aCIsCiAgMHhmZjcyLAogICJpa29yZWFuIiwKICAweDMxNjMsCiAgImlsZGUiLAogIDB4MDJkYywKICAiaWx1eWhlYnJldyIsCiAgMHgwNWFjLAogICJpbWFjcm9uIiwKICAweDAxMmIsCiAgImltYWNyb25jeXJpbGxpYyIsCiAgMHgwNGUzLAogICJpbWFnZW9yYXBwcm94aW1hdGVseWVxdWFsIiwKICAweDIyNTMsCiAgImltYXRyYWd1cm11a2hpIiwKICAweDBhM2YsCiAgImltb25vc3BhY2UiLAogIDB4ZmY0OSwKICAiaW5jcmVtZW50IiwKICAweDIyMDYsCiAgImluZmluaXR5IiwKICAweDIyMWUsCiAgImluaWFybWVuaWFuIiwKICAweDA1NmIsCiAgImludGVncmFsIiwKICAweDIyMmIsCiAgImludGVncm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XZvd2Vsc2lnbmJlbmdhbGkiLAogIDB4MDliZiwKICAiaXZvd2Vsc2lnbmRldmEiLAogIDB4MDkzZiwKICAiaXZvd2Vsc2lnbmd1amFyYXRpIiwKICAweDBhYmYsCiAgIml6aGl0c2FjeXJpbGxpYyIsCiAgMHgwNDc1LAogICJpemhpdHNhZGJsZ3JhdmVjeXJpbGxpYyIsCiAgMHgwNDc3LAogICJqIiwKICAweDAwNmEsCiAgImphYXJtZW5pYW4iLAogIDB4MDU3MSwKICAiamFiZW5nYWxpIiwKICAweDA5OWMsCiAgImphZGV2YSIsCiAgMHgwOTFjLAogICJqYWd1amFyYXRpIiwKICAweDBhOWMsCiAgImphZ3VybXVraGkiLAogIDB4MGExYywKICAiamJvcG9tb2ZvIiwKICAweDMxMTAsCiAgImpjYXJvbiIsCiAgMHgwMWYwLAogICJqY2lyY2xlIiwKICAweDI0ZDksCiAgImpjaXJjdW1mbGV4IiwKICAweDAxMzUsCiAgImpjcm9zc2VkdGFpbCIsCiAgMHgwMjlkLAogICJqZG90bGVzc3N0cm9rZSIsCiAgMHgwMjVmLAogICJqZWN5cmlsbGljIiwKICAweDA0NTgsCiAgImplZW1hcmFiaWMiLAogIDB4MDYyYywKICAiamVlbWZpbmFsYXJhYmljIiwKICAweGZlOWUsCiAgImplZW1pbml0aWFsYXJhYmljIiwKICAweGZlOWYsCiAgImplZW1tZWRpYWxhcmFiaWMiLAogIDB4ZmVhMCwKICAiamVoYXJhYmljIiwKICAweDA2OTgsCiAgImplaGZpbmFsYXJhYmljIiwKICAweGZiOGIsCiAgImpoYWJlbmdhbGkiLAogIDB4MDk5ZCwKICAiamhhZGV2YSIsCiAgMHgwOTFkLAogICJqaGFndWphcmF0aSIsCiAgMHgwYTlkLAogICJqaGFndXJtdWtoaSIsCiAgMHgwYTFkLAogICJqaGVoYXJtZW5pYW4iLAogIDB4MDU3YiwKICAiamlzIiwKICAweDMwMDQsCiAgImptb25vc3BhY2UiLAogIDB4ZmY0YSwKICAianBhcmVuIiwKICAweDI0YTUsCiAgImpzdXBlcmlvciIsCiAgMHgwMmIyLAogICJrIiwKICAweDAwNmIsCiAgImthYmFzaGtpcmN5cmlsbGljIiwKICAweDA0YTEsCiAgImthYmVuZ2FsaSIsCiAgMHgwOTk1LAogICJrYWN1dGUiLAogIDB4MWUzMSwKICAia2FjeXJpbGxpYyIsCiAgMHgwNDNhLAogICJrYWRlc2NlbmRlcmN5cmlsbGljIiwKICAweDA0OWIsCiAgImthZGV2YSIsCiAgMHgwOTE1LAogICJrYWYiLAogIDB4MDVkYiwKICAia2FmYXJhYmljIiwKICAweDA2NDMsCiAgImthZmRhZ2VzaCIsCiAgMHhmYjNiLAogICJrYWZkYWdlc2hoZWJyZXciLAogIDB4ZmIzYiwKICAia2FmZmluYWxhcmFiaWMiLAogIDB4ZmVkYSwKICAia2FmaGVicmV3IiwKICAweDA1ZGIsCiAgImthZmluaXRpYWxhcmFiaWMiLAogIDB4ZmVkYiwKICAia2FmbWVkaWFsYXJhYmljIiwKICAweGZlZGMsCiAgImthZnJhZmVoZWJyZXciLAogIDB4ZmI0ZCwKICAia2FndWphcmF0aSIsCiAgMHgwYTk1LAogICJrYWd1cm11a2hpIiwKICAweDBhMTUsCiAgImthaGlyYWdhbmEiLAogIDB4MzA0YiwKICAia2Fob29rY3lyaWxsaWMiLAogIDB4MDRjNCwKICAia2FrYXRha2FuYSIsCiAgMHgzMGFiLAogICJrYWthdGFrYW5haGFsZndpZHRoIiwKICAweGZmNzYsCiAgImthcHBhIiwKICAweDAzYmEsCiAgImthcHBhc3ltYm9sZ3JlZWsiLAogIDB4MDNmMCwKICAia2FweWVvdW5taWV1bWtvcmVhbiIsCiAgMHgzMTcxLAogICJrYXB5ZW91bnBoaWV1cGhrb3JlYW4iLAogIDB4MzE4NCwKICAia2FweWVvdW5waWV1cGtvcmVhbiIsCiAgMHgzMTc4LAogICJrYXB5ZW91bnNzYW5ncGlldXBrb3JlYW4iLAogIDB4MzE3OSwKICAia2Fyb3J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GFoYXJhYmljIiwKICAweDA2MmUsCiAgImtoYWhmaW5hbGFyYWJpYyIsCiAgMHhmZWE2LAogICJraGFoaW5pdGlhbGFyYWJpYyIsCiAgMHhmZWE3LAogICJraGFobWVkaWFsYXJhYmljIiwKICAweGZlYTgsCiAgImtoZWljb3B0aWMiLAogIDB4MDNlNywKICAia2hoYWRldmEiLAogIDB4MDk1OSwKICAia2hoYWd1cm11a2hpIiwKICAweDBhNTksCiAgImtoaWV1a2hhY2lyY2xla29yZWFuIiwKICAweDMyNzgsCiAgImtoaWV1a2hhcGFyZW5rb3JlYW4iLAogIDB4MzIxOCwKICAia2hpZXVraGNpcmNsZWtvcmVhbiIsCiAgMHgzMjZhLAogICJraGlldWtoa29yZWFuIiwKICAweDMxNGIsCiAgImtoaWV1a2hwYXJlbmtvcmVhbiIsCiAgMHgzMjBhLAogICJraG9raGFpdGhhaSIsCiAgMHgwZTAyLAogICJraG9raG9udGhhaSIsCiAgMHgwZTA1LAogICJraG9raHVhdHRoYWkiLAogIDB4MGUwMywKICAia2hva2h3YWl0aGFpIiwKICAweDBlMDQsCiAgImtob211dHRoYWkiLAogIDB4MGU1YiwKICAia2hvb2siLAogIDB4MDE5OSwKICAia2hvcmFraGFuZ3RoYWkiLAogIDB4MGUwNiwKICAia2h6c3F1YXJlIiwKICAweDMzOTEsCiAgImtpaGlyYWdhbmEiLAogIDB4MzA0ZCwKICAia2lrYXRha2FuYSIsCiAgMHgzMGFkLAogICJraWthdGFrYW5haGFsZndpZHRoIiwKICAweGZmNzcsCiAgImtpcm9ndXJhbXVzcXVhcmUiLAogIDB4MzMxNSwKICAia2lyb21lZXRvcnVzcXVhcmUiLAogIDB4MzMxNiwKICAia2lyb3NxdWFyZSIsCiAgMHgzMzE0LAogICJraXllb2thY2lyY2xla29yZWFuIiwKICAweDMyNmUsCiAgImtpeWVva2FwYXJlbmtvcmVhbiIsCiAgMHgzMjBlLAogICJraXllb2tjaXJjbGVrb3JlYW4iLAogIDB4MzI2MCwKICAia2l5ZW9ra29yZWFuIiwKICAweDMxMzEsCiAgImtpeWVva3BhcmVua29yZWFuIiwKICAweDMyMDAsCiAgImtpeWVva3Npb3Nrb3JlYW4iLAogIDB4MzEzMywKICAia2plY3lyaWxsaWMiLAogIDB4MDQ1YywKICAia2xpbmViZWxvdyIsCiAgMHgxZTM1LAogICJrbHNxdWFyZSIsCiAgMHgzMzk4LAogICJrbWN1YmVkc3F1YXJlIiwKICAweDMzYTYsCiAgImttb25vc3BhY2UiLAogIDB4ZmY0YiwKICAia21zcXVhcmVkc3F1YXJlIiwKICAweDMzYTIsCiAgImtvaGlyYWdhbmEiLAogIDB4MzA1MywKICAia29obXNxdWFyZSIsCiAgMHgzM2MwLAogICJrb2thaXRoYWkiLAogIDB4MGUwMSwKICAia29rYXRha2FuYSIsCiAgMHgzMGIzLAogICJrb2thdGFrYW5haGFsZndpZHRoIiwKICAweGZmN2EsCiAgImtvb3Bvc3F1YXJlIiwKICAweDMzMWUsCiAgImtvcHBhY3lyaWxsaWMiLAogIDB4MDQ4MSwKICAia29yZWFuc3RhbmRhcmRzeW1ib2wiLAogIDB4MzI3ZiwKICAia29yb25pc2NtYiIsCiAgMHgwMzQzLAogICJrcGFyZW4iLAogIDB4MjRhNiwKICAia3Bhc3F1YXJlIiwKICAweDMzYWEsCiAgImtzaWN5cmlsbGljIiwKICAweDA0NmYsCiAgImt0c3F1YXJlIiwKICAweDMzY2YsCiAgImt0dXJuZWQiLAogIDB4MDI5ZSwKICAia3VoaXJhZ2FuYSIsCiAgMHgzMDRmLAogICJrdWthdGFrYW5hIiwKICAweDMwYWYsCiAgImt1a2F0YWthbmFoYWxmd2lkdGgiLAogIDB4ZmY3OCwKICAia3ZzcXVhcmUiLAogIDB4MzNiOCwKICAia3dzcXVhcmUiLAogIDB4MzNiZSwKICAibCIsCiAgMHgwMDZjLAogICJsYWJlbmdhbGkiLAogIDB4MDliMiwKICAibGFjdXRlIiwKICAweDAxM2EsCiAgImxhZGV2YSIsCiA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2h0dmVydGljYWwiLAogIDB4ZmUzNiwKICAicGFydGlhbGRpZmYiLAogIDB4MjIwMiwKICAicGFzZXFoZWJyZXciLAogIDB4MDVjMCwKICAicGFzaHRhaGVicmV3IiwKICAweDA1OTksCiAgInBhc3F1YXJlIiwKICAweDMzYTksCiAgInBhdGFoIiwKICAweDA1YjcsCiAgInBhdGFoMTEiLAogIDB4MDViNywKICAicGF0YWgxZCIsCiAgMHgwNWI3LAogICJwYXRhaDJhIiwKICAweDA1YjcsCiAgInBhdGFoaGVicmV3IiwKICAweDA1YjcsCiAgInBhdGFobmFycm93aGVicmV3IiwKICAweDA1YjcsCiAgInBhdGFocXVhcnRlcmhlYnJldyIsCiAgMHgwNWI3LAogICJwYXRhaHdpZGVoZWJyZXciLAogIDB4MDViNywKICAicGF6ZXJoZWJyZXciLAogIDB4MDVhMSwKICAicGJvcG9tb2ZvIiwKICAweDMxMDYsCiAgInBjaXJjbGUiLAogIDB4MjRkZiwKICAicGRvdGFjY2VudCIsCiAgMHgxZTU3LAogICJwZSIsCiAgMHgwNWU0LAogICJwZWN5cmlsbGljIiwKICAweDA0M2YsCiAgInBlZGFnZXNoIiwKICAweGZiNDQsCiAgInBlZGFnZXNoaGVicmV3IiwKICAweGZiNDQsCiAgInBlZXppc3F1YXJlIiwKICAweDMzM2IsCiAgInBlZmluYWxkYWdlc2hoZWJyZXciLAogIDB4ZmI0MywKICAicGVoYXJhYmljIiwKICAweDA2N2UsCiAgInBlaGFybWVuaWFuIiwKICAweDA1N2EsCiAgInBlaGVicmV3IiwKICAweDA1ZTQsCiAgInBlaGZpbmFsYXJhYmljIiwKICAweGZiNTcsCiAgInBlaGluaXRpYWxhcmFiaWMiLAogIDB4ZmI1OCwKICAicGVoaXJhZ2FuYSIsCiAgMHgzMDdhLAogICJwZWhtZWRpYWxhcmFiaWMiLAogIDB4ZmI1OSwKICAicGVrYXRha2FuYSIsCiAgMHgzMGRhLAogICJwZW1pZGRsZWhvb2tjeXJpbGxpYyIs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aGlsYXRpbiIsCiAgMHgwMjc4LAogICJwaGludGh1dGhhaSIsCiAgMHgwZTNhLAogICJwaGlzeW1ib2xncmVlayIsCiAgMHgwM2Q1LAogICJwaG9vayIsCiAgMHgwMWE1LAogICJwaG9waGFudGhhaSIsCiAgMHgwZTFlLAogICJwaG9waHVuZ3RoYWkiLAogIDB4MGUxYywKICAicGhvc2FtcGhhb3RoYWkiLAogIDB4MGUyMCwKICAicGkiLAogIDB4MDNjMCwKICAicGlldXBhY2lyY2xla29yZWFuIiwKICAweDMyNzMsCiAgInBpZXVwYXBhcmVua29yZWFuIiwKICAweDMyMTMsCiAgInBpZXVwY2lldWNrb3JlYW4iLAogIDB4MzE3NiwKICAicGlldXBjaXJjbGVrb3JlYW4iLAogIDB4MzI2NSwKICAicGlldXBraXllb2trb3JlYW4iLAogIDB4MzE3MiwKICAicGlldXBrb3JlYW4iLAogIDB4MzE0MiwKICAicGlldXBwYXJlbmtvcmVhbiIsCiAgMHgzMjA1LAogICJwaWV1cHNpb3NraXllb2trb3JlYW4iLAogIDB4MzE3NCwKICAicGlldXBzaW9za29yZWFuIiwKICAweDMxNDQsCiAgInBpZXVwc2lvc3Rpa2V1dGtvcmVhbiIsCiAgMHgzMTc1LAogICJwaWV1cHRoaWV1dGhrb3JlYW4iLAogIDB4MzE3NywKICAicGlldXB0aWtldXRrb3JlYW4iLAogIDB4MzE3MywKICAicGloaXJhZ2FuYSIsCiAgMHgzMDc0LAogICJwaWthdGFrYW5hIiwKICAweDMwZDQsCiAgInBpc3ltYm9sZ3JlZWsiLAogIDB4MDNkNiwKICAicGl3cmFybWVuaWFuIiwKICAweDA1ODMsCiAgInBsdXMiLAogIDB4MDAyYiwKICAicGx1c2JlbG93Y21iIiwKICAweDAzMWYsCiAgInBsdXNjaXJjbGUiLAogIDB4MjI5NSwKICAicGx1c21pbnVzIiwKICAweDAwYjEsCiAgInBsdXNtb2QiLAogIDB4MDJkNiwKICAicGx1c21vbm9zcGFjZSIsCiAgMHhm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iAgInB1aGlyYWdhbmEiLAogIDB4MzA3NywKICAicHVrYXRha2FuYSIsCiAgMHgzMGQ3LAogICJwdnNxdWFyZSIsCiAgMHgzM2I0LAogICJwd3NxdWFyZSIsCiAgMHgzM2JhLAogICJxIiwKICAweDAwNzEsCiAgInFhZGV2YSIsCiAgMHgwOTU4LAogICJxYWRtYWhlYnJldyIsCiAgMHgwNWE4LAogICJxYWZhcmFiaWMiLAogIDB4MDY0MiwKICAicWFmZmluYWxhcmFiaWMiLAogIDB4ZmVkNiwKICAicWFmaW5pdGlhbGFyYWJpYyIsCiAgMHhmZWQ3LAogICJxYWZtZWRpYWxhcmFiaWMiLAogIDB4ZmVkOCwKICAicWFtYXRzIiwKICAweDA1YjgsCiAgInFhbWF0czEwIiwKICAweDA1YjgsCiAgInFhbWF0czFhIiwKICAweDA1YjgsCiAgInFhbWF0czFjIiwKICAweDA1YjgsCiAgInFhbWF0czI3IiwKICAweDA1YjgsCiAgInFhbWF0czI5IiwKICAweDA1YjgsCiAgInFhbWF0czMzIiwKICAweDA1YjgsCiAgInFhbWF0c2RlIiwKICAweDA1YjgsCiAgInFhbWF0c2hlYnJldyIsCiAgMHgwNWI4LAogICJxYW1hdHNuYXJyb3doZWJyZXciLAogIDB4MDViOCwKICAicWFtYXRzcWF0YW5oZWJyZXciLAogIDB4MDViOCwKICAicWFtYXRzcWF0YW5uYXJyb3doZWJyZXciLAogIDB4MDViOCwKICAicWFtYXRzcWF0YW5xdWFydGVyaGVicmV3IiwKICAweDA1YjgsCiAgInFhbWF0c3FhdGFud2lkZWhlYnJldyIsCiAgMHgwNWI4LAogICJxYW1hdHNxdWFydGVyaGVicmV3IiwKICAweDA1YjgsCiAgInFhbWF0c3dpZGVoZWJyZXciLAogIDB4MDViOCwKICAicWFybmV5cGFyYWhlYnJldyIsCiAgMHgwNTlmLAogICJxYm9wb21vZm8iLAogIDB4MzExMSwKICAicWNpcmNsZSIsCiAgMHgyNGUwLAogICJxaG9vayIsCiAgMHgwMm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sCiAgMHgwMTU5LAogICJyY2VkaWxsYSIsCiAgMHgwMTU3LAogICJyY2lyY2xlIiwKICAweDI0ZTEsCiAgInJjb21tYWFjY2VudCIsCiAgMHgwMTU3LAogICJyZGJsZ3JhdmUiLAogIDB4MDIxMSwKICAicmRvdGFjY2VudCIsCiAgMHgxZTU5LAogICJyZG90YmVsb3ciLAogIDB4MWU1YiwKICAicmRvdGJlbG93bWFjcm9uIiwKICAweDFlNWQsCiAgInJlZmVyZW5jZW1hcmsiLAogIDB4MjAzYiwKICAicmVmbGV4c3Vic2V0IiwKICAweDIyODYsCiAgInJlZmxleHN1cGVyc2V0IiwKICAweDIyODcsCiAgInJlZ2lzdGVyZWQiLAogIDB4MDBhZSwKICAicmVnaXN0ZXJzYW5zIiwKICAweGY4ZTgsCiAgInJlZ2lzdGVyc2VyaWYiLAogIDB4ZjZkYSwKICAicmVoYXJhYmljIiwKICAweDA2MzEsCiAgInJlaGFybWVuaWFuIiwKICAweDA1ODAsCiAgInJlaGZpbmFsYXJhYmljIiwKICAweGZlYWUsCiAgInJlaGlyYWdhbmEiLAogIDB4MzA4YywKICAicmVrYXRha2FuYSIsCiAgMHgzMGVjLAogICJyZWthdGFrYW5haGFsZndpZHRoIiwKICAweGZmOWEsCiAgInJlc2giLAogIDB4MDVlOCwKICAicmVzaGRhZ2VzaGhlYnJldyIsCiAgMHhmYjQ4LAogICJyZXNoaGVicmV3IiwKICAweDA1ZTgsCiAgInJldmVyc2VkdGlsZGUiLAogIDB4MjIzZCwKICAicmV2aWFoZWJyZXciLAogIDB4MDU5NywKICAicmV2aWFtdWdyYXNoaGVicmV3IiwKICAweDA1OTcsCiAgInJldmxvZ2ljYWxub3QiLAogIDB4MjMxMCwKICAicmZpc2hob29rIiwKICAweDAyN2UsCiAgInJmaXNoaG9va3JldmVyc2VkIiwKICAweDAyN2YsCiAgInJoYWJlbmdhbGkiLAogIDB4MDlkZCwKICAicmhhZGV2YSIsCiAgMHgwOTVkLAogICJyaG8iLAog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haSIsCiAgMHgwZTM4LAogICJzYXJhdXV0aGFpIiwKICAweDBlMzksCiAgInNib3BvbW9mbyIsCiAgMHgzMTE5LAogICJzY2Fyb24iLAogIDB4MDE2MSwKICAic2Nhcm9uZG90YWNjZW50IiwKICAweDFlNjcsCiAgInNjZWRpbGxhIiwKICAweDAxNWYsCiAgInNjaHdhIiwKICAweDAyNTksCiAgInNjaHdhY3lyaWxsaWMiLAogIDB4MDRkOSwKICAic2Nod2FkaWVyZXNpc2N5cmlsbGljIiwKICAweDA0ZGIsCiAgInNjaHdhaG9vayIsCiAgMHgwMjVhLAogICJzY2lyY2xlIiwKICAweDI0ZTIsCiAgInNjaXJjdW1mbGV4IiwKICAweDAxNWQsCiAgInNjb21tYWFjY2VudCIsCiAgMHgwMjE5LAogICJzZG90YWNjZW50IiwKICAweDFlNjEsCiAgInNkb3RiZWxvdyIsCiAgMHgxZTYzLAogICJzZG90YmVsb3dkb3RhY2NlbnQiLAogIDB4MWU2OSwKICAic2VhZ3VsbGJlbG93Y21iIiwKICAweDAzM2MsCiAgInNlY29uZCIsCiAgMHgyMDMzLAogICJzZWNvbmR0b25lY2hpbmVzZSIsCiAgMHgwMmNhLAogICJzZWN0aW9uIiwKICAweDAwYTcsCiAgInNlZW5hcmFiaWMiLAogIDB4MDYzMywKICAic2VlbmZpbmFsYXJhYmljIiwKICAweGZlYjIsCiAgInNlZW5pbml0aWFsYXJhYmljIiwKICAweGZlYjMsCiAgInNlZW5tZWRpYWxhcmFiaWMiLAogIDB4ZmViNCwKICAic2Vnb2wiLAogIDB4MDViNiwKICAic2Vnb2wxMyIsCiAgMHgwNWI2LAogICJzZWdvbDFmIiwKICAweDA1YjYsCiAgInNlZ29sMmMiLAogIDB4MDViNiwKICAic2Vnb2xoZWJyZXciLAogIDB4MDViNiwKICAic2Vnb2xuYXJyb3doZWJyZXciLAogIDB4MDViNiwKICAic2Vnb2xxdWFydGVyaGVicmV3IiwKICAweDA1YjYsCiAgInNlZ29sdGFoZWJ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gMHgwNDQ5LAogICJzaGVlbmFyYWJpYyIsCiAgMHgwNjM0LAogICJzaGVlbmZpbmFsYXJhYmljIiwKICAweGZlYjYsCiAgInNoZWVuaW5pdGlhbGFyYWJpYyIsCiAgMHhmZWI3LAogICJzaGVlbm1lZGlhbGFyYWJpYyIsCiAgMHhmZWI4LAogICJzaGVpY29wdGljIiwKICAweDAzZTMsCiAgInNoZXFlbCIsCiAgMHgyMGFhLAogICJzaGVxZWxoZWJyZXciLAogIDB4MjBhYSwKICAic2hldmEiLAogIDB4MDViMCwKICAic2hldmExMTUiLAogIDB4MDViMCwKICAic2hldmExNSIsCiAgMHgwNWIwLAogICJzaGV2YTIyIiwKICAweDA1YjAsCiAgInNoZXZhMmUiLAogIDB4MDViMCwKICAic2hldmFoZWJyZXciLAogIDB4MDViMCwKICAic2hldmFuYXJyb3doZWJyZXciLAogIDB4MDViMCwKICAic2hldmFxdWFydGVyaGVicmV3IiwKICAweDA1YjAsCiAgInNoZXZhd2lkZWhlYnJldyIsCiAgMHgwNWIwLAogICJzaGhhY3lyaWxsaWMiLAogIDB4MDRiYiwKICAic2hpbWFjb3B0aWMiLAogIDB4MDNlZCwKICAic2hpbiIsCiAgMHgwNWU5LAogICJzaGluZGFnZXNoIiwKICAweGZiNDksCiAgInNoaW5kYWdlc2hoZWJyZXciLAogIDB4ZmI0OSwKICAic2hpbmRhZ2VzaHNoaW5kb3QiLAogIDB4ZmIyYywKICAic2hpbmRhZ2VzaHNoaW5kb3RoZWJyZXciLAogIDB4ZmIyYywKICAic2hpbmRhZ2VzaHNpbmRvdCIsCiAgMHhmYjJkLAogICJzaGluZGFnZXNoc2luZG90aGVicmV3IiwKICAweGZiMmQsCiAgInNoaW5kb3RoZWJyZXciLAogIDB4MDVjMSwKICAic2hpbmhlYnJldyIsCiAgMHgwNWU5LAogICJzaGluc2hpbmRvdCIsCiAgMHhmYjJhLAogICJzaGluc2hpbmRvdGhlYnJldyIsCiAgMHhmYjJhLAogICJzaGluc2luZG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ogICJzaXhndWphcmF0aSIsCiAgMHgwYWVjLAogICJzaXhndXJtdWtoaSIsCiAgMHgwYTZjLAogICJzaXhoYWNrYXJhYmljIiwKICAweDA2NjYsCiAgInNpeGhhbmd6aG91IiwKICAweDMwMjYsCiAgInNpeGlkZW9ncmFwaGljcGFyZW4iLAogIDB4MzIyNSwKICAic2l4aW5mZXJpb3IiLAogIDB4MjA4NiwKICAic2l4bW9ub3NwYWNlIiwKICAweGZmMTYsCiAgInNpeG9sZHN0eWxlIiwKICAweGY3MzYsCiAgInNpeHBhcmVuIiwKICAweDI0NzksCiAgInNpeHBlcmlvZCIsCiAgMHgyNDhkLAogICJzaXhwZXJzaWFuIiwKICAweDA2ZjYsCiAgInNpeHJvbWFuIiwKICAweDIxNzUsCiAgInNpeHN1cGVyaW9yIiwKICAweDIwNzYsCiAgInNpeHRlZW5jaXJjbGUiLAogIDB4MjQ2ZiwKICAic2l4dGVlbmN1cnJlbmN5ZGVub21pbmF0b3JiZW5nYWxpIiwKICAweDA5ZjksCiAgInNpeHRlZW5wYXJlbiIsCiAgMHgyNDgzLAogICJzaXh0ZWVucGVyaW9kIiwKICAweDI0OTcsCiAgInNpeHRoYWkiLAogIDB4MGU1NiwKICAic2xhc2giLAogIDB4MDAyZiwKICAic2xhc2htb25vc3BhY2UiLAogIDB4ZmYwZiwKICAic2xvbmciLAogIDB4MDE3ZiwKICAic2xvbmdkb3RhY2NlbnQiLAogIDB4MWU5YiwKICAic21pbGVmYWNlIiwKICAweDI2M2EsCiAgInNtb25vc3BhY2UiLAogIDB4ZmY1MywKICAic29mcGFzdXFoZWJyZXciLAogIDB4MDVjMywKICAic29mdGh5cGhlbiIsCiAgMHgwMGFkLAogICJzb2Z0c2lnbmN5cmlsbGljIiwKICAweDA0NGMsCiAgInNvaGlyYWdhbmEiLAogIDB4MzA1ZCwKICAic29rYXRha2FuYSIsCiAgMHgzMGJkLAogICJzb2thdGFrYW5haGFsZndpZHRoIiwKICAweGZmN2YsCiAgInNvb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ywKICAidGhhbnRoYWtoYXR1cHBlcmxlZnR0aGFpIiwKICAweGY4OTYsCiAgInRoZWhhcmFiaWMiLAogIDB4MDYyYiwKICAidGhlaGZpbmFsYXJhYmljIiwKICAweGZlOWEsCiAgInRoZWhpbml0aWFsYXJhYmljIiwKICAweGZlOWIsCiAgInRoZWhtZWRpYWxhcmFiaWMiLAogIDB4ZmU5YywKICAidGhlcmVleGlzdHMiLAogIDB4MjIwMywKICAidGhlcmVmb3JlIiwKICAweDIyMzQsCiAgInRoZXRhIiwKICAweDAzYjgsCiAgInRoZXRhMSIsCiAgMHgwM2QxLAogICJ0aGV0YXN5bWJvbGdyZWVrIiwKICAweDAzZDEsCiAgInRoaWV1dGhhY2lyY2xla29yZWFuIiwKICAweDMyNzksCiAgInRoaWV1dGhhcGFyZW5rb3JlYW4iLAogIDB4MzIxOSwKICAidGhpZXV0aGNpcmNsZWtvcmVhbiIsCiAgMHgzMjZiLAogICJ0aGlldXRoa29yZWFuIiwKICAweDMxNGMsCiAgInRoaWV1dGhwYXJlbmtvcmVhbiIsCiAgMHgzMjBiLAogICJ0aGlydGVlbmNpcmNsZSIsCiAgMHgyNDZjLAogICJ0aGlydGVlbnBhcmVuIiwKICAweDI0ODAsCiAgInRoaXJ0ZWVucGVyaW9kIiwKICAweDI0OTQsCiAgInRob25hbmdtb250aG90aGFpIiwKICAweDBlMTEsCiAgInRob29rIiwKICAweDAxYWQsCiAgInRob3BodXRoYW90aGFpIiwKICAweDBlMTIsCiAgInRob3JuIiwKICAweDAwZmUsCiAgInRob3RoYWhhbnRoYWkiLAogIDB4MGUxNywKICAidGhvdGhhbnRoYWkiLAogIDB4MGUxMCwKICAidGhvdGhvbmd0aGFpIiwKICAweDBlMTgsCiAgInRob3RodW5ndGhhaSIsCiAgMHgwZTE2LAogICJ0aG91c2FuZGN5cmlsbGljIiwKICAweDA0ODIsCiAgInRob3VzYW5kc3NlcGFyYXRvcmFyYWJpYyIsCiAgMHgwNjZjLAogICJ0aG91c2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AogIDB4MDlkZiwKICAieXlhZGV2YSIsCiAgMHgwOTVmLAogICJ6IiwKICAweDAwN2EsCiAgInphYXJtZW5pYW4iLAogIDB4MDU2NiwKICAiemFjdXRlIiwKICAweDAxN2EsCiAgInphZGV2YSIsCiAgMHgwOTViLAogICJ6YWd1cm11a2hpIiwKICAweDBhNWIsCiAgInphaGFyYWJpYyIsCiAgMHgwNjM4LAogICJ6YWhmaW5hbGFyYWJpYyIsCiAgMHhmZWM2LAogICJ6YWhpbml0aWFsYXJhYmljIiwKICAweGZlYzcsCiAgInphaGlyYWdhbmEiLAogIDB4MzA1NiwKICAiemFobWVkaWFsYXJhYmljIiwKICAweGZlYzgsCiAgInphaW5hcmFiaWMiLAogIDB4MDYzMiwKICAiemFpbmZpbmFsYXJhYmljIiwKICAweGZlYjAsCiAgInpha2F0YWthbmEiLAogIDB4MzBiNiwKICAiemFxZWZnYWRvbGhlYnJldyIsCiAgMHgwNTk1LAogICJ6YXFlZnFhdGFuaGVicmV3IiwKICAweDA1OTQsCiAgInphcnFhaGVicmV3IiwKICAweDA1OTgsCiAgInpheWluIiwKICAweDA1ZDYsCiAgInpheWluZGFnZXNoIiwKICAweGZiMzYsCiAgInpheWluZGFnZXNoaGVicmV3IiwKICAweGZiMzYsCiAgInpheWluaGVicmV3IiwKICAweDA1ZDYsCiAgInpib3BvbW9mbyIsCiAgMHgzMTE3LAogICJ6Y2Fyb24iLAogIDB4MDE3ZSwKICAiemNpcmNsZSIsCiAgMHgyNGU5LAogICJ6Y2lyY3VtZmxleCIsCiAgMHgxZTkxLAogICJ6Y3VybCIsCiAgMHgwMjkxLAogICJ6ZG90IiwKICAweDAxN2MsCiAgInpkb3RhY2NlbnQiLAogIDB4MDE3YywKICAiemRvdGJlbG93IiwKICAweDFlOTMsCiAgInplY3lyaWxsaWMiLAogIDB4MDQzNywKICAiemVkZXNjZW5kZXJjeXJpbGxpYyIsCiAgMHgwNDk5LAogICJ6ZWRpZXJlc2lzY3lyaWxsaWMiL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hMTgiLAogIDB4MjcxMiwKICAiYTE5IiwKICAweDI3MTMsCiAgImEyMCIsCiAgMHgyNzE0LAogICJhMjEiLAogIDB4MjcxNSwKICAiYTIyIiwKICAweDI3MTYsCiAgImEyMyIsCiAgMHgyNzE3LAogICJhMjQiLAogIDB4MjcxOCwKICAiYTI1IiwKICAweDI3MTksCiAgImEyNiIsCiAgMHgyNzFhLAogICJhMjciLAogIDB4MjcxYiwKICAiYTI4IiwKICAweDI3MWMsCiAgImE2IiwKICAweDI3MWQsCiAgImE3IiwKICAweDI3MWUsCiAgImE4IiwKICAweDI3MWYsCiAgImE5IiwKICAweDI3MjAsCiAgImExMCIsCiAgMHgyNzIxLAogICJhMjkiLAogIDB4MjcyMiwKICAiYTMwIiwKICAweDI3MjMsCiAgImEzMSIsCiAgMHgyNzI0LAogICJhMzIiLAogIDB4MjcyNSwKICAiYTMzIiwKICAweDI3MjYsCiAgImEzNCIsCiAgMHgyNzI3LAogICJhMzUiLAogIDB4MjYwNSwKICAiYTM2IiwKICAweDI3MjksCiAgImEzNyIsCiAgMHgyNzJhLAogICJhMzgiLAogIDB4MjcyYiwKICAiYTM5IiwKICAweDI3MmMsCiAgImE0MCIsCiAgMHgyNzJkLAogICJhNDEiLAogIDB4MjcyZSwKICAiYTQyIiwKICAweDI3MmYsCiAgImE0MyIsCiAgMHgyNzMwLAogICJhNDQiLAogIDB4MjczMSwKICAiYTQ1IiwKICAweDI3MzIsCiAgImE0NiIsCiAgMHgyNzMzLAogICJhNDciLAogIDB4MjczNCwKICAiYTQ4IiwKICAweDI3MzUsCiAgImE0OSIsCiAgMHgyNzM2LAogICJhNTAiLAogIDB4MjczNywKICAiYTUxIiwKICAweDI3MzgsCiAgImE1MiIsCiAgMHgyNzM5LAogICJhNTMiLAogIDB4MjczYSwKICAiYTU0IiwKICAweDI3M2IsCiAgImE1NSIsCiAgMHgyNzNjLAogICJhNTYiLAogIDB4MjczZCwKICAiYTU3IiwKICAweDI3M2UsCiAgImE1OCIs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KICAiYTE2NCIsCiAgMHgyMTk1LAogICJhMTk2IiwKICAweDI3OTgsCiAgImExNjUiLAogIDB4Mjc5OSwKICAiYTE5MiIsCiAgMHgyNzlhLAogICJhMTY2IiwKICAweDI3OWIsCiAgImExNjciLAogIDB4Mjc5YywKICAiYTE2OCIsCiAgMHgyNzlkLAogICJhMTY5IiwKICAweDI3OWUsCiAgImExNzAiLAogIDB4Mjc5ZiwKICAiYTE3MSIsCiAgMHgyN2EwLAogICJhMTcyIiwKICAweDI3YTEsCiAgImExNzMiLAogIDB4MjdhMiwKICAiYTE2MiIsCiAgMHgyN2EzLAogICJhMTc0IiwKICAweDI3YTQsCiAgImExNzUiLAogIDB4MjdhNSwKICAiYTE3NiIsCiAgMHgyN2E2LAogICJhMTc3IiwKICAweDI3YTcsCiAgImExNzgiLAogIDB4MjdhOCwKICAiYTE3OSIsCiAgMHgyN2E5LAogICJhMTkzIiwKICAweDI3YWEsCiAgImExODAiLAogIDB4MjdhYiwKICAiYTE5OSIsCiAgMHgyN2FjLAogICJhMTgxIiwKICAweDI3YWQsCiAgImEyMDAiLAogIDB4MjdhZSwKICAiYTE4MiIsCiAgMHgyN2FmLAogICJhMjAxIiwKICAweDI3YjEsCiAgImExODMiLAogIDB4MjdiMiwKICAiYTE4NCIsCiAgMHgyN2IzLAogICJhMTk3IiwKICAweDI3YjQsCiAgImExODUiLAogIDB4MjdiNSwKICAiYTE5NCIsCiAgMHgyN2I2LAogICJhMTk4IiwKICAweDI3YjcsCiAgImExODYiLAogIDB4MjdiOCwKICAiYTE5NSIsCiAgMHgyN2I5LAogICJhMTg3IiwKICAweDI3YmEsCiAgImExODgiLAogIDB4MjdiYiwKICAiYTE4OSIsCiAgMHgyN2JjLAogICJhMTkwIiwKICAweDI3YmQsCiAgImExOTEiLAogIDB4MjdiZSwKICAiYTg5IiwKICAweDI3NjgsCiAgImE5MCIsCiAgMHgyNzY5LAogICJhOTMiLAogIDB4Mjc2YSwKICAiYTk0IiwKICAweDI3Nm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AwQjciLAogICJcdTAxNDAiLAogICJcdTAwNkNcdTAwQjciLAogICJcdTAxNDkiLAogICJcdTAyQkNcdTAwNkUiLAogICJcdTAxN0YiLAogICJcdTAwNzMiLAogICJcdTAxQzQiLAogICJcdTAwNDRcdTAxN0QiLAogICJcdTAxQzUiLAogICJcdTAwNDRcdTAxN0UiLAogICJcdTAxQzYiLAogICJcdTAwNjRcdTAxN0UiLAogICJcdTAxQzciLAogICJcdTAwNENcdTAwNEEiLAogICJcdTAxQzgiLAogICJcdTAwNENcdTAwNkEiLAogICJcdTAxQzkiLAogICJcdTAwNkNcdTAwNkEiLAogICJcdTAxQ0EiLAogICJcdTAwNEVcdTAwNEEiLAogICJcdTAxQ0IiLAogICJcdTAwNEVcdTAwNkEiLAogICJcdTAxQ0MiLAogICJcdTAwNkVcdTAwNkEiLAogICJcdTAxRjEiLAogICJcdTAwNDRcdTAwNUEiLAogICJcdTAxRjIiLAogICJcdTAwNDRcdTAwN0EiLAogICJcdTAxRjMiLAogICJcdTAwNjRcdTAwN0EiLAogICJcdTAyRDgiLAogICJcdTAwMjBcdTAzMDYiLAogICJcdTAyRDkiLAogICJcdTAwMjBcdTAzMDciLAogICJcdTAyREEiLAogICJcdTAwMjBcdTAzMEEiLAogICJcdTAyREIiLAogICJcdTAwMjBcdTAzMjgiLAogICJcdTAyREMiLAogICJcdTAwMjBcdTAzMDMiLAogICJcdTAyREQiLAogICJcdTAwMjBcdTAzMEIiLAogICJcdTAzN0EiLAogICJcdTAwMjBcdTAzNDUiLAogICJcdTAzODQiLAogICJcdTAwMjBcdTAzMDEiLAogICJcdTAzRDAiLAogICJcdTAzQjIiLAogICJcdTAzRDEiLAogICJcdTAzQjgiLAogICJcdTAzRDIiLAogICJcdTAzQTUiLAogICJcdTAzRDUiLAogICJcdTAzQzYiLAogICJcdTAzRDYiLAogICJcdTAzQzAiLAogICJcdTAzRjAiLAogICJcdTAzQkEiLAogICJcdTAzRjEiLAogICJcdTAzQzEiLAogICJcdTAzRjIiLAogICJcdTAzQzIiLAogICJcdTAzRjQiLAogICJcdTAzOTgiLAogICJcdTAzRjUiLAogICJcdTAzQjUiLAogICJcdTAzRjkiLAogICJcdTAzQTMiLAogICJcdTA1ODciLAogICJcdTA1NjVcdTA1ODIiLAogICJcdTA2NzUiLAogICJcdTA2MjdcdTA2NzQiLAogICJcdTA2NzYiLAogICJcdTA2NDhcdTA2NzQiLAogICJcdTA2NzciLAogICJcdTA2QzdcdTA2NzQiLAogICJcdTA2NzgiLAogICJcdTA2NEFcdTA2NzQiLAogICJcdTBFMzMiLAogICJcdTBFNERcdTBFMzIiLAogICJcdTBFQjMiLAogICJcdTBFQ0RcdTBFQjIiLAogICJcdTBFREMiLAogICJcdTBFQUJcdTBFOTkiLAogICJcdTBFREQiLAogICJcdTBFQUJcdTBFQTEiLAogICJcdTBGNzciLAogICJcdTBGQjJcdTBGODEiLAogICJcdTBGNzkiLAogICJcdTBGQjNcdTBGODEiLAogICJcdTFFOUEiLAogICJcdTAwNjFcdTAyQkUiLAogICJcdTFGQkQiLAogICJcdTAwMjBcdTAzMTMiLAogICJcdTFGQkYiLAogICJcdTAwMjBcdTAzMTMiLAogICJcdTFGQzAiLAogICJcdTAwMjBcdTAzNDIiLAogICJcdTFGRkUiLAogICJcdTAwMjBcdTAzMTQiLAogICJcdTIwMDIiLAogICJcdTAwMjAiLAogICJcdTIwMDMiLAogICJcdTAwMjAiLAogICJcdTIwMDQiLAogICJcdTAwMjAiLAogICJcdTIwMDUiLAogICJcdTAwMjAiLAogICJcdTIwMDYiLAogICJcdTAwMjAiLAogICJcdTIwMDgiLAogICJcdTAwMjAiLAogICJcdTIwMDkiLAogICJcdTAwMjAiLAogICJcdTIwMEEiLAogICJcdTAwMjAiLAogICJcdTIwMTciLAogICJcdTAwMjBcdTAzMzMiLAogICJcdTIwMjQiLAogICJcdTAwMkUiLAogICJcdTIwMjUiLAogICJcdTAwMkVcdTAwMkUiLAogICJcdTIwMjYiLAogICJcdTAwMkVcdTAwMkVcdTAwMkUiLAogICJcdTIwMzMiLAogICJcdTIwMzJcdTIwMzIiLAogICJcdTIwMzQiLAogICJcdTIwMzJcdTIwMzJcdTIwMzIiLAogICJcdTIwMzYiLAogICJcdTIwMzVcdTIwMzUiLAogICJcdTIwMzciLAogICJcdTIwMzVcdTIwMzVcdTIwMzUiLAogICJcdTIwM0MiLAogICJcdTAwMjFcdTAwMjEiLAogICJcdTIwM0UiLAogICJcdTAwMjBcdTAzMDUiLAogICJcdTIwNDciLAogICJcdTAwM0ZcdTAwM0YiLAogICJcdTIwNDgiLAogICJcdTAwM0ZcdTAwMjEiLAogICJcdTIwNDkiLAogICJcdTAwMjFcdTAwM0YiLAogICJcdTIwNTciLAogICJcdTIwMzJcdTIwMzJcdTIwMzJcdTIwMzIiLAogICJcdTIwNUYiLAogICJcdTAwMjAiLAogICJcdTIwQTgiLAogICJcdTAwNTJcdTAwNzMiLAogICJcdTIxMDAiLAogICJcdTAwNjFcdTAwMkZcdTAwNjMiLAogICJcdTIxMDEiLAogICJcdTAwNjFcdTAwMkZcdTAwNzMiLAogICJcdTIxMDMiLAogICJcdTAwQjBcdTAwNDMiLAogICJcdTIxMDUiLAogICJcdTAwNjNcdTAwMkZcdTAwNkYiLAogICJcdTIxMDYiLAogICJcdTAwNjNcdTAwMkZcdTAwNzUiLAogICJcdTIxMDciLAogICJcdTAxOTAiLAogICJcdTIxMDkiLAogICJcdTAwQjBcdTAwNDYiLAogICJcdTIxMTYiLAogICJcdTAwNEVcdTAwNkYiLAogICJcdTIxMjEiLAogICJcdTAwNTRcdTAwNDVcdTAwNEMiLAogICJcdTIxMzUiLAogICJcdTA1RDAiLAogICJcdTIxMzYiLAogICJcdTA1RDEiLAogICJcdTIxMzciLAogICJcdTA1RDIiLAogICJcdTIxMzgiLAogICJcdTA1RDMiLAogICJcdTIxM0IiLAogICJcdTAwNDZcdTAwNDFcdTAwNTgiLAogICJcdTIxNjAiLAogICJcdTAwNDkiLAogICJcdTIxNjEiLAogICJcdTAwNDlcdTAwNDkiLAogICJcdTIxNjIiLAogICJcdTAwNDlcdTAwNDlcdTAwNDkiLAogICJcdTIxNjMiLAogICJcdTAwNDlcdTAwNTYiLAogICJcdTIxNjQiLAogICJcdTAwNTYiLAogICJcdTIxNjUiLAogICJcdTAwNTZcdTAwNDkiLAogICJcdTIxNjYiLAogICJcdTAwNTZcdTAwNDlcdTAwNDkiLAogICJcdTIxNjciLAogICJcdTAwNTZcdTAwNDlcdTAwNDlcdTAwNDkiLAogICJcdTIxNjgiLAogICJcdTAwNDlcdTAwNTgiLAogICJcdTIxNjkiLAogICJcdTAwNTgiLAogICJcdTIxNkEiLAogICJcdTAwNThcdTAwNDkiLAogICJcdTIxNkIiLAogICJcdTAwNThcdTAwNDlcdTAwNDkiLAogICJcdTIxNkMiLAogICJcdTAwNEMiLAogICJcdTIxNkQiLAogICJcdTAwNDMiLAogICJcdTIxNkUiLAogICJcdTAwNDQiLAogICJcdTIxNkYiLAogICJcdTAwNEQiLAogICJcdTIxNzAiLAogICJcdTAwNjkiLAogICJcdTIxNzEiLAogICJcdTAwNjlcdTAwNjkiLAogICJcdTIxNzIiLAogICJcdTAwNjlcdTAwNjlcdTAwNjkiLAogICJcdTIxNzMiLAogICJcdTAwNjlcdTAwNzYiLAogICJcdTIxNzQiLAogICJcdTAwNzYiLAogICJcdTIxNzUiLAogICJcdTAwNzZcdTAwNjkiLAogICJcdTIxNzYiLAogICJcdTAwNzZcdTAwNjlcdTAwNjkiLAogICJcdTIxNzciLAogICJcdTAwNzZcdTAwNjlcdTAwNjlcdTAwNjkiLAogICJcdTIxNzgiLAogICJcdTAwNjlcdTAwNzgiLAogICJcdTIxNzkiLAogICJcdTAwNzgiLAogICJcdTIxN0EiLAogICJcdTAwNzhcdTAwNjkiLAogICJcdTIxN0IiLAogICJcdTAwNzhcdTAwNjlcdTAwNjkiLAogICJcdTIxN0MiLAogICJcdTAwNkMiLAogICJcdTIxN0QiLAogICJcdTAwNjMiLAogICJcdTI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TAwMjkiLAogICJcdTI0QjUiLAogICJcdTAwMjhcdTAwN0FcdTAwMjkiLAogICJcdTJBMEMiLAogICJcdTIyMkJcdTIyMkJcdTIyMkJcdTIyMkIiLAogICJcdTJBNzQiLAogICJcdTAwM0FcdTAwM0FcdTAwM0QiLAogICJcdTJBNzUiLAogICJcdTAwM0RcdTAwM0QiLAogICJcdTJBNzYiLAogICJcdTAwM0RcdTAwM0RcdTAwM0QiLAogICJcdTJFOUYiLAogICJcdTZCQ0QiLAogICJcdTJFRjMiLAogICJcdTlGOUYiLAogICJcdTJGMDAiLAogICJcdTRFMDAiLAogICJcdTJGMDEiLAogICJcdTRFMjgiLAogICJcdTJGMDIiLAogICJcdTRFMzYiLAogICJcdTJGMDMiLAogICJcdTRFM0YiLAogICJcdTJGMDQiLAogICJcdTRFNTkiLAogICJcdTJGMDUiLAogICJcdTRFODUiLAogICJcdTJGMDYiLAogICJcdTRFOEMiLAogICJcdTJGMDciLAogICJcdTRFQTAiLAogICJcdTJGMDgiLAogICJcdTRFQkEiLAogICJcdTJGMDkiLAogICJcdTUxM0YiLAogICJcdTJGMEEiLAogICJcdTUxNjUiLAogICJcdTJGMEIiLAogICJcdTUxNkIiLAogICJcdTJGMEMiLAogICJcdTUxODIiLAogICJcdTJGMEQiLAogICJcdTUxOTYiLAogICJcdTJGMEUiLAogICJcdTUxQUIiLAogICJcdTJGMEYiLAogICJcdTUxRTAiLAogICJcdTJGMTAiLAogICJcdTUxRjUiLAogICJcdTJGMTEiLAogICJcdTUyMDAiLAogICJcdTJGMTIiLAogICJcdTUyOUIiLAogICJcdTJGMTMiLAogICJcdTUyRjkiLAogICJcdTJGMTQiLAogICJcdTUzMTUiLAogICJcdTJGMTUiLAogICJcdTUzMUEiLAogICJcdTJGMTYiLAogICJcdTUzMzgiLAogICJcdTJGMTciLAogICJcdTUzNDEiLAogICJcdTJGMTgiLAogICJcdTUzNUMiLAogICJcdTJGMTkiLAogICJcdTUzNjkiLAogICJcdTJGMUEiLAogICJcdTUzODIiLAogICJcdTJGMUIiLAogICJcdTUzQjYiLAogICJcdTJGMUMiLAogICJcdTUzQzgiLAogICJcdTJGMUQiLAogICJcdTUzRTMiLAogICJcdTJGMUUiLAogICJcdTU2RDciLAogICJcdTJGMUYiLAogICJcdTU3MUYiLAogICJcdTJGMjAiLAogICJcdTU4RUIiLAogICJcdTJGMjEiLAogICJcdTU5MDIiLAogICJcdTJGMjIiLAogICJcdTU5MEEiLAogICJcdTJGMjMiLAogICJcdTU5MTUiLAogICJcdTJGMjQiLAogICJcdTU5MjciLAogICJcdTJGMjUiLAogICJcdTU5NzMiLAogICJcdTJGMjYiLAogICJcdTVCNTAiLAogICJcdTJGMjciLAogICJcdTVCODAiLAogICJcdTJGMjgiLAogICJcdTVCRjgiLAogICJcdTJGMjkiLAogICJcdTVDMEYiLAogICJcdTJGMkEiLAogICJcdTVDMjIiLAogICJcdTJGMkIiLAogICJcdTVDMzgiLAogICJcdTJGMkMiLAogICJcdTVDNkUiLAogICJcdTJGMkQiLAogICJcdTVDNzEiLAogICJcdTJGMkUiLAogICJcdTVEREIiLAogICJcdTJGMkYiLAogICJcdTVERTUiLAogICJcdTJGMzAiLAogICJcdTVERjEiLAogICJcdTJGMzEiLAogICJcdTVERkUiLAogICJcdTJGMzIiLAogICJcdTVFNzIiLAogICJcdTJGMzMiLAogICJcdTVFN0EiLAogICJcdTJGMzQiLAogICJcdTVFN0YiLAogICJcdTJGMzUiLAogICJcdTVFRjQiLAogICJcdTJGMzYiLAogICJcdTVFRkUiLAogICJcdTJGMzciLAogICJcdTVGMEIiLAogICJcdTJGMzgiLAogICJcdTVGMTMiLAogICJcdTJGMzkiLAogICJcdTVGNTAiLAogICJcdTJGM0EiLAogICJcdTVGNjEiLAogICJcdTJGM0IiLAogICJcdTVGNzMiLAogICJcdTJGM0MiLAogICJcdTVGQzMiLAogICJcdTJGM0QiLAogICJcdTYyMDgiLAogICJcdTJGM0UiLAogICJcdTYyMzYiLAogICJcdTJGM0YiLAogICJcdTYyNEIiLAogICJcdTJGNDAiLAogICJcdTY1MkYiLAogICJcdTJGNDEiLAogICJcdTY1MzQiLAogICJcdTJGNDIiLAogICJcdTY1ODciLAogICJcdTJGNDMiLAogICJcdTY1OTciLAogICJcdTJGNDQiLAogICJcdTY1QTQiLAogICJcdTJGNDUiLAogICJcdTY1QjkiLAogICJcdTJGNDYiLAogICJcdTY1RTAiLAogICJcdTJGNDciLAogICJcdTY1RTUiLAogICJcdTJGNDgiLAogICJcdTY2RjAiLAogICJcdTJGNDkiLAogICJcdTY3MDgiLAogICJcdTJGNEEiLAogICJcdTY3MjgiLAogICJcdTJGNEIiLAogICJcdTZCMjAiLAogICJcdTJGNEMiLAogICJcdTZCNjIiLAogICJcdTJGNEQiLAogICJcdTZCNzkiLAogICJcdTJGNEUiLAogICJcdTZCQjMiLAogICJcdTJGNEYiLAogICJcdTZCQ0IiLAogICJcdTJGNTAiLAogICJcdTZCRDQiLAogICJcdTJGNTEiLAogICJcdTZCREIiLAogICJcdTJGNTIiLAogICJcdTZDMEYiLAogICJcdTJGNTMiLAogICJcdTZDMTQiLAogICJcdTJGNTQiLAogICJcdTZDMzQiLAogICJcdTJGNTUiLAogICJcdTcwNkIiLAogICJcdTJGNTYiLAogICJcdTcyMkEiLAogICJcdTJGNTciLAogICJcdTcyMzYiLAogICJcdTJGNTgiLAogICJcdTcyM0IiLAogICJcdTJGNTkiLAogICJcdTcyM0YiLAogICJcdTJGNUEiLAogICJcdTcyNDciLAogICJcdTJGNUIiLAogICJcdTcyNTkiLAogICJcdTJGNUMiLAogICJcdTcyNUIiLAogICJcdTJGNUQiLAogICJcdTcyQUMiLAogICJcdTJGNUUiLAogICJcdTczODQiLAogICJcdTJGNUYiLAogICJcdTczODkiLAogICJcdTJGNjAiLAogICJcdTc0REMiLAogICJcdTJGNjEiLAogICJcdTc0RTYiLAogICJcdTJGNjIiLAogICJcdTc1MTgiLAogICJcdTJGNjMiLAogICJcdTc1MUYiLAogICJcdTJGNjQiLAogICJcdTc1MjgiLAogICJcdTJGNjUiLAogICJcdTc1MzAiLAogICJcdTJGNjYiLAogICJcdTc1OEIiLAogICJcdTJGNjciLAogICJcdTc1OTIiLAogICJcdTJGNjgiLAogICJcdTc2NzYiLAogICJcdTJGNjkiLAogICJcdTc2N0QiLAogICJcdTJGNkEiLAogICJcdTc2QUUiLAogICJcdTJGNkIiLAogICJcdTc2QkYiLAogICJcdTJGNkMiLAogICJcdTc2RUUiLAogICJcdTJGNkQiLAogICJcdTc3REIiLAogICJcdTJGNkUiLAogICJcdTc3RTIiLAogICJcdTJGNkYiLAogICJcdTc3RjMiLAogICJcdTJGNzAiLAogICJcdTc5M0EiLAogICJcdTJGNzEiLAogICJcdTc5QjgiLAogICJcdTJGNzIiLAogICJcdTc5QkUiLAogICJcdTJGNzMiLAogICJcdTdBNzQiLAogICJcdTJGNzQiLAogICJcdTdBQ0IiLAogICJcdTJGNzUiLAogICJcdTdBRjkiLAogICJcdTJGNzYiLAogICJcdTdDNzMiLAogICJcdTJGNzciLAogICJcdTdDRjgiLAogICJcdTJGNzgiLAogICJcdTdGMzYiLAogICJcdTJGNzkiLAogICJcdTdGNTEiLAogICJcdTJGN0EiLAogICJcdTdGOEEiLAogICJcdTJGN0IiLAogICJcdTdGQkQiLAogICJcdTJGN0MiLAogICJcdTgwMDEiLAogICJcdTJGN0QiLAogICJcdTgwMEMiLAogICJcdTJGN0UiLAogICJcdTgwMTIiLAogICJcdTJGN0YiLAogICJcdTgwMzMiLAogICJcdTJGODAiLAogICJcdTgwN0YiLAogICJcdTJGODEiLAogICJcdTgwODkiLAogICJcdTJGODIiLAogICJcdTgxRTMiLAogICJcdTJGODMiLAogICJcdTgxRUEiLAogICJcdTJGODQiLAogICJcdTgxRjMiLAogICJcdTJGODUiLAogICJcdTgxRkMiLAogICJcdTJGODYiLAogICJcdTgyMEMiLAogICJcdTJGODciLAogICJcdTgyMUIiLAogICJcdTJGODgiLAogICJcdTgyMUYiLAogICJcdTJGODkiLAogICJcdTgyNkUiLAogICJcdTJGOEEiLAogICJcdTgyNzIiLAogICJcdTJGOEIiLAogICJcdTgyNzgiLAogICJcdTJGOEMiLAogICJcdTg2NEQiLAogICJcdTJGOEQiLAogICJcdTg2NkIiLAogICJcdTJGOEUiLAogICJcdTg4NDAiLAogICJcdTJGOEYiLAogICJcdTg4NEMiLAogICJcdTJGOTAiLAogICJcdTg4NjMiLAogICJcdTJGOTEiLAogICJcdTg5N0UiLAogICJcdTJGOTIiLAogICJcdTg5OEIiLAogICJcdTJGOTMiLAogICJcdTg5RDIiLAogICJcdTJGOTQiLAogICJcdThBMDAiLAogICJcdTJGOTUiLAogICJcdThDMzciLAogICJcdTJGOTYiLAogICJcdThDNDYiLAogICJcdTJGOTciLAogICJcdThDNTUiLAogICJcdTJGOTgiLAogICJcdThDNzgiLAogICJcdTJGOTkiLAogICJcdThDOUQiLAogICJcdTJGOUEiLAogICJcdThENjQiLAogICJcdTJGOUIiLAogICJcdThENzAiLAogICJcdTJGOUMiLAogICJcdThEQjMiLAogICJcdTJGOUQiLAogICJcdThFQUIiLAogICJcdTJGOUUiLAogICJcdThFQ0EiLAogICJcdTJGOUYiLAogICJcdThGOUIiLAogICJcdTJGQTAiLAogICJcdThGQjAiLAogICJcdTJGQTEiLAogICJcdThGQjUiLAogICJcdTJGQTIiLAogICJcdTkwOTEiLAogICJcdTJGQTMiLAogICJcdTkxNDkiLAogICJcdTJGQTQiLAogICJcdTkxQzYiLAogICJcdTJGQTUiLAogICJcdTkxQ0MiLAogICJcdTJGQTYiLAogICJcdTkxRDEiLAogICJcdTJGQTciLAogICJcdTk1NzciLAogICJcdTJGQTgiLAogICJcdTk1ODAiLAogICJcdTJGQTkiLAogICJcdTk2MUMiLAogICJcdTJGQUEiLAogICJcdTk2QjYiLAogICJcdTJGQUIiLAogICJcdTk2QjkiLAogICJcdTJGQUMiLAogICJcdTk2RTgiLAogICJcdTJGQUQiLAogICJcdTk3NTEiLAogICJcdTJGQUUiLAogICJcdTk3NUUiLAogICJcdTJGQUYiLAogICJcdTk3NjIiLAogICJcdTJGQjAiLAogICJcdTk3NjkiLAogICJcdTJGQjEiLAogICJcdTk3Q0IiLAogICJcdTJGQjIiLAogICJcdTk3RUQiLAogICJcdTJGQjMiLAogICJcdTk3RjMiLAogICJcdTJGQjQiLAogICJcdTk4MDEiLAogICJcdTJGQjUiLAogICJcdTk4QTgiLAogICJcdTJGQjYiLAogICJcdTk4REIiLAogICJcdTJGQjciLAogICJcdTk4REYiLAogICJcdTJGQjgiLAogICJcdTk5OTYiLAogICJcdTJGQjkiLAogICJcdTk5OTkiLAogICJcdTJGQkEiLAogICJcdTk5QUMiLAogICJcdTJGQkIiLAogICJcdTlBQTgiLAogICJcdTJGQkMiLAogICJcdTlBRDgiLAogICJcdTJGQkQiLAogICJcdTlBREYiLAogICJcdTJGQkUiLAogICJcdTlCMjUiLAogICJcdTJGQkYiLAogICJcdTlCMkYiLAogICJcdTJGQzAiLAogICJcdTlCMzIiLAogICJcdTJGQzEiLAogICJcdTlCM0MiLAogICJcdTJGQzIiLAogICJcdTlCNUEiLAogICJcdTJGQzMiLAogICJcdTlDRTUiLAogICJcdTJGQzQiLAogICJcdTlFNzUiLAogICJcdTJGQzUiLAogICJcdTlFN0YiLAogICJcdTJGQzYiLAogICJcdTlFQTUiLAogICJcdTJGQzciLAogICJcdTlFQkIiLAogICJcdTJGQzgiLAogICJcdTlFQzMiLAogICJcdTJGQzkiLAogICJcdTlFQ0QiLAogICJcdTJGQ0EiLAogICJcdTlFRDEiLAogICJcdTJGQ0IiLAogICJcdTlFRjkiLAogICJcdTJGQ0MiLAogICJcdTlFRkQiLAogICJcdTJGQ0QiLAogICJcdTlGMEUiLAogICJcdTJGQ0UiLAogICJcdTlGMTMiLAogICJcdTJGQ0YiLAogICJcdTlGMjAiLAogICJcdTJGRDAiLAogICJcdTlGM0IiLAogICJcdTJGRDEiLAogICJcdTlGNEEiLAogICJcdTJGRDIiLAogICJcdTlGNTIiLAogICJcdTJGRDMiLAogICJcdTlGOEQiLAogICJcdTJGRDQiLAogICJcdTlGOUMiLAogICJcdTJGRDUiLAogICJcdTlGQTAiLAogICJcdTMwMzYiLAogICJcdTMwMTIiLAogICJcdTMwMzgiLAogICJcdTUzNDEiLAogICJcdTMwMzkiLAogICJcdTUzNDQiLAogICJcdTMwM0EiLAogICJcdTUzNDUiLAogICJcdTMwOUIiLAogICJcdTAwMjBcdTMwOTkiLAogICJcdTMwOUMiLAogICJcdTAwMjBcdTMwOUEiLAogICJcdTMxMzEiLAogICJcdTExMDAiLAogICJcdTMxMzIiLAogICJcdTExMDEiLAogICJcdTMxMzMiLAogICJcdTExQUEiLAogICJcdTMxMzQiLAogICJcdTExMDIiLAogICJcdTMxMzUiLAogICJcdTExQUMiLAogICJcdTMxMzYiLAogICJcdTExQUQiLAogICJcdTMxMzciLAogICJcdTExMDMiLAogICJcdTMxMzgiLAogICJcdTExMDQiLAogICJcdTMxMzkiLAogICJcdTExMDUiLAogICJcdTMxM0EiLAogICJcdTExQjAiLAogICJcdTMxM0IiLAogICJcdTExQjEiLAogICJcdTMxM0MiLAogICJcdTExQjIiLAogICJcdTMxM0QiLAogICJcdTExQjMiLAogICJcdTMxM0UiLAogICJcdTExQjQiLAogICJcdTMxM0YiLAogICJcdTExQjUiLAogICJcdTMxNDAiLAogICJcdTExMUEiLAogICJcdTMxNDEiLAogICJcdTExMDYiLAogICJcdTMxNDIiLAogICJcdTExMDciLAogICJcdTMxNDMiLAogICJcdTExMDgiLAogICJcdTMxNDQiLAogICJcdTExMjEiLAogICJcdTMxNDUiLAogICJcdTExMDkiLAogICJcdTMxNDYiLAogICJcdTExMEEiLAogICJcdTMxNDciLAogICJcdTExMEIiLAogICJcdTMxNDgiLAogICJcdTExMEMiLAogICJcdTMxNDkiLAogICJcdTExMEQiLAogICJcdTMxNEEiLAogICJcdTExMEUiLAogICJcdTMxNEIiLAogICJcdTExMEYiLAogICJcdTMxNEMiLAogICJcdTExMTAiLAogICJcdTMxNEQiLAogICJcdTExMTEiLAogICJcdTMxNEUiLAogICJcdTExMTIiLAogICJcdTMxNEYiLAogICJcdTExNjEiLAogICJcdTMxNTAiLAogICJcdTExNjIiLAogICJcdTMxNTEiLAogICJcdTExNjMiLAogICJcdTMxNTIiLAogICJcdTExNjQiLAogICJcdTMxNTMiLAogICJcdTExNjUiLAogICJcdTMxNTQiLAogICJcdTExNjYiLAogICJcdTMxNTUiLAogICJcdTExNjciLAogICJcdTMxNTYiLAogICJcdTExNjgiLAogICJcdTMxNTciLAogICJcdTExNjkiLAogICJcdTMxNTgiLAogICJcdTExNkEiLAogICJcdTMxNTkiLAogICJcdTExNkIiLAogICJcdTMxNUEiLAogICJcdTExNkMiLAogICJcdTMxNUIiLAogICJcdTExNkQiLAogICJcdTMxNUMiLAogICJcdTExNkUiLAogICJcdTMxNUQiLAogICJcdTExNkYiLAogICJcdTMxNUUiLAogICJcdTExNzAiLAogICJcdTMxNUYiLAogICJcdTExNzEiLAogICJcdTMxNjAiLAogICJcdTExNzIiLAogICJcdTMxNjEiLAogICJcdTExNzMiLAogICJcdTMxNjIiLAogICJcdTExNzQiLAogICJcdTMxNjMiLAogICJcdTExNzUiLAogICJcdTMxNjQiLAogICJcdTExNjAiLAogICJcdTMxNjUiLAogICJcdTExMTQiLAogICJcdTMxNjYiLAogICJcdTExMTUiLAogICJcdTMxNjciLAogICJcdTExQzciLAogICJcdTMxNjgiLAogICJcdTExQzgiLAogICJcdTMxNjkiLAogICJcdTExQ0MiLAogICJcdTMxNkEiLAogICJcdTExQ0UiLAogICJcdTMxNkIiLAogICJcdTExRDMiLAogICJcdTMxNkMiLAogICJcdTExRDciLAogICJcdTMxNkQiLAogICJcdTExRDkiLAogICJcdTMxNkUiLAogICJcdTExMUMiLAogICJcdTMxNkYiLAogICJcdTExREQiLAogICJcdTMxNzAiLAogICJcdTExREYiLAogICJcdTMxNzEiLAogICJcdTExMUQiLAogICJcdTMxNzIiLAogICJcdTExMUUiLAogICJcdTMxNzMiLAogICJcdTExMjAiLAogICJcdTMxNzQiLAogICJcdTExMjIiLAogICJcdTMxNzUiLAogICJcdTExMjMiLAogICJcdTMxNzYiLAogICJcdTExMjciLAogICJcdTMxNzciLAogICJcdTExMjkiLAogICJcdTMxNzgiLAogICJcdTExMkIiLAogICJcdTMxNzkiLAogICJcdTExMkMiLAogICJcdTMxN0EiLAogICJcdTExMkQiLAogICJcdTMxN0IiLAogICJcdTExMkUiLAogICJcdTMxN0MiLAogICJcdTExMkYiLAogICJcdTMxN0QiLAogICJcdTExMzIiLAogICJcdTMxN0UiLAogICJcdTExMzYiLAogICJcdTMxN0YiLAogICJcdTExNDAiLAogICJcdTMxODAiLAogICJcdTExNDciLAogICJcdTMxODEiLAogICJcdTExNEMiLAogICJcdTMxODIiLAogICJcdTExRjEiLAogICJcdTMxODMiLAogICJcdTExRjIiLAogICJcdTMxODQiLAogICJcdTExNTciLAogICJcdTMxODUiLAogICJcdTExNTgiLAogICJcdTMxODYiLAogICJcdTExNTkiLAogICJcdTMxODciLAogICJcdTExODQiLAogICJcdTMxODgiLAogICJcdTExODUiLAogICJcdTMxODkiLAogICJcdTExODgiLAogICJcdTMxOEEiLAogICJcdTExOTEiLAogICJcdTMxOEIiLAogICJcdTExOTIiLAogICJcdTMxOEMiLAogICJcdTExOTQiLAogICJcdTMxOEQiLAogICJcdTExOUUiLAogICJcdTMxOEUiLAogICJcdTExQTEiLAogICJcdTMyMDAiLAogICJcdTAwMjhcdTExMDBcdTAwMjkiLAogICJcdTMyMDEiLAogICJcdTAwMjhcdTExMDJcdTAwMjkiLAogICJcdTMyMDIiLAogICJcdTAwMjhcdTExMDNcdTAwMjkiLAogICJcdTMyMDMiLAogICJcdTAwMjhcdTExMDVcdTAwMjkiLAogICJcdTMyMDQiLAogICJcdTAwMjhcdTExMDZcdTAwMjkiLAogICJcdTMyMDUiLAogICJcdTAwMjhcdTExMDdcdTAwMjkiLAogICJcdTMyMDYiLAogICJcdTAwMjhcdTExMDlcdTAwMjkiLAogICJcdTMyMDciLAogICJcdTAwMjhcdTExMEJcdTAwMjkiLAogICJcdTMyMDgiLAogICJcdTAwMjhcdTExMENcdTAwMjkiLAogICJcdTMyMDkiLAogICJcdTAwMjhcdTExMEVcdTAwMjkiLAogICJcdTMyMEEiLAogICJcdTAwMjhcdTExMEZcdTAwMjkiLAogICJcdTMyMEIiLAogICJcdTAwMjhcdTExMTBcdTAwMjkiLAogICJcdTMyMEMiLAogICJcdTAwMjhcdTExMTFcdTAwMjkiLAogICJcdTMyMEQiLAogICJcdTAwMjhcdTExMTJcdTAwMjkiLAogICJcdTMyMEUiLAogICJcdTAwMjhcdTExMDBcdTExNjFcdTAwMjkiLAogICJcdTMyMEYiLAogICJcdTAwMjhcdTExMDJcdTExNjFcdTAwMjkiLAogICJcdTMyMTAiLAogICJcdTAwMjhcdTExMDNcdTExNjFcdTAwMjkiLAogICJcdTMyMTEiLAogICJcdTAwMjhcdTExMDVcdTExNjFcdTAwMjkiLAogICJcdTMyMTIiLAogICJcdTAwMjhcdTExMDZcdTExNjFcdTAwMjkiLAogICJcdTMyMTMiLAogICJcdTAwMjhcdTExMDdcdTExNjFcdTAwMjkiLAogICJcdTMyMTQiLAogICJcdTAwMjhcdTExMDlcdTExNjFcdTAwMjkiLAogICJcdTMyMTUiLAogICJcdTAwMjhcdTExMEJcdTExNjFcdTAwMjkiLAogICJcdTMyMTYiLAogICJcdTAwMjhcdTExMENcdTExNjFcdTAwMjkiLAogICJcdTMyMTciLAogICJcdTAwMjhcdTExMEVcdTExNjFcdTAwMjkiLAogICJcdTMyMTgiLAogICJcdTAwMjhcdTExMEZcdTExNjFcdTAwMjkiLAogICJcdTMyMTkiLAogICJcdTAwMjhcdTExMTBcdTExNjFcdTAwMjkiLAogICJcdTMyMUEiLAogICJcdTAwMjhcdTExMTFcdTExNjFcdTAwMjkiLAogICJcdTMyMUIiLAogICJcdTAwMjhcdTExMTJcdTExNjFcdTAwMjkiLAogICJcdTMyMUMiLAogICJcdTAwMjhcdTExMENcdTExNkVcdTAwMjkiLAogICJcdTMyMUQiLAogICJcdTAwMjhcdTExMEJcdTExNjlcdTExMENcdTExNjVcdTExQUJcdTAwMjkiLAogICJcdTMyMUUiLAogICJcdTAwMjhcdTExMEJcdTExNjlcdTExMTJcdTExNkVcdTAwMjkiLAogICJcdTMyMjAiLAogICJcdTAwMjhcdTRFMDBcdTAwMjkiLAogICJcdTMyMjEiLAogICJcdTAwMjhcdTRFOENcdTAwMjkiLAogICJcdTMyMjIiLAogICJcdTAwMjhcdTRFMDlcdTAwMjkiLAogICJcdTMyMjMiLAogICJcdTAwMjhcdTU2REJcdTAwMjkiLAogICJcdTMyMjQiLAogICJcdTAwMjhcdTRFOTRcdTAwMjkiLAogICJcdTMyMjUiLAogICJcdTAwMjhcdTUxNkRcdTAwMjkiLAogICJcdTMyMjYiLAogICJcdTAwMjhcdTRFMDNcdTAwMjkiLAogICJcdTMyMjciLAogICJcdTAwMjhcdTUxNkJcdTAwMjkiLAogICJcdTMyMjgiLAogICJcdTAwMjhcdTRFNURcdTAwMjkiLAogICJcdTMyMjkiLAogICJcdTAwMjhcdTUzNDFcdTAwMjkiLAogICJcdTMyMkEiLAogICJcdTAwMjhcdTY3MDhcdTAwMjkiLAogICJcdTMyMkIiLAogICJcdTAwMjhcdTcwNkJcdTAwMjkiLAogICJcdTMyMkMiLAogICJcdTAwMjhcdTZDMzRcdTAwMjkiLAogICJcdTMyMkQiLAogICJcdTAwMjhcdTY3MjhcdTAwMjkiLAogICJcdTMyMkUiLAogICJcdTAwMjhcdTkxRDFcdTAwMjkiLAogICJcdTMyMkYiLAogICJcdTAwMjhcdTU3MUZcdTAwMjkiLAogICJcdTMyMzAiLAogICJcdTAwMjhcdTY1RTVcdTAwMjkiLAogICJcdTMyMzEiLAogICJcdTAwMjhcdTY4MkFcdTAwMjkiLAogICJcdTMyMzIiLAogICJcdTAwMjhcdTY3MDlcdTAwMjkiLAogICJcdTMyMzMiLAogICJcdTAwMjhcdTc5M0VcdTAwMjkiLAogICJcdTMyMzQiLAogICJcdTAwMjhcdTU0MERcdTAwMjkiLAogICJcdTMyMzUiLAogICJcdTAwMjhcdTcyNzlcdTAwMjkiLAogICJcdTMyMzYiLAogICJcdTAwMjhcdThDQTFcdTAwMjkiLAogICJcdTMyMzciLAogICJcdTAwMjhcdTc5NURcdTAwMjkiLAogICJcdTMyMzgiLAogICJcdTAwMjhcdTUyQjRcdTAwMjkiLAogICJcdTMyMzkiLAogICJcdTAwMjhcdTRFRTNcdTAwMjkiLAogICJcdTMyM0EiLAogICJcdTAwMjhcdTU0N0NcdTAwMjkiLAogICJcdTMyM0IiLAogICJcdTAwMjhcdTVCNjZcdTAwMjkiLAogICJcdTMyM0MiLAogICJcdTAwMjhcdTc2RTNcdTAwMjkiLAogICJcdTMyM0QiLAogICJcdTAwMjhcdTRGMDFcdTAwMjkiLAogICJcdTMyM0UiLAogICJcdTAwMjhcdThDQzdcdTAwMjkiLAogICJcdTMyM0YiLAogICJcdTAwMjhcdTUzNTRcdTAwMjkiLAogICJcdTMyNDAiLAogICJcdTAwMjhcdTc5NkRcdTAwMjkiLAogICJcdTMyNDEiLAogICJcdTAwMjhcdTRGMTFcdTAwMjkiLAogICJcdTMyNDIiLAogICJcdTAwMjhcdTgxRUFcdTAwMjkiLAogICJcdTMyNDMiLAogICJcdTAwMjhcdTgxRjNcdTAwMjkiLAogICJcdTMyQzAiLAogICJcdTAwMzFcdTY3MDgiLAogICJcdTMyQzEiLAogICJcdTAwMzJcdTY3MDgiLAogICJcdTMyQzIiLAogICJcdTAwMzNcdTY3MDgiLAogICJcdTMyQzMiLAogICJcdTAwMzRcdTY3MDgiLAogICJcdTMyQzQiLAogICJcdTAwMzVcdTY3MDgiLAogICJcdTMyQzUiLAogICJcdTAwMzZcdTY3MDgiLAogICJcdTMyQzYiLAogICJcdTAwMzdcdTY3MDgiLAogICJcdTMyQzciLAogICJcdTAwMzhcdTY3MDgiLAogICJcdTMyQzgiLAogICJcdTAwMz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JcdTY1RTUiLAogICJcdTMzRjYiLAogICJcdTAwMzJcdTAwMzNcdTY1RTUiLAogICJcdTMzRjciLAogICJcdTAwMzJcdTAwMzRcdTY1RTUiLAogICJcdTMzRjgiLAogICJcdTAwMzJcdTAwMzVcdTY1RTUiLAogICJcdTMzRjkiLAogICJcdTAwMzJcdTAwMzZcdTY1RTUiLAogICJcdTMzRkEiLAogICJcdTAwMzJcdTAwMzdcdTY1RTUiLAogICJcdTMzRkIiLAogICJcdTAwMzJcdTAwMzhcdTY1RTUiLAogICJcdTMzRkMiLAogICJcdTAwMzJcdTAwMzlcdTY1RTUiLAogICJcdTMzRkQiLAogICJcdTAwMzNcdTAwMzBcdTY1RTUiLAogICJcdTMzRkUiLAogICJcdTAwMzNcdTAwMzFcdTY1RTUiLAogICJcdUZCMDAiLAogICJcdTAwNjZcdTAwNjYiLAogICJcdUZCMDEiLAogICJcdTAwNjZcdTAwNjkiLAogICJcdUZCMDIiLAogICJcdTAwNjZcdTAwNkMiLAogICJcdUZCMDMiLAogICJcdTAwNjZcdTAwNjZcdTAwNjkiLAogICJcdUZCMDQiLAogICJcdTAwNjZcdTAwNjZcdTAwNkMiLAogICJcdUZCMDUiLAogICJcdTAxN0ZcdTAwNzQiLAogICJcdUZCMDYiLAogICJcdTAwNzNcdTAwNzQiLAogICJcdUZCMTMiLAogICJcdTA1NzRcdTA1NzYiLAogICJcdUZCMTQiLAogICJcdTA1NzRcdTA1NjUiLAogICJcdUZCMTUiLAogICJcdTA1NzRcdTA1NkIiLAogICJcdUZCMTYiLAogICJcdTA1N0VcdTA1NzYiLAogICJcdUZCMTciLAogICJcdTA1NzRcdTA1NkQiLAogICJcdUZCNEYiLAogICJcdTA1RDBcdTA1REMiLAogICJcdUZCNTAiLAogICJcdTA2NzEiLAogICJcdUZCNTEiLAogICJcdTA2NzEiLAogICJcdUZCNTIiLAogICJcdTA2N0IiLAogICJcdUZCNTMiLAogICJcdTA2N0IiLAogICJcdUZCNTQiLAogICJcdTA2N0IiLAogICJcdUZCNTUiLAogICJcdTA2N0IiLAogICJcdUZCNTYiLAogICJcdTA2N0UiLAogICJcdUZCNTciLAogICJcdTA2N0UiLAogICJcdUZCNTgiLAogICJcdTA2N0UiLAogICJcdUZCNTkiLAogICJcdTA2N0UiLAogICJcdUZCNUEiLAogICJcdTA2ODAiLAogICJcdUZCNUIiLAogICJcdTA2ODAiLAogICJcdUZCNUMiLAogICJcdTA2ODAiLAogICJcdUZCNUQiLAogICJcdTA2ODAiLAogICJcdUZCNUUiLAogICJcdTA2N0EiLAogICJcdUZCNUYiLAogICJcdTA2N0EiLAogICJcdUZCNjAiLAogICJcdTA2N0EiLAogICJcdUZCNjEiLAogICJcdTA2N0EiLAogICJcdUZCNjIiLAogICJcdTA2N0YiLAogICJcdUZCNjMiLAogICJcdTA2N0YiLAogICJcdUZCNjQiLAogICJcdTA2N0YiLAogICJcdUZCNjUiLAogICJcdTA2N0YiLAogICJcdUZCNjYiLAogICJcdTA2NzkiLAogICJcdUZCNjciLAogICJcdTA2NzkiLAogICJcdUZCNjgiLAogICJcdTA2NzkiLAogICJcdUZCNjkiLAogICJcdTA2NzkiLAogICJcdUZCNkEiLAogICJcdTA2QTQiLAogICJcdUZCNkIiLAogICJcdTA2QTQiLAogICJcdUZCNkMiLAogICJcdTA2QTQiLAogICJcdUZCNkQiLAogICJcdTA2QTQiLAogICJcdUZCNkUiLAogICJcdTA2QTYiLAogICJcdUZCNkYiLAogICJcdTA2QTYiLAogICJcdUZCNzAiLAogICJcdTA2QTYiLAogICJcdUZCNzEiLAogICJcdTA2QTYiLAogICJcdUZCNzIiLAogICJcdTA2ODQiLAogICJcdUZCNzMiLAogICJcdTA2ODQiLAogICJcdUZCNzQiLAogICJcdTA2ODQiLAogICJcdUZCNzUiLAogICJcdTA2ODQiLAogICJcdUZCNzYiLAogICJcdTA2ODMiLAogICJcdUZCNzciLAogICJcdTA2ODMiLAogICJcdUZCNzgiLAogICJcdTA2ODMiLAogICJcdUZCNzkiLAogICJcdTA2ODMiLAogICJcdUZCN0EiLAogICJcdTA2ODYiLAogICJcdUZCN0IiLAogICJcdTA2ODYiLAogICJcdUZCN0MiLAogICJcdTA2ODYiLAogICJcdUZCN0QiLAogICJcdTA2ODYiLAogICJcdUZCN0UiLAogICJcdTA2ODciLAogICJcdUZCN0YiLAogICJcdTA2ODciLAogICJcdUZCODAiLAogICJcdTA2ODciLAogICJcdUZCODEiLAogICJcdTA2ODciLAogICJcdUZCODIiLAogICJcdTA2OEQiLAogICJcdUZCODMiLAogICJcdTA2OEQiLAogICJcdUZCODQiLAogICJcdTA2OEMiLAogICJcdUZCODUiLAogICJcdTA2OEMiLAogICJcdUZCODYiLAogICJcdTA2OEUiLAogICJcdUZCODciLAogICJcdTA2OEUiLAogICJcdUZCODgiLAogICJcdTA2ODgiLAogICJcdUZCODkiLAogICJcdTA2ODgiLAogICJcdUZCOEEiLAogICJcdTA2OTgiLAogICJcdUZCOEIiLAogICJcdTA2OTgiLAogICJcdUZCOEMiLAogICJcdTA2OTEiLAogICJcdUZCOEQiLAogICJcdTA2OTEiLAogICJcdUZCOEUiLAogICJcdTA2QTkiLAogICJcdUZCOEYiLAogICJcdTA2QTkiLAogICJcdUZCOTAiLAogICJcdTA2QTkiLAogICJcdUZCOTEiLAogICJcdTA2QTkiLAogICJcdUZCOTIiLAogICJcdTA2QUYiLAogICJcdUZCOTMiLAogICJcdTA2QUYiLAogICJcdUZCOTQiLAogICJcdTA2QUYiLAogICJcdUZCOTUiLAogICJcdTA2QUYiLAogICJcdUZCOTYiLAogICJcdTA2QjMiLAogICJcdUZCOTciLAogICJcdTA2QjMiLAogICJcdUZCOTgiLAogICJcdTA2QjMiLAogICJcdUZCOTkiLAogICJcdTA2QjMiLAogICJcdUZCOUEiLAogICJcdTA2QjEiLAogICJcdUZCOUIiLAogICJcdTA2QjEiLAogICJcdUZCOUMiLAogICJcdTA2QjEiLAogICJcdUZCOUQiLAogICJcdTA2QjEiLAogICJcdUZCOUUiLAogICJcdTA2QkEiLAogICJcdUZCOUYiLAogICJcdTA2QkEiLAogICJcdUZCQTAiLAogICJcdTA2QkIiLAogICJcdUZCQTEiLAogICJcdTA2QkIiLAogICJcdUZCQTIiLAogICJcdTA2QkIiLAogICJcdUZCQTMiLAogICJcdTA2QkIiLAogICJcdUZCQTQiLAogICJcdTA2QzAiLAogICJcdUZCQTUiLAogICJcdTA2QzAiLAogICJcdUZCQTYiLAogICJcdTA2QzEiLAogICJcdUZCQTciLAogICJcdTA2QzEiLAogICJcdUZCQTgiLAogICJcdTA2QzEiLAogICJcdUZCQTkiLAogICJcdTA2QzEiLAogICJcdUZCQUEiLAogICJcdTA2QkUiLAogICJcdUZCQUIiLAogICJcdTA2QkUiLAogICJcdUZCQUMiLAogICJcdTA2QkUiLAogICJcdUZCQUQiLAogICJcdTA2QkUiLAogICJcdUZCQUUiLAogICJcdTA2RDIiLAogICJcdUZCQUYiLAogICJcdTA2RDIiLAogICJcdUZCQjAiLAogICJcdTA2RDMiLAogICJcdUZCQjEiLAogICJcdTA2RDMiLAogICJcdUZCRDMiLAogICJcdTA2QUQiLAogICJcdUZCRDQiLAogICJcdTA2QUQiLAogICJcdUZCRDUiLAogICJcdTA2QUQiLAogICJcdUZCRDYiLAogICJcdTA2QUQiLAogICJcdUZCRDciLAogICJcdTA2QzciLAogICJcdUZCRDgiLAogICJcdTA2QzciLAogICJcdUZCRDkiLAogICJcdTA2QzYiLAogICJcdUZCREEiLAogICJcdTA2QzYiLAogICJcdUZCREIiLAogICJcdTA2QzgiLAogICJcdUZCREMiLAogICJcdTA2QzgiLAogICJcdUZCREQiLAogICJcdTA2NzciLAogICJcdUZCREUiLAogICJcdTA2Q0IiLAogICJcdUZCREYiLAogICJcdTA2Q0IiLAogICJcdUZCRTAiLAogICJcdTA2QzUiLAogICJcdUZCRTEiLAogICJcdTA2QzUiLAogICJcdUZCRTIiLAogICJcdTA2QzkiLAogICJcdUZCRTMiLAogICJcdTA2QzkiLAogICJcdUZCRTQiLAogICJcdTA2RDAiLAogICJcdUZCRTUiLAogICJcdTA2RDAiLAogICJcdUZCRTYiLAogICJcdTA2RDAiLAogICJcdUZCRTciLAogICJcdTA2RDAiLAogICJcdUZCRTgiLAogICJcdTA2NDkiLAogICJcdUZCRTkiLAogICJcdTA2NDkiLAogICJcdUZCRUEiLAogICJcdTA2MjZcdTA2MjciLAogICJcdUZCRUIiLAogICJcdTA2MjZcdTA2MjciLAogICJcdUZCRUMiLAogICJcdTA2MjZcdTA2RDUiLAogICJcdUZCRUQiLAogICJcdTA2MjZcdTA2RDUiLAogICJcdUZCRUUiLAogICJcdTA2MjZcdTA2NDgiLAogICJcdUZCRUYiLAogICJcdTA2MjZcdTA2NDgiLAogICJcdUZCRjAiLAogICJcdTA2MjZcdTA2QzciLAogICJcdUZCRjEiLAogICJcdTA2MjZcdTA2QzciLAogICJcdUZCRjIiLAogICJcdTA2MjZcdTA2QzYiLAogICJcdUZCRjMiLAogICJcdTA2MjZcdTA2QzYiLAogICJcdUZCRjQiLAogICJcdTA2MjZcdTA2QzgiLAogICJcdUZCRjUiLAogICJcdTA2MjZcdTA2QzgiLAogICJcdUZCRjYiLAogICJcdTA2MjZcdTA2RDAiLAogICJcdUZCRjciLAogICJcdTA2MjZcdTA2RDAiLAogICJcdUZCRjgiLAogICJcdTA2MjZcdTA2RDAiLAogICJcdUZCRjkiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZCRkEiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZCRkIiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZCRkMiLAogICJcdTA2Q0MiLAogICJcdUZCRkQiLAogICJcdTA2Q0MiLAogICJcdUZCRkUiLAogICJcdTA2Q0MiLAogICJcdUZCRkYiLAogICJcdTA2Q0MiLAogICJcdUZDMDAiLAogICJcdTA2MjZcdTA2MkMiLAogICJcdUZDMDEiLAogICJcdTA2MjZcdTA2MkQiLAogICJcdUZDMDIiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDMDMiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZDMDQiLAogICJcdTA2MjZcdTA2NEEiLAogICJcdUZDMDUiLAogICJcdTA2MjhcdTA2MkMiLAogICJcdUZDMDYiLAogICJcdTA2MjhcdTA2MkQiLAogICJcdUZDMDciLAogICJcdTA2MjhcdTA2MkUiLAogICJcdUZDMDgiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDMDkiLAogICJcdTA2MjhcdTA2NDkiLAogICJcdUZDMEEiLAogICJcdTA2MjhcdTA2NEEiLAogICJcdUZDMEIiLAogICJcdTA2MkFcdTA2MkMiLAogICJcdUZDMEMiLAogICJcdTA2MkFcdTA2MkQiLAogICJcdUZDMEQiLAogICJcdTA2MkFcdTA2MkUiLAogICJcdUZDMEUiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDMEYiLAogICJcdTA2MkFcdTA2NDkiLAogICJcdUZDMTAiLAogICJcdTA2MkFcdTA2NEEiLAogICJcdUZDMTEiLAogICJcdTA2MkJcdTA2MkMiLAogICJcdUZDMTIiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDMTMiLAogICJcdTA2MkJcdTA2NDkiLAogICJcdUZDMTQiLAogICJcdTA2MkJcdTA2NEEiLAogICJcdUZDMTUiLAogICJcdTA2MkNcdTA2MkQiLAogICJcdUZDMTYiLAogICJcdTA2MkNcdTA2NDUiLAogICJcdUZDMTciLAogICJcdTA2MkRcdTA2MkMiLAogICJcdUZDMTgiLAogICJcdTA2MkRcdTA2NDUiLAogICJcdUZDMTkiLAogICJcdTA2MkVcdTA2MkMiLAogICJcdUZDMUEiLAogICJcdTA2MkVcdTA2MkQiLAogICJcdUZDMUIiLAogICJcdTA2MkVcdTA2NDUiLAogICJcdUZDMUMiLAogICJcdTA2MzNcdTA2MkMiLAogICJcdUZDMUQiLAogICJcdTA2MzNcdTA2MkQiLAogICJcdUZDMUUiLAogICJcdTA2MzNcdTA2MkUiLAogICJcdUZDMUYiLAogICJcdTA2MzNcdTA2NDUiLAogICJcdUZDMjAiLAogICJcdTA2MzVcdTA2MkQiLAogICJcdUZDMjEiLAogICJcdTA2MzVcdTA2NDUiLAogICJcdUZDMjIiLAogICJcdTA2MzZcdTA2MkMiLAogICJcdUZDMjMiLAogICJcdTA2MzZcdTA2MkQiLAogICJcdUZDMjQiLAogICJcdTA2MzZcdTA2MkUiLAogICJcdUZDMjUiLAogICJcdTA2MzZcdTA2NDUiLAogICJcdUZDMjYiLAogICJcdTA2MzdcdTA2MkQiLAogICJcdUZDMjciLAogICJcdTA2MzdcdTA2NDUiLAogICJcdUZDMjgiLAogICJcdTA2MzhcdTA2NDUiLAogICJcdUZDMjkiLAogICJcdTA2MzlcdTA2MkMiLAogICJcdUZDMkEiLAogICJcdTA2MzlcdTA2NDUiLAogICJcdUZDMkIiLAogICJcdTA2M0FcdTA2MkMiLAogICJcdUZDMkMiLAogICJcdTA2M0FcdTA2NDUiLAogICJcdUZDMkQiLAogICJcdTA2NDFcdTA2MkMiLAogICJcdUZDMkUiLAogICJcdTA2NDFcdTA2MkQiLAogICJcdUZDMkYiLAogICJcdTA2NDFcdTA2MkUiLAogICJcdUZDMzAiLAogICJcdTA2NDFcdTA2NDUiLAogICJcdUZDMzEiLAogICJcdTA2NDFcdTA2NDkiLAogICJcdUZDMzIiLAogICJcdTA2NDFcdTA2NEEiLAogICJcdUZDMzMiLAogICJcdTA2NDJcdTA2MkQiLAogICJcdUZDMzQiLAogICJcdTA2NDJcdTA2NDUiLAogICJcdUZDMzUiLAogICJcdTA2NDJcdTA2NDkiLAogICJcdUZDMzYiLAogICJcdTA2NDJcdTA2NEEiLAogICJcdUZDMzciLAogICJcdTA2NDNcdTA2MjciLAogICJcdUZDMzgiLAogICJcdTA2NDNcdTA2MkMiLAogICJcdUZDMzkiLAogICJcdTA2NDNcdTA2MkQiLAogICJcdUZDM0EiLAogICJcdTA2NDNcdTA2MkUiLAogICJcdUZDM0IiLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDM0MiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDM0QiLAogICJcdTA2NDNcdTA2NDkiLAogICJcdUZDM0UiLAogICJcdTA2NDNcdTA2NEEiLAogICJcdUZDM0YiLAogICJcdTA2NDRcdTA2MkMiLAogICJcdUZDNDAiLAogICJcdTA2NDRcdTA2MkQiLAogICJcdUZDNDEiLAogICJcdTA2NDRcdTA2MkUiLAogICJcdUZDNDIiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDNDMiLAogICJcdTA2NDRcdTA2NDkiLAogICJcdUZDNDQiLAogICJcdTA2NDRcdTA2NEEiLAogICJcdUZDNDUiLAogICJcdTA2NDVcdTA2MkMiLAogICJcdUZDNDYiLAogICJcdTA2NDVcdTA2MkQiLAogICJcdUZDNDciLAogICJcdTA2NDVcdTA2MkUiLAogICJcdUZDNDgiLAogICJcdTA2NDVcdTA2NDUiLAogICJcdUZDNDkiLAogICJcdTA2NDVcdTA2NDkiLAogICJcdUZDNEEiLAogICJcdTA2NDVcdTA2NEEiLAogICJcdUZDNEIiLAogICJcdTA2NDZcdTA2MkMiLAogICJcdUZDNEMiLAogICJcdTA2NDZcdTA2MkQiLAogICJcdUZDNEQiLAogICJcdTA2NDZcdTA2MkUiLAogICJcdUZDNEUiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDNEYiLAogICJcdTA2NDZcdTA2NDkiLAogICJcdUZDNTAiLAogICJcdTA2NDZcdTA2NEEiLAogICJcdUZDNTEiLAogICJcdTA2NDdcdTA2MkMiLAogICJcdUZDNTIiLAogICJcdTA2NDdcdTA2NDUiLAogICJcdUZDNTMiLAogICJcdTA2NDdcdTA2NDkiLAogICJcdUZDNTQiLAogICJcdTA2NDdcdTA2NEEiLAogICJcdUZDNTUiLAogICJcdTA2NEFcdTA2MkMiLAogICJcdUZDNTYiLAogICJcdTA2NEFcdTA2MkQiLAogICJcdUZDNTciLAogICJcdTA2NEFcdTA2MkUiLAogICJcdUZDNTgiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDNTkiLAogICJcdTA2NEFcdTA2NDkiLAogICJcdUZDNUEiLAogICJcdTA2NEFcdTA2NEEiLAogICJcdUZDNUIiLAogICJcdTA2MzBcdTA2NzAiLAogICJcdUZDNUMiLAogICJcdTA2MzFcdTA2NzAiLAogICJcdUZDNUQiLAogICJcdTA2NDlcdTA2NzAiLAogICJcdUZDNUUiLAogICJcdTAwMjBcdTA2NENcdTA2NTEiLAogICJcdUZDNUYiLAogICJcdTAwMjBcdTA2NERcdTA2NTEiLAogICJcdUZDNjAiLAogICJcdTAwMjBcdTA2NEVcdTA2NTEiLAogICJcdUZDNjEiLAogICJcdTAwMjBcdTA2NEZcdTA2NTEiLAogICJcdUZDNjIiLAogICJcdTAwMjBcdTA2NTBcdTA2NTEiLAogICJcdUZDNjMiLAogICJcdTAwMjBcdTA2NTFcdTA2NzAiLAogICJcdUZDNjQiLAogICJcdTA2MjZcdTA2MzEiLAogICJcdUZDNjUiLAogICJcdTA2MjZcdTA2MzIiLAogICJcdUZDNjYiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDNjciLAogICJcdTA2MjZcdTA2NDYiLAogICJcdUZDNjgiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZDNjkiLAogICJcdTA2MjZcdTA2NEEiLAogICJcdUZDNkEiLAogICJcdTA2MjhcdTA2MzEiLAogICJcdUZDNkIiLAogICJcdTA2MjhcdTA2MzIiLAogICJcdUZDNkMiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDNkQiLAogICJcdTA2MjhcdTA2NDYiLAogICJcdUZDNkUiLAogICJcdTA2MjhcdTA2NDkiLAogICJcdUZDNkYiLAogICJcdTA2MjhcdTA2NEEiLAogICJcdUZDNzAiLAogICJcdTA2MkFcdTA2MzEiLAogICJcdUZDNzEiLAogICJcdTA2MkFcdTA2MzIiLAogICJcdUZDNzIiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDNzMiLAogICJcdTA2MkFcdTA2NDYiLAogICJcdUZDNzQiLAogICJcdTA2MkFcdTA2NDkiLAogICJcdUZDNzUiLAogICJcdTA2MkFcdTA2NEEiLAogICJcdUZDNzYiLAogICJcdTA2MkJcdTA2MzEiLAogICJcdUZDNzciLAogICJcdTA2MkJcdTA2MzIiLAogICJcdUZDNzgiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDNzkiLAogICJcdTA2MkJcdTA2NDYiLAogICJcdUZDN0EiLAogICJcdTA2MkJcdTA2NDkiLAogICJcdUZDN0IiLAogICJcdTA2MkJcdTA2NEEiLAogICJcdUZDN0MiLAogICJcdTA2NDFcdTA2NDkiLAogICJcdUZDN0QiLAogICJcdTA2NDFcdTA2NEEiLAogICJcdUZDN0UiLAogICJcdTA2NDJcdTA2NDkiLAogICJcdUZDN0YiLAogICJcdTA2NDJcdTA2NEEiLAogICJcdUZDODAiLAogICJcdTA2NDNcdTA2MjciLAogICJcdUZDODEiLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDODIiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDODMiLAogICJcdTA2NDNcdTA2NDkiLAogICJcdUZDODQiLAogICJcdTA2NDNcdTA2NEEiLAogICJcdUZDODUiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDODYiLAogICJcdTA2NDRcdTA2NDkiLAogICJcdUZDODciLAogICJcdTA2NDRcdTA2NEEiLAogICJcdUZDODgiLAogICJcdTA2NDVcdTA2MjciLAogICJcdUZDODkiLAogICJcdTA2NDVcdTA2NDUiLAogICJcdUZDOEEiLAogICJcdTA2NDZcdTA2MzEiLAogICJcdUZDOEIiLAogICJcdTA2NDZcdTA2MzIiLAogICJcdUZDOEMiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDOEQiLAogICJcdTA2NDZcdTA2NDYiLAogICJcdUZDOEUiLAogICJcdTA2NDZcdTA2NDkiLAogICJcdUZDOEYiLAogICJcdTA2NDZcdTA2NEEiLAogICJcdUZDOTAiLAogICJcdTA2NDlcdTA2NzAiLAogICJcdUZDOTEiLAogICJcdTA2NEFcdTA2MzEiLAogICJcdUZDOTIiLAogICJcdTA2NEFcdTA2MzIiLAogICJcdUZDOTMiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDOTQiLAogICJcdTA2NEFcdTA2NDYiLAogICJcdUZDOTUiLAogICJcdTA2NEFcdTA2NDkiLAogICJcdUZDOTYiLAogICJcdTA2NEFcdTA2NEEiLAogICJcdUZDOTciLAogICJcdTA2MjZcdTA2MkMiLAogICJcdUZDOTgiLAogICJcdTA2MjZcdTA2MkQiLAogICJcdUZDOTkiLAogICJcdTA2MjZcdTA2MkUiLAogICJcdUZDOUEiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDOUIiLAogICJcdTA2MjZcdTA2NDciLAogICJcdUZDOUMiLAogICJcdTA2MjhcdTA2MkMiLAogICJcdUZDOUQiLAogICJcdTA2MjhcdTA2MkQiLAogICJcdUZDOUUiLAogICJcdTA2MjhcdTA2MkUiLAogICJcdUZDOUYiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDQTAiLAogICJcdTA2MjhcdTA2NDciLAogICJcdUZDQTEiLAogICJcdTA2MkFcdTA2MkMiLAogICJcdUZDQTIiLAogICJcdTA2MkFcdTA2MkQiLAogICJcdUZDQTMiLAogICJcdTA2MkFcdTA2MkUiLAogICJcdUZDQTQiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDQTUiLAogICJcdTA2MkFcdTA2NDciLAogICJcdUZDQTYiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDQTciLAogICJcdTA2MkNcdTA2MkQiLAogICJcdUZDQTgiLAogICJcdTA2MkNcdTA2NDUiLAogICJcdUZDQTkiLAogICJcdTA2MkRcdTA2MkMiLAogICJcdUZDQUEiLAogICJcdTA2MkRcdTA2NDUiLAogICJcdUZDQUIiLAogICJcdTA2MkVcdTA2MkMiLAogICJcdUZDQUMiLAogICJcdTA2MkVcdTA2NDUiLAogICJcdUZDQUQiLAogICJcdTA2MzNcdTA2MkMiLAogICJcdUZDQUUiLAogICJcdTA2MzNcdTA2MkQiLAogICJcdUZDQUYiLAogICJcdTA2MzNcdTA2MkUiLAogICJcdUZDQjAiLAogICJcdTA2MzNcdTA2NDUiLAogICJcdUZDQjEiLAogICJcdTA2MzVcdTA2MkQiLAogICJcdUZDQjIiLAogICJcdTA2MzVcdTA2MkUiLAogICJcdUZDQjMiLAogICJcdTA2MzVcdTA2NDUiLAogICJcdUZDQjQiLAogICJcdTA2MzZcdTA2MkMiLAogICJcdUZDQjUiLAogICJcdTA2MzZcdTA2MkQiLAogICJcdUZDQjYiLAogICJcdTA2MzZcdTA2MkUiLAogICJcdUZDQjciLAogICJcdTA2MzZcdTA2NDUiLAogICJcdUZDQjgiLAogICJcdTA2MzdcdTA2MkQiLAogICJcdUZDQjkiLAogICJcdTA2MzhcdTA2NDUiLAogICJcdUZDQkEiLAogICJcdTA2MzlcdTA2MkMiLAogICJcdUZDQkIiLAogICJcdTA2MzlcdTA2NDUiLAogICJcdUZDQkMiLAogICJcdTA2M0FcdTA2MkMiLAogICJcdUZDQkQiLAogICJcdTA2M0FcdTA2NDUiLAogICJcdUZDQkUiLAogICJcdTA2NDFcdTA2MkMiLAogICJcdUZDQkYiLAogICJcdTA2NDFcdTA2MkQiLAogICJcdUZDQzAiLAogICJcdTA2NDFcdTA2MkUiLAogICJcdUZDQzEiLAogICJcdTA2NDFcdTA2NDUiLAogICJcdUZDQzIiLAogICJcdTA2NDJcdTA2MkQiLAogICJcdUZDQzMiLAogICJcdTA2NDJcdTA2NDUiLAogICJcdUZDQzQiLAogICJcdTA2NDNcdTA2MkMiLAogICJcdUZDQzUiLAogICJcdTA2NDNcdTA2MkQiLAogICJcdUZDQzYiLAogICJcdTA2NDNcdTA2MkUiLAogICJcdUZDQzciLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDQzgiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDQzkiLAogICJcdTA2NDRcdTA2MkMiLAogICJcdUZDQ0EiLAogICJcdTA2NDRcdTA2MkQiLAogICJcdUZDQ0IiLAogICJcdTA2NDRcdTA2MkUiLAogICJcdUZDQ0MiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDQ0QiLAogICJcdTA2NDRcdTA2NDciLAogICJcdUZDQ0UiLAogICJcdTA2NDVcdTA2MkMiLAogICJcdUZDQ0YiLAogICJcdTA2NDVcdTA2MkQiLAogICJcdUZDRDAiLAogICJcdTA2NDVcdTA2MkUiLAogICJcdUZDRDEiLAogICJcdTA2NDVcdTA2NDUiLAogICJcdUZDRDIiLAogICJcdTA2NDZcdTA2MkMiLAogICJcdUZDRDMiLAogICJcdTA2NDZcdTA2MkQiLAogICJcdUZDRDQiLAogICJcdTA2NDZcdTA2MkUiLAogICJcdUZDRDUiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDRDYiLAogICJcdTA2NDZcdTA2NDciLAogICJcdUZDRDciLAogICJcdTA2NDdcdTA2MkMiLAogICJcdUZDRDgiLAogICJcdTA2NDdcdTA2NDUiLAogICJcdUZDRDkiLAogICJcdTA2NDdcdTA2NzAiLAogICJcdUZDREEiLAogICJcdTA2NEFcdTA2MkMiLAogICJcdUZDREIiLAogICJcdTA2NEFcdTA2MkQiLAogICJcdUZDREMiLAogICJcdTA2NEFcdTA2MkUiLAogICJcdUZDREQiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDREUiLAogICJcdTA2NEFcdTA2NDciLAogICJcdUZDREYiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDRTAiLAogICJcdTA2MjZcdTA2NDciLAogICJcdUZDRTEiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDRTIiLAogICJcdTA2MjhcdTA2NDciLAogICJcdUZDRTMiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDRTQiLAogICJcdTA2MkFcdTA2NDciLAogICJcdUZDRTUiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDRTYiLAogICJcdTA2MkJcdTA2NDciLAogICJcdUZDRTciLAogICJcdTA2MzNcdTA2NDUiLAogICJcdUZDRTgiLAogICJcdTA2MzNcdTA2NDciLAogICJcdUZDRTkiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZDRUEiLAogICJcdTA2MzRcdTA2NDciLAogICJcdUZDRUIiLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDRUMiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDRUQiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDRUUiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDRUYiLAogICJcdTA2NDZcdTA2NDciLAogICJcdUZDRjAiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDRjEiLAogICJcdTA2NEFcdTA2NDciLAogICJcdUZDRjIiLAogICJcdTA2NDBcdTA2NEVcdTA2NTEiLAogICJcdUZDRjMiLAogICJcdTA2NDBcdTA2NEZcdTA2NTEiLAogICJcdUZDRjQiLAogICJcdTA2NDBcdTA2NTBcdTA2NTEiLAogICJcdUZDRjUiLAogICJcdTA2MzdcdTA2NDkiLAogICJcdUZDRjYiLAogICJcdTA2MzdcdTA2NEEiLAogICJcdUZDRjciLAogICJcdTA2MzlcdTA2NDkiLAogICJcdUZDRjgiLAogICJcdTA2MzlcdTA2NEEiLAogICJcdUZDRjkiLAogICJcdTA2M0FcdTA2NDkiLAogICJcdUZDRkEiLAogICJcdTA2M0FcdTA2NEEiLAogICJcdUZDRkIiLAogICJcdTA2MzNcdTA2NDkiLAogICJcdUZDRkMiLAogICJcdTA2MzNcdTA2NEEiLAogICJcdUZDRkQiLAogICJcdTA2MzRcdTA2NDkiLAogICJcdUZDRkUiLAogICJcdTA2MzRcdTA2NEEiLAogICJcdUZDRkYiLAogICJcdTA2MkRcdTA2NDkiLAogICJcdUZEMDAiLAogICJcdTA2MkRcdTA2NEEiLAogICJcdUZEMDEiLAogICJcdTA2MkNcdTA2NDkiLAogICJcdUZEMDIiLAogICJcdTA2MkNcdTA2NEEiLAogICJcdUZEMDMiLAogICJcdTA2MkVcdTA2NDkiLAogICJcdUZEMDQiLAogICJcdTA2MkVcdTA2NEEiLAogICJcdUZEMDUiLAogICJcdTA2MzVcdTA2NDkiLAogICJcdUZEMDYiLAogICJcdTA2MzVcdTA2NEEiLAogICJcdUZEMDciLAogICJcdTA2MzZcdTA2NDkiLAogICJcdUZEMDgiLAogICJcdTA2MzZcdTA2NEEiLAogICJcdUZEMDkiLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMEEiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMEIiLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEMEMiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZEMEQiLAogICJcdTA2MzRcdTA2MzEiLAogICJcdUZEMEUiLAogICJcdTA2MzNcdTA2MzEiLAogICJcdUZEMEYiLAogICJcdTA2MzVcdTA2MzEiLAogICJcdUZEMTAiLAogICJcdTA2MzZcdTA2MzEiLAogICJcdUZEMTEiLAogICJcdTA2MzdcdTA2NDkiLAogICJcdUZEMTIiLAogICJcdTA2MzdcdTA2NEEiLAogICJcdUZEMTMiLAogICJcdTA2MzlcdTA2NDkiLAogICJcdUZEMTQiLAogICJcdTA2MzlcdTA2NEEiLAogICJcdUZEMTUiLAogICJcdTA2M0FcdTA2NDkiLAogICJcdUZEMTYiLAogICJcdTA2M0FcdTA2NEEiLAogICJcdUZEMTciLAogICJcdTA2MzNcdTA2NDkiLAogICJcdUZEMTgiLAogICJcdTA2MzNcdTA2NEEiLAogICJcdUZEMTkiLAogICJcdTA2MzRcdTA2NDkiLAogICJcdUZEMUEiLAogICJcdTA2MzRcdTA2NEEiLAogICJcdUZEMUIiLAogICJcdTA2MkRcdTA2NDkiLAogICJcdUZEMUMiLAogICJcdTA2MkRcdTA2NEEiLAogICJcdUZEMUQiLAogICJcdTA2MkNcdTA2NDkiLAogICJcdUZEMUUiLAogICJcdTA2MkNcdTA2NEEiLAogICJcdUZEMUYiLAogICJcdTA2MkVcdTA2NDkiLAogICJcdUZEMjAiLAogICJcdTA2MkVcdTA2NEEiLAogICJcdUZEMjEiLAogICJcdTA2MzVcdTA2NDkiLAogICJcdUZEMjIiLAogICJcdTA2MzVcdTA2NEEiLAogICJcdUZEMjMiLAogICJcdTA2MzZcdTA2NDkiLAogICJcdUZEMjQiLAogICJcdTA2MzZcdTA2NEEiLAogICJcdUZEMjUiLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMjYiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMjciLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEMjgiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZEMjkiLAogICJcdTA2MzRcdTA2MzEiLAogICJcdUZEMkEiLAogICJcdTA2MzNcdTA2MzEiLAogICJcdUZEMkIiLAogICJcdTA2MzVcdTA2MzEiLAogICJcdUZEMkMiLAogICJcdTA2MzZcdTA2MzEiLAogICJcdUZEMkQiLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMkUiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMkYiLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEMzAiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZEMzEiLAogICJcdTA2MzNcdTA2NDciLAogICJcdUZEMzIiLAogICJcdTA2MzRcdTA2NDciLAogICJcdUZEMzMiLAogICJcdTA2MzdcdTA2NDUiLAogICJcdUZEMzQiLAogICJcdTA2MzNcdTA2MkMiLAogICJcdUZEMzUiLAogICJcdTA2MzNcdTA2MkQiLAogICJcdUZEMzYiLAogICJcdTA2MzNcdTA2MkUiLAogICJcdUZEMzciLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMzgiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMzkiLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEM0EiLAogICJcdTA2MzdcdTA2NDUiLAogICJcdUZEM0IiLAogICJcdTA2MzhcdTA2NDUiLAogICJcdUZEM0MiLAogICJcdTA2MjdcdTA2NEIiLAogICJcdUZEM0QiLAogICJcdTA2MjdcdTA2NEIiLAogICJcdUZENTAiLAogICJcdTA2MkFcdTA2MkNcdTA2NDUiLAogICJcdUZENTEiLAogICJcdTA2MkFcdTA2MkRcdTA2MkMiLAogICJcdUZENTIiLAogICJcdTA2MkFcdTA2MkRcdTA2MkMiLAogICJcdUZENTMiLAogICJcdTA2MkFcdTA2MkRcdTA2NDUiLAogICJcdUZENTQiLAogICJcdTA2MkFcdTA2MkVcdTA2NDUiLAogICJcdUZENTUiLAogICJcdTA2MkFcdTA2NDVcdTA2MkMiLAogICJcdUZENTYiLAogICJcdTA2MkFcdTA2NDVcdTA2MkQiLAogICJcdUZENTciLAogICJcdTA2MkFcdTA2NDVcdTA2MkUiLAogICJcdUZENTgiLAogICJcdTA2MkNcdTA2NDVcdTA2MkQiLAogICJcdUZENTkiLAogICJcdTA2MkNcdTA2NDVcdTA2MkQiLAogICJcdUZENUEiLAogICJcdTA2MkRcdTA2NDVcdTA2NEEiLAogICJcdUZENUIiLAogICJcdTA2MkRcdTA2NDVcdTA2NDkiLAogICJcdUZENUMiLAogICJcdTA2MzNcdTA2MkRcdTA2MkMiLAogICJcdUZENUQiLAogICJcdTA2MzNcdTA2MkNcdTA2MkQiLAogICJcdUZENUUiLAogICJcdTA2MzNcdTA2MkNcdTA2NDkiLAogICJcdUZENUYiLAogICJcdTA2MzNcdTA2NDVcdTA2MkQiLAogICJcdUZENjAiLAogICJcdTA2MzNcdTA2NDVcdTA2MkQiLAogICJcdUZENjEiLAogICJcdTA2MzNcdTA2NDVcdTA2MkMiLAogICJcdUZENjIiLAogICJcdTA2MzNcdTA2NDVcdTA2NDUiLAogICJcdUZENjMiLAogICJcdTA2MzNcdTA2NDVcdTA2NDUiLAogICJcdUZENjQiLAogICJcdTA2MzVcdTA2MkRcdTA2MkQiLAogICJcdUZENjUiLAogICJcdTA2MzVcdTA2MkRcdTA2MkQiLAogICJcdUZENjYiLAogICJcdTA2MzVcdTA2NDVcdTA2NDUiLAogICJcdUZENjciLAogICJcdTA2MzRcdTA2MkRcdTA2NDUiLAogICJcdUZENjgiLAogICJcdTA2MzRcdTA2MkRcdTA2NDUiLAogICJcdUZENjkiLAogICJcdTA2MzRcdTA2MkNcdTA2NEEiLAogICJcdUZENkEiLAogICJcdTA2MzRcdTA2NDVcdTA2MkUiLAogICJcdUZENkIiLAogICJcdTA2MzRcdTA2NDVcdTA2MkUiLAogICJcdUZENkMiLAogICJcdTA2MzRcdTA2NDVcdTA2NDUiLAogICJcdUZENkQiLAogICJcdTA2MzRcdTA2NDVcdTA2NDUiLAogICJcdUZENkUiLAogICJcdTA2MzZcdTA2MkRcdTA2NDkiLAogICJcdUZENkYiLAogICJcdTA2MzZcdTA2MkVcdTA2NDUiLAogICJcdUZENzAiLAogICJcdTA2MzZcdTA2MkVcdTA2NDUiLAogICJcdUZENzEiLAogICJcdTA2MzdcdTA2NDVcdTA2MkQiLAogICJcdUZENzIiLAogICJcdTA2MzdcdTA2NDVcdTA2MkQiLAogICJcdUZENzMiLAogICJcdTA2MzdcdTA2NDVcdTA2NDUiLAogICJcdUZENzQiLAogICJcdTA2MzdcdTA2NDVcdTA2NEEiLAogICJcdUZENzUiLAogICJcdTA2MzlcdTA2MkNcdTA2NDUiLAogICJcdUZENzYiLAogICJcdTA2MzlcdTA2NDVcdTA2NDUiLAogICJcdUZENzciLAogICJcdTA2MzlcdTA2NDVcdTA2NDUiLAogICJcdUZENzgiLAogICJcdTA2MzlcdTA2NDVcdTA2NDkiLAogICJcdUZENzkiLAogICJcdTA2M0FcdTA2NDVcdTA2NDUiLAogICJcdUZEN0EiLAogICJcdTA2M0FcdTA2NDVcdTA2NEEiLAogICJcdUZEN0IiLAogICJcdTA2M0FcdTA2NDVcdTA2NDkiLAogICJcdUZEN0MiLAogICJcdTA2NDFcdTA2MkVcdTA2NDUiLAogICJcdUZEN0QiLAogICJcdTA2NDFcdTA2MkVcdTA2NDUiLAogICJcdUZEN0UiLAogICJcdTA2NDJcdTA2NDVcdTA2MkQiLAogICJcdUZEN0YiLAogICJcdTA2NDJcdTA2NDVcdTA2NDUiLAogICJcdUZEODAiLAogICJcdTA2NDRcdTA2MkRcdTA2NDUiLAogICJcdUZEODEiLAogICJcdTA2NDRcdTA2MkRcdTA2NEEiLAogICJcdUZEODIiLAogICJcdTA2NDRcdTA2MkRcdTA2NDkiLAogICJcdUZEODMiLAogICJcdTA2NDRcdTA2MkNcdTA2MkMiLAogICJcdUZEODQiLAogICJcdTA2NDRcdTA2MkNcdTA2MkMiLAogICJcdUZEODUiLAogICJcdTA2NDRcdTA2MkVcdTA2NDUiLAogICJcdUZEODYiLAogICJcdTA2NDRcdTA2MkVcdTA2NDUiLAogICJcdUZEODciLAogICJcdTA2NDRcdTA2NDVcdTA2MkQiLAogICJcdUZEODgiLAogICJcdTA2NDRcdTA2NDVcdTA2MkQiLAogICJcdUZEODkiLAogICJcdTA2NDVcdTA2MkRcdTA2MkMiLAogICJcdUZEOEEiLAogICJcdTA2NDVcdTA2MkRcdTA2NDUiLAogICJcdUZEOEIiLAogICJcdTA2NDVcdTA2MkRcdTA2NEEiLAogICJcdUZEOEMiLAogICJcdTA2NDVcdTA2MkNcdTA2MkQiLAogICJcdUZEOEQiLAogICJcdTA2NDVcdTA2MkNcdTA2NDUiLAogICJcdUZEOEUiLAogICJcdTA2NDVcdTA2MkVcdTA2MkMiLAogICJcdUZEOEYiLAogICJcdTA2NDVcdTA2MkVcdTA2NDUiLAogICJcdUZEOTIiLAogICJcdTA2NDVcdTA2MkNcdTA2MkUiLAogICJcdUZEOTMiLAogICJcdTA2NDdcdTA2NDVcdTA2MkMiLAogICJcdUZEOTQiLAogICJcdTA2NDdcdTA2NDVcdTA2NDUiLAogICJcdUZEOTUiLAogICJcdTA2NDZcdTA2MkRcdTA2NDUiLAogICJcdUZEOTYiLAogICJcdTA2NDZcdTA2MkRcdTA2NDkiL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dTA2NDVcdTA2NDUiLAogICJcdUZEQzYiLAogICJcdTA2MzNcdTA2MkVcdTA2NEEiLAogICJcdUZEQzciLAogICJcdTA2NDZcdTA2MkNcdTA2NEEiLAogICJcdUZFNDkiLAogICJcdTIwM0UiLAogICJcdUZFNEEiLAogICJcdTIwM0UiLAogICJcdUZFNEIiLAogICJcdTIwM0UiLAogICJcdUZFNEMiLAogICJcdTIwM0UiLAogICJcdUZFNEQiLAogICJcdTAwNUYiLAogICJcdUZFNEUiLAogICJcdTAwNUYiLAogICJcdUZFNEYiLAogICJcdTAwNUYiLAogICJcdUZFODAiLAogICJcdTA2MjEiLAogICJcdUZFODEiLAogICJcdTA2MjIiLAogICJcdUZFODIiLAogICJcdTA2MjIiLAogICJcdUZFODMiLAogICJcdTA2MjMiLAogICJcdUZFODQiLAogICJcdTA2MjMiLAogICJcdUZFODUiLAogICJcdTA2MjQiLAogICJcdUZFODYiLAogICJcdTA2MjQiLAogICJcdUZFODciLAogICJcdTA2MjUiLAogICJcdUZFODgiLAogICJcdTA2MjUiLAogICJcdUZFODkiLAogICJcdTA2MjYiLAogICJcdUZFOEEiLAogICJcdTA2MjYiLAogICJcdUZFOEIiLAogICJcdTA2MjYiLAogICJcdUZFOEMiLAogICJcdTA2MjYiLAogICJcdUZFOEQiLAogICJcdTA2MjciLAogICJcdUZFOEUiLAogICJcdTA2MjciLAogICJcdUZFOEYiLAogICJcdTA2MjgiLAogICJcdUZFOTAiLAogICJcdTA2MjgiLAogICJcdUZFOTEiLAogICJcdTA2MjgiLAogICJcdUZFOTIiLAogICJcdTA2MjgiLAogICJcdUZFOTMiLAogICJcdTA2MjkiLAogICJcdUZFOTQiLAogICJcdTA2MjkiLAogICJcdUZFOTUiLAogICJcdTA2MkEiLAogICJcdUZFOTYiLAogICJcdTA2MkEiLAogICJcdUZFOTciLAogICJcdTA2MkEiLAogICJcdUZFOTgiLAogICJcdTA2MkEiLAogICJcdUZFOTkiLAogICJcdTA2MkIiLAogICJcdUZFOUEiLAogICJcdTA2MkIiLAogICJcdUZFOUIiLAogICJcdTA2MkIiLAogICJcdUZFOUMiLAogICJcdTA2MkIiLAogICJcdUZFOUQiLAogICJcdTA2MkMiLAogICJcdUZFOUUiLAogICJcdTA2MkMiLAogICJcdUZFOUYiLAogICJcdTA2MkMiLAogICJcdUZFQTAiLAogICJcdTA2MkMiLAogICJcdUZFQTEiLAogICJcdTA2MkQiLAogICJcdUZFQTIiLAogICJcdTA2MkQiLAogICJcdUZFQTMiLAogICJcdTA2MkQiLAogICJcdUZFQTQiLAogICJcdTA2MkQiLAogICJcdUZFQTUiLAogICJcdTA2MkUiLAogICJcdUZFQTYiLAogICJcdTA2MkUiLAogICJcdUZFQTciLAogICJcdTA2MkUiLAogICJcdUZFQTgiLAogICJcdTA2MkUiLAogICJcdUZFQTkiLAogICJcdTA2MkYiLAogICJcdUZFQUEiLAogICJcdTA2MkYiLAogICJcdUZFQUIiLAogICJcdTA2MzAiLAogICJcdUZFQUMiLAogICJcdTA2MzAiLAogICJcdUZFQUQiLAogICJcdTA2MzEiLAogICJcdUZFQUUiLAogICJcdTA2MzEiLAogICJcdUZFQUYiLAogICJcdTA2MzIiLAogICJcdUZFQjAiLAogICJcdTA2MzIiLAogICJcdUZFQjEiLAogICJcdTA2MzMiLAogICJcdUZFQjIiLAogICJcdTA2MzMiLAogICJcdUZFQjMiLAogICJcdTA2MzMiLAogICJcdUZFQjQiLAogICJcdTA2MzMiLAogICJcdUZFQjUiLAogICJcdTA2MzQiLAogICJcdUZFQjYiLAogICJcdTA2MzQiLAogICJcdUZFQjciLAogICJcdTA2MzQiLAogICJcdUZFQjgiLAogICJcdTA2MzQiLAogICJcdUZFQjkiLAogICJcdTA2MzUiLAogICJcdUZFQkEiLAogICJcdTA2MzUiLAogICJcdUZFQkIiLAogICJcdTA2MzUiLAogICJcdUZFQkMiLAogICJcdTA2MzUiLAogICJcdUZFQkQiLAogICJcdTA2MzYiLAogICJcdUZFQkUiLAogICJcdTA2MzYiLAogICJcdUZFQkYiLAogICJcdTA2MzYiLAogICJcdUZFQzAiLAogICJcdTA2MzYiLAogICJcdUZFQzEiLAogICJcdTA2MzciLAogICJcdUZFQzIiLAogICJcdTA2MzciLAogICJcdUZFQzMiLAogICJcdTA2MzciLAogICJcdUZFQzQiLAogICJcdTA2MzciLAogICJcdUZFQzUiLAogICJcdTA2MzgiLAogICJcdUZFQzYiLAogICJcdTA2MzgiLAogICJcdUZFQzciLAogICJcdTA2MzgiLAogICJcdUZFQzgiLAogICJcdTA2MzgiLAogICJcdUZFQzkiLAogICJcdTA2MzkiLAogICJcdUZFQ0EiLAogICJcdTA2MzkiLAogICJcdUZFQ0IiLAogICJcdTA2MzkiLAogICJcdUZFQ0MiLAogICJcdTA2MzkiLAogICJcdUZFQ0QiLAogICJcdTA2M0EiLAogICJcdUZFQ0UiLAogICJcdTA2M0EiLAogICJcdUZFQ0YiLAogICJcdTA2M0EiLAogICJcdUZFRDAiLAogICJcdTA2M0EiLAogICJcdUZFRDEiLAogICJcdTA2NDEiLAogICJcdUZFRDIiLAogICJcdTA2NDEiLAogICJcdUZFRDMiLAogICJcdTA2NDEiLAogICJcdUZFRDQiLAogICJcdTA2NDEiLAogICJcdUZFRDUiLAogICJcdTA2NDIiLAogICJcdUZFRDYiLAogICJcdTA2NDIiLAogICJcdUZFRDciLAogICJcdTA2NDIiLAogICJcdUZFRDgiLAogICJcdTA2NDIiLAogICJcdUZFRDkiLAogICJcdTA2NDMiLAogICJcdUZFREEiLAogICJcdTA2NDMiLAogICJcdUZFREIiLAogICJcdTA2NDMiLAogICJcdUZFREMiLAogICJcdTA2NDMiLAogICJcdUZFREQiLAogICJcdTA2NDQiLAogICJcdUZFREUiLAogICJcdTA2NDQiLAogICJcdUZFREYiLAogICJcdTA2NDQiLAogICJcdUZFRTAiLAogICJcdTA2NDQiLAogICJcdUZFRTEiLAogICJcdTA2NDUiLAogICJcdUZFRTIiLAogICJcdTA2NDUiLAogICJcdUZFRTMiLAogICJcdTA2NDUiLAogICJcdUZFRTQiLAogICJcdTA2NDUiLAogICJcdUZFRTUiLAogICJcdTA2NDYiLAogICJcdUZFRTYiLAogICJcdTA2NDYiLAogICJcdUZFRTciLAogICJcdTA2NDYiLAogICJcdUZFRTgiLAogICJcdTA2NDYiLAogICJcdUZFRTkiLAogICJcdTA2NDciLAogICJcdUZFRUEiLAogICJcdTA2NDciLAogICJcdUZFRUIiLAogICJcdTA2NDciLAogICJcdUZFRUMiLAogICJcdTA2NDciLAogICJcdUZFRUQiLAogICJcdTA2NDgiLAogICJcdUZFRUUiLAogICJcdTA2NDgiLAogICJcdUZFRUYiLAogICJcdTA2NDkiLAogICJcdUZFRjAiLAogICJcdTA2NDkiLAogICJcdUZFRjEiLAogICJcdTA2NEEiLAogICJcdUZFRjIiLAogICJcdTA2NEEiLAogICJcdUZFRjMiLAogICJcdTA2NEEiLAogICJcdUZFRjQiLAogICJcdTA2NEEiLAogICJcdUZFRjUiLAogICJcdTA2NDRcdTA2MjIiLAogICJcdUZFRjYiLAogICJcdTA2NDRcdTA2MjIiLAogICJcdUZFRjciLAogICJcdTA2NDRcdTA2MjMiLAogICJcdUZFRjgiLAogICJcdTA2NDRcdTA2MjMiLAogICJcdUZFRjkiLAogICJcdTA2NDRcdTA2MjUiLAogICJcdUZFRkEiLAogICJcdTA2NDRcdTA2MjUiLAogICJcdUZFRkIiLAogICJcdTA2NDRcdTA2MjciLAogICJcdUZFRkMiLAogICJcdTA2NDRcdTA2MjciCiBdOwp9KTsKZnVuY3Rpb24gcmV2ZXJzZUlmUnRsKGNoYXJzKSB7CiBjb25zdCBjaGFyc0xlbmd0aCA9IGNoYXJzLmxlbmd0aDsKIGlmIChjaGFyc0xlbmd0aCA8PSAxIHx8ICFpc1JUTFJhbmdlRm9yKGNoYXJzLmNoYXJDb2RlQXQoMCkpKSB7CiAgcmV0dXJuIGNoYXJzOwogfQogY29uc3QgYnVmID0gW107CiBmb3IgKGxldCBpaSA9IGNoYXJzTGVuZ3RoIC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aGlzLmNmZi5jaGFyc2V0LmNoYXJzZXQ7CiAgfQogIGdldEdseXBoTWFwcGluZygpIHsKICAgIGNvbnN0IGNmZiA9IHRoaXMuY2ZmOwogICAgY29uc3QgcHJvcGVydGllcyA9IHRoaXMucHJvcGVydGllczsKICAgIGNvbnN0IHsKICAgICAgY2lkVG9HaWRNYXAsCiAgICAgIGNNYXAKICAgIH0gPSBwcm9wZXJ0aWVzOwogICAgY29uc3QgY2hhcnNldHMgPSBjZmYuY2hhcnNldC5jaGFyc2V0OwogICAgbGV0IGNoYXJDb2RlVG9HbHlwaElkOwogICAgbGV0IGdseXBoSWQ7CiAgICBpZiAocHJvcGVydGllcy5jb21wb3NpdGUpIHsKICAgICAgbGV0IGludkNpZFRvR2lkTWFwOwogICAgICBpZiAoY2lkVG9HaWRNYXAgJiYgY2lkVG9HaWRNYXAubGVuZ3RoID4gMCkgewogICAgICAgIGludkNpZFRvR2lkTWFwID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBjaWRUb0dpZE1hcC5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICBjb25zdCBnaWQgPSBjaWRUb0dpZE1hcFtpXTsKICAgICAgICAgIGlmIChnaWQgIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICBpbnZDaWRUb0dpZE1hcFtnaWRdID0gaTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgY2hhckNvZGVUb0dseXBoSWQgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICBsZXQgY2hhckNvZGU7CiAgICAgIGlmIChjZmYuaXNDSURGb250KSB7CiAgICAgICAgZm9yIChnbHlwaElkID0gMDsgZ2x5cGhJZCA8IGNoYXJzZXRzLmxlbmd0aDsgZ2x5cGhJZCsrKSB7CiAgICAgICAgICBjb25zdCBjaWQgPSBjaGFyc2V0c1tnbHlwaElkXTsKICAgICAgICAgIGNoYXJDb2RlID0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ZDogImxpbmVUbyIsCiAgICAgIGFyZ3M6IFt4LCB5XQogICAgfSk7CiAgfQogIGZ1bmN0aW9uIHF1YWRyYXRpY0N1cnZlVG8oeGEsIHlhLCB4LCB5KSB7CiAgICBjbWRzLnB1c2goewogICAgICBjbWQ6ICJxdWFkcmF0aWNDdXJ2ZVRvIiwKICAgICAgYXJnczogW3hhLCB5YSwgeCwgeV0KICAgIH0pOwogIH0KICBsZXQgaSA9IDA7CiAgY29uc3QgbnVtYmVyT2ZDb250b3VycyA9IGdldEludDE2KGNvZGUsIGkpOwogIGxldCBmbGFnczsKICBsZXQgeCA9IDAsCiAgICB5ID0gMDsKICBpICs9IDEwOwogIGlmIChudW1iZXJPZkNvbnRvdXJzIDwgMCkgewogICAgZG8gewogICAgICBmbGFncyA9IGdldFVpbnQxNihjb2RlLCBpKTsKICAgICAgY29uc3QgZ2x5cGhJbmRleCA9IGdldFVpbnQxNihjb2RlLCBpICsgMik7CiAgICAgIGkgKz0gNDsKICAgICAgbGV0IGFyZzEsIGFyZzI7CiAgICAgIGlmIChmbGFncyAmIDB4MDEpIHsKICAgICAgICBpZiAoZmxhZ3MgJiAweDAyKSB7CiAgICAgICAgICBhcmcxID0gZ2V0SW50MTYoY29kZSwgaSk7CiAgICAgICAgICBhcmcyID0gZ2V0SW50MTYoY29kZSwgaSArIDIpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBhcmcxID0gZ2V0VWludDE2KGNvZGUsIGkpOwogICAgICAgICAgYXJnMiA9IGdldFVpbnQxNihjb2RlLCBpICsgMik7CiAgICAgICAgfQogICAgICAgIGkgKz0gNDsKICAgICAgfSBlbHNlIHsKICAgICAgICBpZiAoZmxhZ3MgJiAweDAyKSB7CiAgICAgICAgICBhcmcxID0gZ2V0SW50OChjb2RlLCBpKyspOwogICAgICAgICAgYXJnMiA9IGdldEludDgoY29kZSwgaSsrKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgYXJnMSA9IGNvZGVbaSsrXTsKICAgICAgICAgIGFyZzIgPSBjb2RlW2krK107CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChmbGFncyAmIDB4MDIpIHsKICAgICAgICB4ID0gYXJnMTsKICAgICAgICB5ID0gYXJnMjsKICAgICAgfSBlbHNlIHsKICAgICAgICB4ID0gMDsKICAgICAgICB5ID0gMDsKICAgICAgfQogICAgICBsZXQgc2NhbGVYID0gMSwKICAgICAgICBzY2FsZVkgPSAxLAogICAgICAgIHNjYWxlMDEgPSAwLAogICAgICAgIHNjYWxlMTAgPSAwOwogICAgICBpZiAoZmxhZ3MgJiAweDA4KSB7CiAgICAgICAgc2NhbGVYID0gc2NhbGVZID0gZ2V0RmxvYXQyMTQoY29kZSwgaSk7CiAgICAgICAgaSArPSAyOwogICAgICB9IGVsc2UgaWYgKGZsYWdzICYgMHg0MCkgewogICAgICAgIHNjYWxlWCA9IGdldEZsb2F0MjE0KGNvZGUsIGkpOwogICAgICAgIHNjYWxlWSA9IGdldEZsb2F0MjE0KGNvZGUsIGkgKyAyKTsKICAgICAgICBpICs9IDQ7CiAgICAgIH0gZWxzZSBpZiAoZmxhZ3MgJiAweDgwKSB7CiAgICAgICAgc2NhbGVYID0gZ2V0RmxvYXQyMTQoY29kZSwgaSk7CiAgICAgICAgc2NhbGUwMSA9IGdldEZsb2F0MjE0KGNvZGUsIGkgKyAyKTsKICAgICAgICBzY2FsZTEwID0gZ2V0RmxvYXQyMTQoY29kZSwgaSArIDQpOwogICAgICAgIHNjYWxlWSA9IGdldEZsb2F0MjE0KGNvZGUsIGkgKyA2KTsKICAgICAgICBpICs9IDg7CiAgICAgIH0KICAgICAgY29uc3Qgc3ViZ2x5cGggPSBmb250LmdseXBoc1tnbHlwaEluZGV4XTsKICAgICAgaWYgKHN1YmdseXBoKSB7CiAgICAgICAgY21kcy5wdXNoKHsKICAgICAgICAgIGNtZDogInNhdmUiCiAgICAgICAgfSwgewogICAgICAgICAgY21kOiAidHJhbnNmb3JtIiwKICAgICAgICAgIGFyZ3M6IFtzY2FsZVgsIHNjYWxlMDEsIHNjYWxlMTAsIHNjYWxlWSwgeCwgeV0KICAgICAgICB9KTsKICAgICAgICBpZiAoIShmbGFncyAmIDB4MDIpKSB7fQogICAgICAgIGNvbXBpbGVHbHlmKHN1YmdseXBoLCBjbWRzLCBmb250KTsKICAgICAgICBjbWRzLnB1c2goewogICAgICAgICAgY21kOiAicmVzdG9yZSIKICAgICAgICB9KTsKICAgICAgfQogICAgfSB3aGlsZSAoZmxhZ3MgJiAweDIwKTsKICB9IGVsc2UgewogICAgY29uc3QgZW5kUHRzT2ZDb250b3VycyA9IFtdOwogICAgbGV0IGosIGpqOwogICAgZm9yIChqID0gMDsgaiA8IG51bWJlck9mQ29udG91cnM7IGorKykgewogICAgICBlbmRQdHNPZkNvbnRvdXJzLnB1c2goZ2V0VWludDE2KGNvZGUsIGkpKTsKICAgICAgaSArPSAyOwogICAgfQogICAgY29uc3QgaW5zdHJ1Y3Rpb25MZW5ndGggPSBnZXRVaW50MTYoY29kZSwgaSk7CiAgICBpICs9IDIgKyBpbnN0cnVjdGlvbkxlbmd0aDsKICAgIGNvbnN0IG51bWJlck9mUG9pbnRzID0gZW5kUHRzT2ZDb250b3Vycy5hdCgtMSkgKyAxOwogICAgY29uc3QgcG9pbnRzID0gW107CiAgICB3aGlsZSAocG9pbnRzLmxlbmd0aCA8IG51bWJlck9mUG9pbnRzKSB7CiAgICAgIGZsYWdzID0gY29kZVtpKytdOwogICAgICBsZXQgcmVwZWF0ID0gMTsKICAgICAgaWYgKGZsYWdzICYgMHgwOCkgewogICAgICAgIHJlcGVhdCArPSBjb2RlW2krK107CiAgICAgIH0KICAgICAgd2hpbGUgKHJlcGVhdC0tID4gMCkgewogICAgICAgIHBvaW50cy5wdXNoKHsKICAgICAgICAgIGZsYWdzCiAgICAgICAgfSk7CiAgICAgIH0KICAgIH0KICAgIGZvciAoaiA9IDA7IGogPCBudW1iZXJPZlBvaW50czsgaisrKSB7CiAgICAgIHN3aXRjaCAocG9pbnRzW2pdLmZsYWdzICYgMHgxMikgewogICAgICAgIGNhc2UgMHgwMDoKICAgICAgICAgIHggKz0gZ2V0SW50MTYoY29kZSwgaSk7CiAgICAgICAgICBpICs9IDI7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4MDI6CiAgICAgICAgICB4IC09IGNvZGVbaSsrXTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHgxMjoKICAgICAgICAgIHggKz0gY29kZVtpKytdOwogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgcG9pbnRzW2pdLnggPSB4OwogICAgfQogICAgZm9yIChqID0gMDsgaiA8IG51bWJlck9mUG9pbnRzOyBqKyspIHsKICAgICAgc3dpdGNoIChwb2ludHNbal0uZmxhZ3MgJiAweDI0KSB7CiAgICAgICAgY2FzZSAweDAwOgogICAgICAgICAgeSArPSBnZXRJbnQxNihjb2RlLCBpKTsKICAgICAgICAgIGkgKz0gMjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHgwNDoKICAgICAgICAgIHkgLT0gY29kZVtpKytdOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDI0OgogICAgICAgICAgeSArPSBjb2RlW2krK107CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgICBwb2ludHNbal0ueSA9IHk7CiAgICB9CiAgICBsZXQgc3RhcnRQb2ludCA9IDA7CiAgICBmb3IgKGkgPSAwOyBpIDwgbnVtYmVyT2ZDb250b3VyczsgaSsrKSB7CiAgICAgIGNvbnN0IGVuZFBvaW50ID0gZW5kUHRzT2ZDb250b3Vyc1tpXTsKICAgICAgY29uc3QgY29udG91ciA9IHBvaW50cy5zbGljZShzdGFydFBvaW50LCBlbmRQb2ludCArIDEpOwogICAgICBpZiAoY29udG91clswXS5mbGFncyAmIDEpIHsKICAgICAgICBjb250b3VyLnB1c2goY29udG91clswXSk7CiAgICAgIH0gZWxzZSBpZiAoY29udG91ci5hdCgtMSkuZmxhZ3MgJiAxKSB7CiAgICAgICAgY29udG91ci51bnNoaWZ0KGNvbnRvdXIuYXQoLTEpKTsKICAgICAgfSBlbHNlIHsKICAgICAgICBjb25zdCBwID0gewogICAgICAgICAgZmxhZ3M6IDEsCiAgICAgICAgICB4OiAoY29udG91clswXS54ICsgY29udG91ci5hdCgtMSkueCkgLyAyLAogICAgICAgICAgeTogKGNvbnRvdXJbMF0ueSArIGNvbnRvdXIuYXQoLTEpLnkpIC8gMgogICAgICAgIH07CiAgICAgICAgY29udG91ci51bnNoaWZ0KHApOwogICAgICAgIGNvbnRvdXIucHVzaChwKTsKICAgICAgfQogICAgICBtb3ZlVG8oY29udG91clswXS54LCBjb250b3VyWzBdLnkpOwogICAgICBmb3IgKGogPSAxLCBqaiA9IGNvbnRvdXIubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgIGlmIChjb250b3VyW2pdLmZsYWdzICYgMSkgewogICAgICAgICAgbGluZVRvKGNvbnRvdXJbal0ueCwgY29udG91cltqXS55KTsKICAgICAgICB9IGVsc2UgaWYgKGNvbnRvdXJbaiArIDFdLmZsYWdzICYgMSkgewogICAgICAgICAgcXVhZHJhdGljQ3VydmVUbyhjb250b3VyW2pdLngsIGNvbnRvdXJbal0ueSwgY29udG91cltqICsgMV0ueCwgY29udG91cltqICsgMV0ueSk7CiAgICAgICAgICBqKys7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHF1YWRyYXRpY0N1cnZlVG8oY29udG91cltqXS54LCBjb250b3VyW2pdLnksIChjb250b3VyW2pdLnggKyBjb250b3VyW2ogKyAxXS54KSAvIDIsIChjb250b3VyW2pdLnkgKyBjb250b3VyW2ogKyAxXS55KSAvIDIpOwogICAgICAgIH0KICAgICAgfQogICAgICBzdGFydFBvaW50ID0gZW5kUG9pbnQgKyAxOwogICAgfQogIH0KfQpmdW5jdGlvbiBjb21waWxlQ2hhclN0cmluZyhjaGFyU3RyaW5nQ29kZSwgY21kcywgZm9udCwgZ2x5cGhJZCkgewogIGZ1bmN0aW9uIG1vdmVUbyh4LCB5KSB7CiAgICBjbWRzLnB1c2goewogICAgICBjbWQ6ICJtb3ZlVG8iLAogICAgICBhcmdzOiBbeCwgeV0KICAgIH0pOwogIH0KICBmdW5jdGlvbiBsaW5lVG8oeCwgeSkgewogICAgY21kcy5wdXNoKHsKICAgICAgY21kOiAibGluZVRvIiwKICAgICAgYXJnczogW3gsIHldCiAgICB9KTsKICB9CiAgZnVuY3Rpb24gYmV6aWVyQ3VydmVUbyh4MSwgeTEsIHgyLCB5MiwgeCwgeSkgewogICAgY21kcy5wdXNoKHsKICAgICAgY21kOiAiYmV6aWVyQ3VydmVUbyIsCiAgICAgIGFyZ3M6IFt4MSwgeTEsIHgyLCB5MiwgeCwgeV0KICAgIH0pOwogIH0KICBjb25zdCBzdGFjayA9IFtdOwogIGxldCB4ID0gMCwKICAgIHkgPSAwOwogIGxldCBzdGVtcyA9IDA7CiAgZnVuY3Rpb24gcGFyc2UoY29kZSkgewogICAgbGV0IGkgPSAwOwogICAgd2hpbGUgKGkgPCBjb2RlLmxlbmd0aCkgewogICAgICBsZXQgc3RhY2tDbGVhbiA9IGZhbHNlOwogICAgICBsZXQgdiA9IGNvZGVbaSsrXTsKICAgICAgbGV0IHhhLCB4YiwgeWEsIHliLCB5MSwgeTIsIHkzLCBuLCBzdWJyQ29kZTsKICAgICAgc3dpdGNoICh2KSB7CiAgICAgICAgY2FzZSAxOgogICAgICAgICAgc3RlbXMgKz0gc3RhY2subGVuZ3RoID4+IDE7CiAgICAgICAgICBzdGFja0NsZWFuID0gdHJ1ZTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMzoKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDQ6CiAgICAgICAgICB5ICs9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbW92ZVRvKHgsIHkpOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDU6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgbGluZVRvKHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSA2OgogICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgeCArPSBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBsaW5lVG8oeCwgeSk7CiAgICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICB5ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIGxpbmVUbyh4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgNzoKICAgICAgICAgIHdoaWxlIChzdGFjay5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgbGluZVRvKHgsIHkpOwogICAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgeCArPSBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBsaW5lVG8oeCwgeSk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDg6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAxMDoKICAgICAgICAgIG4gPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN1YnJDb2RlID0gbnVsbDsKICAgICAgICAgIGlmIChmb250LmlzQ0ZGQ0lERm9udCkgewogICAgICAgICAgICBjb25zdCBmZEluZGV4ID0gZm9udC5mZFNlbGVjdC5nZXRGREluZGV4KGdseXBoSWQpOwogICAgICAgICAgICBpZiAoZmRJbmRleCA+PSAwICYmIGZkSW5kZXggPCBmb250LmZkQXJyYXkubGVuZ3RoKSB7CiAgICAgICAgICAgICAgY29uc3QgZm9udERpY3QgPSBmb250LmZkQXJyYXlbZmRJbmRleF07CiAgICAgICAgICAgICAgbGV0IHN1YnJzOwogICAgICAgICAgICAgIGlmIChmb250RGljdC5wcml2YXRlRGljdCAmJiBmb250RGljdC5wcml2YXRlRGljdC5zdWJyc0luZGV4KSB7CiAgICAgICAgICAgICAgICBzdWJycyA9IGZvbnREaWN0LnByaXZhdGVEaWN0LnN1YnJzSW5kZXgub2JqZWN0czsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHN1YnJzKSB7CiAgICAgICAgICAgICAgICBuICs9IGdldFN1YnJvdXRpbmVCaWFzKHN1YnJzKTsKICAgICAgICAgICAgICAgIHN1YnJDb2RlID0gc3VicnNbbl07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiSW52YWxpZCBmZCBpbmRleCBmb3IgZ2x5cGggaW5kZXguIik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHN1YnJDb2RlID0gZm9udC5zdWJyc1tuICsgZm9udC5zdWJyc0JpYXNdOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHN1YnJDb2RlKSB7CiAgICAgICAgICAgIHBhcnNlKHN1YnJDb2RlKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMTE6CiAgICAgICAgICByZXR1cm47CiAgICAgICAgY2FzZSAxMjoKICAgICAgICAgIHYgPSBjb2RlW2krK107CiAgICAgICAgICBzd2l0Y2ggKHYpIHsKICAgICAgICAgICAgY2FzZSAzNDoKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHkxID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5LCB4YiwgeTEsIHgsIHkxKTsKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeTEsIHhiLCB5LCB4LCB5KTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAzNToKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5ID0geWIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgICAgIHhhID0geCArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeWEgPSB5ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB4ID0geGIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeWEsIHhiLCB5YiwgeCwgeSk7CiAgICAgICAgICAgICAgc3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMzY6CiAgICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5MSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHkyID0geTEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeTEsIHhiLCB5MiwgeCwgeTIpOwogICAgICAgICAgICAgIHhhID0geCArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeTMgPSB5MiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5MiwgeGIsIHkzLCB4LCB5KTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAzNzoKICAgICAgICAgICAgICBjb25zdCB4MCA9IHgsCiAgICAgICAgICAgICAgICB5MCA9IHk7CiAgICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5YSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHliID0geWEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeSA9IHliICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiOwogICAgICAgICAgICAgIHkgPSB5YjsKICAgICAgICAgICAgICBpZiAoTWF0aC5hYnMoeCAtIHgwKSA+IE1hdGguYWJzKHkgLSB5MCkpIHsKICAgICAgICAgICAgICAgIHggKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgeSArPSBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYHVua25vd24gb3BlcmF0b3I6IDEyICR7dn1gKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMTQ6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoID49IDQpIHsKICAgICAgICAgICAgY29uc3QgYWNoYXIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgICAgY29uc3QgYmNoYXIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgICAgeSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgICB4ID0gc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGNtZHMucHVzaCh7CiAgICAgICAgICAgICAgY21kOiAic2F2ZSIKICAgICAgICAgICAgfSwgewogICAgICAgICAgICAgIGNtZDogInRyYW5zbGF0ZSIsCiAgICAgICAgICAgICAgYXJnczogW3gsIHldCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBsZXQgY21hcCA9IGxvb2t1cENtYXAoZm9udC5jbWFwLCBTdHJpbmcuZnJvbUNoYXJDb2RlKGZvbnQuZ2x5cGhOYW1lTWFwW19lbmNvZGluZ3MuU3RhbmRhcmRFbmNvZGluZ1thY2hhcl1dKSk7CiAgICAgICAgICAgIGNvbXBpbGVDaGFyU3RyaW5nKGZvbnQuZ2x5cGhzW2NtYXAuZ2x5cGhJZF0sIGNtZHMsIGZvbnQsIGNtYXAuZ2x5cGhJZCk7CiAgICAgICAgICAgIGNtZHMucHVzaCh7CiAgICAgICAgICAgICAgY21kOiAicmVzdG9yZSIKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGNtYXAgPSBsb29rdXBDbWFwKGZvbnQuY21hcCwgU3RyaW5nLmZyb21DaGFyQ29kZShmb250LmdseXBoTmFtZU1hcFtfZW5jb2RpbmdzLlN0YW5kYXJkRW5jb2RpbmdbYmNoYXJdXSkpOwogICAgICAgICAgICBjb21waWxlQ2hhclN0cmluZyhmb250LmdseXBoc1tjbWFwLmdseXBoSWRdLCBjbWRzLCBmb250LCBjbWFwLmdseXBoSWQpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuOwogICAgICAgIGNhc2UgMTg6CiAgICAgICAgICBzdGVtcyArPSBzdGFjay5sZW5ndGggPj4gMTsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAxOToKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgaSArPSBzdGVtcyArIDcgPj4gMzsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAyMDoKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgaSArPSBzdGVtcyArIDcgPj4gMzsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAyMToKICAgICAgICAgIHkgKz0gc3RhY2sucG9wKCk7CiAgICAgICAgICB4ICs9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbW92ZVRvKHgsIHkpOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDIyOgogICAgICAgICAgeCArPSBzdGFjay5wb3AoKTsKICAgICAgICAgIG1vdmVUbyh4LCB5KTsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAyMzoKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDI0OgogICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDIpIHsKICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWEgPSB5ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHliID0geWEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB4ID0geGIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5ID0geWIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIHggKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgIGxpbmVUbyh4LCB5KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjU6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gNikgewogICAgICAgICAgICB4ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgbGluZVRvKHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHliID0geWEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjY6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoICUgMikgewogICAgICAgICAgICB4ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHg7CiAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiOwogICAgICAgICAgICB5ID0geWIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjc6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoICUgMikgewogICAgICAgICAgICB5ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YSA9IHk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeSA9IHliOwogICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjg6CiAgICAgICAgICBzdGFjay5wdXNoKChjb2RlW2ldIDw8IDI0IHwgY29kZVtpICsgMV0gPDwgMTYpID4+IDE2KTsKICAgICAgICAgIGkgKz0gMjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjk6CiAgICAgICAgICBuID0gc3RhY2sucG9wKCkgKyBmb250LmdzdWJyc0JpYXM7CiAgICAgICAgICBzdWJyQ29kZSA9IGZvbnQuZ3N1YnJzW25dOwogICAgICAgICAgaWYgKHN1YnJDb2RlKSB7CiAgICAgICAgICAgIHBhcnNlKHN1YnJDb2RlKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMzA6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHg7CiAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeSA9IHliICsgKHN0YWNrLmxlbmd0aCA9PT0gMSA/IHN0YWNrLnNoaWZ0KCkgOiAwKTsKICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeWEsIHhiLCB5YiwgeCwgeSk7CiAgICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YSA9IHk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeSA9IHliICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiICsgKHN0YWNrLmxlbmd0aCA9PT0gMSA/IHN0YWNrLnNoaWZ0KCkgOiAwKTsKICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeWEsIHhiLCB5YiwgeCwgeSk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDMxOgogICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWEgPSB5OwogICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHggPSB4YiArIChzdGFjay5sZW5ndGggPT09IDEgPyBzdGFjay5zaGlmdCgpIDogMCk7CiAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgeGEgPSB4OwogICAgICAgICAgICB5YSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgPSB5YiArIChzdGFjay5sZW5ndGggPT09IDEgPyBzdGFjay5zaGlmdCgpIDogMCk7CiAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIGlmICh2IDwgMzIpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGB1bmtub3duIG9wZXJhdG9yOiAke3Z9YCk7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAodiA8IDI0NykgewogICAgICAgICAgICBzdGFjay5wdXNoKHYgLSAxMzkpOwogICAgICAgICAgfSBlbHNlIGlmICh2IDwgMjUxKSB7CiAgICAgICAgICAgIHN0YWNrLnB1c2goKHYgLSAyNDcpICogMjU2ICsgY29kZVtpKytdICsgMTA4KTsKICAgICAgICAgIH0gZWxzZSBpZiAodiA8IDI1NSkgewogICAgICAgICAgICBzdGFjay5wdXNoKC0odiAtIDI1MSkgKiAyNTYgLSBjb2RlW2krK10gLSAxMDgpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhY2sucHVzaCgoY29kZVtpXSA8PCAyNCB8IGNvZGVbaSArIDFdIDw8IDE2IHwgY29kZVtpICsgMl0gPDwgOCB8IGNvZGVbaSArIDNdKSAvIDY1NTM2KTsKICAgICAgICAgICAgaSArPSA0OwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKHN0YWNrQ2xlYW4pIHsKICAgICAgICBzdGFjay5sZW5ndGggPSAwOwogICAgICB9CiAgICB9CiAgfQogIHBhcnNlKGNoYXJTdHJpbmdDb2RlKTsKfQpjb25zdCBOT09QID0gW107CmNsYXNzIENvbXBpbGVkRm9udCB7CiAgY29uc3RydWN0b3IoZm9udE1hdHJpeCkgewogICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IENvbXBpbGVkRm9udCkgewogICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJDYW5ub3QgaW5pdGlhbGl6ZSBDb21waWxlZEZvbnQuIik7CiAgICB9CiAgICB0aGlzLmZvbnRNYXRyaXggPSBmb250TWF0cml4OwogICAgdGhpcy5jb21waWxlZEdseXBocyA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICB0aGlzLmNvbXBpbGVkQ2hhckNvZGVUb0dseXBoSWQgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogIH0KICBnZXRQYXRoSnModW5pY29kZSkgewogICAgY29uc3QgewogICAgICBjaGFyQ29kZSwKICAgICAgZ2x5cGhJZAogICAgfSA9IGxvb2t1cENtYXAodGhpcy5jbWFwLCB1bmljb2RlKTsKICAgIGxldCBmbiA9IHRoaXMuY29tcGlsZWRHbHlwaHNbZ2x5cGhJZF07CiAgICBpZiAoIWZuKSB7CiAgICAgIHRyeSB7CiAgICAgICAgZm4gPSB0aGlzLmNvbXBpbGVHbHlwaCh0aGlzLmdseXBoc1tnbHlwaElkXSwgZ2x5cGhJZCk7CiAgICAgICAgdGhpcy5jb21waWxlZEdseXBoc1tnbHlwaElkXSA9IGZuOwogICAgICB9IGNhdGNoIChleCkgewogICAgICAgIHRoaXMuY29tcGlsZWRHbHlwaHNbZ2x5cGhJZF0gPSBOT09QOwogICAgICAgIGlmICh0aGlzLmNvbXBpbGVkQ2hhckNvZGVUb0dseXBoSWRbY2hhckNvZGVdID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgIHRoaXMuY29tcGlsZWRDaGFyQ29kZVRvR2x5cGhJZFtjaGFyQ29kZV0gPSBnbHlwaElkOwogICAgICAgIH0KICAgICAgICB0aHJvdyBleDsKICAgICAgfQogICAgfQogICAgaWYgKHRoaXMuY29tcGlsZWRDaGFyQ29kZVRvR2x5cGhJZFtjaGFyQ29kZV0gPT09IHVuZGVmaW5lZCkgewogICAgICB0aGlzLmNvbXBpbGVkQ2hhckNvZGVUb0dseXBoSWRbY2hhckNvZGVdID0gZ2x5cGhJZDsKICAgIH0KICAgIHJldHVybiBmbjsKICB9CiAgY29tcGlsZUdseXBoKGNvZGUsIGdseXBoSWQpIHsKICAgIGlmICghY29kZSB8fCBjb2RlLmxlbmd0aCA9PT0gMCB8fCBjb2RlWzBdID09PSAxNCkgewogICAgICByZXR1cm4gTk9PUDsKICAgIH0KICAgIGxldCBmb250TWF0cml4ID0gdGhpcy5mb250TWF0cml4OwogICAgaWYgKHRoaXMuaXNDRkZDSURGb250KSB7CiAgICAgIGNvbnN0IGZkSW5kZXggPSB0aGlzLmZkU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zg7CiAgICB0Lnplcm8gPSA1NTY7CiAgICB0Lm9uZSA9IDU1NjsKICAgIHQudHdvID0gNTU2OwogICAgdC50aHJlZSA9IDU1NjsKICAgIHQuZm91ciA9IDU1NjsKICAgIHQuZml2ZSA9IDU1NjsKICAgIHQuc2l4ID0gNTU2OwogICAgdC5zZXZlbiA9IDU1NjsKICAgIHQuZWlnaHQgPSA1NTY7CiAgICB0Lm5pbmUgPSA1NTY7CiAgICB0LmNvbG9uID0gMjc4OwogICAgdC5zZW1pY29sb24gPSAyNzg7CiAgICB0Lmxlc3MgPSA1ODQ7CiAgICB0LmVxdWFsID0gNTg0OwogICAgdC5ncmVhdGVyID0gNTg0OwogICAgdC5xdWVzdGlvbiA9IDU1NjsKICAgIHQuYXQgPSAxMDE1OwogICAgdC5BID0gNjY3OwogICAgdC5CID0gNjY3OwogICAgdC5DID0gNzIyOwogICAgdC5EID0gNzIyOwogICAgdC5FID0gNjY3OwogICAgdC5GID0gNjExOwogICAgdC5HID0gNzc4OwogICAgdC5IID0gNzIyOwogICAgdC5JID0gMjc4OwogICAgdC5KID0gNTAwOwogICAgdC5LID0gNjY3OwogICAgdC5MID0gNTU2OwogICAgdC5NID0gODMzOwogICAgdC5OID0gNzIyOwogICAgdC5PID0gNzc4OwogICAgdC5QID0gNjY3OwogICAgdC5RID0gNzc4OwogICAgdC5SID0gNzIyOwogICAgdC5TID0gNjY3OwogICAgdC5UID0gNjExOwogICAgdC5VID0gNzIyOwogICAgdC5WID0gNjY3OwogICAgdC5XID0gOTQ0OwogICAgdC5YID0gNjY3OwogICAgdC5ZID0gNjY3OwogICAgdC5aID0gNjExOwogICAgdC5icmFja2V0bGVmdCA9IDI3ODsKICAgIHQuYmFja3NsYXNoID0gMjc4OwogICAgdC5icmFja2V0cmlnaHQgPSAyNzg7CiAgICB0LmFzY2lpY2lyY3VtID0gNDY5OwogICAgdC51bmRlcnNjb3JlID0gNTU2OwogICAgdC5xdW90ZWxlZnQgPSAyMjI7CiAgICB0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nR3byA9IDU1NjsKICAgIHQudGhyZWUgPSA1NTY7CiAgICB0LmZvdXIgPSA1NTY7CiAgICB0LmZpdmUgPSA1NTY7CiAgICB0LnNpeCA9IDU1NjsKICAgIHQuc2V2ZW4gPSA1NTY7CiAgICB0LmVpZ2h0ID0gNTU2OwogICAgdC5uaW5lID0gNTU2OwogICAgdC5jb2xvbiA9IDMzMzsKICAgIHQuc2VtaWNvbG9uID0gMzMzOwogICAgdC5sZXNzID0gNTg0OwogICAgdC5lcXVhbCA9IDU4NDsKICAgIHQuZ3JlYXRlciA9IDU4NDsKICAgIHQucXVlc3Rpb24gPSA2MTE7CiAgICB0LmF0ID0gOTc1OwogICAgdC5BID0gNzIyOwogICAgdC5CID0gNzIyOwogICAgdC5DID0gNzIyOwogICAgdC5EID0gNzIyOwogICAgdC5FID0gNjY3OwogICAgdC5GID0gNjExOwogICAgdC5HID0gNzc4OwogICAgdC5IID0gNzIyOwogICAgdC5JID0gMjc4OwogICAgdC5KID0gNTU2OwogICAgdC5LID0gNzIyOwogICAgdC5MID0gNjExOwogICAgdC5NID0gODMzOwogICAgdC5OID0gNzIyOwogICAgdC5PID0gNzc4OwogICAgdC5QID0gNjY3OwogICAgdC5RID0gNzc4OwogICAgdC5SID0gNzIyOwogICAgdC5TID0gNjY3OwogICAgdC5UID0gNjExOwogICAgdC5VID0gNzIyOwogICAgdC5WID0gNjY3OwogICAgdC5XID0gOTQ0OwogICAgdC5YID0gNjY3OwogICAgdC5ZID0gNjY3OwogICAgdC5aID0gNjExOwogICAgdC5icmFja2V0bGVmdCA9IDMzMzsKICAgIHQuYmFja3NsYXNoID0gMjc4OwogICAgdC5icmFja2V0cmlnaHQgPSAzMzM7CiAgICB0LmFzY2lpY2lyY3VtID0gNTg0OwogICAgdC51bmRlcnNjb3JlID0gNTU2OwogICAgdC5xdW90ZWxlZnQgPSAyNzg7CiAgICB0LmEgPSA1NTY7CiAgICB0LmIgPSA2MTE7CiAgICB0LmMgPSA1NTY7CiAgICB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TU2OwogICAgdC5mID0gMzMzOwogICAgdC5nID0gNjExOwogICAgdC5oID0gNjExOwogICAgdC5pID0gMjc4OwogICAgdC5qID0gMjc4OwogICAgdC5rID0gNTU2OwogICAgdC5sID0gMjc4OwogICAgdC5tID0gODg5OwogICAgdC5uID0gNjExOwogICAgdC5vID0gNjExOwogICAgdC5wID0gNjExOwogICAgdC5xID0gNjExOwogICAgdC5yID0gMzg5OwogICAgdC5zID0gNTU2OwogICAgdC50ID0gMzMzOwogICAgdC51ID0gNjExOwogICAgdC52ID0gNTU2OwogICAgdC53ID0gNzc4OwogICAgdC54ID0gNTU2OwogICAgdC55ID0gNTU2OwogICAgdC56ID0gNTAwOwogICAgdC5icmFjZWxlZnQgPSAzODk7CiAgICB0LmJhciA9IDI4MDsKICAgIHQuYnJhY2VyaWdodCA9IDM4OTsKICAgIHQuYXNjaWl0aWxkZSA9IDU4NDsKICAgIHQuZXhjbGFtZG93biA9IDMzMzsKICAgIHQuY2VudCA9IDU1NjsKICAgIHQuc3RlcmxpbmcgPSA1NTY7CiAgICB0LmZyYWN0aW9uID0gMTY3OwogICAgdC55ZW4gPSA1NTY7CiAgICB0LmZsb3JpbiA9IDU1NjsKICAgIHQuc2VjdGlvbiA9IDU1NjsKICAgIHQuY3VycmVuY3kgPSA1NTY7CiAgICB0LnF1b3Rlc2luZ2xlID0gMjM4OwogICAgdC5xdW90ZWRibGxlZnQgPSA1MDA7CiAgICB0Lmd1aWxsZW1vdGxlZnQgPSA1NTY7CiAgICB0Lmd1aWxzaW5nbGxlZnQgPSAzMzM7CiAgICB0Lmd1aWxzaW5nbHJpZ2h0ID0gMzMzOwogICAgdC5maSA9IDYxMTsKICAgIHQuZmwgPSA2MTE7CiAgICB0LmVuZGFzaCA9IDU1NjsKICAgIHQuZGFnZ2VyID0gNTU2OwogICAgdC5kYWdnZXJkYmwgPSA1NTY7CiAgICB0LnBlcmlvZGNlbnRlcmVkID0gMjc4OwogICAgdC5wYXJhZ3JhcGggPSA1NT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9IDU4NDsKICAgIHQub2RpZXJlc2lzID0gNTU2OwogICAgdC51ZGllcmVzaXMgPSA1NTY7CiAgICB0Lm5vdGVxdWFsID0gNTQ5OwogICAgdC5nY29tbWFhY2NlbnQgPSA1NTY7CiAgICB0LmV0aCA9IDU1NjsKICAgIHQuemNhcm9uID0gNTAwOwogICAgdC5uY29tbWFhY2NlbnQgPSA1NTY7CiAgICB0Lm9uZXN1cGVyaW9yID0gMzMzOwogICAgdC5pbWFjcm9uID0gMjc4OwogICAgdC5FdXJvID0gNTU2OwogIH0pOwogIHQuU3ltYm9sID0gKDAsIF9jb3JlX3V0aWxzLmdldExvb2t1cFRhYmxlRmFjdG9yeSkoZnVuY3Rpb24gKHQpIHsKICAgIHQuc3BhY2UgPSAyNTA7CiAgICB0LmV4Y2xhbSA9IDMzMzsKICAgIHQudW5pdmVyc2FsID0gNzEzOwogICAgdC5udW1iZXJzaWduID0gNTAwOwogICAgdC5leGlzdGVudGlhbCA9IDU0OTsKICAgIHQucGVyY2VudCA9IDgzMzsKICAgIHQuYW1wZXJzYW5kID0gNzc4OwogICAgdC5zdWNodGhhdCA9IDQzOTsKICAgIHQucGFyZW5sZWZ0ID0gMzMzOwogICAgdC5wYXJlbnJpZ2h0ID0gMzMzOwogICAgdC5hc3Rlcmlza21hdGggPSA1MDA7CiAgICB0LnBsdXMgPSA1NDk7CiAgICB0LmNvbW1hID0gMjUwOwogICAgdC5taW51cyA9IDU0OTsKICAgIHQucGVyaW9kID0gMjUwOwogICAgdC5zbGFzaCA9IDI3ODsKICAgIHQuemVybyA9IDUwMDsKICAgIHQub25lID0gNTAwOwogICAgdC50d28gPSA1MDA7CiAgICB0LnRocmVlID0gNTAwOwogICAgdC5mb3VyID0gNTAwOwogICAgdC5maXZlID0gNTAwOwogICAgdC5zaXggPSA1MDA7CiAgICB0LnNldmVuID0gNTAwOwogICAgdC5laWdodCA9IDUwMDsKICAgIHQubmluZSA9IDUwMDsKICAgIHQuY29sb24gPSAyNzg7CiA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ogICAgfQogIH0KfQpjbGFzcyBHbHlwaEhlYWRlciB7CiAgY29uc3RydWN0b3IoX3JlZjMpIHsKICAgIGxldCB7CiAgICAgIG51bWJlck9mQ29udG91cnMsCiAgICAgIHhNaW4sCiAgICAgIHlNaW4sCiAgICAgIHhNYXgsCiAgICAgIHlNYXgKICAgIH0gPSBfcmVmMzsKICAgIHRoaXMubnVtYmVyT2ZDb250b3VycyA9IG51bWJlck9mQ29udG91cnM7CiAgICB0aGlzLnhNaW4gPSB4TWluOwogICAgdGhpcy55TWluID0geU1pbjsKICAgIHRoaXMueE1heCA9IHhNYXg7CiAgICB0aGlzLnlNYXggPSB5TWF4OwogIH0KICBzdGF0aWMgcGFyc2UocG9zLCBnbHlmKSB7CiAgICByZXR1cm4gWzEwLCBuZXcgR2x5cGhIZWFkZXIoewogICAgICBudW1iZXJPZkNvbnRvdXJzOiBnbHlmLmdldEludDE2KHBvcyksCiAgICAgIHhNaW46IGdseWYuZ2V0SW50MTYocG9zICsgMiksCiAgICAgIHlNaW46IGdseWYuZ2V0SW50MTYocG9zICsgNCksCiAgICAgIHhNYXg6IGdseWYuZ2V0SW50MTYocG9zICsgNiksCiAgICAgIHlNYXg6IGdseWYuZ2V0SW50MTYocG9zICsgOCkKICAgIH0pXTsKICB9CiAgZ2V0U2l6ZSgpIHsKICAgIHJldHVybiAxMDsKICB9CiAgd3JpdGUocG9zLCBidWYpIHsKICAgIGJ1Zi5zZXRJbnQxNihwb3MsIHRoaXMubnVtYmVyT2ZDb250b3Vycyk7CiAgICBidWYuc2V0SW50MTYocG9zICsgMiwgdGhpcy54TWluKTsKICAgIGJ1Zi5zZXRJbnQxNihwb3MgKyA0LCB0aGlzLnlNaW4pOwogICAgYnVmLnNldEludDE2KHBvcyArIDYsIHRoaXMueE1heCk7CiAgICBidWYuc2V0SW50MTYocG9zICsgOCwgdGhpcy55TWF4KTsKICAgIHJldHVybiAxMDsKICB9CiAgc2NhbGUoeCwgZmFjdG9yKSB7CiAgICB0aG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Nvb3JkaW5hdGVzLnB1c2gobGFzdENvb3JkaW5hdGUpOwogICAgICB9IGVsc2UgaWYgKGZsYWcgJiBZX0lTX1NBTUVfT1JfUE9TSVRJVkVfWV9TSE9SVF9WRUNUT1IpIHsKICAgICAgICB5Q29vcmRpbmF0ZXMucHVzaChsYXN0Q29vcmRpbmF0ZSk7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgbGFzdENvb3JkaW5hdGUgKz0gZ2x5Zi5nZXRJbnQxNihwb3MpOwogICAgICAgIHBvcyArPSAyOwogICAgICAgIHlDb29yZGluYXRlcy5wdXNoKGxhc3RDb29yZGluYXRlKTsKICAgICAgfQogICAgICBwb2ludEZsYWdzLnB1c2goZmxhZyAmIE9OX0NVUlZFX1BPSU5UIHwgZmxhZyAmIE9WRVJMQVBfU0lNUExFKTsKICAgICAgaWYgKGVuZFB0c09mQ29udG91cnNbZW5kUHRzT2ZDb250b3Vyc0luZGV4XSA9PT0gaSkgewogICAgICAgIHhDb29yZGluYXRlcyA9IGFsbFhDb29yZGluYXRlc1tlbmRQdHNPZkNvbnRvdXJzSW5kZXhdOwogICAgICAgIGVuZFB0c09mQ29udG91cnNJbmRleCsrOwogICAgICAgIGNvbnRvdXJzLnB1c2gobmV3IENvbnRvdXIoewogICAgICAgICAgZmxhZ3M6IHBvaW50RmxhZ3MsCiAgICAgICAgICB4Q29vcmRpbmF0ZXMsCiAgICAgICAgICB5Q29vcmRpbmF0ZXMKICAgICAgICB9KSk7CiAgICAgICAgeUNvb3JkaW5hdGVzID0gW107CiAgICAgICAgcG9pbnRGbGFncyA9IFtdOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gbmV3IFNpbXBsZUdseXBoKHsKICAgICAgY29udG91cnMsCiAgICAgIGluc3RydWN0aW9ucwogICAgfSk7CiAgfQogIGdldFNpemUoKSB7CiAgICBsZXQgc2l6ZSA9IHRoaXMuY29udG91cnMubGVuZ3RoICogMiArIDIgKyB0aGlzLmluc3RydWN0aW9ucy5sZW5ndGg7CiAgICBsZXQgbGFzdFggPSAwOwogICAgbGV0IGxhc3RZID0gMDsKICAgIGZvciAoY29uc3QgY29udG91ciBvZiB0aGlzLmNvbnRvdXJzKSB7CiAgICAgIHNpemUgKz0gY29udG91ci5mbGFncy5sZW5ndGg7CiAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGNvbnRvdXIueENvb3JkaW5hdGVzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb25zdCB4ID0gY29udG91ci54Q29vcmRpbmF0ZXNbaV07CiAgICAgICAgY29uc3QgeSA9IGNvbnRvdXIueUNvb3JkaW5hdGVzW2ldOwogICAgICAgIGxldCBhYnMgPSBNYXRoLmFicyh4IC0gbGFzdFgpOwogICAgICAgIGlmIChhYnMgPiAyNTUpIHsKICAgICAgICAgIHNpemUgKz0gMjsKICAgICAgICB9IGVsc2UgaWYgKGFicyA+IDApIHsKICAgICAgICAgIHNpemUgKz0gMTsKICAgICAgICB9CiAgICAgICAgbGFzdFggPSB4OwogICAgICAgIGFicyA9IE1hdGguYWJzKHkgLSBsYXN0WSk7CiAgICAgICAgaWYgKGFicyA+IDI1NSkgewogICAgICAgICAgc2l6ZSArPSAyOwogICAgICAgIH0gZWxzZSBpZiAoYWJzID4gMCkgewogICAgICAgICAgc2l6ZSArPSAxOwogICAgICAgIH0KICAgICAgICBsYXN0WSA9IHk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBzaXplOwogIH0KICB3cml0ZShwb3MsIGJ1ZikgewogICAgY29uc3Qgc3BvcyA9IHBvczsKICAgIGNvbnN0IHhDb29yZGluYXRlcyA9IFtdOwogICAgY29uc3QgeUNvb3JkaW5hdGVzID0gW107CiAgICBjb25zdCBmbGFncyA9IFtdOwogICAgbGV0IGxhc3RYID0gMDsKICAgIGxldCBsYXN0WSA9IDA7CiAgICBmb3IgKGNvbnN0IGNvbnRvdXIgb2YgdGhpcy5jb250b3VycykgewogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBjb250b3VyLnhDb29yZGluYXRlcy5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgbGV0IGZsYWcgPSBjb250b3VyLmZsYWdzW2ldOwogICAgICAgIGNvbnN0IHggPSBjb250b3VyLnhDb29yZGluYXRlc1tpXTsKICAgICAgICBsZXQgZGVsdGEgPSB4IC0gbGFzdFg7CiAgICAgICAgaWYgKGRlbHRhID09PSAwKSB7CiAgICAgICAgICBmbGFnIHw9IFhfSVNfU0FNRV9PUl9QT1NJVElWRV9YX1NIT1JUX1ZFQ1RPUjsKICAgICAgICAgIHhDb29yZGluYXRlcy5wdXNoKDApOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb25zdCBhYnMgPSBNYXRoLmFicyhkZWx0YSk7CiAgICAgICAgICBpZiAoYWJzIDw9IDI1NSkgewogICAgICAgICAgICBmbGFnIHw9IGRlbHRhID49IDAgPyBYX1NIT1JUX1ZFQ1RPUiB8IFhfSVNfU0FNRV9PUl9QT1NJVElWRV9YX1NIT1JUX1ZFQ1RPUiA6IFhfU0hPUlRfVkVDVE9SOwogICAgICAgICAgICB4Q29vcmRpbmF0ZXMucHVzaChhYnMpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgeENvb3JkaW5hdGVzLnB1c2goZGVsdGEpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBsYXN0WCA9IHg7CiAgICAgICAgY29uc3QgeSA9IGNvbnRvdXIueUNvb3JkaW5hdGVzW2ldOwogICAgICAgIGRlbHRhID0geSAtIGxhc3RZOwogICAgICAgIGlmIChkZWx0YSA9PT0gMCkgewogICAgICAgICAgZmxhZyB8PSBZX0lTX1NBTUVfT1JfUE9TSVRJVkVfWV9TSE9SVF9WRUNUT1I7CiAgICAgICAgICB5Q29vcmRpbmF0ZXMucHVzaCgwKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY29uc3QgYWJzID0gTWF0aC5hYnMoZGVsdGEpOwogICAgICAgICAgaWYg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WxlICgobWF4UG93ZXIyIF4gZW50cmllc0NvdW50KSA+IG1heFBvd2VyMikgewogICAgICBtYXhQb3dlcjIgPDw9IDE7CiAgICAgIGxvZzIrKzsKICAgIH0KICAgIGNvbnN0IHNlYXJjaFJhbmdlID0gbWF4UG93ZXIyICogZW50cnlTaXplOwogICAgcmV0dXJuIHsKICAgICAgcmFuZ2U6IHNlYXJjaFJhbmdlLAogICAgICBlbnRyeTogbG9nMiwKICAgICAgcmFuZ2VTaGlmdDogZW50cnlTaXplICogZW50cmllc0NvdW50IC0gc2VhcmNoUmFuZ2UKICAgIH07CiAgfQogIHRvQXJyYXkoKSB7CiAgICBsZXQgc2ZudCA9IHRoaXMuc2ZudDsKICAgIGNvbnN0IHRhYmxlcyA9IHRoaXMudGFibGVzOwogICAgY29uc3QgdGFibGVzTmFtZXMgPSBPYmplY3Qua2V5cyh0YWJsZXMpOwogICAgdGFibGVzTmFtZXMuc29ydCgpOwogICAgY29uc3QgbnVtVGFibGVzID0gdGFibGVzTmFtZXMubGVuZ3RoOwogICAgbGV0IGksIGosIGpqLCB0YWJsZSwgdGFibGVOYW1lOwogICAgbGV0IG9mZnNldCA9IE9URl9IRUFERVJfU0laRSArIG51bVRhYmxlcyAqIE9URl9UQUJMRV9FTlRSWV9TSVpFOwogICAgY29uc3QgdGFibGVPZmZzZXRzID0gW29mZnNldF07CiAgICBmb3IgKGkgPSAwOyBpIDwgbnVtVGFibGVzOyBpKyspIHsKICAgICAgdGFibGUgPSB0YWJsZXNbdGFibGVzTmFtZXNbaV1dOwogICAgICBjb25zdCBwYWRkZWRMZW5ndGggPSAodGFibGUubGVuZ3RoICsgMyAmIH4zKSA+Pj4gMDsKICAgICAgb2Zmc2V0ICs9IHBhZGRlZExlbmd0aDsKICAgICAgdGFibGVPZmZzZXRzLnB1c2gob2Zmc2V0KTsKICAgIH0KICAgIGNvbnN0IGZpbGUgPSBuZXcgVWludDhBcnJheShvZmZzZXQpOwogICAgZm9yIChpID0gMDsgaSA8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jaCAodmFsdWUpIHsKICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgaWYgKCFISU5USU5HX0VOQUJMRUQpIHsKICAgICAgICAgICAgICB0aGlzLnN0YWNrID0gW107CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDIsIENPTU1BTkRfTUFQLmhzdGVtKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDM6CiAgICAgICAgICAgIGlmICghSElOVElOR19FTkFCTEVEKSB7CiAgICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgyLCBDT01NQU5EX01BUC52c3RlbSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSA0OgogICAgICAgICAgICBpZiAodGhpcy5mbGV4aW5nKSB7CiAgICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgMSkgewogICAgICAgICAgICAgICAgZXJyb3IgPSB0cnVlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNvbnN0IGR5ID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgICB0aGlzLnN0YWNrLnB1c2goMCwgZHkpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgxLCBDT01NQU5EX01BUC52bW92ZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDU6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgyLCBDT01NQU5EX01BUC5ybGluZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDY6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgxLCBDT01NQU5EX01BUC5obGluZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDc6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgxLCBDT01NQU5EX01BUC52bGluZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDg6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg2LCBDT01NQU5EX01BUC5ycmN1cnZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgOToKICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMTA6CiAgICAgICAgICAgIGlmICh0aGlzLnN0YWNrLmxlbmd0aCA8IDEpIHsKICAgICAgICAgICAgICBlcnJvciA9IHRydWU7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc3Vick51bWJlciA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGlmICghc3VicnNbc3Vick51bWJlcl0pIHsKICAgICAgICAgICAgICBlcnJvciA9IHRydWU7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmNvbnZlcnQoc3VicnNbc3Vick51bWJlcl0sIHN1YnJzLCBzZWFjQW5hbHlzaXNFbmFibGVkKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDExOgogICAgICAgICAgICByZXR1cm4gZXJyb3I7CiAgICAgICAgICBjYXNlIDEzOgogICAgICAgICAgICBpZiAodGhpcy5zdGFjay5sZW5ndGggPCAyKSB7CiAgICAgICAgICAgICAgZXJyb3IgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHd4ID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgc2J4ID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgdGhpcy5sc2IgPSBzYng7CiAgICAgICAgICAgIHRoaXMud2lkdGggPSB3eDsKICAgICAgICAgICAgdGhpcy5zdGFjay5wdXNoKHd4LCBzYngpOwogICAgICAgICAgICBlcnJvciA9IHRoaXMuZXhlY3V0ZUNvbW1hbmQoMiwgQ09NTUFORF9NQVAuaG1vdmV0byk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAxNDoKICAgICAgICAgICAgdGhpcy5vdXRwdXQucHVzaChDT01NQU5EX01BUC5lbmRjaGFyWzBdKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDIxOgogICAgICAgICAgICBpZiAodGhpcy5mbGV4aW5nKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDIsIENPTU1BTkRfTUFQLnJtb3ZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMjI6CiAgICAgICAgICAgIGlmICh0aGlzLmZsZXhpbmcpIHsKICAgICAgICAgICAgICB0aGlzLnN0YWNrLnB1c2goMCk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDEsIENPTU1BTkRfTUFQLmhtb3ZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMzA6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg0LCBDT01NQU5EX01BUC52aGN1cnZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMzE6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg0LCBDT01NQU5EX01BUC5odmN1cnZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgMDoKICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgMToKICAgICAgICAgICAgaWYgKCFISU5USU5HX0VOQUJMRUQpIHsKICAgICAgICAgICAgICB0aGlzLnN0YWNrID0gW107CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDIsIENPTU1BTkRfTUFQLnZzdGVtKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICgxMiA8PCA4KSArIDI6CiAgICAgICAgICAgIGlmICghSElOVElOR19FTkFCTEVEKSB7CiAgICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgyLCBDT01NQU5EX01BUC5oc3RlbSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAoMTIgPDwgOCkgKyA2OgogICAgICAgICAgICBpZiAoc2VhY0FuYWx5c2lzRW5hYmxlZCkgewogICAgICAgICAgICAgIGNvbnN0IGFzYiA9IHRoaXMuc3RhY2suYXQoLTUpOwogICAgICAgICAgICAgIHRoaXMuc2VhYyA9IHRoaXMuc3RhY2suc3BsaWNlKC00LCA0KTsKICAgICAgICAgICAgICB0aGlzLnNlYWNbMF0gKz0gdGhpcy5sc2IgLSBhc2I7CiAgICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDAsIENPTU1BTkRfTUFQLmVuZGNoYXIpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg0LCBDT01NQU5EX01BUC5lbmRjaGFyKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgNzoKICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgNCkgewogICAgICAgICAgICAgIGVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnN0YWNrLnBvcCgpOwogICAgICAgICAgICB3eCA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGNvbnN0IHNieSA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIHNieCA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIHRoaXMubHNiID0gc2J4OwogICAgICAgICAgICB0aGlzLndpZHRoID0gd3g7CiAgICAgICAgICAgIHRoaXMuc3RhY2sucHVzaCh3eCwgc2J4LCBzYnkpOwogICAgICAgICAgICBlcnJvciA9IHRoaXMuZXhlY3V0ZUNvbW1hbmQoMywgQ09NTUFORF9NQVAucm1vdmV0byk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAoMTIgPDwgOCkgKyAxMjoKICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICAgIGVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBudW0yID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgY29uc3QgbnVtMSA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIHRoaXMuc3RhY2sucHVzaChudW0xIC8gbnVtMik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAoMTIgPDwgOCkgKyAxNjoKICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICAgIGVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBzdWJyTnVtYmVyID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgY29uc3QgbnVtQXJncyA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGlmIChzdWJyTnVtYmVyID09PSAwICYmIG51bUFyZ3MgPT09IDMpIHsKICAgICAgICAgICAgICBjb25zdCBmbGV4QXJncyA9IHRoaXMuc3RhY2suc3BsaWNlKC0xNywgMTcpOwogICAgICAgICAgICAgIHRoaXMuc3RhY2sucHVzaChmbGV4QXJnc1syXSArIGZsZXhBcmdzWzBdLCBmbGV4QXJnc1szXSArIGZsZXhBcmdzWzFdLCBmbGV4QXJnc1s0XSwgZmxleEFyZ3NbNV0sIGZsZXhBcmdzWzZdLCBmbGV4QXJnc1s3XSwgZmxleEFyZ3NbOF0sIGZsZXhBcmdzWzldLCBmbGV4QXJnc1sxMF0sIGZsZXhBcmdzWzExXSwgZmxleEFyZ3NbMTJdLCBmbGV4QXJnc1sxM10sIGZsZXhBcmdzWzE0XSk7CiAgICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDEzLCBDT01NQU5EX01BUC5mbGV4LCB0cnVlKTsKICAgICAgICAgICAgICB0aGlzLmZsZXhpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICB0aGlzLnN0YWNrLnB1c2goZmxleEFyZ3NbMTVdLCBmbGV4QXJnc1sxNl0pOwogICAgICAgICAgICB9IGVsc2UgaWYgKHN1YnJOdW1iZXIgPT09IDEgJiYgbnVtQXJncyA9PT0gMCkgewogICAgICAgICAgICAgIHRoaXMuZmxleGluZyA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICgxMiA8PCA4KSArIDE3OgogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgMzM6CiAgICAgICAgICAgIHRoaXMuc3RhY2sgPSBbXTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoJ1Vua25vd24gdHlwZSAxIGNoYXJzdHJpbmcgY29tbWFuZCBvZiAiJyArIHZhbHVlICsgJyInKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmIChlcnJvcikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgaWYgKHZhbHVlIDw9IDI0NikgewogICAgICAgIHZhbHVlIC09IDEzOTsKICAgICAgfSBlbHNlIGlmICh2YWx1ZSA8PSAyNTApIHsKICAgICAgICB2YWx1ZSA9ICh2YWx1ZSAtIDI0NykgKiAyNTYgKyBlbmNvZGVkWysraV0gKyAxMDg7CiAgICAgIH0gZWxzZSBpZiAodmFsdWUgPD0gMjU0KSB7CiAgICAgICAgdmFsdWUgPSAtKCh2YWx1ZSAtIDI1MSkgKiAyNTYpIC0gZW5jb2RlZFsrK2ldIC0gMTA4OwogICAgICB9IGVsc2UgewogICAgICAgIHZhbHVlID0gKGVuY29kZWRbKytpXSAmIDB4ZmYpIDw8IDI0IHwgKGVuY29kZWRbKytpXSAmIDB4ZmYpIDw8IDE2IHwgKGVuY29kZWRbKytpXSAmIDB4ZmYpIDw8IDggfCAoZW5jb2RlZFsrK2ldICYgMHhmZikgPDwgMDsKICAgICAgfQogICAgICB0aGlzLnN0YWNrLnB1c2godmFsdWUpOwogICAgfQogICAgcmV0dXJuIGVycm9yOwogIH0KICBleGVjdXRlQ29tbWFuZChob3dNYW55QXJncywgY29tbWFuZCwga2VlcFN0YWNrKSB7CiAgICBjb25zdCBzdGFja0xlbmd0aCA9IHRoaXMuc3RhY2subGVuZ3RoOwogICAgaWYgKGh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nN0IHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgcmV0dXJuIHRva2VuID09PSAidHJ1ZSIgPyAxIDogMDsKICB9CiAgbmV4dENoYXIoKSB7CiAgICByZXR1cm4gdGhpcy5jdXJyZW50Q2hhciA9IHRoaXMuc3RyZWFtLmdldEJ5dGUoKTsKICB9CiAgcHJldkNoYXIoKSB7CiAgICB0aGlzLnN0cmVhbS5za2lwKC0yKTsKICAgIHJldHVybiB0aGlzLmN1cnJlbnRDaGFyID0gdGhpcy5zdHJlYW0uZ2V0Qnl0ZSgpOwogIH0KICBnZXRUb2tlbigpIHsKICAgIGxldCBjb21tZW50ID0gZmFsc2U7CiAgICBsZXQgY2ggPSB0aGlzLmN1cnJlbnRDaGFyOwogICAgd2hpbGUgKHRydWUpIHsKICAgICAgaWYgKGNoID09PSAtMSkgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAgIGlmIChjb21tZW50KSB7CiAgICAgICAgaWYgKGNoID09PSAweDBhIHx8IGNoID09PSAweDBkKSB7CiAgICAgICAgICBjb21tZW50ID0gZmFsc2U7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGNoID09PSAweDI1KSB7CiAgICAgICAgY29tbWVudCA9IHRydWU7CiAgICAgIH0gZWxzZSBpZiAoISgwLCBfY29yZV91dGlscy5pc1doaXRlU3BhY2UpKGNoKSkgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgfQogICAgaWYgKGlzU3BlY2lhbChjaCkpIHsKICAgICAgdGhpcy5uZXh0Q2hhcigpOwogICAgICByZXR1cm4gU3RyaW5nLmZyb21DaGFyQ29kZShjaCk7CiAgICB9CiAgICBsZXQgdG9rZW4gPSAiIjsKICAgIGRvIHsKICAgICAgdG9rZW4gKz0gU3RyaW5nLmZyb21DaGFyQ29kZShjaCk7CiAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgfSB3aGlsZSAoY2ggPj0gMCAmJiAhKDAsIF9jb3JlX3V0aWxzLmlzV2hpdGVTcGFjZSkoY2gpICYmICFpc1NwZWNpYWwoY2gpKTsKICAgIHJldHVybiB0b2tlbjsKICB9CiAgcmVhZENoYXJTdHJpbmdzKGJ5dGVzLCBsZW5JVikgewogICAgaWYgKGxlbklWID09PSAtMSkgewogICAgICByZXR1cm4gYnl0ZXM7CiAgICB9CiAgICByZXR1cm4gZGVjcnlwdChieXRlcywgQ0hBUl9TVFJTX0VOQ1JZUFRfS0VZLCBsZW5JVik7CiAgfQogIGV4dHJhY3RGb250UHJvZ3JhbShwcm9wZXJ0aWVzKSB7CiAgICBjb25zdCBzdHJlYW0gPSB0aGlzLnN0cmVhbTsKICAgIGNvbnN0IHN1YnJzID0gW10sCiAgICAgIGNoYXJzdHJpbmdzID0gW107CiAgICBjb25zdCBwcml2YXRlRGF0YSA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICBwcml2YXRlRGF0YS5sZW5JViA9IDQ7CiAgICBjb25zdCBwcm9ncmFtID0gewogICAgICBzdWJyczogW10sCiAgICAgIGNoYXJzdHJpbmdzOiBbXSwKICAgICAgcHJvcGVydGllczogewogICAgICAgIHByaXZhdGVEYXRhCiAgICAgIH0KICAgIH07CiAgICBsZXQgdG9rZW4sIGxlbmd0aCwgZGF0YSwgbGVuSVY7CiAgICB3aGlsZSAoKHRva2VuID0gdGhpcy5nZXRUb2tlbigpKSAhPT0gbnVsbCkgewogICAgICBpZiAodG9rZW4gIT09ICIvIikgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgICBzd2l0Y2ggKHRva2VuKSB7CiAgICAgICAgY2FzZSAiQ2hhclN0cmluZ3MiOgogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICAgICAgdG9rZW4gPSB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgIGlmICh0b2tlbiA9PT0gbnVsbCB8fCB0b2tlbiA9PT0gImVuZCIpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodG9rZW4gIT09ICIvIikgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGdseXBoID0gdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBsZW5ndGggPSB0aGlzLnJlYWRJbnQoKTsKICAgICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBkYXRhID0gbGVuZ3RoID4gMCA/IHN0cmVhbS5nZXRCeXRlcyhsZW5ndGgpIDogbmV3IFVpbnQ4QXJyYXkoMCk7CiAgICAgICAgICAgIGxlbklWID0gcHJvZ3JhbS5wcm9wZXJ0aWVzLnByaXZhdGVEYXRhLmxlbklWOwogICAgICAgICAgICBjb25zdCBlbmNvZGVkID0gdGhpcy5yZWFkQ2hhclN0cmluZ3MoZGF0YSwgbGVuSVYpOwogICAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICAgIHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBpZiAodG9rZW4gPT09ICJub2FjY2VzcyIpIHsKICAgICAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgIH0gZWxzZSBpZiAodG9rZW4gPT09ICIvIikgewogICAgICAgICAgICAgIHRoaXMucHJldkNoYXIoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjaGFyc3RyaW5ncy5wdXNoKHsKICAgICAgICAgICAgICBnbHlwaCwKICAgICAgICAgICAgICBlbmNvZGVkCiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiU3VicnMiOgogICAgICAgICAgdGhpcy5yZWFkSW50KCk7CiAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICB3aGlsZSAodGhpcy5nZXRUb2tlbigpID09PSAiZHVwIikgewogICAgICAgICAgICBjb25zdCBpbmRleCA9IHRoaXMucmVhZEludCgpOwogICAgICAgICAgICBsZW5ndGggPSB0aGlzLnJlYWRJbnQoKTsKICAgICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBkYXRhID0gbGVuZ3RoID4gMCA/IHN0cmVhbS5nZXRCeXRlcyhsZW5ndGgpIDogbmV3IFVpbnQ4QXJyYXkoMCk7CiAgICAgICAgICAgIGxlbklWID0gcHJvZ3JhbS5wcm9wZXJ0aWVzLnByaXZhdGVEYXRhLmxlbklWOwogICAgICAgICAgICBjb25zdCBlbmNvZGVkID0gdGhpcy5yZWFkQ2hhclN0cmluZ3MoZGF0YSwgbGVuSVYpOwogICAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICAgIHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBpZiAodG9rZW4gPT09ICJub2FjY2VzcyIpIHsKICAgICAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc3VicnNbaW5kZXhdID0gZW5jb2RlZDsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkJsdWVWYWx1ZXMiOgogICAgICAgIGNhc2UgIk90aGVyQmx1ZXMiOgogICAgICAgIGNhc2UgIkZhbWlseUJsdWVzIjoKICAgICAgICBjYXNlICJGYW1pbHlPdGhlckJsdWVzIjoKICAgICAgICAgIGNvbnN0IGJsdWVBcnJheSA9IHRoaXMucmVhZE51bWJlckFycmF5KCk7CiAgICAgICAgICBpZiAoYmx1ZUFycmF5Lmxlbmd0aCA+IDAgJiYgYmx1ZUFycmF5Lmxlbmd0aCAlIDIgPT09IDAgJiYgSElOVElOR19FTkFCTEVEKSB7CiAgICAgICAgICAgIHByb2dyYW0ucHJvcGVydGllcy5wcml2YXRlRGF0YVt0b2tlbl0gPSBibHVlQXJyYXk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJTdGVtU25hcEgiOgogICAgICAgIGNhc2UgIlN0ZW1TbmFwViI6CiAgICAgICAgICBwcm9ncmFtLnByb3BlcnRpZXMucHJpdmF0ZURhdGFbdG9rZW5dID0gdGhpcy5yZWFkTnVtYmVyQXJyYXkoKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIlN0ZEhXIjoKICAgICAgICBjYXNlICJTdGRWVyI6CiAgICAgICAgICBwcm9ncmFtLnByb3BlcnRpZXMucHJpdmF0ZURhdGFbdG9rZW5dID0gdGhpcy5yZWFkTnVtYmVyQXJyYXkoKVswXTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkJsdWVTaGlmdCI6CiAgICAgICAgY2FzZSAibGVuSVYiOgogICAgICAgIGNhc2UgIkJsdWVGdXp6IjoKICAgICAgICBjYXNlICJCbHVlU2NhbGUiOgogICAgICAgIGNhc2UgIkxhbmd1YWdlR3JvdXAiOgogICAgICAgICAgcHJvZ3JhbS5wcm9wZXJ0aWVzLnByaXZhdGVEYXRhW3Rva2VuXSA9IHRoaXMucmVhZE51bWJlcigpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiRXhwYW5zaW9uRmFjdG9yIjoKICAgICAgICAgIHByb2dyYW0ucHJvcGVydGllcy5wcml2YXRlRGF0YVt0b2tlbl0gPSB0aGlzLnJlYWROdW1iZXIoKSB8fCAwLjA2OwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiRm9yY2VCb2xkIjoKICAgICAgICAgIHByb2dyYW0ucHJvcGVydGllcy5wcml2YXRlRGF0YVt0b2tlbl0gPSB0aGlzLnJlYWRCb29sZWFuKCk7CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgfQogICAgZm9yIChjb25zdCB7CiAgICAgIGVuY29kZWQsCiAgICAgIGdseXBoCiAgICB9IG9mIGNoYXJzdHJpbmdzKSB7CiAgICAgIGNvbnN0IGNoYXJTdHJpbmcgPSBuZXcgVHlwZTFDaGFyU3RyaW5nKCk7CiAgICAgIGNvbnN0IGVycm9yID0gY2hhclN0cmluZy5jb252ZXJ0KGVuY29kZWQsIHN1YnJzLCB0aGlzLnNlYWNBbmFseXNpc0VuYWJsZWQpOwogICAgICBsZXQgb3V0cHV0ID0gY2hhclN0cmluZy5vdXRwdXQ7CiAgICAgIGlmIChlcnJvcikgewogICAgICAgIG91dHB1dCA9IFsxNF07CiAgICAgIH0KICAgICAgY29uc3QgY2hhclN0cmluZ09iamVjdCA9IHsKICAgICAgICBnbHlwaE5hbWU6IGdseXBoLAogICAgICAgIGNoYXJzdHJpbmc6IG91dHB1dCwKICAgICAgICB3aWR0aDogY2hhclN0cmluZy53aWR0aCwKICAgICAgICBsc2I6IGNoYXJTdHJpbmcubHNiLAogICAgICAgIHNlYWM6IGNoYXJTdHJpbmcuc2VhYwogICAgICB9OwogICAgICBpZiAoZ2x5cGggPT09ICIubm90ZGVmIikgewogICAgICAgIHByb2dyYW0uY2hhcnN0cmluZ3MudW5zaGlmdChjaGFyU3RyaW5nT2JqZWN0KTsKICAgICAgfSBlbHNlIHsKICAgICAgICBwcm9ncmFtLmNoYXJzdHJpbmdzLnB1c2goY2hhclN0cmluZ09iamVjdCk7CiAgICAgIH0KICAgICAgaWYgKHByb3BlcnRpZXMuYnVpbHRJbkVuY29kaW5nKSB7CiAgICAgICAgY29uc3QgaW5kZXggPSBwcm9wZXJ0aWVzLmJ1aWx0SW5FbmNvZGluZy5pbmRleE9mKGdseXBoKTsKICAgICAgICBpZiAoaW5kZXggPiAtMSAmJiBwcm9wZXJ0aWVzLndpZHRoc1tpbmRleF0gPT09IHVuZGVmaW5lZCAmJiBpbmRleCA+PSBwcm9wZXJ0aWVzLmZpcnN0Q2hhciAmJiBpbmRleCA8PSBwcm9wZXJ0aWVzLmxhc3RDaGFyKSB7CiAgICAgICAgICBwcm9wZXJ0aWVzLndpZHRoc1tpbmRleF0gPSBjaGFyU3RyaW5nLndpZHRoOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIHByb2dyYW07CiAgfQogIGV4dHJhY3RGb250SGVhZGVyKHByb3BlcnRpZXMpIHsKICAgIGxldCB0b2tlbjsKICAgIHdoaWxlICgodG9rZW4gPSB0aGlzLmdldFRva2VuKCkpICE9PSBudWxsKSB7CiAgICAgIGlmICh0b2tlbiAhPT0gIi8iKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdG9rZW4gPSB0aGlzLmdldFRva2VuKCk7CiAgICAgIHN3aXRjaCAodG9rZW4pIHsKICAgICAgICBjYXNlICJGb250TWF0cml4IjoKICAgICAgICAgIGNvbnN0IG1hdHJpeCA9IHRoaXMucmVhZE51bWJlckFycmF5KCk7CiAgICAgICAgICBwcm9wZXJ0aWVzLmZvbnRNYXRyaXggPSBtYXRyaXg7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJFbmNvZGluZyI6CiAgICAgICAgICBjb25zdCBlbmNvZGluZ0FyZyA9IHRoaXMuZ2V0VG9rZW4oKTsKICAgICAgICAgIGxldCBlbmNvZGluZzsKICAgICAgICAgIGlmICghL15cZCskLy50ZXN0KGVuY29kaW5nQXJnKSkgewogICAgICAgICAgICBlbmNvZGluZyA9ICgwLCBfZW5jb2RpbmdzLmdldEVuY29kaW5nKShlbmNvZGluZ0FyZyk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBlbmNvZGluZyA9IFtdOwogICAgICAgICAgICBjb25zdCBzaXplID0gcGFyc2VJbnQoZW5jb2RpbmdBcmcsIDEwKSB8IDA7CiAgICAgICAgICAgIHRoaXMuZ2V0VG9rZW4oKTsKICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBzaXplOyBqKyspIHsKICAgICAgICAgICAgICB0b2tlbiA9IHRoaXMuZ2V0VG9rZW4oKTsKICAgICAgICAgICAgICB3aGlsZSAodG9rZW4gIT09ICJkdXAiICYmIHRva2VuICE9PSAiZGVmIikgewogICAgICAgICAgICAgICAgdG9rZW4gPSB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgICAgICBpZiAodG9rZW4gPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAodG9rZW4gPT09ICJkZWYiKSB7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgaW5kZXggPSB0aGlzLnJlYWRJbnQoKTsKICAgICAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgICAgY29uc3QgZ2x5cGggPSB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgICAgZW5jb2RpbmdbaW5kZXhdID0gZ2x5cGg7CiAgICAgICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBwcm9wZXJ0aWVzLmJ1aWx0SW5FbmNvZGluZyA9IGVuY29kaW5nOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiRm9udEJCb3giOgogICAgICAgICAgY29uc3QgZm9udEJCb3ggPSB0aGlzLnJlYWROdW1iZXJBcnJheSgpOwogICAgICAgICAgcHJvcGVydGllcy5hc2NlbnQgPSBNYXRoLm1heChmb250QkJveFszXSwgZm9udEJCb3hbMV0pOwogICAgICAgICAgcHJvcGVydGllcy5kZXNjZW50ID0gTWF0aC5taW4oZm9udEJCb3hbMV0sIGZvbnRCQm94WzNdKTsKICAgICAgICAgIHByb3BlcnRpZXMuYXNjZW50U2NhbGVkID0gdHJ1ZTsKICAgICAgICAgIGJyZWFrOwogICAgICB9Ci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gICBjb25zdCBwcyA9IFtdOwogICAgbGV0IHZlcnRpY2VzTGVmdCA9IDA7CiAgICB3aGlsZSAocmVhZGVyLmhhc0RhdGEpIHsKICAgICAgY29uc3QgZiA9IHJlYWRlci5yZWFkRmxhZygpOwogICAgICBjb25zdCBjb29yZCA9IHJlYWRlci5yZWFkQ29vcmRpbmF0ZSgpOwogICAgICBjb25zdCBjb2xvciA9IHJlYWRlci5yZWFkQ29tcG9uZW50cygpOwogICAgICBpZiAodmVydGljZXNMZWZ0ID09PSAwKSB7CiAgICAgICAgaWYgKCEoMCA8PSBmICYmIGYgPD0gMikpIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiVW5rbm93biB0eXBlNCBmbGFnIik7CiAgICAgICAgfQogICAgICAgIHN3aXRjaCAoZikgewogICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICB2ZXJ0aWNlc0xlZnQgPSAzOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgcHMucHVzaChwcy5hdCgtMiksIHBzLmF0KC0xKSk7CiAgICAgICAgICAgIHZlcnRpY2VzTGVmdCA9IDE7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICBwcy5wdXNoKHBzLmF0KC0zKSwgcHMuYXQoLTEpKTsKICAgICAgICAgICAgdmVydGljZXNMZWZ0ID0gMTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIG9wZXJhdG9ycy5wdXNoKGYpOwogICAgICB9CiAgICAgIHBzLnB1c2goY29vcmRzLmxlbmd0aCk7CiAgICAgIGNvb3Jkcy5wdXNoKGNvb3JkKTsKICAgICAgY29sb3JzLnB1c2goY29sb3IpOwogICAgICB2ZXJ0aWNlc0xlZnQtLTsKICAgICAgcmVhZGVyLmFsaWduKCk7CiAgICB9CiAgICB0aGlzLmZpZ3VyZXMucHVzaCh7CiAgICAgIHR5cGU6ICJ0cmlhbmdsZXMiLAogICAgICBjb29yZHM6IG5ldyBJbnQzMkFycmF5KHBzKSwKICAgICAgY29sb3JzOiBuZXcgSW50MzJBcnJheShwcykKICAgIH0pOwogIH0KICBfZGVjb2RlVHlwZTVTaGFkaW5nKHJlYWRlciwgdmVydGljZXNQZXJSb3cpIHsKICAgIGNvbnN0IGNvb3JkcyA9IHRoaXMuY29vcmRzOwogICAgY29uc3QgY29sb3JzID0gdGhpcy5jb2xvcnM7CiAgICBjb25zdCBwcyA9IFtdOwogICAgd2hpbGUgKHJlYWRlci5oYXNEYXRhKSB7CiAgICAgIGNvbnN0IGNvb3JkID0gcmVhZGVyLnJlYWRDb29yZGluYXRlKCk7CiAgICAgIGNvbnN0IGNvbG9yID0gcmVhZGVyLnJlYWRDb21wb25lbnRzKCk7CiAgICAgIHBzLnB1c2goY29vcmRzLmxlbmd0aCk7CiAgICAgIGNvb3Jkcy5wdXNoKGNvb3JkKTsKICAgICAgY29sb3JzLnB1c2goY29sb3IpOwogICAgfQogICAgdGhpcy5maWd1cmVzLnB1c2goewogICAgICB0eXBlOiAibGF0dGljZSIsCiAgICAgIGNvb3JkczogbmV3IEludDMyQXJyYXkocHMpLAogICAgICBjb2xvcnM6IG5ldyBJbnQzMkFycmF5KHBzKSwKICAgICAgdmVydGljZXNQZXJSb3cKICAgIH0pOwogIH0KICBfZGVjb2RlVHlwZTZTaGFkaW5nKHJlYWRlcikgewogICAgY29uc3QgY29vcmRzID0gdGhpcy5jb29yZHM7CiAgICBjb25zdCBjb2xvcnMgPSB0aGlzLmNvbG9yczsKICAgIGNvbnN0IHBzID0gbmV3IEludDMyQXJyYXkoMTYpOwogICAgY29uc3QgY3MgPSBuZXcgSW50MzJBcnJheSg0KTsKICAgIHdoaWxlIChyZWFkZXIuaGFzRGF0YSkgewogICAgICBjb25zdCBmID0gcmVhZGVyLnJlYWRGbGFnKCk7CiAgICAgIGlmICghKDAgPD0gZiAmJiBmIDw9IDMpKSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJVbmtub3duIHR5cGU2IGZsYWciKTsKICAgICAgfQogICAgICBjb25zdCBwaSA9IGNvb3Jkcy5sZW5ndGg7CiAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGYgIT09IDAgPyA4IDogMTI7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgY29vcmRzLnB1c2gocmVhZGVyLnJlYWRDb29yZGluYXRlKCkpOwogICAgICB9CiAgICAgIGNvbnN0IGNpID0gY29sb3JzLmxlbmd0aDsKICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZiAhPT0gMCA/IDIgOiA0OyBpIDwgaWk7IGkrKykgewogICAgICAgIGNvbG9ycy5wdXNoKHJlYWRlci5yZWFkQ29tcG9uZW50cygpKTsKICAgICAgfQogICAgICBsZXQgdG1wMSwgdG1wMiwgdG1wMywgdG1wNDsKICAgICAgc3dpdGNoIChmKSB7CiAgICAgICAgY2FzZSAwOgogICAgICAgICAgcHNbMTJdID0gcGkgKyAzOwogICAgICAgICAgcHNbMTNdID0gcGkgKyA0OwogICAgICAgICAgcHNbMTRdID0gcGkgKyA1OwogICAgICAgICAgcHNbMTVdID0gcGkgKyA2OwogICAgICAgICAgcHNbOF0gPSBwaSArIDI7CiAgICAgICAgICBwc1sxMV0gPSBwaSArIDc7CiAgICAgICAgICBwc1s0XSA9IHBpICsgMTsKICAgICAgICAgIHBzWzddID0gcGkgKyA4OwogICAgICAgICAgcHNbMF0gPSBwaTsKICAgICAgICAgIHBzWzFdID0gcGkgKyAxMTsKICAgICAgICAgIHBzWzJdID0gcGkgKyAxMDsKICAgICAgICAgIHBzWzNdID0gcGkgKyA5OwogICAgICAgICAgY3NbMl0gPSBjaSArIDE7CiAgICAgICAgICBjc1szXSA9IGNpICsgMjsKICAgICAgICAgIGNzWzBdID0gY2k7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMzsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMToKICAgICAgICAgIHRtcDEgPSBwc1sxMl07CiAgICAgICAgICB0bXAyID0gcHNbMTNdOwogICAgICAgICAgdG1wMyA9IHBzWzE0XTsKICAgICAgICAgIHRtcDQgPSBwc1sxNV07CiAgICAgICAgICBwc1sxMl0gPSB0bXA0OwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSB0bXAzOwogICAgICAgICAgcHNbMTFdID0gcGkgKyAzOwogICAgICAgICAgcHNbNF0gPSB0bXAyOwogICAgICAgICAgcHNbN10gPSBwaSArIDQ7CiAgICAgICAgICBwc1swXSA9IHRtcDE7CiAgICAgICAgICBwc1sxXSA9IHBpICsgNzsKICAgICAgICAgIHBzWzJdID0gcGkgKyA2OwogICAgICAgICAgcHNbM10gPSBwaSArIDU7CiAgICAgICAgICB0bXAxID0gY3NbMl07CiAgICAgICAgICB0bXAyID0gY3NbM107CiAgICAgICAgICBjc1syXSA9IHRtcDI7CiAgICAgICAgICBjc1szXSA9IGNpOwogICAgICAgICAgY3NbMF0gPSB0bXAxOwogICAgICAgICAgY3NbMV0gPSBjaSArIDE7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDI6CiAgICAgICAgICB0bXAxID0gcHNbMTVdOwogICAgICAgICAgdG1wMiA9IHBzWzExXTsKICAgICAgICAgIHBzWzEyXSA9IHBzWzNdOwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSBwc1s3XTsKICAgICAgICAgIHBzWzExXSA9IHBpICsgMzsKICAgICAgICAgIHBzWzRdID0gdG1wMjsKICAgICAgICAgIHBzWzddID0gcGkgKyA0OwogICAgICAgICAgcHNbMF0gPSB0bXAxOwogICAgICAgICAgcHNbMV0gPSBwaSArIDc7CiAgICAgICAgICBwc1syXSA9IHBpICsgNjsKICAgICAgICAgIHBzWzNdID0gcGkgKyA1OwogICAgICAgICAgdG1wMSA9IGNzWzNdOwogICAgICAgICAgY3NbMl0gPSBjc1sxXTsKICAgICAgICAgIGNzWzNdID0gY2k7CiAgICAgICAgICBjc1swXSA9IHRtcDE7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMzoKICAgICAgICAgIHBzWzEyXSA9IHBzWzBdOwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSBwc1sxXTsKICAgICAgICAgIHBzWzExXSA9IHBpICsgMzsKICAgICAgICAgIHBzWzRdID0gcHNbMl07CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gcHNbM107CiAgICAgICAgICBwc1sxXSA9IHBpICsgNzsKICAgICAgICAgIHBzWzJdID0gcGkgKyA2OwogICAgICAgICAgcHNbM10gPSBwaSArIDU7CiAgICAgICAgICBjc1syXSA9IGNzWzBdOwogICAgICAgICAgY3NbM10gPSBjaTsKICAgICAgICAgIGNzWzBdID0gY3NbMV07CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIHBzWzVdID0gY29vcmRzLmxlbmd0aDsKICAgICAgY29vcmRzLnB1c2goWygtNCAqIGNvb3Jkc1twc1swXV1bMF0gLSBjb29yZHNbcHNbMTVdXVswXSArIDYgKiAoY29vcmRzW3BzWzRdXVswXSArIGNvb3Jkc1twc1sxXV1bMF0pIC0gMiAqIChjb29yZHNbcHNbMTJdXVswXSArIGNvb3Jkc1twc1szXV1bMF0pICsgMyAqIChjb29yZHNbcHNbMTNdXVswXSArIGNvb3Jkc1twc1s3XV1bMF0p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29sb3JzID0gdGhpcy5jb2xvcnM7CiAgICBjb25zdCBwcyA9IG5ldyBJbnQzMkFycmF5KDE2KTsKICAgIGNvbnN0IGNzID0gbmV3IEludDMyQXJyYXkoNCk7CiAgICB3aGlsZSAocmVhZGVyLmhhc0RhdGEpIHsKICAgICAgY29uc3QgZiA9IHJlYWRlci5yZWFkRmxhZygpOwogICAgICBpZiAoISgwIDw9IGYgJiYgZiA8PSAzKSkgewogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiVW5rbm93biB0eXBlNyBmbGFnIik7CiAgICAgIH0KICAgICAgY29uc3QgcGkgPSBjb29yZHMubGVuZ3RoOwogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBmICE9PSAwID8gMTIgOiAxNjsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb29yZHMucHVzaChyZWFkZXIucmVhZENvb3JkaW5hdGUoKSk7CiAgICAgIH0KICAgICAgY29uc3QgY2kgPSBjb2xvcnMubGVuZ3RoOwogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBmICE9PSAwID8gMiA6IDQ7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgY29sb3JzLnB1c2gocmVhZGVyLnJlYWRDb21wb25lbnRzKCkpOwogICAgICB9CiAgICAgIGxldCB0bXAxLCB0bXAyLCB0bXAzLCB0bXA0OwogICAgICBzd2l0Y2ggKGYpIHsKICAgICAgICBjYXNlIDA6CiAgICAgICAgICBwc1sxMl0gPSBwaSArIDM7CiAgICAgICAgICBwc1sxM10gPSBwaSArIDQ7CiAgICAgICAgICBwc1sxNF0gPSBwaSArIDU7CiAgICAgICAgICBwc1sxNV0gPSBwaSArIDY7CiAgICAgICAgICBwc1s4XSA9IHBpICsgMjsKICAgICAgICAgIHBzWzldID0gcGkgKyAxMzsKICAgICAgICAgIHBzWzEwXSA9IHBpICsgMTQ7CiAgICAgICAgICBwc1sxMV0gPSBwaSArIDc7CiAgICAgICAgICBwc1s0XSA9IHBpICsgMTsKICAgICAgICAgIHBzWzVdID0gcGkgKyAxMjsKICAgICAgICAgIHBzWzZdID0gcGkgKyAxNTsKICAgICAgICAgIHBzWzddID0gcGkgKyA4OwogICAgICAgICAgcHNbMF0gPSBwaTsKICAgICAgICAgIHBzWzFdID0gcGkgKyAxMTsKICAgICAgICAgIHBzWzJdID0gcGkgKyAxMDsKICAgICAgICAgIHBzWzNdID0gcGkgKyA5OwogICAgICAgICAgY3NbMl0gPSBjaSArIDE7CiAgICAgICAgICBjc1szXSA9IGNpICsgMjsKICAgICAgICAgIGNzWzBdID0gY2k7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMzsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMToKICAgICAgICAgIHRtcDEgPSBwc1sxMl07CiAgICAgICAgICB0bXAyID0gcHNbMTNdOwogICAgICAgICAgdG1wMyA9IHBzWzE0XTsKICAgICAgICAgIHRtcDQgPSBwc1sxNV07CiAgICAgICAgICBwc1sxMl0gPSB0bXA0OwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSB0bXAzOwogICAgICAgICAgcHNbOV0gPSBwaSArIDk7CiAgICAgICAgICBwc1sxMF0gPSBwaSArIDEwOwogICAgICAgICAgcHNbMTFdID0gcGkgKyAzOwogICAgICAgICAgcHNbNF0gPSB0bXAyOwogICAgICAgICAgcHNbNV0gPSBwaSArIDg7CiAgICAgICAgICBwc1s2XSA9IHBpICsgMTE7CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gdG1wMTsKICAgICAgICAgIHBzWzFdID0gcGkgKyA3OwogICAgICAgICAgcHNbMl0gPSBwaSArIDY7CiAgICAgICAgICBwc1szXSA9IHBpICsgNTsKICAgICAgICAgIHRtcDEgPSBjc1syXTsKICAgICAgICAgIHRtcDIgPSBjc1szXTsKICAgICAgICAgIGNzWzJdID0gdG1wMjsKICAgICAgICAgIGNzWzNdID0gY2k7CiAgICAgICAgICBjc1swXSA9IHRtcDE7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjoKICAgICAgICAgIHRtcDEgPSBwc1sxNV07CiAgICAgICAgICB0bXAyID0gcHNbMTFdOwogICAgICAgICAgcHNbMTJdID0gcHNbM107CiAgICAgICAgICBwc1sxM10gPSBwaSArIDA7CiAgICAgICAgICBwc1sxNF0gPSBwaSArIDE7CiAgICAgICAgICBwc1sxNV0gPSBwaSArIDI7CiAgICAgICAgICBwc1s4XSA9IHBzWzddOwogICAgICAgICAgcHNbOV0gPSBwaSArIDk7CiAgICAgICAgICBwc1sxMF0gPSBwaSArIDEwOwogICAgICAgICAgcHNbMTFdID0gcGkgKyAzOwogICAgICAgICAgcHNbNF0gPSB0bXAyOwogICAgICAgICAgcHNbNV0gPSBwaSArIDg7CiAgICAgICAgICBwc1s2XSA9IHBpICsgMTE7CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gdG1wMTsKICAgICAgICAgIHBzWzFdID0gcGkgKyA3OwogICAgICAgICAgcHNbMl0gPSBwaSArIDY7CiAgICAgICAgICBwc1szXSA9IHBpICsgNTsKICAgICAgICAgIHRtcDEgPSBjc1szXTsKICAgICAgICAgIGNzWzJdID0gY3NbMV07CiAgICAgICAgICBjc1szXSA9IGNpOwogICAgICAgICAgY3NbMF0gPSB0bXAxOwogICAgICAgICAgY3NbMV0gPSBjaSArIDE7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDM6CiAgICAgICAgICBwc1sxMl0gPSBwc1swXTsKICAgICAgICAgIHBzWzEzXSA9IHBpICsgMDsKICAgICAgICAgIHBzWzE0XSA9IHBpICsgMTsKICAgICAgICAgIHBzWzE1XSA9IHBpICsgMjsKICAgICAgICAgIHBzWzhdID0gcHNbMV07CiAgICAgICAgICBwc1s5XSA9IHBpICsgOTsKICAgICAgICAgIHBzWzEwXSA9IHBpICsgMTA7CiAgICAgICAgICBwc1sxMV0gPSBwaSArIDM7CiAgICAgICAgICBwc1s0XSA9IHBzWzJdOwogICAgICAgICAgcHNbNV0gPSBwaSArIDg7CiAgICAgICAgICBwc1s2XSA9IHBpICsgMTE7CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gcHNbM107CiAgICAgICAgICBwc1sxXSA9IHBpICsgNzsKICAgICAgICAgIHBzWzJdID0gcGkgKyA2OwogICAgICAgICAgcHNbM10gPSBwaSArIDU7CiAgICAgICAgICBjc1syXSA9IGNzWzBdOwogICAgICAgICAgY3NbM10gPSBjaTsKICAgICAgICAgIGNzWzBdID0gY3NbMV07CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIHRoaXMuZmlndXJlcy5wdXNoKHsKICAgICAgICB0eXBlOiAicGF0Y2giLAogICAgICAgIGNvb3JkczogbmV3IEludDMyQXJyYXkocHMpLAogICAgICAgIGNvbG9yczogbmV3IEludDMyQXJyYXkoY3MpCiAgICAgIH0pOwogICAgfQogIH0KICBfYnVpbGRGaWd1cmVGcm9tUGF0Y2goaW5kZXgpIHsKICAgIGNvbnN0IGZpZ3VyZSA9IHRoaXMuZmlndXJlc1tpbmRleF07CiAgICAoMCwgX3V0aWwuYXNzZXJ0KShmaWd1cmUudHlwZSA9PT0gInBhdGNoIiwgIlVuZXhwZWN0ZWQgcGF0Y2ggbWVzaCBmaWd1cmUiKTsKICAgIGNvbnN0IGNvb3JkcyA9IHRoaXMuY29vcmRzLAogICAgICBjb2xvcnMgPSB0aGlzLmNvbG9yczsKICAgIGNvbnN0IHBpID0gZmlndXJlLmNvb3JkczsKICAgIGNvbnN0IGNpID0gZmlndXJlLmNvbG9yczsKICAgIGNvbnN0IGZpZ3VyZU1pblggPSBNYXRoLm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HJvdykgKyBjM1swXSAqIHJvdykgLyBzcGxpdFlCeSB8IDA7CiAgICAgIGNyWzFdID0gKGMxWzFdICogKHNwbGl0WUJ5IC0gcm93KSArIGMzWzFdICogcm93KSAvIHNwbGl0WUJ5IHwgMDsKICAgICAgY3JbMl0gPSAoYzFbMl0gKiAoc3BsaXRZQnkgLSByb3cpICsgYzNbMl0gKiByb3cpIC8gc3BsaXRZQnkgfCAwOwogICAgICBmb3IgKGxldCBjb2wgPSAwOyBjb2wgPD0gc3BsaXRYQnk7IGNvbCsrLCBrKyspIHsKICAgICAgICBpZiAoKHJvdyA9PT0gMCB8fCByb3cgPT09IHNwbGl0WUJ5KSAmJiAoY29sID09PSAwIHx8IGNvbCA9PT0gc3BsaXRYQnkpKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgbGV0IHggPSAwLAogICAgICAgICAgeSA9IDA7CiAgICAgICAgbGV0IHEgPSAwOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDw9IDM7IGkrKykgewogICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPD0gMzsgaisrLCBxKyspIHsKICAgICAgICAgICAgY29uc3QgbSA9IGJSb3dbcm93XVtpXSAqIGJDb2xbY29sXVtqXTsKICAgICAgICAgICAgeCArPSBjb29yZHNbcGlbcV1dWzBdICogbTsKICAgICAgICAgICAgeSArPSBjb29yZHNbcGlbcV1dWzFdICogbTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZmlndXJlQ29vcmRzW2tdID0gY29vcmRzLmxlbmd0aDsKICAgICAgICBjb29yZHMucHVzaChbeCwgeV0pOwogICAgICAgIGZpZ3VyZUNvbG9yc1trXSA9IGNvbG9ycy5sZW5ndGg7CiAgICAgICAgY29uc3QgbmV3Q29sb3IgPSBuZXcgVWludDhBcnJheSgzKTsKICAgICAgICBuZXdDb2xvclswXSA9IChjbFswXSAqIChzcGxpdFhCeSAtIGNvbCkgKyBjclswXSAqIGNvbCkgLyB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d0aDsgaSsrKSB7CiAgICAgIHdoaWxlIChjb2RlU2l6ZSA8IGJwcykgewogICAgICAgIGNvZGVCdWYgPDw9IDg7CiAgICAgICAgY29kZUJ1ZiB8PSBzdHJCeXRlc1tzdHJJZHgrK107CiAgICAgICAgY29kZVNpemUgKz0gODsKICAgICAgfQogICAgICBjb2RlU2l6ZSAtPSBicHM7CiAgICAgIGFycmF5W2ldID0gKGNvZGVCdWYgPj4gY29kZVNpemUpICogc2FtcGxlTXVsOwogICAgICBjb2RlQnVmICY9ICgxIDw8IGNvZGVTaXplKSAtIDE7CiAgICB9CiAgICByZXR1cm4gYXJyYXk7CiAgfQogIHN0YXRpYyBwYXJzZShfcmVmMikgewogICAgbGV0IHsKICAgICAgeHJlZiwKICAgICAgaXNFdmFsU3VwcG9ydGVkLAogICAgICBmbgogICAgfSA9IF9yZWYyOwogICAgY29uc3QgZGljdCA9IGZuLmRpY3QgfHwgZm47CiAgICBjb25zdCB0eXBlTnVtID0gZGljdC5nZXQoIkZ1bmN0aW9uVHlwZSIpOwogICAgc3dpdGNoICh0eXBlTnVtKSB7CiAgICAgIGNhc2UgMDoKICAgICAgICByZXR1cm4gdGhpcy5jb25zdHJ1Y3RTYW1wbGVkKHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICBmbiwKICAgICAgICAgIGRpY3QKICAgICAgICB9KTsKICAgICAgY2FzZSAxOgogICAgICAgIGJyZWFrOwogICAgICBjYXNlIDI6CiAgICAgICAgcmV0dXJuIHRoaXMuY29uc3RydWN0SW50ZXJwb2xhdGVkKHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICBkaWN0CiAgICAgICAgfSk7CiAgICAgIGNhc2UgMzoKICAgICAgICByZXR1cm4gdGhpcy5jb25zdHJ1Y3RTdGljaGVkKHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTd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CiAgICAgICAgICBpZiAoaiAmIHBvcykgewogICAgICAgICAgICBjdWJlTltqXSAqPSBuMTsKICAgICAgICAgICAgY3ViZVZlcnRleFtqXSArPSBvZmZzZXQxOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY3ViZU5bal0gKj0gbjA7CiAgICAgICAgICAgIGN1YmVWZXJ0ZXhbal0gKz0gb2Zmc2V0MDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgayAqPSBzaXplX2k7CiAgICAgICAgcG9zIDw8PSAxOwogICAgICB9CiAgICAgIGZvciAoaiA9IDA7IGogPCBvdXRwdXRTaXplOyArK2opIHsKICAgICAgICBsZXQgcmogPSAwOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBjdWJlVmVydGljZXM7IGkrKykgewogICAgICAgICAgcmogKz0gc2FtcGxlc1tjdWJlVmVydGV4W2ldICsgal0gKiBjdWJlTltpXTsKICAgICAgICB9CiAgICAgICAgcmogPSBpbnRlcnBvbGF0ZShyaiwgMCwgMSwgZGVjb2RlW2pdWzBdLCBkZWNvZGVbal1bMV0pOwogICAgICAgIGRlc3RbZGVzdE9mZnNldCArIGpdID0gTWF0aC5taW4oTWF0aC5tYXgocmosIHJhbmdlW2pdWzBdKSwgcmFuZ2Vbal1bMV0pOwogICAgICB9CiAgICB9OwogIH0KICBzdGF0aWMgY29uc3RydWN0SW50ZXJwb2xhdGVkKF9yZWY1KSB7CiAgICBsZXQgewogICAgICB4cmVmLAogICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgIGRpY3QKICAgIH0gPSBfcmVmNTsKICAgIGNvbnN0IGMwID0gdG9OdW1iZXJBcnJheShkaWN0LmdldEFycmF5KCJDMCIpKSB8fCBbMF07CiAgICBjb25zdCBjMSA9IHRvTnVtYmVyQXJyYXkoZGljdC5nZXRBcnJheSgiQzEiKSkgfHwgWzFdOwogICAgY29uc3QgbiA9IGRpY3QuZ2V0KCJOIik7CiAgICBjb25zdCBkaWZmID0gW107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y5wdXNoKHRoaXMucGFyc2UoewogICAgICAgIHhyZWYsCiAgICAgICAgaXNFdmFsU3VwcG9ydGVkLAogICAgICAgIGZuOiB4cmVmLmZldGNoSWZSZWYoZm4pCiAgICAgIH0pKTsKICAgIH0KICAgIGNvbnN0IGJvdW5kcyA9IHRvTnVtYmVyQXJyYXkoZGljdC5nZXRBcnJheSgiQm91bmRzIikpOwogICAgY29uc3QgZW5jb2RlID0gdG9OdW1iZXJBcnJheShkaWN0LmdldEFycmF5KCJFbmNvZGUiKSk7CiAgICBjb25zdCB0bXBCdWYgPSBuZXcgRmxvYXQzMkFycmF5KDEpOwogICAgcmV0dXJuIGZ1bmN0aW9uIGNvbnN0cnVjdFN0aWNoZWRGbihzcmMsIHNyY09mZnNldCwgZGVzdCwgZGVzdE9mZnNldCkgewogICAgICBjb25zdCBjbGlwID0gZnVuY3Rpb24gY29uc3RydWN0U3RpY2hlZEZyb21JUkNsaXAodiwgbWluLCBtYXgpIHsKICAgICAgICBpZiAodiA+IG1heCkgewogICAgICAgICAgdiA9IG1heDsKICAgICAgICB9IGVsc2UgaWYgKHYgPCBtaW4pIHsKICAgICAgICAgIHYgPSBtaW47CiAgICAgICAgfQogICAgICAgIHJldHVybiB2OwogICAgICB9OwogICAgICBjb25zdCB2ID0gY2xpcChzcmNbc3JjT2Zmc2V0XSwgZG9tYWluWzBdLCBkb21haW5bMV0pOwogICAgICBjb25zdCBsZW5ndGggPSBib3VuZHMubGVuZ3RoOwogICAgICBsZXQgaTsKICAgICAgZm9yIChpID0gMDsgaSA8IGxlbmd0aDsgKytpKSB7CiAgICAgICAgaWYgKHYgPCBib3VuZHNbaV0pIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfQogICAgICBsZXQgZG1pbiA9IGRvbWFpblswXTsKICAgICAgaWYgKGkgPiAwKSB7CiAgICAgICAgZG1pbiA9IGJvdW5kc1tpIC0gMV07CiAgICAgIH0KICAgICAgbGV0IGRtYXggPSBkb21haW5bMV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dWU7CiAgICAgICAga2V5ICs9IHZhbHVlICsgIl8iOwogICAgICB9CiAgICAgIGNvbnN0IGNhY2hlZFZhbHVlID0gY2FjaGVba2V5XTsKICAgICAgaWYgKGNhY2hlZFZhbHVlICE9PSB1bmRlZmluZWQpIHsKICAgICAgICBkZXN0LnNldChjYWNoZWRWYWx1ZSwgZGVzdE9mZnNldCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGNvbnN0IG91dHB1dCA9IG5ldyBGbG9hdDMyQXJyYXkobnVtT3V0cHV0cyk7CiAgICAgIGNvbnN0IHN0YWNrID0gZXZhbHVhdG9yLmV4ZWN1dGUoaW5wdXQpOwogICAgICBjb25zdCBzdGFja0luZGV4ID0gc3RhY2subGVuZ3RoIC0gbnVtT3V0cHV0czsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bU91dHB1dHM7IGkrKykgewogICAgICAgIHZhbHVlID0gc3RhY2tbc3RhY2tJbmRleCArIGldOwogICAgICAgIGxldCBib3VuZCA9IHJhbmdlW2kgKiAyXTsKICAgICAgICBpZiAodmFsdWUgPCBib3VuZCkgewogICAgICAgICAgdmFsdWUgPSBib3VuZDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgYm91bmQgPSByYW5nZVtpICogMiArIDFdOwogICAgICAgICAgaWYgKHZhbHVlID4gYm91bmQpIHsKICAgICAgICAgICAgdmFsdWUgPSBib3VuZDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgb3V0cHV0W2ldID0gdmFsdWU7CiAgICAgIH0KICAgICAgaWYgKGNhY2hlX2F2YWlsYWJsZSA+IDApIHsKICAgICAgICBjYWNoZV9hdmFpbGFibGUtLTsKICAgICAgICBjYWNoZVtrZXldID0gb3V0cHV0OwogICAgICB9CiAgICAgIGRlc3Quc2V0KG91dHB1dCwgZGVzdE9mZnNldCk7CiAgICB9OwogIH0KfQpmdW5jdGlvbiBpc1BERkZ1bmN0aW9uKHYpIHsKICBsZXQgZm5EaWN0OwogIGl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ICAgIHRocm93IG5ldyBFcnJvcigiUG9zdFNjcmlwdCBmdW5jdGlvbiBzdGFjayBvdmVyZmxvdy4iKTsKICAgIH0KICAgIGNvbnN0IHN0YWNrID0gdGhpcy5zdGFjazsKICAgIGZvciAobGV0IGkgPSBzdGFjay5sZW5ndGggLSBuLCBqID0gbiAtIDE7IGogPj0gMDsgai0tLCBpKyspIHsKICAgICAgc3RhY2sucHVzaChzdGFja1tpXSk7CiAgICB9CiAgfQogIGluZGV4KG4pIHsKICAgIHRoaXMucHVzaCh0aGlzLnN0YWNrW3RoaXMuc3RhY2subGVuZ3RoIC0gbiAtIDFdKTsKICB9CiAgcm9sbChuLCBwKSB7CiAgICBjb25zdCBzdGFjayA9IHRoaXMuc3RhY2s7CiAgICBjb25zdCBsID0gc3RhY2subGVuZ3RoIC0gbjsKICAgIGNvbnN0IHIgPSBzdGFjay5sZW5ndGggLSAxOwogICAgY29uc3QgYyA9IGwgKyAocCAtIE1hdGguZmxvb3IocCAvIG4pICogbik7CiAgICBmb3IgKGxldCBpID0gbCwgaiA9IHI7IGkgPCBqOyBpKyssIGotLSkgewogICAgICBjb25zdCB0ID0gc3RhY2tbaV07CiAgICAgIHN0YWNrW2ldID0gc3RhY2tbal07CiAgICAgIHN0YWNrW2pdID0gdDsKICAgIH0KICAgIGZvciAobGV0IGkgPSBsLCBqID0gYyAtIDE7IGkgPCBqOyBpKyssIGotLSkgewogICAgICBjb25zdCB0ID0gc3RhY2tbaV07CiAgICAgIHN0YWNrW2ldID0gc3RhY2tbal07CiAgICAgIHN0YWNrW2pdID0gdDsKICAgIH0KICAgIGZvciAobGV0IGkgPSBjLCBqID0gcjsgaSA8IGo7IGkrKywgai0tKSB7CiAgICAgIGNvbnN0IHQgPSBzdGFja1tpXTsKICAgICAgc3RhY2tbaV0gPSBzdGFja1tqXTsKICAgICAgc3RhY2tbal0gPSB0OwogICAgfQogIH0KfQpjbGFzcyBQb3N0U2NyaXB0RXZhbHVhdG9yIHsKICBjb25zdHJ1Y3RvcihvcGVyYXRvcnMpIHsKICAgIHRoaXMub3BlcmF0b3JzID0gb3BlcmF0b3JzOwogIH0KICBleGVjdXRlKGluaXRpYWxTdGFjaykgewogICAgY29uc3Qgc3RhY2sgPSBuZXcgUG9zdFNjcmlwdFN0YWNrKGluaXRpYWxTdGFjayk7CiAgICBsZXQgY291bnRlciA9IDA7CiAgICBjb25zdCBvcGVyYXRvcnMgPSB0aGlzLm9wZXJhdG9yczsKICAgIGNvbnN0IGxlbmd0aCA9IG9wZXJhdG9ycy5sZW5ndGg7CiAgICBsZXQgb3BlcmF0b3IsIGEsIGI7CiAgICB3aGlsZSAoY291bnRlciA8IGxlbmd0aCkgewogICAgICBvcGVyYXRvciA9IG9wZXJhdG9yc1tjb3VudGVyKytdOwogICAgICBpZiAodHlwZW9mIG9wZXJhdG9yID09PSAibnVtYmVyIikgewogICAgICAgIHN0YWNrLnB1c2gob3BlcmF0b3IpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIHN3aXRjaCAob3BlcmF0b3IpIHsKICAgICAgICBjYXNlICJqeiI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBpZiAoIWEpIHsKICAgICAgICAgICAgY291bnRlciA9IGI7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJqIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGNvdW50ZXIgPSBhOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiYWJzIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goTWF0aC5hYnMoYSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiYWRkIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSArIGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiYW5kIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGlmICh0eXBlb2YgYSA9PT0gImJvb2xlYW4iICYmIHR5cGVvZiBiID09PSAiYm9vbGVhbiIpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhICYmIGIpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhICYgYik7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJhdGFuIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBNYXRoLmF0YW4yKGEsIGIpIC8gTWF0aC5QSSAqIDE4MDsKICAgICAgICAgIGlmIChhIDwgMCkgewogICAgICAgICAgICBhICs9IDM2MDsKICAgICAgICAgIH0KICAgICAgICAgIHN0YWNrLnB1c2goYSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJiaXRzaGlmdCI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBpZiAoYSA+IDApIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhIDw8IGIpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhID4+IGIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiY2VpbGluZyI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGguY2VpbChhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJjb3B5IjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLmNvcHkoYSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJjb3MiOgogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChNYXRoLmNvcyhhICUgMzYwIC8gMTgwICogTWF0aC5QSSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiY3ZpIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKSB8IDA7CiAgICAgICAgICBzdGFjay5wdXNoKGEpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiY3ZyIjoKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImRpdiI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgLyBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImR1cCI6CiAgICAgICAgICBzdGFjay5jb3B5KDEpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZXEiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhID09PSBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImV4Y2giOgogICAgICAgICAgc3RhY2sucm9sbCgyLCAxKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImV4cCI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgKiogYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJmYWxzZSI6CiAgICAgICAgICBzdGFjay5wdXNoKGZhbHNlKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImZsb29yIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goTWF0aC5mbG9vcihhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJnZSI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgPj0gYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJndCI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgPiBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImlkaXYiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhIC8gYiB8IDApOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiaW5kZXgiOgogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2suaW5kZXgoYSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJsZSI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgPD0gYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJsbiI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGgubG9nKGEpKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImxvZyI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGgubG9nKGEpIC8gTWF0aC5MTjEwKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImx0IjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSA8IGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibW9kIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSAlIGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibXVsIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSAqIGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibmUiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhICE9PSBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIm5lZyI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKC1hKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIm5vdCI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBpZiAodHlwZW9mIGEgPT09ICJib29sZWFuIikgewogICAgICAgICAgICBzdGFjay5wdXNoKCFhKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHN0YWNrLnB1c2gofmEpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAib3IiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgaWYgKHR5cGVvZiBhID09PSAiYm9vbGVhbiIgJiYgdHlwZW9mIGIgPT09ICJib29sZWFuIikgewogICAgICAgICAgICBzdGFjay5wdXNoKGEgfHwgYik7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzdGFjay5wdXNoKGEgfCBiKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInBvcCI6CiAgICAgICAgICBzdGFjay5wb3AoKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJvbGwiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucm9sbChhLCBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJvdW5kIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goTWF0aC5yb3VuZChhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJzaW4iOgogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChNYXRoLnNpbihhICUgMzYwIC8gMTgwICogTWF0aC5QSSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAic3FydCI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGguc3FydChhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJzdWIiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhIC0gYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJ0cnVlIjoKICAgICAgICAgIHN0YWNrLnB1c2godHJ1ZSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJ0cnVuY2F0ZSI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gYSA8IDAgPyBNYXRoLmNlaWwoYSkgOiBNYXRoLmZsb29yKGEpOwogICAgICAgICAgc3R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UgPT09ICJsaXRlcmFsIikgewogICAgaWYgKG51bTIubnVtYmVyID09PSAwKSB7CiAgICAgIHJldHVybiBuZXcgQXN0TGl0ZXJhbCgwKTsKICAgIH0gZWxzZSBpZiAobnVtMi5udW1iZXIgPT09IDEpIHsKICAgICAgcmV0dXJuIG51bTE7CiAgICB9IGVsc2UgaWYgKG51bTEudHlwZSA9PT0gImxpdGVyYWwiKSB7CiAgICAgIHJldHVybiBuZXcgQXN0TGl0ZXJhbChudW0xLm51bWJlciAqIG51bTIubnVtYmVyKTsKICAgIH0KICB9CiAgaWYgKG51bTEudHlwZSA9PT0gImxpdGVyYWwiKSB7CiAgICBpZiAobnVtMS5udW1iZXIgPT09IDApIHsKICAgICAgcmV0dXJuIG5ldyBBc3RMaXRlcmFsKDApOwogICAgfSBlbHNlIGlmIChudW0xLm51bWJlciA9PT0gMSkgewogICAgICByZXR1cm4gbnVtMjsKICAgIH0KICB9CiAgY29uc3QgbWluID0gTWF0aC5taW4obnVtMS5taW4gKiBudW0yLm1pbiwgbnVtMS5taW4gKiBudW0yLm1heCwgbnVtMS5tYXggKiBudW0yLm1pbiwgbnVtMS5tYXggKiBudW0yLm1heCk7CiAgY29uc3QgbWF4ID0gTWF0aC5tYXgobnVtMS5taW4gKiBudW0yLm1pbiwgbnVtMS5taW4gKiBudW0yLm1heCwgbnVtMS5tYXggKiBudW0yLm1pbiwgbnVtMS5tYXggKiBudW0yLm1heCk7CiAgcmV0dXJuIG5ldyBBc3RCaW5hcnlPcGVyYXRpb24oIioiLCBudW0xLCBudW0yLCBtaW4sIG1heCk7Cn0KZnVuY3Rpb24gYnVpbGRTdWJPcGVyYXRpb24obnVtMSwgbnVtMikgewogIGlmIChudW0yLnR5cGUgPT09ICJsaXRlcmFsIikgewogICAgaWYgKG51bTIubnVtYmVyID09PSAwKSB7CiAgICAgIHJldHVybiBudW0xOwogICAgfSBlbHNlIGlmIChudW0xLnR5cGUgPT09ICJsaXRlcmFsIikgewogICAgICByZXR1cm4gbmV3IEFzdExpdGVyYWwobnVtMS5udW1iZXIgLSBudW0yLm51bWJlcik7CiAgICB9CiAgfQogIGlmIChudW0yLnR5cGUgPT09ICJiaW5hcnkiICYmIG51bTIub3AgPT09ICItIiAmJiBudW0xLnR5cGUgPT09ICJsaXRlcmFsIiAmJiBudW0xLm51bWJlciA9PT0gMSAmJiBudW0yLmFyZzEudHlwZSA9PT0gImxpdGVyYWwiICYmIG51bTIuYXJnMS5udW1iZXIgPT09IDEpIHsKICAgIHJldHVybiBudW0yLmFyZzI7CiAgfQogIHJldHVybiBuZXcgQXN0QmluYXJ5T3BlcmF0aW9uKCItIiwgbnVtMSwgbnVtMiwgbnVtMS5taW4gLSBudW0yLm1heCwgbnVtMS5tYXggLSBudW0yLm1pbik7Cn0KZnVuY3Rpb24gYnVpbGRNaW5PcGVyYXRpb24obnVtMSwgbWF4KSB7CiAgaWYgKG51bTEubWluID49IG1heCkgewogICAgcmV0dXJuIG5ldyBBc3RMaXRlcmFsKG1heCk7CiAgfSBlbHNlIGlmIChudW0xLm1heCA8PSBtYXgpIHsKICAgIHJldHVybiBudW0xOwogIH0KICByZXR1cm4gbmV3IEFzdE1pbihudW0xLCBtYXgpOwp9CmNsYXNzIFBvc3RTY3JpcHRDb21waWxlciB7CiAgY29tcGlsZShjb2RlLCBkb21haW4sIHJhbmdlKSB7CiAgICBjb25zdCBzdGFjayA9IFtdOwogICAgY29uc3QgaW5zdHJ1Y3Rpb25zID0gW107CiAgICBjb25zdCBpbnB1dFNpemUgPSBkb21haW4ubGVuZ3RoID4+IDEsCiAgICAgIG91dHB1dFNpemUgPSByYW5nZS5sZW5ndGggPj4gMTsKICAgIGxldCBsYXN0UmVnaXN0ZXIgPSAwOwogICAgbGV0IG4sIGo7CiAgICBsZXQgbnVtMSwgbnVtMiwgYXN0MSwgYXN0MiwgdG1wVmFyLCBpdGVtOwogICAgZm9yIChsZXQgaSA9IDA7IGkgPCBpbnB1dFNpemU7IGkrKykgewogICAgICBzdGFjay5wdXNoKG5ldyBBc3RBcmd1bWVudChpLCBkb21haW5baSAqIDJdLCBkb21haW5baSAqIDIgKyAxXSkpOwogICAgfQogICAgZm9yIChsZXQgaSA9IDAsIGlpID0gY29kZS5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgIGl0ZW0gPSBjb2RlW2ldOwogICAgICBpZiAodHlwZW9mIGl0ZW0gPT09ICJudW1iZXIiKSB7CiAgICAgICAgc3RhY2sucHVzaChuZXcgQXN0TGl0ZXJhbChpdGVtKSk7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgc3dpdGNoIChpdGVtKSB7CiAgICAgICAgY2FzZSAiYWRkIjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAyKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbnVtMiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChidWlsZEFkZE9wZXJhdGlvbihudW0xLCBudW0yKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJjdnIiOgogICAgICAgICAgaWYgKHN0YWNrLmxlbmd0aCA8IDEpIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJtdWwiOgogICAgICAgICAgaWYgKHN0YWNrLmxlbmd0aCA8IDIpIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBudW0yID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBudW0xID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGJ1aWxkTXVsT3BlcmF0aW9uKG51bTEsIG51bTIpKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInN1YiI6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgIH0KICAgICAgICAgIG51bTIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIG51bTEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYnVpbGRTdWJPcGVyYXRpb24obnVtMSwgbnVtMikpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZXhjaCI6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgIH0KICAgICAgICAgIGFzdDEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGFzdDIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYXN0MSwgYXN0Mik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJwb3AiOgogICAgICAgICAgaWYgKHN0YWNrLmxlbmd0aCA8IDEpIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBzdGFjay5wb3AoKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImluZGV4IjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAxKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgaWYgKG51bTEudHlwZSAhPT0gImxpdGVyYWwiKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbiA9IG51bTEubnVtYmVyOwogICAgICAgICAgaWYgKG4gPCAwIHx8ICFOdW1iZXIuaXNJbnRlZ2VyKG4pIHx8IHN0YWNrLmxlbmd0aCA8IG4pIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBhc3QxID0gc3RhY2tbc3RhY2subGVuZ3RoIC0gbiAtIDFdOwogICAgICAgICAgaWYgKGFzdDEudHlwZSA9PT0gImxpdGVyYWwiIHx8IGFzdDEudHlwZSA9PT0gInZhciIpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhc3QxKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICB0bXBWYXIgPSBuZXcgQXN0VmFyaWFibGUobGFzdFJlZ2lzdGVyKyssIGFzdDEubWluLCBhc3QxLm1heCk7CiAgICAgICAgICBzdGFja1tzdGFjay5sZW5ndGggLSBuIC0gMV0gPSB0bXBWYXI7CiAgICAgICAgICBzdGFjay5wdXNoKHRtcFZhcik7CiAgICAgICAgICBpbnN0cnVjdGlvbnMucHVzaChuZXcgQXN0VmFyaWFibGVEZWZpbml0aW9uKHRtcFZhciwgYXN0MSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZHVwIjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAxKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHR5cGVvZiBjb2RlW2kgKyAxXSA9PT0gIm51bWJlciIgJiYgY29kZVtpICsgMl0gPT09ICJndCIgJiYgY29kZVtpICsgM10gPT09IGkgKyA3ICYmIGNvZGVbaSArIDRdID09PSAianoiICYmIGNvZGVbaSArIDVdID09PSAicG9wIiAmJiBjb2RlW2kgKyA2XSA9PT0gY29kZVtpICsgMV0pIHsKICAgICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgICBzdGFjay5wdXNoKGJ1aWxkTWluT3BlcmF0aW9uKG51bTEsIGNvZGVbaSArIDFdKSk7CiAgICAgICAgICAgIGkgKz0gNjsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBhc3QxID0gc3RhY2suYXQoLTEpOwogICAgICAgICAgaWYgKGFzdDEudHlwZSA9PT0gImxpdGVyYWwiIHx8IGFzdDEudHlwZSA9PT0gInZhciIpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhc3QxKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICB0bXBWYXIgPSBuZXcgQXN0VmFyaWFibGUobGFzdFJlZ2lzdGVyKyssIGFzdDEubWluLCBhc3QxLm1heCk7CiAgICAgICAgICBzdGFja1tzdGFjay5sZW5ndGggLSAxXSA9IHRtcFZhcjsKICAgICAgICAgIHN0YWNrLnB1c2godG1wVmFyKTsKICAgICAgICAgIGluc3RydWN0aW9ucy5wdXNoKG5ldyBBc3RWYXJpYWJsZURlZmluaXRpb24odG1wVmFyLCBhc3QxKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJyb2xsIjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAyKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbnVtMiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgaWYgKG51bTIudHlwZSAhPT0gImxpdGVyYWwiIHx8IG51bTEudHlwZSAhPT0gImxpdGVyYWwiKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaiA9IG51bTIubnVtYmVyOwogICAgICAgICAgbiA9IG51bTEubnVtYmVyOwogICAgICAgICAgaWYgKG4gPD0gMCB8fCAhTnVtYmVyLmlzSW50ZWdlcihuKSB8fCAhTnVtYmVyLmlzSW50ZWdlcihqKSB8fCBzdGFjay5sZW5ndGggPCBuKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaiA9IChqICUgbiArIG4pICUgbjsKICAgICAgICAgIGlmIChqID09PSAwKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgc3RhY2sucHVzaCguLi5zdGFjay5zcGxpY2Uoc3RhY2subGVuZ3RoIC0gbiwgbiAtIGopKT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sICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJOU00iLCAiTlNNIiwgIk5TTSIsICJOU00iLCAiTlNNIiwgIk5TTSIsICJOU00iLCAiQU4iLCAiT04iLCAiTlNNIiwgIk5TTSIsICJOU00iLCAiTlNNIiwgIk5TTSIsICJOU00iLCAiQUwiLCAiQUwiLCAiTlNNIiwgIk5TTSIsICJPTiIsICJOU00iLCAiTlNNIiwgIk5TTSIsICJOU00iLCAiQUwiLCAiQUwiLCAiRU4iLCAiRU4iLCAiRU4iLCAiRU4iLCAiRU4iLCAiRU4iLCAiRU4iLCAiRU4iLCAiRU4iLCAiRU4iLCAiQUwiLCAiQUwiLCAiQUwiLCA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aDsgKytpKSB7CiAgICBpZiAodHlwZXNbaV0gPT09ICJFTiIpIHsKICAgICAgZm9yIChsZXQgaiA9IGkgLSAxOyBqID49IDA7IC0taikgewogICAgICAgIGlmICh0eXBlc1tqXSAhPT0gIkVUIikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIHR5cGVzW2pdID0gIkVOIjsKICAgICAgfQogICAgICBmb3IgKGxldCBqID0gaSArIDE7IGogPCBzdHJMZW5ndGg7ICsraikgewogICAgICAgIGlmICh0eXBlc1tqXSAhPT0gIkVUIikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIHR5cGVzW2pdID0gIkVOIjsKICAgICAgfQogICAgfQogIH0KICBmb3IgKGkgPSAwOyBpIDwgc3RyTGVuZ3RoOyArK2kpIHsKICAgIHQgPSB0eXBlc1tpXTsKICAgIGlmICh0ID09PSAiV1MiIHx8IHQgPT09ICJFUyIgfHwgdCA9PT0gIkVUIiB8fCB0ID09PSAiQ1MiKSB7CiAgICAgIHR5cGVzW2ldID0gIk9OIjsKICAgIH0KICB9CiAgbGFzdFR5cGUgPSBzb3I7CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICB0ID0gdHlwZXNbaV07CiAgICBpZiAodCA9PT0gIkVOIikgewogICAgICB0eXBlc1tpXSA9IGxhc3RUeXBlID09PSAiTCIgPyAiTCIgOiAiRU4iOwogICAgfSBlbHNlIGlmICh0ID09PSAiUiIgfHwgdCA9PT0gIkwiKSB7CiAgICAgIGxhc3RUeXBlID0gdDsKICAgIH0KICB9CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICBpZiAodHlwZXNbaV0gPT09ICJPTiIpIHsKICAgICAgY29uc3QgZW5kID0gZmluZFVuZXF1YWwodHlwZXMsIGkgKyAxLCAiT04iKTsKICAgICAgbGV0IGJlZm9yZSA9IHNvcjsKICAgICAgaWYgKGkgPiAwKSB7CiAgICAgICAgYmVmb3JlID0gdHlwZXNbaSAtIDFdOwogICAgICB9CiAgICAgIGxldCBhZnRlciA9IGVvcjsKICAgICAgaWYgKGVuZCArIDEgPCBzdHJMZW5ndGgpIHsKICAgICAgICBhZnRlciA9IHR5cGVzW2VuZCArIDFdOwogICAgICB9CiAgICAgIGlmIChiZWZvcmUgIT09ICJMIikgewogICAgICAgIGJlZm9yZSA9ICJSIjsKICAgICAgfQogICAgICBpZiAoYWZ0ZXIgIT09ICJMIikgewogICAgICAgIGFmdGVyID0gIlIiOwogICAgICB9CiAgICAgIGlmIChiZWZvcmUgPT09IGFmdGVyKSB7CiAgICAgICAgc2V0VmFsdWVzKHR5cGVzLCBpLCBlbmQsIGJlZm9yZSk7CiAgICAgIH0KICAgICAgaSA9IGVuZCAtIDE7CiAgICB9CiAgfQogIGZvciAoaSA9IDA7IGkgPCBzdHJMZW5ndGg7ICsraSkgewogICAgaWYgKHR5cGVzW2ldID09PSAiT04iKSB7CiAgICAgIHR5cGVzW2ldID0gZTsKICAgIH0KICB9CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICB0ID0gdHlwZXNbaV07CiAgICBpZiAoaXNFdmVuKGxldmVsc1tpXSkpIHsKICAgICAgaWYgKHQgPT09ICJSIikgewogICAgICAgIGxldmVsc1tpXSArPSAxOwogICAgICB9IGVsc2UgaWYgKHQgPT09ICJBTiIgfHwgdCA9PT0gIkVOIikgewogICAgICAgIGxldmVsc1tpXSArPSAyOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBpZiAodCA9PT0gIkwiIHx8IHQgPT09ICJBTiIgfHwgdCA9PT0gIkVOIikgewogICAgICAgIGxldmVsc1tpXSArPSAxOwogICAgICB9CiAgICB9CiAgfQogIGxldCBoaWdoZXN0TGV2ZWwgPSAtMTsKICBsZXQgbG93ZXN0T2RkTGV2ZWwgPSA5OTsKICBsZXQgbGV2ZWw7CiAgZm9yIChpID0gMCwgaWkgPSBsZXZlbHMubG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B3aWR0aCwKICAgICAgaGVpZ2h0LAogICAgICBraW5kCiAgICB9ID0gdGhpcy5faW1nRGF0YTsKICAgIGxldCBkYXRhID0gdGhpcy5faW1nRGF0YS5kYXRhOwogICAgbGV0IGJpdFBlclBpeGVsOwogICAgbGV0IGNvbG9yVGFibGUgPSBuZXcgVWludDhBcnJheSgwKTsKICAgIGxldCBtYXNrVGFibGUgPSBjb2xvclRhYmxlOwogICAgbGV0IGNvbXByZXNzaW9uID0gMDsKICAgIHN3aXRjaCAoa2luZCkgewogICAgICBjYXNlIF91dGlsLkltYWdlS2luZC5HUkFZU0NBTEVfMUJQUDoKICAgICAgICB7CiAgICAgICAgICBiaXRQZXJQaXhlbCA9IDE7CiAgICAgICAgICBjb2xvclRhYmxlID0gbmV3IFVpbnQ4QXJyYXkodGhpcy5faXNNYXNrID8gWzI1NSwgMjU1LCAyNTUsIDI1NSwgMCwgMCwgMCwgMF0gOiBbMCwgMCwgMCwgMCwgMjU1LCAyNTUsIDI1NSwgMjU1XSk7CiAgICAgICAgICBjb25zdCByb3dMZW4gPSB3aWR0aCArIDcgPj4gMzsKICAgICAgICAgIGNvbnN0IHJvd1NpemUgPSByb3dMZW4gKyAzICYgLTQ7CiAgICAgICAgICBpZiAocm93TGVuICE9PSByb3dTaXplKSB7CiAgICAgICAgICAgIGNvbnN0IG5ld0RhdGEgPSBuZXcgVWludDhBcnJheShyb3dTaXplICogaGVpZ2h0KTsKICAgICAgICAgICAgbGV0IGsgPSAwOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBoZWlnaHQgKiByb3dMZW47IGkgPCBpaTsgaSArPSByb3dMZW4sIGsgKz0gcm93U2l6ZSkgewogICAgICAgICAgICAgIG5ld0RhdGEuc2V0KGRhdGEuc3ViYXJyYXkoaSwgaSArIHJvd0xlbiksIGspOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGRhdGEgPSBuZXdEYXRhOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICBjYXNlIF91dGlsLkltYWdlS2luZC5SR0JfMjRCUFA6CiAgICAgICAgewogICAgICAgICAgYml0UGVyUGl4ZWwgPSAyNDsKICAgICAgICAgIGlmICh3aWR0aCAmIDMpIHsKICAgICAgICAgICAgY29uc3Qgcm93TGVuID0gMyAqIHdpZHRoOwogICAgICAgICAgICBjb25zdCByb3dTaXplID0gcm93TGVuICsgMyAmIC00OwogICAgICAgICAgICBjb25zdCBleHRyYUxlbiA9IHJvd1NpemUgLSByb3dMZW47CiAgICAgICAgICAgIGNvbnN0IG5ld0RhdGEgPSBuZXcgVWludDhBcnJheShyb3dTaXplICogaGVpZ2h0KTsKICAgICAgICAgICAgbGV0IGsgPSAwOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBoZWlnaHQgKiByb3dMZW47IGkgPCBpaTsgaSArPSByb3dMZW4pIHsKICAgICAgICAgICAgICBjb25zdCByb3cgPSBkYXRhLnN1YmFycmF5KGksIGkgKyByb3dMZW4pOwogICAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgcm93TGVuOyBqICs9IDMpIHsKICAgICAgICAgICAgICAgIG5ld0RhdGFbaysrXSA9IHJvd1tqICsgMl07CiAgICAgICAgICAgICAgICBuZXdEYXRhW2srK10gPSByb3dbaiArIDFdOwogICAgICAgICAgICAgICAgbmV3RGF0YVtrKytdID0gcm93W2pdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBrICs9IGV4dHJhTGVuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGRhdGEgPSBuZXdEYXRhOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZGF0YS5sZW5ndGg7IGkgPCBpaTsgaSArPSAzKSB7CiAgICAgICAgICAgICAgY29uc3QgdG1wID0gZGF0YVtpXTsKICAgICAgICAgICAgICBkYXRhW2ldID0gZGF0YVtpICsgMl07CiAgICAgICAgICAgICAgZGF0Y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0NvdW50cyk7CiAgICBsZXQgazEgPSAwLAogICAgICBrMiA9IDA7CiAgICBsZXQgaDEgPSB0aGlzLmgxLAogICAgICBoMiA9IHRoaXMuaDI7CiAgICBjb25zdCBDMSA9IDB4Y2M5ZTJkNTEsCiAgICAgIEMyID0gMHgxYjg3MzU5MzsKICAgIGNvbnN0IEMxX0xPVyA9IEMxICYgTUFTS19MT1csCiAgICAgIEMyX0xPVyA9IEMyICYgTUFTS19MT1c7CiAgICBmb3IgKGxldCBpID0gMDsgaSA8IGJsb2NrQ291bnRzOyBpKyspIHsKICAgICAgaWYgKGkgJiAxKSB7CiAgICAgICAgazEgPSBkYXRhVWludDMyW2ldOwogICAgICAgIGsxID0gazEgKiBDMSAmIE1BU0tfSElHSCB8IGsxICogQzFfTE9XICYgTUFTS19MT1c7CiAgICAgICAgazEgPSBrMSA8PCAxNSB8IGsxID4+PiAxNzsKICAgICAgICBrMSA9IGsxICogQzIgJiBNQVNLX0hJR0ggfCBrMSAqIEMyX0xPVyAmIE1BU0tfTE9XOwogICAgICAgIGgxIF49IGsxOwogICAgICAgIGgxID0gaDEgPDwgMTMgfCBoMSA+Pj4gMTk7CiAgICAgICAgaDEgPSBoMSAqIDUgKyAweGU2NTQ2YjY0OwogICAgICB9IGVsc2UgewogICAgICAgIGsyID0gZGF0YVVpbnQzMltpXTsKICAgICAgICBrMiA9IGsyICogQzEgJiBNQVNLX0hJR0ggfCBrMiAqIEMxX0xPVyAmIE1BU0tfTE9XOwogICAgICAgIGsyID0gazIgPDwgMTUgfCBrMiA+Pj4gMTc7CiAgICAgICAgazIgPSBrMiAqIEMyICYgTUFTS19ISUdIIHwgazIgKiBDMl9MT1cgJiBNQVNLX0xPVzsKICAgICAgICBoMiBePSBrMjsKICAgICAgICBoMiA9IGgyIDw8IDEzIHwgaDIgPj4+IDE5OwogICAgICAgIGgyID0gaDIgKiA1ICsgMHhlNjU0NmI2NDsKICAgICAgfQogICAgfQogICAgazEgPSAwOwogICAgc3dpdGNo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KICAgIGRlc3QgPSBuZXcgVWludDMyQXJyYXkobGVuZ3RoKTsKICB9CiAgY29uc3QgeFJhdGlvID0gdzEgLyB3MjsKICBjb25zdCB5UmF0aW8gPSBoMSAvIGgyOwogIGxldCBpLAogICAgaiwKICAgIHB5LAogICAgbmV3SW5kZXggPSAwLAogICAgb2xkSW5kZXg7CiAgY29uc3QgeFNjYWxlZCA9IG5ldyBVaW50MTZBcnJheSh3Mik7CiAgY29uc3QgdzFTY2FubGluZSA9IHcxOwogIGZvciAoaSA9IDA7IGkgPCB3MjsgaSsrKSB7CiAgICB4U2NhbGVkW2ldID0gTWF0aC5mbG9vcihpICogeFJhdGlvKTsKICB9CiAgZm9yIChpID0gMDsgaSA8IGgyOyBpKyspIHsKICAgIHB5ID0gTWF0aC5mbG9vcihpICogeVJhdGlvKSAqIHcxU2NhbmxpbmU7CiAgICBmb3IgKGogPSAwOyBqIDwgdzI7IGorKykgewogICAgICBvbGRJbmRleCA9IHB5ICsgeFNjYWxlZFtqXTsKICAgICAgZGVzdFtuZXdJbmRleCsrXSA9IHNyY1tvbGRJbmRleF07CiAgICB9CiAgfQogIHJldHVybiBkZXN0Owp9CmNsYXNzIFBERkltYWdlIHsKICBjb25zdHJ1Y3RvcihfcmVmKSB7CiAgICBsZXQgewogICAgICB4cmVmLAogICAgICByZXMsCiAgICAgIGltYWdlLAogICAgICBpc0lubGluZSA9IGZhbHNlLAogICAgICBzbWFzayA9IG51bGwsCiAgICAgIG1hc2sgPSBudWxsLAogICAgICBpc01hc2sgPSBmYWxzZSwKICAgICAgcGRmRnVuY3Rpb25GYWN0b3J5LAogICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgfSA9IF9yZWY7CiAgICB0aGlzLmltYWdlID0gaW1hZ2U7CiAgICBjb25zdCBkaWN0ID0gaW1hZ2UuZGljdDsKICAgIGNvbnN0IGZpbHRlciA9IGRpY3QuZ2V0KCJGIiwgIkZpbHRlciIpOwogICAgbGV0IGZpbHRlck5hbWU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LCAiQml0c1BlckNvbXBvbmVudCIpOwogICAgICBpZiAoIWJpdHNQZXJDb21wb25lbnQpIHsKICAgICAgICBpZiAodGhpcy5pbWFnZU1hc2spIHsKICAgICAgICAgIGJpdHNQZXJDb21wb25lbnQgPSAxOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYEJpdHMgcGVyIGNvbXBvbmVudCBtaXNzaW5nIGluIGltYWdlOiAke3RoaXMuaW1hZ2VNYXNrfWApOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgdGhpcy5icGMgPSBiaXRzUGVyQ29tcG9uZW50OwogICAgaWYgKCF0aGlzLmltYWdlTWFzaykgewogICAgICBsZXQgY29sb3JTcGFjZSA9IGRpY3QuZ2V0UmF3KCJDUyIpIHx8IGRpY3QuZ2V0UmF3KCJDb2xvclNwYWNlIik7CiAgICAgIGlmICghY29sb3JTcGFjZSkgewogICAgICAgICgwLCBfdXRpbC5pbmZvKSgiSlBYIGltYWdlcyAod2hpY2ggZG8gbm90IHJlcXVpcmUgY29sb3Igc3BhY2VzKSIpOwogICAgICAgIHN3aXRjaCAoaW1hZ2UubnVtQ29tcHMpIHsKICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgY29sb3JTcGFjZSA9IF9wcmltaXRpdmVzLk5hbWUuZ2V0KCJEZXZpY2VHcmF5Iik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAzOgogICAgICAgICAgICBjb2xvclNwYWNlID0gX3ByaW1pdGl2ZXMuTmFtZS5nZXQoIkRldmljZVJHQiIpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgNDoKICAgICAgICAgICAgY29sb3JTcGFjZSA9IF9wcmltaXRpdmVzLk5hbWUuZ2V0KCJEZXZpY2VDTVlLIik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgdGhyb3cgbmV3IEV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3IgKGxldCBpID0gMCwgaiA9IDA7IGkgPCB0aGlzLmRlY29kZS5sZW5ndGg7IGkgKz0gMiwgKytqKSB7CiAgICAgICAgY29uc3QgZG1pbiA9IHRoaXMuZGVjb2RlW2ldOwogICAgICAgIGNvbnN0IGRtYXggPSB0aGlzLmRlY29kZVtpICsgMV07CiAgICAgICAgdGhpcy5kZWNvZGVDb2VmZmljaWVudHNbal0gPSBpc0luZGV4ZWQgPyAoZG1heCAtIGRtaW4pIC8gbWF4IDogZG1heCAtIGRtaW47CiAgICAgICAgdGhpcy5kZWNvZGVBZGRlbmRzW2pdID0gaXNJbmRleGVkID8gZG1pbiA6IG1heCAqIGRtaW47CiAgICAgIH0KICAgIH0KICAgIGlmIChzbWFzaykgewogICAgICB0aGlzLnNtYXNrID0gbmV3IFBERkltYWdlKHsKICAgICAgICB4cmVmLAogICAgICAgIHJlcywKICAgICAgICBpbWFnZTogc21hc2ssCiAgICAgICAgaXNJbmxpbmUsCiAgICAgICAgcGRmRnVuY3Rpb25GYWN0b3J5LAogICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgIH0pOwogICAgfSBlbHNlIGlmIChtYXNrKSB7CiAgICAgIGlmIChtYXNrIGluc3RhbmNlb2YgX2Jhc2Vfc3RyZWFtLkJhc2VTdHJlYW0pIHsKICAgICAgICBjb25zdCBtYXNrRGljdCA9IG1hc2suZGljdCwKICAgICAgICAgIGltYWdlTWFzayA9IG1hc2tEaWN0LmdldCgiSU0iLCAiSW1hZ2VNYXNrIik7CiAgICAgICAgaWYgKCFpbWFnZU1hc2spIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiSWdub3JpbmcgL01hc2sgaW4gaW1hZ2Ugd2l0aG91dCAvSW1hZ2VNYXNrLiIpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB0aGlzLm1hc2sgPSBuZXcgUERGSW1hZ2UoewogICAgICAgICAgICB4cmVmLAogICAgICAgICAgICByZXMsCiAgICAgICAgICAgIGltYWdlOiBtYXNrLAogICAgICAgICAgICBpc0lubGluZSwKICAgICAgICAgICAgaXNNYXNrOiB0cnVlLAogICAgICAgICAgICBwZGZGdW5jdGlvbkZhY3RvcnksCiAgICAgICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgdGhpcy5tYXNrID0gbWFzazsKICAgICAgfQogICAgfQogIH0KICBzdGF0aWMgYXN5bmMgYnVpbGRJbWFnZShfcmVmMikgewogICAgbGV0IHsKICAgICAgeHJlZiwKICAgICAgcmVzLAogICAgICBpbWFnZSwKICAgICAgaXNJbmxpbmUgPSBmYWxzZSwKICAgICAgcGRmRnVuY3Rpb25GYWN0b3J5LAogICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgfSA9IF9yZWYyOwogICAgY29uc3QgaW1hZ2VEYXRhID0gaW1hZ2U7CiAgICBsZXQgc21hc2tEYXRhID0gbnVsbDsKICAgIGxldCBtYXNrRGF0YSA9IG51bGw7CiAgICBjb25zdCBzbWFzayA9IGltYWdlLmRpY3QuZ2V0KCJTTWFzayIpOwogICAgY29uc3QgbWFzayA9IGltYWdlLmRpY3QuZ2V0KCJNYXNrIik7CiAgICBpZiAoc21hc2spIHsKICAgICAgaWYgKHNtYXNrIGluc3RhbmNlb2YgX2Jhc2Vfc3RyZWFtLkJhc2VTdHJlYW0pIHsKICAgICAgICBzbWFza0RhdGEgPSBzbWFzazsKICAgICAgfSBlbHNlIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoIlVuc3VwcG9ydGVkIC9TTWFzayBmb3JtYXQuIik7CiAgICAgIH0KICAgIH0gZWxzZSBpZiAobWFzaykgewogICAgICBpZiAobWFzayBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtIHx8IEFycmF5LmlzQXJyYXkobWFzaykpIHsKICAgICAgICBtYXNrRGF0YSA9IG1hc2s7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJVbnN1cHBvcnRlZCAvTWFzayBmb3JtYXQuIik7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBuZXcgUERGSW1hZ2UoewogICAgICB4cmVmLAogICAgICByZXMsCiAgICAgIGltYWdlOiBpbWFnZURhdGEsCiAgICAgIGlzSW5saW5lLAogICAgICBzbWFzazogc21hc2tEYXRhLAogICAgICBtYXNrOiBtYXNrRGF0YSwKICAgICAgcGRmRnVuY3Rpb25GYWN0b3J5LAogICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgfSk7CiAgfQogIHN0YXRpYyBjcmVhdGVSYXdNYXNrKF9yZWYzKSB7CiAgICBsZXQgewogICAgICBpbWdBcnJheSwKICAgICAgd2lkdGgsCiAgICAgIGhlaWdodCwKICAgICAgaW1hZ2VJc0Zyb21EZWNvZGVTdHJlYW0sCiAgICAgIGludmVyc2VEZWNvZGUsCiAgICAgIGludGVycG9sYXRlCiAgICB9ID0gX3JlZjM7CiAgICBjb25zdCBjb21wdXRlZExlbmd0aCA9ICh3aWR0aCArIDcgPj4gMykgKiBoZWlnaHQ7CiAgICBjb25zdCBhY3R1YWxMZW5ndGggPSBpbWdBcnJheS5ieXRlTGVuZ3RoOwogICAgY29uc3QgaGF2ZUZ1bGxEYXRhID0gY29tcHV0ZWRMZW5ndGggPT09IGFjdHVhbExlbmd0aDsKICAgIGxldCBkYXRhLCBpOwogICAgaWYgKGltYWdlSXNGcm9tRGVjb2RlU3RyZWFtICYmICghaW52ZXJzZURlY29kZSB8fCBoYXZlRnVsbERhdGEpKSB7CiAgICAgIGRhdGEgPSBpbWdBcnJheTsKICAgIH0gZWxzZSBpZiAoIWludmVyc2VEZWNvZGUpIHsKICAgICAgZGF0YSA9IG5ldyBVaW50OEFycmF5KGltZ0FycmF5KTsKICAgIH0gZWxzZSB7CiAgICAgIGRhdGEgPSBuZXcgVWludDhBcnJheShjb21wdXRlZExlbmd0a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4Q2xhbXBlZEFycmF5KHdpZHRoICogaGVpZ2h0ICogNCk7CiAgICAgICAgKDAsIF9pbWFnZV91dGlscy5jb252ZXJ0QmxhY2tBbmRXaGl0ZVRvUkdCQSkoewogICAgICAgICAgc3JjOiBpbWdBcnJheSwKICAgICAgICAgIGRlc3Q6IGRhdGEsCiAgICAgICAgICB3aWR0aCwKICAgICAgICAgIGhlaWdodCwKICAgICAgICAgIG5vbkJsYWNrQ29sb3I6IDAsCiAgICAgICAgICBpbnZlcnNlRGVjb2RlCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIF9pbWFnZV9yZXNpemVyLkltYWdlUmVzaXplci5jcmVhdGVJbWFnZSh7CiAgICAgICAgICBraW5kOiBfdXRpbC5JbWFnZUtpbmQuUkdCQV8zMkJQUCwKICAgICAgICAgIGRhdGEsCiAgICAgICAgICB3aWR0aCwKICAgICAgICAgIGhlaWdodCwKICAgICAgICAgIGludGVycG9sYXRlCiAgICAgICAgfSk7CiAgICAgIH0KICAgICAgY29uc3QgY2FudmFzID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgY29uc3QgY3R4ID0gY2FudmFzLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGltZ0RhdGEgPSBjdHguY3JlYXRlSW1hZ2VEYXRhKHdpZHRoLCBoZWlnaHQpOwogICAgICAoMCwgX2ltYWdlX3V0aWxzLmNvbnZlcnRCbGFja0FuZFdoaXRlVG9SR0JBKSh7CiAgICAgICAgc3JjOiBpbWdBcnJheSwKICAgICAgICBkZXN0OiBpbWdEYXRhLmRhdGEsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0LAogICAgICAgIG5vbkJsYWNrQ29sb3I6IDAsCiAgICAgICAgaW52ZXJzZURlY29kZQogICAgICB9KTsKICAgICAgY3R4LnB1dEltYWdlRGF0YShpbWdEYXRhLCAwLCAwKTsKICAgICAgY29uc3QgYml0bWFwID0gY2FudmFzLnRyYW5zZmVyVG9JbWFnZUJpdG1hcCgpOwogICAgICByZXR1cm4gewogICAgICAgIGRhdGE6IG51bGwsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0LAogICAgICAgIGludGVycG9sYXRlLAogICAgICAgIGJpdG1hcAogICAgICB9OwogICAgfQogICAgcmV0dXJuIHRoaXMuY3JlYXRlUmF3TWFzayh7CiAgICAgIGltZ0FycmF5LAogICAgICB3aWR0aCwKICAgICAgaGVpZ2h0LAogICAgICBpbnZlcnNlRGVjb2RlLAogICAgICBpbWFnZUlzRnJvbURlY29kZVN0cmVhbSwKICAgICAgaW50ZXJwb2xhdGUKICAgIH0pOwogIH0KICBnZXQgZHJhd1dpZHRoKCkgewogICAgcmV0dXJuIE1hdGgubWF4KHRoaXMud2lkdGgsIHRoaXMuc21hc2sgJiYgdGhpcy5zbWFzay53aWR0aCB8fCAwLCB0aGlzLm1hc2sgJiYgdGhpcy5tYXNrLndpZHRoIHx8IDApOwogIH0KICBnZXQgZHJhd0hlaWdodCgpIHsKICAgIHJldHVybiBNYXRoLm1heCh0aGlzLmhlaWdodCwgdGhpcy5zbWFzayAmJiB0aGlzLnNtYXNrLmhlaWdodCB8fCAwLCB0aGlzLm1hc2sgJiYgdGhpcy5tYXNrLmhlaWdodCB8fCAwKTsKICB9CiAgZGVjb2RlQnVmZmVyKGJ1ZmZlcikgewogICAgY29uc3QgYnBjID0gdGhpcy5icGM7CiAgICBjb25zdCBudW1Db21wcyA9IHRoaXMubnVtQ29tcHM7CiAgICBjb25zdCBkZWNvZGVBZGRlbmRzID0gdGhpcy5kZWNvZGVBZGRlbmRzOwogICAgY29uc3QgZGVjb2RlQ29lZmZpY2llbnRzID0gdGhpcy5kZWNvZGVDb2VmZmljaWVudHM7CiAgICBjb25zdCBtYXggPSAoMSA8PCBicGMpIC0gMTsKICAgIGxldCBpLCBpaTsKICAgIGlmIChicGMgPT09IDEpIHsKICAgICAgZm9yIChpID0gMCwgaWkgPSBidWZmZXIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgIGJ1ZmZlcltpXSA9ICshYnVmZmVyW2ldOwogICAgICB9CiAgICAgIHJldHVybjsKICAgIH0KICAgIGxldCBpbmRleCA9IDA7CiAgICBmb3IgKGkgPSAwLCBpaSA9IHRoaXMud2lkdGggKiB0aGlzLmhlaWdodDsgaSA8IGlpOyBpKyspIHsKICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBudW1Db21wczsgaisrKSB7CiAgICAgICAgYnVmZmVyW2luZGV4XSA9IGRlY29kZUFuZENsYW1wKGJ1ZmZlcltpbmRleF0sIGRlY29kZUFkZGVuZHNbal0sIGRlY29kZUNvZWZmaWNpZW50c1tqXSwgbWF4KTsKICAgICAgICBpbmRleCsrOwogICAgICB9CiAgICB9CiAgfQogIGdldENvbXBvbmVudHMoYnVmZmVyKSB7CiAgICBjb25zdCBicGMgPSB0aGlzLmJwYzsKICAgIGlmIChicGMgPT09IDgpIHsKICAgICAgcmV0dXJuIGJ1ZmZlcjsKICAgIH0KICAgIGNvbnN0IHdpZHRoID0gdGhpcy53aWR0aDsKICAgIGNvbnN0IGhlaWdodCA9IHRoaXMuaGVpZ2h0OwogICAgY29uc3QgbnVtQ29tcHMgPSB0aGlzLm51bUNvbXBzOwogICAgY29uc3QgbGVuZ3RoID0gd2lkdGggKiBoZWlnaHQgKiBudW1Db21wczsKICAgIGxldCBidWZmZXJQb3MgPSAwOwogICAgbGV0IG91dHB1dDsKICAgIGlmIChicGMgPD0gOCkgewogICAgICBvdXRwdXQgPSBuZXcgVWludDhBcnJheShsZW5ndGgpOwogICAgfSBlbHNlIGlmIChicGMgPD0gMTYpIHsKICAgICAgb3V0cHV0ID0gbmV3IFVpbnQxNkFycmF5KGxlbmd0aCk7CiAgICB9IGVsc2UgewogICAgICBvdXRwdXQgPSBuZXcgVWludDMyQXJyYXkobGVuZ3RoKTsKICAgIH0KICAgIGNvbnN0IHJvd0NvbXBzID0gd2lkdGggKiBudW1Db21wczsKICAgIGNvbnN0IG1heCA9ICgxIDw8IGJwYykgLSAxOwogICAgbGV0IGkgPSAwLAogICAgICBpaSwKICAgICAgYnVmOwogICAgaWYgKGJwYyA9PT0gMSkgewogICAgICBsZXQgbWFzaywgbG9vcDFFbmQsIGxvb3AyRW5kOwogICAgICBmb3IgKGxldCBqID0gMDsgaiA8IGhlaWdodDsgaisrKSB7CiAgICAgICAgbG9vcDFFbmQgPSBpICsgKHJvd0NvbXBzICYgfjcpOwogICAgICAgIGxvb3AyRW5kID0gaSArIHJvd0NvbXBzOwogICAgICAgIHdoaWxlIChpIDwgbG9vcDFFbmQpIHsKICAgICAgICAgIGJ1ZiA9IGJ1ZmZlcltidWZmZXJQb3MrK107CiAgICAgICAgICBvdXRwdXRbaV0gPSBidWYgPj4gNyAmIDE7CiAgICAgICAgICBvdXRwdXRbaSArIDFdID0gYnVmID4+IDYgJiAxOwogICAgICAgICAgb3V0cHV0W2kgKyAyXSA9IGJ1ZiA+PiA1ICYgMTsKICAgICAgICAgIG91dHB1dFtpICsgM10gPSBidWYgPj4gNCAmIDE7CiAgICAgICAgICBvdXRwdXRbaSArIDRdID0gYnVmID4+IDMgJiAxOwogICAgICAgICAgb3V0cHV0W2kgKyA1XSA9IGJ1ZiA+PiAyICYgMTsKICAgICAgICAgIG91dHB1dFtpICsgNl0gPSBidWYgPj4gMSAmIDE7CiAgICAgICAgICBvdXRwdXRbaSArIDddID0gYnVmICYgMTsKICAgICAgICAgIGkgKz0gODsKICAgICAgICB9CiAgICAgICAgaWYgKGkgPCBsb29wMkVuZCkgewogICAgICAgICAgYnVmID0gYnVmZmVyW2J1ZmZlclBvcysrXTsKICAgICAgICAgIG1hc2sgPSAxMjg7CiAgICAgICAgICB3aGlsZSAoaSA8IGxvb3AyRW5kKSB7CiAgICAgICAgICAgIG91dHB1dFtpKytdID0gKyEhKGJ1ZiAmIG1hc2spOwogICAgICAgICAgICBtYXNrID4+PSAxOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgbGV0IGJpdHMgPSAwOwogICAgICBidWYgPSAwOwogICAgICBmb3IgKGkgPSAwLCBpaSA9IGxlbmd0aDsgaSA8IGlpOyArK2kpIHsKICAgICAgICBpZiAoaSAlIHJvd0NvbXBzID09PSAwKSB7CiAgICAgICAgICBidWYgPSAwOwogICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgfQogICAgICAgIHdoaWxlIChiaXRzIDwgYnBjKSB7CiAgICAgICAgICBidWYgPSBidWYgPDwgOCB8IGJ1ZmZlcltidWZmZXJQb3MrK107CiAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHJlbWFpbmluZ0JpdHMgPSBiaXRzIC0gYnBjOwogICAgICAgIGxldCB2YWx1ZSA9IGJ1ZiA+PiByZW1haW5pbmdCaXRzOwogICAgICAgIGlmICh2YWx1ZSA8IDApIHsKICAgICAgICAgIHZhbHVlID0gMDsKICAgICAgICB9IGVsc2UgaWYgKHZhbHVlID4gbWF4KSB7CiAgICAgICAgICB2YWx1ZSA9IG1heDsKICAgICAgICB9CiAgICAgICAgb3V0cHV0W2ldID0gdmFsdWU7CiAgICAgICAgYnVmICY9ICgxIDw8IHJlbWFpbmluZ0JpdHMpIC0gMTsKICAgICAgICBiaXRzID0gcmVtYWluaW5nQml0czsKICAgICAgfQogICAgfQogICAgcmV0dXJuIG91dHB1dDsKICB9CiAgZmlsbE9wYWNpdHkocmdiYUJ1Ziwgd2lkdGgsIGhlaWdodCwgYWN0dWFsSGVpZ2h0LCBpbWFnZSkgewogICAgY29uc3Qgc21hc2sgPSB0aGlzLnNtYXNrOwogICAgY29uc3QgbWFzayA9IHRoaXMubWFzazsKICAgIGxldCBhbHBoYUJ1Ziwgc3csIHNoLCBpLCBpaSwgajsKICAgIGlmIChzbWFzaykgewogICAgICBzdyA9IHNtYXNrLndpZHRoOwogICAgICBzaCA9IHNtYXNrLmhlaWdodDsKICAgICAgYWxw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wgaWkgPSB3aWR0aCAqIGhlaWdodDsgaSA8IGlpOyArK2kpIHsKICAgICAgICAgIGxldCBvcGFjaXR5ID0gMDsKICAgICAgICAgIGNvbnN0IGltYWdlT2Zmc2V0ID0gaSAqIG51bUNvbXBzOwogICAgICAgICAgZm9yIChqID0gMDsgaiA8IG51bUNvbXBzOyArK2opIHsKICAgICAgICAgICAgY29uc3QgY29sb3IgPSBpbWFnZVtpbWFnZU9mZnNldCArIGpdOwogICAgICAgICAgICBjb25zdCBtYXNrT2Zmc2V0ID0gaiAqIDI7CiAgICAgICAgICAgIGlmIChjb2xvciA8IG1hc2tbbWFza09mZnNldF0gfHwgY29sb3IgPiBtYXNrW21hc2tPZmZzZXQgKyAxXSkgewogICAgICAgICAgICAgIG9wYWNpdHkgPSAyNTU7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGFscGhhQnVmW2ldID0gb3BhY2l0eTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJVbmtub3duIG1hc2sgZm9ybWF0LiIpOwogICAgICB9CiAgICB9CiAgICBpZiAoYWxwaGFCdWYpIHsKICAgICAgZm9yIChpID0gMCwgaiA9IDMsIGlpID0gd2lkdGggKiBhY3R1YWxIZWlnaHQ7IGkgPCBpaTsgKytpLCBqICs9IDQpIHsKICAgICAgICByZ2JhQnVmW2pdID0gYWxwaGFCdWZbaV07CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGZvciAoaSA9IDAsIGogPSAzLCBpaSA9IHdpZHRoICogYWN0dWFsSGVpZ2h0OyBpIDwgaWk7ICsraSwgaiArPSA0KSB7CiAgICAgICAgcmdiYUJ1ZltqXSA9IDI1NTsKICAgICAgfQogICAgfQogIH0KICB1bmRvUHJlYmxlbmQoYnVmZmVyLCB3aWR0aCwgaGVpZ2h0KSB7CiAgICBjb25zdCBtYXR0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vbG9yU3BhY2UubmFtZSA9PT0gIkRldmljZVJHQiIgJiYgYnBjID09PSA4ICYmICF0aGlzLm5lZWRzRGVjb2RlKSB7CiAgICAgICAga2luZCA9IF91dGlsLkltYWdlS2luZC5SR0JfMjRCUFA7CiAgICAgIH0KICAgICAgaWYgKGtpbmQgJiYgIXRoaXMuc21hc2sgJiYgIXRoaXMubWFzayAmJiBkcmF3V2lkdGggPT09IG9yaWdpbmFsV2lkdGggJiYgZHJhd0hlaWdodCA9PT0gb3JpZ2luYWxIZWlnaHQpIHsKICAgICAgICBjb25zdCBkYXRhID0gdGhpcy5nZXRJbWFnZUJ5dGVzKG9yaWdpbmFsSGVpZ2h0ICogcm93Qnl0ZXMsIHt9KTsKICAgICAgICBpZiAoaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQpIHsKICAgICAgICAgIGlmIChtdXN0QmVSZXNpemVkKSB7CiAgICAgICAgICAgIHJldHVybiBfaW1hZ2VfcmVzaXplci5JbWFnZVJlc2l6ZXIuY3JlYXRlSW1hZ2UoewogICAgICAgICAgICAgIGRhdGEsCiAgICAgICAgICAgICAga2luZCwKICAgICAgICAgICAgICB3aWR0aDogZHJhd1dpZHRoLAogICAgICAgICAgICAgIGhlaWdodDogZHJhd0hlaWdodCwKICAgICAgICAgICAgICBpbnRlcnBvbGF0ZTogdGhpcy5pbnRlcnBvbGF0ZQogICAgICAgICAgICB9LCB0aGlzLm5lZWRzRGVjb2RlKTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiB0aGlzLmNyZWF0ZUJpdG1hcChraW5kLCBvcmlnaW5hbFdpZHRoLCBvcmlnaW5hbEhlaWdodCwgZGF0YSk7CiAgICAgICAgfQogICAgICAgIGltZ0RhdGEua2luZCA9IGtpbmQ7CiAgICAgICAgaW1nRGF0YS5kYXRhID0gZGF0YTsKICAgICAgICBpZiAodGhpcy5uZWVkc0RlY29kZSkgewogICAgICAgICAgKDAsIF91dGlsLmFzc2VydCkoa2luZCA9PT0g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AgICBpc0hhbmRsZWQgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGlzSGFuZGxlZCkgewogICAgICAgICAgICBjb25zdCByZ2JhID0gdGhpcy5nZXRJbWFnZUJ5dGVzKGltYWdlTGVuZ3RoLCB7CiAgICAgICAgICAgICAgZHJhd1dpZHRoLAogICAgICAgICAgICAgIGRyYXdIZWlnaHQsCiAgICAgICAgICAgICAgZm9yY2VSR0JBOiB0cnVlCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICByZXR1cm4gdGhpcy5jcmVhdGVCaXRtYXAoX3V0aWwuSW1hZ2VLaW5kLlJHQkFfMzJCUFAsIGRyYXdXaWR0aCwgZHJhd0hlaWdodCwgcmdiYSk7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHN3aXRjaCAodGhpcy5jb2xvclNwYWNlLm5hbWUpIHsKICAgICAgICAgICAgY2FzZSAiRGV2aWNlR3JheSI6CiAgICAgICAgICAgICAgaW1hZ2VMZW5ndGggKj0gMzsKICAgICAgICAgICAgY2FzZSAiRGV2aWNlUkdCIjoKICAgICAgICAgICAgY2FzZSAiRGV2aWNlQ01ZSyI6CiAgICAgICAgICAgICAgaW1nRGF0YS5raW5kID0gX3V0aWwuSW1hZ2VLaW5kLlJHQl8yNEJQUDsKICAgICAgICAgICAgICBpbWdEYXRhLmRhdGEgPSB0aGlzLmdldEltYWdlQnl0ZXMoaW1hZ2VMZW5ndGgsIHsKICAgICAgICAgICAgICAgIGRyYXdXaWR0aCwKICAgICAgICAgICAgICAgIGRyYXdIZWlnaHQsCiAgICAgICAgICAgICAgICBmb3JjZVJHQjogdHJ1ZQogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIGlmIChtdXN0QmVSZXNpemVkKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gX2ltYWdlX3Jlc2l6ZXIuSW1hZ2VSZXNpemVyLmNyZWF0ZUltYWdlKGlt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ybiAiJiI7CiAgICAgICAgY2FzZSAicXVvdCI6CiAgICAgICAgICByZXR1cm4gJyInOwogICAgICAgIGNhc2UgImFwb3MiOgogICAgICAgICAgcmV0dXJuICInIjsKICAgICAgfQogICAgICByZXR1cm4gdGhpcy5vblJlc29sdmVFbnRpdHkoZW50aXR5KTsKICAgIH0pOwogIH0KICBfcGFyc2VDb250ZW50KHMsIHN0YXJ0KSB7CiAgICBjb25zdCBhdHRyaWJ1dGVzID0gW107CiAgICBsZXQgcG9zID0gc3RhcnQ7CiAgICBmdW5jdGlvbiBza2lwV3MoKSB7CiAgICAgIHdoaWxlIChwb3MgPCBzLmxlbmd0aCAmJiBpc1doaXRlc3BhY2UocywgcG9zKSkgewogICAgICAgICsrcG9zOwogICAgICB9CiAgICB9CiAgICB3aGlsZSAocG9zIDwgcy5sZW5ndGggJiYgIWlzV2hpdGVzcGFjZShzLCBwb3MpICYmIHNbcG9zXSAhPT0gIj4iICYmIHNbcG9zXSAhPT0gIi8iKSB7CiAgICAgICsrcG9zOwogICAgfQogICAgY29uc3QgbmFtZSA9IHMuc3Vic3RyaW5nKHN0YXJ0LCBwb3MpOwogICAgc2tpcFdzKCk7CiAgICB3aGlsZSAocG9zIDwgcy5sZW5ndGggJiYgc1twb3NdICE9PSAiPiIgJiYgc1twb3NdICE9PSAiLyIgJiYgc1twb3NdICE9PSAiPyIpIHsKICAgICAgc2tpcFdzKCk7CiAgICAgIGxldCBhdHRyTmFtZSA9ICIiLAogICAgICAgIGF0dHJWYWx1ZSA9ICIiOwogICAgICB3aGlsZSAocG9zIDwgcy5sZW5ndGggJiYgIWlzV2hpdGVzcGFjZShzLCBwb3MpICYmIHNbcG9zXSAhPT0gIj0iKSB7CiAgICAgICAgYXR0ck5hbWUgKz0gc1twb3NdOwogICAgICAgICsrcG9zOwogICAgICB9CiAgICAgIHNraXBXcygpOwogICAgICBpZiAoc1twb3NdICE9PSAiPSIpIHsKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogIC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b3M7CiAgICB9CiAgICBjb25zdCBuYW1lID0gcy5zdWJzdHJpbmcoc3RhcnQsIHBvcyk7CiAgICBza2lwV3MoKTsKICAgIGNvbnN0IGF0dHJTdGFydCA9IHBvczsKICAgIHdoaWxlIChwb3MgPCBzLmxlbmd0aCAmJiAoc1twb3NdICE9PSAiPyIgfHwgc1twb3MgKyAxXSAhPT0gIj4iKSkgewogICAgICArK3BvczsKICAgIH0KICAgIGNvbnN0IHZhbHVlID0gcy5zdWJzdHJpbmcoYXR0clN0YXJ0LCBwb3MpOwogICAgcmV0dXJuIHsKICAgICAgbmFtZSwKICAgICAgdmFsdWUsCiAgICAgIHBhcnNlZDogcG9zIC0gc3RhcnQKICAgIH07CiAgfQogIHBhcnNlWG1sKHMpIHsKICAgIGxldCBpID0gMDsKICAgIHdoaWxlIChpIDwgcy5sZW5ndGgpIHsKICAgICAgY29uc3QgY2ggPSBzW2ldOwogICAgICBsZXQgaiA9IGk7CiAgICAgIGlmIChjaCA9PT0gIjwiKSB7CiAgICAgICAgKytqOwogICAgICAgIGNvbnN0IGNoMiA9IHNbal07CiAgICAgICAgbGV0IHE7CiAgICAgICAgc3dpdGNoIChjaDIpIHsKICAgICAgICAgIGNhc2UgIi8iOgogICAgICAgICAgICArK2o7CiAgICAgICAgICAgIHEgPSBzLmluZGV4T2YoIj4iLCBqKTsKICAgICAgICAgICAgaWYgKHEgPCAwKSB7CiAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRFbGVtZW50KTsKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGhpcy5vbkVuZEVsZW1lbnQocy5zdWJzdHJpbmcoaiwgcSkpOwogICAgICAgICAgICBqID0gcSArIDE7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAiPyI6CiAgICAgICAgICAgICsrajsKICAgICAgICAgICAgY29uc3QgcGkgPSB0aGlzLl9wYXJzZVByb2Nlc3NpbmdJbnN0cnVjdGlvbihzLCBqKTsKICAgICAgICAgICAgaWYgKHMuc3Vic3RyaW5nKGogKyBwaS5wYXJzZWQsIGogKyBwaS5wYXJzZWQgKyAyKSAhPT0gIj8+IikgewogICAgICAgICAgICAgIHRoaXMub25FcnJvcihYTUxQYXJzZXJFcnJvckNvZGUuVW50ZXJtaW5hdGVkWG1sRGVjbGFyYXRpb24pOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLm9uUGkocGkubmFtZSwgcGkudmFsdWUpOwogICAgICAgICAgICBqICs9IHBpLnBhcnNlZCArIDI7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAiISI6CiAgICAgICAgICAgIGlmIChzLnN1YnN0cmluZyhqICsgMSwgaiArIDMpID09PSAiLS0iKSB7CiAgICAgICAgICAgICAgcSA9IHMuaW5kZXhPZigiLS0+IiwgaiArIDMpOwogICAgICAgICAgICAgIGlmIChxIDwgMCkgewogICAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRDb21tZW50KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgdGhpcy5vbkNvbW1lbnQocy5zdWJzdHJpbmcoaiArIDMsIHEpKTsKICAgICAgICAgICAgICBqID0gcSArIDM7CiAgICAgICAgICAgIH0gZWxzZSBpZiAocy5zdWJzdHJpbmcoaiArIDEsIGogKyA4KSA9PT0gIltDREFUQVsiKSB7CiAgICAgICAgICAgICAgcSA9IHMuaW5kZXhPZigiXV0+IiwgaiArIDgpOwogICAgICAgICAgICAgIGlmIChxIDwgMCkgewogICAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRDZGF0KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgdGhpcy5vbkNkYXRhKHMuc3Vic3RyaW5nKGogKyA4LCBxKSk7CiAgICAgICAgICAgICAgaiA9IHEgKyAzOwogICAgICAgICAgICB9IGVsc2UgaWYgKHMuc3Vic3RyaW5nKGogKyAxLCBqICsgOCkgPT09ICJET0NUWVBFIikgewogICAgICAgICAgICAgIGNvbnN0IHEyID0gcy5pbmRleE9mKCJbIiwgaiArIDgpOwogICAgICAgICAgICAgIGxldCBjb21wbGV4RG9jdHlwZSA9IGZhbHNlOwogICAgICAgICAgICAgIHEgPSBzLmluZGV4T2YoIj4iLCBqICsgOCk7CiAgICAgICAgICAgICAgaWYgKHEgPCAwKSB7CiAgICAgICAgICAgICAgICB0aGlzLm9uRXJyb3IoWE1MUGFyc2VyRXJyb3JDb2RlLlVudGVybWluYXRlZERvY3R5cGVEZWNsYXJhdGlvbik7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChxMiA+IDAgJiYgcSA+IHEyKSB7CiAgICAgICAgICAgICAgICBxID0gcy5pbmRleE9mKCJdPiIsIGogKyA4KTsKICAgICAgICAgICAgICAgIGlmIChxIDwgMCkgewogICAgICAgICAgICAgICAgICB0aGlzLm9uRXJyb3IoWE1MUGFyc2VyRXJyb3JDb2RlLlVudGVybWluYXRlZERvY3R5cGVEZWNsYXJhdGlvbik7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbXBsZXhEb2N0eXBlID0gdHJ1ZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgZG9jdHlwZUNvbnRlbnQgPSBzLnN1YnN0cmluZyhqICsgOCwgcSArIChjb21wbGV4RG9jdHlwZSA/IDEgOiAwKSk7CiAgICAgICAgICAgICAgdGhpcy5vbkRvY3R5cGUoZG9jdHlwZUNvbnRlbnQpOwogICAgICAgICAgICAgIGogPSBxICsgKGNvbXBsZXhEb2N0eXBlID8gMiA6IDEpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRoaXMub25FcnJvcihYTUxQYXJzZXJFcnJvckNvZGUuTWFsZm9ybWVkRWxlbWVudCk7CiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgY29uc3QgY29udGVudCA9IHRoaXMuX3BhcnNlQ29udGVudChzLCBqKTsKICAgICAgICAgICAgaWYgKGNvbnRlbnQgPT09IG51bGwpIHsKICAgICAgICAgICAgICB0aGlzLm9uRXJyb3IoWE1MUGFyc2VyRXJyb3JDb2RlLk1hbGZvcm1lZEVsZW1lbnQpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgaXNDbG9zZWQgPSBmYWxzZTsKICAgICAgICAgICAgaWYgKHMuc3Vic3RyaW5nKGogKyBjb250ZW50LnBhcnNlZCwgaiArIGNvbnRlbnQucGFyc2VkICsgMikgPT09ICIvPiIpIHsKICAgICAgICAgICAgICBpc0Nsb3NlZCA9IHRydWU7CiAgICAgICAgICAgIH0gZWxzZSBpZiAocy5zdWJzdHJpbmcoaiArIGNvbnRlbnQucGFyc2VkLCBqICsgY29udGVudC5wYXJzZWQgKyAxKSAhPT0gIj4iKSB7CiAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRFbGVtZW50KTsKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGhpcy5vbkJlZ2luRWxlbWVudChjb250ZW50Lm5hbWUsIGNvbnRlbnQuYXR0cmlidXRlcywgaXNDbG9zZWQpOwogICAgICAgICAgICBqICs9IGNvbnRlbnQucGFyc2VkICsgKGlzQ2xvc2VkID8gMiA6IDEpOwogICAgICAgICAgICBicmVhazs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iAgICAgICAgICBjb25zdCByZXMgPSBub2RlLnNlYXJjaE5vZGUocGF0aHMsIHBvcyArIDEpOwogICAgICAgICAgaWYgKHJlcyAhPT0gbnVsbCkgewogICAgICAgICAgICByZXR1cm4gcmVzOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY29uc3QgW3BhcmVudF0gPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGxldCBzaWJsaW5nUG9zID0gMDsKICAgICAgICAgIGZvciAoY29uc3QgY2hpbGQgb2YgcGFyZW50LmNoaWxkTm9kZXMpIHsKICAgICAgICAgICAgaWYgKGNvbXBvbmVudC5uYW1lID09PSBjaGlsZC5ub2RlTmFtZSkgewogICAgICAgICAgICAgIGlmIChzaWJsaW5nUG9zID09PSBjb21wb25lbnQucG9zKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gY2hpbGQuc2VhcmNoTm9kZShwYXRocywgcG9zICsgMSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNpYmxpbmdQb3MrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG5vZGUuc2VhcmNoTm9kZShwYXRocywgcG9zICsgMSk7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChub2RlLmNoaWxkTm9kZXMgJiYgbm9kZS5jaGlsZE5vZGVzLmxlbmd0aCAhPT0gMCkgewogICAgICAgIHN0YWNrLnB1c2goW25vZGUsIDBdKTsKICAgICAgICBub2RlID0gbm9kZS5jaGlsZE5vZGVzWzBdOwogICAgICB9IGVsc2UgaWYgKHN0YWNrLmxlbmd0aCA9PT0gMCkgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9IGVsc2UgewogICAgICAgIHdoaWxlIChzdGFjay5sZW5ndGggIT09IDApIHsKICAgICAgICAgIGNvbnN0IFtwYXJlbnQsIGN1cnJlbnRQb3NdID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBjb25zdCBuZXdQb3MgPSBjdXJyZW50UG9zICsgMTsKICAgICAgICAgIGlmIChuZXdQb3MgPCBwYXJlbnQuY2hpbGROb2Rlcy5sZW5ndGgpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChbcGFyZW50LCBuZXdQb3NdKTsKICAgICAgICAgICAgbm9kZSA9IHBhcmVudC5jaGlsZE5vZGVzW25ld1Bvc107CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICB9CiAgZHVtcChidWZmZXIpIHsKICAgIGlmICh0aGlzLm5vZGVOYW1lID09PSAiI3RleHQiKSB7CiAgICAgIGJ1ZmZlci5wdXNoKCgwLCBfY29yZV91dGlscy5lbmNvZGVUb1htbFN0cmluZykodGhpcy5ub2RlVmFsdWUpKTsKICAgICAgcmV0dXJuOwogICAgfQogICAgYnVmZmVyLnB1c2goYDwke3RoaXMubm9kZU5hbWV9YCk7CiAgICBpZiAodGhpcy5hdHRyaWJ1dGVzKSB7CiAgICAgIGZvciAoY29uc3QgYXR0cmlidXRlIG9mIHRoaXMuYXR0cmlidXRlcykgewogICAgICAgIGJ1ZmZlci5wdXNoKGAgJHthdHRyaWJ1dGUubmFtZX09IiR7KDAsIF9jb3JlX3V0aWxzLmVuY29kZVRvWG1sU3RyaW5nKShhdHRyaWJ1dGUudmFsdWUpfSJgKTsKICAgICAgfQogICAgfQogICAgaWYgKHRoaXMuaGFzQ2hpbGROb2RlcygpKSB7CiAgICAgIGJ1ZmZlci5wdXNoKCI+Iik7CiAgICAgIGZvciAoY29uc3QgY2hpbGQgb2YgdGhpcy5jaGlsZE5vZGVzKSB7CiAgICAgICAgY2hpbGQuZHVtcChidWZmZXIpOwogICAgICB9CiAg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KICAgICAgICBnOwogICAgICBmb3IgKGogPSAwOyBqIDwgNjQ7ICsraikgewogICAgICAgIGlmIChqIDwgMTYpIHsKICAgICAgICAgIGYgPSBiICYgYyB8IH5iICYgZDsKICAgICAgICAgIGcgPSBqOwogICAgICAgIH0gZWxzZSBpZiAoaiA8IDMyKSB7CiAgICAgICAgICBmID0gZCAmIGIgfCB+ZCAmIGM7CiAgICAgICAgICBnID0gNSAqIGogKyAxICYgMTU7CiAgICAgICAgfSBlbHNlIGlmIChqIDwgNDgpIHsKICAgICAgICAgIGYgPSBiIF4gYyBeIGQ7CiAgICAgICAgICBnID0gMyAqIGogKyA1ICYgMTU7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGYgPSBjIF4gKGIgfCB+ZCk7CiAgICAgICAgICBnID0gNyAqIGogJiAxNTsKICAgICAgICB9CiAgICAgICAgY29uc3QgdG1wID0gZCwKICAgICAgICAgIHJvdGF0ZUFyZyA9IGEgKyBmICsga1tqXSArIHdbZ10gfCAwLAogICAgICAgICAgcm90YXRlID0gcltqXTsKICAgICAgICBkID0gYzsKICAgICAgICBjID0gYjsKICAgICAgICBiID0gYiArIChyb3RhdGVBcmcgPDwgcm90YXRlIHwgcm90YXRlQXJnID4+PiAzMiAtIHJvdGF0ZSkgfCAwOwogICAgICAgIGEgPSB0bXA7CiAgICAgIH0KICAgICAgaDAgPSBoMCArIGEgfCAwOwogICAgICBoMSA9IGgxICsgYiB8IDA7CiAgICAgIGgyID0gaDIgKyBjIHwgMDsKICAgICAgaDMgPSBoMyArIGQgfCAwOwogICAgfQogICAgcmV0dXJuIG5ldyBVaW50OEFycmF5KFtoMCAmIDB4RkYsIGgwID4+IDggJiAweEZGLCBoMCA+PiAxNiAmIDB4RkYsIGgwID4+PiAyNCAmIDB4RkYsIGgxICYgMHhGRiwgaDEgPj4gOCAmIDB4RkYsIGgxID4+IDE2ICYgMHhGRiwgaDEgPj4+IDI0ICYgMHhGRiwgaDIgJiAweEZGLCBoMiA+PiA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gIGNoKHRtcDEsIGUsIGYsIGcsIHRtcDIpOwogICAgICAgIHQxLmFkZCh0bXAxKTsKICAgICAgICB0MS5hZGQoa1tqXSk7CiAgICAgICAgdDEuYWRkKHdbal0pOwogICAgICAgIHNpZ21hKHQyLCBhLCB0bXAyKTsKICAgICAgICBtYWoodG1wMSwgYSwgYiwgYywgdG1wMik7CiAgICAgICAgdDIuYWRkKHRtcDEpOwogICAgICAgIHRtcDMgPSBoOwogICAgICAgIGggPSBnOwogICAgICAgIGcgPSBmOwogICAgICAgIGYgPSBlOwogICAgICAgIGQuYWRkKHQxKTsKICAgICAgICBlID0gZDsKICAgICAgICBkID0gYzsKICAgICAgICBjID0gYjsKICAgICAgICBiID0gYTsKICAgICAgICB0bXAzLmFzc2lnbih0MSk7CiAgICAgICAgdG1wMy5hZGQodDIpOwogICAgICAgIGEgPSB0bXAzOwogICAgICB9CiAgICAgIGgwLmFkZChhKTsKICAgICAgaDEuYWRkKGIpOwogICAgICBoMi5hZGQoYyk7CiAgICAgIGgzLmFkZChkKTsKICAgICAgaDQuYWRkKGUpOwogICAgICBoNS5hZGQoZik7CiAgICAgIGg2LmFkZChnKTsKICAgICAgaDcuYWRkKGgpOwogICAgfQogICAgbGV0IHJlc3VsdDsKICAgIGlmICghbW9kZTM4NCkgewogICAgICByZXN1bHQgPSBuZXcgVWludDhBcnJheSg2NCk7CiAgICAgIGgwLmNvcHlUbyhyZXN1bHQsIDApOwogICAgICBoMS5jb3B5VG8ocmVzdWx0LCA4KTsKICAgICAgaDIuY29weVRvKHJlc3VsdCwgMTYpOwogICAgICBoMy5jb3B5VG8ocmVzdWx0LCAyNCk7CiAgICAgIGg0LmNvcHlUbyhyZXN1bHQsIDMyKTsKICAgICAgaDUuY29weVRvKHJlc3VsdCwgNDApOwogICAgICBoNi5jb3B5VG8ocmVzdWx0LCA0OCk7CiAgICAgIGg3LmNvcHlUbyhyZXN1bHQsIDU2KTsKICAgIH0gZWxzZSB7CiAgICAgIHJlc3VsdC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107CiAgICBsZXQgaXYgPSB0aGlzLml2OwogICAgZm9yIChsZXQgaSA9IDA7IGkgPCBzb3VyY2VMZW5ndGg7ICsraSkgewogICAgICBidWZmZXJbYnVmZmVyTGVuZ3RoXSA9IGRhdGFbaV07CiAgICAgICsrYnVmZmVyTGVuZ3RoOwogICAgICBpZiAoYnVmZmVyTGVuZ3RoIDwgMTYpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBwbGFpbiA9IHRoaXMuX2RlY3J5cHQoYnVmZmVyLCB0aGlzLl9rZXkpOwogICAgICBmb3IgKGxldCBqID0gMDsgaiA8IDE2OyArK2opIHsKICAgICAgICBwbGFpbltqXSBePSBpdltqXTsKICAgICAgfQogICAgICBpdiA9IGJ1ZmZlcjsKICAgICAgcmVzdWx0LnB1c2gocGxhaW4pOwogICAgICBidWZmZXIgPSBuZXcgVWludDhBcnJheSgxNik7CiAgICAgIGJ1ZmZlckxlbmd0aCA9IDA7CiAgICB9CiAgICB0aGlzLmJ1ZmZlciA9IGJ1ZmZlcjsKICAgIHRoaXMuYnVmZmVyTGVuZ3RoID0gYnVmZmVyTGVuZ3RoOwogICAgdGhpcy5pdiA9IGl2OwogICAgaWYgKHJlc3VsdC5sZW5ndGggPT09IDApIHsKICAgICAgcmV0dXJuIG5ldyBVaW50OEFycmF5KDApOwogICAgfQogICAgbGV0IG91dHB1dExlbmd0aCA9IDE2ICogcmVzdWx0Lmxlbmd0aDsKICAgIGlmIChmaW5hbGl6ZSkgewogICAgICBjb25zdCBsYXN0QmxvY2sgPSByZXN1bHQuYXQoLTEpOwogICAgICBsZXQgcHNMZW4gPSBsYXN0QmxvY2tbMTVdOwogICAgICBpZiAocHNMZW4gPD0gMTYpIHsKICAgICAgICBmb3IgKGxldCBpID0gMTUsIGlpID0gMTYgLSBwc0xlbjsgaSA+PSBpaTsgLS1pKSB7CiAgICAgICAgICBpZiAobGFzdEJsb2NrW2ldICE9PSBwc0xlbikgewogICAgICAgICAgICBw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AweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkXSk7CiAgICB0aGlzLl9rZXkgPSB0aGlzLl9leHBhbmRLZXkoa2V5KTsKICB9CiAgX2V4cGFuZEtleShjaXBoZXJLZXkpIHsKICAgIGNvbnN0IGIgPSAxNzY7CiAgICBjb25zdCBzID0gdGhpcy5fczsKICAgIGNvbnN0IHJjb24gPSB0aGlzLl9yY29uOwogICAgY29uc3QgcmVzdWx0ID0gbmV3IFVpbnQ4QXJyYXkoYik7CiAgICByZXN1bHQuc2V0KGNpcGhlcktleSk7CiAgICBmb3IgKGxldCBqID0gMTYsIGkgPSAxOyBqIDwgYjsgKytpKSB7CiAgICAgIGxldCB0MSA9IHJlc3VsdFtqIC0gM107CiAgICAgIGxldCB0MiA9IHJlc3VsdFtqIC0gMl07CiAgICAgIGxldCB0MyA9IHJlc3VsdFtqIC0gMV07CiAgICAgIGxldCB0NCA9IHJlc3VsdFtqIC0gNF07CiAgICAgIHQxID0gc1t0MV07CiAgICAgIHQyID0gc1t0Ml07CiAgICAgIHQzID0gc1t0M107CiAgICAgIHQ0ID0gc1t0NF07CiAgICAgIHQxIF49IHJjb25baV07CiAgICAgIGZvciAobGV0IG4gPSAwOyBuIDwgNDsgKytuKSB7CiAgICAgICAgcmVzdWx0W2pdID0gdDEgXj0gcmVzdWx0W2ogLSAxNl07CiAgICAgICAgaisrOwogICAgICAgIHJlc3VsdFtqXSA9IHQyIF49IHJlc3VsdFtqIC0gMTZdOwogICAgICAgIGorKzsKICAgICAgICByZXN1bHRbal0gPSB0MyBePSByZXN1bHRbaiAtIDE2XTsKICAgICAgICBqKys7CiAgICAgICAgcmVzdWx0W2pdID0gdDQgXj0gcmVzdWx0W2ogLSAxNl07CiAgICAgICAgaisrOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gcmVzdWx0OwogIH0KfQpleHBvcnRzLkFFUzEyOENpcGhlciA9IEFFUzEyOENpcGhlcjsKY2xhc3MgQUVTMjU2Q2lwaGVyIGV4dGVuZHMgQUVTQmFzZUNpcGhlciB7CiAgY29uc3RydWN0b3Ioa2V5KSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5fY3ljbGVzT2ZSZXBldGl0aW9uID0gMTQ7CiAgICB0aGlzLl9rZXlTaXplID0gMjI0OwogICAgdGhpcy5fa2V5ID0gdGhpcy5fZXhwYW5kS2V5KGtleSk7CiAgfQogIF9leHBhbmRLZXkoY2lwaGVyS2V5KSB7CiAgICBjb25zdCBiID0gMjQwOwogICAgY29uc3QgcyA9IHRoaXMuX3M7CiAgICBjb25zdCByZXN1bHQgPSBuZXcgVWludDhBcnJheShiKTsKICAgIHJlc3VsdC5zZXQoY2lwaGVyS2V5KTsKICAgIGxldCByID0gMTsKICAgIGxldCB0MSwgdDIsIHQzLCB0NDsKICAgIGZvciAobGV0IGogPSAzMiwgaSA9IDE7IGogPCBiOyArK2kpIHsKICAgICAgaWYgKGogJSAzMiA9PT0gMTYpIHsKICAgICAgICB0MSA9IHNbdDFdOwogICAgICAgIHQyID0gc1t0Ml07CiAgICAgICAgdDMgPSBzW3QzXTsKICAgICAgICB0NCA9IHNbdDRdOwogICAgICB9IGVsc2UgaWYgKGogJSAzMiA9PT0gMCkgewogICAgICAgIHQxID0gcmVzdWx0W2ogLSAzXTsKICAgICAgICB0MiA9IHJlc3VsdFtqIC0gMl07CiAgICAgICAgdDMgPSByZXN1bHRbaiAtIDFdOwogICAgICAgIHQ0ID0gcmVzdWx0W2ogLSA0XTsKICAgICAgICB0MSA9IHNbdDFdOwogICAgICAgIHQyID0gc1t0Ml07CiAgICAgICAgdDMgPSBzW3QzXTsKICAgICAgICB0NCA9IHNbdDRdOwogICAgICAgIHQxIF49IHI7CiAgICAgICAgaWYgKChyIDw8PSAxKSA+PSAyNTYpIHsKICAgICAgICAgIHIgPSAociBeIDB4MWIpICYgMHhmZjsKICAgICAgICB9CiAgICAgIH0KICAgICAgZm9yIChsZXQgbiA9IDA7IG4gPCA0OyArK24pIHsKICAgICAgICByZXN1bHRbal0gPSB0MSBePSByZXN1bHRbaiAtIDMyXTsKICAgICAgICBqKys7CiAgICAgICAgcmVzdWx0W2pdID0gdDIgXj0gcmVzdWx0W2ogLSAzMl07CiAgICAgICAgaisrOwogICAgICAgIHJlc3VsdFtqXSA9IHQzIF49IHJlc3VsdFtqIC0gMzJdOwogICAgICAgIGorKzsKICAgICAgICByZXN1bHRbal0gPSB0NCBePSByZXN1bHRbaiAtIDMyXTsKICAgICAgICBqKys7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiByZXN1bHQ7CiAgfQp9CmV4cG9ydHMuQUVTMjU2Q2lwaGVyID0gQUVTMjU2Q2lwaGVyOwpjbGFzcyBQREYxNyB7CiAgY2hlY2tPd25lclBhc3N3b3JkKHBhc3N3b3JkLCBvd25lclZhbGlkYXRpb25TYWx0LCB1c2VyQnl0ZXMsIG93bmVyUGFzc3dvcmQpIHsKICAgIGNvbnN0IGhhc2hEYXRhID0gbmV3IFVpbnQ4QXJyYXkocGFzc3dvcmQubGVuZ3RoICsgNTYpOwogICAgaGFzaERhdGEuc2V0KHBhc3N3b3JkLCAwKTsKICAg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XIoZGF0YSkuc2VyaWFsaXphYmxlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfSBjYXRjaCAoZXgpIHsKICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuTWlzc2luZ0RhdGFFeGNlcHRpb24pIHsKICAgICAgICB0aHJvdyBleDsKICAgICAgfQogICAgICAoMCwgX3V0aWwuaW5mbykoYFNraXBwaW5nIGludmFsaWQgTWV0YWRhdGE6ICIke2V4fSIuYCk7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIm1ldGFkYXRhIiwgbWV0YWRhdGEpOwogIH0KICBnZXQgbWFya0luZm8oKSB7CiAgICBsZXQgbWFya0luZm8gPSBudWxsOwogICAgdHJ5IHsKICAgICAgbWFya0luZm8gPSB0aGlzLl9yZWFkTWFya0luZm8oKTsKICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgIGlmIChleCBpbnN0YW5jZW9mIF9jb3JlX3V0aWxzLk1pc3NpbmdEYXRhRXhjZXB0aW9uKSB7CiAgICAgICAgdGhyb3cgZXg7CiAgICAgIH0KICAgICAgKDAsIF91dGlsLndhcm4pKCJVbmFibGUgdG8gcmVhZCBtYXJrIGluZm8uIik7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIm1hcmtJbmZvIiwgbWFya0luZm8pOwogIH0KICBfcmVhZE1hcmtJbmZvKCkgewogICAgY29uc3Qgb2JqID0gdGhpcy5fY2F0RGljdC5nZXQoIk1hcmtJbmZvIik7CiAgICBpZiAoIShvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIGNvbnN0IG1hcmtJbmZvID0gewogICAgICBNYXJrZWQ6IGZhbHNlLAogICAgICBVc2VyUHJvcGVydGllczogZmFsc2UsCiAgICAgIFN1c3BlY3RzOiBmYWxzZQogICAgfTsKICAg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1ZSA9IFt7CiAgICAgIG9iaiwKICAgICAgcGFyZW50OiByb290CiAgICB9XTsKICAgIGNvbnN0IHByb2Nlc3NlZCA9IG5ldyBfcHJpbWl0aXZlcy5SZWZTZXQoKTsKICAgIHByb2Nlc3NlZC5wdXQob2JqKTsKICAgIGNvbnN0IHhyZWYgPSB0aGlzLnhyZWYsCiAgICAgIGJsYWNrQ29sb3IgPSBuZXcgVWludDhDbGFtcGVkQXJyYXkoMyk7CiAgICB3aGlsZSAocXVldWUubGVuZ3RoID4gMCkgewogICAgICBjb25zdCBpID0gcXVldWUuc2hpZnQoKTsKICAgICAgY29uc3Qgb3V0bGluZURpY3QgPSB4cmVmLmZldGNoSWZSZWYoaS5vYmopOwogICAgICBpZiAob3V0bGluZURpY3QgPT09IG51bGwpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoIW91dGxpbmVEaWN0LmhhcygiVGl0bGUiKSkgewogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBvdXRsaW5lIGl0ZW0gZW5jb3VudGVyZWQuIik7CiAgICAgIH0KICAgICAgY29uc3QgZGF0YSA9IHsKICAgICAgICB1cmw6IG51bGwsCiAgICAgICAgZGVzdDogbnVsbCwKICAgICAgICBhY3Rpb246IG51bGwKICAgICAgfTsKICAgICAgQ2F0YWxvZy5wYXJzZURlc3REaWN0aW9uYXJ5KHsKICAgICAgICBkZXN0RGljdDogb3V0bGluZURpY3QsCiAgICAgICAgcmVzdWx0T2JqOiBkYXRhLAogICAgICAgIGRvY0Jhc2VVcmw6IHRoaXMucGRmTWFuYWdlci5kb2NCYXNlVXJsLAogICAgICAgIGRvY0F0dGFjaG1lbnRzOiB0aGlzLmF0dGFjaG1lbnRzCiAgICAgIH0pOwogICAgICBjb25zdCB0aXRsZSA9IG91dGxpbmVEaWN0LmdldCgiVGl0bGUiKTsKICAgICAgY29uc3QgZmxhZ3MgPSBvdXRsaW5lRGljdC5nZXQoIkYiKSB8fCAwOwogICAgICBjb25zdCBjb2xvciA9IG91dGxpbmVEaWN0LmdldEFycmF5KCJDIik7CiAgICAgIGNvbnN0IGNvdW50ID0gb3V0bGluZURpY3QuZ2V0KCJDb3VudCIpOwogICAgICBsZXQgcmdiQ29sb3IgPSBibGFja0NvbG9yOwogICAgICBpZiAoQXJyYXkuaXNBcnJheShjb2xvcikgJiYgY29sb3IubGVuZ3RoID09PSAzICYmIChjb2xvclswXSAhPT0gMCB8fCBjb2xvclsxXSAhPT0gMCB8fCBjb2xvclsyXSAhPT0gMCkpIHsKICAgICAgICByZ2JDb2xvciA9IF9jb2xvcnNwYWNlLkNvbG9yU3BhY2Uuc2luZ2xldG9ucy5yZ2IuZ2V0UmdiKGNvbG9yLCAwKTsKICAgICAgfQogICAgICBjb25zdCBvdXRsaW5lSXRlbSA9IHsKICAgICAgICBhY3Rpb246IGRhdGEuYWN0aW9uLAogICAgICAgIGF0dGFjaG1lbnQ6IGRhdGEuYXR0YWNobWVudCwKICAgICAgICBkZXN0OiBkYXRhLmRlc3QsCiAgICAgICAgdXJsOiBkYXRhLnVybCwKICAgICAgICB1bnNhZmVVcmw6IGRhdGEudW5zYWZlVXJsLAogICAgICAgIG5ld1dpbmRvdzogZGF0YS5uZXdXaW5kb3csCiAgICAgICAgc2V0T0NHU3RhdGU6IGRhdGEuc2V0T0NHU3RhdGUsCiAgICAgICAgdGl0bGU6ICgwLCBfdXRpbC5zdHJpbmdUb1BERlN0cmluZykodGl0bGUpLAogICAgICAgIGNvbG9yOiByZ2JDb2xvciwKICAgICAgICBjb3VudDogTnVtYmVyLmlzSW50ZWdlcihjb3VudCkgPyBjb3VudCA6IHVuZGVmaW5lZCwKICAgICAgICBib2xkOiAhIShmbGFncyAmIDIpLAogICAgICAgIGl0YWxpYzogISEoZmxhZ3MgJiAxKSwKICAgICAgICBpdGVtczogW10KICAgICAgfTsKICAgICAgaS5wYXJlbnQuaXRlbXMucHVzaChvdXRsaW5lSXRlbSk7CiAgICAgIG9iaiA9IG91dGxpbmVEaWN0LmdldFJhdygiRmlyc3QiKTsKICAgICAgaWYgKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZiAmJiAhcHJvY2Vzc2VkLmhhcyhvYmopKSB7CiAgICAgICAgcXVldWUucHVzaCh7CiAgICAgICAgICBvYmosCiAgICAgICAgICBwYXJlbnQ6IG91dGxpbmVJdGVtCiAgICAgICAgfSk7CiAgICAgICAgcHJvY2Vzc2VkLnB1dChvYmopOwogICAgICB9CiAgICAgIG9iaiA9IG91dGxpbmVEaWN0LmdldFJhdygiTmV4dCIpOwogICAgICBpZiAob2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmICYmICFwcm9jZXNzZWQuaGFzKG9iaikpIHsKICAgICAgICBxdWV1ZS5wdXNoKHsKICAgICAgICAgIG9iaiwKICAgICAgICAgIHBhcmVudDogaS5wYXJlbnQKICAgICAgICB9KTsKICAgICAgICBwcm9jZXNzZWQucHV0KG9iaik7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiByb290Lml0ZW1zLmxlbmd0aCA+IDAgPyByb290Lml0ZW1zIDogbnVsbDsKICB9CiAgZ2V0IHBlcm1pc3Npb25zKCkgewogICAgbGV0IHBlcm1pc3Npb25zID0gbnVsbDsKICAgIHRyeSB7CiAgICAgIHBlcm1pc3Npb25zID0gdGhpcy5fcmVhZFBlcm1pc3Npb25zKCk7CiAgICB9IGNhdGNoIChleCkgewogICAgICBpZiAoZXggaW5zdGFuY2VvZiBfY29yZV91dGlscy5NaXNzaW5nRGF0YUV4Y2VwdGlvbikgewogICAgICAgIHRocm93IGV4OwogICAgICB9CiAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5hYmxlIHRvIHJlYWQgcGVybWlzc2lvbnMuIik7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInBlcm1pc3Npb25zIiwgcGVybWlzc2lvbnMpOwogIH0KICBfcmVhZFBlcm1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Db25maWciLCBudWxsKTsKICAgICAgfQogICAgICBjb25zdCBncm91cHNEYXRhID0gcHJvcGVydGllcy5nZXQoIk9DR3MiKTsKICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGdyb3Vwc0RhdGEpKSB7CiAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBudWxsKTsKICAgICAgfQogICAgICBjb25zdCBncm91cHMgPSBbXTsKICAgICAgY29uc3QgZ3JvdXBSZWZzID0gW107CiAgICAgIGZvciAoY29uc3QgZ3JvdXBSZWYgb2YgZ3JvdXBzRGF0YSkgewogICAgICAgIGlmICghKGdyb3VwUmVmIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGdyb3VwUmVmcy5wdXNoKGdyb3VwUmVmKTsKICAgICAgICBjb25zdCBncm91cCA9IHRoaXMueHJlZi5mZXRjaElmUmVmKGdyb3VwUmVmKTsKICAgICAgICBncm91cHMucHVzaCh7CiAgICAgICAgICBpZDogZ3JvdXBSZWYudG9TdHJpbmcoKSwKICAgICAgICAgIG5hbWU6IHR5cGVvZiBncm91cC5nZXQoIk5hbWUiKSA9PT0gInN0cmluZyIgPyAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKGdyb3VwLmdldCgiTmFtZSIpKSA6IG51bGwsCiAgICAgICAgICBpbnRlbnQ6IHR5cGVvZiBncm91cC5nZXQoIkludGVudCIpID09PSAic3RyaW5nIiA/ICgwLCBfdXRpbC5zdHJpbmdUb1BERlN0cmluZykoZ3JvdXAuZ2V0KCJJbnRlbnQiKSkgOiBudWxsCiAgICAgICAgfSk7CiAgICAgIH0KICAgICAgY29uZmlnID0gdGhpcy5fcmVhZE9wdGlvbmFsQ29udGVudENvbmZpZyhkZWZhdWx0Q29uZmlnLCBncm91cFJlZnMpOwogICAgICBjb25maWcuZ3JvdXBzID0gZ3JvdXBzOwogICAgfSBjYXRjaCAoZXgpIHsKICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuTWlzc2luZ0RhdGFFeGNlcHRpb24pIHsKICAgICAgICB0aHJvdyBleDsKICAgICAgfQogICAgICAoMCwgX3V0aWwud2FybikoYFVuYWJsZSB0byByZWFkIG9wdGlvbmFsIGNvbnRlbnQgY29uZmlnOiAke2V4fWApOwogICAgfQogICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBjb25maWcpOwogIH0KICBfcmVhZE9wdGlvbmFsQ29udGVudENvbmZpZyhjb25maWcsIGNvbnRlbnRHcm91cFJlZnMpIHsKICAgIGZ1bmN0aW9uIHBhcnNlT25PZmYocmVmcykgewogICAgICBjb25zdCBvblBhcnNlZCA9IFtdOwogICAgICBpZiAoQXJyYXkuaXNBcnJheShyZWZzKSkgewogICAgICAgIGZvciAoY29uc3QgdmFsdWUgb2YgcmVmcykgewogICAgICAgICAgaWYgKCEodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGNvbnRlbnRHcm91cFJlZnMuaW5jbHVkZXModmFsdWUpKSB7CiAgICAgICAgICAgIG9uUGFyc2VkLnB1c2godmFsdWUudG9TdHJpbmcoKSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiBvblBhcnNlZDsKICAgIH0KICAgIGZ1bmN0aW9uIHBhcnNlT3JkZXIocmVmcykgewogICAgICBsZXQgbmVzdGVkTGV2ZWxzID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiAwOwogICAgICBpZiAoIUFycmF5LmlzQXJyYXkocmVmcykpIHsKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgICBjb25zdCBvcmRlciA9IFtdOwogICAgICBmb3IgKGNvbnN0IHZhbHVlIG9mIHJlZnMpIHsKICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYgJiYgY29udGVudEdyb3VwUmVmcy5pbmNsdWRlcyh2YWx1ZSkpIHsKICAgICAgICAgIHBhcnNlZE9yZGVyUmVmcy5wdXQodmFsdWUpOwogICAgICAgICAgb3JkZXIucHVzaCh2YWx1ZS50b1N0cmluZygpKTsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBjb25zdCBuZXN0ZWRPcmRlciA9IHBhcnNlTmVzdGVkT3JkZXIodmFsdWUsIG5lc3RlZExldmVscyk7CiAgICAgICAgaWYgKG5lc3RlZE9yZGVyKSB7CiAgICAgICAgICBvcmRlci5wdXNoKG5lc3RlZE9yZGVyKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKG5lc3RlZExldmVscyA+IDApIHsKICAgICAgICByZXR1cm4gb3JkZXI7CiAgICAgIH0KICAgICAgY29uc3QgaGlkZGVuR3JvdXBzID0gW107CiAgICAgIGZvciAoY29uc3QgZ3JvdXBSZWYgb2YgY29udGVudEdyb3VwUmVmcykgewogICAgICAgIGlmIChwYXJzZWRPcmRlclJlZnMuaGFzKGdyb3VwUmVmKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGhpZGRlbkdyb3Vwcy5wdXNoKGdyb3VwUmVmLnRvU3RyaW5nKCkpOwogICAgICB9CiAgICAgIGlmIChoaWRkZW5Hcm91cHMubGVuZ3RoKSB7CiAgICAgICAgb3JkZXIucHVzaCh7CiAgICAgICAgICBuYW1lOiBudWxsLAogICAgICAgICAgb3JkZXI6IGhpZGRlbkdyb3VwcwogICAgICAgIH0pOwogICAgICB9CiAgICAgIHJldHVybiBvcmRlcjsKICAgIH0KICAgIGZ1bmN0aW9uI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PSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHApOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBwcmVmaXggPSAiIjsKICAgICAgICB9CiAgICAgICAgaWYgKGxhYmVsRGljdC5oYXMoIlN0IikpIHsKICAgICAgICAgIGNvbnN0IHN0ID0gbGFiZWxEaWN0LmdldCgiU3QiKTsKICAgICAgICAgIGlmICghKE51bWJlci5pc0ludGVnZXIoc3QpICYmIHN0ID49IDEpKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBzdGFydCBpbiBQYWdlTGFiZWwgZGljdGlvbmFyeS4iKTsKICAgICAgICAgIH0KICAgICAgICAgIGN1cnJlbnRJbmRleCA9IHN0OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjdXJyZW50SW5kZXggPSAxOwogICAgICAgIH0KICAgICAgfQogICAgICBzd2l0Y2ggKHN0eWxlKSB7CiAgICAgICAgY2FzZSAiRCI6CiAgICAgICAgICBjdXJyZW50TGFiZWwgPSBjdXJyZW50SW5kZXg7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJSIjoKICAgICAgICBjYXNlICJyIjoKICAgICAgICAgIGN1cnJlbnRMYWJlbCA9ICgwLCBfY29yZV91dGlscy50b1JvbWFuTnVtZXJhbHMpKGN1cnJlbnRJbmRleCwgc3R5bGUgPT09ICJyIik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJBIjoKICAgICAgICBjYXNlICJhIjoKICAgICAgICAgIGNvbnN0IExJTUlUID0gMjY7CiAgICAgICAgICBjb25zdCBBX1VQUEVSX0NBU0UgPSAweDQxLAogICAgICAgICAgICBBX0xPV0VSX0NBU0UgPSAweDYxOwogICAgICAgICAgY29uc3QgYmFzZUNoYXJDb2RlID0gc3R5bGUgPT09ICJhIiA/IEFfTE9XRVJfQ0FTRSA6IEFfVVBQRVJfQ0FTRTsKICAgICAgICAgIGNvbnN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V0KGtleSk7CiAgICAgIGxldCBwcmVmVmFsdWU7CiAgICAgIHN3aXRjaCAoa2V5KSB7CiAgICAgICAgY2FzZSAiSGlkZVRvb2xiYXIiOgogICAgICAgIGNhc2UgIkhpZGVNZW51YmFyIjoKICAgICAgICBjYXNlICJIaWRlV2luZG93VUkiOgogICAgICAgIGNhc2UgIkZpdFdpbmRvdyI6CiAgICAgICAgY2FzZSAiQ2VudGVyV2luZG93IjoKICAgICAgICBjYXNlICJEaXNwbGF5RG9jVGl0bGUiOgogICAgICAgIGNhc2UgIlBpY2tUcmF5QnlQREZTaXplIjoKICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJib29sZWFuIikgewogICAgICAgICAgICBwcmVmVmFsdWUgPSB2YWx1ZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIk5vbkZ1bGxTY3JlZW5QYWdlTW9kZSI6CiAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgICAgICAgICAgIGNhc2UgIlVzZU5vbmUiOgogICAgICAgICAgICAgIGNhc2UgIlVzZU91dGxpbmVzIjoKICAgICAgICAgICAgICBjYXNlICJVc2VUaHVtYnMiOgogICAgICAgICAgICAgIGNhc2UgIlVzZU9DIjoKICAgICAgICAgICAgICAgIHByZWZWYWx1ZSA9IHZhbHVlLm5hbWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgcHJlZlZhbHVlID0gIlVzZU5vbmUiOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJEaXJlY3Rpb24iOgogICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkgewogICAgICAgICAgICBzd2l0Y2ggKHZhbHVlLm5hbWUpIHsKICAgICAgICAgICAgICBjYXNlICJMMlIiOgogICAgICAgICAgICAgIGNhc2UgIlIyTCI6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSB2YWx1ZS5uYW1lOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHByZWZWYWx1ZSA9ICJMMlIiOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJWaWV3QXJlYSI6CiAgICAgICAgY2FzZSAiVmlld0NsaXAiOgogICAgICAgIGNhc2UgIlByaW50QXJlYSI6CiAgICAgICAgY2FzZSAiUHJpbnRDbGlwIjoKICAgICAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgc3dpdGNoICh2YWx1ZS5uYW1lKSB7CiAgICAgICAgICAgICAgY2FzZSAiTWVkaWFCb3giOgogICAgICAgICAgICAgIGNhc2UgIkNyb3BCb3giOgogICAgICAgICAgICAgIGNhc2UgIkJsZWVkQm94IjoKICAgICAgICAgICAgICBjYXNlICJUcmltQm94IjoKICAgICAgICAgICAgICBjYXNlICJBcnRCb3giOgogICAgICAgICAgICAgICAgcHJlZlZhbHVlID0gdmFsdWUubmFtZTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSAiQ3JvcEJveCI7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIlByaW50U2NhbGluZyI6CiAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgICAgICAgICAgIGNhc2UgIk5vbmUiOgogICAgICAgICAgICAgIGNhc2UgIkFwcERlZmF1bHQiOgogICAgICAgICAgICAgICAgcHJlZlZhbHVlID0gdmFsdWUubmFtZTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSAiQXBwRGVmYXVsdCI7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkR1cGxleCI6CiAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgICAgICAgICAgIGNhc2UgIlNpbXBsZXgiOgogICAgICAgICAgICAgIGNhc2UgIkR1cGxleEZsaXBTaG9ydEVkZ2UiOgogICAgICAgICAgICAgIGNhc2UgIkR1cGxleEZsaXBMb25nRWRnZSI6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSB2YWx1ZS5uYW1lOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHByZWZWYWx1ZSA9ICJOb25lIjsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiUHJpbnRQYWdlUmFuZ2UiOgogICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkodmFsdWUpICYmIHZhbHVlLmxlbmd0aCAlIDIgPT09IDApIHsKICAgICAgICAgICAgY29uc3QgaXNWYWxpZCA9IHZhbHVlLmV2ZXJ5KChwYWdlLCBpLCBhcnIpID0+IHsKICAgICAgICAgICAgICByZXR1cm4gTnVtYmVyLmlzSW50ZWdlcihwYWdlKSAmJiBwYWdlID4gMCAmJiAoaSA9PT0gMCB8fCBwYWdlID49IGFycltpIC0gMV0pICYmIHBhZ2UgPD0gdGhpcy5udW1QYWdlczsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGlmIChpc1ZhbGlkKSB7CiAgICAgICAgICAgICAgcHJlZlZhbHVlID0gdmFsdWU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIk51bUNvcGllcyI6CiAgICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcih2YWx1ZSkgJiYgdmFsdWUgPiAwKSB7CiAgICAgICAgICAgIHByZWZWYWx1ZSA9IHZhbHVlOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgSWdub3Jpbmcgbm9uLXN0YW5kYXJkIGtleSBpbiBWaWV3ZXJQcmVmZXJlbmNlczogJHtrZXl9LmApOwogICAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKHByZWZWYWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKGBCYWQgdmFsdWUsIGZvciBrZXkgIiR7a2V5fSIsIGluIFZpZXdlclByZWZlcmVuY2VzOiAke3ZhbHVlfS5gKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoIXByZWZzKSB7CiAgICAgICAgcHJlZnMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICB9CiAgICAgIHByZWZzW2tleV0gPSBwcmVmVmFsdWU7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInZpZXdlclByZWZlcmVuY2VzIiwgcHJlZnMpOwogIH0KICBnZXQgb3BlbkFjdGlvbigpIHsKICAgIGNvbnN0IG9iaiA9IHRoaXMuX2NhdERpY3QuZ2V0KCJPcGVuQWN0aW9uIik7CiAgICBjb25zdCBvcGVuQWN0aW9uID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0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KTsKICAgICAgaWYgKGN1cnJlbnROb2RlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmKSB7CiAgICAgICAgY29uc3QgY291bnQgPSBwYWdlS2lkc0NvdW50Q2FjaGUuZ2V0KGN1cnJlbnROb2RlKTsKICAgICAgICBpZiAoY291bnQgPj0gMCAmJiBjdXJyZW50UGFnZUluZGV4ICsgY291bnQgPD0gcGFnZUluZGV4KSB7CiAgICAgICAgICBjdXJyZW50UGFnZUluZGV4ICs9IGNvdW50OwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGlmICh2aXNpdGVkTm9kZXMuaGFzKGN1cnJlbnROb2RlKSkgewogICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJQYWdlcyB0cmVlIGNvbnRhaW5zIGNpcmN1bGFyIHJlZmVyZW5jZS4iKTsKICAgICAgICB9CiAgICAgICAgdmlzaXRlZE5vZGVzLnB1dChjdXJyZW50Tm9kZSk7CiAgICAgICAgY29uc3Qgb2JqID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKGN1cnJlbnROb2RlKTsKICAgICAgICBpZiAob2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgbGV0IHR5cGUgPSBvYmouZ2V0UmF3KCJUeXBlIik7CiAgICAgICAgICBpZiAodHlwZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICB0eXBlID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKHR5cGUpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKCgwLCBfcHJpbWl0aXZlcy5pc05hbWUpKHR5cGUsICJQYWdlIikgfHwgIW9iai5oYXMoIktpZHMiKSkgewogICAgICAgICAgICBpZiAoIXBhZ2VLaWRzQ291bnRDYWNoZS5oYXMoY3VycmVudE5vZGUpKSB7CiAgICAgICAgICAgICAgcGFnZUtpZHNDb3VudENhY2hlLnB1dChjdXJyZW50Tm9kZSwgMSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKCFwYWdlSW5kZXhDYWNoZS5oYXMoY3VycmVudE5vZGUpKSB7CiAgICAgICAgICAgICAgcGFnZUluZGV4Q2FjaGUucHV0KGN1cnJlbnROb2RlLCBjdXJyZW50UGFnZUluZGV4KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoY3VycmVudFBhZ2VJbmRleCA9PT0gcGFnZUluZGV4KSB7CiAgICAgICAgICAgICAgcmV0dXJuIFtvYmosIGN1cnJlbnROb2RlXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjdXJyZW50UGFnZUluZGV4Kys7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBub2Rlc1RvVmlzaXQucHVzaChvYmopOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmICghKGN1cnJlbnROb2RlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlBhZ2UgZGljdGlvbmFyeSBraWQgcmVmZXJlbmNlIHBvaW50cyB0byB3cm9uZyB0eXBlIG9mIG9iamVjdC4iKTsKICAgICAgfQogICAgICBjb25zdCB7CiAgICAgICAgb2JqSWQKICAgICAgfSA9IGN1cnJlbnROb2RlOwogICAgICBsZXQgY291bnQgPSBjdXJyZW50Tm9kZS5nZXRSYXcoIkNvdW50Iik7CiAgICAgIGlmIChjb3VudCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIGNvdW50ID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKGNvdW50KTsKICAgICAgfQogICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihjb3VudCkgJiYgY291bnQgPj0gMCkgewogICAgICAgIGlmIChvYmpJZCAmJiAhcGFnZUtpZHNDb3VudENhY2hlLmhhcyhvYmpJ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tpZHMpOwogICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICBhZGRQYWdlRXJyb3IoZXgpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmICghQXJyYXkuaXNBcnJheShraWRzKSkgewogICAgICAgIGFkZFBhZ2VFcnJvcihuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlBhZ2UgZGljdGlvbmFyeSBraWRzIG9iamVjdCBpcyBub3QgYW4gYXJyYXkuIikpOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGlmIChwb3NJbktpZHMgPj0ga2lkcy5sZW5ndGgpIHsKICAgICAgICBxdWV1ZS5wb3AoKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBraWRPYmogPSBraWRzW3Bvc0luS2lkc107CiAgICAgIGxldCBvYmo7CiAgICAgIGlmIChraWRPYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICBpZiAodmlzaXRlZE5vZGVzLmhhcyhraWRPYmopKSB7CiAgICAgICAgICBhZGRQYWdlRXJyb3IobmV3IF91dGlsLkZvcm1hdEVycm9yKCJQYWdlcyB0cmVlIGNvbnRhaW5zIGNpcmN1bGFyIHJlZmVyZW5jZS4iKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgdmlzaXRlZE5vZGVzLnB1dChraWRPYmopOwogICAgICAgIHRyeSB7CiAgICAgICAgICBvYmogPSBhd2FpdCB4cmVmLmZldGNoQXN5bmMoa2lkT2JqKTsKICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgYWRkUGFnZUVycm9yKGV4KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICBvYmogPSBraWRPYmo7CiAgICAgIH0KICAgICAgaWYgKCEob2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICBhZGRQYWdlRXJyb3IobmV3IF91dGlsLkZvcm1hdEVycm9yKCJQYWdlIGRpY3Rpb25hcnkga2lkIHJlZmVyZW5jZSBwb2ludHMgdG8gd3JvbmcgdHlwZSBvZiBvYmplY3QuIikpOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGxldCB0eXBlID0gb2JqLmdldFJhdygiVHlwZSIpOwogICAgICBpZiAodHlwZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIHRyeSB7CiAgICAgICAgICB0eXBlID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKHR5cGUpOwogICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICBhZGRQYWdlRXJyb3IoZXgpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKSh0eXBlLCAiUGFnZSIpIHx8ICFvYmouaGFzKCJLaWRzIikpIHsKICAgICAgICBhZGRQYWdlRGljdChvYmosIGtpZE9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZiA/IGtpZE9iaiA6IG51bGwpOwogICAgICB9IGVsc2UgewogICAgICAgIHF1ZXVlLnB1c2goewogICAgICAgICAgY3VycmVudE5vZGU6IG9iaiwKICAgICAgICAgIHBvc0luS2lkczogMAogICAgICAgIH0pOwogICAgICB9CiAgICAgIHF1ZXVlSXRlbS5wb3NJbktpZHMrKzsKICAgIH0KICAgIHJldHVybiBtYXA7CiAgfQogIGdldFBhZ2VJbmRleChwYWdlUmVmKSB7CiAgICBjb25zdCBjYWNoZWRQYWdlSW5kZXggPSB0aGlzLnBhZ2VJbmRleENhY2hlLmdldChwYWdlUmVmKTsKICAgIGlmIChjYWNoZWRQYWdlSW5kZXggIT09IHVuZGVmaW5lZCkgewogICAgICByZXR1cm4gUHJvbWlzZS5yZXNvbHZlKGNhY2hlZFBhZ2VJbmRleCk7CiAgICB9CiAgICBjb25zdCB4cmVmID0gdGhpcy54cmVmOwogICAgZnVuY3Rpb24gcGFnZXNCZWZvcmVSZWYoa2lkUmVmKSB7CiAgICAgIGxldCB0b3RhbCA9IDAsCiAgICAgICAgcGFyZW50UmVmOwogICAgICByZXR1cm4geHJlZi5mZXRjaEFzeW5jKGtpZFJlZikudGhlbihmdW5jdGlvbiAobm9kZSkgewogICAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNSZWZzRXF1YWwpKGtpZFJlZiwgcGFnZVJlZikgJiYgISgwLCBfcHJpbWl0aXZlcy5pc0RpY3QpKG5vZGUsICJQYWdlIikgJiYgIShub2RlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCAmJiAhbm9kZS5oYXMoIlR5cGUiKSAmJiBub2RlLmhhcygiQ29udGVudHMiKSkpIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiVGhlIHJlZmVyZW5jZSBkb2VzIG5vdCBwb2ludCB0byBhIC9QYWdlIGRpY3Rpb25hcnkuIik7CiAgICAgICAgfQogICAgICAgIGlmICghbm9kZSkgewogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICAgIGlmICghKG5vZGUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJOb2RlIG11c3QgYmUgYSBkaWN0aW9uYXJ5LiIpOwogICAgICAgIH0KICAgICAgICBwYXJlbnRSZWYgPSBub2RlLmdldFJhdygiUGFyZW50Iik7CiAgICAgICAgcmV0dXJuIG5vZGUuZ2V0QXN5bmMoIlBhcmVudCIpOwogICAgICB9KS50aGVuKGZ1bmN0aW9uIChwYXJlbnQpIHsKICAgICAgICBpZiAoIXBhcmVudCkgewogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICAgIGlmICghKHBhcmVudCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlBhcmVudCBtdXN0IGJlIGEgZGljdGlvbmFyeS4iKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHBhcmVudC5nZXRBc3luYygiS2lkcyIpOwogICAgICB9KS50aGVuKGZ1bmN0aW9uIChraWRzKSB7CiAgICAgICAgaWYgKCFraWRzKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9CiAgICAgICAgY29uc3Qga2lkUHJvbWlzZXMgPSBbXTsKICAgICAgICBsZXQgZm91bmQgPSBmYWxzZTsKICAgICAgICBmb3IgKGNvbnN0IGtpZCBvZiBraWRzKSB7CiAgICAgICAgICBpZiAoIShraWQgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiS2lkIG11c3QgYmUgYSByZWZlcmVuY2UuIik7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoKDAsIF9wcmltaXRpdmVzLmlzUmVmc0VxdWFsKShraWQsIGtpZFJlZikpIHsKICAgICAgICAgICAgZm91bmQgPSB0cnVlOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGtpZFByb21pc2VzLnB1c2goeHJlZi5mZXRjaEFzeW5jKGtpZCkudGhlbihmdW5jdGlvbiAob2JqKSB7CiAgICAgICAgICAgIGlmICghKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJLaWQgbm9kZSBtdXN0IGJlIGEgZGljdGlvbmFyeS4iKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAob2JqLmhhcygiQ291bnQiKSkgewogICAgICAgICAgICAgIHRvdGFsICs9IG9iai5nZXQoIkNvdW50Iik7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdG90YWwrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfSkpOwogICAgICAgIH0KICAgICAgICBpZiAoIWZvdW5kKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIktpZCByZWZlcmVuY2Ugbm90IGZvdW5kIGluIHBhcmVudCdzIGtpZHMuIik7CiAgICAgICAgfQogICAgICAgIHJldHVybiBQcm9taXNlLmFsbChraWRQcm9taXNlcykudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICByZXR1cm4gW3RvdGFsLCBwYXJlbnRSZWZdOwogICAgICAgIH0pOwogICAgICB9KTsKICAgIH0KICAgIGxldCB0b3RhbCA9IDA7CiAgICBjb25zdCBuZXh0ID0gcmVmID0+IHBhZ2VzQmVmb3JlUmVmKHJlZikudGhlbihhcmdzID0+IHsKICAgICAgaWYgKCFhcmdzKSB7CiAgICAgICAgdGhpcy5wYWdlSW5kZXhDYWNoZS5wdXQocGFnZVJlZiwgdG90YWwpOwogICAgICAgIHJldHVybiB0b3RhbDsKICAgICAgfQogICAgICBjb25zdCBbY291bnQsIHBhcmVudFJlZl0gPSBhcmdzOwogICAgICB0b3RhbCArPSBjb3VudDsKICAgICAgcmV0dXJuIG5leHQocGFyZW50UmVmKTsKICAgIH0pOwogICAgcmV0dXJuIG5leHQocGFnZVJlZik7CiAgfQogIGdldCBiYXNlVXJsKCkgewogICAgY29uc3QgdXJpID0gdGhpcy5fY2F0RGljdC5nZXQoIlVSSSIpOwogICAgaWYgKHVyaSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgY29uc3QgYmFzZSA9IHVyaS5nZXQoIkJhc2UiKTsKICAgICAgaWYgKHR5cGVvZiBiYXNlID09PSAic3RyaW5nIikgewogICAgICAgIGNvbnN0IGFic29sdXRlVXJsID0gKDAsIF91dGlsLmNyZWF0ZVZhbGlkQWJzb2x1dGVVcmwpKG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MCkgJiAxKSA9PT0gMDsKICAgICAgICAgIGNvbnN0IGZpZWxkcyA9IFtdOwogICAgICAgICAgY29uc3QgcmVmcyA9IFtdOwogICAgICAgICAgZm9yIChjb25zdCBvYmogb2YgYWN0aW9uLmdldCgiRmllbGRzIikgfHwgW10pIHsKICAgICAgICAgICAgaWYgKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICAgIHJlZnMucHVzaChvYmoudG9TdHJpbmcoKSk7CiAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIG9iaiA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICBmaWVsZHMucHVzaCgoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKG9iaikpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICByZXN1bHRPYmoucmVzZXRGb3JtID0gewogICAgICAgICAgICBmaWVsZHMsCiAgICAgICAgICAgIHJlZnMsCiAgICAgICAgICAgIGluY2x1ZGUKICAgICAgICAgIH07CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJVUkkiOgogICAgICAgICAgdXJsID0gYWN0aW9uLmdldCgiVVJJIik7CiAgICAgICAgICBpZiAodXJsIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkgewogICAgICAgICAgICB1cmwgPSAiLyIgKyB1cmwubmFtZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkdvVG8iOgogICAgICAgICAgZGVzdCA9IGFjdGlvbi5nZXQoIkQiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkxhdW5jaCI6CiAgICAgICAgY2FzZSAiR29Ub1IiOgogICAgICAgICAgY29uc3QgdXJsRGljdCA9IGFjdGlvbi5nZXQoIkYiKTsKICAgICAgICAgIGlmICh1cmxEaWN0IGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICB1cmwgPSB1cmxEaWN0LmdldCgiRiIpIHx8IG51bGw7CiAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiB1cmxEaWN0ID09PSAic3RyaW5nIikgewogICAgICAgICAgICB1cmwgPSB1cmxEaWN0OwogICAgICAgICAgfQogICAgICAgICAgbGV0IHJlbW90ZURlc3QgPSBhY3Rpb24uZ2V0KCJEIik7CiAgICAgICAgICBpZiAocmVtb3RlRGVzdCkgewogICAgICAgICAgICBpZiAocmVtb3RlRGVzdCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgICByZW1vdGVEZXN0ID0gcmVtb3RlRGVzdC5uYW1lOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICh0eXBlb2YgdXJsID09PSAic3RyaW5nIikgewogICAgICAgICAgICAgIGNvbnN0IGJhc2VVcmwgPSB1cmwuc3BsaXQoIiMiKVswXTsKICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlbW90ZURlc3QgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICB1cmwgPSBiYXNlVXJsICsgIiMiICsgcmVtb3RlRGVzdDsKICAgICAgICAgICAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkocmVtb3RlRGVzdCkpIHsKICAgICAgICAgICAgICAgIHVybCA9IGJhc2VVcmwgKyAiIyIgKyBKU09OLnN0cmluZ2lmeShyZW1vdGVEZXN0KTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IG5ld1dpbmRvdyA9IGFjdGlvbi5nZXQoIk5ld1dpbmRvdyIpOwogICAgICAgICAgaWYgKHR5cGVvZiBuZXdXaW5kb3cgPT09ICJib29sZWFuIikgewogICAgICAgICAgICByZXN1bHRPYmoubmV3V2luZG93ID0gbmV3V2luZG93OwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiR29Ub0UiOgogICAgICAgICAgY29uc3QgdGFyZ2V0ID0gYWN0aW9uLmdldCgiVCIpOwogICAgICAgICAgbGV0IGF0dGFjaG1lbnQ7CiAgICAgICAgICBpZiAoZG9jQXR0YWNobWVudHMgJiYgdGFyZ2V0IGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICBjb25zdCByZWxhdGlvbnNoaXAgPSB0YXJnZXQuZ2V0KCJSIik7CiAgICAgICAgICAgIGNvbnN0IG5hbWUgPSB0YXJnZXQuZ2V0KCJOIik7CiAgICAgICAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKShyZWxhdGlvbnNoaXAsICJDIikgJiYgdHlwZW9mIG5hbWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgYXR0YWNobWVudCA9IGRvY0F0dGFjaG1lbnRzWygwLCBfdXRpbC5zdHJpbmdUb1BERlN0cmluZykobmFtZSldOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYXR0YWNobWVudCkgewogICAgICAgICAgICByZXN1bHRPYmouYXR0YWNobWVudCA9IGF0dGFjaG1lbnQ7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhcnNlRGVzdERpY3Rpb25hcnkgLSB1bmltcGxlbWVudGVkICJHb1RvRSIgYWN0aW9uLmApOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiTmFtZWQiOgogICAgICAgICAgY29uc3QgbmFtZWRBY3Rpb24gPSBhY3Rpb24uZ2V0KCJOIik7CiAgICAgICAgICBpZiAobmFtZWRBY3Rpb24gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHJlc3VsdE9iai5hY3Rpb24gPSBuYW1lZEFjdGlvbi5uYW1lOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiU2V0T0NHU3RhdGUiOgogICAgICAgICAgY29uc3Qgc3RhdGUgPSBhY3Rpb24uZ2V0KCJTdGF0ZSIpOwogICAgICAgICAgY29uc3QgcHJlc2VydmVSQiA9IGFjdGlvbi5nZXQoIlByZXNlcnZlUkIiKTsKICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShzdGF0ZSkgfHwgc3RhdGUubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgY29uc3Qgc3RhdGVBcnIgPSBbXTsKICAgICAgICAgIGZvciAoY29uc3QgZWxlbSBvZiBzdGF0ZSkgewogICAgICAgICAgICBpZiAoZWxlbSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgICBzd2l0Y2ggKGVsZW0ubmFtZSkgewogICAgICAgICAgICAgICAgY2FzZSAiT04iOgogICAgICAgICAgICAgICAgY2FzZSAiT0ZGIjoKICAgICAgICAgICAgICAgIGNhc2UgIlRvZ2dsZSI6CiAgICAgICAgICAgICAgICAgIHN0YXRlQXJyLnB1c2goZWxlbS5uYW1lKTsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgaWYgKGVsZW0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICAgICAgICBzdGF0ZUFyci5wdXNoKGVsZW0udG9TdHJpbmcoKSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzdGF0ZUFyci5sZW5ndGggIT09IHN0YXRlLmxlbmd0aCkgewogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIHJlc3VsdE9iai5zZXRPQ0dTdGF0ZSA9IHsKICAgICAgICAgICAgc3RhdGU6IHN0YXRlQXJyLAogICAgICAgICAgICBwcmVzZXJ2ZVJCOiB0eXBlb2YgcHJlc2VydmVSQiA9PT0gImJvb2xlYW4iID8gcHJlc2VydmVSQiA6IHRydWUKICAgICAgICAgIH07CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJKYXZhU2NyaXB0IjoKICAgICAgICAgIGNvbnN0IGpzQWN0aW9uID0gYWN0aW9uLmdldCgiSlMiKTsKICAgICAgICAgIGxldCBqczsKICAgICAgICAgIGlmIChqc0FjdGlvbiBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSB7CiAgICAgICAgICAgIGpzID0ganNBY3Rpb24uZ2V0U3RyaW5nKCk7CiAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBqc0FjdGlvbiA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAganMgPSBqc0FjdGlvbjsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IGpzVVJMID0ganMgJiYgKDAsIF9jb3JlX3V0aWxzLnJlY292ZXJKc1VSTCkoKDAsIF91dGlsLnN0cmluZ1RvUERGU3RyaW5nKShqcykpOwogICAgICAgICAgaWYgKGpzVVJMKSB7CiAgICAgICAgICAgIHVybCA9IGpzVVJMLnVybDsKICAgICAgICAgICAgcmVzdWx0T2JqLm5ld1dpbmRvdyA9IGpzVVJMLm5ld1dpbmRvdzsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIGlmIChhY3Rpb25OYW1lID09PSAiSmF2YVNjcmlwdCIgfHwgYWN0aW9uTmFtZSA9PT0gIlN1Ym1pdEZvcm0iKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBwYXJzZURlc3REaWN0aW9uYXJ5IC0gdW5zdXBwb3J0ZWQgYWN0aW9uOiAiJHthY3Rpb25OYW1lfSIuYCk7CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgfSBlbHNlIGlmIChkZXN0RGljdC5oYXMoIkRlc3QiKSkgewogICAgICBkZXN0ID0gZGVzdERpY3QuZ2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cnJheShraWRzKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGZvciAoY29uc3Qga2lkIG9mIGtpZHMpIHsKICAgICAgICAgIGlmIChwcm9jZXNzZWQuaGFzKGtpZCkpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBEdXBsaWNhdGUgZW50cnkgaW4gIiR7dGhpcy5fdHlwZX0iIHRyZWUuYCk7CiAgICAgICAgICB9CiAgICAgICAgICBxdWV1ZS5wdXNoKGtpZCk7CiAgICAgICAgICBwcm9jZXNzZWQucHV0KGtpZCk7CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IGVudHJpZXMgPSBvYmouZ2V0KHRoaXMuX3R5cGUpOwogICAgICBpZiAoIUFycmF5LmlzQXJyYXkoZW50cmllcykpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBlbnRyaWVzLmxlbmd0aDsgaSA8IGlpOyBpICs9IDIpIHsKICAgICAgICBtYXAuc2V0KHhyZWYuZmV0Y2hJZlJlZihlbnRyaWVzW2ldKSwgeHJlZi5mZXRjaElmUmVmKGVudHJpZXNbaSArIDFdKSk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBtYXA7CiAgfQogIGdldChrZXkpIHsKICAgIGlmICghdGhpcy5yb290KSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgY29uc3QgeHJlZiA9IHRoaXMueHJlZjsKICAgIGxldCBraWRzT3JFbnRyaWVzID0geHJlZi5mZXRjaElmUmVmKHRoaXMucm9vdCk7CiAgICBsZXQgbG9vcENvdW50ID0gMDsKICAgIGNvbnN0IE1BWF9MRVZFTFMgPSAxMDsKICAgIHdoaWxlIChraWRzT3JFbnRyaWVzLmhhcygiS2lkcyIpKSB7CiAgICAgIGlmICgrK2xvb3BDb3VudCA+IE1BWF9MRVZFTFMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYFNlYXJjaCBkZXB0aCBsaW1pdCByZWFjaGVkIGZvciAiJHt0aGlzLl90eXBlfSIgdHJlZS5gKTsKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgICBjb25zdCBraWRzID0ga2lkc09yRW50cmllcy5nZXQoIktpZHMiKTsKICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGtpZHMpKSB7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0KICAgICAgbGV0IGwgPSAwLAogICAgICAgIHIgPSBraWRzLmxlbmd0aCAtIDE7CiAgICAgIHdoaWxlIChsIDw9IHIpIHsKICAgICAgICBjb25zdCBtID0gbCArIHIgPj4gMTsKICAgICAgICBjb25zdCBraWQgPSB4cmVmLmZldGNoSWZSZWYoa2lkc1ttXSk7CiAgICAgICAgY29uc3QgbGltaXRzID0ga2lkLmdldCgiTGltaXRzIik7CiAgICAgICAgaWYgKGtleSA8IHhyZWYuZmV0Y2hJZlJlZihsaW1pdHNbMF0pKSB7CiAgICAgICAgICByID0gbSAtIDE7CiAgICAgICAgfSBlbHNlIGlmIChrZXkgPiB4cmVmLmZldGNoSWZSZWYobGltaXRzWzFdKSkgewogICAgICAgICAgbCA9IG0gKyAxOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBraWRzT3JFbnRyaWVzID0ga2lkOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChsID4gcikgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICB9CiAgICBjb25zdCBlbnRyaWVzID0ga2lkc09yRW50cmllcy5nZXQodGhpcy5fdHlwZSk7CiAgICBpZiAoQXJyYXkuaXNBcnJheShlbnRyaWVzKSkgewogICAgICBsZXQgbCA9IDAsCiAgICAgICAgciA9IGVudHJpZXMubGVuZ3RoIC0gMjsKICAgICAgd2hpbGUgKGwgPD0gcikgewogICAgICAgIGNvbnN0IHRtcCA9IGwgKyByID4+IDE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bGFjZUFsbCgiXFxcXCIsICJcXCIpLnJlcGxhY2VBbGwoIlxcLyIsICIvIikucmVwbGFjZUFsbCgiXFwiLCAiLyIpOwogICAgfQogICAgcmV0dXJuIHRoaXMuX2ZpbGVuYW1lOwogIH0KICBnZXQgY29udGVudCgpIHsKICAgIGlmICghdGhpcy5jb250ZW50QXZhaWxhYmxlKSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgaWYgKCF0aGlzLmNvbnRlbnRSZWYgJiYgdGhpcy5yb290KSB7CiAgICAgIHRoaXMuY29udGVudFJlZiA9IHBpY2tQbGF0Zm9ybUl0ZW0odGhpcy5yb290LmdldCgiRUYiKSk7CiAgICB9CiAgICBsZXQgY29udGVudCA9IG51bGw7CiAgICBpZiAodGhpcy5jb250ZW50UmVmKSB7CiAgICAgIGNvbnN0IGZpbGVPYmogPSB0aGlzLnhyZWYuZmV0Y2hJZlJlZih0aGlzLmNvbnRlbnRSZWYpOwogICAgICBpZiAoZmlsZU9iaiBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSB7CiAgICAgICAgY29udGVudCA9IGZpbGVPYmouZ2V0Qnl0ZXMoKTsKICAgICAgfSBlbHNlIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoIkVtYmVkZGVkIGZpbGUgc3BlY2lmaWNhdGlvbiBwb2ludHMgdG8gbm9uLWV4aXN0aW5nL2ludmFsaWQgY29udGVudCIpOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICAoMCwgX3V0aWwud2FybikoIkVtYmVkZGVkIGZpbGUgc3BlY2lmaWNhdGlvbiBkb2VzIG5vdCBoYXZlIGEgY29udGVudCIpOwogICAgfQogICAgcmV0dXJuIGNvbnRlbnQ7CiAgfQogIGdldCBzZXJpYWxpemFibGUoKSB7CiAgICByZXR1cm4gewogICAgICBmaWxlbmFtZTogdGhpcy5maWxlbmFtZSwKICAgICAgY29udGVudDogdGhpcy5jb250ZW50CiAgICB9OwogIH0KfQp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kMykgewogICAgICAgIHJldHVybiBTdHJpbmcuZnJvbUNoYXJDb2RlKGQxICogNjQgKyBkMiAqIDggKyBkMyAqIDEpOwogICAgICB9KS5yZXBsYWNlQWxsKC8mKGFtcHxhcG9zfGd0fGx0fHF1b3QpOy9nLCBmdW5jdGlvbiAoc3RyLCBuYW1lKSB7CiAgICAgICAgc3dpdGNoIChuYW1lKSB7CiAgICAgICAgICBjYXNlICJhbXAiOgogICAgICAgICAgICByZXR1cm4gIiYiOwogICAgICAgICAgY2FzZSAiYXBvcyI6CiAgICAgICAgICAgIHJldHVybiAiJyI7CiAgICAgICAgICBjYXNlICJndCI6CiAgICAgICAgICAgIHJldHVybiAiPiI7CiAgICAgICAgICBjYXNlICJsdCI6CiAgICAgICAgICAgIHJldHVybiAiPCI7CiAgICAgICAgICBjYXNlICJxdW90IjoKICAgICAgICAgICAgcmV0dXJuICciJzsKICAgICAgICB9CiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBfcmVwYWlyOiAke25hbWV9IGlzbid0IGRlZmluZWQuYCk7CiAgICAgIH0pOwogICAgICBjb25zdCBjaGFyQnVmID0gWyI+Il07CiAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGJ5dGVzLmxlbmd0aDsgaSA8IGlpOyBpICs9IDIpIHsKICAgICAgICBjb25zdCBjb2RlID0gYnl0ZXMuY2hhckNvZGVBdChpKSAqIDI1NiArIGJ5dGVzLmNoYXJDb2RlQXQoaSArIDEpOwogICAgICAgIGlmIChjb2RlID49IDMyICYmIGNvZGUgPCAxMjcgJiYgY29kZSAhPT0gNjAgJiYgY29kZSAhPT0gNjIgJiYgY29kZSAhPT0gMzgpIHsKICAgICAgICAgIGNoYXJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKGNvZGUpKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY2hhckJ1Zi5wdXNoKCImI3giICsgKDB4MTAwMDAgKyBjb2RlKS50b1N0cmluZygxNikuc3Vic3RyaW5n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gICAgfQogICAgICBjb25zdCBsYW5nID0gbm9kZS5kaWN0LmdldCgiTGFuZyIpOwogICAgICBpZiAodHlwZW9mIGxhbmcgPT09ICJzdHJpbmciKSB7CiAgICAgICAgb2JqLmxhbmcgPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKGxhbmcpOwogICAgICB9CiAgICAgIGZvciAoY29uc3Qga2lkIG9mIG5vZGUua2lkcykgewogICAgICAgIGNvbnN0IGtpZEVsZW1lbnQgPSBraWQudHlwZSA9PT0gU3RydWN0RWxlbWVudFR5cGUuRUxFTUVOVCA/IGtpZC5wYXJlbnROb2RlIDogbnVsbDsKICAgICAgICBpZiAoa2lkRWxlbWVudCkgewogICAgICAgICAgbm9kZVRvU2VyaWFsaXphYmxlKGtpZEVsZW1lbnQsIG9iaiwgbGV2ZWwgKyAxKTsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0gZWxzZSBpZiAoa2lkLnR5cGUgPT09IFN0cnVjdEVsZW1lbnRUeXBlLlBBR0VfQ09OVEVOVCB8fCBraWQudHlwZSA9PT0gU3RydWN0RWxlbWVudFR5cGUuU1RSRUFNX0NPTlRFTlQpIHsKICAgICAgICAgIG9iai5jaGlsZHJlbi5wdXNoKHsKICAgICAgICAgICAgdHlwZTogImNvbnRlbnQiLAogICAgICAgICAgICBpZDogYHBhZ2Uke2tpZC5wYWdlT2JqSWR9X21jaWQke2tpZC5tY2lkfWAKICAgICAgICAgIH0pOwogICAgICAgIH0gZWxzZSBpZiAoa2lkLnR5cGUgPT09IFN0cnVjdEVsZW1lbnRUeXBlLk9CSkVDVCkgewogICAgICAgICAgb2JqLmNoaWxkcmVuLnB1c2goewogICAgICAgICAgICB0eXBlOiAib2JqZWN0IiwKICAgICAgICAgICAgaWQ6IGtpZC5yZWZPYmpJZAogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBjb25zdCByb290ID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgIH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ICAgICAgICBub2Rlc1RvVmlzaXQucHVzaChyYXdWYWx1ZSk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiB0aGlzLl93YWxrKG5vZGVzVG9WaXNpdCk7CiAgfQogIGFzeW5jIF93YWxrKG5vZGVzVG9WaXNpdCkgewogICAgY29uc3Qgbm9kZXNUb1JldmlzaXQgPSBbXTsKICAgIGNvbnN0IHBlbmRpbmdSZXF1ZXN0cyA9IFtdOwogICAgd2hpbGUgKG5vZGVzVG9WaXNpdC5sZW5ndGgpIHsKICAgICAgbGV0IGN1cnJlbnROb2RlID0gbm9kZXNUb1Zpc2l0LnBvcCgpOwogICAgICBpZiAoY3VycmVudE5vZGUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICBpZiAodGhpcy5yZWZTZXQuaGFzKGN1cnJlbnROb2RlKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIHRyeSB7CiAgICAgICAgICB0aGlzLnJlZlNldC5wdXQoY3VycmVudE5vZGUpOwogICAgICAgICAgY3VycmVudE5vZGUgPSB0aGlzLnhyZWYuZmV0Y2goY3VycmVudE5vZGUpOwogICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICBpZiAoIShleCBpbnN0YW5jZW9mIF9jb3JlX3V0aWxzLk1pc3NpbmdEYXRhRXhjZXB0aW9uKSkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYE9iamVjdExvYWRlci5fd2FsayAtIHJlcXVlc3RpbmcgYWxsIGRhdGE6ICIke2V4fSIuYCk7CiAgICAgICAgICAgIHRoaXMucmVmU2V0ID0gbnVsbDsKICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgIG1hbmFnZXIKICAgICAgICAgICAgfSA9IHRoaXMueHJlZi5zdHJlYW07CiAgICAgICAgICAgIHJldHVybiBtYW5hZ2VyLnJlcXVlc3RBbGxDaHVua3MoKTsKICAgICAgICAgIH0KICAgICAgICAgIG5vZGVzVG9SZXZpc2l0LnB1c2goY3VycmVudE5vZGUpOwogICAgICAgICAgcGVuZGluZ1JlcXVlc3RzLnB1c2goewogICAgICAgICAgICBiZWdpbjogZXguYmVnaW4sCiAgICAgICAgICAgIGVuZDogZXguZW5kCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKGN1cnJlbnROb2RlIGluc3RhbmNlb2YgX2Jhc2Vfc3RyZWFtLkJhc2VTdHJlYW0pIHsKICAgICAgICBjb25zdCBiYXNlU3RyZWFtcyA9IGN1cnJlbnROb2RlLmdldEJhc2VTdHJlYW1zKCk7CiAgICAgICAgaWYgKGJhc2VTdHJlYW1zKSB7CiAgICAgICAgICBsZXQgZm91bmRNaXNzaW5nRGF0YSA9IGZhbHNlOwogICAgICAgICAgZm9yIChjb25zdCBzdHJlYW0gb2YgYmFzZVN0cmVhbXMpIHsKICAgICAgICAgICAgaWYgKHN0cmVhbS5pc0RhdGFMb2FkZWQpIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBmb3VuZE1pc3NpbmdEYXRhID0gdHJ1ZTsKICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3RzLnB1c2goewogICAgICAgICAgICAgIGJlZ2luOiBzdHJlYW0uc3RhcnQsCiAgICAgICAgICAgICAgZW5kOiBzdHJlYW0uZW5kCiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGZvdW5kTWlzc2luZ0RhdGEpIHsKICAgICAgICAgICAgbm9kZXNUb1JldmlzaXQucHVzaChjdXJyZW50Tm9kZSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIGFkZENoaWxkcmVuKGN1cnJlbnROb2RlLCBub2Rlc1RvVmlzaXQpOwogICAgfQogICAgaWYgKHBlbmRpbmdSZXF1ZXN0cy5sZW5ndGgpIHsKICAgICAgYXdhaXQgdGhpcy54cmVmLnN0cmVhbS5tYW5hZ2VyLnJl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9PT0gMCkgewogICAgICByZXR1cm4gdGhpc1skY29udGVudF07CiAgICB9CiAgICByZXR1cm4gdGhpc1tfY2hpbGRyZW5dLm1hcChjID0+IGNbJHRleHRdKCkpLmpvaW4oIiIpOwogIH0KICBnZXQgW19hdHRyaWJ1dGVOYW1lc10oKSB7CiAgICBjb25zdCBwcm90byA9IE9iamVjdC5nZXRQcm90b3R5cGVPZih0aGlzKTsKICAgIGlmICghcHJvdG8uX2F0dHJpYnV0ZXMpIHsKICAgICAgY29uc3QgYXR0cmlidXRlcyA9IHByb3RvLl9hdHRyaWJ1dGVzID0gbmV3IFNldCgpOwogICAgICBmb3IgKGNvbnN0IG5hbWUgb2YgT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXModGhpcykpIHsKICAgICAgICBpZiAodGhpc1tuYW1lXSA9PT0gbnVsbCB8fCB0aGlzW25hbWVdIGluc3RhbmNlb2YgWEZBT2JqZWN0IHx8IHRoaXNbbmFtZV0gaW5zdGFuY2VvZiBYRkFPYmplY3RBcnJheSkgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGF0dHJpYnV0ZXMuYWRkKG5hbWUpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgX2F0dHJpYnV0ZU5hbWVzLCBwcm90by5fYXR0cmlidXRlcyk7CiAgfQogIFskaXNEZXNjZW5kZW50XShwYXJlbnQpIHsKICAgIGxldCBub2RlID0gdGhpczsKICAgIHdoaWxlIChub2RlKSB7CiAgICAgIGlmIChub2RlID09PSBwYXJlbnQpIHsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfQogICAgICBub2RlID0gbm9kZVskZ2V0UGFyZW50XSgpOwogICAgfQogICAgcmV0dXJuIGZhbHNlOwogIH0KICBbJGdldFBhcmVudF0oKSB7CiAgICByZXR1cm4gdGhpc1tfcGFyZW50XTsKICB9CiAgWyRnZXRTdWJmb3JtUGFyZW50XSgpIHsKICAgIHJldH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dmFsdWVbX2NoaWxkcmVuXS5sZW5ndGgsIGlpID0gcHJvdG9WYWx1ZVtfY2hpbGRyZW5dLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgIGNvbnN0IGNoaWxkID0gcHJvdG9bX2NoaWxkcmVuXVtpXVskY2xvbmVdKCk7CiAgICAgICAgICBpZiAodmFsdWUucHVzaChjaGlsZCkpIHsKICAgICAgICAgICAgY2hpbGRbX3BhcmVudF0gPSB0aGlzOwogICAgICAgICAgICB0aGlzW19jaGlsZHJlbl0ucHVzaChjaGlsZCk7CiAgICAgICAgICAgIGNoaWxkW19yZXNvbHZlUHJvdG90eXBlc0hlbHBlcl0oaWRzLCBhbmNlc3RvcnMpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmICh2YWx1ZSAhPT0gbnVsbCkgewogICAgICAgIHZhbHVlWyRyZXNvbHZlUHJvdG90eXBlc10oaWRzLCBhbmNlc3RvcnMpOwogICAgICAgIGlmIChwcm90b1ZhbHVlKSB7CiAgICAgICAgICB2YWx1ZVtfYXBwbHlQcm90b3R5cGVdKHByb3RvVmFsdWUsIGlkcywgYW5jZXN0b3JzKTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKHByb3RvVmFsdWUgIT09IG51bGwpIHsKICAgICAgICBjb25zdCBjaGlsZCA9IHByb3RvVmFsdWVbJGNsb25lXSgpOwogICAgICAgIGNoaWxkW19wYXJlbnRdID0gdGhpczsKICAgICAgICB0aGlzW25hbWVdID0gY2hpbGQ7CiAgICAgICAgdGhpc1tfY2hpbGRyZW5dLnB1c2goY2hpbGQpOwogICAgICAgIGNoaWxkW19yZXNvbHZlUHJvdG90eXBlc0hlbHBlcl0oaWRzLCBhbmNlc3RvcnMpOwogICAgICB9CiAgICB9CiAgfQogIHN0YXRpYyBb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nN0YW5jZW9mIFhGQU9iamVjdEFycmF5KSB7CiAgICAgICAgY2xvbmVbbmFtZV0gPSBuZXcgWEZBT2JqZWN0QXJyYXkodmFsdWVbX21heF0pOwogICAgICB9IGVsc2UgewogICAgICAgIGNsb25lW25hbWVdID0gbnVsbDsKICAgICAgfQogICAgfQogICAgZm9yIChjb25zdCBjaGlsZCBvZiB0aGlzW19jaGlsZHJlbl0pIHsKICAgICAgY29uc3QgbmFtZSA9IGNoaWxkWyRub2RlTmFtZV07CiAgICAgIGNvbnN0IGNsb25lZENoaWxkID0gY2hpbGRbJGNsb25lXSgpOwogICAgICBjbG9uZVtfY2hpbGRyZW5dLnB1c2goY2xvbmVkQ2hpbGQpOwogICAgICBjbG9uZWRDaGlsZFtfcGFyZW50XSA9IGNsb25lOwogICAgICBpZiAoY2xvbmVbbmFtZV0gPT09IG51bGwpIHsKICAgICAgICBjbG9uZVtuYW1lXSA9IGNsb25lZENoaWxkOwogICAgICB9IGVsc2UgewogICAgICAgIGNsb25lW25hbWVdW19jaGlsZHJlbl0ucHVzaChjbG9uZWRDaGlsZCk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBjbG9uZTsKICB9CiAgWyRnZXRDaGlsZHJlbl0oKSB7CiAgICBsZXQgbmFtZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogbnVsbDsKICAgIGlmICghbmFtZSkgewogICAgICByZXR1cm4gdGhpc1tfY2hpbGRyZW5dOwogICAgfQogICAgcmV0dXJuIHRoaXNbX2NoaWxkcmVuXS5maWx0ZXIoYyA9PiBjWyRub2RlTmFtZV0gPT09IG5hbWUpOwogIH0KICBbJGdldENoaWxkcmVuQnlDbGFzc10obmFtZSkgewogICAgcmV0dXJuIHRoaXNbbmFtZV07CiAgfQogIFskZ2V0Q2hpbGRyZW5CeU5hbWVdKG5hbWUsIGFsbFRyYW5zcGFyZW50KSB7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ICAgICAgfQogICAgfQogICAgaWYgKCF0aGlzWyRjb250ZW50XSAmJiB0aGlzW19jaGlsZHJlbl0ubGVuZ3RoID09PSAwKSB7CiAgICAgIGJ1Zi5wdXNoKCIvPiIpOwogICAgICByZXR1cm47CiAgICB9CiAgICBidWYucHVzaCgiPiIpOwogICAgaWYgKHRoaXNbJGNvbnRlbnRdKSB7CiAgICAgIGlmICh0eXBlb2YgdGhpc1skY29udGVudF0gPT09ICJzdHJpbmciKSB7CiAgICAgICAgYnVmLnB1c2goKDAsIF9jb3JlX3V0aWxzLmVuY29kZVRvWG1sU3RyaW5nKSh0aGlzWyRjb250ZW50XSkpOwogICAgICB9IGVsc2UgewogICAgICAgIHRoaXNbJGNvbnRlbnRdWyR0b1N0cmluZ10oYnVmKTsKICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgZm9yIChjb25zdCBjaGlsZCBvZiB0aGlzW19jaGlsZHJlbl0pIHsKICAgICAgICBjaGlsZFskdG9TdHJpbmddKGJ1Zik7CiAgICAgIH0KICAgIH0KICAgIGJ1Zi5wdXNoKGA8LyR7cHJlZml4fSR7dXRmOFRhZ05hbWV9PmApOwogIH0KICBbJG9uQ2hpbGRdKGNoaWxkKSB7CiAgICBpZiAodGhpc1skY29udGVudF0pIHsKICAgICAgY29uc3Qgbm9kZSA9IG5ldyBYbWxPYmplY3QodGhpc1skbmFtZXNwYWNlSWRdLCAiI3RleHQiKTsKICAgICAgdGhpc1skYXBwZW5kQ2hpbGRdKG5vZGUpOwogICAgICBub2RlWyRjb250ZW50XSA9IHRoaXNbJGNvbnRlbnRdOwogICAgICB0aGlzWyRjb250ZW50XSA9ICIiOwogICAgfQogICAgdGhpc1skYXBwZW5kQ2hpbGRdKGNoaWxkKTsKICAgIHJldHVybiB0cnVlOwogIH0KICBbJG9uVGV4dF0oc3RyKSB7CiAgICB0aGlzWyRjb250ZW50XSArPSBzdHI7CiAgfQogIFskZmluYWxpemVdKCkgewogICAgaWYgKHRoaXNbJGNvbnRl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dXRpbC53YXJuKSgiWEZBIC0gSW52YWxpZCBpbmRleCBpbiBTT00gZXhwcmVzc2lvbiIpOwogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAgIHBhcnNlZC5hdCgtMSkuaW5kZXggPSBwYXJzZUluZGV4KG1hdGNoWzBdKTsKICAgICAgcG9zICs9IG1hdGNoWzBdLmxlbmd0aCArIDE7CiAgICAgIGNvbnRpbnVlOwogICAgfQogICAgbGV0IG9wZXJhdG9yOwogICAgc3dpdGNoIChleHByLmNoYXJBdChwb3MpKSB7CiAgICAgIGNhc2UgIi4iOgogICAgICAgIGlmICghZG90RG90QWxsb3dlZCkgewogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICAgIHBvcysrOwogICAgICAgIG9wZXJhdG9yID0gb3BlcmF0b3JzLmRvdERvdDsKICAgICAgICBicmVhazsKICAgICAgY2FzZSAiIyI6CiAgICAgICAgcG9zKys7CiAgICAgICAgb3BlcmF0b3IgPSBvcGVyYXRvcnMuZG90SGFzaDsKICAgICAgICBicmVhazsKICAgICAgY2FzZSAiWyI6CiAgICAgICAgaWYgKG5vRXhwcikgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJYRkEgLSBTT00gZXhwcmVzc2lvbiBjb250YWlucyBhIEZvcm1DYWxjIHN1YmV4cHJlc3Npb24gd2hpY2ggaXMgbm90IHN1cHBvcnRlZCBmb3Igbm93LiIpOwogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICAgIG9wZXJhdG9yID0gb3BlcmF0b3JzLmRvdEJyYWNrZXQ7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgIigiOgogICAgICAgIGlmIChub0V4cHIpIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiWEZBIC0gU09NIGV4cHJlc3Npb24gY29udGFpbnMgYSBKYXZhU2NyaXB0IHN1YmV4cHJlc3Npb24gd2hpY2ggaXMgbm90IHN1cHBvcnRlZCBmb3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mFsc2UpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2Ugb3BlcmF0b3JzLmRvdERvdDoKICAgICAgICAgICAgY2hpbGRyZW4gPSBub2RlW194ZmFfb2JqZWN0LiRnZXRDaGlsZHJlbkJ5TmFtZV0obmFtZSwgdHJ1ZSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBvcGVyYXRvcnMuZG90SGFzaDoKICAgICAgICAgICAgY2hpbGRyZW4gPSBub2RlW194ZmFfb2JqZWN0LiRnZXRDaGlsZHJlbkJ5Q2xhc3NdKG5hbWUpOwogICAgICAgICAgICBpZiAoY2hpbGRyZW4gaW5zdGFuY2VvZiBfeGZhX29iamVjdC5YRkFPYmplY3RBcnJheSkgewogICAgICAgICAgICAgIGNoaWxkcmVuID0gY2hpbGRyZW4uY2hpbGRyZW47CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgY2hpbGRyZW4gPSBbY2hpbGRyZW5dOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmICh1c2VDYWNoZSkgewogICAgICAgICAgY2FjaGVkLnNldChjYWNoZU5hbWUsIGNoaWxkcmVuKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKGNoaWxkcmVuLmxlbmd0aCA+IDApIHsKICAgICAgICBub2Rlcy5wdXNoKGNoaWxkcmVuKTsKICAgICAgfQogICAgfQogICAgaWYgKG5vZGVzLmxlbmd0aCA9PT0gMCAmJiAhaXNRdWFsaWZpZWQgJiYgaSA9PT0gMCkgewogICAgICBjb25zdCBwYXJlbnQgPSBjb250YWluZXJbX3hmYV9vYmplY3QuJGdldFBhcmVudF0oKTsKICAgICAgY29udGFpbmVyID0gcGFyZW50OwogICAgICBpZiAoIWNvbnRhaW5lcikgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAg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ogICAgICBjb25uZWN0aW9uCiAgICB9IG9mIGZvcm1Ob2RlLnNldFByb3BlcnR5LmNoaWxkcmVuKSB7CiAgICAgIGlmIChjb25uZWN0aW9uKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKCFyZWYpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBub2RlcyA9ICgwLCBfc29tLnNlYXJjaE5vZGUpKHRoaXMucm9vdCwgZGF0YU5vZGUsIHJlZiwgZmFsc2UsIGZhbHNlKTsKICAgICAgaWYgKCFub2RlcykgewogICAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gSW52YWxpZCByZWZlcmVuY2U6ICR7cmVmfS5gKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBbbm9kZV0gPSBub2RlczsKICAgICAgaWYgKCFub2RlW194ZmFfb2JqZWN0LiRpc0Rlc2NlbmRlbnRdKHRoaXMuZGF0YSkpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYFhGQSAtIEludmFsaWQgbm9kZTogbXVzdCBiZSBhIGRhdGEgbm9kZS5gKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCB0YXJnZXROb2RlcyA9ICgwLCBfc29tLnNlYXJjaE5vZGUpKHRoaXMucm9vdCwgZm9ybU5vZGUsIHRhcmdldCwgZmFsc2UsIGZhbHNlKTsKICAgICAgaWYgKCF0YXJnZXROb2RlcykgewogICAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gSW52YWxpZCB0YXJnZXQ6ICR7dGFyZ2V0fS5gKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBbdGFyZ2V0Tm9kZV0gPSB0YXJnZXROb2RlczsKICAgICAgaWYgKCF0YXJnZXROb2RlW194ZmFfb2JqZWN0LiRpc0Rlc2NlbmRlbnRdKGZvcm1Ob2RlKSkgewogICAgICAgICgwLCBfdXRpbC53YXJuKShgW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sKICAgIGNvbnN0IHZhbHVlcyA9IG5ldyBfdGVtcGxhdGUuSXRlbXMoe30pOwogICAgZm9ybU5vZGVbX3hmYV9vYmplY3QuJGFwcGVuZENoaWxkXShsYWJlbHMpOwogICAgZm9ybU5vZGUuaXRlbXMucHVzaChsYWJlbHMpOwogICAgZm9ybU5vZGVbX3hmYV9vYmplY3QuJGFwcGVuZENoaWxkXSh2YWx1ZXMpOwogICAgZm9ybU5vZGUuaXRlbXMucHVzaCh2YWx1ZXMpOwogICAgZm9yIChjb25zdCB7CiAgICAgIHJlZiwKICAgICAgbGFiZWxSZWYsCiAgICAgIHZhbHVlUmVmLAogICAgICBjb25uZWN0aW9uCiAgICB9IG9mIGZvcm1Ob2RlLmJpbmRJdGVtcy5jaGlsZHJlbikgewogICAgICBpZiAoY29ubmVjdGlvbikgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmICghcmVmKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgY29uc3Qgbm9kZXMgPSAoMCwgX3NvbS5zZWFyY2hOb2RlKSh0aGlzLnJvb3QsIGRhdGFOb2RlLCByZWYsIGZhbHNlLCBmYWxzZSk7CiAgICAgIGlmICghbm9kZXMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYFhGQSAtIEludmFsaWQgcmVmZXJlbmNlOiAke3JlZn0uYCk7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgZm9yIChjb25zdCBub2RlIG9mIG5vZGVzKSB7CiAgICAgICAgaWYgKCFub2RlW194ZmFfb2JqZWN0LiRpc0Rlc2NlbmRlbnRdKHRoaXMuZGF0YXNldHMpKSB7CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoYFhGQSAtIEludmFsaWQgcmVmICgke3JlZn0pOiBtdXN0IGJlIGEgZGF0YXNldHMgY2hpbGQuYCk7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgY29uc3QgbGFiZWxOb2RlcyA9ICg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AgICBjYXNlICJkYXRhUmVmIjoKICAgICAgICAgICAgaWYgKCFjaGlsZC5iaW5kLnJlZikgewogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gcmVmIGlzIGVtcHR5IGluIG5vZGUgJHtjaGlsZFtfeGZhX29iamVjdC4kbm9kZU5hbWVdfS5gKTsKICAgICAgICAgICAgICB0aGlzLl9zZXRBbmRCaW5kKGNoaWxkLCBkYXRhTm9kZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmVmID0gY2hpbGQuYmluZC5yZWY7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmIChjaGlsZC5iaW5kLnBpY3R1cmUpIHsKICAgICAgICAgIHBpY3R1cmUgPSBjaGlsZC5iaW5kLnBpY3R1cmVbX3hmYV9vYmplY3QuJGNvbnRlbnRdOwogICAgICAgIH0KICAgICAgfQogICAgICBjb25zdCBbbWluLCBtYXhdID0gdGhpcy5fZ2V0T2NjdXJJbmZvKGNoaWxkKTsKICAgICAgaWYgKHJlZikgewogICAgICAgIG1hdGNoID0gKDAsIF9zb20uc2VhcmNoTm9kZSkodGhpcy5yb290LCBkYXRhTm9kZSwgcmVmLCB0cnVlLCBmYWxzZSk7CiAgICAgICAgaWYgKG1hdGNoID09PSBudWxsKSB7CiAgICAgICAgICBtYXRjaCA9ICgwLCBfc29tLmNyZWF0ZURhdGFOb2RlKSh0aGlzLmRhdGEsIGRhdGFOb2RlLCByZWYpOwogICAgICAgICAgaWYgKCFtYXRjaCkgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh0aGlzLl9pc0NvbnN1bWVEYXRhKCkpIHsKICAgICAgICAgICAgbWF0Y2hbX3hmYV9vYmplY3QuJGNvbnN1bWVkXSA9IHRydWU7CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLl9zZXRBbmRCaW5kKGNoaWxkLCBtYXRjaCk7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgaWYgKHRoaXMuX2lzQ29uc3VtZURhdGEoKSkgewogICAgICAgICAgICBtYXRjaCA9IG1hdGNoLmZpbHRlcihub2RlID0+ICFub2RlW194ZmFfb2JqZWN0LiRjb25zdW1lZF0pOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG1hdGNoLmxlbmd0aCA+IG1heCkgewogICAgICAgICAgICBtYXRjaCA9IG1hdGNoLnNsaWNlKDAsIG1heCk7CiAgICAgICAgICB9IGVsc2UgaWYgKG1hdGNoLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICBtYXRjaCA9IG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAobWF0Y2ggJiYgdGhpcy5faXNDb25zdW1lRGF0YSgpKSB7CiAgICAgICAgICAgIG1hdGNoLmZvckVhY2gobm9kZSA9PiB7CiAgICAgICAgICAgICAgbm9kZVtfeGZhX29iamVjdC4kY29uc3VtZWRdID0gdHJ1ZTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGlmICghY2hpbGQubmFtZSkgewogICAgICAgICAgdGhpcy5fc2V0QW5kQmluZChjaGlsZCwgZGF0YU5vZGUpOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGlmICh0aGlzLl9pc0NvbnN1bWVEYXRhKCkpIHsKICAgICAgICAgIGNvbnN0IG1hdGNoZXMgPSBbXTsKICAgICAgICAgIHdoaWxlIChtYXRjaGVzLmxlbmd0aCA8IG1heCkgewogICAgICAgICAgICBjb25zdCBmb3VuZCA9IHRoaXMuX2ZpbmREYXRhQnlOYW1lVG9Db25zdW1lKGNoaWxkLm5hbWUsIGNoaWxkW194ZmFfb2JqZWN0LiRoYXNTZXR0YWJsZVZhbHVlXSgpLCBkYXRhTm9kZSwgZ2xvYmFsKTsKICAgICAgICAgICAgaWYgKCFmb3VuZCkgewogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZvdW5kW194ZmFfb2JqZWN0LiRjb25zdW1lZF0gPSB0cnVlOwogICAgICAgICAgICBtYXRjaGVzLnB1c2goZm91bmQpOwogICAgICAgICAgfQogICAgICAgICAgbWF0Y2ggPSBtYXRjaGVzLmxlbmd0aCA+IDAgPyBtYXRjaGVzIDogbnVsbDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgbWF0Y2ggPSBkYXRhTm9kZVtfeGZhX29iamVjdC4kZ2V0UmVhbENoaWxkcmVuQnlOYW1lSXRdKGNoaWxkLm5hbWUsIGZhbHNlLCB0aGlzLmVtcHR5TWVyZ2UpLm5leHQoKS52YWx1ZTsKICAgICAgICAgIGlmICghbWF0Y2gpIHsKICAgICAgICAgICAgaWYgKG1pbiA9PT0gMCkgewogICAgICAgICAgICAgIHVzZWxlc3NOb2Rlcy5wdXNoKGNoaWxkKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBuc0lkID0gZGF0YU5vZGVbX3hmYV9vYmplY3QuJG5hbWVzcGFjZUlkXSA9PT0gTlNfREFUQVNFVFMgPyAtMSA6IGRhdGFOb2RlW194ZmFfb2JqZWN0LiRuYW1lc3BhY2VJZF07CiAgICAgICAgICAgIG1hdGNoID0gY2hpbGRbX3hmYV9vYmplY3QuJGRhdGFdID0gbmV3IF94ZmFfb2JqZWN0LlhtbE9iamVjdChuc0lkLCBjaGlsZC5uYW1lKTsKICAgICAgICAgICAgaWYgKHRoaXMuZW1wdHlNZXJnZSkgewogICAgICAgICAgICAgIG1hdGNoW194ZmFfb2JqZWN0LiRjb25zdW1lZF0gPSB0cnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGRhdGFOb2RlW194ZmFfb2JqZWN0LiRhcHBlbmRDaGlsZF0obWF0Y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sKICAgICAgbm9kZVtfeGZhX29iamVjdC4kdGFiSW5kZXhdID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0UGFyZW50XSgpW194ZmFfb2JqZWN0LiR0YWJJbmRleF07CiAgICAgIHJldHVybjsKICAgIH0KICAgIGlmIChub2RlW194ZmFfb2JqZWN0LiR0YWJJbmRleF0pIHsKICAgICAgcmV0dXJuOwogICAgfQogICAgbGV0IG5leHQgPSBudWxsOwogICAgZm9yIChjb25zdCBjaGlsZCBvZiBub2RlLnRyYXZlcnNhbFtfeGZhX29iamVjdC4kZ2V0Q2hpbGRyZW5dKCkpIHsKICAgICAgaWYgKGNoaWxkLm9wZXJhdGlvbiA9PT0gIm5leHQiKSB7CiAgICAgICAgbmV4dCA9IGNoaWxkOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBpZiAoIW5leHQgfHwgIW5leHQucmVmKSB7CiAgICAgIG5vZGVbX3hmYV9vYmplY3QuJHRhYkluZGV4XSA9IG5vZGVbX3hmYV9vYmplY3QuJGdldFBhcmVudF0oKVtfeGZhX29iamVjdC4kdGFiSW5kZXhdOwogICAgICByZXR1cm47CiAgICB9CiAgICBjb25zdCByb290ID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0VGVtcGxhdGVSb290XSgpOwogICAgbm9kZVtfeGZhX29iamVjdC4kdGFiSW5kZXhdID0gKytyb290W194ZmFfb2JqZWN0LiR0YWJJbmRleF07CiAgICBjb25zdCByZWYgPSByb290W194ZmFfb2JqZWN0LiRzZWFyY2hOb2RlXShuZXh0LnJlZiwgbm9kZSk7CiAgICBpZiAoIXJlZikgewogICAgICByZXR1cm47CiAgICB9CiAgICBub2RlID0gcmVmWzBdOwogIH0KfQpmdW5jdGlvbiBhcHBseUFzc2lzdChvYmosIGF0dHJpYnV0ZXMpIHsKICBjb25zdCBhc3Npc3QgPSBvYmouYXNzaXN0OwogIGlmIChhc3Npc3QpIHsKICAgIGNvbnN0IGFzc2lzdFRpdGxlID0gYXNza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pKSwgNTAgKiAoMSAtIE1hdGguc2luKHN0YXJ0QW5nbGUgKyBzd2VlcEFuZ2xlKSldOwogICAgICBhcmMgPSB7CiAgICAgICAgbmFtZTogInBhdGgiLAogICAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICAgIHhtbG5zOiBTVkdfTlMsCiAgICAgICAgICBkOiBgTSAke3gxfSAke3kxfSBBIDUwIDUwIDAgJHtsYXJnZUFyY30gMCAke3gyfSAke3kyfWAsCiAgICAgICAgICB2ZWN0b3JFZmZlY3Q6ICJub24tc2NhbGluZy1zdHJva2UiLAogICAgICAgICAgc3R5bGUKICAgICAgICB9CiAgICAgIH07CiAgICAgIE9iamVjdC5hc3NpZ24oYXR0cmlidXRlcywgewogICAgICAgIHZpZXdCb3g6ICIwIDAgMTAwIDEwMCIsCiAgICAgICAgcHJlc2VydmVBc3BlY3RSYXRpbzogIm5vbmUiCiAgICAgIH0pOwogICAgfQogICAgY29uc3Qgc3ZnID0gewogICAgICBuYW1lOiAic3ZnIiwKICAgICAgY2hpbGRyZW46IFthcmNdLAogICAgICBhdHRyaWJ1dGVzCiAgICB9OwogICAgY29uc3QgcGFyZW50ID0gdGhpc1tfeGZhX29iamVjdC4kZ2V0UGFyZW50XSgpW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCk7CiAgICBpZiAoaGFzTWFyZ2luKHBhcmVudCkpIHsKICAgICAgcmV0dXJuIF91dGlscy5IVE1MUmVzdWx0LnN1Y2Nlc3MoewogICAgICAgIG5hbWU6ICJkaXYiLAogICAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICAgIHN0eWxlOiB7CiAgICAgICAgICAgIGRpc3BsYXk6ICJpbmxpbmUiLAogICAgICAgICAgICB3aWR0aDogIjEwMCUiLAogICAgICAgICAgICBoZWlnaHQ6ICIxMDAlIgogICAgICAgICAgfQogICAgICAgIH0sCiAgICAgICAgY2hpbGRyZW46IFtzdmddCiAgICAgIH0pOwogICAgfQogICAgc3ZnLmF0dH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QogIFtfeGZhX29iamVjdC4kdG9IVE1MXShhdmFpbGFibGVTcGFjZSkgewogICAgY29uc3QgcGFyZW50ID0gdGhpc1tfeGZhX29iamVjdC4kZ2V0UGFyZW50XSgpOwogICAgY29uc3QgZ3JhbmRwYSA9IHBhcmVudFtfeGZhX29iamVjdC4kZ2V0UGFyZW50XSgpOwogICAgY29uc3QgaHRtbEJ1dHRvbiA9IHsKICAgICAgbmFtZTogImJ1dHRvbiIsCiAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICBpZDogdGhpc1tfeGZhX29iamVjdC4kdWlkXSwKICAgICAgICBjbGFzczogWyJ4ZmFCdXR0b24iXSwKICAgICAgICBzdHlsZToge30KICAgICAgfSwKICAgICAgY2hpbGRyZW46IFtdCiAgICB9OwogICAgZm9yIChjb25zdCBldmVudCBvZiBncmFuZHBhLmV2ZW50LmNoaWxkcmVuKSB7CiAgICAgIGlmIChldmVudC5hY3Rpdml0eSAhPT0gImNsaWNrIiB8fCAhZXZlbnQuc2NyaXB0KSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgY29uc3QganNVUkwgPSAoMCwgX2NvcmVfdXRpbHMucmVjb3ZlckpzVVJMKShldmVudC5zY3JpcHRbX3hmYV9vYmplY3QuJGNvbnRlbnRdKTsKICAgICAgaWYgKCFqc1VSTCkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IGhyZWYgPSAoMCwgX2h0bWxfdXRpbHMuZml4VVJMKShqc1VSTC51cmwpOwogICAgICBpZiAoIWhyZWYpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBodG1sQnV0dG9uLmNoaWxkcmVuLnB1c2goewogICAgICAgIG5hbWU6ICJhIiwKICAgICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgICBpZDogImxpbmsiICsgdGhpc1tfeGZhX29iamVjdC4kdWlkXSwKICAgICAgICAgIGhyZWYsCiAgICAgICAgICBuZXdXaW5kb3c6IG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nZlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAidG9wIjoKICAgICAgICBjYXNlICJib3R0b20iOgogICAgICAgICAgaGVpZ2h0ID0gdGhpcy5yZXNlcnZlIDw9IDAgPyBoZWlnaHQgOiB0aGlzLnJlc2VydmU7CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgICB0aGlzW194ZmFfb2JqZWN0LiRleHRyYV0gPSAoMCwgX2h0bWxfdXRpbHMubGF5b3V0Tm9kZSkodGhpcywgewogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodAogICAgICB9KTsKICAgIH0KICAgIHJldHVybiB0aGlzW194ZmFfb2JqZWN0LiRleHRyYV07CiAgfQogIFtfeGZhX29iamVjdC4kdG9IVE1MXShhdmFpbGFibGVTcGFjZSkgewogICAgaWYgKCF0aGlzLnZhbHVlKSB7CiAgICAgIHJldHVybiBfdXRpbHMuSFRNTFJlc3VsdC5FTVBUWTsKICAgIH0KICAgIHRoaXNbX3hmYV9vYmplY3QuJHB1c2hQYXJhXSgpOwogICAgY29uc3QgdmFsdWUgPSB0aGlzLnZhbHVlW194ZmFfb2JqZWN0LiR0b0hUTUxdKGF2YWlsYWJsZVNwYWNlKS5odG1sOwogICAgaWYgKCF2YWx1ZSkgewogICAgICB0aGlzW194ZmFfb2JqZWN0LiRwb3BQYXJhXSgpOwogICAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuRU1QVFk7CiAgICB9CiAgICBjb25zdCBzYXZlZFJlc2VydmUgPSB0aGlzLnJlc2VydmU7CiAgICBpZiAodGhpcy5yZXNlcnZlIDw9IDApIHsKICAgICAgY29uc3QgewogICAgICAgIHcsCiAgICAgICAgaAogICAgICB9ID0gdGhpc1tfeGZhX29iamVjdC4kZ2V0RXh0cmFdKGF2YWlsYWJsZVNwYWNlKTsKICAgICAgc3dpdGNoICh0aGlzLnBsYWNlbWVudCkgewogICAgICAgIGNhc2UgImxlZnQiOgogICAgICAgIGNhc2UgInJpZ2h0IjoKICAgICAgICBjYXNlICJpbmxpbmUiOgogICAgICAgICAgdGhpcy5yZXNlcnZlID0gdzsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInRvcCI6CiAgICAgICAgY2FzZSAiYm90dG9tIjoKICAgICAgICAgIHRoaXMucmVzZXJ2ZSA9IGg7CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgfQogICAgY29uc3QgY2hpbGRyZW4gPSBbXTsKICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJzdHJpbmciKSB7CiAgICAgIGNoaWxkcmVuLnB1c2goewogICAgICAgIG5hbWU6ICIjdGV4dCIsCiAgICAgICAgdmFsdWUKICAgICAgfSk7CiAgICB9IGVsc2UgewogICAgICBjaGlsZHJlbi5wdXNoKHZhbHVlKTsKICAgIH0KICAgIGNvbnN0IHN0eWxlID0gKDAsIF9odG1sX3V0aWxzLnRvU3R5bGUpKHRoaXMsICJmb250IiwgIm1hcmdpbiIsICJ2aXNpYmlsaXR5Iik7CiAgICBzd2l0Y2ggKHRoaXMucGxhY2VtZW50KSB7CiAgICAgIGNhc2UgImxlZnQiOgogICAgICBjYXNlICJyaWdodCI6CiAgICAgICAgaWYgKHRoaXMucmVzZXJ2ZSA+IDApIHsKICAgICAgICAgIHN0eWxlLndpZHRoID0gKDAsIF9odG1sX3V0aWxzLm1lYXN1cmVUb1N0cmluZykodGhpcy5yZXNlcnZlKTsKICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgInRvcCI6CiAgICAgIGNhc2UgImJvdHRvbSI6CiAgICAgICAgaWYgKHRoaXMucmVzZXJ2ZSA+IDApIHsKICAgICAgICAgIHN0eWxlLmhlaWdodCA9ICgwLCBfaHRtbF91dGlscy5tZWFzdXJlVG9TdHJpbmcpKHRoaXMucmVzZXJ2ZSk7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgfQogICAgKDAsIF9odG1sX3V0aWxzLnNldFBhcmEpKHRoaXMsIG51bGwsIHZ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gICAgICAgY2FzZSAiZGFzaERvdERvdCI6CiAgICAgICAgICBzdHlsZS5zdHlsZSA9ICJkYXNoZWQiOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZGFzaGVkIjoKICAgICAgICAgIHN0eWxlLnN0eWxlID0gImRhc2hlZCI7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJkb3R0ZWQiOgogICAgICAgICAgc3R5bGUuc3R5bGUgPSAiZG90dGVkIjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImVtYm9zc2VkIjoKICAgICAgICAgIHN0eWxlLnN0eWxlID0gInJpZGdlIjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImV0Y2hlZCI6CiAgICAgICAgICBzdHlsZS5zdHlsZSA9ICJncm9vdmUiOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibG93ZXJlZCI6CiAgICAgICAgICBzdHlsZS5zdHlsZSA9ICJpbnNldCI7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJyYWlzZWQiOgogICAgICAgICAgc3R5bGUuc3R5bGUgPSAib3V0c2V0IjsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gc3R5bGU7CiAgfQp9CmNsYXNzIEVuY29kaW5nIGV4dGVuZHMgX3hmYV9vYmplY3QuT3B0aW9uT2JqZWN0IHsKICBjb25zdHJ1Y3RvcihhdHRyaWJ1dGVzKSB7CiAgICBzdXBlcihURU1QTEFURV9OU19JRCwgImVuY29kaW5nIiwgWyJhZGJlLng1MDkucnNhX3NoYTEiLCAiYWRiZS5wa2NzNy5kZXRhY2hlZCIsICJhZGJlLnBrY3M3LnNoYTEiXSk7CiAgICB0aGlzLmlkID0gYXR0cmlidXRlcy5pZCB8fCAiIjsKICAgIHRoaXMudXNlID0gYXR0cmlidXRlcy51c2UgfHwgIiI7CiAgICB0aGlzLnVzZWhyZWYgPSBhdHRyaWJ1dGVzLnVzZW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pcy5zZXRQcm9wZXJ0eSA9IG5ldyBfeGZhX29iamVjdC5YRkFPYmplY3RBcnJheSgpOwogIH0KICBbX3hmYV9vYmplY3QuJGlzQmluZGFibGVdKCkgewogICAgcmV0dXJuIHRydWU7CiAgfQogIFtfeGZhX29iamVjdC4kc2V0VmFsdWVdKHZhbHVlKSB7CiAgICBfc2V0VmFsdWUodGhpcywgdmFsdWUpOwogIH0KICBbX3hmYV9vYmplY3QuJHRvSFRNTF0oYXZhaWxhYmxlU3BhY2UpIHsKICAgIHNldFRhYkluZGV4KHRoaXMpOwogICAgaWYgKCF0aGlzLnVpKSB7CiAgICAgIHRoaXMudWkgPSBuZXcgVWkoe30pOwogICAgICB0aGlzLnVpW194ZmFfb2JqZWN0LiRnbG9iYWxEYXRhXSA9IHRoaXNbX3hmYV9vYmplY3QuJGdsb2JhbERhdGFdOwogICAgICB0aGlzW194ZmFfb2JqZWN0LiRhcHBlbmRDaGlsZF0odGhpcy51aSk7CiAgICAgIGxldCBub2RlOwogICAgICBzd2l0Y2ggKHRoaXMuaXRlbXMuY2hpbGRyZW4ubGVuZ3RoKSB7CiAgICAgICAgY2FzZSAwOgogICAgICAgICAgbm9kZSA9IG5ldyBUZXh0RWRpdCh7fSk7CiAgICAgICAgICB0aGlzLnVpLnRleHRFZGl0ID0gbm9kZTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMToKICAgICAgICAgIG5vZGUgPSBuZXcgQ2hlY2tCdXR0b24oe30pOwogICAgICAgICAgdGhpcy51aS5jaGVja0J1dHRvbiA9IG5vZGU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDI6CiAgICAgICAgICBub2RlID0gbmV3IENob2ljZUxpc3Qoe30pOwogICAgICAgICAgdGhpcy51aS5jaG9pY2VMaXN0ID0gbm9kZTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIHRoaXMudWlbX3hmYV9vYmplY3QuJGFwcGVuZENoaWxkXShub2RlKTsKICAgIH0K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mNoZWNrQnV0dG9uLnNpemU7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29uc3QgewogICAgICAgICAgdywKICAgICAgICAgIGgKICAgICAgICB9ID0gKDAsIF9odG1sX3V0aWxzLmxheW91dE5vZGUpKHRoaXMsIGF2YWlsYWJsZVNwYWNlKTsKICAgICAgICBpZiAodyAhPT0gbnVsbCkgewogICAgICAgICAgdWlXID0gdzsKICAgICAgICAgIHVpSCA9IGg7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHVpSCA9ICgwLCBfZm9udHMuZ2V0TWV0cmljcykodGhpcy5mb250LCB0cnVlKS5saW5lTm9HYXA7CiAgICAgICAgfQogICAgICB9CiAgICAgIGJvcmRlckRpbXMgPSBnZXRCb3JkZXJEaW1zKHRoaXMudWlbX3hmYV9vYmplY3QuJGdldEV4dHJhXSgpKTsKICAgICAgdWlXICs9IGJvcmRlckRpbXMudzsKICAgICAgdWlIICs9IGJvcmRlckRpbXMuaDsKICAgICAgaWYgKHRoaXMuY2FwdGlvbikgewogICAgICAgIGNvbnN0IHsKICAgICAgICAgIHcsCiAgICAgICAgICBoLAogICAgICAgICAgaXNCcm9rZW4KICAgICAgICB9ID0gdGhpcy5jYXB0aW9uW194ZmFfb2JqZWN0LiRnZXRFeHRyYV0oYXZhaWxhYmxlU3BhY2UpOwogICAgICAgIGlmIChpc0Jyb2tlbiAmJiB0aGlzW194ZmFfb2JqZWN0LiRnZXRTdWJmb3JtUGFyZW50XSgpW194ZmFfb2JqZWN0LiRpc1RoZXJlTW9yZVdpZHRoXSgpKSB7CiAgICAgICAgICB0aGlzW194ZmFfb2JqZWN0LiRwb3BQYXJhXSgpOwogICAgICAgICAgcmV0dXJuIF91dGlscy5IVE1MUmVzdWx0LkZBSUxVUkU7CiAgICAgICAgfQogICAgICAgIHdpZHRoID0gdzsKICAgICAgICBoZWlnaHQgPSBoOwogICAgICAgIHN3aXRjaCAodGhpcy5jYXB0aW9uLnBsYWNlbWVudCkgewogICAgICAgICAgY2FzZSAibGVmdCI6CiAgICAgICAgICBjYXNlICJyaWdodCI6CiAgICAgICAgICBjYXNlICJpbmxpbmUiOgogICAgICAgICAgICB3aWR0aCArPSB1aVc7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAidG9wIjoKICAgICAgICAgIGNhc2UgImJvdHRvbSI6CiAgICAgICAgICAgIGhlaWdodCArPSB1aUg7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICB3aWR0aCA9IHVpVzsKICAgICAgICBoZWlnaHQgPSB1aUg7CiAgICAgIH0KICAgICAgaWYgKHdpZHRoICYmIHRoaXMudyA9PT0gIiIpIHsKICAgICAgICB3aWR0aCArPSBtYXJnaW5IOwogICAgICAgIHRoaXMudyA9IE1hdGgubWluKHRoaXMubWF4VyA8PSAwID8gSW5maW5pdHkgOiB0aGlzLm1heFcsIHRoaXMubWluVyArIDEgPCB3aWR0aCA/IHdpZHRoIDogdGhpcy5taW5XKTsKICAgICAgfQogICAgICBpZiAoaGVpZ2h0ICYmIHRoaXMuaCA9PT0gIiIpIHsKICAgICAgICBoZWlnaHQgKz0gbWFyZ2luVjsKICAgICAgICB0aGlzLmggPSBNYXRoLm1pbih0aGlzLm1heEggPD0gMCA/IEluZmluaXR5IDogdGhpcy5tYXhILCB0aGlzLm1pbkggKyAxIDwgaGVpZ2h0ID8gaGVpZ2h0IDogdGhpcy5taW5IKTsKICAgICAgfQogICAgfQogICAgdGhpc1tfeGZhX29iamVjdC4kcG9wUGFyYV0oKTsKICAgICgwLCBfaHRtbF91dGlscy5maXhEaW1lbnNpb25zKSh0aGlzKTsKICAgIHNldEZpcnN0VW5zcGxpdHRhYmxlKHRoaXMpOwogICAgaWYgKCEoMCwgX2xheW91dC5jaGVja0RpbWVuc2lvbnMpKHRoaXMsIGF2YWlsYWJsZVNwYWNlKSkgewogICAgICB0aGlzLncgPSBzYXZlZFc7CiAgICAgIHRoaXMuaCA9I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7CiAgICBpZiAodGhpcy51aS5idXR0b24pIHsKICAgICAgaWYgKHVpLmNoaWxkcmVuLmxlbmd0aCA9PT0gMSkgewogICAgICAgIFthRWxlbWVudF0gPSB1aS5jaGlsZHJlbi5zcGxpY2UoMCwgMSk7CiAgICAgIH0KICAgICAgT2JqZWN0LmFzc2lnbih1aS5hdHRyaWJ1dGVzLnN0eWxlLCBib3JkZXJTdHlsZSk7CiAgICB9IGVsc2UgewogICAgICBPYmplY3QuYXNzaWduKHN0eWxlLCBib3JkZXJTdHlsZSk7CiAgICB9CiAgICBjaGlsZHJlbi5wdXNoKHVpKTsKICAgIGlmICh0aGlzLnZhbHVlKSB7CiAgICAgIGlmICh0aGlzLnVpLmltYWdlRWRpdCkgewogICAgICAgIHVpLmNoaWxkcmVuLnB1c2godGhpcy52YWx1ZVtfeGZhX29iamVjdC4kdG9IVE1MXSgpLmh0bWwpOwogICAgICB9IGVsc2UgaWYgKCF0aGlzLnVpLmJ1dHRvbikgewogICAgICAgIGxldCB2YWx1ZSA9ICIiOwogICAgICAgIGlmICh0aGlzLnZhbHVlLmV4RGF0YSkgewogICAgICAgICAgdmFsdWUgPSB0aGlzLnZhbHVlLmV4RGF0YVtfeGZhX29iamVjdC4kdGV4dF0oKTsKICAgICAgICB9IGVsc2UgaWYgKHRoaXMudmFsdWUudGV4dCkgewogICAgICAgICAgdmFsdWUgPSB0aGlzLnZhbHVlLnRleHRbX3hmYV9vYmplY3QuJGdldEV4dHJhXSgpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb25zdCBodG1sVmFsdWUgPSB0aGlzLnZhbHVlW194ZmFfb2JqZWN0LiR0b0hUTUxdKCkuaHRtbDsKICAgICAgICAgIGlmIChodG1sVmFsdWUgIT09IG51bGwpIHsKICAgICAgICAgICAgdmFsdWUgPSBodG1sVmFsdWUuY2hpbGRyZW5bMF0udmFsdWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmICh0aGlzLnVpLnRleHRFZG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9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICBsZXQgcHJvcE5hbWUgPSAiY29sb3IiOwogICAgbGV0IGFsdFByb3BOYW1lID0gcHJvcE5hbWU7CiAgICBpZiAocGFyZW50IGluc3RhbmNlb2YgQm9yZGVyKSB7CiAgICAgIHByb3BOYW1lID0gImJhY2tncm91bmQtY29sb3IiOwogICAgICBhbHRQcm9wTmFtZSA9ICJiYWNrZ3JvdW5kIjsKICAgICAgaWYgKGdncmFuZHBhIGluc3RhbmNlb2YgVWkpIHsKICAgICAgICBzdHlsZS5iYWNrZ3JvdW5kQ29sb3IgPSAid2hpdGUiOwogICAgICB9CiAgICB9CiAgICBpZiAocGFyZW50IGluc3RhbmNlb2YgUmVjdGFuZ2xlIHx8IHBhcmVudCBpbnN0YW5jZW9mIEFyYykgewogICAgICBwcm9wTmFtZSA9IGFsdFByb3BOYW1lID0gImZpbGwiOwogICAgICBzdHlsZS5maWxsID0gIndoaXRlIjsKICAgIH0KICAgIGZvciAoY29uc3QgbmFtZSBvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyh0aGlzKSkgewogICAgICBpZiAobmFtZSA9PT0gImV4dHJhcyIgfHwgbmFtZSA9PT0gImNvbG9yIikgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IG9iaiA9IHRoaXNbbmFtZV07CiAgICAgIGlmICghKG9iaiBpbnN0YW5jZW9mIF94ZmFfb2JqZWN0LlhGQU9iamVjdCkpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBjb2xvciA9IG9ialtfeGZhX29iamVjdC4kdG9TdHlsZV0odGhpcy5jb2xvcik7CiAgICAgIGlmIChjb2xvcikgewogICAgICAgIHN0eWxlW2NvbG9yLnN0YXJ0c1dpdGgoIiMiKSA/IHByb3BOYW1lIDogYWx0UHJvcE5hbWVdID0gY29sb3I7CiAgICAgIH0KICAgICAgcmV0dXJuIHN0eWxlOwogICAgfQogICAgaW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VTaGlmdCk7CiAgICB9CiAgICBzdHlsZS5mb250S2VybmluZyA9IHRoaXMua2VybmluZ01vZGUgPT09ICJub25lIiA/ICJub25lIiA6ICJub3JtYWwiOwogICAgc3R5bGUubGV0dGVyU3BhY2luZyA9ICgwLCBfaHRtbF91dGlscy5tZWFzdXJlVG9TdHJpbmcpKHRoaXMubGV0dGVyU3BhY2luZyk7CiAgICBpZiAodGhpcy5saW5lVGhyb3VnaCAhPT0gMCkgewogICAgICBzdHlsZS50ZXh0RGVjb3JhdGlvbiA9ICJsaW5lLXRocm91Z2giOwogICAgICBpZiAodGhpcy5saW5lVGhyb3VnaCA9PT0gMikgewogICAgICAgIHN0eWxlLnRleHREZWNvcmF0aW9uU3R5bGUgPSAiZG91YmxlIjsKICAgICAgfQogICAgfQogICAgaWYgKHRoaXMub3ZlcmxpbmUgIT09IDApIHsKICAgICAgc3R5bGUudGV4dERlY29yYXRpb24gPSAib3ZlcmxpbmUiOwogICAgICBpZiAodGhpcy5vdmVybGluZSA9PT0gMikgewogICAgICAgIHN0eWxlLnRleHREZWNvcmF0aW9uU3R5bGUgPSAiZG91YmxlIjsKICAgICAgfQogICAgfQogICAgc3R5bGUuZm9udFN0eWxlID0gdGhpcy5wb3N0dXJlOwogICAgc3R5bGUuZm9udFNpemUgPSAoMCwgX2h0bWxfdXRpbHMubWVhc3VyZVRvU3RyaW5nKSgwLjk5ICogdGhpcy5zaXplKTsKICAgICgwLCBfaHRtbF91dGlscy5zZXRGb250RmFtaWx5KSh0aGlzLCB0aGlzLCB0aGlzW194ZmFfb2JqZWN0LiRnbG9iYWxEYXRhXS5mb250RmluZGVyLCBzdHlsZSk7CiAgICBpZiAodGhpcy51bmRlcmxpbmUgIT09IDApIHsKICAgICAgc3R5bGUudGV4dERlY29yYXRpb24gPSAidW5kZXJsaW5lIjsKICAgICAgaWYgKHRoaXMudW5kZXJsaW5lID09PSAyKSB7CiAgICAgICAgc3R5bGUudGV4dERlY29yYXRpb25TdHlsZSA9ICJ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bnRUeXBlKSB7CiAgICAgICAgcmV0dXJuIF91dGlscy5IVE1MUmVzdWx0LkVNUFRZOwogICAgICB9CiAgICB9CiAgICBjb25zdCBibG9iID0gbmV3IEJsb2IoW2J1ZmZlcl0sIHsKICAgICAgdHlwZTogdGhpcy5jb250ZW50VHlwZQogICAgfSk7CiAgICBsZXQgc3R5bGU7CiAgICBzd2l0Y2ggKHRoaXMuYXNwZWN0KSB7CiAgICAgIGNhc2UgImZpdCI6CiAgICAgIGNhc2UgImFjdHVhbCI6CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgImhlaWdodCI6CiAgICAgICAgc3R5bGUgPSB7CiAgICAgICAgICBoZWlnaHQ6ICIxMDAlIiwKICAgICAgICAgIG9iamVjdEZpdDogImZpbGwiCiAgICAgICAgfTsKICAgICAgICBicmVhazsKICAgICAgY2FzZSAibm9uZSI6CiAgICAgICAgc3R5bGUgPSB7CiAgICAgICAgICB3aWR0aDogIjEwMCUiLAogICAgICAgICAgaGVpZ2h0OiAiMTAwJSIsCiAgICAgICAgICBvYmplY3RGaXQ6ICJmaWxsIgogICAgICAgIH07CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgIndpZHRoIjoKICAgICAgICBzdHlsZSA9IHsKICAgICAgICAgIHdpZHRoOiAiMTAwJSIsCiAgICAgICAgICBvYmplY3RGaXQ6ICJmaWxsIgogICAgICAgIH07CiAgICAgICAgYnJlYWs7CiAgICB9CiAgICBjb25zdCBwYXJlbnQgPSB0aGlzW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCk7CiAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuc3VjY2Vzcyh7CiAgICAgIG5hbWU6ICJpbWciLAogICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgY2xhc3M6IFsieGZhSW1hZ2UiXSwKICAgICAgICBzdHlsZSwKICAgICAgICBzcmM6IFVSTC5jcmVhdGVPYmplY3RVUkwoYmxvYiksCiAgICAgICAgYWx0OiBw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LCAiNTAlIiwgIjEwMCUiXTsKICAgICAgd2lkdGggPSBzdHlsZS5zdHJva2VXaWR0aDsKICAgIH0gZWxzZSBpZiAocGFyZW50LmggPD0gdGhpY2tuZXNzKSB7CiAgICAgIFt4MSwgeTEsIHgyLCB5Ml0gPSBbMCwgIjUwJSIsICIxMDAlIiwgIjUwJSJdOwogICAgICBoZWlnaHQgPSBzdHlsZS5zdHJva2VXaWR0aDsKICAgIH0gZWxzZSB7CiAgICAgIGlmICh0aGlzLnNsb3BlID09PSAiXFwiKSB7CiAgICAgICAgW3gxLCB5MSwgeDIsIHkyXSA9IFswLCAwLCAiMTAwJSIsICIxMDAlIl07CiAgICAgIH0gZWxzZSB7CiAgICAgICAgW3gxLCB5MSwgeDIsIHkyXSA9IFswLCAiMTAwJSIsICIxMDAlIiwgMF07CiAgICAgIH0KICAgIH0KICAgIGNvbnN0IGxpbmUgPSB7CiAgICAgIG5hbWU6ICJsaW5lIiwKICAgICAgYXR0cmlidXRlczogewogICAgICAgIHhtbG5zOiBTVkdfTlMsCiAgICAgICAgeDEsCiAgICAgICAgeTEsCiAgICAgICAgeDIsCiAgICAgICAgeTIsCiAgICAgICAgc3R5bGUKICAgICAgfQogICAgfTsKICAgIGNvbnN0IHN2ZyA9IHsKICAgICAgbmFtZTogInN2ZyIsCiAgICAgIGNoaWxkcmVuOiBbbGluZV0sCiAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICB4bWxuczogU1ZHX05TLAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBzdHlsZTogewogICAgICAgICAgb3ZlcmZsb3c6ICJ2aXNpYmxlIgogICAgICAgIH0KICAgICAgfQogICAgfTsKICAgIGlmIChoYXNNYXJnaW4ocGFyZW50KSkgewogICAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuc3VjY2Vzcyh7CiAgICAgICAgbmFtZTogImRpdiIsCiAgICAgICAgYXR0cmlidXRlczogewogICAgICAgICAgc3R5bGU6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gY29ybmVyID0gdGhpcy5jb3JuZXIuY2hpbGRyZW4ubGVuZ3RoID8gdGhpcy5jb3JuZXIuY2hpbGRyZW5bMF0gOiBuZXcgQ29ybmVyKHt9KTsKICAgIGNvbnN0IGNvcm5lclN0eWxlID0gY29ybmVyW194ZmFfb2JqZWN0LiR0b1N0eWxlXSgpOwogICAgY29uc3QgcmVjdCA9IHsKICAgICAgbmFtZTogInJlY3QiLAogICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgeG1sbnM6IFNWR19OUywKICAgICAgICB3aWR0aDogIjEwMCUiLAogICAgICAgIGhlaWdodDogIjEwMCUiLAogICAgICAgIHg6IDAsCiAgICAgICAgeTogMCwKICAgICAgICByeDogY29ybmVyU3R5bGUucmFkaXVzLAogICAgICAgIHJ5OiBjb3JuZXJTdHlsZS5yYWRpdXMsCiAgICAgICAgc3R5bGUKICAgICAgfQogICAgfTsKICAgIGNvbnN0IHN2ZyA9IHsKICAgICAgbmFtZTogInN2ZyIsCiAgICAgIGNoaWxkcmVuOiBbcmVjdF0sCiAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICB4bWxuczogU1ZHX05TLAogICAgICAgIHN0eWxlOiB7CiAgICAgICAgICBvdmVyZmxvdzogInZpc2libGUiCiAgICAgICAgfSwKICAgICAgICB3aWR0aDogIjEwMCUiLAogICAgICAgIGhlaWdodDogIjEwMCUiCiAgICAgIH0KICAgIH07CiAgICBjb25zdCBwYXJlbnQgPSB0aGlzW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKClbX3hmYV9vYmplY3QuJGdldFBhcmVudF0oKTsKICAgIGlmIChoYXNNYXJnaW4ocGFyZW50KSkgewogICAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuc3VjY2Vzcyh7CiAgICAgICAgbmFtZTogImRpdiIsCiAgICAgICAgYXR0cmlidXRlczogewogICAgICAgICAgc3R5bGU6IHsKICAgICAgICAgICAgZGlzcGxheTogImlubGluZSIsCiAgICAgICAgIC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3V0RmFpbHVyZSA9IGZhbHNlOwogICAgICBjb25zdCBmbHVzaCA9IGluZGV4ID0+IHsKICAgICAgICBjb25zdCBodG1sID0gcm9vdFtfeGZhX29iamVjdC4kZmx1c2hIVE1MXSgpOwogICAgICAgIGlmIChodG1sKSB7CiAgICAgICAgICBoYXNTb21ldGhpbmcgPSBoYXNTb21ldGhpbmcgfHwgaHRtbC5jaGlsZHJlbiAmJiBodG1sLmNoaWxkcmVuLmxlbmd0aCAhPT0gMDsKICAgICAgICAgIGh0bWxDb250ZW50QXJlYXNbaW5kZXhdLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgICAgICAgfQogICAgICB9OwogICAgICBmb3IgKGxldCBpID0gc3RhcnRJbmRleCwgaWkgPSBjb250ZW50QXJlYXMubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgIGNvbnN0IGNvbnRlbnRBcmVhID0gdGhpc1tfeGZhX29iamVjdC4kZXh0cmFdLmN1cnJlbnRDb250ZW50QXJlYSA9IGNvbnRlbnRBcmVhc1tpXTsKICAgICAgICBjb25zdCBzcGFjZSA9IHsKICAgICAgICAgIHdpZHRoOiBjb250ZW50QXJlYS53LAogICAgICAgICAgaGVpZ2h0OiBjb250ZW50QXJlYS5oCiAgICAgICAgfTsKICAgICAgICBzdGFydEluZGV4ID0gMDsKICAgICAgICBpZiAobGVhZGVyKSB7CiAgICAgICAgICBodG1sQ29udGVudEFyZWFzW2ldLmNoaWxkcmVuLnB1c2gobGVhZGVyW194ZmFfb2JqZWN0LiR0b0hUTUxdKHNwYWNlKS5odG1sKTsKICAgICAgICAgIGxlYWRlciA9IG51bGw7CiAgICAgICAgfQogICAgICAgIGlmICh0cmFpbGVyKSB7CiAgICAgICAgICBodG1sQ29udGVudEFyZWFzW2ldLmNoaWxkcmVuLnB1c2godHJhaWxlcltfeGZhX29iamVjdC4kdG9IVE1MXShzcGFjZSkuaHRtbCk7CiAgICAgICAgICB0cmFpbGVyID0gbnVsbDsKICAgICAgICB9CiAgICAgICAgY29uc3QgaHRtbCA9IHJvb3RbX3hmYV9vYmplY3QuJHRvSFRNTF0oc3BhY2UpOwogICAgICAgIGlmIChodG1sLnN1Y2Nlc3MpIHsKICAgICAgICAgIGlmIChodG1sLmh0bWwpIHsKICAgICAgICAgICAgaGFzU29tZXRoaW5nID0gaGFzU29tZXRoaW5nIHx8IGh0bWwuaHRtbC5jaGlsZHJlbiAmJiBodG1sLmh0bWwuY2hpbGRyZW4ubGVuZ3RoICE9PSAwOwogICAgICAgICAgICBodG1sQ29udGVudEFyZWFzW2ldLmNoaWxkcmVuLnB1c2goaHRtbC5odG1sKTsKICAgICAgICAgIH0gZWxzZSBpZiAoIWhhc1NvbWV0aGluZyAmJiBtYWluSHRtbC5jaGlsZHJlbi5sZW5ndGggPiAxKSB7CiAgICAgICAgICAgIG1haW5IdG1sLmNoaWxkcmVuLnBvcCgpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG1haW5IdG1sOwogICAgICAgIH0KICAgICAgICBpZiAoaHRtbC5pc0JyZWFrKCkpIHsKICAgICAgICAgIGNvbnN0IG5vZGUgPSBodG1sLmJyZWFrTm9kZTsKICAgICAgICAgIGZsdXNoKGkpOwogICAgICAgICAgaWYgKG5vZGUudGFyZ2V0VHlwZSA9PT0gImF1dG8iKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG5vZGUubGVhZGVyKSB7CiAgICAgICAgICAgIGxlYWRlciA9IHRoaXNbX3hmYV9vYmplY3QuJHNlYXJjaE5vZGVdKG5vZGUubGVhZGVyLCBub2RlW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCkpOwogICAgICAgICAgICBsZWFkZXIgPSBsZWFkZXIgPyBsZWFkZXJbMF0gOiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG5vZGUudHJhaWxlcikgewogICAgICAgICAgICB0cmFpbGVyID0gdGhpc1tfeGZhX29iamVjdC4kc2VhcmNoTm9kZV0obm9kZS50cmFpbGVyLCBub2RlW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCkpOwogICAgICAgICAgICB0cmFpbGVyID0gdHJhaWxlciA/IHRyYWlsZXJbMF0gOiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG5vZGUudGFyZ2V0VHlwZSA9PT0gInBhZ2VBcmVhIikgewogICAgICAgICAgICB0YXJnZXRQYWdlQXJlYSA9IG5vZGVbX3hmYV9vYmplY3QuJGV4dHJhXS50YXJnZXQ7CiAgICAgICAgICAgIGkgPSBJbmZpbml0eTsKICAgICAgICAgIH0gZWxzZSBpZiAoIW5vZGVbX3hmYV9vYmplY3QuJGV4dHJhXS50YXJnZXQpIHsKICAgICAgICAgICAgaSA9IG5vZGVbX3hmYV9vYmplY3QuJGV4dHJhXS5pbmRleDsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRhcmdldFBhZ2VBcmVhID0gbm9kZVtfeGZhX29iamVjdC4kZXh0cmFdLnRhcmdldDsKICAgICAgICAgICAgc3RhcnRJbmRleCA9IG5vZGVbX3hmYV9vYmplY3QuJGV4dHJhXS5pbmRleCArIDE7CiAgICAgICAgICAgIGkgPSBJbmZpbml0eTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBpZiAodGhpc1tfeGZhX29iamVjdC4kZXh0cmFdLm92ZXJmbG93Tm9kZSkgewogICAgICAgICAgY29uc3Qgbm9kZSA9IHRoaXNbX3hmYV9vYmplY3QuJGV4dHJhXS5vdmVyZmxvd05vZGU7CiAgICAgICAgICB0aGlzW194ZmFfb2JqZWN0LiRleHRyYV0ub3ZlcmZsb3dOb2RlID0gbnVsbDsKICAgICAgICAgIGNvbnN0IG92ZXJmbG93RXh0cmEgPSBub2RlW194ZmFfb2JqZWN0LiRnZXRFeHRyYV0oKTsKICAgICAgICAgIGNvbnN0IHRhcmdldCA9IG92ZXJmbG93RXh0cmEudGFyZ2V0OwogICAgICAgICAgb3ZlcmZsb3dFeHRyYS5hZGRMZWFkZXIgPSBvdmVyZmxvd0V4dHJhLmxlYWRlciAhPT0gbnVsbDsKICAgICAgICAgIG92ZXJmbG93RXh0cmEuYWRkVHJhaWxlciA9IG92ZXJmbG93RXh0cmEudHJhaWxlciAhPT0gbnVsbDsKICAgICAgICAgIGZsdXNoKGkpOwogICAgICAgICAgY29uc3QgY3VycmVudEluZGV4ID0gaTsKICAgICAgICAgIGkgPSBJbmZpbml0eTsKICAgICAgICAgIGlmICh0YXJnZXQgaW5zdGFuY2VvZiBQYWdlQXJlYSkgewogICAgICAgICAgICB0YXJnZXRQYWdlQXJlYSA9IHRhcmdldDsKICAgICAgICAgIH0gZWxzZSBpZiAodGFyZ2V0IGluc3RhbmNlb2YgQ29udGVudEFyZWEpIHsKICAgICAgICAgICAgY29uc3QgaW5kZXggPSBjb250ZW50QXJlYXMuaW5kZXhPZih0YXJnZXQpOwogICAgICAgICAgICBpZiAoaW5kZXggIT09IC0xKSB7CiAgICAgICAgICAgICAgaWYgKGluZGV4ID4gY3VycmVudEluZGV4KSB7CiAgICAgICAgICAgICAgICBpID0gaW5kZXggLSAxOwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBzdGFydEluZGV4ID0gaW5kZXg7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRhcmdldFBhZ2VBcmVhID0gdGFyZ2V0W194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCk7CiAgICAgICAgICAgICAgc3RhcnRJbmRleCA9IHRhcmdldFBhZ2VBcmVhLmNvbnRlbnRBcmVhLmNoaWxkcmVuLmluZGV4T2YodGFyZ2V0KTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGZsdXNoKGkpOwogICAgICB9CiAgICAgIHRoaXNbX3hmYV9vYmplY3QuJGV4dHJhXS5wY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YWNjLCBsaW5lKSA9PiB7CiAgICAgICAgaWYgKGxpbmUpIHsKICAgICAgICAgIGFjYy5wdXNoKGxpbmUpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gYWNjOwogICAgICB9LCBbXSkuam9pbigiXG4iKTsKICAgIH0KICAgIHJldHVybiB0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XVtfeGZhX29iamVjdC4kdGV4dF0oKTsKICB9CiAgW194ZmFfb2JqZWN0LiR0b0hUTUxdKGF2YWlsYWJsZVNwYWNlKSB7CiAgICBpZiAodHlwZW9mIHRoaXNbX3hmYV9vYmplY3QuJGNvbnRlbnRdID09PSAic3RyaW5nIikgewogICAgICBjb25zdCBodG1sID0gdmFsdWVUb0h0bWwodGhpc1tfeGZhX29iamVjdC4kY29udGVudF0pLmh0bWw7CiAgICAgIGlmICh0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XS5pbmNsdWRlcygiXHUyMDI5IikpIHsKICAgICAgICBodG1sLm5hbWUgPSAiZGl2IjsKICAgICAgICBodG1sLmNoaWxkcmVuID0gW107CiAgICAgICAgdGhpc1tfeGZhX29iamVjdC4kY29udGVudF0uc3BsaXQoIlx1MjAyOSIpLm1hcChwYXJhID0+IHBhcmEuc3BsaXQoL1tcdTIwMjhcbl0vKS5yZWR1Y2UoKGFjYywgbGluZSkgPT4gewogICAgICAgICAgYWNjLnB1c2goewogICAgICAgICAgICBuYW1lOiAic3BhbiIsCiAgICAgICAgICAgIHZhbHVlOiBsaW5lCiAgICAgICAgICB9LCB7CiAgICAgICAgICAgIG5hbWU6ICJiciIKICAgICAgICAgIH0pOwogICAgICAgICAgcmV0dXJuIGFjYzsKICAgICAgICB9LCBbXSkpLmZvckVhY2gobGluZXMgPT4gewogICAgICAgICAgaHRtbC5jaGlsZHJlbi5wdXNoKHsKICAgICAgICAgICAgbmFtZTogInAiLAogICAgICAgICAgICBjaGlsZHJlbjogbGluZXMKICAgICAgICAgIH0pOwogICAgICAgIH0pOwogICAgICB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pcy5tdWx0aUxpbmUgPT09IDEpIHsKICAgICAgaHRtbCA9IHsKICAgICAgICBuYW1lOiAidGV4dGFyZWEiLAogICAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICAgIGRhdGFJZDogZmllbGRbX3hmYV9vYmplY3QuJGRhdGFdICYmIGZpZWxkW194ZmFfb2JqZWN0LiRkYXRhXVtfeGZhX29iamVjdC4kdWlkXSB8fCBmaWVsZFtfeGZhX29iamVjdC4kdWlkXSwKICAgICAgICAgIGZpZWxkSWQ6IGZpZWxkW194ZmFfb2JqZWN0LiR1aWRdLAogICAgICAgICAgY2xhc3M6IFsieGZhVGV4dGZpZWxkIl0sCiAgICAgICAgICBzdHlsZSwKICAgICAgICAgICJhcmlhLWxhYmVsIjogYXJpYUxhYmVsKGZpZWxkKSwKICAgICAgICAgICJhcmlhLXJlcXVpcmVkIjogZmFsc2UKICAgICAgICB9CiAgICAgIH07CiAgICB9IGVsc2UgewogICAgICBodG1sID0gewogICAgICAgIG5hbWU6ICJpbnB1dCIsCiAgICAgICAgYXR0cmlidXRlczogewogICAgICAgICAgdHlwZTogInRleHQiLAogICAgICAgICAgZGF0YUlkOiBmaWVsZFtfeGZhX29iamVjdC4kZGF0YV0gJiYgZmllbGRbX3hmYV9vYmplY3QuJGRhdGFdW194ZmFfb2JqZWN0LiR1aWRdIHx8IGZpZWxkW194ZmFfb2JqZWN0LiR1aWRdLAogICAgICAgICAgZmllbGRJZDogZmllbGRbX3hmYV9vYmplY3QuJHVpZF0sCiAgICAgICAgICBjbGFzczogWyJ4ZmFUZXh0ZmllbGQiXSwKICAgICAgICAgIHN0eWxlLAogICAgICAgICAgImFyaWEtbGFiZWwiOiBhcmlhTGFiZWwoZmllbGQpLAogICAgICAgICAgImFyaWEtcmVxdWlyZWQiOiBmYWxzZQogICAgICAgIH0KICAgICAgfTsKICAgIH0KICAgIGlmIChpc1JlcXVpcmVkKGZpZWxkKSkgewogICAgICBodG1sLmF0dHJpYnV0ZXNbImFyaW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AgICAgZXh0cmEuaGVpZ2h0ID0gTWF0aC5tYXgoZXh0cmEuaGVpZ2h0LCB5ICsgaCk7CiAgICAgICAgZXh0cmEuY2hpbGRyZW4ucHVzaChodG1sKTsKICAgICAgICBicmVhazsKICAgICAgfQogICAgY2FzZSAibHItdGIiOgogICAgY2FzZSAicmwtdGIiOgogICAgICBpZiAoIWV4dHJhLmxpbmUgfHwgZXh0cmEuYXR0ZW1wdCA9PT0gMSkgewogICAgICAgIGV4dHJhLmxpbmUgPSBjcmVhdGVMaW5lKG5vZGUsIFtdKTsKICAgICAgICBleHRyYS5jaGlsZHJlbi5wdXNoKGV4dHJhLmxpbmUpOwogICAgICAgIGV4dHJhLm51bWJlckluTGluZSA9IDA7CiAgICAgIH0KICAgICAgZXh0cmEubnVtYmVySW5MaW5lICs9IDE7CiAgICAgIGV4dHJhLmxpbmUuY2hpbGRyZW4ucHVzaChodG1sKTsKICAgICAgaWYgKGV4dHJhLmF0dGVtcHQgPT09IDApIHsKICAgICAgICBleHRyYS5jdXJyZW50V2lkdGggKz0gdzsKICAgICAgICBleHRyYS5oZWlnaHQgPSBNYXRoLm1heChleHRyYS5oZWlnaHQsIGV4dHJhLnByZXZIZWlnaHQgKyBoKTsKICAgICAgfSBlbHNlIHsKICAgICAgICBleHRyYS5jdXJyZW50V2lkdGggPSB3OwogICAgICAgIGV4dHJhLnByZXZIZWlnaHQgPSBleHRyYS5oZWlnaHQ7CiAgICAgICAgZXh0cmEuaGVpZ2h0ICs9IGg7CiAgICAgICAgZXh0cmEuYXR0ZW1wdCA9IDA7CiAgICAgIH0KICAgICAgZXh0cmEud2lkdGggPSBNYXRoLm1heChleHRyYS53aWR0aCwgZXh0cmEuY3VycmVudFdpZHRoKTsKICAgICAgYnJlYWs7CiAgICBjYXNlICJybC1yb3ciOgogICAgY2FzZSAicm93IjoKICAgICAgewogICAgICAgIGV4dHJhLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgICAgICAgZXh0cmEud2lkdGggKz0g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UubWFyZ2luID8gbm9kZS5tYXJnaW4ubGVmdEluc2V0ICsgbm9kZS5tYXJnaW4ucmlnaHRJbnNldCA6IDA7CiAgc3dpdGNoIChub2RlLmxheW91dCkgewogICAgY2FzZSAibHItdGIiOgogICAgY2FzZSAicmwtdGIiOgogICAgICBpZiAobm9kZVtfeGZhX29iamVjdC4kZXh0cmFdLmF0dGVtcHQgPT09IDApIHsKICAgICAgICByZXR1cm4gewogICAgICAgICAgd2lkdGg6IGF2YWlsYWJsZVNwYWNlLndpZHRoIC0gbWFyZ2luSCAtIG5vZGVbX3hmYV9vYmplY3QuJGV4dHJhXS5jdXJyZW50V2lkdGgsCiAgICAgICAgICBoZWlnaHQ6IGF2YWlsYWJsZVNwYWNlLmhlaWdodCAtIG1hcmdpblYgLSBub2RlW194ZmFfb2JqZWN0LiRleHRyYV0ucHJldkhlaWdodAogICAgICAgIH07CiAgICAgIH0KICAgICAgcmV0dXJuIHsKICAgICAgICB3aWR0aDogYXZhaWxhYmxlU3BhY2Uud2lkdGggLSBtYXJnaW5ILAogICAgICAgIGhlaWdodDogYXZhaWxhYmxlU3BhY2UuaGVpZ2h0IC0gbWFyZ2luViAtIG5vZGVbX3hmYV9vYmplY3QuJGV4dHJhXS5oZWlnaHQKICAgICAgfTsKICAgIGNhc2UgInJsLXJvdyI6CiAgICBjYXNlICJyb3ciOgogICAgICBjb25zdCB3aWR0aCA9IG5vZGVbX3hmYV9vYmplY3QuJGV4dHJhXS5jb2x1bW5XaWR0aHMuc2xpY2Uobm9kZVtfeGZhX29iamVjdC4kZXh0cmFdLmN1cnJlbnRDb2x1bW4pLnJlZHVjZSgoYSwgeCkgPT4gYSArIHgpOwogICAgICByZXR1cm4gewogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodDogYXZhaWxhYmxlU3BhY2UuaGVpZ2h0IC0gbWFyZ2luSAogICAgICB9OwogICAgY2FzZSAidGFibGUiOgogICAgY2FzZSAidGIiOgogICAgICByZXR1cm4gewogICAgICAgI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jYXNlICJ0b3BDZW50ZXIiOgogICAgICBbY2VudGVyWCwgY2VudGVyWV0gPSBbdyAvIDIsIDBdOwogICAgICBicmVhazsKICAgIGNhc2UgInRvcFJpZ2h0IjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gW3csIDBdOwogICAgICBicmVhazsKICB9CiAgbGV0IHgsIHk7CiAgc3dpdGNoIChub2RlLnJvdGF0ZSB8fCAwKSB7CiAgICBjYXNlIDA6CiAgICAgIFt4LCB5XSA9IFstY2VudGVyWCwgLWNlbnRlclldOwogICAgICBicmVhazsKICAgIGNhc2UgOTA6CiAgICAgIFt4LCB5XSA9IFstY2VudGVyWSwgY2VudGVyWF07CiAgICAgIFt3LCBoXSA9IFtoLCAtd107CiAgICAgIGJyZWFrOwogICAgY2FzZSAxODA6CiAgICAgIFt4LCB5XSA9IFtjZW50ZXJYLCBjZW50ZXJZXTsKICAgICAgW3csIGhdID0gWy13LCAtaF07CiAgICAgIGJyZWFrOwogICAgY2FzZSAyNzA6CiAgICAgIFt4LCB5XSA9IFtjZW50ZXJZLCAtY2VudGVyWF07CiAgICAgIFt3LCBoXSA9IFstaCwgd107CiAgICAgIGJyZWFrOwogIH0KICByZXR1cm4gW25vZGUueCArIHggKyBNYXRoLm1pbigwLCB3KSwgbm9kZS55ICsgeSArIE1hdGgubWluKDAsIGgpLCBNYXRoLmFicyh3KSwgTWF0aC5hYnMoaCldOwp9CmZ1bmN0aW9uIGNoZWNrRGltZW5zaW9ucyhub2RlLCBzcGFjZSkgewogIGlmIChub2RlW194ZmFfb2JqZWN0LiRnZXRUZW1wbGF0ZVJvb3RdKClbX3hmYV9vYmplY3QuJGV4dHJhXS5maXJzdFVuc3BsaXR0YWJsZSA9PT0gbnVsbCkgewogICAgcmV0dXJuIHRydWU7CiAgfQogIGlmIChub2RlLncgPT09IDAgfHwgbm9kZS5oID09PSAwKSB7CiAgICByZXR1cm4gdHJ1ZTsKICB9CiAgY29uc3QgRVJST1IgPSAyOwogIGNvbnN0IHBhcmVudCA9IG5vZGVbX3hmYV9vYmplY3QuJGdldFN1YmZvcm1QYXJlbnRdKCk7CiAgY29uc3QgYXR0ZW1wdCA9IHBhcmVudFtfeGZhX29iamVjdC4kZXh0cmFdICYmIHBhcmVudFtfeGZhX29iamVjdC4kZXh0cmFdLmF0dGVtcHQgfHwgMDsKICBjb25zdCBbLCB5LCB3LCBoXSA9IGdldFRyYW5zZm9ybWVkQkJveChub2RlKTsKICBzd2l0Y2ggKHBhcmVudC5sYXlvdXQpIHsKICAgIGNhc2UgImxyLXRiIjoKICAgIGNhc2UgInJsLXRiIjoKICAgICAgaWYgKGF0dGVtcHQgPT09IDApIHsKICAgICAgICBpZiAoIW5vZGVbX3hmYV9vYmplY3QuJGdldFRlbXBsYXRlUm9vdF0oKVtfeGZhX29iamVjdC4kZXh0cmFdLm5vTGF5b3V0RmFpbHVyZSkgewogICAgICAgICAgaWYgKG5vZGUuaCAhPT0gIiIgJiYgTWF0aC5yb3VuZChoIC0gc3BhY2UuaGVpZ2h0KSA+IEVSUk9SKSB7CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChub2RlLncgIT09ICIiKSB7CiAgICAgICAgICAgIGlmIChNYXRoLnJvdW5kKHcgLSBzcGFjZS53aWR0aCkgPD0gRVJST1IpIHsKICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAocGFyZW50W194ZmFfb2JqZWN0LiRleHRyYV0ubnVtYmVySW5MaW5lID09PSAwKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHNwYWNlLmhlaWdodCA+IEVSUk9SOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBzcGFjZS53aWR0aCA+IEVSUk9SOwogICAgICAgIH0KICAgICAgICBpZiAobm9kZS53ICE9PSAiIikgewogICAgICAgICAgcmV0dXJuIE1hdGgucm91bmQodyAtIHNwYWNlLndpZHRoKSA8PSBFUlJPUjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHNwYWNlLndpZHRoID4gRVJST1I7CiAgICAgIH0KICAgICAgaWYgKG5vZGVbX3hmYV9vYmplY3QuJGdldFRlbXBsYXRlUm9vdF0oKVtfeGZhX29iamVjdC4kZXh0cmFdLm5vTGF5b3V0RmFpbHVyZSkgewogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9CiAgICAgIGlmIChub2RlLmggIT09ICIiICYmIE1hdGgucm91bmQoaCAtIHNwYWNlLmhlaWdodCkgPiBFUlJPUikgewogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfQogICAgICBpZiAobm9kZS53ID09PSAiIiB8fCBNYXRoLnJvdW5kKHcgLSBzcGFjZS53aWR0aCkgPD0gRVJST1IpIHsKICAgICAgICByZXR1cm4gc3BhY2UuaGVpZ2h0ID4gRVJST1I7CiAgICAgIH0KICAgICAgaWYgKHBhcmVudFtfeGZhX29iamVjdC4kaXNUaGVyZU1vcmVXaWR0aF0oKSkgewogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfQogICAgICByZXR1cm4gc3BhY2UuaGVpZ2h0ID4gRVJST1I7CiAgICBjYXNlICJ0YWJsZSI6CiAgICBjYXNlICJ0YiI6CiAgICAgIGlmIChub2RlW194ZmFfb2JqZWN0LiRnZXRUZW1wbGF0ZVJvb3RdKClbX3hmYV9vYmplY3QuJGV4dHJhXS5ub0xheW91dEZhaWx1cmUpIHsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfQogICAgICBpZiAobm9kZS5oICE9PSAiIiAmJiAhbm9kZVtfeGZhX29iamVjdC4kaXNTcGxpdHRhYmxlXSgpKSB7CiAgICAgICAgcmV0dXJuIE1hdGgucm91bmQoaCAtIHNwYWNlLmhlaWdodCkgPD0gRVJST1I7CiAgICAgIH0KICAgICAgaWYgKG5vZGUudyA9PT0gIiIgfHwgTWF0aC5yb3VuZ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b3RhdGUobm9kZSwgc3R5bGUpIHsKICAgIGlmIChub2RlLnJvdGF0ZSkgewogICAgICBpZiAoISgidHJhbnNmb3JtIiBpbiBzdHlsZSkpIHsKICAgICAgICBzdHlsZS50cmFuc2Zvcm0gPSAiIjsKICAgICAgfQogICAgICBzdHlsZS50cmFuc2Zvcm0gKz0gYHJvdGF0ZSgtJHtub2RlLnJvdGF0ZX1kZWcpYDsKICAgICAgc3R5bGUudHJhbnNmb3JtT3JpZ2luID0gInRvcCBsZWZ0IjsKICAgIH0KICB9LAogIHByZXNlbmNlKG5vZGUsIHN0eWxlKSB7CiAgICBzd2l0Y2ggKG5vZGUucHJlc2VuY2UpIHsKICAgICAgY2FzZSAiaW52aXNpYmxlIjoKICAgICAgICBzdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgImhpZGRlbiI6CiAgICAgIGNhc2UgImluYWN0aXZlIjoKICAgICAgICBzdHlsZS5kaXNwbGF5ID0gIm5vbmUiOwogICAgICAgIGJyZWFrOwogICAgfQogIH0sCiAgaEFsaWduKG5vZGUsIHN0eWxlKSB7CiAgICBpZiAobm9kZVtfeGZhX29iamVjdC4kbm9kZU5hbWVdID09PSAicGFyYSIpIHsKICAgICAgc3dpdGNoIChub2RlLmhBbGlnbikgewogICAgICAgIGNhc2UgImp1c3RpZnlBbGwiOgogICAgICAgICAgc3R5bGUudGV4dEFsaWduID0gImp1c3RpZnktYWxsIjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJhZGl4IjoKICAgICAgICAgIHN0eWxlLnRleHRBbGlnbiA9ICJsZWZ0IjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICBzdHlsZS50ZXh0QWxpZ24gPSBub2RlLmhBbGlnbjsKICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgc3dpdGNoIChub2RlLmhBbGlnbikgewogICAgICAgIGNhc2UgImxlZnQiOgogICAgICAgICAgc3R5bGUuYWxpZ25TZWxmID0gInN0YXJ0IjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImNlbnRlciI6CiAgICAgICAgICBzdHlsZS5hbGlnblNlbGYgPSAiY2VudGVyIjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJpZ2h0IjoKICAgICAgICAgIHN0eWxlLmFsaWduU2VsZiA9ICJlbmQiOwogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIH0KICB9LAogIG1hcmdpbihub2RlLCBzdHlsZSkgewogICAgaWYgKG5vZGUubWFyZ2luKSB7CiAgICAgIHN0eWxlLm1hcmdpbiA9IG5vZGUubWFyZ2luW194ZmFfb2JqZWN0LiR0b1N0eWxlXSgpLm1hcmdpbjsKICAgIH0KICB9Cn07CmZ1bmN0aW9uIHNldE1pbk1heERpbWVuc2lvbnMobm9kZSwgc3R5bGUpIHsKICBjb25zdCBwYXJlbnQgPSBub2RlW194ZmFfb2JqZWN0LiRnZXRTdWJmb3JtUGFyZW50XSgpOwogIGlmIChwYXJlbnQubGF5b3V0ID09PSAicG9zaXRpb24iKSB7CiAgICBpZiAobm9kZS5taW5XID4gMCkgewogICAgICBzdHlsZS5taW5XaWR0aCA9IG1lYXN1cmVUb1N0cmluZyhub2RlLm1pblcpOwogICAgfQogICAgaWYgKG5vZGUubWF4VyA+IDApIHsKICAgICAgc3R5bGUubWF4V2lkdGggPSBtZWFzdXJlVG9TdHJpbmcobm9kZS5tYXhXKTsKICAgIH0KICAgIGlmIChub2RlLm1pbkggPiAwKSB7CiAgICAgIHN0eWxlLm1pbkhlaWdodCA9IG1lYXN1cmVUb1N0cmluZyhub2RlLm1pbkgpOwogICAgfQogICAgaWYgKG5vZGUubWF4SCA+IDApIHsKICAgICAgc3R5bGUubWF4SGVpZ2h0ID0gbWVhc3VyZVRvU3RyaW5nKG5vZGUubWF4SCk7CiAgICB9CiAgfQp9CmZ1bmN0aW9uIGxheW91dFRleH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PT0gIiIgJiYgbm9kZS5oICE9PSAiIikgewogICAgYmJveCA9IFtub2RlLngsIG5vZGUueSwgbm9kZS53LCBub2RlLmhdOwogIH0gZWxzZSB7CiAgICBpZiAoIWF2YWlsYWJsZVNwYWNlKSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgbGV0IHdpZHRoID0gbm9kZS53OwogICAgaWYgKHdpZHRoID09PSAiIikgewogICAgICBpZiAobm9kZS5tYXhXID09PSAwKSB7CiAgICAgICAgY29uc3QgcGFyZW50ID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0U3ViZm9ybVBhcmVudF0oKTsKICAgICAgICBpZiAocGFyZW50LmxheW91dCA9PT0gInBvc2l0aW9uIiAmJiBwYXJlbnQudyAhPT0gIiIpIHsKICAgICAgICAgIHdpZHRoID0gMDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgd2lkdGggPSBub2RlLm1pblc7CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIHdpZHRoID0gTWF0aC5taW4obm9kZS5tYXhXLCBhdmFpbGFibGVTcGFjZS53aWR0aCk7CiAgICAgIH0KICAgICAgaHRtbC5hdHRyaWJ1dGVzLnN0eWxlLndpZHRoID0gbWVhc3VyZVRvU3RyaW5nKHdpZHRoKTsKICAgIH0KICAgIGxldCBoZWlnaHQgPSBub2RlLmg7CiAgICBpZiAoaGVpZ2h0ID09PSAiIikgewogICAgICBpZiAobm9kZS5tYXhIID09PSAwKSB7CiAgICAgICAgY29uc3QgcGFyZW50ID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0U3ViZm9ybVBhcmVudF0oKTsKICAgICAgICBpZiAocGFyZW50LmxheW91dCA9PT0gInBvc2l0aW9uIiAmJiBwYXJlbnQuaCAhPT0gIiIpIHsKICAgICAgICAgIGhlaWdodCA9IDA7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGhlaWdodCA9IG5vZGUubWluSDsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICA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pZiAobm9kZS5sYXlvdXQgPT09ICJ0YWJsZSIpIHsKICAgIGlmIChub2RlLncgPT09ICIiICYmIEFycmF5LmlzQXJyYXkobm9kZS5jb2x1bW5XaWR0aHMpKSB7CiAgICAgIG5vZGUudyA9IG5vZGUuY29sdW1uV2lkdGhzLnJlZHVjZSgoYSwgeCkgPT4gYSArIHgsIDApOwogICAgfQogIH0KfQpmdW5jdGlvbiBsYXlvdXRDbGFzcyhub2RlKSB7CiAgc3dpdGNoIChub2RlLmxheW91dCkgewogICAgY2FzZSAicG9zaXRpb24iOgogICAgICByZXR1cm4gInhmYVBvc2l0aW9uIjsKICAgIGNhc2UgImxyLXRiIjoKICAgICAgcmV0dXJuICJ4ZmFMclRiIjsKICAgIGNhc2UgInJsLXJvdyI6CiAgICAgIHJldHVybiAieGZhUmxSb3ciOwogICAgY2FzZSAicmwtdGIiOgogICAgICByZXR1cm4gInhmYVJsVGIiOwogICAgY2FzZSAicm93IjoKICAgICAgcmV0dXJuICJ4ZmFSb3ciOwogICAgY2FzZSAidGFibGUiOgogICAgICByZXR1cm4gInhmYVRhYmxlIjsKICAgIGNhc2UgInRiIjoKICAgICAgcmV0dXJuICJ4ZmFUYiI7CiAgICBkZWZhdWx0OgogICAgICByZXR1cm4gInhmYVBvc2l0aW9uIjsKICB9Cn0KZnVuY3Rpb24gdG9TdHlsZShub2RlKSB7CiAgY29uc3Qgc3R5bGUgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogIGZvciAodmFyIF9sZW4gPSBhcmd1bWVudHMubGVuZ3RoLCBuYW1lcyA9IG5ldyBBcnJheShfbGVuID4gMSA/IF9sZW4gLSAxIDogMCksIF9rZXkgPSAxOyBfa2V5IDwgX2xlbjsgX2tleSsrKSB7CiAgICBuYW1lc1tfa2V5IC0gMV0gPSBhcmd1bWVudHNbX2tleV07CiAgfQogIGZvciAoY29uc3QgbmFtZSBvZiBuYW1lcykgewogICAgY29uc3QgdmFsdWUgPSBub2RlW25hbWVdOwogICAgaW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icmVhazsKICAgIH0KICAgIGNvbnN0IGNsYXNzTmFtZXMgPSBbInhmYUJvcmRlciJdOwogICAgaWYgKGlzUHJpbnRPbmx5KG5vZGUuYm9yZGVyKSkgewogICAgICBjbGFzc05hbWVzLnB1c2goInhmYVByaW50T25seSIpOwogICAgfQogICAgY29uc3QgYm9yZGVyID0gewogICAgICBuYW1lOiAiZGl2IiwKICAgICAgYXR0cmlidXRlczogewogICAgICAgIGNsYXNzOiBjbGFzc05hbWVzLAogICAgICAgIHN0eWxlOiB7CiAgICAgICAgICB0b3A6IGAke3RvcH1weGAsCiAgICAgICAgICBsZWZ0OiBgJHtsZWZ0fXB4YCwKICAgICAgICAgIHdpZHRoLAogICAgICAgICAgaGVpZ2h0CiAgICAgICAgfQogICAgICB9LAogICAgICBjaGlsZHJlbjogW10KICAgIH07CiAgICBmb3IgKGNvbnN0IGtleSBvZiBbImJvcmRlciIsICJib3JkZXJXaWR0aCIsICJib3JkZXJDb2xvciIsICJib3JkZXJSYWRpdXMiLCAiYm9yZGVyU3R5bGUiXSkgewogICAgICBpZiAoc3R5bGVba2V5XSAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgYm9yZGVyLmF0dHJpYnV0ZXMuc3R5bGVba2V5XSA9IHN0eWxlW2tleV07CiAgICAgICAgZGVsZXRlIHN0eWxlW2tleV07CiAgICAgIH0KICAgIH0KICAgIHdyYXBwZXIuY2hpbGRyZW4ucHVzaChib3JkZXIsIGh0bWwpOwogIH0gZWxzZSB7CiAgICB3cmFwcGVyLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgfQogIGZvciAoY29uc3Qga2V5IG9mIFsiYmFja2dyb3VuZCIsICJiYWNrZ3JvdW5kQ2xpcCIsICJ0b3AiLCAibGVmdCIsICJ3aWR0aCIsICJoZWlnaHQiLCAibWluV2lkdGgiLCAibWluSGVpZ2h0IiwgIm1heFdpZHRoIiwgIm1heEhlaWdodCIsICJ0cmFuc2Zvcm0iLCAidHJhbnNmb3JtT3Jp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ZvbnQgb2YgdGhpcy5mb250cy52YWx1ZXMoKSkgewogICAgICBpZiAoIXBkZkZvbnQucmVndWxhcikgewogICAgICAgIHBkZkZvbnQucmVndWxhciA9IHBkZkZvbnQuaXRhbGljIHx8IHBkZkZvbnQuYm9sZCB8fCBwZGZGb250LmJvbGRpdGFsaWM7CiAgICAgIH0KICAgIH0KICAgIGlmICghcmVhbGx5TWlzc2luZ0ZvbnRzIHx8IHJlYWxseU1pc3NpbmdGb250cy5zaXplID09PSAwKSB7CiAgICAgIHJldHVybjsKICAgIH0KICAgIGNvbnN0IG15cmlhZCA9IHRoaXMuZm9udHMuZ2V0KCJQZGZKUy1GYWxsYmFjay1QZGZKUy1YRkEiKTsKICAgIGZvciAoY29uc3QgbWlzc2luZyBvZiByZWFsbHlNaXNzaW5nRm9udHMpIHsKICAgICAgdGhpcy5mb250cy5zZXQobWlzc2luZywgbXlyaWFkKTsKICAgIH0KICB9CiAgYWRkUGRmRm9udChwZGZGb250KSB7CiAgICBjb25zdCBjc3NGb250SW5mbyA9IHBkZkZvbnQuY3NzRm9udEluZm87CiAgICBjb25zdCBuYW1lID0gY3NzRm9udEluZm8uZm9udEZhbWlseTsKICAgIGxldCBmb250ID0gdGhpcy5mb250cy5nZXQobmFtZSk7CiAgICBpZiAoIWZvbnQpIHsKICAgICAgZm9udCA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgIHRoaXMuZm9udHMuc2V0KG5hbWUsIGZvbnQpOwogICAgICBpZiAoIXRoaXMuZGVmYXVsdEZvbnQpIHsKICAgICAgICB0aGlzLmRlZmF1bHRGb250ID0gZm9udDsKICAgICAgfQogICAgfQogICAgbGV0IHByb3BlcnR5ID0gIiI7CiAgICBjb25zdCBmb250V2VpZ2h0ID0gcGFyc2VGbG9hdChjc3NGb250SW5mby5mb250V2VpZ2h0KTsKICAgIGlmIChwYXJzZUZsb2F0KGNzc0ZvbnRJbmZvLml0YWxpY0FuZ2xlKSAhPT0gMCkgewogICAgICBwcm9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250OwogICAgfQogICAgY29uc3QgcGF0dGVybiA9IC8sfC18X3wgfGJvbGRpdGFsaWN8Ym9sZHxpdGFsaWN8cmVndWxhcnxpdC9naTsKICAgIGxldCBuYW1lID0gZm9udE5hbWUucmVwbGFjZUFsbChwYXR0ZXJuLCAiIik7CiAgICBmb250ID0gdGhpcy5mb250cy5nZXQobmFtZSk7CiAgICBpZiAoZm9udCkgewogICAgICB0aGlzLmNhY2hlLnNldChmb250TmFtZSwgZm9udCk7CiAgICAgIHJldHVybiBmb250OwogICAgfQogICAgbmFtZSA9IG5hbWUudG9Mb3dlckNhc2UoKTsKICAgIGNvbnN0IG1heWJlID0gW107CiAgICBmb3IgKGNvbnN0IFtmYW1pbHksIHBkZkZvbnRdIG9mIHRoaXMuZm9udHMuZW50cmllcygpKSB7CiAgICAgIGlmIChmYW1pbHkucmVwbGFjZUFsbChwYXR0ZXJuLCAiIikudG9Mb3dlckNhc2UoKS5zdGFydHNXaXRoKG5hbWUpKSB7CiAgICAgICAgbWF5YmUucHVzaChwZGZGb250KTsKICAgICAgfQogICAgfQogICAgaWYgKG1heWJlLmxlbmd0aCA9PT0gMCkgewogICAgICBmb3IgKGNvbnN0IFssIHBkZkZvbnRdIG9mIHRoaXMuZm9udHMuZW50cmllcygpKSB7CiAgICAgICAgaWYgKHBkZkZvbnQucmVndWxhci5uYW1lICYmIHBkZkZvbnQucmVndWxhci5uYW1lLnJlcGxhY2VBbGwocGF0dGVybiwgIiIpLnRvTG93ZXJDYXNlKCkuc3RhcnRzV2l0aChuYW1lKSkgewogICAgICAgICAgbWF5YmUucHVzaChwZGZGb250KTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGlmIChtYXliZS5sZW5ndGggPT09IDApIHsKICAgICAgbmFtZSA9IG5hbWUucmVwbGFjZUFsbCgvcHNtdHxtdC9naSwgIiIpOwogICAgICBmb3IgKGNvbnN0IFtmYW1pbHksIHBkZkZvbnRdIG9mIHRoaXMuZm9udHMuZW50cmllcygpKSB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A+IG1heFdpZHRoKSB7CiAgICAgICAgICB3aWR0aCA9IE1hdGgubWF4KHdpZHRoLCBjdXJyZW50TGluZVdpZHRoKTsKICAgICAgICAgIGN1cnJlbnRMaW5lV2lkdGggPSAwOwogICAgICAgICAgaGVpZ2h0ICs9IGN1cnJlbnRMaW5lSGVpZ2h0OwogICAgICAgICAgY3VycmVudExpbmVIZWlnaHQgPSBnbHlwaEhlaWdodDsKICAgICAgICAgIGxhc3RTcGFjZVBvcyA9IC0xOwogICAgICAgICAgbGFzdFNwYWNlV2lkdGggPSAwOwogICAgICAgICAgaXNCcm9rZW4gPSB0cnVlOwogICAgICAgICAgaXNGaXJzdExpbmUgPSBmYWxzZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY3VycmVudExpbmVIZWlnaHQgPSBNYXRoLm1heChnbHlwaEhlaWdodCwgY3VycmVudExpbmVIZWlnaHQpOwogICAgICAgICAgbGFzdFNwYWNlV2lkdGggPSBjdXJyZW50TGluZVdpZHRoOwogICAgICAgICAgY3VycmVudExpbmVXaWR0aCArPSBnbHlwaFdpZHRoOwogICAgICAgICAgbGFzdFNwYWNlUG9zID0gaTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKGN1cnJlbnRMaW5lV2lkdGggKyBnbHlwaFdpZHRoID4gbWF4V2lkdGgpIHsKICAgICAgICBoZWlnaHQgKz0gY3VycmVudExpbmVIZWlnaHQ7CiAgICAgICAgY3VycmVudExpbmVIZWlnaHQgPSBnbHlwaEhlaWdodDsKICAgICAgICBpZiAobGFzdFNwYWNlUG9zICE9PSAtMSkgewogICAgICAgICAgaSA9IGxhc3RTcGFjZVBvczsKICAgICAgICAgIHdpZHRoID0gTWF0aC5tYXgod2lkdGgsIGxhc3RTcGFjZVdpZHRoKTsKICAgICAgICAgIGN1cnJlbnRMaW5lV2lkdGggPSAwOwogICAgICAgICAgbGFzdFNwYWNlUG9zID0gLTE7CiAgICAgICAgICBsYXN0U3BhY2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tZSA9PT0gInhtbG5zIikgewogICAgICAgIGlmICghbmFtZXNwYWNlKSB7CiAgICAgICAgICBuYW1lc3BhY2UgPSB2YWx1ZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBYRkEgLSBtdWx0aXBsZSBuYW1lc3BhY2UgZGVmaW5pdGlvbiBpbiA8JHt0YWdOYW1lfT5gKTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAobmFtZS5zdGFydHNXaXRoKCJ4bWxuczoiKSkgewogICAgICAgIGNvbnN0IHByZWZpeCA9IG5hbWUuc3Vic3RyaW5nKCJ4bWxuczoiLmxlbmd0aCk7CiAgICAgICAgaWYgKCFwcmVmaXhlcykgewogICAgICAgICAgcHJlZml4ZXMgPSBbXTsKICAgICAgICB9CiAgICAgICAgcHJlZml4ZXMucHVzaCh7CiAgICAgICAgICBwcmVmaXgsCiAgICAgICAgICB2YWx1ZQogICAgICAgIH0pOwogICAgICB9IGVsc2UgewogICAgICAgIGNvbnN0IGkgPSBuYW1lLmluZGV4T2YoIjoiKTsKICAgICAgICBpZiAoaSA9PT0gLTEpIHsKICAgICAgICAgIGF0dHJpYnV0ZU9ialtuYW1lXSA9IHZhbHVlOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBsZXQgbnNBdHRycyA9IGF0dHJpYnV0ZU9ialtfeGZhX29iamVjdC4kbnNBdHRyaWJ1dGVzXTsKICAgICAgICAgIGlmICghbnNBdHRycykgewogICAgICAgICAgICBuc0F0dHJzID0gYXR0cmlidXRlT2JqW194ZmFfb2JqZWN0LiRuc0F0dHJpYnV0ZXNdID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IFtucywgYXR0ck5hbWVdID0gW25hbWUuc2xpY2UoMCwgaSksIG5hbWUuc2xpY2UoaSArIDEpXTsKICAgICAgICAgIGxldCBhdHRycyA9IG5zQXR0cnNbbnNdOwogICAgICAgICAgaWYg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sKICAgICAgICBoYXNOYW1lc3BhY2U6IGhhc05hbWVzcGFjZURlZiwKICAgICAgICBwcmVmaXhlcywKICAgICAgICBuc0Fnbm9zdGljOiBub2RlW194ZmFfb2JqZWN0LiRpc05zQWdub3N0aWNdKCkKICAgICAgfTsKICAgIH0KICAgIHJldHVybiBub2RlOwogIH0KICBpc05zQWdub3N0aWMoKSB7CiAgICByZXR1cm4gdGhpcy5fbnNBZ25vc3RpY0xldmVsID4gMDsKICB9CiAgX3NlYXJjaE5hbWVzcGFjZShuc05hbWUpIHsKICAgIGxldCBucyA9IHRoaXMuX25hbWVzcGFjZXMuZ2V0KG5zTmFtZSk7CiAgICBpZiAobnMpIHsKICAgICAgcmV0dXJuIG5zOwogICAgfQogICAgZm9yIChjb25zdCBbbmFtZSwgewogICAgICBjaGVjawogICAgfV0gb2YgT2JqZWN0LmVudHJpZXMoX25hbWVzcGFjZXMuTmFtZXNwYWNlSWRzKSkgewogICAgICBpZiAoY2hlY2sobnNOYW1lKSkgewogICAgICAgIG5zID0gX3NldHVwLk5hbWVzcGFjZVNldFVwW25hbWVdOwogICAgICAgIGlmIChucykgewogICAgICAgICAgdGhpcy5fbmFtZXNwYWNlcy5zZXQobnNOYW1lLCBucyk7CiAgICAgICAgICByZXR1cm4gbnM7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBucyA9IG5ldyBfdW5rbm93bi5Vbmtub3duTmFtZXNwYWNlKCsrdGhpcy5fbmV4dE5zSWQpOwogICAgdGhpcy5fbmFtZXNwYWNlcy5zZXQobnNOYW1lLCBucyk7CiAgICByZXR1cm4gbnM7CiAgfQogIF9hZGROYW1lc3BhY2VQcmVmaXgocHJlZml4ZXMpIHsKICAgIGZvciAoY29uc3QgewogICAgICBwcmVmaXgsCiAgICAgIHZhbHVlCiAgICB9IG9mIHByZWZpeGVzKSB7CiAgICAgIGNvbnN0IG5hbWVzcGFjZSA9IHRoaXMuX3NlYXJjaE5hbWVzcGFjZSh2YWx1ZSk7CiAgICAgIGxldCBwcmVmaXhTdGFjayA9IHRoaXMuX25hbWVzcGFjZVByZWZpeGVzLmdldChwcmVmaXgpOwogICAgICBpZiAoIXByZWZpeFN0YWNrKSB7CiAgICAgICAgcHJlZml4U3RhY2sgPSBbXTsKICAgICAgICB0aGlzLl9uYW1lc3BhY2VQcmVmaXhlcy5zZXQocHJlZml4LCBwcmVmaXhTdGFjayk7CiAgICAgIH0KICAgICAgcHJlZml4U3RhY2sucHVzaChuYW1lc3BhY2UpOwogICAgfQogIH0KICBfZ2V0TmFtZXNwYWNlVG9Vc2UocHJlZml4KSB7CiAgICBpZiAoIXByZWZpeCkgewogICAgICByZXR1cm4gdGhpcy5fY3VycmVudE5hbWVzcGFjZTsKICAgIH0KICAgIGNvbnN0IHByZWZpeFN0YWNrID0gdGhpcy5fbmFtZXNwYWNlUHJlZml4ZXMuZ2V0KHByZWZpeCk7CiAgICBpZiAocHJlZml4U3RhY2sgJiYgcHJlZml4U3RhY2subGVuZ3RoID4gMCkgewogICAgICByZXR1cm4gcHJlZml4U3RhY2suYXQoLTEpOwogICAgfQogICAgKDAsIF91dGlsLndhcm4pKGBVbmtub3duIG5hbWVzcGFjZSBwcmVmaXg6ICR7cHJlZml4fS5gKTsKICAgIHJldHVybiBudWxsOwogIH0KICBjbGVhbihkYXRhKSB7CiAgICBjb25zdCB7CiAgICAgIGhhc05hbWVzcGFjZSwKICAgICAgcHJlZml4ZXMsCiAgICAgIG5zQWdub3N0aWMKICAgIH0gPSBkYXRhOwogICAgaWYgKGhhc05hbWVzcGFjZSkgewogICAgICB0aGlzLl9jdXJyZW50TmFtZXNwYWNlID0gdGhpcy5fbmFtZXNwYWNlU3RhY2sucG9wKCk7CiAgICB9CiAgICBpZiAocHJlZml4ZXMpIHsKICAgICAgcHJlZml4ZXMuZm9yRWFjaChfcmVmMyA9PiB7CiAgICAgICAgbGV0IHsKICAgICAgICAgIHByZWZpeAogICAgICAgIH0gPSBfcmVmMzsKICA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29iamVjdC4kcHVzaEdseXBoc10obWVhc3VyZSkgewogICAgbGV0IG11c3RQb3AgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IHRydWU7CiAgICBjb25zdCB4ZmFGb250ID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgIGNvbnN0IG1hcmdpbiA9IHsKICAgICAgdG9wOiBOYU4sCiAgICAgIGJvdHRvbTogTmFOLAogICAgICBsZWZ0OiBOYU4sCiAgICAgIHJpZ2h0OiBOYU4KICAgIH07CiAgICBsZXQgbGluZUhlaWdodCA9IG51bGw7CiAgICBmb3IgKGNvbnN0IFtrZXksIHZhbHVlXSBvZiB0aGlzLnN0eWxlLnNwbGl0KCI7IikubWFwKHMgPT4gcy5zcGxpdCgiOiIsIDIpKSkgewogICAgICBzd2l0Y2ggKGtleSkgewogICAgICAgIGNhc2UgImZvbnQtZmFtaWx5IjoKICAgICAgICAgIHhmYUZvbnQudHlwZWZhY2UgPSAoMCwgX3V0aWxzLnN0cmlwUXVvdGVzKSh2YWx1ZSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJmb250LXNpemUiOgogICAgICAgICAgeGZhRm9udC5zaXplID0gKDAsIF91dGlscy5nZXRNZWFzdXJlbWVudCkodmFsdWUpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZm9udC13ZWlnaHQiOgogICAgICAgICAgeGZhRm9udC53ZWlnaHQgPSB2YWx1ZTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImZvbnQtc3R5bGUiOgogICAgICAgICAgeGZhRm9udC5wb3N0dXJlID0gdmFsdWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJsZXR0ZXItc3BhY2luZyI6CiAgICAgICAgICB4ZmFGb250LmxldHRlclNwYWNpbmcgPSAoMCwgX3V0aWxzLmdldE1lYXN1cmVtZW50KSh2YWx1ZSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJtYXJnaW4iOgogICAgICAgICAgY29uc3QgdmFsdWVzID0gdmFsdWUuc3BsaXQoLyBcdC8pLm1hcCh4ID0+ICgwLCBfdXRpbHMuZ2V0TWVhc3VyZW1lbnQpKHgpKTsKICAgICAgICAgIHN3aXRjaCAodmFsdWVzLmxlbmd0aCkgewogICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgbWFyZ2luLnRvcCA9IG1hcmdpbi5ib3R0b20gPSBtYXJnaW4ubGVmdCA9IG1hcmdpbi5yaWdodCA9IHZhbHVlc1swXTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgIG1hcmdpbi50b3AgPSBtYXJnaW4uYm90dG9tID0gdmFsdWVzWzBdOwogICAgICAgICAgICAgIG1hcmdpbi5sZWZ0ID0gbWFyZ2luLnJpZ2h0ID0gdmFsdWVzWzFdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDM6CiAgICAgICAgICAgICAgbWFyZ2luLnRvcCA9IHZhbHVlc1swXTsKICAgICAgICAgICAgICBtYXJnaW4uYm90dG9tID0gdmFsdWVzWzJdOwogICAgICAgICAgICAgIG1hcmdpbi5sZWZ0ID0gbWFyZ2luLnJpZ2h0ID0gdmFsdWVzWzFdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDQ6CiAgICAgICAgICAgICAgbWFyZ2luLnRvcCA9IHZhbHVlc1swXTsKICAgICAgICAgICAgICBtYXJnaW4ubGVmdCA9IHZhbHVlc1sxXTsKICAgICAgICAgICAgICBtYXJnaW4uYm90dG9tID0gdmFsdWVzWzJdOwogICAgICAgICAgICAgIG1hcmdpbi5yaWdodCA9IHZhbHVlc1szXTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIm1hcmdpbi10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HJlYW0ucG9zOwogICAgICBlbnRyeVJhbmdlcy5zcGxpY2UoMCwgMik7CiAgICB9CiAgfQogIGluZGV4T2JqZWN0cygpIHsKICAgIGNvbnN0IFRBQiA9IDB4OSwKICAgICAgTEYgPSAweGEsCiAgICAgIENSID0gMHhkLAogICAgICBTUEFDRSA9IDB4MjA7CiAgICBjb25zdCBQRVJDRU5UID0gMHgyNSwKICAgICAgTFQgPSAweDNjOwogICAgZnVuY3Rpb24gcmVhZFRva2VuKGRhdGEsIG9mZnNldCkgewogICAgICBsZXQgdG9rZW4gPSAiIiwKICAgICAgICBjaCA9IGRhdGFbb2Zmc2V0XTsKICAgICAgd2hpbGUgKGNoICE9PSBMRiAmJiBjaCAhPT0gQ1IgJiYgY2ggIT09IExUKSB7CiAgICAgICAgaWYgKCsrb2Zmc2V0ID49IGRhdGEubGVuZ3RoKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgdG9rZW4gKz0gU3RyaW5nLmZyb21DaGFyQ29kZShjaCk7CiAgICAgICAgY2ggPSBkYXRhW29mZnNldF07CiAgICAgIH0KICAgICAgcmV0dXJuIHRva2VuOwogICAgfQogICAgZnVuY3Rpb24gc2tpcFVudGlsKGRhdGEsIG9mZnNldCwgd2hhdCkgewogICAgICBjb25zdCBsZW5ndGggPSB3aGF0Lmxlbmd0aCwKICAgICAgICBkYXRhTGVuZ3RoID0gZGF0YS5sZW5ndGg7CiAgICAgIGxldCBza2lwcGVkID0gMDsKICAgICAgd2hpbGUgKG9mZnNldCA8IGRhdGFMZW5ndGgpIHsKICAgICAgICBsZXQgaSA9IDA7CiAgICAgICAgd2hpbGUgKGkgPCBsZW5ndGggJiYgZGF0YVtvZmZzZXQgKyBpXSA9PT0gd2hhdFtpXSkgewogICAgICAgICAgKytpOwogICAgICAgIH0KICAgICAgICBpZiAoaSA+PSBsZW5ndGgpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBvZmZzZXQrKzsKICAgICAg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J1ZmZlcltwb3NpdGlvbl07CiAgICAgIGlmIChjaCA9PT0gVEFCIHx8IGNoID09PSBMRiB8fCBjaCA9PT0gQ1IgfHwgY2ggPT09IFNQQUNFKSB7CiAgICAgICAgKytwb3NpdGlvbjsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoY2ggPT09IFBFUkNFTlQpIHsKICAgICAgICBkbyB7CiAgICAgICAgICArK3Bvc2l0aW9uOwogICAgICAgICAgaWYgKHBvc2l0aW9uID49IGxlbmd0aCkgewogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGNoID0gYnVmZmVyW3Bvc2l0aW9uXTsKICAgICAgICB9IHdoaWxlIChjaCAhPT0gTEYgJiYgY2ggIT09IENSKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCB0b2tlbiA9IHJlYWRUb2tlbihidWZmZXIsIHBvc2l0aW9uKTsKICAgICAgbGV0IG07CiAgICAgIGlmICh0b2tlbi5zdGFydHNXaXRoKCJ4cmVmIikgJiYgKHRva2VuLmxlbmd0aCA9PT0gNCB8fCAvXHMvLnRlc3QodG9rZW5bNF0pKSkgewogICAgICAgIHBvc2l0aW9uICs9IHNraXBVbnRpbChidWZmZXIsIHBvc2l0aW9uLCB0cmFpbGVyQnl0ZXMpOwogICAgICAgIHRyYWlsZXJzLnB1c2gocG9zaXRpb24pOwogICAgICAgIHBvc2l0aW9uICs9IHNraXBVbnRpbChidWZmZXIsIHBvc2l0aW9uLCBzdGFydHhyZWZCeXRlcyk7CiAgICAgIH0gZWxzZSBpZiAobSA9IG9ialJlZ0V4cC5leGVjKHRva2VuKSkgewogICAgICAgIGNvbnN0IG51bSA9IG1bMV0gfCAwLAogICAgICAgICAgZ2VuID0gbVsyXSB8IDA7CiAgICAgICAgY29uc3Qgc3RhcnRQb3MgPSBwb3NpdGlvbiArIHRva2VuLmxlbmd0aDsKICAgICAgICBsZXQgY29udGVudExlbmd0aCwKICAgICAgICAgIHVwZGF0ZUVudHJpZXMgPSBmYWxzZTsKICAgICAgICBpZiAoIXRoaXMuZW50cmllc1tudW1dKSB7CiAgICAgICAgICB1cGRhdGVFbnRyaWVzID0gdHJ1ZTsKICAgICAgICB9IGVsc2UgaWYgKHRoaXMuZW50cmllc1tudW1dLmdlbiA9PT0gZ2VuKSB7CiAgICAgICAgICB0cnkgewogICAgICAgICAgICBjb25zdCBwYXJzZXIgPSBuZXcgX3BhcnNlci5QYXJzZXIoewogICAgICAgICAgICAgIGxleGVyOiBuZXcgX3BhcnNlci5MZXhlcihzdHJlYW0ubWFrZVN1YlN0cmVhbShzdGFydFBvcykpCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBwYXJzZXIuZ2V0T2JqKCk7CiAgICAgICAgICAgIHVwZGF0ZUVudHJpZXMgPSB0cnVlOwogICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuUGFyc2VyRU9GRXhjZXB0aW9uKSB7CiAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBpbmRleE9iamVjdHMgLS0gY2hlY2tpbmcgb2JqZWN0ICgke3Rva2VufSk6ICIke2V4fSIuYCk7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdXBkYXRlRW50cmllcyA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHVwZGF0ZUVudHJpZXMpIHsKICAgICAgICAgIHRoaXMuZW50cmllc1tudW1dID0gewogICAgICAgICAgICBvZmZzZXQ6IHBvc2l0aW9uIC0gc3RyZWFtLnN0YXJ0LAogICAgICAgICAgICBnZW4sCiAgICAgICAgICAgIHVuY29tcHJlc3NlZDogdHJ1ZQogICAgICAgICAgfTsKICAgICAgICB9CiAgICAgICAgZ0VuZG9ialJlZ0V4cC5sYXN0SW5kZXggPSBzdGFydFBvczsKICAgICAgICBjb25zdCBtYXRjaCA9IGdFbmRvYmpSZWdFeHAuZXhlYyhidWZmZXJTdHIpOwogICAgICAgIGlmIChtYXRjaCkgewogICAgICAgICAgY29uc3QgZW5kUG9zID0gZ0VuZG9ialJlZ0V4cC5sYXN0SW5kZXggKyAxOwogICAgICAgICAgY29udGVudExlbmd0aCA9IGVuZFBvcyAtIHBvc2l0aW9uOwogICAgICAgICAgaWYgKG1hdGNoWzFdICE9PSAiZW5kb2JqIikgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYGluZGV4T2JqZWN0czogRm91bmQgIiR7bWF0Y2hbMV19IiBpbnNpZGUgb2YgYW5vdGhlciAib2JqIiwgYCArICdjYXVzZWQgYnkgbWlzc2luZyAiZW5kb2JqIiAtLSB0cnlpbmcgdG8gcmVjb3Zlci4nKTsKICAgICAgICAgICAgY29udGVudExlbmd0aCAtPSBtYXRjaFsxXS5sZW5ndGggKyAxOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb250ZW50TGVuZ3RoID0gbGVuZ3RoIC0gcG9zaXRpb247CiAgICAgICAgfQogICAgICAgIGNvbnN0IGNvbnRlbnQgPSBidWZmZXIuc3ViYXJyYXkocG9zaXRpb24sIHBvc2l0aW9uICsgY29udGVudExlbmd0aCk7CiAgICAgICAgY29uc3QgeHJlZlRhZ09mZnNldCA9IHNraXBVbnRpbChjb250ZW50LCAwLCB4cmVmQnl0ZXMpOwogICAgICAgIGlmICh4cmVmVGFnT2Zmc2V0IDwgY29udGVudExlbmd0aCAmJiBjb250ZW50W3hyZWZUYWdPZmZzZXQgKyA1XSA8IDY0KSB7CiAgICAgICAgICB4cmVmU3Rtcy5wdXNoKHBvc2l0aW9uIC0gc3RyZWFtLnN0YXJ0KTsKICAgICAgICAgIHRoaXMuX3hyZWZTdG1zLmFkZChwb3NpdGlvbiAtIHN0cmVhbS5zdGFydCk7CiAgICAgICAgfQogICAgICAgIHBvc2l0aW9uICs9IGNvbnRlbnRMZW5ndGg7CiAgICAgIH0gZWxzZSBpZiAodG9rZW4uc3RhcnRzV2l0aCgidHJhaWxlciIpICYmICh0b2tlbi5sZW5ndGggPT09IDcgfHwgL1xzLy50ZXN0KHRva2VuWzddKSkpIHsKICAgICAgICB0cmFpbGVycy5wdXNoKHBvc2l0aW9uKTsKICAgICAgICBjb25zdCBzdGFydFBvcyA9IHBvc2l0aW9uICsgdG9rZW4ubGVuZ3RoOwogICAgICAgIGxldCBjb250ZW50TGVuZ3RoOwogICAgICAgIGdTdGFydHhyZWZSZWdFeHAubGFzdEluZGV4ID0gc3RhcnRQb3M7CiAgICAgICAgY29uc3QgbWF0Y2ggPSBnU3RhcnR4cmVmUmVnRXhwLmV4ZWMoYnVmZmVyU3RyKTsKICAgICAgICBpZiAobWF0Y2gpIHsKICAgICAgICAgIGNvbnN0IGVuZFBvcyA9IGdTdGFydHhyZWZSZWdFeHAubGFzdEluZGV4ICsgMTsKICAgICAgICAgIGNvbnRlbnRMZW5ndGggPSBlbmRQb3MgLSBwb3NpdGlvbjsKICAgICAgICAgIGlmIChtYXRjaFsxXSAhPT0gInN0YXJ0eHJlZiIpIHsKICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBpbmRleE9iamVjdHM6IEZvdW5kICIke21hdGNoWzFdfSIgYWZ0ZXIgInRyYWlsZXIiLCBgICsgJ2NhdXNlZCBieSBtaXNzaW5nICJzdGFydHhyZWYiIC0tIHRyeWluZyB0byByZWNvdmVyLicpOwogICAgICAgICAgICBjb250ZW50TGVuZ3RoIC09IG1hdGNoWzFdLmxlbmd0aCArIDE7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGNvbnRlbnRMZW5ndGggPSBsZW5ndGggLSBwb3NpdGlvbjsKICAgICAgICB9CiAgICAgICAgcG9zaXRpb24gKz0gY29udGVudExlbmd0aDsKICAgICAgfSBlbHNlIHsKICAgICAgICBwb3NpdGlvbiArPSB0b2tlbi5sZW5ndGggKyAxOwogICAgICB9CiA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4udHJhaWxlckRpY3RzXSkgewogICAgICBpZiAoZGljdCA9PT0gImdlbkZhbGxiYWNrIikgewogICAgICAgIGlmICghdHJhaWxlckVycm9yKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgdGhpcy5fZ2VuZXJhdGlvbkZhbGxiYWNrID0gdHJ1ZTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBsZXQgdmFsaWRQYWdlc0RpY3QgPSBmYWxzZTsKICAgICAgdHJ5IHsKICAgICAgICBjb25zdCByb290RGljdCA9IGRpY3QuZ2V0KCJSb290Iik7CiAgICAgICAgaWYgKCEocm9vdERpY3QgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHBhZ2VzRGljdCA9IHJvb3REaWN0LmdldCgiUGFnZXMiKTsKICAgICAgICBpZiAoIShwYWdlc0RpY3QgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHBhZ2VzQ291bnQgPSBwYWdlc0RpY3QuZ2V0KCJDb3VudCIpOwogICAgICAgIGlmIChOdW1iZXIuaXNJbnRlZ2VyKHBhZ2VzQ291bnQpKSB7CiAgICAgICAgICB2YWxpZFBhZ2VzRGljdCA9IHRydWU7CiAgICAgICAgfQogICAgICB9IGNhdGNoIChleCkgewogICAgICAgIHRyYWlsZXJFcnJvciA9IGV4OwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmICh2YWxpZFBhZ2VzRGljdCAmJiAoIWlzRW5jcnlwdGVkIHx8IGRpY3QuaGFzKCJFbmNyeXB0IikpICYmIGRpY3QuaGFzKCJJRCIpKSB7CiAgICAgICAgcmV0dXJuIGRpY3Q7CiAgICAgIH0KICAgICAgdHJhaWxlckRpY3QgPSBkaWN0OwogICAgfQogICAgaWYgKHRyYWl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VhbShvYmopOwogICAgICAgICAgaWYgKCF0aGlzLnRvcERpY3QpIHsKICAgICAgICAgICAgdGhpcy50b3BEaWN0ID0gZGljdDsKICAgICAgICAgIH0KICAgICAgICAgIGlmICghZGljdCkgewogICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIkZhaWxlZCB0byByZWFkIFhSZWYgc3RyZWFtIik7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBYUmVmIHN0cmVhbSBoZWFkZXIiKTsKICAgICAgICB9CiAgICAgICAgb2JqID0gZGljdC5nZXQoIlByZXYiKTsKICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihvYmopKSB7CiAgICAgICAgICB0aGlzLnN0YXJ0WFJlZlF1ZXVlLnB1c2gob2JqKTsKICAgICAgICB9IGVsc2UgaWYgKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgdGhpcy5zdGFydFhSZWZRdWV1ZS5wdXNoKG9iai5udW0pOwogICAgICAgIH0KICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgIGlmIChlIGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuTWlzc2luZ0RhdGFFeGNlcHRpb24pIHsKICAgICAgICAgIHRocm93IGU7CiAgICAgICAgfQogICAgICAgICgwLCBfdXRpbC5pbmZvKSgiKHdoaWxlIHJlYWRpbmcgWFJlZik6ICIgKyBlKTsKICAgICAgfQogICAgICB0aGlzLnN0YXJ0WFJlZlF1ZXVlLnNoaWZ0KCk7CiAgICB9CiAgICBpZiAodGhpcy50b3BEaWN0KSB7CiAgICAgIHJldHVybiB0aGlzLnRvcERpY3Q7CiAgICB9CiAgICBpZiAocmVjb3ZlcnlNb2RlKSB7CiAgICAgIHJldHVybiB1bmRlZmluZWQ7CiAgICB9CiAgICB0aHJvdyBuZXcgX2NvcmV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lcjogJHtkYXRhLmFjdGlvbn1gKTsKICAgICAgfQogICAgICBpZiAoZGF0YS5jYWxsYmFja0lkKSB7CiAgICAgICAgY29uc3QgY2JTb3VyY2VOYW1lID0gdGhpcy5zb3VyY2VOYW1lOwogICAgICAgIGNvbnN0IGNiVGFyZ2V0TmFtZSA9IGRhdGEuc291cmNlTmFtZTsKICAgICAgICBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSkgewogICAgICAgICAgcmVzb2x2ZShhY3Rpb24oZGF0YS5kYXRhKSk7CiAgICAgICAgfSkudGhlbihmdW5jdGlvbiAocmVzdWx0KSB7CiAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICBzb3VyY2VOYW1lOiBjYlNvdXJjZU5hbWUsCiAgICAgICAgICAgIHRhcmdldE5hbWU6IGNiVGFyZ2V0TmFtZSwKICAgICAgICAgICAgY2FsbGJhY2s6IENhbGxiYWNrS2luZC5EQVRBLAogICAgICAgICAgICBjYWxsYmFja0lkOiBkYXRhLmNhbGxiYWNrSWQsCiAgICAgICAgICAgIGRhdGE6IHJlc3VsdAogICAgICAgICAgfSk7CiAgICAgICAgfSwgZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgc291cmNlTmFtZTogY2JTb3VyY2VOYW1lLAogICAgICAgICAgICB0YXJnZXROYW1lOiBjYlRhcmdldE5hbWUsCiAgICAgICAgICAgIGNhbGxiYWNrOiBDYWxsYmFja0tpbmQuRVJST1IsCiAgICAgICAgICAgIGNhbGxiYWNrSWQ6IGRhdGEuY2FsbGJhY2tJZCwKICAgICAgICAgICAgcmVhc29uOiB3cmFwUmVhc29uKHJlYXNvbikKICAgICAgICAgIH0pOwogICAgICAgIH0pOwogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBpZiAoZGF0YS5zdHJlYW1JZCkgewogICAgICAgIHRoaXMuX2NyZWF0ZVN0cmVh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AgICAgICBpZiAoZGF0YS5zdWNjZXNzKSB7CiAgICAgICAgICBzdHJlYW1Db250cm9sbGVyLnB1bGxDYWxsLnJlc29sdmUoKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgc3RyZWFtQ29udHJvbGxlci5wdWxsQ2FsbC5yZWplY3Qod3JhcFJlYXNvbihkYXRhLnJlYXNvbikpOwogICAgICAgIH0KICAgICAgICBicmVhazsKICAgICAgY2FzZSBTdHJlYW1LaW5kLlBVTEw6CiAgICAgICAgaWYgKCFzdHJlYW1TaW5rKSB7CiAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuUFVMTF9DT01QTEVURSwKICAgICAgICAgICAgc3RyZWFtSWQsCiAgICAgICAgICAgIHN1Y2Nlc3M6IHRydWUKICAgICAgICAgIH0pOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmIChzdHJlYW1TaW5rLmRlc2lyZWRTaXplIDw9IDAgJiYgZGF0YS5kZXNpcmVkU2l6ZSA+IDApIHsKICAgICAgICAgIHN0cmVhbVNpbmsuc2lua0NhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgIH0KICAgICAgICBzdHJlYW1TaW5rLmRlc2lyZWRTaXplID0gZGF0YS5kZXNpcmVkU2l6ZTsKICAgICAgICBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSkgewogICAgICAgICAgcmVzb2x2ZShzdHJlYW1TaW5rLm9uUHVsbCAmJiBzdHJlYW1TaW5rLm9uUHVsbCgpKTsKICAgICAgICB9KS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgIHRhcmdldE5hbWUsCiAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5QVUxMX0NPTVBMRVRFLAogICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgc3VjY2VzczogdHJ1ZQogICAgICAgICAgfSk7CiAgICAgICAgfSwgZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLlBVTExfQ09NUExFVEUsCiAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICByZWFzb246IHdyYXBSZWFzb24ocmVhc29uKQogICAgICAgICAgfSk7CiAgICAgICAgfSk7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgU3RyZWFtS2luZC5FTlFVRVVFOgogICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHN0cmVhbUNvbnRyb2xsZXIsICJlbnF1ZXVlIHNob3VsZCBoYXZlIHN0cmVhbSBjb250cm9sbGVyIik7CiAgICAgICAgaWYgKHN0cmVhbUNvbnRyb2xsZXIuaXNDbG9zZWQpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBzdHJlYW1Db250cm9sbGVyLmNvbnRyb2xsZXIuZW5xdWV1ZShkYXRhLmNodW5rKTsKICAgICAgICBicmVhazsKICAgICAgY2FzZSBTdHJlYW1LaW5kLkNMT1NFOgogICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHN0cmVhbUNvbnRyb2xsZXIsICJjbG9zZSBzaG91bGQgaGF2ZSBzdHJlYW0gY29udHJvbGxlciIpOwogICAgICAgIGlmIChzdHJlYW1Db250cm9sbGVyLmlzQ2xvc2VkKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgc3RyZWFtQ29udHJvbGxlci5pc0Nsb3NlZCA9IHRydWU7CiAgICAgICAgc3RyZWFtQ29udHJvbGxlci5j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VhbVNpbmsub25DYW5jZWwod3JhcFJlYXNvbihkYXRhLnJlYXNvbikpKTsKICAgICAgICB9KS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgIHRhcmdldE5hbWUsCiAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5DQU5DRUxfQ09NUExFVEUsCiAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICBzdWNjZXNzOiB0cnVlCiAgICAgICAgICB9KTsKICAgICAgICB9LCBmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuQ0FOQ0VMX0NPTVBMRVRFLAogICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgcmVhc29uOiB3cmFwUmVhc29uKHJlYXNvbikKICAgICAgICAgIH0pOwogICAgICAgIH0pOwogICAgICAgIHN0cmVhbVNpbmsuc2lua0NhcGFiaWxpdHkucmVqZWN0KHdyYXBSZWFzb24oZGF0YS5yZWFzb24pKTsKICAgICAgICBzdHJlYW1TaW5rLmlzQ2FuY2VsbGVkID0gdHJ1ZTsKICAgICAgICBkZWxldGUgdGhpcy5zdHJlYW1TaW5rc1tzdHJlYW1JZF07CiAgICAgICAgYnJlYWs7CiAgICAgIGRlZmF1bHQ6CiAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJVbmV4cGVjdGVkIHN0cmVhbSBjYXNlIik7CiAgICB9CiAgfQogIGFzeW5jIF9kZWxldGVTdHJlYW1Db250cm9sbGVyKHN0cmVhbUNvbnRyb2xsZXIsIHN0cmVhbUlkKSB7CiAgICBhd2FpdCBQcm9taXNlLmFsbFNldHRsZWQoW3N0cmVhbUNvb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24KLyoqKioqKi8gCQlfX3dlYnBhY2tfbW9kdWxlc19fW21vZHVsZUlkXShtb2R1bGUsIG1vZHVsZS5leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKTsKLyoqKioqKi8gCQovKioqKioqLyAJCS8vIFJldHVybiB0aGUgZXhwb3J0cyBvZiB0aGUgbW9kdWxlCi8qKioqKiovIAkJcmV0dXJuIG1vZHVsZS5leHBvcnRzOwovKioqKioqLyAJfQovKioqKioqLyAJCi8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCi8qKioqKiovIAkvKiB3ZWJwYWNrL3J1bnRpbWUvZGVmaW5lIHByb3BlcnR5IGdldHRlcnMgKi8KLyoqKioqKi8gCSgoKSA9PiB7Ci8qKioqKiovIAkJLy8gZGVmaW5lIGdldHRlciBmdW5jdGlvbnMgZm9yIGhhcm1vbnkgZXhwb3J0cwovKioqKioqLyAJCV9fd19wZGZqc19yZXF1aXJlX18uZCA9IChleHBvcnRzLCBkZWZpbml0aW9uKSA9PiB7Ci8qKioqKiovIAkJCWZvcih2YXIga2V5IGluIGRlZmluaXRpb24pIHsKLyoqKioqKi8gCQkJCWlmKF9fd19wZGZqc19yZXF1aXJlX18ubyhkZWZpbml0aW9uLCBrZXkpICYmICFfX3dfcGRmanNfcmVxdWlyZV9fLm8oZXhwb3J0cywga2V5KSkgewovKioqKioqLyAJCQkJCU9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCBrZXksIHsgZW51bWVyYWJsZTogdHJ1ZSwgZ2V0OiBkZWZpbml0aW9uW2tleV0gfSk7Ci8qKioqKiovIAkJCQl9Ci8qKioqKiovIAkJCX0KLyoqKioqKi8gCQl9OwovKioqKioqLyAJfSkoKTsKLyoqKioqKi8gCQovKioqKioqLyAJLyogd2VicGFjay9ydW50aW1lL2hhc093blByb3BlcnR5IHNob3J0aGFuZCAqLwovKioqKioqLyAJKCgpID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3J0c19fOwoKCk9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgdmFsdWU6IHRydWUKfSkpOwpPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIldvcmtlck1lc3NhZ2VIYW5kbGVyIiwgKHsKICBlbnVtZXJhYmxlOiB0cnVlLAogIGdldDogZnVuY3Rpb24gKCkgewogICAgcmV0dXJuIF93b3JrZXIuV29ya2VyTWVzc2FnZUhhbmRsZXI7CiAgfQp9KSk7CnZhciBfd29ya2VyID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKY29uc3QgcGRmanNWZXJzaW9uID0gJzMuNS4xMjInOwpjb25zdCBwZGZqc0J1aWxkID0gJzYyMjQ2NWRjMic7Cn0pKCk7CgovKioqKioqLyAJcmV0dXJuIF9fd2VicGFja19leHBvcnRzX187Ci8qKioqKiovIH0pKCkKOwp9KTsKLy8jIHNvdXJjZU1hcHBpbmdVUkw9cGRmLndvcmtlci5qcy5tYXA=",H=`data:text/javascript;base64,${o}`,K=`data:text/javascript;base64,${h}`;class J{constructor(I,g){C(this,"pdfDoc"),C(this,"pageNumber"),C(this,"total"),C(this,"dom"),C(this,"pdf"),C(this,"onError"),C(this,"onLoad"),C(this,"getPdfPage",G=>new Promise((b,Y)=>{this.pdfDoc?this.pdfDoc.getPage(G).then(W=>{const l=W.getViewport(),d=document.createElement("canvas");this.dom.appendChild(d);const w=d.getContext("2d"),B=document.body.clientWidth-20,[a,M,m,i]=l.viewBox,V=m>B?B/m:1;d.width=m,d.height=i,l.width=m,l.height=i,d.style.width=Math.floor(l.width)*V+"px",d.style.height=Math.floor(l.height)*V+"px";const R={canvasContext:w,viewport:l,transform:[1,0,0,-1,0,l.height]};W.render(R),b({success:!0,data:W})}):Y({success:!1,data:null,message:"pdfDoc is undefined"})})),C(this,"pdfPreview",()=>{N(H).then(()=>{window.pdfjsLib.GlobalWorkerOptions.workerSrc=K,window.pdfjsLib.getDocument(this.pdf).promise.then(async G=>{this.pdfDoc=G,this.total=G.numPages,this.onLoad&&this.onLoad({success:!0,data:this.pdfDoc});for(let b=1;b<=this.total;b++)await this.getPdfPage(b)})}).catch(G=>{this.onError&&this.onError({success:!1,data:G,message:G})})}),C(this,"prevPage",()=>{this.pageNumber>1?this.pageNumber-=1:this.pageNumber=1,this.getPdfPage(this.pageNumber)}),C(this,"nextPage",()=>{this.pageNumbernew Promise((I,g)=>{const Z=new FileReader;Z.readAsDataURL(A),Z.onload=()=>{I(Z.result)},Z.onerror=c=>{g(c)},Z.onabort=c=>{g(c)}}),u=async(A,I)=>{try{if(typeof window<"u"){const g=await F(A);g&&new J(g,I).pdfPreview()}}catch{}};export{u as renderPdf}; +import{l as N}from"./index.MWfHGcqb.js";import"./framework.CHSXtLMd.js";var s=Object.defineProperty,y=(A,I,g)=>I in A?s(A,I,{enumerable:!0,configurable:!0,writable:!0,value:g}):A[I]=g,C=(A,I,g)=>y(A,typeof I!="symbol"?I+"":I,g);const o="LyoqCiAqIEBsaWNzdGFydCBUaGUgZm9sbG93aW5nIGlzIHRoZSBlbnRpcmUgbGljZW5zZSBub3RpY2UgZm9yIHRoZQogKiBKYXZhU2NyaXB0IGNvZGUgaW4gdGhpcyBwYWdlCiAqCiAqIENvcHlyaWdodCAyMDIzIE1vemlsbGEgRm91bmRhdGlvbgogKgogKiBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKICogeW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgogKiBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKICoKICogICAgIGh0dHA6Ly93d3cuYXBhY2hlLm9yZy9saWNlbnNlcy9MSUNFTlNFLTIuMAogKgogKiBVbmxlc3MgcmVxdWlyZWQgYnkg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RGOFN0cmluZzsKICAgICAgICAgICAgICAgIGV4cG9ydHMudW5yZWFjaGFibGUgPSB1bnJlYWNoYWJsZTsKICAgICAgICAgICAgICAgIGV4cG9ydHMudXRmOFN0cmluZ1RvU3RyaW5nID0gdXRmOFN0cmluZ1RvU3RyaW5nOwogICAgICAgICAgICAgICAgZXhwb3J0cy53YXJuID0gd2FybjsKICAgICAgICAgICAgICAgIGlmICghZ2xvYmFsVGhpcy5fcGRmanNDb21wYXRpYmlsaXR5Q2hlY2tlZCkgewogICAgICAgICAgICAgICAgICAgIGdsb2JhbFRoaXMuX3BkZmpzQ29tcGF0aWJpbGl0eUNoZWNrZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oMik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjb25zdCBJREVOVElUWV9NQVRSSVggPSBbMSwgMCwgMCwgMSwgMCwgMF07CiAgICAgICAgICAgICAgICBleHBvcnRzLklERU5USVRZX01BVFJJWCA9IElERU5USVRZX01BVFJJWDsKICAgICAgICAgICAgICAgIGNvbnN0IEZPTlRfSURFTlRJVFlfTUFUUklYID0gWzAuMDAxLCAwLCAwLCAwLjAwMSwgMCwgMF07CiAgICAgICAgICAgICAgICBleHBvcnRzLkZPTlRfSURFTlRJVFlfTUFUUklYID0gRk9OVF9JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICBjb25zdCBNQVhfSU1BR0VfU0laRV9UT19DQUNIRSA9IDEwZTY7CiAgICAgICAgICAgICAgICBleHBvcnRzLk1BWF9JTUFHRV9TSVpFX1RPX0NBQ0hFID0gTUFYX0lNQUdFX1NJWkVfVE9fQ0FDSEU7CiAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0ZBQ1RPUiA9IDEuMzU7CiAgICAgICAgICAgICAgICBleHBvcnRzLkxJTkVfRkFDVE9SID0gTElORV9GQUNUT1I7CiAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0RFU0NFTlRfRkFDVE9SID0gMC4zNTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuTElORV9ERVNDRU5UX0ZBQ1RPUiA9IExJTkVfREVTQ0VOVF9GQUNUT1I7CiAgICAgICAgICAgICAgICBjb25zdCBCQVNFTElORV9GQUNUT1IgPSBMSU5FX0RFU0NFTlRfRkFDVE9SIC8gTElORV9GQUNUT1I7CiAgICAgICAgICAgICAgICBleHBvcnRzLkJBU0VMSU5FX0ZBQ1RPUiA9IEJBU0VMSU5FX0ZBQ1RPUjsKICAgICAgICAgICAgICAgIGNvbnN0IFJlbmRlcmluZ0ludGVudEZsYWcgPSB7CiAgICAgICAgICAgICAgICAgICAgQU5ZOiAweDAxLAogICAgICAgICAgICAgICAgICAgIERJU1BMQVk6IDB4MDIsCiAgICAgICAgICAgICAgICAgICAgUFJJTlQ6IDB4MDQsCiAgICAgICAgICAgICAgICAgICAgU0FWRTogMHgwOCwKICAgICAgICAgICAgICAgICAgICBBTk5PVEFUSU9OU19GT1JNUzogMHgxMCwKICAgICAgICAgICAgICAgICAgICBBTk5PVEFUSU9OU19TVE9SQUdFOiAweDIwLAogICAgICAgICAgICAgICAgICAgIEFOTk9UQVRJT05TX0RJU0FCTEU6IDB4NDAsCiAgICAgICAgICAgICAgICAgICAgT1BMSVNUOiAweDEwMAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuUmVuZGVyaW5nSW50ZW50RmxhZyA9IFJlbmRlcmluZ0ludGVudEZsYWc7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uTW9kZSA9IHsKICAgICAgICAgICAgICAgICAgICBESVNBQkxFOiAwLAogICAgICAgICAgICAgICAgICAgIEVOQUJMRTogMSwKICAgICAgICAgICAgICAgICAgICBFTkFCTEVfRk9STVM6IDIsCiAgICAgICAgICAgICAgICAgICAgRU5BQkxFX1NUT1JBR0U6IDMKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25Nb2RlID0gQW5ub3RhdGlvbk1vZGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uRWRpdG9yUHJlZml4ID0gInBkZmpzX2ludGVybmFsX2VkaXRvcl8iOwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yUHJlZml4ID0gQW5ub3RhdGlvbkVkaXRvclByZWZpeDsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25FZGl0b3JUeXBlID0gewogICAgICAgICAgICAgICAgICAgIERJU0FCTEU6IC0xLAogICAgICAgICAgICAgICAgICAgIE5PTkU6IDAsCiAgICAgICAgICAgICAgICAgICAgRlJFRVRFWFQ6IDMsCiAgICAgICAgICAgICAgICAgICAgSU5LOiAxNQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvclR5cGUgPSBBbm5vdGF0aW9uRWRpdG9yVHlwZTsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlID0gewogICAgICAgICAgICAgICAgICAgIEZSRUVURVhUX1NJWkU6IDEsCiAgICAgICAgICAgICAgICAgICAgRlJFRVRFWFRfQ09MT1I6IDIsCiAgICAgICAgICAgICAgICAgICAgRlJFRVRFWFRfT1BBQ0lUWTogMywKICAgICAgICAgICAgICAgICAgICBJTktfQ09MT1I6IDExLAogICAgICAgICAgICAgICAgICAgIElOS19USElDS05FU1M6IDEyLAogICAgICAgICAgICAgICAgICAgIElOS19PUEFDSVRZOiAxMwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUgPSBBbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZTsKICAgICAgICAgICAgICAgIGNvbnN0IFBlcm1pc3Npb25GbGFnID0gewogICAgICAgICAgICAgICAgICAgIFBSSU5UOiAweDA0LAogICAgICAgICAgICAgICAgICAgIE1PRElGWV9DT05URU5UUzogMHgwOCwKICAgICAgICAgICAgICAgICAgICBDT1BZOiAweDEwLAogICAgICAgICAgICAgICAgICAgIE1PRElGWV9BTk5PVEFUSU9OUzogMHgyMCwKICAgICAgICAgICAgICAgICAgICBGSUxMX0lOVEVSQUNUSVZFX0ZPUk1TOiAweDEwMCwKICAgICAgICAgICAgICAgICAgICBDT1BZX0ZPUl9BQ0NFU1NJQklMSVRZOiAweDIwMCwKICAgICAgICAgICAgICAgICAgICBBU1NFTUJMRTogMHg0MDAsCiAgICAgICAgICAgICAgICAgICAgUFJJTlRfSElHSF9RVUFMSVRZOiAweDgwMAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuUGVybWlzc2lvbkZsYWcgPSBQZXJtaXNzaW9uRmxhZzsKICAgICAgICAgICAgICAgIGNvbnN0IFRleHRSZW5kZXJpbmdNb2RlID0gewogICAgICAgICAgICAgICAgICAgIEZJTEw6IDAsCiAgICAgICAgICAgICAgICAgICAgU1RST0tFOiAxLAogICAgICAgICAgICAgICAgICAgIEZJTExfU1RST0tFOiAyLAogICAgICAgICAgICAgICAgICAgIElOVklTSUJMRTogMywKICAgICAgICAgICAgICAgICAgICBGSUxMX0FERF9UT19QQVRIOiA0LAogICAgICAgICAgICAgICAgICAgIFNUUk9LRV9BRERfVE9fUEFUSDogNSwKICAgICAgICAgICAgICAgICAgICBGSUxMX1NUUk9LRV9BRERfVE9fUEFUSDogNiwKICAgICAgICAgICAgICAgICAgICBBRERfVE9fUEFUSDogNywKICAgICAgICAgICAgICAgICAgICBGSUxMX1NUUk9LRV9NQVNLOiAzLAogICAgICAgICAgICAgICAgICAgIEFERF9UT19QQVRIX0ZMQUc6IDQKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLlRleHRSZW5kZXJpbmdNb2RlID0gVGV4dFJlbmRlcmluZ01vZGU7CiAgICAgICAgICAgICAgICBjb25zdCBJbWFnZUtpbmQgPSB7CiAgICAgICAgICAgICAgICAgICAgR1JBWVNDQUxFXzFCUFA6IDEsCiAgICAgICAgICAgICAgICAgICAgUkdCXzI0QlBQOiAyLAogICAgICAgICAgICAgICAgICAgIFJHQkFfMzJCUFA6IDMKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkltYWdlS2luZCA9IEltYWdlS2luZDsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25UeXBlID0gewogICAgICAgICAgICAgICAgICAgIFRFWFQ6IDEsCiAgICAgICAgICAgICAgICAgICAgTElOSzogMiwKICAgICAgICAgICAgICAgICAgICBGUkVFVEVYVDogMywKICAgICAgICAgICAgICAgICAgICBMSU5FOiA0LAogICAgICAgICAgICAgICAgICAgIFNRVUFSRTogNSwKICAgICAgICAgICAgICAgICAgICBDSVJDTEU6IDYsCiAgICAgICAgICAgICAgICAgICAgUE9MWUdPTjogNywKICAgICAgICAgICAgICAgICAgICBQT0xZTElORTogOCwKICAgICAgICAgICAgICAgICAgICBISUdITElHSFQ6IDksCiAgICAgICAgICAgICAgICAgICAgVU5ERVJMSU5FOiAxMCwKICAgICAgICAgICAgICAgICAgICBTUVVJR0dMWTogMTEsCiAgICAgICAgICAgICAgICAgICAgU1RSSUtFT1VUOiAxMiwKICAgICAgICAgICAgICAgICAgICBTVEFNUDogMTMsCiAgICAgICAgICAgICAgICAgICAgQ0FSRVQ6IDE0LAogICAgICAgICAgICAgICAgICAgIElOSzogMTUsCiAgICAgICAgICAgICAgICAgICAgUE9QVVA6IDE2LAogICAgICAgICAgICAgICAgICAgIEZJTEVBVFRBQ0hNRU5UOiAxNywKICAgICAgICAgICAgICAgICAgICBTT1VORDogMTgsCiAgICAgICAgICAgICAgICAgICAgTU9WSUU6IDE5LAogICAgICAgICAgICAgICAgICAgIFdJREdFVDogMjAsCiAgICAgICAgICAgICAgICAgICAgU0NSRUVOOiAyMSwKICAgICAgICAgICAgICAgICAgICBQUklOVEVSTUFSSzogMjIsCiAgICAgICAgICAgICAgICAgICAgVFJBUE5FVDogMjMsCiAgICAgICAgICAgICAgICAgICAgV0FURVJNQVJLOiAyNCwKICAgICAgICAgICAgICAgICAgICBUSFJFRUQ6IDI1LAogICAgICAgICAgICAgICAgICAgIFJFREFDVDogMjYKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25UeXBlID0gQW5ub3RhdGlvblR5cGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uU3RhdGVNb2RlbFR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgTUFSS0VEOiAiTWFya2VkIiwKICAgICAgICAgICAgICAgICAgICBSRVZJRVc6ICJSZXZpZXciCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uU3RhdGVNb2RlbFR5cGUgPSBBbm5vdGF0aW9uU3RhdGVNb2RlbFR5cGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uTWFya2VkU3RhdGUgPSB7CiAgICAgICAgICAgICAgICAgICAgTUFSS0VEOiAiTWFya2VkIiwKICAgICAgICAgICAgICAgICAgICBVTk1BUktFRDogIlVubWFya2VkIgogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbk1hcmtlZFN0YXRlID0gQW5ub3RhdGlvbk1hcmtlZFN0YXRlOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvblJldmlld1N0YXRlID0gewogICAgICAgICAgICAgICAgICAgIEFDQ0VQVEVEOiAiQWNjZXB0ZWQiLAogICAgICAgICAgICAgICAgICAgIFJFSkVDVEVEOiAiUmVqZWN0ZWQiLAogICAgICAgICAgICAgICAgICAgIENBTkNFTExFRDogIkNhbmNlbGxlZCIsCiAgICAgICAgICAgICAgICAgICAgQ09NUExFVEVEOiAiQ29tcGxldGVkIiwKICAgICAgICAgICAgICAgICAgICBOT05FOiAiTm9uZSIKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25SZXZpZXdTdGF0ZSA9IEFubm90YXRpb25SZXZpZXdTdGF0ZTsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25SZXBseVR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgR1JPVVA6ICJHcm91cCIsCiAgICAgICAgICAgICAgICAgICAgUkVQTFk6ICJSIgogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvblJlcGx5VHlwZSA9IEFubm90YXRpb25SZXBseVR5cGU7CiAgICAgICAgICAgICAgICBjb25zdCBBbm5vdGF0aW9uRmxhZyA9IHsKICAgICAgICAgICAgICAgICAgICBJTlZJU0lCTEU6IDB4MDEsCiAgICAgICAgICAgICAgICAgICAgSElEREVOOiAweDAyLAogICAgICAgICAgICAgICAgICAgIFBSSU5UOiAweDA0LAogICAgICAgICAgICAgICAgICAgIE5PWk9PTTogMHgwOCwKICAgICAgICAgICAgICAgICAgICBOT1JPVEFURTogMHgxMCwKICAgICAgICAgICAgICAgICAgICBOT1ZJRVc6IDB4MjAsCiAgICAgICAgICAgICAgICAgICAgUkVBRE9OTFk6IDB4NDAsCiAgICAgICAgICAgICAgICAgICAgTE9DS0VEOiAweDgwLAogICAgICAgICAgICAgICAgICAgIFRPR0dMRU5PVklFVzogMHgxMDAsCiAgICAgICAgICAgICAgICAgICAgTE9DS0VEQ09OVEVOVFM6IDB4MjAwCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRmxhZyA9IEFubm90YXRpb25GbGFnOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvbkZpZWxkRmxhZyA9IHsKICAgICAgICAgICAgICAgICAgICBSRUFET05MWTogMHgwMDAwMDAxLAogICAgICAgICAgICAgICAgICAgIFJFUVVJUkVEOiAweDAwMDAwMDIsCiAgICAgICAgICAgICAgICAgICAgTk9FWFBPUlQ6IDB4MDAwMDAwNCwKICAgICAgICAgICAgICAgICAgICBNVUxUSUxJTkU6IDB4MDAwMTAwMCwKICAgICAgICAgICAgICAgICAgICBQQVNTV09SRDogMHgwMDAyMDAwLAogICAgICAgICAgICAgICAgICAgIE5PVE9HR0xFVE9PRkY6IDB4MDAwNDAwMCwKICAgICAgICAgICAgICAgICAgICBSQURJTzogMHgwMDA4MDAwLAogICAgICAgICAgICAgICAgICAgIFBVU0hCVVRUT046IDB4MDAxMDAwMCwKICAgICAgICAgICAgICAgICAgICBDT01CTzogMHgwMDIwMDAwLAogICAgICAgICAgICAgICAgICAgIEVESVQ6IDB4MDA0MDAwMCwKICAgICAgICAgICAgICAgICAgICBTT1JUOiAweDAwODAwMDAsCiAgICAgICAgICAgICAgICAgICAgRklMRVNFTEVDVDogMHgwMTAwMDAwLAogICAgICAgICAgICAgICAgICAgIE1VTFRJU0VMRUNUOiAweDAyMDAwMDAsCiAgICAgICAgICAgICAgICAgICAgRE9OT1RTUEVMTENIRUNLOiAweDA0MDAwMDAsCiAgICAgICAgICAgICAgICAgICAgRE9OT1RTQ1JPTEw6IDB4MDgwMDAwMCwKICAgICAgICAgICAgICAgICAgICBDT01COiAweDEwMDAwMDAsCiAgICAgICAgICAgICAgICAgICAgUklDSFRFWFQ6IDB4MjAwMDAwMCwKICAgICAgICAgICAgICAgICAgICBSQURJT1NJTlVOSVNPTjogMHgyMDAwMDAwLAogICAgICAgICAgICAgICAgICAgIENPTU1JVE9OU0VMQ0hBTkdFOiAweDQwMDAwMDAKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25GaWVsZEZsYWcgPSBBbm5vdGF0aW9uRmllbGRGbGFnOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvbkJvcmRlclN0eWxlVHlwZSA9IHsKICAgICAgICAgICAgICAgICAgICBTT0xJRDogMSwKICAgICAgICAgICAgICAgICAgICBEQVNIRUQ6IDIsCiAgICAgICAgICAgICAgICAgICAgQkVWRUxFRDogMywKICAgICAgICAgICAgICAgICAgICBJTlNFVDogNCwKICAgICAgICAgICAgICAgICAgICBVTkRFUkxJTkU6IDUKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25Cb3JkZXJTdHlsZVR5cGUgPSBBbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlOwogICAgICAgICAgICAgICAgY29uc3QgQW5ub3RhdGlvbkFjdGlvbkV2ZW50VHlwZSA9IHsKICAgICAgICAgICAgICAgICAgICBFOiAiTW91c2UgRW50ZXIiLAogICAgICAgICAgICAgICAgICAgIFg6ICJNb3VzZSBFeGl0IiwKICAgICAgICAgICAgICAgICAgICBEOiAiTW91c2UgRG93biIsCiAgICAgICAgICAgICAgICAgICAgVTogIk1vdXNlIFVwIiwKICAgICAgICAgICAgICAgICAgICBGbzogIkZvY3VzIiwKICAgICAgICAgICAgICAgICAgICBCbDogIkJsdXIiLAogICAgICAgICAgICAgICAgICAgIFBPOiAiUGFnZU9wZW4iLAogICAgICAgICAgICAgICAgICAgIFBDOiAiUGFnZUNsb3NlIiwKICAgICAgICAgICAgICAgICAgICBQVjogIlBhZ2VWaXNpYmxlIiwKICAgICAgICAgICAgICAgICAgICBQSTogIlBhZ2VJbnZpc2libGUiLAogICAgICAgICAgICAgICAgICAgIEs6ICJLZXlzdHJva2UiLAogICAgICAgICAgICAgICAgICAgIEY6ICJGb3JtYXQiLAogICAgICAgICAgICAgICAgICAgIFY6ICJWYWxpZGF0ZSIsCiAgICAgICAgICAgICAgICAgICAgQzogIkNhbGN1bGF0ZSIKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25BY3Rpb25FdmVudFR5cGUgPSBBbm5vdGF0aW9uQWN0aW9uRXZlbnRUeXBlOwogICAgICAgICAgICAgICAgY29uc3QgRG9jdW1lbnRBY3Rpb25FdmVudFR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgV0M6ICJXaWxsQ2xvc2UiLAogICAgICAgICAgICAgICAgICAgIFdTOiAiV2lsbFNhdmUiLAogICAgICAgICAgICAgICAgICAgIERTOiAiRGlkU2F2ZSIsCiAgICAgICAgICAgICAgICAgICAgV1A6ICJXaWxsUHJpbnQiLAogICAgICAgICAgICAgICAgICAgIERQOiAiRGlkUHJpbnQiCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5Eb2N1bWVudEFjdGlvbkV2ZW50VHlwZSA9IERvY3VtZW50QWN0aW9uRXZlbnRUeXBlOwogICAgICAgICAgICAgICAgY29uc3QgUGFnZUFjdGlvbkV2ZW50VHlwZSA9IHsKICAgICAgICAgICAgICAgICAgICBPOiAiUGFnZU9wZW4iLAogICAgICAgICAgICAgICAgICAgIEM6ICJQYWdlQ2xvc2UiCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5QYWdlQWN0aW9uRXZlbnRUeXBlID0gUGFnZUFjdGlvbkV2ZW50VHlwZTsKICAgICAgICAgICAgICAgIGNvbnN0IFZlcmJvc2l0eUxldmVsID0gewogICAgICAgICAgICAgICAgICAgIEVSUk9SUzogMCwKICAgICAgICAgICAgICAgICAgICBXQVJOSU5HUzogMSwKICAgICAgICAgICAgICAgICAgICBJTkZPUzogNQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuVmVyYm9zaXR5TGV2ZWwgPSBWZXJib3NpdHlMZXZlbDsKICAgICAgICAgICAgICAgIGNvbnN0IENNYXBDb21wcmVzc2lvblR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgTk9ORTogMCwKICAgICAgICAgICAgICAgICAgICBCSU5BUlk6IDEKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLkNNYXBDb21wcmVzc2lvblR5cGUgPSBDTWFwQ29tcHJlc3Npb25UeXBlOwogICAgICAgICAgICAgICAgY29uc3QgT1BTID0gewogICAgICAgICAgICAgICAgICAgIGRlcGVuZGVuY3k6IDEsCiAgICAgICAgICAgICAgICAgICAgc2V0TGluZVdpZHRoOiAyLAogICAgICAgICAgICAgICAgICAgIHNldExpbmVDYXA6IDMsCiAgICAgICAgICAgICAgICAgICAgc2V0TGluZUpvaW46IDQsCiAgICAgICAgICAgICAgICAgICAgc2V0TWl0ZXJMaW1pdDogNSwKICAgICAgICAgICAgICAgICAgICBzZXREYXNoOiA2LAogICAgICAgICAgICAgICAgICAgIHNldFJlbmRlcmluZ0ludGVudDogNywKICAgICAgICAgICAgICAgICAgICBzZXRGbGF0bmVzczogOCwKICAgICAgICAgICAgICAgICAgICBzZXRHU3RhdGU6IDksCiAgICAgICAgICAgICAgICAgICAgc2F2ZTogMTAsCiAgICAgICAgICAgICAgICAgICAgcmVzdG9yZTogMTEsCiAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtOiAxMiwKICAgICAgICAgICAgICAgICAgICBtb3ZlVG86IDEzLAogICAgICAgICAgICAgICAgICAgIGxpbmVUbzogMTQsCiAgICAgICAgICAgICAgICAgICAgY3VydmVUbzogMTUsCiAgICAgICAgICAgICAgICAgICAgY3VydmVUbzI6IDE2LAogICAgICAgICAgICAgICAgICAgIGN1cnZlVG8zOiAxNywKICAgICAgICAgICAgICAgICAgICBjbG9zZVBhdGg6IDE4LAogICAgICAgICAgICAgICAgICAgIHJlY3RhbmdsZTogMTksCiAgICAgICAgICAgICAgICAgICAgc3Ryb2tlOiAyMCwKICAgICAgICAgICAgICAgICAgICBjbG9zZVN0cm9rZTogMjEsCiAgICAgICAgICAgICAgICAgICAgZmlsbDogMjIsCiAgICAgICAgICAgICAgICAgICAgZW9GaWxsOiAyMywKICAgICAgICAgICAgICAgICAgICBmaWxsU3Ryb2tlOiAyNCwKICAgICAgICAgICAgICAgICAgICBlb0ZpbGxTdHJva2U6IDI1LAogICAgICAgICAgICAgICAgICAgIGNsb3NlRmlsbFN0cm9rZTogMjYsCiAgICAgICAgICAgICAgICAgICAgY2xvc2VFT0ZpbGxTdHJva2U6IDI3LAogICAgICAgICAgICAgICAgICAgIGVuZFBhdGg6IDI4LAogICAgICAgICAgICAgICAgICAgIGNsaXA6IDI5LAogICAgICAgICAgICAgICAgICAgIGVvQ2xpcDogMzAsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5UZXh0OiAzMSwKICAgICAgICAgICAgICAgICAgICBlbmRUZXh0OiAzMiwKICAgICAgICAgICAgICAgICAgICBzZXRDaGFyU3BhY2luZzogMzMsCiAgICAgICAgICAgICAgICAgICAgc2V0V29yZFNwYWNpbmc6IDM0LAogICAgICAgICAgICAgICAgICAgIHNldEhTY2FsZTogMzUsCiAgICAgICAgICAgICAgICAgICAgc2V0TGVhZGluZzogMzYsCiAgICAgICAgICAgICAgICAgICAgc2V0Rm9udDogMzcsCiAgICAgICAgICAgICAgICAgICAgc2V0VGV4dFJlbmRlcmluZ01vZGU6IDM4LAogICAgICAgICAgICAgICAgICAgIHNldFRleHRSaXNlOiAzOSwKICAgICAgICAgICAgICAgICAgICBtb3ZlVGV4dDogNDAsCiAgICAgICAgICAgICAgICAgICAgc2V0TGVhZGluZ01vdmVUZXh0OiA0MSwKICAgICAgICAgICAgICAgICAgICBzZXRUZXh0TWF0cml4OiA0MiwKICAgICAgICAgICAgICAgICAgICBuZXh0TGluZTogNDMsCiAgICAgICAgICAgICAgICAgICAgc2hvd1RleHQ6IDQ0LAogICAgICAgICAgICAgICAgICAgIHNob3dTcGFjZWRUZXh0OiA0NSwKICAgICAgICAgICAgICAgICAgICBuZXh0TGluZVNob3dUZXh0OiA0NiwKICAgICAgICAgICAgICAgICAgICBuZXh0TGluZVNldFNwYWNpbmdTaG93VGV4dDogNDcsCiAgICAgICAgICAgICAgICAgICAgc2V0Q2hhcldpZHRoOiA0OCwKICAgICAgICAgICAgICAgICAgICBzZXRDaGFyV2lkdGhBbmRCb3VuZHM6IDQ5LAogICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZUNvbG9yU3BhY2U6IDUwLAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDb2xvclNwYWNlOiA1MSwKICAgICAgICAgICAgICAgICAgICBzZXRTdHJva2VDb2xvcjogNTIsCiAgICAgICAgICAgICAgICAgICAgc2V0U3Ryb2tlQ29sb3JOOiA1MywKICAgICAgICAgICAgICAgICAgICBzZXRGaWxsQ29sb3I6IDU0LAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDb2xvck46IDU1LAogICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZUdyYXk6IDU2LAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxHcmF5OiA1NywKICAgICAgICAgICAgICAgICAgICBzZXRTdHJva2VSR0JDb2xvcjogNTgsCiAgICAgICAgICAgICAgICAgICAgc2V0RmlsbFJHQkNvbG9yOiA1OSwKICAgICAgICAgICAgICAgICAgICBzZXRTdHJva2VDTVlLQ29sb3I6IDYwLAogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDTVlLQ29sb3I6IDYxLAogICAgICAgICAgICAgICAgICAgIHNoYWRpbmdGaWxsOiA2MiwKICAgICAgICAgICAgICAgICAgICBiZWdpbklubGluZUltYWdlOiA2MywKICAgICAgICAgICAgICAgICAgICBiZWdpbkltYWdlRGF0YTogNjQsCiAgICAgICAgICAgICAgICAgICAgZW5kSW5saW5lSW1hZ2U6IDY1LAogICAgICAgICAgICAgICAgICAgIHBhaW50WE9iamVjdDogNjYsCiAgICAgICAgICAgICAgICAgICAgbWFya1BvaW50OiA2NywKICAgICAgICAgICAgICAgICAgICBtYXJrUG9pbnRQcm9wczogNjgsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5NYXJrZWRDb250ZW50OiA2OSwKICAgICAgICAgICAgICAgICAgICBiZWdpbk1hcmtlZENvbnRlbnRQcm9wczogNzAsCiAgICAgICAgICAgICAgICAgICAgZW5kTWFya2VkQ29udGVudDogNzEsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5Db21wYXQ6IDcyLAogICAgICAgICAgICAgICAgICAgIGVuZENvbXBhdDogNzMsCiAgICAgICAgICAgICAgICAgICAgcGFpbnRGb3JtWE9iamVjdEJlZ2luOiA3NCwKICAgICAgICAgICAgICAgICAgICBwYWludEZvcm1YT2JqZWN0RW5kOiA3NSwKICAgICAgICAgICAgICAgICAgICBiZWdpbkdyb3VwOiA3NiwKICAgICAgICAgICAgICAgICAgICBlbmRHcm91cDogNzcsCiAgICAgICAgICAgICAgICAgICAgYmVnaW5Bbm5vdGF0aW9uOiA4MCwKICAgICAgICAgICAgICAgICAgICBlbmRBbm5vdGF0aW9uOiA4MSwKICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlTWFza1hPYmplY3Q6IDgzLAogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VNYXNrWE9iamVjdEdyb3VwOiA4NCwKICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlWE9iamVjdDogODUsCiAgICAgICAgICAgICAgICAgICAgcGFpbnRJbmxpbmVJbWFnZVhPYmplY3Q6IDg2LAogICAgICAgICAgICAgICAgICAgIHBhaW50SW5saW5lSW1hZ2VYT2JqZWN0R3JvdXA6IDg3LAogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VYT2JqZWN0UmVwZWF0OiA4OCwKICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlTWFza1hPYmplY3RSZXBlYXQ6IDg5LAogICAgICAgICAgICAgICAgICAgIHBhaW50U29saWRDb2xvckltYWdlTWFzazogOTAsCiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0UGF0aDogOTEKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLk9QUyA9IE9QUzsKICAgICAgICAgICAgICAgIGNvbnN0IFBhc3N3b3JkUmVzcG9uc2VzID0gewogICAgICAgICAgICAgICAgICAgIE5FRURfUEFTU1dPUkQ6IDEsCiAgICAgICAgICAgICAgICAgICAgSU5DT1JSRUNUX1BBU1NXT1JEOiAyCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5QYXNzd29yZFJlc3BvbnNlcyA9IFBhc3N3b3JkUmVzcG9uc2VzOwogICAgICAgICAgICAgICAgbGV0IHZlcmJvc2l0eSA9IFZlcmJvc2l0eUxldmVsLldBUk5JTkdTOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gc2V0VmVyYm9zaXR5TGV2ZWwobGV2ZWwpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihsZXZlbCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmVyYm9zaXR5ID0gbGV2ZWw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0VmVyYm9zaXR5TGV2ZWwoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZlcmJvc2l0eTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGluZm8obXNnKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHZlcmJvc2l0eSA+PSBWZXJib3NpdHlMZXZlbC5JTkZPUykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhgSW5mbzogJHttc2d9YCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gd2Fybihtc2cpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodmVyYm9zaXR5ID49IFZlcmJvc2l0eUxldmVsLldBUk5JTkdTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKGBXYXJuaW5nOiAke21zZ31gKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiB1bnJlYWNoYWJsZShtc2cpIHsKICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IobXNnKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGFzc2VydChjb25kLCBtc2cpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWNvbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdW5yZWFjaGFibGUobXNnKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfaXNWYWxpZFByb3RvY29sKHVybCkgewogICAgICAgICAgICAgICAgICAgIGlmICghdXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh1cmwucHJvdG9jb2wpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiaHR0cDoiOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJodHRwczoiOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJmdHA6IjoKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAibWFpbHRvOiI6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgInRlbDoiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY3JlYXRlVmFsaWRBYnNvbHV0ZVVybCh1cmwpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgYmFzZVVybCA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBsZXQgb3B0aW9ucyA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBpZiAoIXVybCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMgJiYgdHlwZW9mIHVybCA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcHRpb25zLmFkZERlZmF1bHRQcm90b2NvbCAmJiB1cmwuc3RhcnRzV2l0aCgid3d3LiIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZG90cyA9IHVybC5tYXRjaCgvXC4vZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRvdHMgJiYgZG90cy5sZW5ndGggPj0gMikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmwgPSBgaHR0cDovLyR7dXJsfWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMudHJ5Q29udmVydEVuY29kaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsID0gc3RyaW5nVG9VVEY4U3RyaW5nKHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHt9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWJzb2x1dGVVcmwgPSBiYXNlVXJsID8gbmV3IFVSTCh1cmwsIGJhc2VVcmwpIDogbmV3IFVSTCh1cmwpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2lzVmFsaWRQcm90b2NvbChhYnNvbHV0ZVVybCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhYnNvbHV0ZVVybDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7fQogICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gc2hhZG93KG9iaiwgcHJvcCwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgbm9uU2VyaWFsaXphYmxlID0gYXJndW1lbnRzLmxlbmd0aCA+IDMgJiYgYXJndW1lbnRzWzNdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbM10gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkob2JqLCBwcm9wLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiAhbm9uU2VyaWFsaXphYmxlLAogICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiBmYWxzZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbnN0IEJhc2VFeGNlcHRpb24gPSBmdW5jdGlvbiBCYXNlRXhjZXB0aW9uQ2xvc3VyZSgpIHsKICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBCYXNlRXhjZXB0aW9uKG1lc3NhZ2UsIG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IEJhc2VFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVucmVhY2hhYmxlKCJDYW5ub3QgaW5pdGlhbGl6ZSBCYXNlRXhjZXB0aW9uLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWVzc2FnZSA9IG1lc3NhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmFtZSA9IG5hbWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIEJhc2VFeGNlcHRpb24ucHJvdG90eXBlID0gbmV3IEVycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgQmFzZUV4Y2VwdGlvbi5jb25zdHJ1Y3RvciA9IEJhc2VFeGNlcHRpb247CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEJhc2VFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9KCk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkJhc2VFeGNlcHRpb24gPSBCYXNlRXhjZXB0aW9uOwogICAgICAgICAgICAgICAgY2xhc3MgUGFzc3dvcmRFeGNlcHRpb24gZXh0ZW5kcyBCYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2csIGNvZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIobXNnLCAiUGFzc3dvcmRFeGNlcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2RlID0gY29kZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBhc3N3b3JkRXhjZXB0aW9uID0gUGFzc3dvcmRFeGNlcHRpb247CiAgICAgICAgICAgICAgICBjbGFzcyBVbmtub3duRXJyb3JFeGNlcHRpb24gZXh0ZW5kcyBCYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2csIGRldGFpbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIobXNnLCAiVW5rbm93bkVycm9yRXhjZXB0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGV0YWlscyA9IGRldGFpbHM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Vbmtub3duRXJyb3JFeGNlcHRpb24gPSBVbmtub3duRXJyb3JFeGNlcHRpb247CiAgICAgICAgICAgICAgICBjbGFzcyBJbnZhbGlkUERGRXhjZXB0aW9uIGV4dGVuZHMgQmFzZUV4Y2VwdGlvbiB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobXNnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIkludmFsaWRQREZFeGNlcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkludmFsaWRQREZFeGNlcHRpb24gPSBJbnZhbGlkUERGRXhjZXB0aW9uOwogICAgICAgICAgICAgICAgY2xhc3MgTWlzc2luZ1BERkV4Y2VwdGlvbiBleHRlbmRzIEJhc2VFeGNlcHRpb24gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKG1zZykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihtc2csICJNaXNzaW5nUERGRXhjZXB0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5NaXNzaW5nUERGRXhjZXB0aW9uID0gTWlzc2luZ1BERkV4Y2VwdGlvbjsKICAgICAgICAgICAgICAgIGNsYXNzIFVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiBleHRlbmRzIEJhc2VFeGNlcHRpb24gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKG1zZywgc3RhdHVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YXR1cyA9IHN0YXR1czsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiA9IFVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbjsKICAgICAgICAgICAgICAgIGNsYXNzIEZvcm1hdEVycm9yIGV4dGVuZHMgQmFzZUV4Y2VwdGlvbiB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobXNnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIkZvcm1hdEVycm9yIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Gb3JtYXRFcnJvciA9IEZvcm1hdEVycm9yOwogICAgICAgICAgICAgICAgY2xhc3MgQWJvcnRFeGNlcHRpb24gZXh0ZW5kcyBCYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2cpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIobXNnLCAiQWJvcnRFeGNlcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkFib3J0RXhjZXB0aW9uID0gQWJvcnRFeGNlcHRpb247CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBieXRlc1RvU3RyaW5nKGJ5dGVzKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBieXRlcyAhPT0gIm9iamVjdCIgfHwgYnl0ZXMgPT09IG51bGwgfHwgYnl0ZXMubGVuZ3RoID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdW5yZWFjaGFibGUoIkludmFsaWQgYXJndW1lbnQgZm9yIGJ5dGVzVG9TdHJpbmciKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuZ3RoID0gYnl0ZXMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IE1BWF9BUkdVTUVOVF9DT1VOVCA9IDgxOTI7CiAgICAgICAgICAgICAgICAgICAgaWYgKGxlbmd0aCA8IE1BWF9BUkdVTUVOVF9DT1VOVCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gU3RyaW5nLmZyb21DaGFyQ29kZS5hcHBseShudWxsLCBieXRlcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ckJ1ZiA9IFtdOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbGVuZ3RoOyBpICs9IE1BWF9BUkdVTUVOVF9DT1VOVCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVua0VuZCA9IE1hdGgubWluKGkgKyBNQVhfQVJHVU1FTlRfQ09VTlQsIGxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gYnl0ZXMuc3ViYXJyYXkoaSwgY2h1bmtFbmQpOwogICAgICAgICAgICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlLmFwcGx5KG51bGwsIGNodW5rKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHJCdWYuam9pbigiIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzdHJpbmdUb0J5dGVzKHN0cikgewogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygc3RyICE9PSAic3RyaW5nIikgewogICAgICAgICAgICAgICAgICAgICAgICB1bnJlYWNoYWJsZSgiSW52YWxpZCBhcmd1bWVudCBmb3Igc3RyaW5nVG9CeXRlcyIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBsZW5ndGggPSBzdHIubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkobGVuZ3RoKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbmd0aDsgKytpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2ldID0gc3RyLmNoYXJDb2RlQXQoaSkgJiAweGZmOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gYnl0ZXM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzdHJpbmczMih2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBTdHJpbmcuZnJvbUNoYXJDb2RlKHZhbHVlID4+IDI0ICYgMHhmZiwgdmFsdWUgPj4gMTYgJiAweGZmLCB2YWx1ZSA+PiA4ICYgMHhmZiwgdmFsdWUgJiAweGZmKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG9iamVjdFNpemUob2JqKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE9iamVjdC5rZXlzKG9iaikubGVuZ3RoOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gb2JqZWN0RnJvbU1hcChtYXApIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBvYmogPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleSwgdmFsdWVdIG9mIG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBvYmpba2V5XSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gb2JqOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gaXNMaXR0bGVFbmRpYW4oKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgYnVmZmVyOCA9IG5ldyBVaW50OEFycmF5KDQpOwogICAgICAgICAgICAgICAgICAgIGJ1ZmZlcjhbMF0gPSAxOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHZpZXczMiA9IG5ldyBVaW50MzJBcnJheShidWZmZXI4LmJ1ZmZlciwgMCwgMSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZpZXczMlswXSA9PT0gMTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGlzRXZhbFN1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICBuZXcgRnVuY3Rpb24oIiIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBGZWF0dXJlVGVzdCB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBpc0xpdHRsZUVuZGlhbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAiaXNMaXR0bGVFbmRpYW4iLCBpc0xpdHRsZUVuZGlhbigpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBpc0V2YWxTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzaGFkb3codGhpcywgImlzRXZhbFN1cHBvcnRlZCIsIGlzRXZhbFN1cHBvcnRlZCgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAiaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQiLCB0eXBlb2YgT2Zmc2NyZWVuQ2FudmFzICE9PSAidW5kZWZpbmVkIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXQgcGxhdGZvcm0oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgbmF2aWdhdG9yID09PSAidW5kZWZpbmVkIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAicGxhdGZvcm0iLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNXaW46IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzTWFjOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNoYWRvdyh0aGlzLCAicGxhdGZvcm0iLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1dpbjogbmF2aWdhdG9yLnBsYXRmb3JtLmluY2x1ZGVzKCJXaW4iKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzTWFjOiBuYXZpZ2F0b3IucGxhdGZvcm0uaW5jbHVkZXMoIk1hYyIpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRmVhdHVyZVRlc3QgPSBGZWF0dXJlVGVzdDsKICAgICAgICAgICAgICAgIGNvbnN0IGhleE51bWJlcnMgPSBbLi4uQXJyYXkoMjU2KS5rZXlzKCldLm1hcChuID0+IG4udG9TdHJpbmcoMTYpLnBhZFN0YXJ0KDIsICIwIikpOwogICAgICAgICAgICAgICAgY2xhc3MgVXRpbCB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIG1ha2VIZXhDb2xvcihyLCBnLCBiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgIyR7aGV4TnVtYmVyc1tyXX0ke2hleE51bWJlcnNbZ119JHtoZXhOdW1iZXJzW2JdfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBzY2FsZU1pbk1heCh0cmFuc2Zvcm0sIG1pbk1heCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgdGVtcDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRyYW5zZm9ybVswXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRyYW5zZm9ybVswXSA8IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZW1wID0gbWluTWF4WzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFswXSA9IG1pbk1heFsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMV0gPSB0ZW1wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzBdICo9IHRyYW5zZm9ybVswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSAqPSB0cmFuc2Zvcm1bMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNmb3JtWzNdIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXAgPSBtaW5NYXhbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzJdID0gbWluTWF4WzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMl0gKj0gdHJhbnNmb3JtWzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzNdICo9IHRyYW5zZm9ybVszXTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXAgPSBtaW5NYXhbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMF0gPSBtaW5NYXhbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMl0gPSB0ZW1wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGVtcCA9IG1pbk1heFsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSA9IG1pbk1heFszXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNmb3JtWzFdIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRlbXAgPSBtaW5NYXhbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzJdID0gbWluTWF4WzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSA9IHRlbXA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMl0gKj0gdHJhbnNmb3JtWzFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzNdICo9IHRyYW5zZm9ybVsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc2Zvcm1bMl0gPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGVtcCA9IG1pbk1heFswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMF0gPSBtaW5NYXhbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzFdID0gdGVtcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFswXSAqPSB0cmFuc2Zvcm1bMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMV0gKj0gdHJhbnNmb3JtWzJdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFswXSArPSB0cmFuc2Zvcm1bNF07CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSArPSB0cmFuc2Zvcm1bNF07CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsyXSArPSB0cmFuc2Zvcm1bNV07CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFszXSArPSB0cmFuc2Zvcm1bNV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB0cmFuc2Zvcm0obTEsIG0yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbbTFbMF0gKiBtMlswXSArIG0xWzJdICogbTJbMV0sIG0xWzFdICogbTJbMF0gKyBtMVszXSAqIG0yWzFdLCBtMVswXSAqIG0yWzJdICsgbTFbMl0gKiBtMlszXSwgbTFbMV0gKiBtMlsyXSArIG0xWzNdICogbTJbM10sIG0xWzBdICogbTJbNF0gKyBtMVsyXSAqIG0yWzVdICsgbTFbNF0sIG0xWzFdICogbTJbNF0gKyBtMVszXSAqIG0yWzVdICsgbTFbNV1dOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgYXBwbHlUcmFuc2Zvcm0ocCwgbSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4dCA9IHBbMF0gKiBtWzBdICsgcFsxXSAqIG1bMl0gKyBtWzRdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5dCA9IHBbMF0gKiBtWzFdICsgcFsxXSAqIG1bM10gKyBtWzVdOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3h0LCB5dF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBhcHBseUludmVyc2VUcmFuc2Zvcm0ocCwgbSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkID0gbVswXSAqIG1bM10gLSBtWzFdICogbVsyXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeHQgPSAocFswXSAqIG1bM10gLSBwWzFdICogbVsyXSArIG1bMl0gKiBtWzVdIC0gbVs0XSAqIG1bM10pIC8gZDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeXQgPSAoLXBbMF0gKiBtWzFdICsgcFsxXSAqIG1bMF0gKyBtWzRdICogbVsxXSAtIG1bNV0gKiBtWzBdKSAvIGQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeHQsIHl0XTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldEF4aWFsQWxpZ25lZEJvdW5kaW5nQm94KHIsIG0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDEgPSBVdGlsLmFwcGx5VHJhbnNmb3JtKHIsIG0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMiA9IFV0aWwuYXBwbHlUcmFuc2Zvcm0oci5zbGljZSgyLCA0KSwgbSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAzID0gVXRpbC5hcHBseVRyYW5zZm9ybShbclswXSwgclszXV0sIG0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwNCA9IFV0aWwuYXBwbHlUcmFuc2Zvcm0oW3JbMl0sIHJbMV1dLCBtKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtNYXRoLm1pbihwMVswXSwgcDJbMF0sIHAzWzBdLCBwNFswXSksIE1hdGgubWluKHAxWzFdLCBwMlsxXSwgcDNbMV0sIHA0WzFdKSwgTWF0aC5tYXgocDFbMF0sIHAyWzBdLCBwM1swXSwgcDRbMF0pLCBNYXRoLm1heChwMVsxXSwgcDJbMV0sIHAzWzFdLCBwNFsxXSldOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgaW52ZXJzZVRyYW5zZm9ybShtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQgPSBtWzBdICogbVszXSAtIG1bMV0gKiBtWzJdOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW21bM10gLyBkLCAtbVsxXSAvIGQsIC1tWzJdIC8gZCwgbVswXSAvIGQsIChtWzJdICogbVs1XSAtIG1bNF0gKiBtWzNdKSAvIGQsIChtWzRdICogbVsxXSAtIG1bNV0gKiBtWzBdKSAvIGRdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgc2luZ3VsYXJWYWx1ZURlY29tcG9zZTJkU2NhbGUobSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0cmFuc3Bvc2UgPSBbbVswXSwgbVsyXSwgbVsxXSwgbVszXV07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGEgPSBtWzBdICogdHJhbnNwb3NlWzBdICsgbVsxXSAqIHRyYW5zcG9zZVsyXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYiA9IG1bMF0gKiB0cmFuc3Bvc2VbMV0gKyBtWzFdICogdHJhbnNwb3NlWzNdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjID0gbVsyXSAqIHRyYW5zcG9zZVswXSArIG1bM10gKiB0cmFuc3Bvc2VbMl07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQgPSBtWzJdICogdHJhbnNwb3NlWzFdICsgbVszXSAqIHRyYW5zcG9zZVszXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlyc3QgPSAoYSArIGQpIC8gMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2Vjb25kID0gTWF0aC5zcXJ0KChhICsgZCkgKiogMiAtIDQgKiAoYSAqIGQgLSBjICogYikpIC8gMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ggPSBmaXJzdCArIHNlY29uZCB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzeSA9IGZpcnN0IC0gc2Vjb25kIHx8IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbTWF0aC5zcXJ0KHN4KSwgTWF0aC5zcXJ0KHN5KV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBub3JtYWxpemVSZWN0KHJlY3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgciA9IHJlY3Quc2xpY2UoMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZWN0WzBdID4gcmVjdFsyXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgclswXSA9IHJlY3RbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByWzJdID0gcmVjdFswXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVjdFsxXSA+IHJlY3RbM10pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJbMV0gPSByZWN0WzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgclszXSA9IHJlY3RbMV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBpbnRlcnNlY3QocmVjdDEsIHJlY3QyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHhMb3cgPSBNYXRoLm1heChNYXRoLm1pbihyZWN0MVswXSwgcmVjdDFbMl0pLCBNYXRoLm1pbihyZWN0MlswXSwgcmVjdDJbMl0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeEhpZ2ggPSBNYXRoLm1pbihNYXRoLm1heChyZWN0MVswXSwgcmVjdDFbMl0pLCBNYXRoLm1heChyZWN0MlswXSwgcmVjdDJbMl0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhMb3cgPiB4SGlnaCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeUxvdyA9IE1hdGgubWF4KE1hdGgubWluKHJlY3QxWzFdLCByZWN0MVszXSksIE1hdGgubWluKHJlY3QyWzFdLCByZWN0MlszXSkpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5SGlnaCA9IE1hdGgubWluKE1hdGgubWF4KHJlY3QxWzFdLCByZWN0MVszXSksIE1hdGgubWF4KHJlY3QyWzFdLCByZWN0MlszXSkpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoeUxvdyA+IHlIaWdoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3hMb3csIHlMb3csIHhIaWdoLCB5SGlnaF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBiZXppZXJCb3VuZGluZ0JveCh4MCwgeTAsIHgxLCB5MSwgeDIsIHkyLCB4MywgeTMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHZhbHVlcyA9IFtdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzID0gW1tdLCBbXV07CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBhLCBiLCBjLCB0LCB0MSwgdDIsIGIyYWMsIHNxcnRiMmFjOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI7ICsraSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiID0gNiAqIHgwIC0gMTIgKiB4MSArIDYgKiB4MjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhID0gLTMgKiB4MCArIDkgKiB4MSAtIDkgKiB4MiArIDMgKiB4MzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjID0gMyAqIHgxIC0gMyAqIHgwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiID0gNiAqIHkwIC0gMTIgKiB5MSArIDYgKiB5MjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhID0gLTMgKiB5MCArIDkgKiB5MSAtIDkgKiB5MiArIDMgKiB5MzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjID0gMyAqIHkxIC0gMyAqIHkwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKE1hdGguYWJzKGEpIDwgMWUtMTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoTWF0aC5hYnMoYikgPCAxZS0xMikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdCA9IC1jIC8gYjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoMCA8IHQgJiYgdCA8IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHZhbHVlcy5wdXNoKHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGIyYWMgPSBiICogYiAtIDQgKiBjICogYTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNxcnRiMmFjID0gTWF0aC5zcXJ0KGIyYWMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGIyYWMgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0MSA9ICgtYiArIHNxcnRiMmFjKSAvICgyICogYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoMCA8IHQxICYmIHQxIDwgMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR2YWx1ZXMucHVzaCh0MSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0MiA9ICgtYiAtIHNxcnRiMmFjKSAvICgyICogYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoMCA8IHQyICYmIHQyIDwgMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR2YWx1ZXMucHVzaCh0Mik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGogPSB0dmFsdWVzLmxlbmd0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG10OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBqbGVuID0gajsKICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGotLSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdCA9IHR2YWx1ZXNbal07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdCA9IDEgLSB0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzWzBdW2pdID0gbXQgKiBtdCAqIG10ICogeDAgKyAzICogbXQgKiBtdCAqIHQgKiB4MSArIDMgKiBtdCAqIHQgKiB0ICogeDIgKyB0ICogdCAqIHQgKiB4MzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kc1sxXVtqXSA9IG10ICogbXQgKiBtdCAqIHkwICsgMyAqIG10ICogbXQgKiB0ICogeTEgKyAzICogbXQgKiB0ICogdCAqIHkyICsgdCAqIHQgKiB0ICogeTM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzWzBdW2psZW5dID0geDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kc1sxXVtqbGVuXSA9IHkwOwogICAgICAgICAgICAgICAgICAgICAgICBib3VuZHNbMF1bamxlbiArIDFdID0geDM7CiAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kc1sxXVtqbGVuICsgMV0gPSB5MzsKICAgICAgICAgICAgICAgICAgICAgICAgYm91bmRzWzBdLmxlbmd0aCA9IGJvdW5kc1sxXS5sZW5ndGggPSBqbGVuICsgMjsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtNYXRoLm1pbiguLi5ib3VuZHNbMF0pLCBNYXRoLm1pbiguLi5ib3VuZHNbMV0pLCBNYXRoLm1heCguLi5ib3VuZHNbMF0pLCBNYX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CAwLCAweDIwYWNdOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gc3RyaW5nVG9QREZTdHJpbmcoc3RyKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHN0clswXSA+PSAiXHhFRiIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGVuY29kaW5nOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RyWzBdID09PSAiXHhGRSIgJiYgc3RyWzFdID09PSAiXHhGRiIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuY29kaW5nID0gInV0Zi0xNmJlIjsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChzdHJbMF0gPT09ICJceEZGIiAmJiBzdHJbMV0gPT09ICJceEZFIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5jb2RpbmcgPSAidXRmLTE2bGUiOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHN0clswXSA9PT0gIlx4RUYiICYmIHN0clsxXSA9PT0gIlx4QkIiICYmIHN0clsyXSA9PT0gIlx4QkYiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmNvZGluZyA9ICJ1dGYtOCI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuY29kaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlY29kZXIgPSBuZXcgVGV4dERlY29kZXIoZW5jb2RpbmcsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmF0YWw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBzdHJpbmdUb0J5dGVzKHN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlY29kZXIuZGVjb2RlKGJ1ZmZlcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdhcm4oYHN0cmluZ1RvUERGU3RyaW5nOiAiJHtleH0iLmApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ckJ1ZiA9IFtdOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IHN0ci5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvZGUgPSBQREZTdHJpbmdUcmFuc2xhdGVUYWJsZVtzdHIuY2hhckNvZGVBdChpKV07CiAgICAgICAgICAgICAgICAgICAgICAgIHN0ckJ1Zi5wdXNoKGNvZGUgPyBTdHJpbmcuZnJvbUNoYXJDb2RlKGNvZGUpIDogc3RyLmNoYXJBdChpKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHJCdWYuam9pbigiIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzdHJpbmdUb1VURjhTdHJpbmcoc3RyKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlY29kZVVSSUNvbXBvbmVudChlc2NhcGUoc3RyKSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiB1dGY4U3RyaW5nVG9TdHJpbmcoc3RyKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVuZXNjYXBlKGVuY29kZVVSSUNvbXBvbmVudChzdHIpKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGlzQXJyYXlCdWZmZXIodikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB0eXBlb2YgdiA9PT0gIm9iamVjdCIgJiYgdiAhPT0gbnVsbCAmJiB2LmJ5dGVMZW5ndGggIT09IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGlzQXJyYXlFcXVhbChhcnIxLCBhcnIyKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGFycjEubGVuZ3RoICE9PSBhcnIyLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGFycjEubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXJyMVtpXSAhPT0gYXJyMltpXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0TW9kaWZpY2F0aW9uRGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgZGF0ZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogbmV3IERhdGUoKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBbZGF0ZS5nZXRVVENGdWxsWWVhcigpLnRvU3RyaW5nKCksIChkYXRlLmdldFVUQ01vbnRoKCkgKyAxKS50b1N0cmluZygpLnBhZFN0YXJ0KDIsICIwIiksIGRhdGUuZ2V0VVRDRGF0ZSgpLnRvU3RyaW5nKCkucGFkU3RhcnQoMiwgIjAiKSwgZGF0ZS5nZXRVVENIb3VycygpLnRvU3RyaW5nKCkucGFkU3RhcnQoMiwgIjAiKSwgZGF0ZS5nZXRVVENNaW51dGVzKCkudG9TdHJpbmcoKS5wYWRTdGFydCgyLCAiMCIpLCBkYXRlLmdldFVUQ1NlY29uZHMoKS50b1N0cmluZygpLnBhZFN0YXJ0KDIsICIwIildOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBidWZmZXIuam9pbigiIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSgpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjYXBhYmlsaXR5ID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICBsZXQgaXNTZXR0bGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGNhcGFiaWxpdHksICJzZXR0bGVkIiwgewogICAgICAgICAgICAgICAgICAgICAgICBnZXQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXNTZXR0bGVkOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgY2FwYWJpbGl0eS5wcm9taXNlID0gbmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmUsIHJlamVjdCkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXBhYmlsaXR5LnJlc29sdmUgPSBmdW5jdGlvbiAoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNTZXR0bGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHkucmVqZWN0ID0gZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNTZXR0bGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlamVjdChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBjYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAyICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgdmFyIF9pc19ub2RlID0gX193X3BkZmpzX3JlcXVpcmVfXygzKTsKICAgICAgICAgICAgICAgIChmdW5jdGlvbiBjaGVja0RPTU1hdHJpeCgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoZ2xvYmFsVGhpcy5ET01NYXRyaXggfHwgIV9pc19ub2RlLmlzTm9kZUpTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2xvYmFsVGhpcy5ET01NYXRyaXggPSByZXF1aXJlKCJjYW52YXMiKS5ET01NYXRyaXg7CiAgICAgICAgICAgICAgICB9KSgpOwogICAgICAgICAgICAgICAgKGZ1bmN0aW9uIGNoZWNrUGF0aDJEKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxUaGlzLlBhdGgyRCB8fCAhX2lzX25vZGUuaXNOb2RlSlMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIENhbnZhc1JlbmRlcmluZ0NvbnRleHQyRAogICAgICAgICAgICAgICAgICAgIH0gPSByZXF1aXJlKCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlmaWxsUGF0aDJECiAgICAgICAgICAgICAgICAgICAgfSA9IHJlcXVpcmUoInBhdGgyZC1wb2x5ZmlsbCIpOwogICAgICAgICAgICAgICAgICAgIGdsb2JhbFRoaXMuQ2FudmFzUmVuZGVyaW5nQ29udGV4dDJEID0gQ2FudmFzUmVuZGVyaW5nQ29udGV4dDJEOwogICAgICAgICAgICAgICAgICAgIHBvbHlmaWxsUGF0aDJEKGdsb2JhbFRoaXMpOwogICAgICAgICAgICAgICAgfSkoKTsKICAgICAgICAgICAgICAgIChmdW5jdGlvbiBjaGVja1JlYWRhYmxlU3RyZWFtKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxUaGlzLlJlYWRhYmxlU3RyZWFtIHx8ICFfaXNfbm9kZS5pc05vZGVKUykgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdsb2JhbFRoaXMuUmVhZGFibGVTdHJlYW0gPSByZXF1aXJlKCJ3ZWItc3RyZWFtcy1wb2x5ZmlsbC9kaXN0L3BvbnlmaWxsLmpzIikuUmVhZGFibGVTdHJlYW07CiAgICAgICAgICAgICAgICB9KSgpOwogICAgICAgICAgICAgICAgKGZ1bmN0aW9uIGNoZWNrQXJyYXlBdCgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkucHJvdG90eXBlLmF0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXyg0KTsKICAgICAgICAgICAgICAgIH0pKCk7CiAgICAgICAgICAgICAgICAoZnVuY3Rpb24gY2hlY2tUeXBlZEFycmF5QXQoKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKFVpbnQ4QXJyYXkucHJvdG90eXBlLmF0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXyg3OCk7CiAgICAgICAgICAgICAgICB9KSgpOwogICAgICAgICAgICAgICAgKGZ1bmN0aW9uIGNoZWNrU3RydWN0dXJlZENsb25lKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxUaGlzLnN0cnVjdHVyZWRDbG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oOTApOwogICAgICAgICAgICAgICAgfSkoKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLmlzTm9kZUpTID0gdm9pZCAwOwogICAgICAgICAgICAgICAgY29uc3QgaXNOb2RlSlMgPSB0eXBlb2YgcHJvY2VzcyA9PT0gIm9iamVjdCIgJiYgcHJvY2VzcyArICIiID09PSAiW29iamVjdCBwcm9jZXNzXSIgJiYgIXByb2Nlc3MudmVyc2lvbnMubncgJiYgIShwcm9jZXNzLnZlcnNpb25zLmVsZWN0cm9uICYmIHByb2Nlc3MudHlwZSAmJiBwcm9jZXNzLnR5cGUgIT09ICJicm93c2VyIik7CiAgICAgICAgICAgICAgICBleHBvcnRzLmlzTm9kZUpTID0gaXNOb2RlSlM7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDQgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oNSk7CiAgICAgICAgICAgICAgICB2YXIgZW50cnlVbmJpbmQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDc3KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZW50cnlVbmJpbmQoJ0FycmF5JywgJ2F0Jyk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDUgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciAkID0gX193X3BkZmpzX3JlcXVpcmVfXyg2KTsKICAgICAgICAgICAgICAgIHZhciB0b09iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNDMpOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgdG9JbnRlZ2VyT3JJbmZpbml0eSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjUpOwogICAgICAgICAgICAgICAgdmFyIGFkZFRvVW5zY29wYWJsZXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcyKTsKICAgICAgICAgICAgICAgICQoewogICAgICAgICAgICAgICAgICAgIHRhcmdldDogJ0FycmF5JywKICAgICAgICAgICAgICAgICAgICBwcm90bzogdHJ1ZQogICAgICAgICAgICAgICAgfSwgewogICAgICAgICAgICAgICAgICAgIGF0OiBmdW5jdGlvbiBhdChpbmRleCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgTyA9IHRvT2JqZWN0KHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgbGVuID0gbGVuZ3RoT2ZBcnJheUxpa2UoTyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciByZWxhdGl2ZUluZGV4ID0gdG9JbnRlZ2VyT3JJbmZpbml0eShpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBrID0gcmVsYXRpdmVJbmRleCA+PSAwID8gcmVsYXRpdmVJbmRleCA6IGxlbiArIHJlbGF0aXZlSW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBrIDwgMCB8fCBrID49IGxlbiA/IHVuZGVmaW5lZCA6IE9ba107CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBhZGRUb1Vuc2NvcGFibGVzKCdhdCcpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZ2xvYmFsID0gX193X3BkZmpzX3JlcXVpcmVfXyg3KTsKICAgICAgICAgICAgICAgIHZhciBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IgPSAoX193X3BkZmpzX3JlcXVpcmVfXyg4KS5mKTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ3KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lR2xvYmFsUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQxKTsKICAgICAgICAgICAgICAgIHZhciBjb3B5Q29uc3RydWN0b3JQcm9wZXJ0aWVzID0gX193X3BkZmpzX3JlcXVpcmVfXyg1OSk7CiAgICAgICAgICAgICAgICB2YXIgaXNGb3JjZWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcxKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKG9wdGlvbnMsIHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgIHZhciBUQVJHRVQgPSBvcHRpb25zLnRhcmdldDsKICAgICAgICAgICAgICAgICAgICB2YXIgR0xPQkFMID0gb3B0aW9ucy5nbG9iYWw7CiAgICAgICAgICAgICAgICAgICAgdmFyIFNUQVRJQyA9IG9wdGlvbnMuc3RhdDsKICAgICAgICAgICAgICAgICAgICB2YXIgRk9SQ0VELCB0YXJnZXQsIGtleSwgdGFyZ2V0UHJvcGVydHksIHNvdXJjZVByb3BlcnR5LCBkZXNjcmlwdG9yOwogICAgICAgICAgICAgICAgICAgIGlmIChHTE9CQUwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0ID0gZ2xvYmFsOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoU1RBVElDKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldCA9IGdsb2JhbFtUQVJHRVRdIHx8IGRlZmluZUdsb2JhbFByb3BlcnR5KFRBUkdFVCwge30pOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldCA9IChnbG9iYWxbVEFSR0VUXSB8fCB7fSkucHJvdG90eXBlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAodGFyZ2V0KQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGtleSBpbiBzb3VyY2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZVByb3BlcnR5ID0gc291cmNlW2tleV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3B0aW9ucy5kb250Q2FsbEdldFNldCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc2NyaXB0b3IgPSBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IodGFyZ2V0LCBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldFByb3BlcnR5ID0gZGVzY3JpcHRvciAmJiBkZXNjcmlwdG9yLnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0UHJvcGVydHkgPSB0YXJnZXRba2V5XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZPUkNFRCA9IGlzRm9yY2VkKEdMT0JBTCA/IGtleSA6IFRBUkdFVCArIChTVEFUSUMgPyAnLicgOiAnIycpICsga2V5LCBvcHRpb25zLmZvcmNlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIUZPUkNFRCAmJiB0YXJnZXRQcm9wZXJ0eSAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBzb3VyY2VQcm9wZXJ0eSA9PSB0eXBlb2YgdGFyZ2V0UHJvcGVydHkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvcHlDb25zdHJ1Y3RvclByb3BlcnRpZXMoc291cmNlUHJvcGVydHksIHRhcmdldFByb3BlcnR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvcHRpb25zLnNoYW0gfHwgdGFyZ2V0UHJvcGVydHkgJiYgdGFyZ2V0UHJvcGVydHkuc2hhbSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShzb3VyY2VQcm9wZXJ0eSwgJ3NoYW0nLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4odGFyZ2V0LCBrZXksIHNvdXJjZVByb3BlcnR5LCBvcHRpb25zKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjaGVjayA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBpdCAmJiBpdC5NYXRoID09IE1hdGggJiYgaXQ7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBjaGVjayh0eXBlb2YgZ2xvYmFsVGhpcyA9PSAnb2JqZWN0JyAmJiBnbG9iYWxUaGlzKSB8fCBjaGVjayh0eXBlb2Ygd2luZG93ID09ICdvYmplY3QnICYmIHdpbmRvdykgfHwgY2hlY2sodHlwZW9mIHNlbGYgPT0gJ29iamVjdCcgJiYgc2VsZikgfHwgY2hlY2sodHlwZW9mIGdsb2JhbCA9PSAnb2JqZWN0JyAmJiBnbG9iYWwpIHx8IChmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgICAgICAgICB9KCkpIHx8IEZ1bmN0aW9uKCdyZXR1cm4gdGhpcycpKCk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDggKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgY2FsbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTEpOwogICAgICAgICAgICAgICAgdmFyIHByb3BlcnR5SXNFbnVtZXJhYmxlTW9kdWxlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMyk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNCk7CiAgICAgICAgICAgICAgICB2YXIgdG9JbmRleGVkT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNSk7CiAgICAgICAgICAgICAgICB2YXIgdG9Qcm9wZXJ0eUtleSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjEpOwogICAgICAgICAgICAgICAgdmFyIGhhc093biA9IF9fd19wZGZqc19yZXF1aXJlX18oNDIpOwogICAgICAgICAgICAgICAgdmFyIElFOF9ET01fREVGSU5FID0gX193X3BkZmpzX3JlcXVpcmVfXyg0NSk7CiAgICAgICAgICAgICAgICB2YXIgJGdldE93blByb3BlcnR5RGVzY3JpcHRvciA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3I7CiAgICAgICAgICAgICAgICBleHBvcnRzLmYgPSBERVNDUklQVE9SUyA/ICRnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IgOiBmdW5jdGlvbiBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IoTywgUCkgewogICAgICAgICAgICAgICAgICAgIE8gPSB0b0luZGV4ZWRPYmplY3QoTyk7CiAgICAgICAgICAgICAgICAgICAgUCA9IHRvUHJvcGVydHlLZXkoUCk7CiAgICAgICAgICAgICAgICAgICAgaWYgKElFOF9ET01fREVGSU5FKQogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICRnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IoTywgUCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoaGFzT3duKE8sIFApKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yKCFjYWxsKHByb3BlcnR5SXNFbnVtZXJhYmxlTW9kdWxlLmYsIE8sIFApLCBPW1BdKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBPYmplY3QuZGVmaW5lUHJvcGVydHkoe30sIDEsIHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gNzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pWzFdICE9IDc7CiAgICAgICAgICAgICAgICB9KTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTAgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChleGVjKSB7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICEhZXhlYygpOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgTkFUSVZFX0JJTkQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyKTsKICAgICAgICAgICAgICAgIHZhciBjYWxsID0gRnVuY3Rpb24ucHJvdG90eXBlLmNhbGw7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IE5BVElWRV9CSU5EID8gY2FsbC5iaW5kKGNhbGwpIDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsLmFwcGx5KGNhbGwsIGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICFmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHRlc3QgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgfS5iaW5kKCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiB0ZXN0ICE9ICdmdW5jdGlvbicgfHwgdGVzdC5oYXNPd25Qcm9wZXJ0eSgncHJvdG90eXBlJyk7CiAgICAgICAgICAgICAgICB9KTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTMgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCiAgICAgICAgICAgICAgICB2YXIgJHByb3BlcnR5SXNFbnVtZXJhYmxlID0ge30ucHJvcGVydHlJc0VudW1lcmFibGU7CiAgICAgICAgICAgICAgICB2YXIgZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yID0gT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcjsKICAgICAgICAgICAgICAgIHZhciBOQVNIT1JOX0JVRyA9IGdldE93blByb3BlcnR5RGVzY3JpcHRvciAmJiAhJHByb3BlcnR5SXNFbnVtZXJhYmxlLmNhbGwoeyAxOiAyIH0sIDEpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5mID0gTkFTSE9STl9CVUcgPyBmdW5jdGlvbiBwcm9wZXJ0eUlzRW51bWVyYWJsZShWKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGRlc2NyaXB0b3IgPSBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IodGhpcywgVik7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICEhZGVzY3JpcHRvciAmJiBkZXNjcmlwdG9yLmVudW1lcmFibGU7CiAgICAgICAgICAgICAgICB9IDogJHByb3BlcnR5SXNFbnVtZXJhYmxlOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGJpdG1hcCwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiAhKGJpdG1hcCAmIDEpLAogICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6ICEoYml0bWFwICYgMiksCiAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiAhKGJpdG1hcCAmIDQpLAogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTUgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBJbmRleGVkT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNik7CiAgICAgICAgICAgICAgICB2YXIgcmVxdWlyZU9iamVjdENvZXJjaWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTkpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gSW5kZXhlZE9iamVjdChyZXF1aXJlT2JqZWN0Q29lcmNpYmxlKGl0KSk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBjbGFzc29mID0gX193X3BkZmpzX3JlcXVpcmVfXygxOCk7CiAgICAgICAgICAgICAgICB2YXIgJE9iamVjdCA9IE9iamVjdDsKICAgICAgICAgICAgICAgIHZhciBzcGxpdCA9IHVuY3VycnlUaGlzKCcnLnNwbGl0KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiAhJE9iamVjdCgneicpLnByb3BlcnR5SXNFbnVtZXJhYmxlKDApOwogICAgICAgICAgICAgICAgfSkgPyBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xhc3NvZihpdCkgPT0gJ1N0cmluZycgPyBzcGxpdChpdCwgJycpIDogJE9iamVjdChpdCk7CiAgICAgICAgICAgICAgICB9IDogJE9iamVjdDsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBOQVRJVkVfQklORCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTIpOwogICAgICAgICAgICAgICAgdmFyIEZ1bmN0aW9uUHJvdG90eXBlID0gRnVuY3Rpb24ucHJvdG90eXBlOwogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBGdW5jdGlvblByb3RvdHlwZS5jYWxsOwogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzV2l0aEJpbmQgPSBOQVRJVkVfQklORCAmJiBGdW5jdGlvblByb3RvdHlwZS5iaW5kLmJpbmQoY2FsbCwgY2FsbCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IE5BVElWRV9CSU5EID8gdW5jdXJyeVRoaXNXaXRoQmluZCA6IGZ1bmN0aW9uIChmbikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWxsLmFwcGx5KGZuLCBhcmd1bWVudHMpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgdG9TdHJpbmcgPSB1bmN1cnJ5VGhpcyh7fS50b1N0cmluZyk7CiAgICAgICAgICAgICAgICB2YXIgc3RyaW5nU2xpY2UgPSB1bmN1cnJ5VGhpcygnJy5zbGljZSk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHJpbmdTbGljZSh0b1N0cmluZyhpdCksIDgsIC0xKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE5ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaXNOdWxsT3JVbmRlZmluZWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIwKTsKICAgICAgICAgICAgICAgIHZhciAkVHlwZUVycm9yID0gVHlwZUVycm9yOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaXNOdWxsT3JVbmRlZmluZWQoaXQpKQogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyAkVHlwZUVycm9yKCJDYW4ndCBjYWxsIG1ldGhvZCBvbiAiICsgaXQpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBpdDsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDIwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlKSA9PiB7CgogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXQgPT09IG51bGwgfHwgaXQgPT09IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDIxICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgdG9QcmltaXRpdmUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIyKTsKICAgICAgICAgICAgICAgIHZhciBpc1N5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjYpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICB2YXIga2V5ID0gdG9QcmltaXRpdmUoYXJndW1lbnQsICdzdHJpbmcnKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXNTeW1ib2woa2V5KSA/IGtleSA6IGtleSArICcnOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMjIgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjYWxsID0gX193X3BkZmpzX3JlcXVpcmVfXygxMSk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBpc1N5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjYpOwogICAgICAgICAgICAgICAgdmFyIGdldE1ldGhvZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzMpOwogICAgICAgICAgICAgICAgdmFyIG9yZGluYXJ5VG9QcmltaXRpdmUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM2KTsKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciAkVHlwZUVycm9yID0gVHlwZUVycm9yOwogICAgICAgICAgICAgICAgdmFyIFRPX1BSSU1JVElWRSA9IHdlbGxLbm93blN5bWJvbCgndG9QcmltaXRpdmUnKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGlucHV0LCBwcmVmKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFpc09iamVjdChpbnB1dCkgfHwgaXNTeW1ib2woaW5wdXQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaW5wdXQ7CiAgICAgICAgICAgICAgICAgICAgdmFyIGV4b3RpY1RvUHJpbSA9IGdldE1ldGhvZChpbnB1dCwgVE9fUFJJTUlUSVZFKTsKICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0OwogICAgICAgICAgICAgICAgICAgIGlmIChleG90aWNUb1ByaW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHByZWYgPT09IHVuZGVmaW5lZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZWYgPSAnZGVmYXVsdCc7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCA9IGNhbGwoZXhvdGljVG9QcmltLCBpbnB1dCwgcHJlZik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNPYmplY3QocmVzdWx0KSB8fCBpc1N5bWJvbChyZXN1bHQpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcigiQ2FuJ3QgY29udmVydCBvYmplY3QgdG8gcHJpbWl0aXZlIHZhbHVlIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChwcmVmID09PSB1bmRlZmluZWQpCiAgICAgICAgICAgICAgICAgICAgICAgIHByZWYgPSAnbnVtYmVyJzsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gb3JkaW5hcnlUb1ByaW1pdGl2ZShpbnB1dCwgcHJlZik7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAyMyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciAkZG9jdW1lbnRBbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI1KTsKICAgICAgICAgICAgICAgIHZhciBkb2N1bWVudEFsbCA9ICRkb2N1bWVudEFsbC5hbGw7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICRkb2N1bWVudEFsbC5JU19IVE1MRERBID8gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiBpdCA9PSAnb2JqZWN0JyA/IGl0ICE9PSBudWxsIDogaXNDYWxsYWJsZShpdCkgfHwgaXQgPT09IGRvY3VtZW50QWxsOwogICAgICAgICAgICAgICAgfSA6IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB0eXBlb2YgaXQgPT0gJ29iamVjdCcgPyBpdCAhPT0gbnVsbCA6IGlzQ2FsbGFibGUoaXQpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMjQgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciAkZG9jdW1lbnRBbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI1KTsKICAgICAgICAgICAgICAgIHZhciBkb2N1bWVudEFsbCA9ICRkb2N1bWVudEFsbC5hbGw7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICRkb2N1bWVudEFsbC5JU19IVE1MRERBID8gZnVuY3Rpb24gKGFyZ3VtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiBhcmd1bWVudCA9PSAnZnVuY3Rpb24nIHx8IGFyZ3VtZW50ID09PSBkb2N1bWVudEFsbDsKICAgICAgICAgICAgICAgIH0gOiBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHlwZW9mIGFyZ3VtZW50ID09ICdmdW5jdGlvbic7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAyNSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIHZhciBkb2N1bWVudEFsbCA9IHR5cGVvZiBkb2N1bWVudCA9PSAnb2JqZWN0JyAmJiBkb2N1bWVudC5hbGw7CiAgICAgICAgICAgICAgICB2YXIgSVNfSFRNTEREQSA9IHR5cGVvZiBkb2N1bWVudEFsbCA9PSAndW5kZWZpbmVkJyAmJiBkb2N1bWVudEFsbCAhPT0gdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgYWxsOiBkb2N1bWVudEFsbCwKICAgICAgICAgICAgICAgICAgICBJU19IVE1MRERBOiBJU19IVE1MRERBCiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAyNiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGdldEJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI3KTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgaXNQcm90b3R5cGVPZiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjgpOwogICAgICAgICAgICAgICAgdmFyIFVTRV9TWU1CT0xfQVNfVUlEID0gX193X3BkZmpzX3JlcXVpcmVfXygyOSk7CiAgICAgICAgICAgICAgICB2YXIgJE9iamVjdCA9IE9iamVjdDsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gVVNFX1NZTUJPTF9BU19VSUQgPyBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHlwZW9mIGl0ID09ICdzeW1ib2wnOwogICAgICAgICAgICAgICAgfSA6IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHZhciAkU3ltYm9sID0gZ2V0QnVpbHRJbignU3ltYm9sJyk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGlzQ2FsbGFibGUoJFN5bWJvbCkgJiYgaXNQcm90b3R5cGVPZigkU3ltYm9sLnByb3RvdHlwZSwgJE9iamVjdChpdCkpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMjcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBhRnVuY3Rpb24gPSBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXNDYWxsYWJsZShhcmd1bWVudCkgPyBhcmd1bWVudCA6IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChuYW1lc3BhY2UsIG1ldGhvZCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBhcmd1bWVudHMubGVuZ3RoIDwgMiA/IGFGdW5jdGlvbihnbG9iYWxbbmFtZXNwYWNlXSkgOiBnbG9iYWxbbmFtZXNwYWNlXSAmJiBnbG9iYWxbbmFtZXNwYWNlXVttZXRob2RdOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMjggKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB1bmN1cnJ5VGhpcyh7fS5pc1Byb3RvdHlwZU9mKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMjkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBOQVRJVkVfU1lNQk9MID0gX193X3BkZmpzX3JlcXVpcmVfXygzMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IE5BVElWRV9TWU1CT0wgJiYgIVN5bWJvbC5zaGFtICYmIHR5cGVvZiBTeW1ib2wuaXRlcmF0b3IgPT0gJ3N5bWJvbCc7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDMwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgVjhfVkVSU0lPTiA9IF9fd19wZGZqc19yZXF1aXJlX18oMzEpOwogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICEhT2JqZWN0LmdldE93blByb3BlcnR5U3ltYm9scyAmJiAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciBzeW1ib2wgPSBTeW1ib2woKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gIVN0cmluZyhzeW1ib2wpIHx8ICEoT2JqZWN0KHN5bWJvbCkgaW5zdGFuY2VvZiBTeW1ib2wpIHx8ICFTeW1ib2wuc2hhbSAmJiBWOF9WRVJTSU9OICYmIFY4X1ZFUlNJT04gPCA0MTsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAzMSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGdsb2JhbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNyk7CiAgICAgICAgICAgICAgICB2YXIgdXNlckFnZW50ID0gX193X3BkZmpzX3JlcXVpcmVfXygzMik7CiAgICAgICAgICAgICAgICB2YXIgcHJvY2VzcyA9IGdsb2JhbC5wcm9jZXNzOwogICAgICAgICAgICAgICAgdmFyIERlbm8gPSBnbG9iYWwuRGVubzsKICAgICAgICAgICAgICAgIHZhciB2ZXJzaW9ucyA9IHByb2Nlc3MgJiYgcHJvY2Vzcy52ZXJzaW9ucyB8fCBEZW5vICYmIERlbm8udmVyc2lvbjsKICAgICAgICAgICAgICAgIHZhciB2OCA9IHZlcnNpb25zICYmIHZlcnNpb25zLnY4OwogICAgICAgICAgICAgICAgdmFyIG1hdGNoLCB2ZXJzaW9uOwogICAgICAgICAgICAgICAgaWYgKHY4KSB7CiAgICAgICAgICAgICAgICAgICAgbWF0Y2ggPSB2OC5zcGxpdCgnLicpOwogICAgICAgICAgICAgICAgICAgIHZlcnNpb24gPSBtYXRjaFswXSA+IDAgJiYgbWF0Y2hbMF0gPCA0ID8gMSA6ICsobWF0Y2hbMF0gKyBtYXRjaFsxXSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoIXZlcnNpb24gJiYgdXNlckFnZW50KSB7CiAgICAgICAgICAgICAgICAgICAgbWF0Y2ggPSB1c2VyQWdlbnQubWF0Y2goL0VkZ2VcLyhcZCspLyk7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFtYXRjaCB8fCBtYXRjaFsxXSA+PSA3NCkgewogICAgICAgICAgICAgICAgICAgICAgICBtYXRjaCA9IHVzZXJBZ2VudC5tYXRjaCgvQ2hyb21lXC8oXGQrKS8pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobWF0Y2gpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2ZXJzaW9uID0gK21hdGNoWzFdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gdmVyc2lvbjsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMzIgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHR5cGVvZiBuYXZpZ2F0b3IgIT0gJ3VuZGVmaW5lZCcgJiYgU3RyaW5nKG5hdmlnYXRvci51c2VyQWdlbnQpIHx8ICcnOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAzMyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGFDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMzQpOwogICAgICAgICAgICAgICAgdmFyIGlzTnVsbE9yVW5kZWZpbmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygyMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChWLCBQKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGZ1bmMgPSBWW1BdOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBpc051bGxPclVuZGVmaW5lZChmdW5jKSA/IHVuZGVmaW5lZCA6IGFDYWxsYWJsZShmdW5jKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDM0ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIHRyeVRvU3RyaW5nID0gX193X3BkZmpzX3JlcXVpcmVfXygzNSk7CiAgICAgICAgICAgICAgICB2YXIgJFR5cGVFcnJvciA9IFR5cGVFcnJvcjsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGFyZ3VtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzQ2FsbGFibGUoYXJndW1lbnQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYXJndW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcih0cnlUb1N0cmluZyhhcmd1bWVudCkgKyAnIGlzIG5vdCBhIGZ1bmN0aW9uJyk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAzNSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIHZhciAkU3RyaW5nID0gU3RyaW5nOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJFN0cmluZyhhcmd1bWVudCk7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdPYmplY3QnOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDM2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgY2FsbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTEpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc09iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjMpOwogICAgICAgICAgICAgICAgdmFyICRUeXBlRXJyb3IgPSBUeXBlRXJyb3I7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpbnB1dCwgcHJlZikgewogICAgICAgICAgICAgICAgICAgIHZhciBmbiwgdmFsOwogICAgICAgICAgICAgICAgICAgIGlmIChwcmVmID09PSAnc3RyaW5nJyAmJiBpc0NhbGxhYmxlKGZuID0gaW5wdXQudG9TdHJpbmcpICYmICFpc09iamVjdCh2YWwgPSBjYWxsKGZuLCBpbnB1dCkpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsOwogICAgICAgICAgICAgICAgICAgIGlmIChpc0NhbGxhYmxlKGZuID0gaW5wdXQudmFsdWVPZikgJiYgIWlzT2JqZWN0KHZhbCA9IGNhbGwoZm4sIGlucHV0KSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWw7CiAgICAgICAgICAgICAgICAgICAgaWYgKHByZWYgIT09ICdzdHJpbmcnICYmIGlzQ2FsbGFibGUoZm4gPSBpbnB1dC50b1N0cmluZykgJiYgIWlzT2JqZWN0KHZhbCA9IGNhbGwoZm4sIGlucHV0KSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWw7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcigiQ2FuJ3QgY29udmVydCBvYmplY3QgdG8gcHJpbWl0aXZlIHZhbHVlIik7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAzNyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGdsb2JhbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNyk7CiAgICAgICAgICAgICAgICB2YXIgc2hhcmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygzOCk7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgdWlkID0gX193X3BkZmpzX3JlcXVpcmVfXyg0NCk7CiAgICAgICAgICAgICAgICB2YXIgTkFUSVZFX1NZTUJPTCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzApOwogICAgICAgICAgICAgICAgdmFyIFVTRV9TWU1CT0xfQVNfVUlEID0gX193X3BkZmpzX3JlcXVpcmVfXygyOSk7CiAgICAgICAgICAgICAgICB2YXIgU3ltYm9sID0gZ2xvYmFsLlN5bWJvbDsKICAgICAgICAgICAgICAgIHZhciBXZWxsS25vd25TeW1ib2xzU3RvcmUgPSBzaGFyZWQoJ3drcycpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZVdlbGxLbm93blN5bWJvbCA9IFVTRV9TWU1CT0xfQVNfVUlEID8gU3ltYm9sWydmb3InXSB8fCBTeW1ib2wgOiBTeW1ib2wgJiYgU3ltYm9sLndpdGhvdXRTZXR0ZXIgfHwgdWlkOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAobmFtZSkgewogICAgICAgICAgICAgICAgICAgIGlmICghaGFzT3duKFdlbGxLbm93blN5bWJvbHNTdG9yZSwgbmFtZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgV2VsbEtub3duU3ltYm9sc1N0b3JlW25hbWVdID0gTkFUSVZFX1NZTUJPTCAmJiBoYXNPd24oU3ltYm9sLCBuYW1lKSA/IFN5bWJvbFtuYW1lXSA6IGNyZWF0ZVdlbGxLbm93blN5bWJvbCgnU3ltYm9sLicgKyBuYW1lKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFdlbGxLbm93blN5bWJvbHNTdG9yZVtuYW1lXTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDM4ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgSVNfUFVSRSA9IF9fd19wZGZqc19yZXF1aXJlX18oMzkpOwogICAgICAgICAgICAgICAgdmFyIHN0b3JlID0gX193X3BkZmpzX3JlcXVpcmVfXyg0MCk7CiAgICAgICAgICAgICAgICAobW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoa2V5LCB2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdG9yZVtrZXldIHx8IChzdG9yZVtrZXldID0gdmFsdWUgIT09IHVuZGVmaW5lZCA/IHZhbHVlIDoge30pOwogICAgICAgICAgICAgICAgfSkoJ3ZlcnNpb25zJywgW10pLnB1c2goewogICAgICAgICAgICAgICAgICAgIHZlcnNpb246ICczLjI5LjEnLAogICAgICAgICAgICAgICAgICAgIG1vZGU6IElTX1BVUkUgPyAncHVyZScgOiAnZ2xvYmFsJywKICAgICAgICAgICAgICAgICAgICBjb3B5cmlnaHQ6ICfCqSAyMDE0LTIwMjMgRGVuaXMgUHVzaGthcmV2ICh6bG9pcm9jay5ydSknLAogICAgICAgICAgICAgICAgICAgIGxpY2Vuc2U6ICdodHRwczovL2dpdGh1Yi5jb20vemxvaXJvY2svY29yZS1qcy9ibG9iL3YzLjI5LjEvTElDRU5TRScsCiAgICAgICAgICAgICAgICAgICAgc291cmNlOiAnaHR0cHM6Ly9naXRodWIuY29tL3psb2lyb2NrL2NvcmUtanMnCiAgICAgICAgICAgICAgICB9KTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMzkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZhbHNlOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0MCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGdsb2JhbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNyk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lR2xvYmFsUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQxKTsKICAgICAgICAgICAgICAgIHZhciBTSEFSRUQgPSAnX19jb3JlLWpzX3NoYXJlZF9fJzsKICAgICAgICAgICAgICAgIHZhciBzdG9yZSA9IGdsb2JhbFtTSEFSRURdIHx8IGRlZmluZUdsb2JhbFByb3BlcnR5KFNIQVJFRCwge30pOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBzdG9yZTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNDEgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZVByb3BlcnR5ID0gT2JqZWN0LmRlZmluZVByb3BlcnR5OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoa2V5LCB2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KGdsb2JhbCwga2V5LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICBnbG9iYWxba2V5XSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0MiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgdG9PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQzKTsKICAgICAgICAgICAgICAgIHZhciBoYXNPd25Qcm9wZXJ0eSA9IHVuY3VycnlUaGlzKHt9Lmhhc093blByb3BlcnR5KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gT2JqZWN0Lmhhc093biB8fCBmdW5jdGlvbiBoYXNPd24oaXQsIGtleSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBoYXNPd25Qcm9wZXJ0eSh0b09iamVjdChpdCksIGtleSk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0MyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHJlcXVpcmVPYmplY3RDb2VyY2libGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE5KTsKICAgICAgICAgICAgICAgIHZhciAkT2JqZWN0ID0gT2JqZWN0OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gJE9iamVjdChyZXF1aXJlT2JqZWN0Q29lcmNpYmxlKGFyZ3VtZW50KSk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0NCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgaWQgPSAwOwogICAgICAgICAgICAgICAgdmFyIHBvc3RmaXggPSBNYXRoLnJhbmRvbSgpOwogICAgICAgICAgICAgICAgdmFyIHRvU3RyaW5nID0gdW5jdXJyeVRoaXMoMS4wLnRvU3RyaW5nKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGtleSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiAnU3ltYm9sKCcgKyAoa2V5ID09PSB1bmRlZmluZWQgPyAnJyA6IGtleSkgKyAnKV8nICsgdG9TdHJpbmcoKytpZCArIHBvc3RmaXgsIDM2KTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDQ1ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgREVTQ1JJUFRPUlMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkpOwogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlRWxlbWVudCA9IF9fd19wZGZqc19yZXF1aXJlX18oNDYpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSAhREVTQ1JJUFRPUlMgJiYgIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmRlZmluZVByb3BlcnR5KGNyZWF0ZUVsZW1lbnQoJ2RpdicpLCAnYScsIHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gNzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pLmEgIT0gNzsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0NiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGdsb2JhbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNyk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBkb2N1bWVudCA9IGdsb2JhbC5kb2N1bWVudDsKICAgICAgICAgICAgICAgIHZhciBFWElTVFMgPSBpc09iamVjdChkb2N1bWVudCkgJiYgaXNPYmplY3QoZG9jdW1lbnQuY3JlYXRlRWxlbWVudCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBFWElTVFMgPyBkb2N1bWVudC5jcmVhdGVFbGVtZW50KGl0KSA6IHt9OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNDcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lUHJvcGVydHlNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ4KTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVQcm9wZXJ0eURlc2NyaXB0b3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gREVTQ1JJUFRPUlMgPyBmdW5jdGlvbiAob2JqZWN0LCBrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmluZVByb3BlcnR5TW9kdWxlLmYob2JqZWN0LCBrZXksIGNyZWF0ZVByb3BlcnR5RGVzY3JpcHRvcigxLCB2YWx1ZSkpOwogICAgICAgICAgICAgICAgfSA6IGZ1bmN0aW9uIChvYmplY3QsIGtleSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICBvYmplY3Rba2V5XSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBvYmplY3Q7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA0OCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIERFU0NSSVBUT1JTID0gX193X3BkZmpzX3JlcXVpcmVfXyg5KTsKICAgICAgICAgICAgICAgIHZhciBJRThfRE9NX0RFRklORSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDUpOwogICAgICAgICAgICAgICAgdmFyIFY4X1BST1RPVFlQRV9ERUZJTkVfQlVHID0gX193X3BkZmpzX3JlcXVpcmVfXyg0OSk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciB0b1Byb3BlcnR5S2V5ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMSk7CiAgICAgICAgICAgICAgICB2YXIgJFR5cGVFcnJvciA9IFR5cGVFcnJvcjsKICAgICAgICAgICAgICAgIHZhciAkZGVmaW5lUHJvcGVydHkgPSBPYmplY3QuZGVmaW5lUHJvcGVydHk7CiAgICAgICAgICAgICAgICB2YXIgJGdldE93blByb3BlcnR5RGVzY3JpcHRvciA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3I7CiAgICAgICAgICAgICAgICB2YXIgRU5VTUVSQUJMRSA9ICdlbnVtZXJhYmxlJzsKICAgICAgICAgICAgICAgIHZhciBDT05GSUdVUkFCTEUgPSAnY29uZmlndXJhYmxlJzsKICAgICAgICAgICAgICAgIHZhciBXUklUQUJMRSA9ICd3cml0YWJsZSc7CiAgICAgICAgICAgICAgICBleHBvcnRzLmYgPSBERVNDUklQVE9SUyA/IFY4X1BST1RPVFlQRV9ERUZJTkVfQlVHID8gZnVuY3Rpb24gZGVmaW5lUHJvcGVydHkoTywgUCwgQXR0cmlidXRlcykgewogICAgICAgICAgICAgICAgICAgIGFuT2JqZWN0KE8pOwogICAgICAgICAgICAgICAgICAgIFAgPSB0b1Byb3BlcnR5S2V5KFApOwogICAgICAgICAgICAgICAgICAgIGFuT2JqZWN0KEF0dHJpYnV0ZXMpOwogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgTyA9PT0gJ2Z1bmN0aW9uJyAmJiBQID09PSAncHJvdG90eXBlJyAmJiAndmFsdWUnIGluIEF0dHJpYnV0ZXMgJiYgV1JJVEFCTEUgaW4gQXR0cmlidXRlcyAmJiAhQXR0cmlidXRlc1tXUklUQUJMRV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGN1cnJlbnQgPSAkZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yKE8sIFApOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudCAmJiBjdXJyZW50W1dSSVRBQkxFXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgT1tQXSA9IEF0dHJpYnV0ZXMudmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBBdHRyaWJ1dGVzID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogQ09ORklHVVJBQkxFIGluIEF0dHJpYnV0ZXMgPyBBdHRyaWJ1dGVzW0NPTkZJR1VSQUJMRV0gOiBjdXJyZW50W0NPTkZJR1VSQUJMRV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW51bWVyYWJsZTogRU5VTUVSQUJMRSBpbiBBdHRyaWJ1dGVzID8gQXR0cmlidXRlc1tFTlVNRVJBQkxFXSA6IGN1cnJlbnRbRU5VTUVSQUJMRV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiAkZGVmaW5lUHJvcGVydHkoTywgUCwgQXR0cmlidXRlcyk7CiAgICAgICAgICAgICAgICB9IDogJGRlZmluZVByb3BlcnR5IDogZnVuY3Rpb24gZGVmaW5lUHJvcGVydHkoTywgUCwgQXR0cmlidXRlcykgewogICAgICAgICAgICAgICAgICAgIGFuT2JqZWN0KE8pOwogICAgICAgICAgICAgICAgICAgIFAgPSB0b1Byb3BlcnR5S2V5KFApOwogICAgICAgICAgICAgICAgICAgIGFuT2JqZWN0KEF0dHJpYnV0ZXMpOwogICAgICAgICAgICAgICAgICAgIGlmIChJRThfRE9NX0RFRklORSkKICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAkZGVmaW5lUHJvcGVydHkoTywgUCwgQXR0cmlidXRlcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoJ2dldCcgaW4gQXR0cmlidXRlcyB8fCAnc2V0JyBpbiBBdHRyaWJ1dGVzKQogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyAkVHlwZUVycm9yKCdBY2Nlc3NvcnMgbm90IHN1cHBvcnRlZCcpOwogICAgICAgICAgICAgICAgICAgIGlmICgndmFsdWUnIGluIEF0dHJpYnV0ZXMpCiAgICAgICAgICAgICAgICAgICAgICAgIE9bUF0gPSBBdHRyaWJ1dGVzLnZhbHVlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBPOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNDkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gREVTQ1JJUFRPUlMgJiYgZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBPYmplY3QuZGVmaW5lUHJvcGVydHkoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIH0sICdwcm90b3R5cGUnLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiA0MiwKICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgfSkucHJvdG90eXBlICE9IDQyOwogICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDUwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciAkU3RyaW5nID0gU3RyaW5nOwogICAgICAgICAgICAgICAgdmFyICRUeXBlRXJyb3IgPSBUeXBlRXJyb3I7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChhcmd1bWVudCkgewogICAgICAgICAgICAgICAgICAgIGlmIChpc09iamVjdChhcmd1bWVudCkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcmd1bWVudDsKICAgICAgICAgICAgICAgICAgICB0aHJvdyAkVHlwZUVycm9yKCRTdHJpbmcoYXJndW1lbnQpICsgJyBpcyBub3QgYW4gb2JqZWN0Jyk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA1MSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eU1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDgpOwogICAgICAgICAgICAgICAgdmFyIG1ha2VCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1Mik7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lR2xvYmFsUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQxKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKE8sIGtleSwgdmFsdWUsIG9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIW9wdGlvbnMpCiAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbnMgPSB7fTsKICAgICAgICAgICAgICAgICAgICB2YXIgc2ltcGxlID0gb3B0aW9ucy5lbnVtZXJhYmxlOwogICAgICAgICAgICAgICAgICAgIHZhciBuYW1lID0gb3B0aW9ucy5uYW1lICE9PSB1bmRlZmluZWQgPyBvcHRpb25zLm5hbWUgOiBrZXk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzQ2FsbGFibGUodmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICBtYWtlQnVpbHRJbih2YWx1ZSwgbmFtZSwgb3B0aW9ucyk7CiAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMuZ2xvYmFsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzaW1wbGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBPW2tleV0gPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lR2xvYmFsUHJvcGVydHkoa2V5LCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb3B0aW9ucy51bnNhZmUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIE9ba2V5XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgaWYgKE9ba2V5XSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW1wbGUgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzaW1wbGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBPW2tleV0gPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lUHJvcGVydHlNb2R1bGUuZihPLCBrZXksIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW51bWVyYWJsZTogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiAhb3B0aW9ucy5ub25Db25maWd1cmFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6ICFvcHRpb25zLm5vbldyaXRhYmxlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE87CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA1MiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgREVTQ1JJUFRPUlMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkpOwogICAgICAgICAgICAgICAgdmFyIENPTkZJR1VSQUJMRV9GVU5DVElPTl9OQU1FID0gKF9fd19wZGZqc19yZXF1aXJlX18oNTMpLkNPTkZJR1VSQUJMRSk7CiAgICAgICAgICAgICAgICB2YXIgaW5zcGVjdFNvdXJjZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNTQpOwogICAgICAgICAgICAgICAgdmFyIEludGVybmFsU3RhdGVNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDU1KTsKICAgICAgICAgICAgICAgIHZhciBlbmZvcmNlSW50ZXJuYWxTdGF0ZSA9IEludGVybmFsU3RhdGVNb2R1bGUuZW5mb3JjZTsKICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbFN0YXRlID0gSW50ZXJuYWxTdGF0ZU1vZHVsZS5nZXQ7CiAgICAgICAgICAgICAgICB2YXIgJFN0cmluZyA9IFN0cmluZzsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eSA9IE9iamVjdC5kZWZpbmVQcm9wZXJ0eTsKICAgICAgICAgICAgICAgIHZhciBzdHJpbmdTbGljZSA9IHVuY3VycnlUaGlzKCcnLnNsaWNlKTsKICAgICAgICAgICAgICAgIHZhciByZXBsYWNlID0gdW5jdXJyeVRoaXMoJycucmVwbGFjZSk7CiAgICAgICAgICAgICAgICB2YXIgam9pbiA9IHVuY3VycnlUaGlzKFtdLmpvaW4pOwogICAgICAgICAgICAgICAgdmFyIENPTkZJR1VSQUJMRV9MRU5HVEggPSBERVNDUklQVE9SUyAmJiAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBkZWZpbmVQcm9wZXJ0eShmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgfSwgJ2xlbmd0aCcsIHsgdmFsdWU6IDggfSkubGVuZ3RoICE9PSA4OwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB2YXIgVEVNUExBVEUgPSBTdHJpbmcoU3RyaW5nKS5zcGxpdCgnU3RyaW5nJyk7CiAgICAgICAgICAgICAgICB2YXIgbWFrZUJ1aWx0SW4gPSBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uICh2YWx1ZSwgbmFtZSwgb3B0aW9ucykgewogICAgICAgICAgICAgICAgICAgIGlmIChzdHJpbmdTbGljZSgkU3RyaW5nKG5hbWUpLCAwLCA3KSA9PT0gJ1N5bWJvbCgnKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUgPSAnWycgKyByZXBsYWNlKCRTdHJpbmcobmFtZSksIC9eU3ltYm9sXCgoW14pXSopXCkvLCAnJDEnKSArICddJzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMgJiYgb3B0aW9ucy5nZXR0ZXIpCiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUgPSAnZ2V0ICcgKyBuYW1lOwogICAgICAgICAgICAgICAgICAgIGlmIChvcHRpb25zICYmIG9wdGlvbnMuc2V0dGVyKQogICAgICAgICAgICAgICAgICAgICAgICBuYW1lID0gJ3NldCAnICsgbmFtZTsKICAgICAgICAgICAgICAgICAgICBpZiAoIWhhc093bih2YWx1ZSwgJ25hbWUnKSB8fCBDT05GSUdVUkFCTEVfRlVOQ1RJT05fTkFNRSAmJiB2YWx1ZS5uYW1lICE9PSBuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChERVNDUklQVE9SUykKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KHZhbHVlLCAnbmFtZScsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZS5uYW1lID0gbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKENPTkZJR1VSQUJMRV9MRU5HVEggJiYgb3B0aW9ucyAmJiBoYXNPd24ob3B0aW9ucywgJ2FyaXR5JykgJiYgdmFsdWUubGVuZ3RoICE9PSBvcHRpb25zLmFyaXR5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KHZhbHVlLCAnbGVuZ3RoJywgeyB2YWx1ZTogb3B0aW9ucy5hcml0eSB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wdGlvbnMgJiYgaGFzT3duKG9wdGlvbnMsICdjb25zdHJ1Y3RvcicpICYmIG9wdGlvbnMuY29uc3RydWN0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChERVNDUklQVE9SUykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVQcm9wZXJ0eSh2YWx1ZSwgJ3Byb3RvdHlwZScsIHsgd3JpdGFibGU6IGZhbHNlIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHZhbHVlLnByb3RvdHlwZSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLnByb3RvdHlwZSA9IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBlbmZvcmNlSW50ZXJuYWxTdGF0ZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFoYXNPd24oc3RhdGUsICdzb3VyY2UnKSkgewogICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5zb3VyY2UgPSBqb2luKFRFTVBMQVRFLCB0eXBlb2YgbmFtZSA9PSAnc3RyaW5nJyA/IG5hbWUgOiAnJyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBGdW5jdGlvbi5wcm90b3R5cGUudG9TdHJpbmcgPSBtYWtlQnVpbHRJbihmdW5jdGlvbiB0b1N0cmluZygpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXNDYWxsYWJsZSh0aGlzKSAmJiBnZXRJbnRlcm5hbFN0YXRlKHRoaXMpLnNvdXJjZSB8fCBpbnNwZWN0U291cmNlKHRoaXMpOwogICAgICAgICAgICAgICAgfSwgJ3RvU3RyaW5nJyk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDUzICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgREVTQ1JJUFRPUlMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkpOwogICAgICAgICAgICAgICAgdmFyIGhhc093biA9IF9fd19wZGZqc19yZXF1aXJlX18oNDIpOwogICAgICAgICAgICAgICAgdmFyIEZ1bmN0aW9uUHJvdG90eXBlID0gRnVuY3Rpb24ucHJvdG90eXBlOwogICAgICAgICAgICAgICAgdmFyIGdldERlc2NyaXB0b3IgPSBERVNDUklQVE9SUyAmJiBPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yOwogICAgICAgICAgICAgICAgdmFyIEVYSVNUUyA9IGhhc093bihGdW5jdGlvblByb3RvdHlwZSwgJ25hbWUnKTsKICAgICAgICAgICAgICAgIHZhciBQUk9QRVIgPSBFWElTVFMgJiYgZnVuY3Rpb24gc29tZXRoaW5nKCkgewogICAgICAgICAgICAgICAgfS5uYW1lID09PSAnc29tZXRoaW5nJzsKICAgICAgICAgICAgICAgIHZhciBDT05GSUdVUkFCTEUgPSBFWElTVFMgJiYgKCFERVNDUklQVE9SUyB8fCBERVNDUklQVE9SUyAmJiBnZXREZXNjcmlwdG9yKEZ1bmN0aW9uUHJvdG90eXBlLCAnbmFtZScpLmNvbmZpZ3VyYWJsZSk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHsKICAgICAgICAgICAgICAgICAgICBFWElTVFM6IEVYSVNUUywKICAgICAgICAgICAgICAgICAgICBQUk9QRVI6IFBST1BFUiwKICAgICAgICAgICAgICAgICAgICBDT05GSUdVUkFCTEU6IENPTkZJR1VSQUJMRQogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNTQgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBzdG9yZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDApOwogICAgICAgICAgICAgICAgdmFyIGZ1bmN0aW9uVG9TdHJpbmcgPSB1bmN1cnJ5VGhpcyhGdW5jdGlvbi50b1N0cmluZyk7CiAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUoc3RvcmUuaW5zcGVjdFNvdXJjZSkpIHsKICAgICAgICAgICAgICAgICAgICBzdG9yZS5pbnNwZWN0U291cmNlID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvblRvU3RyaW5nKGl0KTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBzdG9yZS5pbnNwZWN0U291cmNlOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA1NSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIE5BVElWRV9XRUFLX01BUCA9IF9fd19wZGZqc19yZXF1aXJlX18oNTYpOwogICAgICAgICAgICAgICAgdmFyIGdsb2JhbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNyk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ3KTsKICAgICAgICAgICAgICAgIHZhciBoYXNPd24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQyKTsKICAgICAgICAgICAgICAgIHZhciBzaGFyZWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQwKTsKICAgICAgICAgICAgICAgIHZhciBzaGFyZWRLZXkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDU3KTsKICAgICAgICAgICAgICAgIHZhciBoaWRkZW5LZXlzID0gX193X3BkZmpzX3JlcXVpcmVfXyg1OCk7CiAgICAgICAgICAgICAgICB2YXIgT0JKRUNUX0FMUkVBRFlfSU5JVElBTElaRUQgPSAnT2JqZWN0IGFscmVhZHkgaW5pdGlhbGl6ZWQnOwogICAgICAgICAgICAgICAgdmFyIFR5cGVFcnJvciA9IGdsb2JhbC5UeXBlRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgV2Vha01hcCA9IGdsb2JhbC5XZWFrTWFwOwogICAgICAgICAgICAgICAgdmFyIHNldCwgZ2V0LCBoYXM7CiAgICAgICAgICAgICAgICB2YXIgZW5mb3JjZSA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBoYXMoaXQpID8gZ2V0KGl0KSA6IHNldChpdCwge30pOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBnZXR0ZXJGb3IgPSBmdW5jdGlvbiAoVFlQRSkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHN0YXRlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KGl0KSB8fCAoc3RhdGUgPSBnZXQoaXQpKS50eXBlICE9PSBUWVBFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBUeXBlRXJyb3IoJ0luY29tcGF0aWJsZSByZWNlaXZlciwgJyArIFRZUEUgKyAnIHJlcXVpcmVkJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN0YXRlOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgaWYgKE5BVElWRV9XRUFLX01BUCB8fCBzaGFyZWQuc3RhdGUpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgc3RvcmUgPSBzaGFyZWQuc3RhdGUgfHwgKHNoYXJlZC5zdGF0ZSA9IG5ldyBXZWFrTWFwKCkpOwogICAgICAgICAgICAgICAgICAgIHN0b3JlLmdldCA9IHN0b3JlLmdldDsKICAgICAgICAgICAgICAgICAgICBzdG9yZS5oYXMgPSBzdG9yZS5oYXM7CiAgICAgICAgICAgICAgICAgICAgc3RvcmUuc2V0ID0gc3RvcmUuc2V0OwogICAgICAgICAgICAgICAgICAgIHNldCA9IGZ1bmN0aW9uIChpdCwgbWV0YWRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0b3JlLmhhcyhpdCkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBUeXBlRXJyb3IoT0JKRUNUX0FMUkVBRFlfSU5JVElBTElaRUQpOwogICAgICAgICAgICAgICAgICAgICAgICBtZXRhZGF0YS5mYWNhZGUgPSBpdDsKICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmUuc2V0KGl0LCBtZXRhZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBtZXRhZGF0YTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGdldCA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3RvcmUuZ2V0KGl0KSB8fCB7fTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGhhcyA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3RvcmUuaGFzKGl0KTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICB2YXIgU1RBVEUgPSBzaGFyZWRLZXkoJ3N0YXRlJyk7CiAgICAgICAgICAgICAgICAgICAgaGlkZGVuS2V5c1tTVEFURV0gPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIHNldCA9IGZ1bmN0aW9uIChpdCwgbWV0YWRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGhhc093bihpdCwgU1RBVEUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgVHlwZUVycm9yKE9CSkVDVF9BTFJFQURZX0lOSVRJQUxJWkVEKTsKICAgICAgICAgICAgICAgICAgICAgICAgbWV0YWRhdGEuZmFjYWRlID0gaXQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShpdCwgU1RBVEUsIG1ldGFkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1ldGFkYXRhOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgZ2V0ID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBoYXNPd24oaXQsIFNUQVRFKSA/IGl0W1NUQVRFXSA6IHt9OwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgaGFzID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBoYXNPd24oaXQsIFNUQVRFKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgc2V0OiBzZXQsCiAgICAgICAgICAgICAgICAgICAgZ2V0OiBnZXQsCiAgICAgICAgICAgICAgICAgICAgaGFzOiBoYXMsCiAgICAgICAgICAgICAgICAgICAgZW5mb3JjZTogZW5mb3JjZSwKICAgICAgICAgICAgICAgICAgICBnZXR0ZXJGb3I6IGdldHRlckZvcgogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNTYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBXZWFrTWFwID0gZ2xvYmFsLldlYWtNYXA7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGlzQ2FsbGFibGUoV2Vha01hcCkgJiYgL25hdGl2ZSBjb2RlLy50ZXN0KFN0cmluZyhXZWFrTWFwKSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDU3ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgc2hhcmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygzOCk7CiAgICAgICAgICAgICAgICB2YXIgdWlkID0gX193X3BkZmpzX3JlcXVpcmVfXyg0NCk7CiAgICAgICAgICAgICAgICB2YXIga2V5cyA9IHNoYXJlZCgna2V5cycpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoa2V5KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGtleXNba2V5XSB8fCAoa2V5c1trZXldID0gdWlkKGtleSkpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNTggKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHt9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA1OSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGhhc093biA9IF9fd19wZGZqc19yZXF1aXJlX18oNDIpOwogICAgICAgICAgICAgICAgdmFyIG93bktleXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYwKTsKICAgICAgICAgICAgICAgIHZhciBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3JNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDgpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZVByb3BlcnR5TW9kdWxlID0gX193X3BkZmpzX3JlcXVpcmVfXyg0OCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uICh0YXJnZXQsIHNvdXJjZSwgZXhjZXB0aW9ucykgewogICAgICAgICAgICAgICAgICAgIHZhciBrZXlzID0gb3duS2V5cyhzb3VyY2UpOwogICAgICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eSA9IGRlZmluZVByb3BlcnR5TW9kdWxlLmY7CiAgICAgICAgICAgICAgICAgICAgdmFyIGdldE93blByb3BlcnR5RGVzY3JpcHRvciA9IGdldE93blByb3BlcnR5RGVzY3JpcHRvck1vZHVsZS5mOwogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwga2V5cy5sZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIga2V5ID0ga2V5c1tpXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFoYXNPd24odGFyZ2V0LCBrZXkpICYmICEoZXhjZXB0aW9ucyAmJiBoYXNPd24oZXhjZXB0aW9ucywga2V5KSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KHRhcmdldCwga2V5LCBnZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3Ioc291cmNlLCBrZXkpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDYwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZ2V0QnVpbHRJbiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjcpOwogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjEpOwogICAgICAgICAgICAgICAgdmFyIGdldE93blByb3BlcnR5U3ltYm9sc01vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNzApOwogICAgICAgICAgICAgICAgdmFyIGFuT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MCk7CiAgICAgICAgICAgICAgICB2YXIgY29uY2F0ID0gdW5jdXJyeVRoaXMoW10uY29uY2F0KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZ2V0QnVpbHRJbignUmVmbGVjdCcsICdvd25LZXlzJykgfHwgZnVuY3Rpb24gb3duS2V5cyhpdCkgewogICAgICAgICAgICAgICAgICAgIHZhciBrZXlzID0gZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZS5mKGFuT2JqZWN0KGl0KSk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGdldE93blByb3BlcnR5U3ltYm9scyA9IGdldE93blByb3BlcnR5U3ltYm9sc01vZHVsZS5mOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBnZXRPd25Qcm9wZXJ0eVN5bWJvbHMgPyBjb25jYXQoa2V5cywgZ2V0T3duUHJvcGVydHlTeW1ib2xzKGl0KSkgOiBrZXlzOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNjEgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBpbnRlcm5hbE9iamVjdEtleXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYyKTsKICAgICAgICAgICAgICAgIHZhciBlbnVtQnVnS2V5cyA9IF9fd19wZGZqc19yZXF1aXJlX18oNjkpOwogICAgICAgICAgICAgICAgdmFyIGhpZGRlbktleXMgPSBlbnVtQnVnS2V5cy5jb25jYXQoJ2xlbmd0aCcsICdwcm90b3R5cGUnKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuZiA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eU5hbWVzIHx8IGZ1bmN0aW9uIGdldE93blByb3BlcnR5TmFtZXMoTykgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBpbnRlcm5hbE9iamVjdEtleXMoTywgaGlkZGVuS2V5cyk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA2MiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgdG9JbmRleGVkT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNSk7CiAgICAgICAgICAgICAgICB2YXIgaW5kZXhPZiA9IChfX3dfcGRmanNfcmVxdWlyZV9fKDYzKS5pbmRleE9mKTsKICAgICAgICAgICAgICAgIHZhciBoaWRkZW5LZXlzID0gX193X3BkZmpzX3JlcXVpcmVfXyg1OCk7CiAgICAgICAgICAgICAgICB2YXIgcHVzaCA9IHVuY3VycnlUaGlzKFtdLnB1c2gpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAob2JqZWN0LCBuYW1lcykgewogICAgICAgICAgICAgICAgICAgIHZhciBPID0gdG9JbmRleGVkT2JqZWN0KG9iamVjdCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGkgPSAwOwogICAgICAgICAgICAgICAgICAgIHZhciByZXN1bHQgPSBbXTsKICAgICAgICAgICAgICAgICAgICB2YXIga2V5OwogICAgICAgICAgICAgICAgICAgIGZvciAoa2V5IGluIE8pCiAgICAgICAgICAgICAgICAgICAgICAgICFoYXNPd24oaGlkZGVuS2V5cywga2V5KSAmJiBoYXNPd24oTywga2V5KSAmJiBwdXNoKHJlc3VsdCwga2V5KTsKICAgICAgICAgICAgICAgICAgICB3aGlsZSAobmFtZXMubGVuZ3RoID4gaSkKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGhhc093bihPLCBrZXkgPSBuYW1lc1tpKytdKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgfmluZGV4T2YocmVzdWx0LCBrZXkpIHx8IHB1c2gocmVzdWx0LCBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDYzICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgdG9JbmRleGVkT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNSk7CiAgICAgICAgICAgICAgICB2YXIgdG9BYnNvbHV0ZUluZGV4ID0gX193X3BkZmpzX3JlcXVpcmVfXyg2NCk7CiAgICAgICAgICAgICAgICB2YXIgbGVuZ3RoT2ZBcnJheUxpa2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDY3KTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVNZXRob2QgPSBmdW5jdGlvbiAoSVNfSU5DTFVERVMpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKCR0aGlzLCBlbCwgZnJvbUluZGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBPID0gdG9JbmRleGVkT2JqZWN0KCR0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGxlbmd0aCA9IGxlbmd0aE9mQXJyYXlMaWtlKE8pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgaW5kZXggPSB0b0Fic29sdXRlSW5kZXgoZnJvbUluZGV4LCBsZW5ndGgpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChJU19JTkNMVURFUyAmJiBlbCAhPSBlbCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChsZW5ndGggPiBpbmRleCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlID0gT1tpbmRleCsrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmFsdWUgIT0gdmFsdWUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKDsgbGVuZ3RoID4gaW5kZXg7IGluZGV4KyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoKElTX0lOQ0xVREVTIHx8IGluZGV4IGluIE8pICYmIE9baW5kZXhdID09PSBlbCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElTX0lOQ0xVREVTIHx8IGluZGV4IHx8IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhSVNfSU5DTFVERVMgJiYgLTE7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHsKICAgICAgICAgICAgICAgICAgICBpbmNsdWRlczogY3JlYXRlTWV0aG9kKHRydWUpLAogICAgICAgICAgICAgICAgICAgIGluZGV4T2Y6IGNyZWF0ZU1ldGhvZChmYWxzZSkKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDY0ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgdG9JbnRlZ2VyT3JJbmZpbml0eSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjUpOwogICAgICAgICAgICAgICAgdmFyIG1heCA9IE1hdGgubWF4OwogICAgICAgICAgICAgICAgdmFyIG1pbiA9IE1hdGgubWluOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaW5kZXgsIGxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgIHZhciBpbnRlZ2VyID0gdG9JbnRlZ2VyT3JJbmZpbml0eShpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGludGVnZXIgPCAwID8gbWF4KGludGVnZXIgKyBsZW5ndGgsIDApIDogbWluKGludGVnZXIsIGxlbmd0aCk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA2NSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHRydW5jID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nik7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChhcmd1bWVudCkgewogICAgICAgICAgICAgICAgICAgIHZhciBudW1iZXIgPSArYXJndW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bWJlciAhPT0gbnVtYmVyIHx8IG51bWJlciA9PT0gMCA/IDAgOiB0cnVuYyhudW1iZXIpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNjYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgY2VpbCA9IE1hdGguY2VpbDsKICAgICAgICAgICAgICAgIHZhciBmbG9vciA9IE1hdGguZmxvb3I7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IE1hdGgudHJ1bmMgfHwgZnVuY3Rpb24gdHJ1bmMoeCkgewogICAgICAgICAgICAgICAgICAgIHZhciBuID0gK3g7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChuID4gMCA/IGZsb29yIDogY2VpbCkobik7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA2NyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHRvTGVuZ3RoID0gX193X3BkZmpzX3JlcXVpcmVfXyg2OCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChvYmopIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdG9MZW5ndGgob2JqLmxlbmd0aCk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA2OCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHRvSW50ZWdlck9ySW5maW5pdHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDY1KTsKICAgICAgICAgICAgICAgIHZhciBtaW4gPSBNYXRoLm1pbjsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGFyZ3VtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFyZ3VtZW50ID4gMCA/IG1pbih0b0ludGVnZXJPckluZmluaXR5KGFyZ3VtZW50KSwgMHgxRkZGRkZGRkZGRkZGRikgOiAwOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNjkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IFsKICAgICAgICAgICAgICAgICAgICAnY29uc3RydWN0b3InLAogICAgICAgICAgICAgICAgICAgICdoYXNPd25Qcm9wZXJ0eScsCiAgICAgICAgICAgICAgICAgICAgJ2lzUHJvdG90eXBlT2YnLAogICAgICAgICAgICAgICAgICAgICdwcm9wZXJ0eUlzRW51bWVyYWJsZScsCiAgICAgICAgICAgICAgICAgICAgJ3RvTG9jYWxlU3RyaW5nJywKICAgICAgICAgICAgICAgICAgICAndG9TdHJpbmcnLAogICAgICAgICAgICAgICAgICAgICd2YWx1ZU9mJwogICAgICAgICAgICAgICAgXTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNzAgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cykgPT4gewoKICAgICAgICAgICAgICAgIGV4cG9ydHMuZiA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHM7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDcxICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgcmVwbGFjZW1lbnQgPSAvI3xcLnByb3RvdHlwZVwuLzsKICAgICAgICAgICAgICAgIHZhciBpc0ZvcmNlZCA9IGZ1bmN0aW9uIChmZWF0dXJlLCBkZXRlY3Rpb24pIHsKICAgICAgICAgICAgICAgICAgICB2YXIgdmFsdWUgPSBkYXRhW25vcm1hbGl6ZShmZWF0dXJlKV07CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlID09IFBPTFlGSUxMID8gdHJ1ZSA6IHZhbHVlID09IE5BVElWRSA/IGZhbHNlIDogaXNDYWxsYWJsZShkZXRlY3Rpb24pID8gZmFpbHMoZGV0ZWN0aW9uKSA6ICEhZGV0ZWN0aW9uOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBub3JtYWxpemUgPSBpc0ZvcmNlZC5ub3JtYWxpemUgPSBmdW5jdGlvbiAoc3RyaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFN0cmluZyhzdHJpbmcpLnJlcGxhY2UocmVwbGFjZW1lbnQsICcuJykudG9Mb3dlckNhc2UoKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgZGF0YSA9IGlzRm9yY2VkLmRhdGEgPSB7fTsKICAgICAgICAgICAgICAgIHZhciBOQVRJVkUgPSBpc0ZvcmNlZC5OQVRJVkUgPSAnTic7CiAgICAgICAgICAgICAgICB2YXIgUE9MWUZJTEwgPSBpc0ZvcmNlZC5QT0xZRklMTCA9ICdQJzsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gaXNGb3JjZWQ7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDcyICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlID0gX193X3BkZmpzX3JlcXVpcmVfXyg3Myk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lUHJvcGVydHkgPSAoX193X3BkZmpzX3JlcXVpcmVfXyg0OCkuZik7CiAgICAgICAgICAgICAgICB2YXIgVU5TQ09QQUJMRVMgPSB3ZWxsS25vd25TeW1ib2woJ3Vuc2NvcGFibGVzJyk7CiAgICAgICAgICAgICAgICB2YXIgQXJyYXlQcm90b3R5cGUgPSBBcnJheS5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICBpZiAoQXJyYXlQcm90b3R5cGVbVU5TQ09QQUJMRVNdID09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KEFycmF5UHJvdG90eXBlLCBVTlNDT1BBQkxFUywgewogICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjcmVhdGUobnVsbCkKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGtleSkgewogICAgICAgICAgICAgICAgICAgIEFycmF5UHJvdG90eXBlW1VOU0NPUEFCTEVTXVtrZXldID0gdHJ1ZTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDczICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0aWVzTW9kdWxlID0gX193X3BkZmpzX3JlcXVpcmVfXyg3NCk7CiAgICAgICAgICAgICAgICB2YXIgZW51bUJ1Z0tleXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDY5KTsKICAgICAgICAgICAgICAgIHZhciBoaWRkZW5LZXlzID0gX193X3BkZmpzX3JlcXVpcmVfXyg1OCk7CiAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IF9fd19wZGZqc19yZXF1aXJlX18oNzYpOwogICAgICAgICAgICAgICAgdmFyIGRvY3VtZW50Q3JlYXRlRWxlbWVudCA9IF9fd19wZGZqc19yZXF1aXJlX18oNDYpOwogICAgICAgICAgICAgICAgdmFyIHNoYXJlZEtleSA9IF9fd19wZGZqc19yZXF1aXJlX18oNTcpOwogICAgICAgICAgICAgICAgdmFyIEdUID0gJz4nOwogICAgICAgICAgICAgICAgdmFyIExUID0gJzwnOwogICAgICAgICAgICAgICAgdmFyIFBST1RPVFlQRSA9ICdwcm90b3R5cGUnOwogICAgICAgICAgICAgICAgdmFyIFNDUklQVCA9ICdzY3JpcHQnOwogICAgICAgICAgICAgICAgdmFyIElFX1BST1RPID0gc2hhcmVkS2V5KCdJRV9QUk9UTycpOwogICAgICAgICAgICAgICAgdmFyIEVtcHR5Q29uc3RydWN0b3IgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIHNjcmlwdFRhZyA9IGZ1bmN0aW9uIChjb250ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIExUICsgU0NSSVBUICsgR1QgKyBjb250ZW50ICsgTFQgKyAnLycgKyBTQ1JJUFQgKyBHVDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgTnVsbFByb3RvT2JqZWN0VmlhQWN0aXZlWCA9IGZ1bmN0aW9uIChhY3RpdmVYRG9jdW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICBhY3RpdmVYRG9jdW1lbnQud3JpdGUoc2NyaXB0VGFnKCcnKSk7CiAgICAgICAgICAgICAgICAgICAgYWN0aXZlWERvY3VtZW50LmNsb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIHRlbXAgPSBhY3RpdmVYRG9jdW1lbnQucGFyZW50V2luZG93Lk9iamVjdDsKICAgICAgICAgICAgICAgICAgICBhY3RpdmVYRG9jdW1lbnQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB0ZW1wOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBOdWxsUHJvdG9PYmplY3RWaWFJRnJhbWUgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGlmcmFtZSA9IGRvY3VtZW50Q3JlYXRlRWxlbWVudCgnaWZyYW1lJyk7CiAgICAgICAgICAgICAgICAgICAgdmFyIEpTID0gJ2phdmEnICsgU0NSSVBUICsgJzonOwogICAgICAgICAgICAgICAgICAgIHZhciBpZnJhbWVEb2N1bWVudDsKICAgICAgICAgICAgICAgICAgICBpZnJhbWUuc3R5bGUuZGlzcGxheSA9ICdub25lJzsKICAgICAgICAgICAgICAgICAgICBodG1sLmFwcGVuZENoaWxkKGlmcmFtZSk7CiAgICAgICAgICAgICAgICAgICAgaWZyYW1lLnNyYyA9IFN0cmluZyhKUyk7CiAgICAgICAgICAgICAgICAgICAgaWZyYW1lRG9jdW1lbnQgPSBpZnJhbWUuY29udGVudFdpbmRvdy5kb2N1bWVudDsKICAgICAgICAgICAgICAgICAgICBpZnJhbWVEb2N1bWVudC5vcGVuKCk7CiAgICAgICAgICAgICAgICAgICAgaWZyYW1lRG9jdW1lbnQud3JpdGUoc2NyaXB0VGFnKCdkb2N1bWVudC5GPU9iamVjdCcpKTsKICAgICAgICAgICAgICAgICAgICBpZnJhbWVEb2N1bWVudC5jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBpZnJhbWVEb2N1bWVudC5GOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBhY3RpdmVYRG9jdW1lbnQ7CiAgICAgICAgICAgICAgICB2YXIgTnVsbFByb3RvT2JqZWN0ID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGFjdGl2ZVhEb2N1bWVudCA9IG5ldyBBY3RpdmVYT2JqZWN0KCdodG1sZmlsZScpOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIE51bGxQcm90b09iamVjdCA9IHR5cGVvZiBkb2N1bWVudCAhPSAndW5kZWZpbmVkJyA/IGRvY3VtZW50LmRvbWFpbiAmJiBhY3RpdmVYRG9jdW1lbnQgPyBOdWxsUHJvdG9PYmplY3RWaWFBY3RpdmVYKGFjdGl2ZVhEb2N1bWVudCkgOiBOdWxsUHJvdG9PYmplY3RWaWFJRnJhbWUoKSA6IE51bGxQcm90b09iamVjdFZpYUFjdGl2ZVgoYWN0aXZlWERvY3VtZW50KTsKICAgICAgICAgICAgICAgICAgICB2YXIgbGVuZ3RoID0gZW51bUJ1Z0tleXMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIHdoaWxlIChsZW5ndGgtLSkKICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIE51bGxQcm90b09iamVjdFtQUk9UT1RZUEVdW2VudW1CdWdLZXlzW2xlbmd0aF1dOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBOdWxsUHJvdG9PYmplY3QoKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBoaWRkZW5LZXlzW0lFX1BST1RPXSA9IHRydWU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IE9iamVjdC5jcmVhdGUgfHwgZnVuY3Rpb24gY3JlYXRlKE8sIFByb3BlcnRpZXMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0OwogICAgICAgICAgICAgICAgICAgIGlmIChPICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIEVtcHR5Q29uc3RydWN0b3JbUFJPVE9UWVBFXSA9IGFuT2JqZWN0KE8pOwogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBuZXcgRW1wdHlDb25zdHJ1Y3RvcigpOwogICAgICAgICAgICAgICAgICAgICAgICBFbXB0eUNvbnN0cnVjdG9yW1BST1RPVFlQRV0gPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRbSUVfUFJPVE9dID0gTzsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gTnVsbFByb3RvT2JqZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFByb3BlcnRpZXMgPT09IHVuZGVmaW5lZCA/IHJlc3VsdCA6IGRlZmluZVByb3BlcnRpZXNNb2R1bGUuZihyZXN1bHQsIFByb3BlcnRpZXMpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNzQgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgVjhfUFJPVE9UWVBFX0RFRklORV9CVUcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ5KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eU1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDgpOwogICAgICAgICAgICAgICAgdmFyIGFuT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MCk7CiAgICAgICAgICAgICAgICB2YXIgdG9JbmRleGVkT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNSk7CiAgICAgICAgICAgICAgICB2YXIgb2JqZWN0S2V5cyA9IF9fd19wZGZqc19yZXF1aXJlX18oNzUpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5mID0gREVTQ1JJUFRPUlMgJiYgIVY4X1BST1RPVFlQRV9ERUZJTkVfQlVHID8gT2JqZWN0LmRlZmluZVByb3BlcnRpZXMgOiBmdW5jdGlvbiBkZWZpbmVQcm9wZXJ0aWVzKE8sIFByb3BlcnRpZXMpIHsKICAgICAgICAgICAgICAgICAgICBhbk9iamVjdChPKTsKICAgICAgICAgICAgICAgICAgICB2YXIgcHJvcHMgPSB0b0luZGV4ZWRPYmplY3QoUHJvcGVydGllcyk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGtleXMgPSBvYmplY3RLZXlzKFByb3BlcnRpZXMpOwogICAgICAgICAgICAgICAgICAgIHZhciBsZW5ndGggPSBrZXlzLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICB2YXIgaW5kZXggPSAwOwogICAgICAgICAgICAgICAgICAgIHZhciBrZXk7CiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGxlbmd0aCA+IGluZGV4KQogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVQcm9wZXJ0eU1vZHVsZS5mKE8sIGtleSA9IGtleXNbaW5kZXgrK10sIHByb3BzW2tleV0pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBPOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNzUgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBpbnRlcm5hbE9iamVjdEtleXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYyKTsKICAgICAgICAgICAgICAgIHZhciBlbnVtQnVnS2V5cyA9IF9fd19wZGZqc19yZXF1aXJlX18oNjkpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBPYmplY3Qua2V5cyB8fCBmdW5jdGlvbiBrZXlzKE8pIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaW50ZXJuYWxPYmplY3RLZXlzKE8sIGVudW1CdWdLZXlzKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDc2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZ2V0QnVpbHRJbiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjcpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBnZXRCdWlsdEluKCdkb2N1bWVudCcsICdkb2N1bWVudEVsZW1lbnQnKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNzcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChDT05TVFJVQ1RPUiwgTUVUSE9EKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVuY3VycnlUaGlzKGdsb2JhbFtDT05TVFJVQ1RPUl0ucHJvdG90eXBlW01FVEhPRF0pOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogNzggKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXyg3OSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDc5ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCiAgICAgICAgICAgICAgICB2YXIgQXJyYXlCdWZmZXJWaWV3Q29yZSA9IF9fd19wZGZqc19yZXF1aXJlX18oODApOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgdG9JbnRlZ2VyT3JJbmZpbml0eSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjUpOwogICAgICAgICAgICAgICAgdmFyIGFUeXBlZEFycmF5ID0gQXJyYXlCdWZmZXJWaWV3Q29yZS5hVHlwZWRBcnJheTsKICAgICAgICAgICAgICAgIHZhciBleHBvcnRUeXBlZEFycmF5TWV0aG9kID0gQXJyYXlCdWZmZXJWaWV3Q29yZS5leHBvcnRUeXBlZEFycmF5TWV0aG9kOwogICAgICAgICAgICAgICAgZXhwb3J0VHlwZWRBcnJheU1ldGhvZCgnYXQnLCBmdW5jdGlvbiBhdChpbmRleCkgewogICAgICAgICAgICAgICAgICAgIHZhciBPID0gYVR5cGVkQXJyYXkodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGxlbiA9IGxlbmd0aE9mQXJyYXlMaWtlKE8pOwogICAgICAgICAgICAgICAgICAgIHZhciByZWxhdGl2ZUluZGV4ID0gdG9JbnRlZ2VyT3JJbmZpbml0eShpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGsgPSByZWxhdGl2ZUluZGV4ID49IDAgPyByZWxhdGl2ZUluZGV4IDogbGVuICsgcmVsYXRpdmVJbmRleDsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gayA8IDAgfHwgayA+PSBsZW4gPyB1bmRlZmluZWQgOiBPW2tdOwogICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDgwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIE5BVElWRV9BUlJBWV9CVUZGRVIgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDgxKTsKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgZ2xvYmFsID0gX193X3BkZmpzX3JlcXVpcmVfXyg3KTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBoYXNPd24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQyKTsKICAgICAgICAgICAgICAgIHZhciBjbGFzc29mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Mik7CiAgICAgICAgICAgICAgICB2YXIgdHJ5VG9TdHJpbmcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM1KTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ3KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lQnVpbHRJbkFjY2Vzc29yID0gX193X3BkZmpzX3JlcXVpcmVfXyg4NCk7CiAgICAgICAgICAgICAgICB2YXIgaXNQcm90b3R5cGVPZiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjgpOwogICAgICAgICAgICAgICAgdmFyIGdldFByb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4NSk7CiAgICAgICAgICAgICAgICB2YXIgc2V0UHJvdG90eXBlT2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg3KTsKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciB1aWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ0KTsKICAgICAgICAgICAgICAgIHZhciBJbnRlcm5hbFN0YXRlTW9kdWxlID0gX193X3BkZmpzX3JlcXVpcmVfXyg1NSk7CiAgICAgICAgICAgICAgICB2YXIgZW5mb3JjZUludGVybmFsU3RhdGUgPSBJbnRlcm5hbFN0YXRlTW9kdWxlLmVuZm9yY2U7CiAgICAgICAgICAgICAgICB2YXIgZ2V0SW50ZXJuYWxTdGF0ZSA9IEludGVybmFsU3RhdGVNb2R1bGUuZ2V0OwogICAgICAgICAgICAgICAgdmFyIEludDhBcnJheSA9IGdsb2JhbC5JbnQ4QXJyYXk7CiAgICAgICAgICAgICAgICB2YXIgSW50OEFycmF5UHJvdG90eXBlID0gSW50OEFycmF5ICYmIEludDhBcnJheS5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICB2YXIgVWludDhDbGFtcGVkQXJyYXkgPSBnbG9iYWwuVWludDhDbGFtcGVkQXJyYXk7CiAgICAgICAgICAgICAgICB2YXIgVWludDhDbGFtcGVkQXJyYXlQcm90b3R5cGUgPSBVaW50OENsYW1wZWRBcnJheSAmJiBVaW50OENsYW1wZWRBcnJheS5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICB2YXIgVHlwZWRBcnJheSA9IEludDhBcnJheSAmJiBnZXRQcm90b3R5cGVPZihJbnQ4QXJyYXkpOwogICAgICAgICAgICAgICAgdmFyIFR5cGVkQXJyYXlQcm90b3R5cGUgPSBJbnQ4QXJyYXlQcm90b3R5cGUgJiYgZ2V0UHJvdG90eXBlT2YoSW50OEFycmF5UHJvdG90eXBlKTsKICAgICAgICAgICAgICAgIHZhciBPYmplY3RQcm90b3R5cGUgPSBPYmplY3QucHJvdG90eXBlOwogICAgICAgICAgICAgICAgdmFyIFR5cGVFcnJvciA9IGdsb2JhbC5UeXBlRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgVE9fU1RSSU5HX1RBRyA9IHdlbGxLbm93blN5bWJvbCgndG9TdHJpbmdUYWcnKTsKICAgICAgICAgICAgICAgIHZhciBUWVBFRF9BUlJBWV9UQUcgPSB1aWQoJ1RZUEVEX0FSUkFZX1RBRycpOwogICAgICAgICAgICAgICAgdmFyIFRZUEVEX0FSUkFZX0NPTlNUUlVDVE9SID0gJ1R5cGVkQXJyYXlDb25zdHJ1Y3Rvcic7CiAgICAgICAgICAgICAgICB2YXIgTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUyA9IE5BVElWRV9BUlJBWV9CVUZGRVIgJiYgISFzZXRQcm90b3R5cGVPZiAmJiBjbGFzc29mKGdsb2JhbC5vcGVyYSkgIT09ICdPcGVyYSc7CiAgICAgICAgICAgICAgICB2YXIgVFlQRURfQVJSQVlfVEFHX1JFUVVJUkVEID0gZmFsc2U7CiAgICAgICAgICAgICAgICB2YXIgTkFNRSwgQ29uc3RydWN0b3IsIFByb3RvdHlwZTsKICAgICAgICAgICAgICAgIHZhciBUeXBlZEFycmF5Q29uc3RydWN0b3JzTGlzdCA9IHsKICAgICAgICAgICAgICAgICAgICBJbnQ4QXJyYXk6IDEsCiAgICAgICAgICAgICAgICAgICAgVWludDhBcnJheTogMSwKICAgICAgICAgICAgICAgICAgICBVaW50OENsYW1wZWRBcnJheTogMSwKICAgICAgICAgICAgICAgICAgICBJbnQxNkFycmF5OiAyLAogICAgICAgICAgICAgICAgICAgIFVpbnQxNkFycmF5OiAyLAogICAgICAgICAgICAgICAgICAgIEludDMyQXJyYXk6IDQsCiAgICAgICAgICAgICAgICAgICAgVWludDMyQXJyYXk6IDQsCiAgICAgICAgICAgICAgICAgICAgRmxvYXQzMkFycmF5OiA0LAogICAgICAgICAgICAgICAgICAgIEZsb2F0NjRBcnJheTogOAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBCaWdJbnRBcnJheUNvbnN0cnVjdG9yc0xpc3QgPSB7CiAgICAgICAgICAgICAgICAgICAgQmlnSW50NjRBcnJheTogOCwKICAgICAgICAgICAgICAgICAgICBCaWdVaW50NjRBcnJheTogOAogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBpc1ZpZXcgPSBmdW5jdGlvbiBpc1ZpZXcoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBrbGFzcyA9IGNsYXNzb2YoaXQpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBrbGFzcyA9PT0gJ0RhdGFWaWV3JyB8fCBoYXNPd24oVHlwZWRBcnJheUNvbnN0cnVjdG9yc0xpc3QsIGtsYXNzKSB8fCBoYXNPd24oQmlnSW50QXJyYXlDb25zdHJ1Y3RvcnNMaXN0LCBrbGFzcyk7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIGdldFR5cGVkQXJyYXlDb25zdHJ1Y3RvciA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIHZhciBwcm90byA9IGdldFByb3RvdHlwZU9mKGl0KTsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KHByb3RvKSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIHZhciBzdGF0ZSA9IGdldEludGVybmFsU3RhdGUocHJvdG8pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdGF0ZSAmJiBoYXNPd24oc3RhdGUsIFRZUEVEX0FSUkFZX0NPTlNUUlVDVE9SKSA/IHN0YXRlW1RZUEVEX0FSUkFZX0NPTlNUUlVDVE9SXSA6IGdldFR5cGVkQXJyYXlDb25zdHJ1Y3Rvcihwcm90byk7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIGlzVHlwZWRBcnJheSA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIGlmICghaXNPYmplY3QoaXQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgdmFyIGtsYXNzID0gY2xhc3NvZihpdCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGhhc093bihUeXBlZEFycmF5Q29uc3RydWN0b3JzTGlzdCwga2xhc3MpIHx8IGhhc093bihCaWdJbnRBcnJheUNvbnN0cnVjdG9yc0xpc3QsIGtsYXNzKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgYVR5cGVkQXJyYXkgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaXNUeXBlZEFycmF5KGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0OwogICAgICAgICAgICAgICAgICAgIHRocm93IFR5cGVFcnJvcignVGFyZ2V0IGlzIG5vdCBhIHR5cGVkIGFycmF5Jyk7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIGFUeXBlZEFycmF5Q29uc3RydWN0b3IgPSBmdW5jdGlvbiAoQykgewogICAgICAgICAgICAgICAgICAgIGlmIChpc0NhbGxhYmxlKEMpICYmICghc2V0UHJvdG90eXBlT2YgfHwgaXNQcm90b3R5cGVPZihUeXBlZEFycmF5LCBDKSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBDOwogICAgICAgICAgICAgICAgICAgIHRocm93IFR5cGVFcnJvcih0cnlUb1N0cmluZyhDKSArICcgaXMgbm90IGEgdHlwZWQgYXJyYXkgY29uc3RydWN0b3InKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgZXhwb3J0VHlwZWRBcnJheU1ldGhvZCA9IGZ1bmN0aW9uIChLRVksIHByb3BlcnR5LCBmb3JjZWQsIG9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIURFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgaWYgKGZvcmNlZCkKICAgICAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgQVJSQVkgaW4gVHlwZWRBcnJheUNvbnN0cnVjdG9yc0xpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBUeXBlZEFycmF5Q29uc3RydWN0b3IgPSBnbG9iYWxbQVJSQVldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFR5cGVkQXJyYXlDb25zdHJ1Y3RvciAmJiBoYXNPd24oVHlwZWRBcnJheUNvbnN0cnVjdG9yLnByb3RvdHlwZSwgS0VZKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgVHlwZWRBcnJheUNvbnN0cnVjdG9yLnByb3RvdHlwZVtLRVldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBUeXBlZEFycmF5Q29uc3RydWN0b3IucHJvdG90eXBlW0tFWV0gPSBwcm9wZXJ0eTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoIVR5cGVkQXJyYXlQcm90b3R5cGVbS0VZXSB8fCBmb3JjZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lQnVpbHRJbihUeXBlZEFycmF5UHJvdG90eXBlLCBLRVksIGZvcmNlZCA/IHByb3BlcnR5IDogTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUyAmJiBJbnQ4QXJyYXlQcm90b3R5cGVbS0VZXSB8fCBwcm9wZXJ0eSwgb3B0aW9ucyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBleHBvcnRUeXBlZEFycmF5U3RhdGljTWV0aG9kID0gZnVuY3Rpb24gKEtFWSwgcHJvcGVydHksIGZvcmNlZCkgewogICAgICAgICAgICAgICAgICAgIHZhciBBUlJBWSwgVHlwZWRBcnJheUNvbnN0cnVjdG9yOwogICAgICAgICAgICAgICAgICAgIGlmICghREVTQ1JJUFRPUlMpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICBpZiAoc2V0UHJvdG90eXBlT2YpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZvcmNlZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoQVJSQVkgaW4gVHlwZWRBcnJheUNvbnN0cnVjdG9yc0xpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBUeXBlZEFycmF5Q29uc3RydWN0b3IgPSBnbG9iYWxbQVJSQVldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChUeXBlZEFycmF5Q29uc3RydWN0b3IgJiYgaGFzT3duKFR5cGVkQXJyYXlDb25zdHJ1Y3RvciwgS0VZKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBUeXBlZEFycmF5Q29uc3RydWN0b3JbS0VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIVR5cGVkQXJyYXlbS0VZXSB8fCBmb3JjZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmluZUJ1aWx0SW4oVHlwZWRBcnJheSwgS0VZLCBmb3JjZWQgPyBwcm9wZXJ0eSA6IE5BVElWRV9BUlJBWV9CVUZGRVJfVklFV1MgJiYgVHlwZWRBcnJheVtLRVldIHx8IHByb3BlcnR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKEFSUkFZIGluIFR5cGVkQXJyYXlDb25zdHJ1Y3RvcnNMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIFR5cGVkQXJyYXlDb25zdHJ1Y3RvciA9IGdsb2JhbFtBUlJBWV07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChUeXBlZEFycmF5Q29uc3RydWN0b3IgJiYgKCFUeXBlZEFycmF5Q29uc3RydWN0b3JbS0VZXSB8fCBmb3JjZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluKFR5cGVkQXJyYXlDb25zdHJ1Y3RvciwgS0VZLCBwcm9wZXJ0eSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZm9yIChOQU1FIGluIFR5cGVkQXJyYXlDb25zdHJ1Y3RvcnNMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgQ29uc3RydWN0b3IgPSBnbG9iYWxbTkFNRV07CiAgICAgICAgICAgICAgICAgICAgUHJvdG90eXBlID0gQ29uc3RydWN0b3IgJiYgQ29uc3RydWN0b3IucHJvdG90eXBlOwogICAgICAgICAgICAgICAgICAgIGlmIChQcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgIGVuZm9yY2VJbnRlcm5hbFN0YXRlKFByb3RvdHlwZSlbVFlQRURfQVJSQVlfQ09OU1RSVUNUT1JdID0gQ29uc3RydWN0b3I7CiAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICBOQVRJVkVfQVJSQVlfQlVGRkVSX1ZJRVdTID0gZmFsc2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmb3IgKE5BTUUgaW4gQmlnSW50QXJyYXlDb25zdHJ1Y3RvcnNMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgQ29uc3RydWN0b3IgPSBnbG9iYWxbTkFNRV07CiAgICAgICAgICAgICAgICAgICAgUHJvdG90eXBlID0gQ29uc3RydWN0b3IgJiYgQ29uc3RydWN0b3IucHJvdG90eXBlOwogICAgICAgICAgICAgICAgICAgIGlmIChQcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgIGVuZm9yY2VJbnRlcm5hbFN0YXRlKFByb3RvdHlwZSlbVFlQRURfQVJSQVlfQ09OU1RSVUNUT1JdID0gQ29uc3RydWN0b3I7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoIU5BVElWRV9BUlJBWV9CVUZGRVJfVklFV1MgfHwgIWlzQ2FsbGFibGUoVHlwZWRBcnJheSkgfHwgVHlwZWRBcnJheSA9PT0gRnVuY3Rpb24ucHJvdG90eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgVHlwZWRBcnJheSA9IGZ1bmN0aW9uIFR5cGVkQXJyYXkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IFR5cGVFcnJvcignSW5jb3JyZWN0IGludm9jYXRpb24nKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGlmIChOQVRJVkVfQVJSQVlfQlVGRkVSX1ZJRVdTKQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKE5BTUUgaW4gVHlwZWRBcnJheUNvbnN0cnVjdG9yc0xpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChnbG9iYWxbTkFNRV0pCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0UHJvdG90eXBlT2YoZ2xvYmFsW05BTUVdLCBUeXBlZEFycmF5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKCFOQVRJVkVfQVJSQVlfQlVGRkVSX1ZJRVdTIHx8ICFUeXBlZEFycmF5UHJvdG90eXBlIHx8IFR5cGVkQXJyYXlQcm90b3R5cGUgPT09IE9iamVjdFByb3RvdHlwZSkgewogICAgICAgICAgICAgICAgICAgIFR5cGVkQXJyYXlQcm90b3R5cGUgPSBUeXBlZEFycmF5LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICBpZiAoTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUykKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChOQU1FIGluIFR5cGVkQXJyYXlDb25zdHJ1Y3RvcnNMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ2xvYmFsW05BTUVdKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFByb3RvdHlwZU9mKGdsb2JhbFtOQU1FXS5wcm90b3R5cGUsIFR5cGVkQXJyYXlQcm90b3R5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUyAmJiBnZXRQcm90b3R5cGVPZihVaW50OENsYW1wZWRBcnJheVByb3RvdHlwZSkgIT09IFR5cGVkQXJyYXlQcm90b3R5cGUpIHsKICAgICAgICAgICAgICAgICAgICBzZXRQcm90b3R5cGVPZihVaW50OENsYW1wZWRBcnJheVByb3RvdHlwZSwgVHlwZWRBcnJheVByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBpZiAoREVTQ1JJUFRPUlMgJiYgIWhhc093bihUeXBlZEFycmF5UHJvdG90eXBlLCBUT19TVFJJTkdfVEFHKSkgewogICAgICAgICAgICAgICAgICAgIFRZUEVEX0FSUkFZX1RBR19SRVFVSVJFRCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgZGVmaW5lQnVpbHRJbkFjY2Vzc29yKFR5cGVkQXJyYXlQcm90b3R5cGUsIFRPX1NUUklOR19UQUcsIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpc09iamVjdCh0aGlzKSA/IHRoaXNbVFlQRURfQVJSQVlfVEFHXSA6IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIGZvciAoTkFNRSBpbiBUeXBlZEFycmF5Q29uc3RydWN0b3JzTGlzdCkKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdsb2JhbFtOQU1FXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlTm9uRW51bWVyYWJsZVByb3BlcnR5KGdsb2JhbFtOQU1FXSwgVFlQRURfQVJSQVlfVEFHLCBOQU1FKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUzogTkFUSVZFX0FSUkFZX0JVRkZFUl9WSUVXUywKICAgICAgICAgICAgICAgICAgICBUWVBFRF9BUlJBWV9UQUc6IFRZUEVEX0FSUkFZX1RBR19SRVFVSVJFRCAmJiBUWVBFRF9BUlJBWV9UQUcsCiAgICAgICAgICAgICAgICAgICAgYVR5cGVkQXJyYXk6IGFUeXBlZEFycmF5LAogICAgICAgICAgICAgICAgICAgIGFUeXBlZEFycmF5Q29uc3RydWN0b3I6IGFUeXBlZEFycmF5Q29uc3RydWN0b3IsCiAgICAgICAgICAgICAgICAgICAgZXhwb3J0VHlwZWRBcnJheU1ldGhvZDogZXhwb3J0VHlwZWRBcnJheU1ldGhvZCwKICAgICAgICAgICAgICAgICAgICBleHBvcnRUeXBlZEFycmF5U3RhdGljTWV0aG9kOiBleHBvcnRUeXBlZEFycmF5U3RhdGljTWV0aG9kLAogICAgICAgICAgICAgICAgICAgIGdldFR5cGVkQXJyYXlDb25zdHJ1Y3RvcjogZ2V0VHlwZWRBcnJheUNvbnN0cnVjdG9yLAogICAgICAgICAgICAgICAgICAgIGlzVmlldzogaXNWaWV3LAogICAgICAgICAgICAgICAgICAgIGlzVHlwZWRBcnJheTogaXNUeXBlZEFycmF5LAogICAgICAgICAgICAgICAgICAgIFR5cGVkQXJyYXk6IFR5cGVkQXJyYXksCiAgICAgICAgICAgICAgICAgICAgVHlwZWRBcnJheVByb3RvdHlwZTogVHlwZWRBcnJheVByb3RvdHlwZQogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogODEgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHR5cGVvZiBBcnJheUJ1ZmZlciAhPSAndW5kZWZpbmVkJyAmJiB0eXBlb2YgRGF0YVZpZXcgIT0gJ3VuZGVmaW5lZCc7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDgyICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgVE9fU1RSSU5HX1RBR19TVVBQT1JUID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Myk7CiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIGNsYXNzb2ZSYXcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE4KTsKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciBUT19TVFJJTkdfVEFHID0gd2VsbEtub3duU3ltYm9sKCd0b1N0cmluZ1RhZycpOwogICAgICAgICAgICAgICAgdmFyICRPYmplY3QgPSBPYmplY3Q7CiAgICAgICAgICAgICAgICB2YXIgQ09SUkVDVF9BUkdVTUVOVFMgPSBjbGFzc29mUmF3KChmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFyZ3VtZW50czsKICAgICAgICAgICAgICAgIH0oKSkpID09ICdBcmd1bWVudHMnOwogICAgICAgICAgICAgICAgdmFyIHRyeUdldCA9IGZ1bmN0aW9uIChpdCwga2V5KSB7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0W2tleV07CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBUT19TVFJJTkdfVEFHX1NVUFBPUlQgPyBjbGFzc29mUmF3IDogZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIE8sIHRhZywgcmVzdWx0OwogICAgICAgICAgICAgICAgICAgIHJldHVybiBpdCA9PT0gdW5kZWZpbmVkID8gJ1VuZGVmaW5lZCcgOiBpdCA9PT0gbnVsbCA/ICdOdWxsJyA6IHR5cGVvZiAodGFnID0gdHJ5R2V0KE8gPSAkT2JqZWN0KGl0KSwgVE9fU1RSSU5HX1RBRykpID09ICdzdHJpbmcnID8gdGFnIDogQ09SUkVDVF9BUkdVTUVOVFMgPyBjbGFzc29mUmF3KE8pIDogKHJlc3VsdCA9IGNsYXNzb2ZSYXcoTykpID09ICdPYmplY3QnICYmIGlzQ2FsbGFibGUoTy5jYWxsZWUpID8gJ0FyZ3VtZW50cycgOiByZXN1bHQ7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA4MyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHdlbGxLbm93blN5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzcpOwogICAgICAgICAgICAgICAgdmFyIFRPX1NUUklOR19UQUcgPSB3ZWxsS25vd25TeW1ib2woJ3RvU3RyaW5nVGFnJyk7CiAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHt9OwogICAgICAgICAgICAgICAgdGVzdFtUT19TVFJJTkdfVEFHXSA9ICd6JzsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gU3RyaW5nKHRlc3QpID09PSAnW29iamVjdCB6XSc7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDg0ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgbWFrZUJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUyKTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDgpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAodGFyZ2V0LCBuYW1lLCBkZXNjcmlwdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGRlc2NyaXB0b3IuZ2V0KQogICAgICAgICAgICAgICAgICAgICAgICBtYWtlQnVpbHRJbihkZXNjcmlwdG9yLmdldCwgbmFtZSwgeyBnZXR0ZXI6IHRydWUgfSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGRlc2NyaXB0b3Iuc2V0KQogICAgICAgICAgICAgICAgICAgICAgICBtYWtlQnVpbHRJbihkZXNjcmlwdG9yLnNldCwgbmFtZSwgeyBzZXR0ZXI6IHRydWUgfSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmluZVByb3BlcnR5LmYodGFyZ2V0LCBuYW1lLCBkZXNjcmlwdG9yKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDg1ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIHRvT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Myk7CiAgICAgICAgICAgICAgICB2YXIgc2hhcmVkS2V5ID0gX193X3BkZmpzX3JlcXVpcmVfXyg1Nyk7CiAgICAgICAgICAgICAgICB2YXIgQ09SUkVDVF9QUk9UT1RZUEVfR0VUVEVSID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Nik7CiAgICAgICAgICAgICAgICB2YXIgSUVfUFJPVE8gPSBzaGFyZWRLZXkoJ0lFX1BST1RPJyk7CiAgICAgICAgICAgICAgICB2YXIgJE9iamVjdCA9IE9iamVjdDsKICAgICAgICAgICAgICAgIHZhciBPYmplY3RQcm90b3R5cGUgPSAkT2JqZWN0LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gQ09SUkVDVF9QUk9UT1RZUEVfR0VUVEVSID8gJE9iamVjdC5nZXRQcm90b3R5cGVPZiA6IGZ1bmN0aW9uIChPKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIG9iamVjdCA9IHRvT2JqZWN0KE8pOwogICAgICAgICAgICAgICAgICAgIGlmIChoYXNPd24ob2JqZWN0LCBJRV9QUk9UTykpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBvYmplY3RbSUVfUFJPVE9dOwogICAgICAgICAgICAgICAgICAgIHZhciBjb25zdHJ1Y3RvciA9IG9iamVjdC5jb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgICAgICBpZiAoaXNDYWxsYWJsZShjb25zdHJ1Y3RvcikgJiYgb2JqZWN0IGluc3RhbmNlb2YgY29uc3RydWN0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbnN0cnVjdG9yLnByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG9iamVjdCBpbnN0YW5jZW9mICRPYmplY3QgPyBPYmplY3RQcm90b3R5cGUgOiBudWxsOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogODYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIEYoKSB7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIEYucHJvdG90eXBlLmNvbnN0cnVjdG9yID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmdldFByb3RvdHlwZU9mKG5ldyBGKCkpICE9PSBGLnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA4NyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzQWNjZXNzb3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg4KTsKICAgICAgICAgICAgICAgIHZhciBhbk9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNTApOwogICAgICAgICAgICAgICAgdmFyIGFQb3NzaWJsZVByb3RvdHlwZSA9IF9fd19wZGZqc19yZXF1aXJlX18oODkpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBPYmplY3Quc2V0UHJvdG90eXBlT2YgfHwgKCdfX3Byb3RvX18nIGluIHt9ID8gKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgQ09SUkVDVF9TRVRURVIgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHt9OwogICAgICAgICAgICAgICAgICAgIHZhciBzZXR0ZXI7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0dGVyID0gdW5jdXJyeVRoaXNBY2Nlc3NvcihPYmplY3QucHJvdG90eXBlLCAnX19wcm90b19fJywgJ3NldCcpOwogICAgICAgICAgICAgICAgICAgICAgICBzZXR0ZXIodGVzdCwgW10pOwogICAgICAgICAgICAgICAgICAgICAgICBDT1JSRUNUX1NFVFRFUiA9IHRlc3QgaW5zdGFuY2VvZiBBcnJheTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gc2V0UHJvdG90eXBlT2YoTywgcHJvdG8pIHsKICAgICAgICAgICAgICAgICAgICAgICAgYW5PYmplY3QoTyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGFQb3NzaWJsZVByb3RvdHlwZShwcm90byk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChDT1JSRUNUX1NFVFRFUikKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldHRlcihPLCBwcm90byk7CiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgIE8uX19wcm90b19fID0gcHJvdG87CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBPOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9KCkpIDogdW5kZWZpbmVkKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogODggKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgdmFyIGFDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMzQpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAob2JqZWN0LCBrZXksIG1ldGhvZCkgewogICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1bmN1cnJ5VGhpcyhhQ2FsbGFibGUoT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcihvYmplY3QsIGtleSlbbWV0aG9kXSkpOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogODkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgJFN0cmluZyA9IFN0cmluZzsKICAgICAgICAgICAgICAgIHZhciAkVHlwZUVycm9yID0gVHlwZUVycm9yOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGFyZ3VtZW50ID09ICdvYmplY3QnIHx8IGlzQ2FsbGFibGUoYXJndW1lbnQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYXJndW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcigiQ2FuJ3Qgc2V0ICIgKyAkU3RyaW5nKGFyZ3VtZW50KSArICcgYXMgYSBwcm90b3R5cGUnKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDkwICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICBfX3dfcGRmanNfcmVxdWlyZV9fKDkxKTsKICAgICAgICAgICAgICAgIF9fd19wZGZqc19yZXF1aXJlX18oOTgpOwogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXygxMDApOwogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXygxMjMpOwogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXygxMjUpOwogICAgICAgICAgICAgICAgdmFyIHBhdGggPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzNyk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHBhdGguc3RydWN0dXJlZENsb25lOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA5MSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciB0b0luZGV4ZWRPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1KTsKICAgICAgICAgICAgICAgIHZhciBhZGRUb1Vuc2NvcGFibGVzID0gX193X3BkZmpzX3JlcXVpcmVfXyg3Mik7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JzID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Mik7CiAgICAgICAgICAgICAgICB2YXIgSW50ZXJuYWxTdGF0ZU1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNTUpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZVByb3BlcnR5ID0gKF9fd19wZGZqc19yZXF1aXJlX18oNDgpLmYpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZUl0ZXJhdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Myk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlSXRlclJlc3VsdE9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oOTcpOwogICAgICAgICAgICAgICAgdmFyIElTX1BVUkUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM5KTsKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgQVJSQVlfSVRFUkFUT1IgPSAnQXJyYXkgSXRlcmF0b3InOwogICAgICAgICAgICAgICAgdmFyIHNldEludGVybmFsU3RhdGUgPSBJbnRlcm5hbFN0YXRlTW9kdWxlLnNldDsKICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbFN0YXRlID0gSW50ZXJuYWxTdGF0ZU1vZHVsZS5nZXR0ZXJGb3IoQVJSQVlfSVRFUkFUT1IpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBkZWZpbmVJdGVyYXRvcihBcnJheSwgJ0FycmF5JywgZnVuY3Rpb24gKGl0ZXJhdGVkLCBraW5kKSB7CiAgICAgICAgICAgICAgICAgICAgc2V0SW50ZXJuYWxTdGF0ZSh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IEFSUkFZX0lURVJBVE9SLAogICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXQ6IHRvSW5kZXhlZE9iamVjdChpdGVyYXRlZCksCiAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4OiAwLAogICAgICAgICAgICAgICAgICAgICAgICBraW5kOiBraW5kCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9LCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHN0YXRlID0gZ2V0SW50ZXJuYWxTdGF0ZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB2YXIgdGFyZ2V0ID0gc3RhdGUudGFyZ2V0OwogICAgICAgICAgICAgICAgICAgIHZhciBraW5kID0gc3RhdGUua2luZDsKICAgICAgICAgICAgICAgICAgICB2YXIgaW5kZXggPSBzdGF0ZS5pbmRleCsrOwogICAgICAgICAgICAgICAgICAgIGlmICghdGFyZ2V0IHx8IGluZGV4ID49IHRhcmdldC5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUudGFyZ2V0ID0gdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlSXRlclJlc3VsdE9iamVjdCh1bmRlZmluZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoa2luZCA9PSAna2V5cycpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjcmVhdGVJdGVyUmVzdWx0T2JqZWN0KGluZGV4LCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGtpbmQgPT0gJ3ZhbHVlcycpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjcmVhdGVJdGVyUmVzdWx0T2JqZWN0KHRhcmdldFtpbmRleF0sIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlSXRlclJlc3VsdE9iamVjdChbCiAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXRbaW5kZXhdCiAgICAgICAgICAgICAgICAgICAgXSwgZmFsc2UpOwogICAgICAgICAgICAgICAgfSwgJ3ZhbHVlcycpOwogICAgICAgICAgICAgICAgdmFyIHZhbHVlcyA9IEl0ZXJhdG9ycy5Bcmd1bWVudHMgPSBJdGVyYXRvcnMuQXJyYXk7CiAgICAgICAgICAgICAgICBhZGRUb1Vuc2NvcGFibGVzKCdrZXlzJyk7CiAgICAgICAgICAgICAgICBhZGRUb1Vuc2NvcGFibGVzKCd2YWx1ZXMnKTsKICAgICAgICAgICAgICAgIGFkZFRvVW5zY29wYWJsZXMoJ2VudHJpZXMnKTsKICAgICAgICAgICAgICAgIGlmICghSVNfUFVSRSAmJiBERVNDUklQVE9SUyAmJiB2YWx1ZXMubmFtZSAhPT0gJ3ZhbHVlcycpCiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lUHJvcGVydHkodmFsdWVzLCAnbmFtZScsIHsgdmFsdWU6ICd2YWx1ZXMnIH0pOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA5MiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0ge307CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDkzICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyICQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYpOwogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExKTsKICAgICAgICAgICAgICAgIHZhciBJU19QVVJFID0gX193X3BkZmpzX3JlcXVpcmVfXygzOSk7CiAgICAgICAgICAgICAgICB2YXIgRnVuY3Rpb25OYW1lID0gX193X3BkZmpzX3JlcXVpcmVfXyg1Myk7CiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZUl0ZXJhdG9yQ29uc3RydWN0b3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk0KTsKICAgICAgICAgICAgICAgIHZhciBnZXRQcm90b3R5cGVPZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODUpOwogICAgICAgICAgICAgICAgdmFyIHNldFByb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Nyk7CiAgICAgICAgICAgICAgICB2YXIgc2V0VG9TdHJpbmdUYWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk2KTsKICAgICAgICAgICAgICAgIHZhciBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQ3KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MSk7CiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JzID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Mik7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JzQ29yZSA9IF9fd19wZGZqc19yZXF1aXJlX18oOTUpOwogICAgICAgICAgICAgICAgdmFyIFBST1BFUl9GVU5DVElPTl9OQU1FID0gRnVuY3Rpb25OYW1lLlBST1BFUjsKICAgICAgICAgICAgICAgIHZhciBDT05GSUdVUkFCTEVfRlVOQ1RJT05fTkFNRSA9IEZ1bmN0aW9uTmFtZS5DT05GSUdVUkFCTEU7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JQcm90b3R5cGUgPSBJdGVyYXRvcnNDb3JlLkl0ZXJhdG9yUHJvdG90eXBlOwogICAgICAgICAgICAgICAgdmFyIEJVR0dZX1NBRkFSSV9JVEVSQVRPUlMgPSBJdGVyYXRvcnNDb3JlLkJVR0dZX1NBRkFSSV9JVEVSQVRPUlM7CiAgICAgICAgICAgICAgICB2YXIgSVRFUkFUT1IgPSB3ZWxsS25vd25TeW1ib2woJ2l0ZXJhdG9yJyk7CiAgICAgICAgICAgICAgICB2YXIgS0VZUyA9ICdrZXlzJzsKICAgICAgICAgICAgICAgIHZhciBWQUxVRVMgPSAndmFsdWVzJzsKICAgICAgICAgICAgICAgIHZhciBFTlRSSUVTID0gJ2VudHJpZXMnOwogICAgICAgICAgICAgICAgdmFyIHJldHVyblRoaXMgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoSXRlcmFibGUsIE5BTUUsIEl0ZXJhdG9yQ29uc3RydWN0b3IsIG5leHQsIERFRkFVTFQsIElTX1NFVCwgRk9SQ0VEKSB7CiAgICAgICAgICAgICAgICAgICAgY3JlYXRlSXRlcmF0b3JDb25zdHJ1Y3RvcihJdGVyYXRvckNvbnN0cnVjdG9yLCBOQU1FLCBuZXh0KTsKICAgICAgICAgICAgICAgICAgICB2YXIgZ2V0SXRlcmF0aW9uTWV0aG9kID0gZnVuY3Rpb24gKEtJTkQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEtJTkQgPT09IERFRkFVTFQgJiYgZGVmYXVsdEl0ZXJhdG9yKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmF1bHRJdGVyYXRvcjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFCVUdHWV9TQUZBUklfSVRFUkFUT1JTICYmIEtJTkQgaW4gSXRlcmFibGVQcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gSXRlcmFibGVQcm90b3R5cGVbS0lORF07CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoS0lORCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBLRVlTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBrZXlzKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEl0ZXJhdG9yQ29uc3RydWN0b3IodGhpcywgS0lORCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgVkFMVUVTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiB2YWx1ZXMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgSXRlcmF0b3JDb25zdHJ1Y3Rvcih0aGlzLCBLSU5EKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBFTlRSSUVTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBlbnRyaWVzKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEl0ZXJhdG9yQ29uc3RydWN0b3IodGhpcywgS0lORCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBJdGVyYXRvckNvbnN0cnVjdG9yKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgdmFyIFRPX1NUUklOR19UQUcgPSBOQU1FICsgJyBJdGVyYXRvcic7CiAgICAgICAgICAgICAgICAgICAgdmFyIElOQ09SUkVDVF9WQUxVRVNfTkFNRSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBJdGVyYWJsZVByb3RvdHlwZSA9IEl0ZXJhYmxlLnByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICB2YXIgbmF0aXZlSXRlcmF0b3IgPSBJdGVyYWJsZVByb3RvdHlwZVtJVEVSQVRPUl0gfHwgSXRlcmFibGVQcm90b3R5cGVbJ0BAaXRlcmF0b3InXSB8fCBERUZBVUxUICYmIEl0ZXJhYmxlUHJvdG90eXBlW0RFRkFVTFRdOwogICAgICAgICAgICAgICAgICAgIHZhciBkZWZhdWx0SXRlcmF0b3IgPSAhQlVHR1lfU0FGQVJJX0lURVJBVE9SUyAmJiBuYXRpdmVJdGVyYXRvciB8fCBnZXRJdGVyYXRpb25NZXRob2QoREVGQVVMVCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGFueU5hdGl2ZUl0ZXJhdG9yID0gTkFNRSA9PSAnQXJyYXknID8gSXRlcmFibGVQcm90b3R5cGUuZW50cmllcyB8fCBuYXRpdmVJdGVyYXRvciA6IG5hdGl2ZUl0ZXJhdG9yOwogICAgICAgICAgICAgICAgICAgIHZhciBDdXJyZW50SXRlcmF0b3JQcm90b3R5cGUsIG1ldGhvZHMsIEtFWTsKICAgICAgICAgICAgICAgICAgICBpZiAoYW55TmF0aXZlSXRlcmF0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlID0gZ2V0UHJvdG90eXBlT2YoYW55TmF0aXZlSXRlcmF0b3IuY2FsbChuZXcgSXRlcmFibGUoKSkpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlICE9PSBPYmplY3QucHJvdG90eXBlICYmIEN1cnJlbnRJdGVyYXRvclByb3RvdHlwZS5uZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIUlTX1BVUkUgJiYgZ2V0UHJvdG90eXBlT2YoQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlKSAhPT0gSXRlcmF0b3JQcm90b3R5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2V0UHJvdG90eXBlT2YpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0UHJvdG90eXBlT2YoQ3VycmVudEl0ZXJhdG9yUHJvdG90eXBlLCBJdGVyYXRvclByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICghaXNDYWxsYWJsZShDdXJyZW50SXRlcmF0b3JQcm90b3R5cGVbSVRFUkFUT1JdKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluKEN1cnJlbnRJdGVyYXRvclByb3RvdHlwZSwgSVRFUkFUT1IsIHJldHVyblRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFRvU3RyaW5nVGFnKEN1cnJlbnRJdGVyYXRvclByb3RvdHlwZSwgVE9fU1RSSU5HX1RBRywgdHJ1ZSwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoSVNfUFVSRSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJdGVyYXRvcnNbVE9fU1RSSU5HX1RBR10gPSByZXR1cm5UaGlzOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChQUk9QRVJfRlVOQ1RJT05fTkFNRSAmJiBERUZBVUxUID09IFZBTFVFUyAmJiBuYXRpdmVJdGVyYXRvciAmJiBuYXRpdmVJdGVyYXRvci5uYW1lICE9PSBWQUxVRVMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFJU19QVVJFICYmIENPTkZJR1VSQUJMRV9GVU5DVElPTl9OQU1FKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkoSXRlcmFibGVQcm90b3R5cGUsICduYW1lJywgVkFMVUVTKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIElOQ09SUkVDVF9WQUxVRVNfTkFNRSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0SXRlcmF0b3IgPSBmdW5jdGlvbiB2YWx1ZXMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhbGwobmF0aXZlSXRlcmF0b3IsIHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoREVGQVVMVCkgewogICAgICAgICAgICAgICAgICAgICAgICBtZXRob2RzID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWVzOiBnZXRJdGVyYXRpb25NZXRob2QoVkFMVUVTKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtleXM6IElTX1NFVCA/IGRlZmF1bHRJdGVyYXRvciA6IGdldEl0ZXJhdGlvbk1ldGhvZChLRVlTKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJpZXM6IGdldEl0ZXJhdGlvbk1ldGhvZChFTlRSSUVTKQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoRk9SQ0VEKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChLRVkgaW4gbWV0aG9kcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChCVUdHWV9TQUZBUklfSVRFUkFUT1JTIHx8IElOQ09SUkVDVF9WQUxVRVNfTkFNRSB8fCAhKEtFWSBpbiBJdGVyYWJsZVByb3RvdHlwZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lQnVpbHRJbihJdGVyYWJsZVByb3RvdHlwZSwgS0VZLCBtZXRob2RzW0tFWV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgJCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiBOQU1FLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb3RvOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcmNlZDogQlVHR1lfU0FGQVJJX0lURVJBVE9SUyB8fCBJTkNPUlJFQ1RfVkFMVUVTX05BTUUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIG1ldGhvZHMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoKCFJU19QVVJFIHx8IEZPUkNFRCkgJiYgSXRlcmFibGVQcm90b3R5cGVbSVRFUkFUT1JdICE9PSBkZWZhdWx0SXRlcmF0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lQnVpbHRJbihJdGVyYWJsZVByb3RvdHlwZSwgSVRFUkFUT1IsIGRlZmF1bHRJdGVyYXRvciwgeyBuYW1lOiBERUZBVUxUIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBJdGVyYXRvcnNbTkFNRV0gPSBkZWZhdWx0SXRlcmF0b3I7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1ldGhvZHM7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA5NCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBJdGVyYXRvclByb3RvdHlwZSA9IChfX3dfcGRmanNfcmVxdWlyZV9fKDk1KS5JdGVyYXRvclByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlID0gX193X3BkZmpzX3JlcXVpcmVfXyg3Myk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNCk7CiAgICAgICAgICAgICAgICB2YXIgc2V0VG9TdHJpbmdUYWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk2KTsKICAgICAgICAgICAgICAgIHZhciBJdGVyYXRvcnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkyKTsKICAgICAgICAgICAgICAgIHZhciByZXR1cm5UaGlzID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKEl0ZXJhdG9yQ29uc3RydWN0b3IsIE5BTUUsIG5leHQsIEVOVU1FUkFCTEVfTkVYVCkgewogICAgICAgICAgICAgICAgICAgIHZhciBUT19TVFJJTkdfVEFHID0gTkFNRSArICcgSXRlcmF0b3InOwogICAgICAgICAgICAgICAgICAgIEl0ZXJhdG9yQ29uc3RydWN0b3IucHJvdG90eXBlID0gY3JlYXRlKEl0ZXJhdG9yUHJvdG90eXBlLCB7IG5leHQ6IGNyZWF0ZVByb3BlcnR5RGVzY3JpcHRvcigrIUVOVU1FUkFCTEVfTkVYVCwgbmV4dCkgfSk7CiAgICAgICAgICAgICAgICAgICAgc2V0VG9TdHJpbmdUYWcoSXRlcmF0b3JDb25zdHJ1Y3RvciwgVE9fU1RSSU5HX1RBRywgZmFsc2UsIHRydWUpOwogICAgICAgICAgICAgICAgICAgIEl0ZXJhdG9yc1tUT19TVFJJTkdfVEFHXSA9IHJldHVyblRoaXM7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEl0ZXJhdG9yQ29uc3RydWN0b3I7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiA5NSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc09iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjMpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNzMpOwogICAgICAgICAgICAgICAgdmFyIGdldFByb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4NSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lQnVpbHRJbiA9IF9fd19wZGZqc19yZXF1aXJlX18oNTEpOwogICAgICAgICAgICAgICAgdmFyIHdlbGxLbm93blN5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzcpOwogICAgICAgICAgICAgICAgdmFyIElTX1BVUkUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM5KTsKICAgICAgICAgICAgICAgIHZhciBJVEVSQVRPUiA9IHdlbGxLbm93blN5bWJvbCgnaXRlcmF0b3InKTsKICAgICAgICAgICAgICAgIHZhciBCVUdHWV9TQUZBUklfSVRFUkFUT1JTID0gZmFsc2U7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JQcm90b3R5cGUsIFByb3RvdHlwZU9mQXJyYXlJdGVyYXRvclByb3RvdHlwZSwgYXJyYXlJdGVyYXRvcjsKICAgICAgICAgICAgICAgIGlmIChbXS5rZXlzKSB7CiAgICAgICAgICAgICAgICAgICAgYXJyYXlJdGVyYXRvciA9IFtdLmtleXMoKTsKICAgICAgICAgICAgICAgICAgICBpZiAoISgnbmV4dCcgaW4gYXJyYXlJdGVyYXRvcikpCiAgICAgICAgICAgICAgICAgICAgICAgIEJVR0dZX1NBRkFSSV9JVEVSQVRPUlMgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBQcm90b3R5cGVPZkFycmF5SXRlcmF0b3JQcm90b3R5cGUgPSBnZXRQcm90b3R5cGVPZihnZXRQcm90b3R5cGVPZihhcnJheUl0ZXJhdG9yKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChQcm90b3R5cGVPZkFycmF5SXRlcmF0b3JQcm90b3R5cGUgIT09IE9iamVjdC5wcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBJdGVyYXRvclByb3RvdHlwZSA9IFByb3RvdHlwZU9mQXJyYXlJdGVyYXRvclByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB2YXIgTkVXX0lURVJBVE9SX1BST1RPVFlQRSA9ICFpc09iamVjdChJdGVyYXRvclByb3RvdHlwZSkgfHwgZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciB0ZXN0ID0ge307CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEl0ZXJhdG9yUHJvdG90eXBlW0lURVJBVE9SXS5jYWxsKHRlc3QpICE9PSB0ZXN0OwogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBpZiAoTkVXX0lURVJBVE9SX1BST1RPVFlQRSkKICAgICAgICAgICAgICAgICAgICBJdGVyYXRvclByb3RvdHlwZSA9IHt9OwogICAgICAgICAgICAgICAgZWxzZSBpZiAoSVNfUFVSRSkKICAgICAgICAgICAgICAgICAgICBJdGVyYXRvclByb3RvdHlwZSA9IGNyZWF0ZShJdGVyYXRvclByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUoSXRlcmF0b3JQcm90b3R5cGVbSVRFUkFUT1JdKSkgewogICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4oSXRlcmF0b3JQcm90b3R5cGUsIElURVJBVE9SLCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgSXRlcmF0b3JQcm90b3R5cGU6IEl0ZXJhdG9yUHJvdG90eXBlLAogICAgICAgICAgICAgICAgICAgIEJVR0dZX1NBRkFSSV9JVEVSQVRPUlM6IEJVR0dZX1NBRkFSSV9JVEVSQVRPUlMKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDk2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lUHJvcGVydHkgPSAoX193X3BkZmpzX3JlcXVpcmVfXyg0OCkuZik7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgVE9fU1RSSU5HX1RBRyA9IHdlbGxLbm93blN5bWJvbCgndG9TdHJpbmdUYWcnKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKHRhcmdldCwgVEFHLCBTVEFUSUMpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodGFyZ2V0ICYmICFTVEFUSUMpCiAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldCA9IHRhcmdldC5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRhcmdldCAmJiAhaGFzT3duKHRhcmdldCwgVE9fU1RSSU5HX1RBRykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmaW5lUHJvcGVydHkodGFyZ2V0LCBUT19TVFJJTkdfVEFHLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogVEFHCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDk3ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlKSA9PiB7CgogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAodmFsdWUsIGRvbmUpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IGRvbmUKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogOTggKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIFRPX1NUUklOR19UQUdfU1VQUE9SVCA9IF9fd19wZGZqc19yZXF1aXJlX18oODMpOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZUJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUxKTsKICAgICAgICAgICAgICAgIHZhciB0b1N0cmluZyA9IF9fd19wZGZqc19yZXF1aXJlX18oOTkpOwogICAgICAgICAgICAgICAgaWYgKCFUT19TVFJJTkdfVEFHX1NVUFBPUlQpIHsKICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluKE9iamVjdC5wcm90b3R5cGUsICd0b1N0cmluZycsIHRvU3RyaW5nLCB7IHVuc2FmZTogdHJ1ZSB9KTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogOTkgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCiAgICAgICAgICAgICAgICB2YXIgVE9fU1RSSU5HX1RBR19TVVBQT1JUID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Myk7CiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODIpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBUT19TVFJJTkdfVEFHX1NVUFBPUlQgPyB7fS50b1N0cmluZyA6IGZ1bmN0aW9uIHRvU3RyaW5nKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiAnW29iamVjdCAnICsgY2xhc3NvZih0aGlzKSArICddJzsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwMCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICBfX3dfcGRmanNfcmVxdWlyZV9fKDEwMSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwMSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIGNvbGxlY3Rpb24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwMik7CiAgICAgICAgICAgICAgICB2YXIgY29sbGVjdGlvblN0cm9uZyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTIwKTsKICAgICAgICAgICAgICAgIGNvbGxlY3Rpb24oJ01hcCcsIGZ1bmN0aW9uIChpbml0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZ1bmN0aW9uIE1hcCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGluaXQodGhpcywgYXJndW1lbnRzLmxlbmd0aCA/IGFyZ3VtZW50c1swXSA6IHVuZGVmaW5lZCk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0sIGNvbGxlY3Rpb25TdHJvbmcpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMDIgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCiAgICAgICAgICAgICAgICB2YXIgJCA9IF9fd19wZGZqc19yZXF1aXJlX18oNik7CiAgICAgICAgICAgICAgICB2YXIgZ2xvYmFsID0gX193X3BkZmpzX3JlcXVpcmVfXyg3KTsKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgdmFyIGlzRm9yY2VkID0gX193X3BkZmpzX3JlcXVpcmVfXyg3MSk7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lQnVpbHRJbiA9IF9fd19wZGZqc19yZXF1aXJlX18oNTEpOwogICAgICAgICAgICAgICAgdmFyIEludGVybmFsTWV0YWRhdGFNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwMyk7CiAgICAgICAgICAgICAgICB2YXIgaXRlcmF0ZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTEwKTsKICAgICAgICAgICAgICAgIHZhciBhbkluc3RhbmNlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTcpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc051bGxPclVuZGVmaW5lZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjApOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBjaGVja0NvcnJlY3RuZXNzT2ZJdGVyYXRpb24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExOCk7CiAgICAgICAgICAgICAgICB2YXIgc2V0VG9TdHJpbmdUYWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDk2KTsKICAgICAgICAgICAgICAgIHZhciBpbmhlcml0SWZSZXF1aXJlZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTE5KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKENPTlNUUlVDVE9SX05BTUUsIHdyYXBwZXIsIGNvbW1vbikgewogICAgICAgICAgICAgICAgICAgIHZhciBJU19NQVAgPSBDT05TVFJVQ1RPUl9OQU1FLmluZGV4T2YoJ01hcCcpICE9PSAtMTsKICAgICAgICAgICAgICAgICAgICB2YXIgSVNfV0VBSyA9IENPTlNUUlVDVE9SX05BTUUuaW5kZXhPZignV2VhaycpICE9PSAtMTsKICAgICAgICAgICAgICAgICAgICB2YXIgQURERVIgPSBJU19NQVAgPyAnc2V0JyA6ICdhZGQnOwogICAgICAgICAgICAgICAgICAgIHZhciBOYXRpdmVDb25zdHJ1Y3RvciA9IGdsb2JhbFtDT05TVFJVQ1RPUl9OQU1FXTsKICAgICAgICAgICAgICAgICAgICB2YXIgTmF0aXZlUHJvdG90eXBlID0gTmF0aXZlQ29uc3RydWN0b3IgJiYgTmF0aXZlQ29uc3RydWN0b3IucHJvdG90eXBlOwogICAgICAgICAgICAgICAgICAgIHZhciBDb25zdHJ1Y3RvciA9IE5hdGl2ZUNvbnN0cnVjdG9yOwogICAgICAgICAgICAgICAgICAgIHZhciBleHBvcnRlZCA9IHt9OwogICAgICAgICAgICAgICAgICAgIHZhciBmaXhNZXRob2QgPSBmdW5jdGlvbiAoS0VZKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB1bmN1cnJpZWROYXRpdmVNZXRob2QgPSB1bmN1cnJ5VGhpcyhOYXRpdmVQcm90b3R5cGVbS0VZXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4oTmF0aXZlUHJvdG90eXBlLCBLRVksIEtFWSA9PSAnYWRkJyA/IGZ1bmN0aW9uIGFkZCh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5jdXJyaWVkTmF0aXZlTWV0aG9kKHRoaXMsIHZhbHVlID09PSAwID8gMCA6IHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICB9IDogS0VZID09ICdkZWxldGUnID8gZnVuY3Rpb24gKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElTX1dFQUsgJiYgIWlzT2JqZWN0KGtleSkgPyBmYWxzZSA6IHVuY3VycmllZE5hdGl2ZU1ldGhvZCh0aGlzLCBrZXkgPT09IDAgPyAwIDoga2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSA6IEtFWSA9PSAnZ2V0JyA/IGZ1bmN0aW9uIGdldChrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBJU19XRUFLICYmICFpc09iamVjdChrZXkpID8gdW5kZWZpbmVkIDogdW5jdXJyaWVkTmF0aXZlTWV0aG9kKHRoaXMsIGtleSA9PT0gMCA/IDAgOiBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICB9IDogS0VZID09ICdoYXMnID8gZnVuY3Rpb24gaGFzKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElTX1dFQUsgJiYgIWlzT2JqZWN0KGtleSkgPyBmYWxzZSA6IHVuY3VycmllZE5hdGl2ZU1ldGhvZCh0aGlzLCBrZXkgPT09IDAgPyAwIDoga2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSA6IGZ1bmN0aW9uIHNldChrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bmN1cnJpZWROYXRpdmVNZXRob2QodGhpcywga2V5ID09PSAwID8gMCA6IGtleSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgdmFyIFJFUExBQ0UgPSBpc0ZvcmNlZChDT05TVFJVQ1RPUl9OQU1FLCAhaXNDYWxsYWJsZShOYXRpdmVDb25zdHJ1Y3RvcikgfHwgIShJU19XRUFLIHx8IE5hdGl2ZVByb3RvdHlwZS5mb3JFYWNoICYmICFmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBOYXRpdmVDb25zdHJ1Y3RvcigpLmVudHJpZXMoKS5uZXh0KCk7CiAgICAgICAgICAgICAgICAgICAgfSkpKTsKICAgICAgICAgICAgICAgICAgICBpZiAoUkVQTEFDRSkgewogICAgICAgICAgICAgICAgICAgICAgICBDb25zdHJ1Y3RvciA9IGNvbW1vbi5nZXRDb25zdHJ1Y3Rvcih3cmFwcGVyLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVAsIEFEREVSKTsKICAgICAgICAgICAgICAgICAgICAgICAgSW50ZXJuYWxNZXRhZGF0YU1vZHVsZS5lbmFibGUoKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGlzRm9yY2VkKENPTlNUUlVDVE9SX05BTUUsIHRydWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBpbnN0YW5jZSA9IG5ldyBDb25zdHJ1Y3RvcigpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgSEFTTlRfQ0hBSU5JTkcgPSBpbnN0YW5jZVtBRERFUl0oSVNfV0VBSyA/IHt9IDogLTAsIDEpICE9IGluc3RhbmNlOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgVEhST1dTX09OX1BSSU1JVElWRVMgPSBmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnN0YW5jZS5oYXMoMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgQUNDRVBUX0lURVJBQkxFUyA9IGNoZWNrQ29ycmVjdG5lc3NPZkl0ZXJhdGlvbihmdW5jdGlvbiAoaXRlcmFibGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBOYXRpdmVDb25zdHJ1Y3RvcihpdGVyYWJsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgQlVHR1lfWkVSTyA9ICFJU19XRUFLICYmIGZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciAkaW5zdGFuY2UgPSBuZXcgTmF0aXZlQ29uc3RydWN0b3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBpbmRleCA9IDU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoaW5kZXgtLSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkaW5zdGFuY2VbQURERVJdKGluZGV4LCBpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gISRpbnN0YW5jZS5oYXMoLTApOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFBQ0NFUFRfSVRFUkFCTEVTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDb25zdHJ1Y3RvciA9IHdyYXBwZXIoZnVuY3Rpb24gKGR1bW15LCBpdGVyYWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFuSW5zdGFuY2UoZHVtbXksIE5hdGl2ZVByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRoYXQgPSBpbmhlcml0SWZSZXF1aXJlZChuZXcgTmF0aXZlQ29uc3RydWN0b3IoKSwgZHVtbXksIENvbnN0cnVjdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzTnVsbE9yVW5kZWZpbmVkKGl0ZXJhYmxlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlcmF0ZShpdGVyYWJsZSwgdGhhdFtBRERFUl0sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQ6IHRoYXQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBU19FTlRSSUVTOiBJU19NQVAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoYXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIENvbnN0cnVjdG9yLnByb3RvdHlwZSA9IE5hdGl2ZVByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIE5hdGl2ZVByb3RvdHlwZS5jb25zdHJ1Y3RvciA9IENvbnN0cnVjdG9yOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChUSFJPV1NfT05fUFJJTUlUSVZFUyB8fCBCVUdHWV9aRVJPKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaXhNZXRob2QoJ2RlbGV0ZScpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZml4TWV0aG9kKCdoYXMnKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIElTX01BUCAmJiBmaXhNZXRob2QoJ2dldCcpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChCVUdHWV9aRVJPIHx8IEhBU05UX0NIQUlOSU5HKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZml4TWV0aG9kKEFEREVSKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKElTX1dFQUsgJiYgTmF0aXZlUHJvdG90eXBlLmNsZWFyKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIE5hdGl2ZVByb3RvdHlwZS5jbGVhcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0ZWRbQ09OU1RSVUNUT1JfTkFNRV0gPSBDb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgICAgICAkKHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2xvYmFsOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcjogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgZm9yY2VkOiBDb25zdHJ1Y3RvciAhPSBOYXRpdmVDb25zdHJ1Y3RvcgogICAgICAgICAgICAgICAgICAgIH0sIGV4cG9ydGVkKTsKICAgICAgICAgICAgICAgICAgICBzZXRUb1N0cmluZ1RhZyhDb25zdHJ1Y3RvciwgQ09OU1RSVUNUT1JfTkFNRSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFJU19XRUFLKQogICAgICAgICAgICAgICAgICAgICAgICBjb21tb24uc2V0U3Ryb25nKENvbnN0cnVjdG9yLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVApOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBDb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwMyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyICQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDYpOwogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgaGlkZGVuS2V5cyA9IF9fd19wZGZqc19yZXF1aXJlX18oNTgpOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgZGVmaW5lUHJvcGVydHkgPSAoX193X3BkZmpzX3JlcXVpcmVfXyg0OCkuZik7CiAgICAgICAgICAgICAgICB2YXIgZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNjEpOwogICAgICAgICAgICAgICAgdmFyIGdldE93blByb3BlcnR5TmFtZXNFeHRlcm5hbE1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTA0KTsKICAgICAgICAgICAgICAgIHZhciBpc0V4dGVuc2libGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwNyk7CiAgICAgICAgICAgICAgICB2YXIgdWlkID0gX193X3BkZmpzX3JlcXVpcmVfXyg0NCk7CiAgICAgICAgICAgICAgICB2YXIgRlJFRVpJTkcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwOSk7CiAgICAgICAgICAgICAgICB2YXIgUkVRVUlSRUQgPSBmYWxzZTsKICAgICAgICAgICAgICAgIHZhciBNRVRBREFUQSA9IHVpZCgnbWV0YScpOwogICAgICAgICAgICAgICAgdmFyIGlkID0gMDsKICAgICAgICAgICAgICAgIHZhciBzZXRNZXRhZGF0YSA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5KGl0LCBNRVRBREFUQSwgewogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2JqZWN0SUQ6ICdPJyArIGlkKyssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3ZWFrRGF0YToge30KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBmYXN0S2V5ID0gZnVuY3Rpb24gKGl0LCBjcmVhdGUpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiBpdCA9PSAnc3ltYm9sJyA/IGl0IDogKHR5cGVvZiBpdCA9PSAnc3RyaW5nJyA/ICdTJyA6ICdQJykgKyBpdDsKICAgICAgICAgICAgICAgICAgICBpZiAoIWhhc093bihpdCwgTUVUQURBVEEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNFeHRlbnNpYmxlKGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAnRic7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghY3JlYXRlKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdFJzsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0TWV0YWRhdGEoaXQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXRbTUVUQURBVEFdLm9iamVjdElEOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBnZXRXZWFrRGF0YSA9IGZ1bmN0aW9uIChpdCwgY3JlYXRlKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFoYXNPd24oaXQsIE1FVEFEQVRBKSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzRXh0ZW5zaWJsZShpdCkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjcmVhdGUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHNldE1ldGFkYXRhKGl0KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0W01FVEFEQVRBXS53ZWFrRGF0YTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgb25GcmVlemUgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoRlJFRVpJTkcgJiYgUkVRVUlSRUQgJiYgaXNFeHRlbnNpYmxlKGl0KSAmJiAhaGFzT3duKGl0LCBNRVRBREFUQSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHNldE1ldGFkYXRhKGl0KTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXQ7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIGVuYWJsZSA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICBtZXRhLmVuYWJsZSA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIFJFUVVJUkVEID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB2YXIgZ2V0T3duUHJvcGVydHlOYW1lcyA9IGdldE93blByb3BlcnR5TmFtZXNNb2R1bGUuZjsKICAgICAgICAgICAgICAgICAgICB2YXIgc3BsaWNlID0gdW5jdXJyeVRoaXMoW10uc3BsaWNlKTsKICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHt9OwogICAgICAgICAgICAgICAgICAgIHRlc3RbTUVUQURBVEFdID0gMTsKICAgICAgICAgICAgICAgICAgICBpZiAoZ2V0T3duUHJvcGVydHlOYW1lcyh0ZXN0KS5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZ2V0T3duUHJvcGVydHlOYW1lc01vZHVsZS5mID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gZ2V0T3duUHJvcGVydHlOYW1lcyhpdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMCwgbGVuZ3RoID0gcmVzdWx0Lmxlbmd0aDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdFtpXSA9PT0gTUVUQURBVEEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3BsaWNlKHJlc3VsdCwgaSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICQoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiAnT2JqZWN0JywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXQ6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JjZWQ6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSwgeyBnZXRPd25Qcm9wZXJ0eU5hbWVzOiBnZXRPd25Qcm9wZXJ0eU5hbWVzRXh0ZXJuYWxNb2R1bGUuZiB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgdmFyIG1ldGEgPSBtb2R1bGUuZXhwb3J0cyA9IHsKICAgICAgICAgICAgICAgICAgICBlbmFibGU6IGVuYWJsZSwKICAgICAgICAgICAgICAgICAgICBmYXN0S2V5OiBmYXN0S2V5LAogICAgICAgICAgICAgICAgICAgIGdldFdlYWtEYXRhOiBnZXRXZWFrRGF0YSwKICAgICAgICAgICAgICAgICAgICBvbkZyZWV6ZTogb25GcmVlemUKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBoaWRkZW5LZXlzW01FVEFEQVRBXSA9IHRydWU7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwNCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGNsYXNzb2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE4KTsKICAgICAgICAgICAgICAgIHZhciB0b0luZGV4ZWRPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1KTsKICAgICAgICAgICAgICAgIHZhciAkZ2V0T3duUHJvcGVydHlOYW1lcyA9IChfX3dfcGRmanNfcmVxdWlyZV9fKDYxKS5mKTsKICAgICAgICAgICAgICAgIHZhciBhcnJheVNsaWNlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMDUpOwogICAgICAgICAgICAgICAgdmFyIHdpbmRvd05hbWVzID0gdHlwZW9mIHdpbmRvdyA9PSAnb2JqZWN0JyAmJiB3aW5kb3cgJiYgT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXMgPyBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyh3aW5kb3cpIDogW107CiAgICAgICAgICAgICAgICB2YXIgZ2V0V2luZG93TmFtZXMgPSBmdW5jdGlvbiAoaXQpIHsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJGdldE93blByb3BlcnR5TmFtZXMoaXQpOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcnJheVNsaWNlKHdpbmRvd05hbWVzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMuZiA9IGZ1bmN0aW9uIGdldE93blByb3BlcnR5TmFtZXMoaXQpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gd2luZG93TmFtZXMgJiYgY2xhc3NvZihpdCkgPT0gJ1dpbmRvdycgPyBnZXRXaW5kb3dOYW1lcyhpdCkgOiAkZ2V0T3duUHJvcGVydHlOYW1lcyh0b0luZGV4ZWRPYmplY3QoaXQpKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwNSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHRvQWJzb2x1dGVJbmRleCA9IF9fd19wZGZqc19yZXF1aXJlX18oNjQpOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwNik7CiAgICAgICAgICAgICAgICB2YXIgJEFycmF5ID0gQXJyYXk7CiAgICAgICAgICAgICAgICB2YXIgbWF4ID0gTWF0aC5tYXg7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChPLCBzdGFydCwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGxlbmd0aCA9IGxlbmd0aE9mQXJyYXlMaWtlKE8pOwogICAgICAgICAgICAgICAgICAgIHZhciBrID0gdG9BYnNvbHV0ZUluZGV4KHN0YXJ0LCBsZW5ndGgpOwogICAgICAgICAgICAgICAgICAgIHZhciBmaW4gPSB0b0Fic29sdXRlSW5kZXgoZW5kID09PSB1bmRlZmluZWQgPyBsZW5ndGggOiBlbmQsIGxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIHJlc3VsdCA9ICRBcnJheShtYXgoZmluIC0gaywgMCkpOwogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIG4gPSAwOyBrIDwgZmluOyBrKyssIG4rKykKICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUHJvcGVydHkocmVzdWx0LCBuLCBPW2tdKTsKICAgICAgICAgICAgICAgICAgICByZXN1bHQubGVuZ3RoID0gbjsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTA2ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIHRvUHJvcGVydHlLZXkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIxKTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVQcm9wZXJ0eU1vZHVsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oNDgpOwogICAgICAgICAgICAgICAgdmFyIGNyZWF0ZVByb3BlcnR5RGVzY3JpcHRvciA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAob2JqZWN0LCBrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHByb3BlcnR5S2V5ID0gdG9Qcm9wZXJ0eUtleShrZXkpOwogICAgICAgICAgICAgICAgICAgIGlmIChwcm9wZXJ0eUtleSBpbiBvYmplY3QpCiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZVByb3BlcnR5TW9kdWxlLmYob2JqZWN0LCBwcm9wZXJ0eUtleSwgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yKDAsIHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICBvYmplY3RbcHJvcGVydHlLZXldID0gdmFsdWU7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMDcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oMTgpOwogICAgICAgICAgICAgICAgdmFyIEFSUkFZX0JVRkZFUl9OT05fRVhURU5TSUJMRSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTA4KTsKICAgICAgICAgICAgICAgIHZhciAkaXNFeHRlbnNpYmxlID0gT2JqZWN0LmlzRXh0ZW5zaWJsZTsKICAgICAgICAgICAgICAgIHZhciBGQUlMU19PTl9QUklNSVRJVkVTID0gZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICRpc0V4dGVuc2libGUoMSk7CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gRkFJTFNfT05fUFJJTUlUSVZFUyB8fCBBUlJBWV9CVUZGRVJfTk9OX0VYVEVOU0lCTEUgPyBmdW5jdGlvbiBpc0V4dGVuc2libGUoaXQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KGl0KSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIGlmIChBUlJBWV9CVUZGRVJfTk9OX0VYVEVOU0lCTEUgJiYgY2xhc3NvZihpdCkgPT0gJ0FycmF5QnVmZmVyJykKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiAkaXNFeHRlbnNpYmxlID8gJGlzRXh0ZW5zaWJsZShpdCkgOiB0cnVlOwogICAgICAgICAgICAgICAgfSA6ICRpc0V4dGVuc2libGU7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEwOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIEFycmF5QnVmZmVyID09ICdmdW5jdGlvbicpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGJ1ZmZlciA9IG5ldyBBcnJheUJ1ZmZlcig4KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKE9iamVjdC5pc0V4dGVuc2libGUoYnVmZmVyKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShidWZmZXIsICdhJywgeyB2YWx1ZTogOCB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTA5ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gT2JqZWN0LmlzRXh0ZW5zaWJsZShPYmplY3QucHJldmVudEV4dGVuc2lvbnMoe30pKTsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTAgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBiaW5kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTEpOwogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExKTsKICAgICAgICAgICAgICAgIHZhciBhbk9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNTApOwogICAgICAgICAgICAgICAgdmFyIHRyeVRvU3RyaW5nID0gX193X3BkZmpzX3JlcXVpcmVfXygzNSk7CiAgICAgICAgICAgICAgICB2YXIgaXNBcnJheUl0ZXJhdG9yTWV0aG9kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTMpOwogICAgICAgICAgICAgICAgdmFyIGxlbmd0aE9mQXJyYXlMaWtlID0gX193X3BkZmpzX3JlcXVpcmVfXyg2Nyk7CiAgICAgICAgICAgICAgICB2YXIgaXNQcm90b3R5cGVPZiA9IF9fd19wZGZqc19yZXF1aXJlX18oMjgpOwogICAgICAgICAgICAgICAgdmFyIGdldEl0ZXJhdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTQpOwogICAgICAgICAgICAgICAgdmFyIGdldEl0ZXJhdG9yTWV0aG9kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTUpOwogICAgICAgICAgICAgICAgdmFyIGl0ZXJhdG9yQ2xvc2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExNik7CiAgICAgICAgICAgICAgICB2YXIgJFR5cGVFcnJvciA9IFR5cGVFcnJvcjsKICAgICAgICAgICAgICAgIHZhciBSZXN1bHQgPSBmdW5jdGlvbiAoc3RvcHBlZCwgcmVzdWx0KSB7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5zdG9wcGVkID0gc3RvcHBlZDsKICAgICAgICAgICAgICAgICAgICB0aGlzLnJlc3VsdCA9IHJlc3VsdDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgUmVzdWx0UHJvdG90eXBlID0gUmVzdWx0LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0ZXJhYmxlLCB1bmJvdW5kRnVuY3Rpb24sIG9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgdGhhdCA9IG9wdGlvbnMgJiYgb3B0aW9ucy50aGF0OwogICAgICAgICAgICAgICAgICAgIHZhciBBU19FTlRSSUVTID0gISEob3B0aW9ucyAmJiBvcHRpb25zLkFTX0VOVFJJRVMpOwogICAgICAgICAgICAgICAgICAgIHZhciBJU19SRUNPUkQgPSAhIShvcHRpb25zICYmIG9wdGlvbnMuSVNfUkVDT1JEKTsKICAgICAgICAgICAgICAgICAgICB2YXIgSVNfSVRFUkFUT1IgPSAhIShvcHRpb25zICYmIG9wdGlvbnMuSVNfSVRFUkFUT1IpOwogICAgICAgICAgICAgICAgICAgIHZhciBJTlRFUlJVUFRFRCA9ICEhKG9wdGlvbnMgJiYgb3B0aW9ucy5JTlRFUlJVUFRFRCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGZuID0gYmluZCh1bmJvdW5kRnVuY3Rpb24sIHRoYXQpOwogICAgICAgICAgICAgICAgICAgIHZhciBpdGVyYXRvciwgaXRlckZuLCBpbmRleCwgbGVuZ3RoLCByZXN1bHQsIG5leHQsIHN0ZXA7CiAgICAgICAgICAgICAgICAgICAgdmFyIHN0b3AgPSBmdW5jdGlvbiAoY29uZGl0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpdGVyYXRvcikKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZXJhdG9yQ2xvc2UoaXRlcmF0b3IsICdub3JtYWwnLCBjb25kaXRpb24pOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFJlc3VsdCh0cnVlLCBjb25kaXRpb24pOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgdmFyIGNhbGxGbiA9IGZ1bmN0aW9uICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoQVNfRU5UUklFUykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5PYmplY3QodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOVEVSUlVQVEVEID8gZm4odmFsdWVbMF0sIHZhbHVlWzFdLCBzdG9wKSA6IGZuKHZhbHVlWzBdLCB2YWx1ZVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOVEVSUlVQVEVEID8gZm4odmFsdWUsIHN0b3ApIDogZm4odmFsdWUpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgaWYgKElTX1JFQ09SRCkgewogICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRvciA9IGl0ZXJhYmxlLml0ZXJhdG9yOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoSVNfSVRFUkFUT1IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaXRlcmF0b3IgPSBpdGVyYWJsZTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBpdGVyRm4gPSBnZXRJdGVyYXRvck1ldGhvZChpdGVyYWJsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXRlckZuKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcih0cnlUb1N0cmluZyhpdGVyYWJsZSkgKyAnIGlzIG5vdCBpdGVyYWJsZScpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNBcnJheUl0ZXJhdG9yTWV0aG9kKGl0ZXJGbikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaW5kZXggPSAwLCBsZW5ndGggPSBsZW5ndGhPZkFycmF5TGlrZShpdGVyYWJsZSk7IGxlbmd0aCA+IGluZGV4OyBpbmRleCsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ID0gY2FsbEZuKGl0ZXJhYmxlW2luZGV4XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdCAmJiBpc1Byb3RvdHlwZU9mKFJlc3VsdFByb3RvdHlwZSwgcmVzdWx0KSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUmVzdWx0KGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRvciA9IGdldEl0ZXJhdG9yKGl0ZXJhYmxlLCBpdGVyRm4pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBuZXh0ID0gSVNfUkVDT1JEID8gaXRlcmFibGUubmV4dCA6IGl0ZXJhdG9yLm5leHQ7CiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKCEoc3RlcCA9IGNhbGwobmV4dCwgaXRlcmF0b3IpKS5kb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgPSBjYWxsRm4oc3RlcC52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRvckNsb3NlKGl0ZXJhdG9yLCAndGhyb3cnLCBlcnJvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZXN1bHQgPT0gJ29iamVjdCcgJiYgcmVzdWx0ICYmIGlzUHJvdG90eXBlT2YoUmVzdWx0UHJvdG90eXBlLCByZXN1bHQpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBSZXN1bHQoZmFsc2UpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTExICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgdW5jdXJyeVRoaXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExMik7CiAgICAgICAgICAgICAgICB2YXIgYUNhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygzNCk7CiAgICAgICAgICAgICAgICB2YXIgTkFUSVZFX0JJTkQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyKTsKICAgICAgICAgICAgICAgIHZhciBiaW5kID0gdW5jdXJyeVRoaXModW5jdXJyeVRoaXMuYmluZCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChmbiwgdGhhdCkgewogICAgICAgICAgICAgICAgICAgIGFDYWxsYWJsZShmbik7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoYXQgPT09IHVuZGVmaW5lZCA/IGZuIDogTkFUSVZFX0JJTkQgPyBiaW5kKGZuLCB0aGF0KSA6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZuLmFwcGx5KHRoYXQsIGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExMiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGNsYXNzb2ZSYXcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE4KTsKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoZm4pIHsKICAgICAgICAgICAgICAgICAgICBpZiAoY2xhc3NvZlJhdyhmbikgPT09ICdGdW5jdGlvbicpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1bmN1cnJ5VGhpcyhmbik7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTMgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciBJdGVyYXRvcnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkyKTsKICAgICAgICAgICAgICAgIHZhciBJVEVSQVRPUiA9IHdlbGxLbm93blN5bWJvbCgnaXRlcmF0b3InKTsKICAgICAgICAgICAgICAgIHZhciBBcnJheVByb3RvdHlwZSA9IEFycmF5LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ICE9PSB1bmRlZmluZWQgJiYgKEl0ZXJhdG9ycy5BcnJheSA9PT0gaXQgfHwgQXJyYXlQcm90b3R5cGVbSVRFUkFUT1JdID09PSBpdCk7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTQgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjYWxsID0gX193X3BkZmpzX3JlcXVpcmVfXygxMSk7CiAgICAgICAgICAgICAgICB2YXIgYUNhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygzNCk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciB0cnlUb1N0cmluZyA9IF9fd19wZGZqc19yZXF1aXJlX18oMzUpOwogICAgICAgICAgICAgICAgdmFyIGdldEl0ZXJhdG9yTWV0aG9kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTUpOwogICAgICAgICAgICAgICAgdmFyICRUeXBlRXJyb3IgPSBUeXBlRXJyb3I7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChhcmd1bWVudCwgdXNpbmdJdGVyYXRvcikgewogICAgICAgICAgICAgICAgICAgIHZhciBpdGVyYXRvck1ldGhvZCA9IGFyZ3VtZW50cy5sZW5ndGggPCAyID8gZ2V0SXRlcmF0b3JNZXRob2QoYXJndW1lbnQpIDogdXNpbmdJdGVyYXRvcjsKICAgICAgICAgICAgICAgICAgICBpZiAoYUNhbGxhYmxlKGl0ZXJhdG9yTWV0aG9kKSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGFuT2JqZWN0KGNhbGwoaXRlcmF0b3JNZXRob2QsIGFyZ3VtZW50KSk7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcih0cnlUb1N0cmluZyhhcmd1bWVudCkgKyAnIGlzIG5vdCBpdGVyYWJsZScpOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTE1ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODIpOwogICAgICAgICAgICAgICAgdmFyIGdldE1ldGhvZCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzMpOwogICAgICAgICAgICAgICAgdmFyIGlzTnVsbE9yVW5kZWZpbmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygyMCk7CiAgICAgICAgICAgICAgICB2YXIgSXRlcmF0b3JzID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Mik7CiAgICAgICAgICAgICAgICB2YXIgd2VsbEtub3duU3ltYm9sID0gX193X3BkZmpzX3JlcXVpcmVfXygzNyk7CiAgICAgICAgICAgICAgICB2YXIgSVRFUkFUT1IgPSB3ZWxsS25vd25TeW1ib2woJ2l0ZXJhdG9yJyk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uIChpdCkgewogICAgICAgICAgICAgICAgICAgIGlmICghaXNOdWxsT3JVbmRlZmluZWQoaXQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZ2V0TWV0aG9kKGl0LCBJVEVSQVRPUikgfHwgZ2V0TWV0aG9kKGl0LCAnQEBpdGVyYXRvcicpIHx8IEl0ZXJhdG9yc1tjbGFzc29mKGl0KV07CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMTYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjYWxsID0gX193X3BkZmpzX3JlcXVpcmVfXygxMSk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciBnZXRNZXRob2QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDMzKTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKGl0ZXJhdG9yLCBraW5kLCB2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgIHZhciBpbm5lclJlc3VsdCwgaW5uZXJFcnJvcjsKICAgICAgICAgICAgICAgICAgICBhbk9iamVjdChpdGVyYXRvcik7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJSZXN1bHQgPSBnZXRNZXRob2QoaXRlcmF0b3IsICdyZXR1cm4nKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpbm5lclJlc3VsdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGtpbmQgPT09ICd0aHJvdycpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJSZXN1bHQgPSBjYWxsKGlubmVyUmVzdWx0LCBpdGVyYXRvcik7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaW5uZXJFcnJvciA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlubmVyUmVzdWx0ID0gZXJyb3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09PSAndGhyb3cnKQogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICBpZiAoaW5uZXJFcnJvcikKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgaW5uZXJSZXN1bHQ7CiAgICAgICAgICAgICAgICAgICAgYW5PYmplY3QoaW5uZXJSZXN1bHQpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExNyAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGlzUHJvdG90eXBlT2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI4KTsKICAgICAgICAgICAgICAgIHZhciAkVHlwZUVycm9yID0gVHlwZUVycm9yOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoaXQsIFByb3RvdHlwZSkgewogICAgICAgICAgICAgICAgICAgIGlmIChpc1Byb3RvdHlwZU9mKFByb3RvdHlwZSwgaXQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaXQ7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgJFR5cGVFcnJvcignSW5jb3JyZWN0IGludm9jYXRpb24nKTsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDExOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHdlbGxLbm93blN5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMzcpOwogICAgICAgICAgICAgICAgdmFyIElURVJBVE9SID0gd2VsbEtub3duU3ltYm9sKCdpdGVyYXRvcicpOwogICAgICAgICAgICAgICAgdmFyIFNBRkVfQ0xPU0lORyA9IGZhbHNlOwogICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICB2YXIgY2FsbGVkID0gMDsKICAgICAgICAgICAgICAgICAgICB2YXIgaXRlcmF0b3JXaXRoUmV0dXJuID0gewogICAgICAgICAgICAgICAgICAgICAgICBuZXh0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4geyBkb25lOiAhIWNhbGxlZCsrIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICdyZXR1cm4nOiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBTQUZFX0NMT1NJTkcgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBpdGVyYXRvcldpdGhSZXR1cm5bSVRFUkFUT1JdID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpczsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIEFycmF5LmZyb20oaXRlcmF0b3JXaXRoUmV0dXJuLCBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IDI7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoZXhlYywgU0tJUF9DTE9TSU5HKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFTS0lQX0NMT1NJTkcgJiYgIVNBRkVfQ0xPU0lORykKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBJVEVSQVRJT05fU1VQUE9SVCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBvYmplY3QgPSB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgb2JqZWN0W0lURVJBVE9SXSA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV4dDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4geyBkb25lOiBJVEVSQVRJT05fU1VQUE9SVCA9IHRydWUgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBleGVjKG9iamVjdCk7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElURVJBVElPTl9TVVBQT1JUOwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTE5ICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgaXNDYWxsYWJsZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMjQpOwogICAgICAgICAgICAgICAgdmFyIGlzT2JqZWN0ID0gX193X3BkZmpzX3JlcXVpcmVfXygyMyk7CiAgICAgICAgICAgICAgICB2YXIgc2V0UHJvdG90eXBlT2YgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg3KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKCR0aGlzLCBkdW1teSwgV3JhcHBlcikgewogICAgICAgICAgICAgICAgICAgIHZhciBOZXdUYXJnZXQsIE5ld1RhcmdldFByb3RvdHlwZTsKICAgICAgICAgICAgICAgICAgICBpZiAoc2V0UHJvdG90eXBlT2YgJiYgaXNDYWxsYWJsZShOZXdUYXJnZXQgPSBkdW1teS5jb25zdHJ1Y3RvcikgJiYgTmV3VGFyZ2V0ICE9PSBXcmFwcGVyICYmIGlzT2JqZWN0KE5ld1RhcmdldFByb3RvdHlwZSA9IE5ld1RhcmdldC5wcm90b3R5cGUpICYmIE5ld1RhcmdldFByb3RvdHlwZSAhPT0gV3JhcHBlci5wcm90b3R5cGUpCiAgICAgICAgICAgICAgICAgICAgICAgIHNldFByb3RvdHlwZU9mKCR0aGlzLCBOZXdUYXJnZXRQcm90b3R5cGUpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiAkdGhpczsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyMCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBjcmVhdGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDczKTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluQWNjZXNzb3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg0KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdElucyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTIxKTsKICAgICAgICAgICAgICAgIHZhciBiaW5kID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTEpOwogICAgICAgICAgICAgICAgdmFyIGFuSW5zdGFuY2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExNyk7CiAgICAgICAgICAgICAgICB2YXIgaXNOdWxsT3JVbmRlZmluZWQgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIwKTsKICAgICAgICAgICAgICAgIHZhciBpdGVyYXRlID0gX193X3BkZmpzX3JlcXVpcmVfXygxMTApOwogICAgICAgICAgICAgICAgdmFyIGRlZmluZUl0ZXJhdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXyg5Myk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlSXRlclJlc3VsdE9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oOTcpOwogICAgICAgICAgICAgICAgdmFyIHNldFNwZWNpZXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyMik7CiAgICAgICAgICAgICAgICB2YXIgREVTQ1JJUFRPUlMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDkpOwogICAgICAgICAgICAgICAgdmFyIGZhc3RLZXkgPSAoX193X3BkZmpzX3JlcXVpcmVfXygxMDMpLmZhc3RLZXkpOwogICAgICAgICAgICAgICAgdmFyIEludGVybmFsU3RhdGVNb2R1bGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDU1KTsKICAgICAgICAgICAgICAgIHZhciBzZXRJbnRlcm5hbFN0YXRlID0gSW50ZXJuYWxTdGF0ZU1vZHVsZS5zZXQ7CiAgICAgICAgICAgICAgICB2YXIgaW50ZXJuYWxTdGF0ZUdldHRlckZvciA9IEludGVybmFsU3RhdGVNb2R1bGUuZ2V0dGVyRm9yOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSB7CiAgICAgICAgICAgICAgICAgICAgZ2V0Q29uc3RydWN0b3I6IGZ1bmN0aW9uICh3cmFwcGVyLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVAsIEFEREVSKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBDb25zdHJ1Y3RvciA9IHdyYXBwZXIoZnVuY3Rpb24gKHRoYXQsIGl0ZXJhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbkluc3RhbmNlKHRoYXQsIFByb3RvdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJbnRlcm5hbFN0YXRlKHRoYXQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBDT05TVFJVQ1RPUl9OQU1FLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4OiBjcmVhdGUobnVsbCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3Q6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXN0OiB1bmRlZmluZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZTogMAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIURFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQuc2l6ZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzTnVsbE9yVW5kZWZpbmVkKGl0ZXJhYmxlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVyYXRlKGl0ZXJhYmxlLCB0aGF0W0FEREVSXSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGF0OiB0aGF0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBU19FTlRSSUVTOiBJU19NQVAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBQcm90b3R5cGUgPSBDb25zdHJ1Y3Rvci5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbFN0YXRlID0gaW50ZXJuYWxTdGF0ZUdldHRlckZvcihDT05TVFJVQ1RPUl9OQU1FKTsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGRlZmluZSA9IGZ1bmN0aW9uICh0aGF0LCBrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBnZXRJbnRlcm5hbFN0YXRlKHRoYXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVudHJ5ID0gZ2V0RW50cnkodGhhdCwga2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwcmV2aW91cywgaW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW50cnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeS52YWx1ZSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5sYXN0ID0gZW50cnkgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4OiBpbmRleCA9IGZhc3RLZXkoa2V5LCB0cnVlKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5OiBrZXksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldmlvdXM6IHByZXZpb3VzID0gc3RhdGUubGFzdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV4dDogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW1vdmVkOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzdGF0ZS5maXJzdCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUuZmlyc3QgPSBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJldmlvdXMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXZpb3VzLm5leHQgPSBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoREVTQ1JJUFRPUlMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLnNpemUrKzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQuc2l6ZSsrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCAhPT0gJ0YnKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5pbmRleFtpbmRleF0gPSBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGF0OwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgZ2V0RW50cnkgPSBmdW5jdGlvbiAodGhhdCwga2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBnZXRJbnRlcm5hbFN0YXRlKHRoYXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGluZGV4ID0gZmFzdEtleShrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVudHJ5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGluZGV4ICE9PSAnRicpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN0YXRlLmluZGV4W2luZGV4XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoZW50cnkgPSBzdGF0ZS5maXJzdDsgZW50cnk7IGVudHJ5ID0gZW50cnkubmV4dCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbnRyeS5rZXkgPT0ga2V5KQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZW50cnk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW5zKFByb3RvdHlwZSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXI6IGZ1bmN0aW9uIGNsZWFyKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0aGF0ID0gdGhpczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgc3RhdGUgPSBnZXRJbnRlcm5hbFN0YXRlKHRoYXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBkYXRhID0gc3RhdGUuaW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVudHJ5ID0gc3RhdGUuZmlyc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGVudHJ5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LnJlbW92ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW50cnkucHJldmlvdXMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeS5wcmV2aW91cyA9IGVudHJ5LnByZXZpb3VzLm5leHQgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBkYXRhW2VudHJ5LmluZGV4XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnkgPSBlbnRyeS5uZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5maXJzdCA9IHN0YXRlLmxhc3QgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5zaXplID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoYXQuc2l6ZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgJ2RlbGV0ZSc6IGZ1bmN0aW9uIChrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGhhdCA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHN0YXRlID0gZ2V0SW50ZXJuYWxTdGF0ZSh0aGF0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgZW50cnkgPSBnZXRFbnRyeSh0aGF0LCBrZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbnRyeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgbmV4dCA9IGVudHJ5Lm5leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBwcmV2ID0gZW50cnkucHJldmlvdXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBzdGF0ZS5pbmRleFtlbnRyeS5pbmRleF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LnJlbW92ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHJldikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXYubmV4dCA9IG5leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXh0KQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV4dC5wcmV2aW91cyA9IHByZXY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZS5maXJzdCA9PSBlbnRyeSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXRlLmZpcnN0ID0gbmV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0YXRlLmxhc3QgPT0gZW50cnkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS5sYXN0ID0gcHJldjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERFU0NSSVBUT1JTKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGUuc2l6ZS0tOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGF0LnNpemUtLTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICEhZW50cnk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yRWFjaDogZnVuY3Rpb24gZm9yRWFjaChjYWxsYmFja2ZuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHN0YXRlID0gZ2V0SW50ZXJuYWxTdGF0ZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgYm91bmRGdW5jdGlvbiA9IGJpbmQoY2FsbGJhY2tmbiwgYXJndW1lbnRzLmxlbmd0aCA+IDEgPyBhcmd1bWVudHNbMV0gOiB1bmRlZmluZWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoZW50cnkgPSBlbnRyeSA/IGVudHJ5Lm5leHQgOiBzdGF0ZS5maXJzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib3VuZEZ1bmN0aW9uKGVudHJ5LnZhbHVlLCBlbnRyeS5rZXksIHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoZW50cnkgJiYgZW50cnkucmVtb3ZlZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5ID0gZW50cnkucHJldmlvdXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhczogZnVuY3Rpb24gaGFzKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhIWdldEVudHJ5KHRoaXMsIGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdElucyhQcm90b3R5cGUsIElTX01BUCA/IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gZ2V0KGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlbnRyeSA9IGdldEVudHJ5KHRoaXMsIGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGVudHJ5ICYmIGVudHJ5LnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldDogZnVuY3Rpb24gc2V0KGtleSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZGVmaW5lKHRoaXMsIGtleSA9PT0gMCA/IDAgOiBrZXksIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSA6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFkZDogZnVuY3Rpb24gYWRkKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmluZSh0aGlzLCB2YWx1ZSA9IHZhbHVlID09PSAwID8gMCA6IHZhbHVlLCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoREVTQ1JJUFRPUlMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluQWNjZXNzb3IoUHJvdG90eXBlLCAnc2l6ZScsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25maWd1cmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBnZXRJbnRlcm5hbFN0YXRlKHRoaXMpLnNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBDb25zdHJ1Y3RvcjsKICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgIHNldFN0cm9uZzogZnVuY3Rpb24gKENvbnN0cnVjdG9yLCBDT05TVFJVQ1RPUl9OQU1FLCBJU19NQVApIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIElURVJBVE9SX05BTUUgPSBDT05TVFJVQ1RPUl9OQU1FICsgJyBJdGVyYXRvcic7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbENvbGxlY3Rpb25TdGF0ZSA9IGludGVybmFsU3RhdGVHZXR0ZXJGb3IoQ09OU1RSVUNUT1JfTkFNRSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBnZXRJbnRlcm5hbEl0ZXJhdG9yU3RhdGUgPSBpbnRlcm5hbFN0YXRlR2V0dGVyRm9yKElURVJBVE9SX05BTUUpOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVJdGVyYXRvcihDb25zdHJ1Y3RvciwgQ09OU1RSVUNUT1JfTkFNRSwgZnVuY3Rpb24gKGl0ZXJhdGVkLCBraW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRJbnRlcm5hbFN0YXRlKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBJVEVSQVRPUl9OQU1FLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldDogaXRlcmF0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhdGU6IGdldEludGVybmFsQ29sbGVjdGlvblN0YXRlKGl0ZXJhdGVkKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBraW5kOiBraW5kLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxhc3Q6IHVuZGVmaW5lZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBzdGF0ZSA9IGdldEludGVybmFsSXRlcmF0b3JTdGF0ZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBraW5kID0gc3RhdGUua2luZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBlbnRyeSA9IHN0YXRlLmxhc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoZW50cnkgJiYgZW50cnkucmVtb3ZlZCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnRyeSA9IGVudHJ5LnByZXZpb3VzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzdGF0ZS50YXJnZXQgfHwgIShzdGF0ZS5sYXN0ID0gZW50cnkgPSBlbnRyeSA/IGVudHJ5Lm5leHQgOiBzdGF0ZS5zdGF0ZS5maXJzdCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZS50YXJnZXQgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNyZWF0ZUl0ZXJSZXN1bHRPYmplY3QodW5kZWZpbmVkLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09ICdrZXlzJykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlSXRlclJlc3VsdE9iamVjdChlbnRyeS5rZXksIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09ICd2YWx1ZXMnKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjcmVhdGVJdGVyUmVzdWx0T2JqZWN0KGVudHJ5LnZhbHVlLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlSXRlclJlc3VsdE9iamVjdChbCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZW50cnkua2V5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVudHJ5LnZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBdLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIElTX01BUCA/ICdlbnRyaWVzJyA6ICd2YWx1ZXMnLCAhSVNfTUFQLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0U3BlY2llcyhDT05TVFJVQ1RPUl9OQU1FKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjEgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluID0gX193X3BkZmpzX3JlcXVpcmVfXyg1MSk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IGZ1bmN0aW9uICh0YXJnZXQsIHNyYywgb3B0aW9ucykgewogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGtleSBpbiBzcmMpCiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmluZUJ1aWx0SW4odGFyZ2V0LCBrZXksIHNyY1trZXldLCBvcHRpb25zKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGFyZ2V0OwogICAgICAgICAgICAgICAgfTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTIyICovCiAgICAgICAgICAgIC8qKiovICgobW9kdWxlLCBfX3VudXNlZF93ZWJwYWNrX2V4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgogICAgICAgICAgICAgICAgdmFyIGdldEJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI3KTsKICAgICAgICAgICAgICAgIHZhciBkZWZpbmVCdWlsdEluQWNjZXNzb3IgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDg0KTsKICAgICAgICAgICAgICAgIHZhciB3ZWxsS25vd25TeW1ib2wgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDM3KTsKICAgICAgICAgICAgICAgIHZhciBERVNDUklQVE9SUyA9IF9fd19wZGZqc19yZXF1aXJlX18oOSk7CiAgICAgICAgICAgICAgICB2YXIgU1BFQ0lFUyA9IHdlbGxLbm93blN5bWJvbCgnc3BlY2llcycpOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoQ09OU1RSVUNUT1JfTkFNRSkgewogICAgICAgICAgICAgICAgICAgIHZhciBDb25zdHJ1Y3RvciA9IGdldEJ1aWx0SW4oQ09OU1RSVUNUT1JfTkFNRSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKERFU0NSSVBUT1JTICYmIENvbnN0cnVjdG9yICYmICFDb25zdHJ1Y3RvcltTUEVDSUVTXSkgewogICAgICAgICAgICAgICAgICAgICAgICBkZWZpbmVCdWlsdEluQWNjZXNzb3IoQ29uc3RydWN0b3IsIFNQRUNJRVMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbmZpZ3VyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjMgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgX193X3BkZmpzX3JlcXVpcmVfXygxMjQpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjQgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBjb2xsZWN0aW9uID0gX193X3BkZmpzX3JlcXVpcmVfXygxMDIpOwogICAgICAgICAgICAgICAgdmFyIGNvbGxlY3Rpb25TdHJvbmcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyMCk7CiAgICAgICAgICAgICAgICBjb2xsZWN0aW9uKCdTZXQnLCBmdW5jdGlvbiAoaW5pdCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBTZXQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpbml0KHRoaXMsIGFyZ3VtZW50cy5sZW5ndGggPyBhcmd1bWVudHNbMF0gOiB1bmRlZmluZWQpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9LCBjb2xsZWN0aW9uU3Ryb25nKTsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTI1ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBJU19QVVJFID0gX193X3BkZmpzX3JlcXVpcmVfXygzOSk7CiAgICAgICAgICAgICAgICB2YXIgJCA9IF9fd19wZGZqc19yZXF1aXJlX18oNik7CiAgICAgICAgICAgICAgICB2YXIgZ2xvYmFsID0gX193X3BkZmpzX3JlcXVpcmVfXyg3KTsKICAgICAgICAgICAgICAgIHZhciBnZXRCdWlsdGluID0gX193X3BkZmpzX3JlcXVpcmVfXygyNyk7CiAgICAgICAgICAgICAgICB2YXIgdW5jdXJyeVRoaXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE3KTsKICAgICAgICAgICAgICAgIHZhciBmYWlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTApOwogICAgICAgICAgICAgICAgdmFyIHVpZCA9IF9fd19wZGZqc19yZXF1aXJlX18oNDQpOwogICAgICAgICAgICAgICAgdmFyIGlzQ2FsbGFibGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI0KTsKICAgICAgICAgICAgICAgIHZhciBpc0NvbnN0cnVjdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxMjYpOwogICAgICAgICAgICAgICAgdmFyIGlzTnVsbE9yVW5kZWZpbmVkID0gX193X3BkZmpzX3JlcXVpcmVfXygyMCk7CiAgICAgICAgICAgICAgICB2YXIgaXNPYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDIzKTsKICAgICAgICAgICAgICAgIHZhciBpc1N5bWJvbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMjYpOwogICAgICAgICAgICAgICAgdmFyIGl0ZXJhdGUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExMCk7CiAgICAgICAgICAgICAgICB2YXIgYW5PYmplY3QgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDUwKTsKICAgICAgICAgICAgICAgIHZhciBjbGFzc29mID0gX193X3BkZmpzX3JlcXVpcmVfXyg4Mik7CiAgICAgICAgICAgICAgICB2YXIgaGFzT3duID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Mik7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwNik7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlTm9uRW51bWVyYWJsZVByb3BlcnR5ID0gX193X3BkZmpzX3JlcXVpcmVfXyg0Nyk7CiAgICAgICAgICAgICAgICB2YXIgbGVuZ3RoT2ZBcnJheUxpa2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDY3KTsKICAgICAgICAgICAgICAgIHZhciB2YWxpZGF0ZUFyZ3VtZW50c0xlbmd0aCA9IF9fd19wZGZqc19yZXF1aXJlX18oMTI3KTsKICAgICAgICAgICAgICAgIHZhciBnZXRSZWdFeHBGbGFncyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTI4KTsKICAgICAgICAgICAgICAgIHZhciBNYXBIZWxwZXJzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMzApOwogICAgICAgICAgICAgICAgdmFyIFNldEhlbHBlcnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzMSk7CiAgICAgICAgICAgICAgICB2YXIgRVJST1JfU1RBQ0tfSU5TVEFMTEFCTEUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzMik7CiAgICAgICAgICAgICAgICB2YXIgUFJPUEVSX1RSQU5TRkVSID0gX193X3BkZmpzX3JlcXVpcmVfXygxMzMpOwogICAgICAgICAgICAgICAgdmFyIE9iamVjdCA9IGdsb2JhbC5PYmplY3Q7CiAgICAgICAgICAgICAgICB2YXIgQXJyYXkgPSBnbG9iYWwuQXJyYXk7CiAgICAgICAgICAgICAgICB2YXIgRGF0ZSA9IGdsb2JhbC5EYXRlOwogICAgICAgICAgICAgICAgdmFyIEVycm9yID0gZ2xvYmFsLkVycm9yOwogICAgICAgICAgICAgICAgdmFyIEV2YWxFcnJvciA9IGdsb2JhbC5FdmFsRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgUmFuZ2VFcnJvciA9IGdsb2JhbC5SYW5nZUVycm9yOwogICAgICAgICAgICAgICAgdmFyIFJlZmVyZW5jZUVycm9yID0gZ2xvYmFsLlJlZmVyZW5jZUVycm9yOwogICAgICAgICAgICAgICAgdmFyIFN5bnRheEVycm9yID0gZ2xvYmFsLlN5bnRheEVycm9yOwogICAgICAgICAgICAgICAgdmFyIFR5cGVFcnJvciA9IGdsb2JhbC5UeXBlRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgVVJJRXJyb3IgPSBnbG9iYWwuVVJJRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgUGVyZm9ybWFuY2VNYXJrID0gZ2xvYmFsLlBlcmZvcm1hbmNlTWFyazsKICAgICAgICAgICAgICAgIHZhciBXZWJBc3NlbWJseSA9IGdsb2JhbC5XZWJBc3NlbWJseTsKICAgICAgICAgICAgICAgIHZhciBDb21waWxlRXJyb3IgPSBXZWJBc3NlbWJseSAmJiBXZWJBc3NlbWJseS5Db21waWxlRXJyb3IgfHwgRXJyb3I7CiAgICAgICAgICAgICAgICB2YXIgTGlua0Vycm9yID0gV2ViQXNzZW1ibHkgJiYgV2ViQXNzZW1ibHkuTGlua0Vycm9yIHx8IEVycm9yOwogICAgICAgICAgICAgICAgdmFyIFJ1bnRpbWVFcnJvciA9IFdlYkFzc2VtYmx5ICYmIFdlYkFzc2VtYmx5LlJ1bnRpbWVFcnJvciB8fCBFcnJvcjsKICAgICAgICAgICAgICAgIHZhciBET01FeGNlcHRpb24gPSBnZXRCdWlsdGluKCdET01FeGNlcHRpb24nKTsKICAgICAgICAgICAgICAgIHZhciBNYXAgPSBNYXBIZWxwZXJzLk1hcDsKICAgICAgICAgICAgICAgIHZhciBtYXBIYXMgPSBNYXBIZWxwZXJzLmhhczsKICAgICAgICAgICAgICAgIHZhciBtYXBHZXQgPSBNYXBIZWxwZXJzLmdldDsKICAgICAgICAgICAgICAgIHZhciBtYXBTZXQgPSBNYXBIZWxwZXJzLnNldDsKICAgICAgICAgICAgICAgIHZhciBTZXQgPSBTZXRIZWxwZXJzLlNldDsKICAgICAgICAgICAgICAgIHZhciBzZXRBZGQgPSBTZXRIZWxwZXJzLmFkZDsKICAgICAgICAgICAgICAgIHZhciBvYmplY3RLZXlzID0gZ2V0QnVpbHRpbignT2JqZWN0JywgJ2tleXMnKTsKICAgICAgICAgICAgICAgIHZhciBwdXNoID0gdW5jdXJyeVRoaXMoW10ucHVzaCk7CiAgICAgICAgICAgICAgICB2YXIgdGhpc0Jvb2xlYW5WYWx1ZSA9IHVuY3VycnlUaGlzKHRydWUudmFsdWVPZik7CiAgICAgICAgICAgICAgICB2YXIgdGhpc051bWJlclZhbHVlID0gdW5jdXJyeVRoaXMoMS4wLnZhbHVlT2YpOwogICAgICAgICAgICAgICAgdmFyIHRoaXNTdHJpbmdWYWx1ZSA9IHVuY3VycnlUaGlzKCcnLnZhbHVlT2YpOwogICAgICAgICAgICAgICAgdmFyIHRoaXNUaW1lVmFsdWUgPSB1bmN1cnJ5VGhpcyhEYXRlLnByb3RvdHlwZS5nZXRUaW1lKTsKICAgICAgICAgICAgICAgIHZhciBQRVJGT1JNQU5DRV9NQVJLID0gdWlkKCdzdHJ1Y3R1cmVkQ2xvbmUnKTsKICAgICAgICAgICAgICAgIHZhciBEQVRBX0NMT05FX0VSUk9SID0gJ0RhdGFDbG9uZUVycm9yJzsKICAgICAgICAgICAgICAgIHZhciBUUkFOU0ZFUlJJTkcgPSAnVHJhbnNmZXJyaW5nJzsKICAgICAgICAgICAgICAgIHZhciBjaGVja0Jhc2ljU2VtYW50aWMgPSBmdW5jdGlvbiAoc3RydWN0dXJlZENsb25lSW1wbGVtZW50YXRpb24pIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHNldDEgPSBuZXcgZ2xvYmFsLlNldChbN10pOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgc2V0MiA9IHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uKHNldDEpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgbnVtYmVyID0gc3RydWN0dXJlZENsb25lSW1wbGVtZW50YXRpb24oT2JqZWN0KDcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHNldDIgPT0gc2V0MSB8fCAhc2V0Mi5oYXMoNykgfHwgdHlwZW9mIG51bWJlciAhPSAnb2JqZWN0JyB8fCBudW1iZXIgIT0gNzsKICAgICAgICAgICAgICAgICAgICB9KSAmJiBzdHJ1Y3R1cmVkQ2xvbmVJbXBsZW1lbnRhdGlvbjsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgY2hlY2tFcnJvcnNDbG9uaW5nID0gZnVuY3Rpb24gKHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uLCAkRXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gIWZhaWxzKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGVycm9yID0gbmV3ICRFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGE6IGVycm9yLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYjogZXJyb3IKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhKHRlc3QgJiYgdGVzdC5hID09PSB0ZXN0LmIgJiYgdGVzdC5hIGluc3RhbmNlb2YgJEVycm9yICYmIHRlc3QuYS5zdGFjayA9PT0gZXJyb3Iuc3RhY2spOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciBjaGVja05ld0Vycm9yc0Nsb25pbmdTZW1hbnRpYyA9IGZ1bmN0aW9uIChzdHJ1Y3R1cmVkQ2xvbmVJbXBsZW1lbnRhdGlvbikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGVzdCA9IHN0cnVjdHVyZWRDbG9uZUltcGxlbWVudGF0aW9uKG5ldyBnbG9iYWwuQWdncmVnYXRlRXJyb3IoWzFdLCBQRVJGT1JNQU5DRV9NQVJLLCB7IGNhdXNlOiAzIH0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRlc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1bmN0aW9uICh0eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IERPTUV4Y2VwdGlvbignVW5jbG9uZWFibGUgdHlwZTogJyArIHR5cGUsIERBVEFfQ0xPTkVfRVJST1IpOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciB0aHJvd1VucG9seWZpbGxhYmxlID0gZnVuY3Rpb24gKHR5cGUsIGFjdGlvbikgewogICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oKGFjdGlvbiB8fCAnQ2xvbmluZycpICsgJyBvZiAnICsgdHlwZSArICcgY2Fubm90IGJlIHByb3Blcmx5IHBvbHlmaWxsZWQgaW4gdGhpcyBlbmdpbmUnLCBEQVRBX0NMT05FX0VSUk9SKTsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlRGF0YVRyYW5zZmVyID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciBkYXRhVHJhbnNmZXI7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyID0gbmV3IGdsb2JhbC5EYXRhVHJhbnNmZXIoKTsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyID0gbmV3IGdsb2JhbC5DbGlwYm9hcmRFdmVudCgnJykuY2xpcGJvYXJkRGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGFUcmFuc2ZlciAmJiBkYXRhVHJhbnNmZXIuaXRlbXMgJiYgZGF0YVRyYW5zZmVyLmZpbGVzID8gZGF0YVRyYW5zZmVyIDogbnVsbDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgc3RydWN0dXJlZENsb25lSW50ZXJuYWwgPSBmdW5jdGlvbiAodmFsdWUsIG1hcCkgewogICAgICAgICAgICAgICAgICAgIGlmIChpc1N5bWJvbCh2YWx1ZSkpCiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5jbG9uZWFibGUoJ1N5bWJvbCcpOwogICAgICAgICAgICAgICAgICAgIGlmICghaXNPYmplY3QodmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgaWYgKG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAobWFwSGFzKG1hcCwgdmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hcEdldChtYXAsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgbWFwID0gbmV3IE1hcCgpOwogICAgICAgICAgICAgICAgICAgIHZhciB0eXBlID0gY2xhc3NvZih2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGRlZXAgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB2YXIgQywgbmFtZSwgY2xvbmVkLCBkYXRhVHJhbnNmZXIsIGksIGxlbmd0aCwga2V5cywga2V5LCBzb3VyY2UsIHRhcmdldCwgb3B0aW9uczsKICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gQXJyYXkobGVuZ3RoT2ZBcnJheUxpa2UodmFsdWUpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZXAgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ09iamVjdCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZXAgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ01hcCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWVwID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdTZXQnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmV3IFNldCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVlcCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnUmVnRXhwJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBSZWdFeHAodmFsdWUuc291cmNlLCBnZXRSZWdFeHBGbGFncyh2YWx1ZSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Vycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUgPSB2YWx1ZS5uYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQWdncmVnYXRlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBnZXRCdWlsdGluKCdBZ2dyZWdhdGVFcnJvcicpKFtdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRXZhbEVycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gRXZhbEVycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1JhbmdlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBSYW5nZUVycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1JlZmVyZW5jZUVycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gUmVmZXJlbmNlRXJyb3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnU3ludGF4RXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBTeW50YXhFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdUeXBlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBUeXBlRXJyb3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnVVJJRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBVUklFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdDb21waWxlRXJyb3InOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBDb21waWxlRXJyb3IoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnTGlua0Vycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gTGlua0Vycm9yKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1J1bnRpbWVFcnJvcic6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IFJ1bnRpbWVFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBFcnJvcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVlcCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NRXhjZXB0aW9uJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBET01FeGNlcHRpb24odmFsdWUubWVzc2FnZSwgdmFsdWUubmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWVwID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdEYXRhVmlldyc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ludDhBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1VpbnQ4QXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdVaW50OENsYW1wZWRBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ludDE2QXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdVaW50MTZBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ludDMyQXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdVaW50MzJBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Zsb2F0MzJBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Zsb2F0NjRBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0JpZ0ludDY0QXJyYXknOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdCaWdVaW50NjRBcnJheSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBDID0gZ2xvYmFsW3R5cGVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpc09iamVjdChDKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmV3IEMoc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUuYnVmZmVyLCBtYXApLCB2YWx1ZS5ieXRlT2Zmc2V0LCB0eXBlID09PSAnRGF0YVZpZXcnID8gdmFsdWUuYnl0ZUxlbmd0aCA6IHZhbHVlLmxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NUXVhZCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBET01RdWFkKHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLnAxLCBtYXApLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2YWx1ZS5wMiwgbWFwKSwgc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUucDMsIG1hcCksIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLnA0LCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hdGl2ZVJlc3RyaWN0ZWRTdHJ1Y3R1cmVkQ2xvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRmlsZUxpc3QnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyID0gY3JlYXRlRGF0YVRyYW5zZmVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVRyYW5zZmVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMCwgbGVuZ3RoID0gbGVuZ3RoT2ZBcnJheUxpa2UodmFsdWUpOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVRyYW5zZmVyLml0ZW1zLmFkZChzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2YWx1ZVtpXSwgbWFwKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IGRhdGFUcmFuc2Zlci5maWxlczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAobmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5hdGl2ZVJlc3RyaWN0ZWRTdHJ1Y3R1cmVkQ2xvbmUodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdJbWFnZURhdGEnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBuZXcgSW1hZ2VEYXRhKHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLmRhdGEsIG1hcCksIHZhbHVlLndpZHRoLCB2YWx1ZS5oZWlnaHQsIHsgY29sb3JTcGFjZTogdmFsdWUuY29sb3JTcGFjZSB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hdGl2ZVJlc3RyaWN0ZWRTdHJ1Y3R1cmVkQ2xvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuYXRpdmVSZXN0cmljdGVkU3RydWN0dXJlZENsb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmF0aXZlUmVzdHJpY3RlZFN0cnVjdHVyZWRDbG9uZSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQmlnSW50JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IE9iamVjdCh2YWx1ZS52YWx1ZU9mKCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Jvb2xlYW4nOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gT2JqZWN0KHRoaXNCb29sZWFuVmFsdWUodmFsdWUpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdOdW1iZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gT2JqZWN0KHRoaXNOdW1iZXJWYWx1ZSh2YWx1ZSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1N0cmluZyc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBPYmplY3QodGhpc1N0cmluZ1ZhbHVlKHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRGF0ZSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBuZXcgRGF0ZSh0aGlzVGltZVZhbHVlKHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQXJyYXlCdWZmZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbC5EYXRhVmlldzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghQyAmJiB0eXBlb2YgdmFsdWUuc2xpY2UgIT0gJ2Z1bmN0aW9uJykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlLnNsaWNlID09ICdmdW5jdGlvbicgJiYgIXZhbHVlLnJlc2l6YWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSB2YWx1ZS5zbGljZSgwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGggPSB2YWx1ZS5ieXRlTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25zID0gJ21heEJ5dGVMZW5ndGgnIGluIHZhbHVlID8geyBtYXhCeXRlTGVuZ3RoOiB2YWx1ZS5tYXhCeXRlTGVuZ3RoIH0gOiB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IG5ldyBBcnJheUJ1ZmZlcihsZW5ndGgsIG9wdGlvbnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2UgPSBuZXcgQyh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldCA9IG5ldyBDKGNsb25lZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0LnNldFVpbnQ4KGksIHNvdXJjZS5nZXRVaW50OChpKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oJ0FycmF5QnVmZmVyIGlzIGRldGFjaGVkJywgREFUQV9DTE9ORV9FUlJPUik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnU2hhcmVkQXJyYXlCdWZmZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQmxvYic6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lZCA9IHZhbHVlLnNsaWNlKDAsIHZhbHVlLnNpemUsIHZhbHVlLnR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0RPTVBvaW50JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NUG9pbnRSZWFkT25seSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDID0gZ2xvYmFsW3R5cGVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQgPSBDLmZyb21Qb2ludCA/IEMuZnJvbVBvaW50KHZhbHVlKSA6IG5ldyBDKHZhbHVlLngsIHZhbHVlLnksIHZhbHVlLnosIHZhbHVlLncpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0RPTVJlY3QnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdET01SZWN0UmVhZE9ubHknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbFt0eXBlXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gQy5mcm9tUmVjdCA/IEMuZnJvbVJlY3QodmFsdWUpIDogbmV3IEModmFsdWUueCwgdmFsdWUueSwgdmFsdWUud2lkdGgsIHZhbHVlLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NTWF0cml4JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRE9NTWF0cml4UmVhZE9ubHknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbFt0eXBlXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gQy5mcm9tTWF0cml4ID8gQy5mcm9tTWF0cml4KHZhbHVlKSA6IG5ldyBDKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBdWRpb0RhdGEnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdWaWRlb0ZyYW1lJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNDYWxsYWJsZSh2YWx1ZS5jbG9uZSkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gdmFsdWUuY2xvbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbmNsb25lYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdGaWxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmVkID0gbmV3IEZpbGUoW3ZhbHVlXSwgdmFsdWUubmFtZSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Nyb3BUYXJnZXQnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdDcnlwdG9LZXknOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdGaWxlU3lzdGVtRGlyZWN0b3J5SGFuZGxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnRmlsZVN5c3RlbUZpbGVIYW5kbGUnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdGaWxlU3lzdGVtSGFuZGxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnR1BVQ29tcGlsYXRpb25JbmZvJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnR1BVQ29tcGlsYXRpb25NZXNzYWdlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnSW1hZ2VCaXRtYXAnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdSVENDZXJ0aWZpY2F0ZSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1dlYkFzc2VtYmx5Lk1vZHVsZSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvd1VucG9seWZpbGxhYmxlKHR5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbmNsb25lYWJsZSh0eXBlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG1hcFNldChtYXAsIHZhbHVlLCBjbG9uZWQpOwogICAgICAgICAgICAgICAgICAgIGlmIChkZWVwKQogICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0FycmF5JzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ09iamVjdCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5cyA9IG9iamVjdEtleXModmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDAsIGxlbmd0aCA9IGxlbmd0aE9mQXJyYXlMaWtlKGtleXMpOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5ID0ga2V5c1tpXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUHJvcGVydHkoY2xvbmVkLCBrZXksIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlW2tleV0sIG1hcCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ01hcCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUuZm9yRWFjaChmdW5jdGlvbiAodiwgaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXBTZXQoY2xvbmVkLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbChrLCBtYXApLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2LCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1NldCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUuZm9yRWFjaChmdW5jdGlvbiAodikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRBZGQoY2xvbmVkLCBzdHJ1Y3R1cmVkQ2xvbmVJbnRlcm5hbCh2LCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0Vycm9yJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjcmVhdGVOb25FbnVtZXJhYmxlUHJvcGVydHkoY2xvbmVkLCAnbWVzc2FnZScsIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLm1lc3NhZ2UsIG1hcCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoYXNPd24odmFsdWUsICdjYXVzZScpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShjbG9uZWQsICdjYXVzZScsIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLmNhdXNlLCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hbWUgPT0gJ0FnZ3JlZ2F0ZUVycm9yJykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZWQuZXJyb3JzID0gc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUuZXJyb3JzLCBtYXApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0RPTUV4Y2VwdGlvbic6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEVSUk9SX1NUQUNLX0lOU1RBTExBQkxFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZU5vbkVudW1lcmFibGVQcm9wZXJ0eShjbG9uZWQsICdzdGFjaycsIHN0cnVjdHVyZWRDbG9uZUludGVybmFsKHZhbHVlLnN0YWNrLCBtYXApKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xvbmVkOwogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIHZhciB0cnlUb1RyYW5zZmVyID0gZnVuY3Rpb24gKHJhd1RyYW5zZmVyLCBtYXApIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzT2JqZWN0KHJhd1RyYW5zZmVyKSkKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgVHlwZUVycm9yKCdUcmFuc2ZlciBvcHRpb24gY2Fubm90IGJlIGNvbnZlcnRlZCB0byBhIHNlcXVlbmNlJyk7CiAgICAgICAgICAgICAgICAgICAgdmFyIHRyYW5zZmVyID0gW107CiAgICAgICAgICAgICAgICAgICAgaXRlcmF0ZShyYXdUcmFuc2ZlciwgZnVuY3Rpb24gKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHB1c2godHJhbnNmZXIsIGFuT2JqZWN0KHZhbHVlKSk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGkgPSAwOwogICAgICAgICAgICAgICAgICAgIHZhciBsZW5ndGggPSBsZW5ndGhPZkFycmF5TGlrZSh0cmFuc2Zlcik7CiAgICAgICAgICAgICAgICAgICAgdmFyIHZhbHVlLCB0eXBlLCBDLCB0cmFuc2ZlcnJlZEFycmF5LCB0cmFuc2ZlcnJlZCwgY2FudmFzLCBjb250ZXh0OwogICAgICAgICAgICAgICAgICAgIGlmIChQUk9QRVJfVFJBTlNGRVIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmZXJyZWRBcnJheSA9IG5hdGl2ZVN0cnVjdHVyZWRDbG9uZSh0cmFuc2ZlciwgeyB0cmFuc2ZlcjogdHJhbnNmZXIgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChpIDwgbGVuZ3RoKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwU2V0KG1hcCwgdHJhbnNmZXJbaV0sIHRyYW5zZmVycmVkQXJyYXlbaSsrXSk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChpIDwgbGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHRyYW5zZmVyW2krK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobWFwSGFzKG1hcCwgdmFsdWUpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oJ0R1cGxpY2F0ZSB0cmFuc2ZlcmFibGUnLCBEQVRBX0NMT05FX0VSUk9SKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUgPSBjbGFzc29mKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ0ltYWdlQml0bWFwJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQyA9IGdsb2JhbC5PZmZzY3JlZW5DYW52YXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNDb25zdHJ1Y3RvcihDKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSwgVFJBTlNGRVJSSU5HKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcyA9IG5ldyBDKHZhbHVlLndpZHRoLCB2YWx1ZS5oZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dCA9IGNhbnZhcy5nZXRDb250ZXh0KCdiaXRtYXByZW5kZXJlcicpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dC50cmFuc2ZlckZyb21JbWFnZUJpdG1hcCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2ZlcnJlZCA9IGNhbnZhcy50cmFuc2ZlclRvSW1hZ2VCaXRtYXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBdWRpb0RhdGEnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ1ZpZGVvRnJhbWUnOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUodmFsdWUuY2xvbmUpIHx8ICFpc0NhbGxhYmxlKHZhbHVlLmNsb3NlKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSwgVFJBTlNGRVJSSU5HKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zZmVycmVkID0gdmFsdWUuY2xvbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLmNsb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnQXJyYXlCdWZmZXInOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUodmFsdWUudHJhbnNmZXIpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3dVbnBvbHlmaWxsYWJsZSh0eXBlLCBUUkFOU0ZFUlJJTkcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2ZlcnJlZCA9IHZhbHVlLnRyYW5zZmVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgJ01lZGlhU291cmNlSGFuZGxlJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdNZXNzYWdlUG9ydCc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnT2Zmc2NyZWVuQ2FudmFzJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdSZWFkYWJsZVN0cmVhbSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnVHJhbnNmb3JtU3RyZWFtJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdXcml0YWJsZVN0cmVhbSc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93VW5wb2x5ZmlsbGFibGUodHlwZSwgVFJBTlNGRVJSSU5HKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc2ZlcnJlZCA9PT0gdW5kZWZpbmVkKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBET01FeGNlcHRpb24oJ1RoaXMgb2JqZWN0IGNhbm5vdCBiZSB0cmFuc2ZlcnJlZDogJyArIHR5cGUsIERBVEFfQ0xPTkVfRVJST1IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwU2V0KG1hcCwgdmFsdWUsIHRyYW5zZmVycmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICQoewogICAgICAgICAgICAgICAgICAgIGdsb2JhbDogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgIHNoYW06ICFQUk9QRVJfVFJBTlNGRVIsCiAgICAgICAgICAgICAgICAgICAgZm9yY2VkOiBGT1JDRURfUkVQTEFDRU1FTlQKICAgICAgICAgICAgICAgIH0sIHsKICAgICAgICAgICAgICAgICAgICBzdHJ1Y3R1cmVkQ2xvbmU6IGZ1bmN0aW9uIHN0cnVjdHVyZWRDbG9uZSh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgb3B0aW9ucyA9IHZhbGlkYXRlQXJndW1lbnRzTGVuZ3RoKGFyZ3VtZW50cy5sZW5ndGgsIDEpID4gMSAmJiAhaXNOdWxsT3JVbmRlZmluZWQoYXJndW1lbnRzWzFdKSA/IGFuT2JqZWN0KGFyZ3VtZW50c1sxXSkgOiB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0cmFuc2ZlciA9IG9wdGlvbnMgPyBvcHRpb25zLnRyYW5zZmVyIDogdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgbWFwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodHJhbnNmZXIgIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwID0gbmV3IE1hcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5VG9UcmFuc2Zlcih0cmFuc2ZlciwgbWFwKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3RydWN0dXJlZENsb25lSW50ZXJuYWwodmFsdWUsIG1hcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyNiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgZmFpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEwKTsKICAgICAgICAgICAgICAgIHZhciBpc0NhbGxhYmxlID0gX193X3BkZmpzX3JlcXVpcmVfXygyNCk7CiAgICAgICAgICAgICAgICB2YXIgY2xhc3NvZiA9IF9fd19wZGZqc19yZXF1aXJlX18oODIpOwogICAgICAgICAgICAgICAgdmFyIGdldEJ1aWx0SW4gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDI3KTsKICAgICAgICAgICAgICAgIHZhciBpbnNwZWN0U291cmNlID0gX193X3BkZmpzX3JlcXVpcmVfXyg1NCk7CiAgICAgICAgICAgICAgICB2YXIgbm9vcCA9IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgZW1wdHkgPSBbXTsKICAgICAgICAgICAgICAgIHZhciBjb25zdHJ1Y3QgPSBnZXRCdWlsdEluKCdSZWZsZWN0JywgJ2NvbnN0cnVjdCcpOwogICAgICAgICAgICAgICAgdmFyIGNvbnN0cnVjdG9yUmVnRXhwID0gL15ccyooPzpjbGFzc3xmdW5jdGlvbilcYi87CiAgICAgICAgICAgICAgICB2YXIgZXhlYyA9IHVuY3VycnlUaGlzKGNvbnN0cnVjdG9yUmVnRXhwLmV4ZWMpOwogICAgICAgICAgICAgICAgdmFyIElOQ09SUkVDVF9UT19TVFJJTkcgPSAhY29uc3RydWN0b3JSZWdFeHAuZXhlYyhub29wKTsKICAgICAgICAgICAgICAgIHZhciBpc0NvbnN0cnVjdG9yTW9kZXJuID0gZnVuY3Rpb24gaXNDb25zdHJ1Y3Rvcihhcmd1bWVudCkgewogICAgICAgICAgICAgICAgICAgIGlmICghaXNDYWxsYWJsZShhcmd1bWVudCkpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Qobm9vcCwgZW1wdHksIGFyZ3VtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB2YXIgaXNDb25zdHJ1Y3RvckxlZ2FjeSA9IGZ1bmN0aW9uIGlzQ29uc3RydWN0b3IoYXJndW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ2FsbGFibGUoYXJndW1lbnQpKQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChjbGFzc29mKGFyZ3VtZW50KSkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBc3luY0Z1bmN0aW9uJzoKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAnR2VuZXJhdG9yRnVuY3Rpb24nOgogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICdBc3luY0dlbmVyYXRvckZ1bmN0aW9uJzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIElOQ09SUkVDVF9UT19TVFJJTkcgfHwgISFleGVjKGNvbnN0cnVjdG9yUmVnRXhwLCBpbnNwZWN0U291cmNlKGFyZ3VtZW50KSk7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIGlzQ29uc3RydWN0b3JMZWdhY3kuc2hhbSA9IHRydWU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICFjb25zdHJ1Y3QgfHwgZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHZhciBjYWxsZWQ7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGlzQ29uc3RydWN0b3JNb2Rlcm4oaXNDb25zdHJ1Y3Rvck1vZGVybi5jYWxsKSB8fCAhaXNDb25zdHJ1Y3Rvck1vZGVybihPYmplY3QpIHx8ICFpc0NvbnN0cnVjdG9yTW9kZXJuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9KSB8fCBjYWxsZWQ7CiAgICAgICAgICAgICAgICB9KSA/IGlzQ29uc3RydWN0b3JMZWdhY3kgOiBpc0NvbnN0cnVjdG9yTW9kZXJuOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMjcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUpID0+IHsKCiAgICAgICAgICAgICAgICB2YXIgJFR5cGVFcnJvciA9IFR5cGVFcnJvcjsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKHBhc3NlZCwgcmVxdWlyZWQpIHsKICAgICAgICAgICAgICAgICAgICBpZiAocGFzc2VkIDwgcmVxdWlyZWQpCiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93ICRUeXBlRXJyb3IoJ05vdCBlbm91Z2ggYXJndW1lbnRzJyk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhc3NlZDsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyOCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGNhbGwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDExKTsKICAgICAgICAgICAgICAgIHZhciBoYXNPd24gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDQyKTsKICAgICAgICAgICAgICAgIHZhciBpc1Byb3RvdHlwZU9mID0gX193X3BkZmpzX3JlcXVpcmVfXygyOCk7CiAgICAgICAgICAgICAgICB2YXIgcmVnRXhwRmxhZ3MgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEyOSk7CiAgICAgICAgICAgICAgICB2YXIgUmVnRXhwUHJvdG90eXBlID0gUmVnRXhwLnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKFIpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgZmxhZ3MgPSBSLmZsYWdzOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBmbGFncyA9PT0gdW5kZWZpbmVkICYmICEoJ2ZsYWdzJyBpbiBSZWdFeHBQcm90b3R5cGUpICYmICFoYXNPd24oUiwgJ2ZsYWdzJykgJiYgaXNQcm90b3R5cGVPZihSZWdFeHBQcm90b3R5cGUsIFIpID8gY2FsbChyZWdFeHBGbGFncywgUikgOiBmbGFnczsKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEyOSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKICAgICAgICAgICAgICAgIHZhciBhbk9iamVjdCA9IF9fd19wZGZqc19yZXF1aXJlX18oNTApOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHRoYXQgPSBhbk9iamVjdCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gJyc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuaGFzSW5kaWNlcykKICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ICs9ICdkJzsKICAgICAgICAgICAgICAgICAgICBpZiAodGhhdC5nbG9iYWwpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAnZyc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuaWdub3JlQ2FzZSkKICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0ICs9ICdpJzsKICAgICAgICAgICAgICAgICAgICBpZiAodGhhdC5tdWx0aWxpbmUpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAnbSc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuZG90QWxsKQogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgKz0gJ3MnOwogICAgICAgICAgICAgICAgICAgIGlmICh0aGF0LnVuaWNvZGUpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAndSc7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQudW5pY29kZVNldHMpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSAndic7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRoYXQuc3RpY2t5KQogICAgICAgICAgICAgICAgICAgICAgICByZXN1bHQgKz0gJ3knOwogICAgICAgICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7CiAgICAgICAgICAgICAgICB9OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzAgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciB1bmN1cnJ5VGhpcyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTcpOwogICAgICAgICAgICAgICAgdmFyIE1hcFByb3RvdHlwZSA9IE1hcC5wcm90b3R5cGU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHsKICAgICAgICAgICAgICAgICAgICBNYXA6IE1hcCwKICAgICAgICAgICAgICAgICAgICBzZXQ6IHVuY3VycnlUaGlzKE1hcFByb3RvdHlwZS5zZXQpLAogICAgICAgICAgICAgICAgICAgIGdldDogdW5jdXJyeVRoaXMoTWFwUHJvdG90eXBlLmdldCksCiAgICAgICAgICAgICAgICAgICAgaGFzOiB1bmN1cnJ5VGhpcyhNYXBQcm90b3R5cGUuaGFzKSwKICAgICAgICAgICAgICAgICAgICByZW1vdmU6IHVuY3VycnlUaGlzKE1hcFByb3RvdHlwZVsnZGVsZXRlJ10pLAogICAgICAgICAgICAgICAgICAgIHByb3RvOiBNYXBQcm90b3R5cGUKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzMSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIHVuY3VycnlUaGlzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNyk7CiAgICAgICAgICAgICAgICB2YXIgU2V0UHJvdG90eXBlID0gU2V0LnByb3RvdHlwZTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gewogICAgICAgICAgICAgICAgICAgIFNldDogU2V0LAogICAgICAgICAgICAgICAgICAgIGFkZDogdW5jdXJyeVRoaXMoU2V0UHJvdG90eXBlLmFkZCksCiAgICAgICAgICAgICAgICAgICAgaGFzOiB1bmN1cnJ5VGhpcyhTZXRQcm90b3R5cGUuaGFzKSwKICAgICAgICAgICAgICAgICAgICByZW1vdmU6IHVuY3VycnlUaGlzKFNldFByb3RvdHlwZVsnZGVsZXRlJ10pLAogICAgICAgICAgICAgICAgICAgIHByb3RvOiBTZXRQcm90b3R5cGUsCiAgICAgICAgICAgICAgICAgICAgJGhhczogU2V0UHJvdG90eXBlLmhhcywKICAgICAgICAgICAgICAgICAgICAka2V5czogU2V0UHJvdG90eXBlLmtleXMKICAgICAgICAgICAgICAgIH07CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzMiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICB2YXIgY3JlYXRlUHJvcGVydHlEZXNjcmlwdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9ICFmYWlscyhmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGVycm9yID0gRXJyb3IoJ2EnKTsKICAgICAgICAgICAgICAgICAgICBpZiAoISgnc3RhY2snIGluIGVycm9yKSkKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGVycm9yLCAnc3RhY2snLCBjcmVhdGVQcm9wZXJ0eURlc2NyaXB0b3IoMSwgNykpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBlcnJvci5zdGFjayAhPT0gNzsKICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzMgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDcpOwogICAgICAgICAgICAgICAgdmFyIGZhaWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxMCk7CiAgICAgICAgICAgICAgICB2YXIgVjggPSBfX3dfcGRmanNfcmVxdWlyZV9fKDMxKTsKICAgICAgICAgICAgICAgIHZhciBJU19CUk9XU0VSID0gX193X3BkZmpzX3JlcXVpcmVfXygxMzQpOwogICAgICAgICAgICAgICAgdmFyIElTX0RFTk8gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzNSk7CiAgICAgICAgICAgICAgICB2YXIgSVNfTk9ERSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTM2KTsKICAgICAgICAgICAgICAgIHZhciBzdHJ1Y3R1cmVkQ2xvbmUgPSBnbG9iYWwuc3RydWN0dXJlZENsb25lOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMgPSAhIXN0cnVjdHVyZWRDbG9uZSAmJiAhZmFpbHMoZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChJU19ERU5PICYmIFY4ID4gOTIgfHwgSVNfTk9ERSAmJiBWOCA+IDk0IHx8IElTX0JST1dTRVIgJiYgVjggPiA5NykKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHZhciBidWZmZXIgPSBuZXcgQXJyYXlCdWZmZXIoOCk7CiAgICAgICAgICAgICAgICAgICAgdmFyIGNsb25lID0gc3RydWN0dXJlZENsb25lKGJ1ZmZlciwgeyB0cmFuc2ZlcjogW2J1ZmZlcl0gfSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGJ1ZmZlci5ieXRlTGVuZ3RoICE9IDAgfHwgY2xvbmUuYnl0ZUxlbmd0aCAhPSA4OwogICAgICAgICAgICAgICAgfSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzNCAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSwgX191bnVzZWRfd2VicGFja19leHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgdmFyIElTX0RFTk8gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzNSk7CiAgICAgICAgICAgICAgICB2YXIgSVNfTk9ERSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTM2KTsKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gIUlTX0RFTk8gJiYgIUlTX05PREUgJiYgdHlwZW9mIHdpbmRvdyA9PSAnb2JqZWN0JyAmJiB0eXBlb2YgZG9jdW1lbnQgPT0gJ29iamVjdCc7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzNSAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gdHlwZW9mIERlbm8gPT0gJ29iamVjdCcgJiYgRGVubyAmJiB0eXBlb2YgRGVuby52ZXJzaW9uID09ICdvYmplY3QnOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzYgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBjbGFzc29mID0gX193X3BkZmpzX3JlcXVpcmVfXygxOCk7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cyA9IHR5cGVvZiBwcm9jZXNzICE9ICd1bmRlZmluZWQnICYmIGNsYXNzb2YocHJvY2VzcykgPT0gJ3Byb2Nlc3MnOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxMzcgKi8KICAgICAgICAgICAgLyoqKi8gKChtb2R1bGUsIF9fdW51c2VkX3dlYnBhY2tfZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgIHZhciBnbG9iYWwgP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V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9hbm5vdGF0aW9uX3N0b3JhZ2UgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzOSk7CiAgICAgICAgICAgICAgICB2YXIgX2Rpc3BsYXlfdXRpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0Mik7CiAgICAgICAgICAgICAgICB2YXIgX2ZvbnRfbG9hZGVyID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDUpOwogICAgICAgICAgICAgICAgdmFyIF9jYW52YXMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0Nik7CiAgICAgICAgICAgICAgICB2YXIgX3dvcmtlcl9vcHRpb25zID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDkpOwogICAgICAgICAgICAgICAgdmFyIF9pc19ub2RlID0gX193X3BkZmpzX3JlcXVpcmVfXygzKTsKICAgICAgICAgICAgICAgIHZhciBfbWVzc2FnZV9oYW5kbGVyID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTApOwogICAgICAgICAgICAgICAgdmFyIF9tZXRhZGF0YSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTUxKTsKICAgICAgICAgICAgICAgIHZhciBfb3B0aW9uYWxfY29udGVudF9jb25maWcgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1Mik7CiAgICAgICAgICAgICAgICB2YXIgX3RyYW5zcG9ydF9zdHJlYW0gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1Myk7CiAgICAgICAgICAgICAgICB2YXIgX3hmYV90ZXh0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTQpOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKG9iaiwgcHJpdmF0ZVNldCkgeyBfY2hlY2tQcml2YXRlUmVkZWNsYXJhdGlvbihvYmosIHByaXZhdGVTZXQpOyBwcml2YXRlU2V0LmFk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ZmF1bHRTdGFuZGFyZEZvbnREYXRhRmFjdG9yeTsKICAgICAgICAgICAgICAgIGlmIChfaXNfbm9kZS5pc05vZGVKUykgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgTm9kZUNhbnZhc0ZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgIE5vZGVDTWFwUmVhZGVyRmFjdG9yeSwKICAgICAgICAgICAgICAgICAgICAgICAgTm9kZUZpbHRlckZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgIE5vZGVTdGFuZGFyZEZvbnREYXRhRmFjdG9yeQogICAgICAgICAgICAgICAgICAgIH0gPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE1NSk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0Q2FudmFzRmFjdG9yeSA9IERlZmF1bHRDYW52YXNGYWN0b3J5ID0gTm9kZUNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0Q01hcFJlYWRlckZhY3RvcnkgPSBEZWZhdWx0Q01hcFJlYWRlckZhY3RvcnkgPSBOb2RlQ01hcFJlYWRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0RmlsdGVyRmFjdG9yeSA9IERlZmF1bHRGaWx0ZXJGYWN0b3J5ID0gTm9kZUZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgZXhwb3J0cy5EZWZhdWx0U3RhbmRhcmRGb250RGF0YUZhY3RvcnkgPSBEZWZhdWx0U3RhbmRhcmRGb250RGF0YUZhY3RvcnkgPSBOb2RlU3RhbmRhcmRGb250RGF0YUZhY3Rvcnk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBsZXQgY3JlYXRlUERGTmV0d29ya1N0cmVhbTsKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZiAoX2lzX25vZGUuaXNOb2RlSlMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUERGTm9kZVN0cmVhbQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTYpOwogICAgICAgICAgICAgICAgICAgICAgICBjcmVhdGVQREZOZXR3b3JrU3RyZWFtID0gcGFyYW1zID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUERGTm9kZVN0cmVhbShwYXJhbXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIFBERk5ldHdvcmtTdHJlYW0KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTU5KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUERGRmV0Y2hTdHJlYW0KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTYwKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUERGTmV0d29ya1N0cmVhbSA9IHBhcmFtcyA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF9kaXNwbGF5X3V0aWxzLmlzVmFsaWRGZXRjaFVybCkocGFyYW1zLnVybCkgPyBuZXcgUERGRmV0Y2hTdHJlYW0ocGFyYW1zKSA6IG5ldyBQREZOZXR3b3JrU3RyZWFtKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0RG9jdW1lbnQoc3JjKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBzcmMgPT09ICJzdHJpbmciIHx8IHNyYyBpbnN0YW5jZW9mIFVSTCkgewogICAgICAgICAgICAgICAgICAgICAgICBzcmMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cmw6IHNyYwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoKDAsIF91dGlsLmlzQXJyYXlCdWZmZXIpKHNyYykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3JjID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YTogc3JjCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygc3JjICE9PSAib2JqZWN0IikgewogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcGFyYW1ldGVyIGluIGdldERvY3VtZW50LCBuZWVkIHBhcmFtZXRlciBvYmplY3QuIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghc3JjLnVybCAmJiAhc3JjLmRhdGEgJiYgIXNyYy5yYW5nZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcGFyYW1ldGVyIG9iamVjdDogbmVlZCBlaXRoZXIgLmRhdGEsIC5yYW5nZSBvciAudXJsIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgUERGRG9jdW1lbnRMb2FkaW5nVGFzaygpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgZG9jSWQKICAgICAgICAgICAgICAgICAgICB9ID0gdGFzazsKICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBzcmMudXJsID8gZ2V0VXJsUHJvcChzcmMudXJsKSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHNyYy5kYXRhID8gZ2V0RGF0YVByb3Aoc3JjLmRhdGEpIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBodHRwSGVhZGVycyA9IHNyYy5odHRwSGVhZGVycyB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpdGhDcmVkZW50aWFscyA9IHNyYy53aXRoQ3JlZGVudGlhbHMgPT09IHRydWU7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFzc3dvcmQgPSBzcmMucGFzc3dvcmQgPz8gbnVsbDsKICAgICAgICAgICAgICAgICAgICBjb25zdCByYW5nZVRyYW5zcG9ydCA9IHNyYy5yYW5nZSBpbnN0YW5jZW9mIFBERkRhdGFSYW5nZVRyYW5zcG9ydCA/IHNyYy5yYW5nZSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFuZ2VDaHVua1NpemUgPSBOdW1iZXIuaXNJbnRlZ2VyKHNyYy5yYW5nZUNodW5rU2l6ZSkgJiYgc3JjLnJhbmdlQ2h1bmtTaXplID4gMCA/IHNyYy5yYW5nZUNodW5rU2l6ZSA6IERFRkFVTFRfUkFOR0VfQ0hVTktfU0laRTsKICAgICAgICAgICAgICAgICAgICBsZXQgd29ya2VyID0gc3JjLndvcmtlciBpbnN0YW5jZW9mIFBERldvcmtlciA/IHNyYy53b3JrZXIgOiBudWxsOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHZlcmJvc2l0eSA9IHNyYy52ZXJib3NpdHk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZG9jQmFzZVVybCA9IHR5cGVvZiBzcmMuZG9jQmFzZVVybCA9PT0gInN0cmluZyIgJiYgISgwLCBfZGlzcGxheV91dGlscy5pc0RhdGFTY2hlbWUpKHNyYy5kb2NCYXNlVXJsKSA/IHNyYy5kb2NCYXNlVXJsIDogbnVsbD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DYW52YXNTdXBwb3J0ZWQgPT09ICJib29sZWFuIiA/IHNyYy5pc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCA6ICFfaXNfbm9kZS5pc05vZGVKUzsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXNNYXhBcmVhSW5CeXRlcyA9IE51bWJlci5pc0ludGVnZXIoc3JjLmNhbnZhc01heEFyZWFJbkJ5dGVzKSA/IHNyYy5jYW52YXNNYXhBcmVhSW5CeXRlcyA6IC0xOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGRpc2FibGVGb250RmFjZSA9IHR5cGVvZiBzcmMuZGlzYWJsZUZvbnRGYWNlID09PSAiYm9vbGVhbiIgPyBzcmMuZGlzYWJsZUZvbnRGYWNlIDogX2lzX25vZGUuaXNOb2RlSlM7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udEV4dHJhUHJvcGVydGllcyA9IHNyYy5mb250RXh0cmFQcm9wZXJ0aWVzID09PSB0cnVlOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGVuYWJsZVhmYSA9IHNyYy5lbmFibGVYZmEgPT09IHRydWU7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3duZXJEb2N1bWVudCA9IHNyYy5vd25lckRvY3VtZW50IHx8IGdsb2JhbFRoaXMuZG9jdW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZGlzYWJsZVJhbmdlID0gc3JjLmRpc2FibGVSYW5nZSA9PT0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXNhYmxlU3RyZWFtID0gc3JjLmRpc2FibGVTdHJlYW0gPT09IHRydWU7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZGlzYWJsZUF1dG9GZXRjaCA9IHNyYy5kaXNhYmxlQXV0b0ZldGNoID09PSB0cnVlOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBkZkJ1ZyA9IHNyYy5wZGZCdWcgPT09IHRydWU7CiAgICAgICAgICA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VmYXVsdEZpbHRlckZhY3RvcnkoewogICAgICAgICAgICAgICAgICAgICAgICBkb2NJZCwKICAgICAgICAgICAgICAgICAgICAgICAgb3duZXJEb2N1bWVudAogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0eWxlRWxlbWVudCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnNldFZlcmJvc2l0eUxldmVsKSh2ZXJib3NpdHkpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydEZhY3RvcnkgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc0ZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlckZhY3RvcnkKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGlmICghdXNlV29ya2VyRmV0Y2gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNwb3J0RmFjdG9yeS5jTWFwUmVhZGVyRmFjdG9yeSA9IG5ldyBDTWFwUmVhZGVyRmFjdG9yeSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYXNlVXJsOiBjTWFwVXJsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNDb21wcmVzc2VkOiBjTWFwUGFja2VkCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0cmFuc3BvcnRGYWN0b3J5LnN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gbmV3IFN0YW5kYXJkRm9udERhdGFGYWN0b3J5KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VVcmw6IHN0YW5kYXJkRm9udERhdGFVcmwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghd29ya2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdvcmtlclBhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZlcmJvc2l0eSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvcnQ6IF93b3JrZXJfb3B0aW9ucy5HbG9iYWxXb3JrZXJPcHRpb25zLndvcmtlclBvcnQKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgd29ya2VyID0gd29ya2VyUGFyYW1zLnBvcnQgPyBQREZXb3JrZXIuZnJvbVBvcnQod29ya2VyUGFyYW1zKSA6IG5ldyBQREZXb3JrZXIod29ya2VyUGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGFzay5fd29ya2VyID0gd29ya2VyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBmZXRjaERvY1BhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgZG9jSWQsCiAgICAgICAgICAgICAgICAgICAgICAgIGFwaVZlcnNpb246ICczLjUuMTIyJywKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgcGFzc3dvcmQsCiAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVBdXRvRmV0Y2gsCiAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlQ2h1bmtTaXplLAogICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgIGRvY0Jhc2VVcmwsCiAgICAgICAgICAgICAgICAgICAgICAgIGVuYWJsZVhmYSwKICAgICAgICAgICAgICAgICAgICAgICAgZXZhbHVhdG9yT3B0aW9uczogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4SW1hZ2VTaXplLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUZvbnRGYWNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlRXJyb3JzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNFdmFsU3VwcG9ydGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNNYXhBcmVhSW5CeXRlcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvbnRFeHRyYVByb3BlcnRpZXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VTeXN0ZW1Gb250cywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNNYXBVcmw6IHVzZVdvcmtlckZldGNoID8gY01hcFVybCA6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFuZGFyZEZvbnREYXRhVXJsOiB1c2VXb3JrZXJGZXRjaCA/IHN0YW5kYXJkRm9udERhdGFVcmwgOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydFBhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlRXJyb3JzLAogICAgICAgICAgICAgICAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVGb250RmFjZSwKICAgICAgICAgICAgICAgICAgICAgICAgZm9udEV4dHJhUHJvcGVydGllcywKICAgICAgICAgICAgICAgICAgICAgICAgZW5hYmxlWGZhLAogICAgICAgICAgICAgICAgICAgICAgICBvd25lckRvY3VtZW50LAogICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlQXV0b0ZldGNoLAogICAgICAgICAgICAgICAgICAgICAgICBwZGZCdWcsCiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlRWxlbWVudAogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgd29ya2VyLnByb21pc2UudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0YXNrLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJMb2FkaW5nIGFib3J0ZWQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3b3JrZXJJZFByb21pc2UgPSBfZmV0Y2hEb2N1bWVudCh3b3JrZXIsIGZldGNoRG9jUGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbmV0d29ya1N0cmVhbVByb21pc2UgPSBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG5ldHdvcmtTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmFuZ2VUcmFuc3BvcnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXR3b3JrU3RyZWFtID0gbmV3IF90cmFuc3BvcnRfc3RyZWFtLlBERkRhdGFUcmFuc3BvcnRTdHJlYW0oewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluaXRpYWxEYXRhOiByYW5nZVRyYW5zcG9ydC5pbml0aWFsRGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvZ3Jlc3NpdmVEb25lOiByYW5nZVRyYW5zcG9ydC5wcm9ncmVzc2l2ZURvbmUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lOiByYW5nZVRyYW5zcG9ydC5jb250ZW50RGlzcG9zaXRpb25GaWxlbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZVJhbmdlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlU3RyZWFtCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgcmFuZ2VUcmFuc3BvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICghZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldHdvcmtTdHJlYW0gPSBjcmVhdGVQREZOZXR3b3JrU3RyZWFtKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXJsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGh0dHBIZWFkZXJzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aXRoQ3JlZGVudGlhbHMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlQ2h1bmtTaXplLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlUmFuZ2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVTdHJlYW0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUobmV0d29ya1N0cmVhbSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5hbGwoW3dvcmtlcklkUHJvbWlzZSwgbmV0d29ya1N0cmVhbVByb21pc2VdKS50aGVuKGZ1bmN0aW9uIChfcmVmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgW3dvcmtlcklkLCBuZXR3b3JrU3RyZWFtXSA9IF9yZWY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGFzay5kZXN0cm95ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkxvYWRpbmcgYWJvcnRlZCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWVzc2FnZUhhbmRsZXIgPSBuZXcgX21lc3NhZ2VfaGFuZGxlci5NZXNzYWdlSGFuZGxlcihkb2NJZCwgd29ya2VySWQsIHdvcmtlci5wb3J0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcG9ydCA9IG5ldyBXb3JrZXJUcmFuc3BvcnQobWVzc2FnZUhhbmRsZXIsIHRhc2ssIG5ldHdvcmtTdHJlYW0sIHRyYW5zcG9ydFBhcmFtcywgdHJhbnNwb3J0RmFjdG9yeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXNrLl90cmFuc3BvcnQgPSB0cmFuc3BvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlSGFuZGxlci5zZW5kKCJSZWFkeSIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9KS5jYXRjaCh0YXNrLl9jYXBhYmlsaXR5LnJlamVjdCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRhc2s7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBhc3luYyBmdW5jdGlvbiBfZmV0Y2hEb2N1bWVudCh3b3JrZXIsIHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgIGlmICh3b3JrZXIuZGVzdHJveWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiV29ya2VyIHdhcyBkZXN0cm95ZWQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgd29ya2VySWQgPSBhd2FpdCB3b3JrZXIubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXREb2NSZXF1ZXN0Iiwgc291cmNlLCBzb3VyY2UuZGF0YSA/IFtzb3VyY2UuZGF0YS5idWZmZXJdIDogbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHdvcmtlci5kZXN0cm95ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJXb3JrZXIgd2FzIGRlc3Ryb3llZCIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VySWQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRVcmxQcm9wKHZhbCkgewogICAgICAgICAgICAgICAgICAgIGlmICh2YWwgaW5zdGFuY2VvZiBVUkwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbC5ocmVmOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFVSTCh2YWwsIHdpbmRvdy5sb2NhdGlvbikuaHJlZjsKICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2lzX25vZGUuaXNOb2RlSlMgJiYgdHlwZW9mIHZhbCA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJJbnZhbGlkIFBERiB1cmwgZGF0YTogIiArICJlaXRoZXIgc3RyaW5nIG9yIFVSTC1vYmplY3QgaXMgZXhwZWN0ZWQgaW4gdGhlIHVybCBwcm9wZXJ0eS4iKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldERhdGFQcm9wKHZhbCkgewogICAgICAgICAgICAgICAgICAgIGlmIChfaXNfbm9kZS5pc05vZGVKUyAmJiB0eXBlb2YgQnVmZmVyICE9PSAidW5kZWZpbmVkIiAmJiB2YWwgaW5zdGFuY2VvZiBCdWZmZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF9kaXNwbGF5X3V0aWxzLmRlcHJlY2F0ZWQpKCJQbGVhc2UgcHJvdmlkZSBiaW5hcnkgZGF0YSBhcyBgVWludDhBcnJheWAsIHJhdGhlciB0aGFuIGBCdWZmZXJgLiIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFVpbnQ4QXJyYXkodmFsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHZhbCBpbnN0YW5jZW9mIFVpbnQ4QXJyYXkgJiYgdmFsLmJ5dGVMZW5ndGggPT09IHZhbC5idWZmZXIuYnl0ZUxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbCA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zdHJpbmdUb0J5dGVzKSh2YWwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbCA9PT0gIm9iamVjdCIgJiYgIWlzTmFOKHZhbCA9PT0gbnVsbCB8fCB2YWwgPT09IHZvaWQgMCA/IHZvaWQgMCA6IHZhbC5sZW5ndGgpIHx8ICgwLCBfdXRpbC5pc0FycmF5QnVmZmVyKSh2YWwpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgVWludDhBcnJheSh2YWwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgUERGIGJpbmFyeSBkYXRhOiBlaXRoZXIgVHlwZWRBcnJheSwgIiArICJzdHJpbmcsIG9yIGFycmF5LWxpa2Ugb2JqZWN0IGlzIGV4cGVjdGVkIGluIHRoZSBkYXRhIHByb3BlcnR5LiIpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUERGRG9jdW1lbnRMb2FkaW5nVGFzayB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljICNkb2NJZCA9IDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RyYW5zcG9ydCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3dvcmtlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZG9jSWQgPSBgZCR7UERGRG9jdW1lbnRMb2FkaW5nVGFzay4jZG9jSWQrK31gOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3Ryb3llZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUGFzc3dvcmQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJvbWlzZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2NhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgZGVzdHJveSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF90cmFuc3BvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdHJveWVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgKChfdGhpcyRfdHJhbnNwb3J0ID0gdGhpcy5fdHJhbnNwb3J0KSA9PT0gbnVsbCB8fCBfdGhpcyRfdHJhbnNwb3J0ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfdHJhbnNwb3J0LmRlc3Ryb3koKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RyYW5zcG9ydCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl93b3JrZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3dvcmtlci5kZXN0cm95KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl93b3JrZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZEb2N1bWVudExvYWRpbmdUYXNrID0gUERGRG9jdW1lbnRMb2FkaW5nVGFzazsKICAgICAgICAgICAgICAgIGNsYXNzIFBERkRhdGFSYW5nZVRyYW5zcG9ydCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobGVuZ3RoLCBpbml0aWFsRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcHJvZ3Jlc3NpdmVEb25lID0gYXJndW1lbnRzLmxlbmd0aCA+IDIgJiYgYXJndW1lbnRzWzJdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMl0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lID0gYXJndW1lbnRzLmxlbmd0aCA+IDMgJiYgYXJndW1lbnRzWzNdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbM10gOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxlbmd0aCA9IGxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pbml0aWFsRGF0YSA9IGluaXRpYWxEYXRhOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnByb2dyZXNzaXZlRG9uZSA9IHByb2dyZXNzaXZlRG9uZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250ZW50RGlzcG9zaXRpb25GaWxlbmFtZSA9IGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZUxpc3RlbmVycyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wcm9ncmVzc0xpc3RlbmVycyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wcm9ncmVzc2l2ZVJlYWRMaXN0ZW5lcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcHJvZ3Jlc3NpdmVEb25lTGlzdGVuZXJzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWR5Q2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkUmFuZ2VMaXN0ZW5lcihsaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZUxpc3RlbmVycy5wdXNoKGxpc3RlbmVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkUHJvZ3Jlc3NMaXN0ZW5lcihsaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wcm9ncmVzc0xpc3RlbmVycy5wdXNoKGxpc3RlbmVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkUHJvZ3Jlc3NpdmVSZWFkTGlzdGVuZXIobGlzdGVuZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcHJvZ3Jlc3NpdmVSZWFkTGlzdGVuZXJzLnB1c2gobGlzdGVuZXIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRQcm9ncmVzc2l2ZURvbmVMaXN0ZW5lcihsaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wcm9ncmVzc2l2ZURvbmVMaXN0ZW5lcnMucHVzaChsaXN0ZW5lcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uRGF0YVJhbmdlKGJlZ2luLCBjaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpc3RlbmVyIG9mIHRoaXMuX3JhbmdlTGlzdGVuZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaXN0ZW5lcihiZWdpbiwgY2h1bmspOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uRGF0YVByb2dyZXNzKGxvYWRlZCwgdG90YWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnByb21pc2UudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpc3RlbmVyIG9mIHRoaXMuX3Byb2dyZXNzTGlzdGVuZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlzdGVuZXIobG9hZGVkLCB0b3RhbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBvbkRhdGFQcm9ncmVzc2l2ZVJlYWQoY2h1bmspIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnByb21pc2UudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpc3RlbmVyIG9mIHRoaXMuX3Byb2dyZXNzaXZlUmVhZExpc3RlbmVycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpc3RlbmVyKGNodW5rKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uRGF0YVByb2dyZXNzaXZlRG9uZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnByb21pc2UudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpc3RlbmVyIG9mIHRoaXMuX3Byb2dyZXNzaXZlRG9uZUxpc3RlbmVycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpc3RlbmVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0cmFuc3BvcnRSZWFkeSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVxdWVzdERhdGFSYW5nZShiZWdpbiwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkFic3RyYWN0IG1ldGhvZCBQREZEYXRhUmFuZ2VUcmFuc3BvcnQucmVxdWVzdERhdGFSYW5nZSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhYm9ydCgpIHt9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkRhdGFSYW5nZVRyYW5zcG9ydCA9IFBERkRhdGFSYW5nZVRyYW5zcG9ydDsKICAgICAgICAgICAgICAgIGNsYXNzIFBERkRvY3VtZW50UHJveHkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBkZkluZm8sIHRyYW5zcG9ydCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZJbmZvID0gcGRmSW5mbzsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdHJhbnNwb3J0ID0gdHJhbnNwb3J0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgYW5ub3RhdGlvblN0b3JhZ2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuYW5ub3RhdGlvblN0b3JhZ2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBmaWx0ZXJGYWN0b3J5KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBudW1QYWdlcygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3BkZkluZm8ubnVtUGFnZXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBmaW5nZXJwcmludHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9wZGZJbmZvLmZpbmdlcnByaW50czsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGlzUHVyZVhmYSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJpc1B1cmVYZmEiLCAhIXRoaXMuX3RyYW5zcG9ydC5faHRtbEZvclhmYSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBhbGxYZmFIdG1sKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0Ll9odG1sRm9yWGZhOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYWdlKHBhZ2VOdW1iZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5nZXRQYWdlKHBhZ2VOdW1iZXIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYWdlSW5kZXgocmVmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0UGFnZUluZGV4KHJlZik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERlc3RpbmF0aW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5nZXREZXN0aW5hdGlvbnMoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RGVzdGluYXRpb24oaWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5nZXREZXN0aW5hdGlvbihpZCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhZ2VMYWJlbHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0UGFnZUxhYmVscygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYWdlTGF5b3V0KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldFBhZ2VMYXlvdXQoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGFnZU1vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0UGFnZU1vZGUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0Vmlld2VyUHJlZmVyZW5jZXMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0Vmlld2VyUHJlZmVyZW5jZXMoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0T3BlbkFjdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5nZXRPcGVuQWN0aW9uKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEF0dGFjaG1lbnRzKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldEF0dGFjaG1lbnRzKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEphdmFTY3JpcHQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0SmF2YVNjcmlwdCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRKU0FjdGlvbnMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0RG9jSlNBY3Rpb25zKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE91dGxpbmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0T3V0bGluZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRPcHRpb25hbENvbnRlbnRDb25maWcoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0T3B0aW9uYWxDb250ZW50Q29uZmlnKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBlcm1pc3Npb25zKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldFBlcm1pc3Npb25zKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE1ldGFkYXRhKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldE1ldGFkYXRhKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE1hcmtJbmZvKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldE1hcmtJbmZvKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERhdGEoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0RGF0YSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzYXZlRG9jdW1lbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuc2F2ZURvY3VtZW50KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERvd25sb2FkSW5mbygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5kb3dubG9hZEluZm9DYXBhYmlsaXR5LnByb21pc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsZWFudXAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrZWVwTG9hZGVkRm9udHMgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LnN0YXJ0Q2xlYW51cChrZWVwTG9hZGVkRm9udHMgfHwgdGhpcy5pc1B1cmVYZmEpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5sb2FkaW5nVGFzay5kZXN0cm95KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBsb2FkaW5nUGFyYW1zKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmxvYWRpbmdQYXJhbXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBsb2FkaW5nVGFzaygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3RyYW5zcG9ydC5sb2FkaW5nVGFzazsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RmllbGRPYmplY3RzKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldEZpZWxkT2JqZWN0cygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXNKU0FjdGlvbnMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuaGFzSlNBY3Rpb25zKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldENhbGN1bGF0aW9uT3JkZXJJZHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0Q2FsY3VsYXRpb25PcmRlcklkcygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuUERGRG9jdW1lbnRQcm94eSA9IFBERkRvY3VtZW50UHJveHk7CiAgICAgICAgICAgICAgICB2YXIgX2RlbGF5ZWRDbGVhbnVwVGltZW91dCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9wZW5kaW5nQ2xlYW51cCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF90cnlDbGVhbnVwID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2Fib3J0RGVsYXllZENsZWFudXAgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIFBERlBhZ2VQcm94eSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFnZUluZGV4LCBwYWdlSW5mbywgdHJhbnNwb3J0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwZGZCdWcgPSBhcmd1bWVudHMubGVuZ3RoID4gMyAmJiBhcmd1bWVudHNbM10gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1szXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2Fib3J0RGVsYXllZENsZWFudXApOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3RyeUNsZWFudXApOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZGVsYXllZENsZWFudXBUaW1lb3V0LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcGVuZGluZ0NsZWFudXAsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYWdlSW5kZXggPSBwYWdlSW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3BhZ2VJbmZvID0gcGFnZUluZm87CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RyYW5zcG9ydCA9IHRyYW5zcG9ydDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RhdHMgPSBwZGZCdWcgPyBuZXcgX2Rpc3BsYXlfdXRpbHMuU3RhdFRpbWVyKCkgOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZCdWcgPSBwZGZCdWc7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbW9uT2JqcyA9IHRyYW5zcG9ydC5jb21tb25PYmpzOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9ianMgPSBuZXcgUERGT2JqZWN0cygpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tYXliZUNsZWFudXBBZnRlclJlbmRlciA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pbnRlbnRTdGF0ZXMgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdHJveWVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwYWdlTnVtYmVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcGFnZUluZGV4ICsgMTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHJvdGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3BhZ2VJbmZvLnJvdGF0ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHJlZigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3BhZ2VJbmZvLnJlZjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHVzZXJVbml0KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcGFnZUluZm8udXNlclVuaXQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCB2aWV3KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcGFnZUluZm8udmlldzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0Vmlld3BvcnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uID0gdGhpcy5yb3RhdGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRYID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFkgPSAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9udEZsaXAgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBfZGlzcGxheV91dGlscy5QYWdlVmlld3BvcnQoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld0JveDogdGhpcy52aWV3LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9udEZsaXAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFubm90YXRpb25zKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50ID0gImRpc3BsYXkiCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IHt9OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnRlbnRBcmdzID0gdGhpcy5fdHJhbnNwb3J0LmdldFJlbmRlcmluZ0ludGVudChpbnRlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldEFubm90YXRpb25zKHRoaXMuX3BhZ2VJbmRleCwgaW50ZW50QXJncy5yZW5kZXJpbmdJbnRlbnQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRKU0FjdGlvbnMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQuZ2V0UGFnZUpTQWN0aW9ucyh0aGlzLl9wYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNQdXJlWGZhKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgImlzUHVyZVhmYSIsICEhdGhpcy5fdHJhbnNwb3J0Ll9odG1sRm9yWGZhKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgZ2V0WGZhKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3RyYW5zcG9ydCRfaHRtOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKChfdGhpcyRfdHJhbnNwb3J0JF9odG0gPSB0aGlzLl90cmFuc3BvcnQuX2h0bWxGb3JYZmEpID09PSBudWxsIHx8IF90aGlzJF90cmFuc3BvcnQkX2h0bSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX3RyYW5zcG9ydCRfaHRtLmNoaWxkcmVuW3RoaXMuX3BhZ2VJbmRleF0pIHx8IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcihfcmVmMikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3N0YXRzOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzQ29udGV4dCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50ID0gImRpc3BsYXkiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvbk1vZGUgPSBfdXRpbC5Bbm5vdGF0aW9uTW9kZS5FTkFCTEUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0gPSBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzRmFjdG9yeSA9IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWNrZ3JvdW5kID0gbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbmFsQ29udGVudENvbmZpZ1Byb21pc2UgPSBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvbkNhbnZhc01hcCA9IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlQ29sb3JzID0gbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50QW5ub3RhdGlvblN0b3JhZ2UgPSBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNhbnZhc0ZhY3RvcnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfZGlzcGxheV91dGlscy5kZXByZWNhdGVkKSgicmVuZGVyIG5vIGxvbmdlciBhY2NlcHRzIHRoZSBgY2FudmFzRmFjdG9yeWAtb3B0aW9uLCAiICsgInBsZWFzZSBwYXNzIGl0IHRvIHRoZSBgZ2V0RG9jdW1lbnRgLWZ1bmN0aW9uIGluc3RlYWQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9zdGF0cyA9IHRoaXMuX3N0YXRzKSA9PT0gbnVsbCB8fCBfdGhpcyRfc3RhdHMgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9zdGF0cy50aW1lKCJPdmVyYWxsIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGludGVudEFyZ3MgPSB0aGlzLl90cmFuc3BvcnQuZ2V0UmVuZGVyaW5nSW50ZW50KGludGVudCwgYW5ub3RhdGlvbk1vZGUsIHByaW50QW5ub3RhdGlvblN0b3JhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3BlbmRpbmdDbGVhbnVwLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Fib3J0RGVsYXllZENsZWFudXAsIF9hYm9ydERlbGF5ZWRDbGVhbnVwMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFvcHRpb25hbENvbnRlbnRDb25maWdQcm9taXNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25hbENvbnRlbnRDb25maWdQcm9taXNlID0gdGhpcy5fdHJhbnNwb3J0LmdldE9wdGlvbmFsQ29udGVudENvbmZpZygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpbnRlbnRTdGF0ZSA9IHRoaXMuX2ludGVudFN0YXRlcy5nZXQoaW50ZW50QXJncy5jYWNoZUtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW50ZW50U3RhdGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ludGVudFN0YXRlcy5zZXQoaW50ZW50QXJncy5jYWNoZUtleSwgaW50ZW50U3RhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlbnRTdGF0ZS5zdHJlYW1SZWFkZXJDYW5jZWxUaW1lb3V0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhclRpbWVvdXQoaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyQ2FuY2VsVGltZW91dCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5zdHJlYW1SZWFkZXJDYW5jZWxUaW1lb3V0ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnRlbnRQcmludCA9ICEhKGludGVudEFyZ3MucmVuZGVyaW5nSW50ZW50ICYgX3V0aWwuUmVuZGVyaW5nSW50ZW50RmxhZy5QUklOVCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW50ZW50U3RhdGUuZGlzcGxheVJlYWR5Q2FwYWJpbGl0eSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9zdGF0czI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5kaXNwbGF5UmVhZHlDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUub3BlcmF0b3JMaXN0ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZuQXJyYXk6IFtdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFyZ3NBcnJheTogW10sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGFzdENodW5rOiBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXBhcmF0ZUFubm90czogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfc3RhdHMyID0gdGhpcy5fc3RhdHMpID09PSBudWxsIHx8IF90aGlzJF9zdGF0czIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9zdGF0czIudGltZSgiUGFnZSBSZXF1ZXN0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wdW1wT3BlcmF0b3JMaXN0KGludGVudEFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbXBsZXRlID0gZXJyb3IgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9zdGF0czMsIF90aGlzJF9zdGF0czQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5yZW5kZXJUYXNrcy5kZWxldGUoaW50ZXJuYWxSZW5kZXJUYXNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9tYXliZUNsZWFudXBBZnRlclJlbmRlciB8fCBpbnRlbnRQcmludCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfcGVuZGluZ0NsZWFudXAsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdHJ5Q2xlYW51cCwgX3RyeUNsZWFudXAyKS5jYWxsKHRoaXMsICFpbnRlbnRQcmludCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcm5hbFJlbmRlclRhc2suY2FwYWJpbGl0eS5yZWplY3QoZXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Fib3J0T3BlcmF0b3JMaXN0KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbjogZXJyb3IgaW5zdGFuY2VvZiBFcnJvciA/IGVycm9yIDogbmV3IEVycm9yKGVycm9yKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcm5hbFJlbmRlclRhc2suY2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX3N0YXRzMyA9IHRoaXMuX3N0YXRzKSA9PT0gbnVsbCB8fCBfdGhpcyRfc3RhdHMzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfc3RhdHMzLnRpbWVFbmQoIlJlbmRlcmluZyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9zdGF0czQgPSB0aGlzLl9zdGF0cykgPT09IG51bGwgfHwgX3RoaXMkX3N0YXRzNCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX3N0YXRzNC50aW1lRW5kKCJPdmVyYWxsIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGludGVybmFsUmVuZGVyVGFzayA9IG5ldyBJbnRlcm5hbFJlbmRlclRhc2soewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2s6IGNvbXBsZXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zOiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzQ29udGV4dCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFja2dyb3VuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9ianM6IHRoaXMub2JqcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1vbk9ianM6IHRoaXMuY29tbW9uT2JqcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25DYW52YXNNYXAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcGVyYXRvckxpc3Q6IGludGVudFN0YXRlLm9wZXJhdG9yTGlzdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJbmRleDogdGhpcy5fcGFnZUluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzRmFjdG9yeTogY2FudmFzRmFjdG9yeSB8fCB0aGlzLl90cmFuc3BvcnQuY2FudmFzRmFjdG9yeSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlckZhY3Rvcnk6IHRoaXMuX3RyYW5zcG9ydC5maWx0ZXJGYWN0b3J5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdXNlUmVxdWVzdEFuaW1hdGlvbkZyYW1lOiAhaW50ZW50UHJpbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZGZCdWc6IHRoaXMuX3BkZkJ1ZywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VDb2xvcnMKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIChpbnRlbnRTdGF0ZS5yZW5kZXJUYXNrcyB8fD0gbmV3IFNldCgpKS5hZGQoaW50ZXJuYWxSZW5kZXJUYXNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVuZGVyVGFzayA9IGludGVybmFsUmVuZGVyVGFzay50YXNrOwogICAgICAgICAgICAgICAgICAgICAgICBQcm9taXNlLmFsbChbaW50ZW50U3RhdGUuZGlzcGxheVJlYWR5Q2FwYWJpbGl0eS5wcm9taXNlLCBvcHRpb25hbENvbnRlbnRDb25maWdQcm9taXNlXSkudGhlbihfcmVmMyA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3N0YXRzNTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBbdHJhbnNwYXJlbmN5LCBvcHRpb25hbENvbnRlbnRDb25maWddID0gX3JlZjM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wZW5kaW5nQ2xlYW51cCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wbGV0ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfc3RhdHM1ID0gdGhpcy5fc3RhdHMpID09PSBudWxsIHx8IF90aGlzJF9zdGF0czUgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9zdGF0czUudGltZSgiUmVuZGVyaW5nIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcm5hbFJlbmRlclRhc2suaW5pdGlhbGl6ZUdyYXBoaWNzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc3BhcmVuY3ksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uYWxDb250ZW50Q29uZmlnCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVybmFsUmVuZGVyVGFzay5vcGVyYXRvckxpc3RDaGFuZ2VkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pLmNhdGNoKGNvbXBsZXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlbmRlclRhc2s7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE9wZXJhdG9yTGlzdCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudCA9ICJkaXNwbGF5IiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25Nb2RlID0gX3V0aWwuQW5ub3RhdGlvbk1vZGUuRU5BQkxFLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJpbnRBbm5vdGF0aW9uU3RvcmFnZSA9IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG9wZXJhdG9yTGlzdENoYW5nZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW50ZW50U3RhdGUub3BlcmF0b3JMaXN0Lmxhc3RDaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLm9wTGlzdFJlYWRDYXBhYmlsaXR5LnJlc29sdmUoaW50ZW50U3RhdGUub3BlcmF0b3JMaXN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5yZW5kZXJUYXNrcy5kZWxldGUob3BMaXN0VGFzayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW50ZW50QXJncyA9IHRoaXMuX3RyYW5zcG9ydC5nZXRSZW5kZXJpbmdJbnRlbnQoaW50ZW50LCBhbm5vdGF0aW9uTW9kZSwgcHJpbnRBbm5vdGF0aW9uU3RvcmFnZSwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpbnRlbnRTdGF0ZSA9IHRoaXMuX2ludGVudFN0YXRlcy5nZXQoaW50ZW50QXJncy5jYWNoZUtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW50ZW50U3RhdGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ludGVudFN0YXRlcy5zZXQoaW50ZW50QXJncy5jYWNoZUtleSwgaW50ZW50U3RhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBvcExpc3RUYXNrOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWludGVudFN0YXRlLm9wTGlzdFJlYWRDYXBhYmlsaXR5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3N0YXRzNjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wTGlzdFRhc2sgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3BMaXN0VGFzay5vcGVyYXRvckxpc3RDaGFuZ2VkID0gb3BlcmF0b3JMaXN0Q2hhbmdlZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLm9wTGlzdFJlYWRDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKGludGVudFN0YXRlLnJlbmRlclRhc2tzIHx8PSBuZXcgU2V0KCkpLmFkZChvcExpc3RUYXNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLm9wZXJhdG9yTGlzdCA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbkFycmF5OiBbXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmdzQXJyYXk6IFtdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxhc3RDaHVuazogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VwYXJhdGVBbm5vdHM6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX3N0YXRzNiA9IHRoaXMuX3N0YXRzKSA9PT0gbnVsbCB8fCBfdGhpcyRfc3RhdHM2ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfc3RhdHM2LnRpbWUoIlBhZ2UgUmVxdWVzdCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcHVtcE9wZXJhdG9yTGlzdChpbnRlbnRBcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaW50ZW50U3RhdGUub3BMaXN0UmVhZENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RyZWFtVGV4dENvbnRlbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlQ29tYmluZVRleHRJdGVtcyA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5jbHVkZU1hcmtlZENvbnRlbnQgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgVEVYVF9DT05URU5UX0NIVU5LX1NJWkUgPSAxMDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl90cmFuc3BvcnQubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhTdHJlYW0oIkdldFRleHRDb250ZW50IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZGV4OiB0aGlzLl9wYWdlSW5kZXgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21iaW5lVGV4dEl0ZW1zOiBkaXNhYmxlQ29tYmluZVRleHRJdGVtcyAhPT0gdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluY2x1ZGVNYXJrZWRDb250ZW50OiBpbmNsdWRlTWFya2VkQ29udGVudCA9PT0gdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaWdoV2F0ZXJNYXJrOiBURVhUX0NPTlRFTlRfQ0hVTktfU0laRSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemUodGV4dENvbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGV4dENvbnRlbnQuaXRlbXMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0VGV4dENvbnRlbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwYXJhbXMgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IHt9OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fdHJhbnNwb3J0Ll9odG1sRm9yWGZhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5nZXRYZmEoKS50aGVuKHhmYSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF94ZmFfdGV4dC5YZmFUZXh0LnRleHRDb250ZW50KHhmYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWFkYWJsZVN0cmVhbSA9IHRoaXMuc3RyZWFtVGV4dENvbnRlbnQocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlLCByZWplY3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHB1bXAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZGVyLnJlYWQoKS50aGVuKGZ1bmN0aW9uIChfcmVmNCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmNDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUodGV4dENvbnRlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5hc3NpZ24odGV4dENvbnRlbnQuc3R5bGVzLCB2YWx1ZS5zdHlsZXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0Q29udGVudC5pdGVtcy5wdXNoKC4uLnZhbHVlLml0ZW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHVtcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIHJlamVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWFkZXIgPSByZWFkYWJsZVN0cmVhbS5nZXRSZWFkZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRleHRDb250ZW50ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zOiBbXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZXM6IE9iamVjdC5jcmVhdGUobnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdW1wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRTdHJ1Y3RUcmVlKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdHJhbnNwb3J0LmdldFN0cnVjdFRyZWUodGhpcy5fcGFnZUluZGV4KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2Rlc3Ryb3koKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdHJveWVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2FpdE9uID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW50ZW50U3RhdGUgb2YgdGhpcy5faW50ZW50U3RhdGVzLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9hYm9ydE9wZXJhdG9yTGlzdCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uOiBuZXcgRXJyb3IoIlBhZ2Ugd2FzIGRlc3Ryb3llZC4iKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JjZTogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW50ZW50U3RhdGUub3BMaXN0UmVhZENhcGFiaWxpdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW50ZXJuYWxSZW5kZXJUYXNrIG9mIGludGVudFN0YXRlLnJlbmRlclRhc2tzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2FpdE9uLnB1c2goaW50ZXJuYWxSZW5kZXJUYXNrLmNvbXBsZXRlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZXJuYWxSZW5kZXJUYXNrLmNhbmNlbCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub2Jqcy5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3BlbmRpbmdDbGVhbnVwLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Fib3J0RGVsYXllZENsZWFudXAsIF9hYm9ydERlbGF5ZWRDbGVhbnVwMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFByb21pc2UuYWxsKHdhaXRPbik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsZWFudXAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZXNldFN0YXRzID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9wZW5kaW5nQ2xlYW51cCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN1Y2Nlc3MgPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF90cnlDbGVhbnVwLCBfdHJ5Q2xlYW51cDIpLmNhbGwodGhpcywgZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVzZXRTdGF0cyAmJiBzdWNjZXNzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdGF0cyAmJj0gbmV3IF9kaXNwbGF5X3V0aWxzLlN0YXRUaW1lcigpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzdWNjZXNzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfc3RhcnRSZW5kZXJQYWdlKHRyYW5zcGFyZW5jeSwgY2FjaGVLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9zdGF0czcsIF9pbnRlbnRTdGF0ZSRkaXNwbGF5UjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW50ZW50U3RhdGUgPSB0aGlzLl9pbnRlbnRTdGF0ZXMuZ2V0KGNhY2hlS2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpbnRlbnRTdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfc3RhdHM3ID0gdGhpcy5fc3RhdHMpID09PSBudWxsIHx8IF90aGlzJF9zdGF0czcgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9zdGF0czcudGltZUVuZCgiUGFnZSBSZXF1ZXN0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIChfaW50ZW50U3RhdGUkZGlzcGxheVIgPSBpbnRlbnRTdGF0ZS5kaXNwbGF5UmVhZHlDYXBhYmlsaXR5KSA9PT0gbnVsbCB8fCBfaW50ZW50U3RhdGUkZGlzcGxheVIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9pbnRlbnRTdGF0ZSRkaXNwbGF5Ui5yZXNvbHZlKHRyYW5zcGFyZW5jeSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9yZW5kZXJQYWdlQ2h1bmsob3BlcmF0b3JMaXN0Q2h1bmssIGludGVudFN0YXRlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IG9wZXJhdG9yTGlzdENodW5rLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLm9wZXJhdG9yTGlzdC5mbkFycmF5LnB1c2gob3BlcmF0b3JMaXN0Q2h1bmsuZm5BcnJheVtpXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5vcGVyYXRvckxpc3QuYXJnc0FycmF5LnB1c2gob3BlcmF0b3JMaXN0Q2h1bmsuYXJnc0FycmF5W2ldKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5vcGVyYXRvckxpc3QubGFzdENodW5rID0gb3BlcmF0b3JMaXN0Q2h1bmsubGFzdENodW5rOwogICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5vcGVyYXRvckxpc3Quc2VwYXJhdGVBbm5vdHMgPSBvcGVyYXRvckxpc3RDaHVuay5zZXBhcmF0ZUFubm90czsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBpbnRlcm5hbFJlbmRlclRhc2sgb2YgaW50ZW50U3RhdGUucmVuZGVyVGFza3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVybmFsUmVuZGVyVGFzay5vcGVyYXRvckxpc3RDaGFuZ2VkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wZXJhdG9yTGlzdENodW5rLmxhc3RDaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdHJ5Q2xlYW51cCwgX3RyeUNsZWFudXAyKS5jYWxsKHRoaXMsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9wdW1wT3BlcmF0b3JMaXN0KF9yZWY1KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJpbmdJbnRlbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZUtleSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25TdG9yYWdlTWFwCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmNTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVhZGFibGVTdHJlYW0gPSB0aGlzLl90cmFuc3BvcnQubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhTdHJlYW0oIkdldE9wZXJhdG9yTGlzdCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJbmRleDogdGhpcy5fcGFnZUluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50OiByZW5kZXJpbmdJbnRlbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZUtleSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25TdG9yYWdlOiBhbm5vdGF0aW9uU3RvcmFnZU1hcAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVhZGVyID0gcmVhZGFibGVTdHJlYW0uZ2V0UmVhZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGludGVudFN0YXRlID0gdGhpcy5faW50ZW50U3RhdGVzLmdldChjYWNoZUtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLnN0cmVhbVJlYWRlciA9IHJlYWRlcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHVtcCA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRlci5yZWFkKCkudGhlbihfcmVmNiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fdHJhbnNwb3J0LmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlbmRlclBhZ2VDaHVuayh2YWx1ZSwgaW50ZW50U3RhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1bXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fdHJhbnNwb3J0LmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlbnRTdGF0ZS5vcGVyYXRvckxpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUub3BlcmF0b3JMaXN0Lmxhc3RDaHVuayA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW50ZXJuYWxSZW5kZXJUYXNrIG9mIGludGVudFN0YXRlLnJlbmRlclRhc2tzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlcm5hbFJlbmRlclRhc2sub3BlcmF0b3JMaXN0Q2hhbmdlZCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3RyeUNsZWFudXAsIF90cnlDbGVhbnVwMikuY2FsbCh0aGlzLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGludGVudFN0YXRlLmRpc3BsYXlSZWFkeUNhcGFiaWxpdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUuZGlzcGxheVJlYWR5Q2FwYWJpbGl0eS5yZWplY3QocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGludGVudFN0YXRlLm9wTGlzdFJlYWRDYXBhYmlsaXR5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLm9wTGlzdFJlYWRDYXBhYmlsaXR5LnJlamVjdChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IHJlYXNvbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgcHVtcCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfYWJvcnRPcGVyYXRvckxpc3QoX3JlZjcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yY2UgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjc7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGludGVudFN0YXRlLnN0cmVhbVJlYWRlckNhbmNlbFRpbWVvdXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsZWFyVGltZW91dChpbnRlbnRTdGF0ZS5zdHJlYW1SZWFkZXJDYW5jZWxUaW1lb3V0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLnN0cmVhbVJlYWRlckNhbmNlbFRpbWVvdXQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZm9yY2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlbnRTdGF0ZS5yZW5kZXJUYXNrcy5zaXplID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZWFzb24gaW5zdGFuY2VvZiBfZGlzcGxheV91dGlscy5SZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGVsYXkgPSBSRU5ERVJJTkdfQ0FOQ0VMTEVEX1RJTUVPVVQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlYXNvbi5leHRyYURlbGF5ID4gMCAmJiByZWFzb24uZXh0cmFEZWxheSA8IDEwMDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsYXkgKz0gcmVhc29uLmV4dHJhRGVsYXk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLnN0cmVhbVJlYWRlckNhbmNlbFRpbWVvdXQgPSBzZXRUaW1lb3V0KCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyQ2FuY2VsVGltZW91dCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Fib3J0T3BlcmF0b3JMaXN0KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudFN0YXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yY2U6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgZGVsYXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnRTdGF0ZS5zdHJlYW1SZWFkZXIuY2FuY2VsKG5ldyBfdXRpbC5BYm9ydEV4Y2VwdGlvbihyZWFzb24ubWVzc2FnZSkpLmNhdGNoKCgpID0+IHt9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50U3RhdGUuc3RyZWFtUmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3RyYW5zcG9ydC5kZXN0cm95ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IFtjdXJDYWNoZUtleSwgY3VySW50ZW50U3RhdGVdIG9mIHRoaXMuX2ludGVudFN0YXRlcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1ckludGVudFN0YXRlID09PSBpbnRlbnRTdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ludGVudFN0YXRlcy5kZWxldGUoY3VyQ2FjaGVLZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xlYW51cCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgc3RhdHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9zdGF0czsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERlBhZ2VQcm94eSA9IFBERlBhZ2VQcm94eTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF90cnlDbGVhbnVwMigpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgZGVsYXllZCA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfYWJvcnREZWxheWVkQ2xlYW51cCwgX2Fib3J0RGVsYXllZENsZWFudXAyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wZW5kaW5nQ2xlYW51cCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoZGVsYXllZCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2RlbGF5ZWRDbGVhbnVwVGltZW91dCwgc2V0VGltZW91dCgoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2RlbGF5ZWRDbGVhbnVwVGltZW91dCwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF90cnlDbGVhbnVwLCBfdHJ5Q2xlYW51cDIpLmNhbGwodGhpcywgZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICB9LCBERUxBWUVEX0NMRUFOVVBfVElNRU9VVCkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJUYXNrcywKICAgICAgICAgICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0CiAgICAgICAgICAgICAgICAgICAgfSBvZiB0aGlzLl9pbnRlbnRTdGF0ZXMudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlbmRlclRhc2tzLnNpemUgPiAwIHx8ICFvcGVyYXRvckxpc3QubGFzdENodW5rKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGhpcy5faW50ZW50U3RhdGVzLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5vYmpzLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9wZW5kaW5nQ2xlYW51cCwgZmFsc2UpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2Fib3J0RGVsYXllZENsZWFudXAyKCkgewogICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlbGF5ZWRDbGVhbnVwVGltZW91dCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2xlYXJUaW1lb3V0KF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVsYXllZENsZWFudXBUaW1lb3V0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZGVsYXllZENsZWFudXBUaW1lb3V0LCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBMb29wYmFja1BvcnQgewogICAgICAgICAgICAgICAgICAgICNsaXN0ZW5lcnMgPSBuZXcgU2V0KCk7CiAgICAgICAgICAgICAgICAgICAgI2RlZmVycmVkID0gUHJvbWlzZS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgcG9zdE1lc3NhZ2Uob2JqLCB0cmFuc2ZlcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBldmVudCA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGE6IHN0cnVjdHVyZWRDbG9uZShvYmosIHRyYW5zZmVyID8gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zZmVyCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IDogbnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jZGVmZXJyZWQudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpc3RlbmVyIG9mIHRoaXMuI2xpc3RlbmVycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpc3RlbmVyLmNhbGwodGhpcywgZXZlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkRXZlbnRMaXN0ZW5lcihuYW1lLCBsaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNsaXN0ZW5lcnMuYWRkKGxpc3RlbmVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlRXZlbnRMaXN0ZW5lcihuYW1lLCBsaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNsaXN0ZW5lcnMuZGVsZXRlKGxpc3RlbmVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGVybWluYXRlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNsaXN0ZW5lcnMuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkxvb3BiYWNrUG9ydCA9IExvb3BiYWNrUG9ydDsKICAgICAgICAgICAgICAgIGNvbnN0IFBERldvcmtlclV0aWwgPSB7CiAgICAgICAgICAgICAgICAgICAgaXNXb3JrZXJEaXNhYmxlZDogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgZmFsbGJhY2tXb3JrZXJTcmM6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgZmFrZVdvcmtlcklkOiAwCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZXb3JrZXJVdGlsID0gUERGV29ya2VyVXRpbDsKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZiAoX2lzX25vZGUuaXNOb2RlSlMgJiYgdHlwZW9mIHJlcXVpcmUgPT09ICJmdW5jdGlvbiIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyVXRpbC5pc1dvcmtlckRpc2FibGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyVXRpbC5mYWxsYmFja1dvcmtlclNyYyA9ICIuL3BkZi53b3JrZXIuanMiOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIGRvY3VtZW50ID09PSAib2JqZWN0IikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2RvY3VtZW50LCBfZG9jdW1lbnQkY3VycmVudFNjcmk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBkZmpzRmlsZVBhdGggPSAoX2RvY3VtZW50ID0gZG9jdW1lbnQpID09PSBudWxsIHx8IF9kb2N1bWVudCA9PT0gdm9pZCAwID8gdm9pZCAwIDogKF9kb2N1bWVudCRjdXJyZW50U2NyaSA9IF9kb2N1bWVudC5jdXJyZW50U2NyaXB0KSA9PT0gbnVsbCB8fCBfZG9jdW1lbnQkY3VycmVudFNjcmkgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9kb2N1bWVudCRjdXJyZW50U2NyaS5zcmM7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwZGZqc0ZpbGVQYXRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBQREZXb3JrZXJVdGlsLmZhbGxiYWNrV29ya2VyU3JjID0gcGRmanNGaWxlUGF0aC5yZXBsYWNlKC8oXC4oPzptaW5cLik/anMpKFw/LiopPyQvaSwgIi53b3JrZXIkMSQyIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyVXRpbC5pc1NhbWVPcmlnaW4gPSBmdW5jdGlvbiAoYmFzZVVybCwgb3RoZXJVcmwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJhc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYXNlID0gbmV3IFVSTChiYXNlVXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghYmFzZS5vcmlnaW4gfHwgYmFzZS5vcmlnaW4gPT09ICJudWxsIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG90aGVyID0gbmV3IFVSTChvdGhlclVybCwgYmFzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBiYXNlLm9yaWdpbiA9PT0gb3RoZXIub3JpZ2luOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyVXRpbC5jcmVhdGVDRE5XcmFwcGVyID0gZnVuY3Rpb24gKHVybCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3cmFwcGVyID0gYGltcG9ydFNjcmlwdHMoIiR7dXJsfSIpO2A7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBVUkwuY3JlYXRlT2JqZWN0VVJMKG5ldyBCbG9iKFt3cmFwcGVyXSkpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQREZXb3JrZXIgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyAjd29ya2VyUG9ydHMgPSBuZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZSA9IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb3J0ID0gbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZlcmJvc2l0eSA9ICgwLCBfdXRpbC5nZXRWZXJib3NpdHlMZXZlbCkoKQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBvcnQgJiYgUERGV29ya2VyLiN3b3JrZXJQb3J0cy5oYXMocG9ydCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiQ2Fubm90IHVzZSBtb3JlIHRoYW4gb25lIFBERldvcmtlciBwZXIgcG9ydC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hbWUgPSBuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3Ryb3llZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZlcmJvc2l0eSA9IHZlcmJvc2l0eTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wb3J0ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fd2ViV29ya2VyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbWVzc2FnZUhhbmRsZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocG9ydCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyLiN3b3JrZXJQb3J0cy5zZXQocG9ydCwgdGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pbml0aWFsaXplRnJvbVBvcnQocG9ydCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faW5pdGlhbGl6ZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJvbWlzZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3JlYWR5Q2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcG9ydCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3BvcnQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBtZXNzYWdlSGFuZGxlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX21lc3NhZ2VIYW5kbGVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfaW5pdGlhbGl6ZUZyb21Qb3J0KHBvcnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcG9ydCA9IHBvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX21lc3NhZ2VIYW5kbGVyID0gbmV3IF9tZXNzYWdlX2hhbmRsZXIuTWVzc2FnZUhhbmRsZXIoIm1haW4iLCAid29ya2VyIiwgcG9ydCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX21lc3NhZ2VIYW5kbGVyLm9uKCJyZWFkeSIsIGZ1bmN0aW9uICgpIHt9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbWVzc2FnZUhhbmRsZXIuc2VuZCgiY29uZmlndXJlIiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmVyYm9zaXR5OiB0aGlzLnZlcmJvc2l0eQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2luaXRpYWxpemUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghUERGV29ya2VyVXRpbC5pc1dvcmtlckRpc2FibGVkICYmICFQREZXb3JrZXIuX21haW5UaHJlYWRXb3JrZXJNZXNzYWdlSGFuZGxlcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXJTcmMKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBQREZXb3JrZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghUERGV29ya2VyVXRpbC5pc1NhbWVPcmlnaW4od2luZG93LmxvY2F0aW9uLmhyZWYsIHdvcmtlclNyYykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd29ya2VyU3JjID0gUERGV29ya2VyVXRpbC5jcmVhdGVDRE5XcmFwcGVyKG5ldyBVUkwod29ya2VyU3JjLCB3aW5kb3cubG9jYXRpb24pLmhyZWYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3b3JrZXIgPSBuZXcgV29ya2VyKHdvcmtlclNyYyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWVzc2FnZUhhbmRsZXIgPSBuZXcgX21lc3NhZ2VfaGFuZGxlci5NZXNzYWdlSGFuZGxlcigibWFpbiIsICJ3b3JrZXIiLCB3b3JrZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRlcm1pbmF0ZUVhcmx5ID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZXJyb3IiLCBvbldvcmtlckVycm9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIuZGVzdHJveSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIudGVybWluYXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZHlDYXBhYmlsaXR5LnJlamVjdChuZXcgRXJyb3IoIldvcmtlciB3YXMgZGVzdHJveWVkIikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0dXBGYWtlV29ya2VyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9uV29ya2VyRXJyb3IgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5fd2ViV29ya2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXJtaW5hdGVFYXJseSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigiZXJyb3IiLCBvbldvcmtlckVycm9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlSGFuZGxlci5vbigidGVzdCIsIGRhdGEgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZXJyb3IiLCBvbldvcmtlckVycm9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGVzdHJveWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXJtaW5hdGVFYXJseSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tZXNzYWdlSGFuZGxlciA9IG1lc3NhZ2VIYW5kbGVyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcG9ydCA9IHdvcmtlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3dlYldvcmtlciA9IHdvcmtlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWR5Q2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlSGFuZGxlci5zZW5kKCJjb25maWd1cmUiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmVyYm9zaXR5OiB0aGlzLnZlcmJvc2l0eQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXR1cEZha2VXb3JrZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLmRlc3Ryb3koKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdvcmtlci50ZXJtaW5hdGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJyZWFkeSIsIGRhdGEgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3b3JrZXIucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZXJyb3IiLCBvbldvcmtlckVycm9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGVzdHJveWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXJtaW5hdGVFYXJseSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZW5kVGVzdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXR1cEZha2VXb3JrZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNlbmRUZXN0ID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXN0T2JqID0gbmV3IFVpbnQ4QXJyYXkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIuc2VuZCgidGVzdCIsIHRlc3RPYmosIFt0ZXN0T2JqLmJ1ZmZlcl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VuZFRlc3QoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJUaGUgd29ya2VyIGhhcyBiZWVuIGRpc2FibGVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldHVwRmFrZVdvcmtlcigpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfc2V0dXBGYWtlV29ya2VyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIVBERldvcmtlclV0aWwuaXNXb3JrZXJEaXNhYmxlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJTZXR0aW5nIHVwIGZha2Ugd29ya2VyLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgUERGV29ya2VyVXRpbC5pc1dvcmtlckRpc2FibGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBQREZXb3JrZXIuX3NldHVwRmFrZVdvcmtlckdsb2JhbC50aGVuKFdvcmtlck1lc3NhZ2VIYW5kbGVyID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWR5Q2FwYWJpbGl0eS5yZWplY3QobmV3IEVycm9yKCJXb3JrZXIgd2FzIGRlc3Ryb3llZCIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb3J0ID0gbmV3IExvb3BiYWNrUG9ydCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcG9ydCA9IHBvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IGBmYWtlJHtQREZXb3JrZXJVdGlsLmZha2VXb3JrZXJJZCsrfWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3b3JrZXJIYW5kbGVyID0gbmV3IF9tZXNzYWdlX2hhbmRsZXIuTWVzc2FnZUhhbmRsZXIoaWQgKyAiX3dvcmtlciIsIGlkLCBwb3J0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIFdvcmtlck1lc3NhZ2VIYW5kbGVyLnNldHVwKHdvcmtlckhhbmRsZXIsIHBvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWVzc2FnZUhhbmRsZXIgPSBuZXcgX21lc3NhZ2VfaGFuZGxlci5NZXNzYWdlSGFuZGxlcihpZCwgaWQgKyAiX3dvcmtlciIsIHBvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbWVzc2FnZUhhbmRsZXIgPSBtZXNzYWdlSGFuZGxlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWR5Q2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlSGFuZGxlci5zZW5kKCJjb25maWd1cmUiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmVyYm9zaXR5OiB0aGlzLnZlcmJvc2l0eQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pLmNhdGNoKHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkeUNhcGFiaWxpdHkucmVqZWN0KG5ldyBFcnJvcihgU2V0dGluZyB1cCBmYWtlIHdvcmtlciBmYWlsZWQ6ICIke3JlYXNvbi5tZXNzYWdlfSIuYCkpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZGVzdHJveSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kZXN0cm95ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fd2ViV29ya2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl93ZWJXb3JrZXIudGVybWluYXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl93ZWJXb3JrZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIFBERldvcmtlci4jd29ya2VyUG9ydHMuZGVsZXRlKHRoaXMuX3BvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wb3J0ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX21lc3NhZ2VIYW5kbGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tZXNzYWdlSGFuZGxlci5kZXN0cm95KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tZXNzYWdlSGFuZGxlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGZyb21Qb3J0KHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIShwYXJhbXMgIT09IG51bGwgJiYgcGFyYW1zICE9PSB2b2lkIDAgJiYgcGFyYW1zLnBvcnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIlBERldvcmtlci5mcm9tUG9ydCAtIGludmFsaWQgbWV0aG9kIHNpZ25hdHVyZS4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy4jd29ya2VyUG9ydHMuaGFzKHBhcmFtcy5wb3J0KSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI3dvcmtlclBvcnRzLmdldChwYXJhbXMucG9ydCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBQREZXb3JrZXIocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCB3b3JrZXJTcmMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfd29ya2VyX29wdGlvbnMuR2xvYmFsV29ya2VyT3B0aW9ucy53b3JrZXJTcmMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfd29ya2VyX29wdGlvbnMuR2xvYmFsV29ya2VyT3B0aW9ucy53b3JrZXJTcmM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFBERldvcmtlclV0aWwuZmFsbGJhY2tXb3JrZXJTcmMgIT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2lzX25vZGUuaXNOb2RlSlMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuZGVwcmVjYXRlZCkoJ05vICJHbG9iYWxXb3JrZXJPcHRpb25zLndvcmtlclNyYyIgc3BlY2lmaWVkLicpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFBERldvcmtlclV0aWwuZmFsbGJhY2tXb3JrZXJTcmM7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdObyAiR2xvYmFsV29ya2VyT3B0aW9ucy53b3JrZXJTcmMiIHNwZWNpZmllZC4nKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBfbWFpblRocmVhZFdvcmtlck1lc3NhZ2VIYW5kbGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9nbG9iYWxUaGlzJHBkZmpzV29yazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoKF9nbG9iYWxUaGlzJHBkZmpzV29yayA9IGdsb2JhbFRoaXMucGRmanNXb3JrZXIpID09PSBudWxsIHx8IF9nbG9iYWxUaGlzJHBkZmpzV29yayA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2dsb2JhbFRoaXMkcGRmanNXb3JrLldvcmtlck1lc3NhZ2VIYW5kbGVyKSB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBfc2V0dXBGYWtlV29ya2VyR2xvYmFsKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsb2FkZXIgPSBhc3luYyAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYWluV29ya2VyTWVzc2FnZUhhbmRsZXIgPSB0aGlzLl9tYWluVGhyZWFkV29ya2VyTWVzc2FnZUhhbmRsZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobWFpbldvcmtlck1lc3NhZ2VIYW5kbGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1haW5Xb3JrZXJNZXNzYWdlSGFuZGxlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfaXNfbm9kZS5pc05vZGVKUyAmJiB0eXBlb2YgcmVxdWlyZSA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdvcmtlciA9IGV2YWwoInJlcXVpcmUiKSh0aGlzLndvcmtlclNyYyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5Xb3JrZXJNZXNzYWdlSGFuZGxlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF3YWl0ICgwLCBfZGlzcGxheV91dGlscy5sb2FkU2NyaXB0KSh0aGlzLndvcmtlclNyYyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gd2luZG93LnBkZmpzV29ya2VyLldvcmtlck1lc3NhZ2VIYW5kbGVyOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIl9zZXR1cEZha2VXb3JrZXJHbG9iYWwiLCBsb2FkZXIoKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZXb3JrZXIgPSBQREZXb3JrZXI7CiAgICAgICAgICAgICAgICB2YXIgX21ldGhvZFByb21pc2VzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX3BhZ2VDYWNoZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9wYWdlUHJvbWlzZXMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY2FjaGVTaW1wbGVNZXRob2QgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIFdvcmtlclRyYW5zcG9ydCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobWVzc2FnZUhhbmRsZXIsIGxvYWRpbmdUYXNrLCBuZXR3b3JrU3RyZWFtLCBwYXJhbXMsIGZhY3RvcnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9jYWNoZVNpbXBsZU1ldGhvZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9tZXRob2RQcm9taXNlcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbmV3IE1hcCgpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcGFnZUNhY2hlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgTWFwKCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9wYWdlUHJvbWlzZXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBNYXAoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tZXNzYWdlSGFuZGxlciA9IG1lc3NhZ2VIYW5kbGVyOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxvYWRpbmdUYXNrID0gbG9hZGluZ1Rhc2s7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbW9uT2JqcyA9IG5ldyBQREZPYmplY3RzKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZm9udExvYWRlciA9IG5ldyBfZm9udF9sb2FkZXIuRm9udExvYWRlcih7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvd25lckRvY3VtZW50OiBwYXJhbXMub3duZXJEb2N1bWVudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlRWxlbWVudDogcGFyYW1zLnN0eWxlRWxlbWVudAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFyYW1zID0gcGFyYW1zOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkgPSBmYWN0b3J5LmNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsdGVyRmFjdG9yeSA9IGZhY3RvcnkuZmlsdGVyRmFjdG9yeTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jTWFwUmVhZGVyRmFjdG9yeSA9IGZhY3RvcnkuY01hcFJlYWRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhbmRhcmRGb250RGF0YUZhY3RvcnkgPSBmYWN0b3J5LnN0YW5kYXJkRm9udERhdGFGYWN0b3J5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3Ryb3llZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3Ryb3lDYXBhYmlsaXR5ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFzc3dvcmRDYXBhYmlsaXR5ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbmV0d29ya1N0cmVhbSA9IG5ldHdvcmtTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZWFkZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sYXN0UHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRvd25sb2FkSW5mb0NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0dXBNZXNzYWdlSGFuZGxlcigpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgYW5ub3RhdGlvblN0b3JhZ2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiYW5ub3RhdGlvblN0b3JhZ2UiLCBuZXcgX2Fubm90YXRpb25fc3RvcmFnZS5Bbm5vdGF0aW9uU3RvcmFnZSgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UmVuZGVyaW5nSW50ZW50KGludGVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYW5ub3RhdGlvbk1vZGUgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IF91dGlsLkFubm90YXRpb25Nb2RlLkVOQUJMRTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHByaW50QW5ub3RhdGlvblN0b3JhZ2UgPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpc09wTGlzdCA9IGFyZ3VtZW50cy5sZW5ndGggPiAzICYmIGFyZ3VtZW50c1szXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzNdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZW5kZXJpbmdJbnRlbnQgPSBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLkRJU1BMQVk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBhbm5vdGF0aW9uTWFwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChpbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImFueSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyaW5nSW50ZW50ID0gX3V0aWwuUmVuZGVyaW5nSW50ZW50RmxhZy5BTlk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJkaXNwbGF5IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgInByaW50IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJpbmdJbnRlbnQgPSBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLlBSSU5UOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYGdldFJlbmRlcmluZ0ludGVudCAtIGludmFsaWQgaW50ZW50OiAke2ludGVudH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGFubm90YXRpb25Nb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25Nb2RlLkRJU0FCTEU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyaW5nSW50ZW50ICs9IF91dGlsLlJlbmRlcmluZ0ludGVudEZsYWcuQU5OT1RBVElPTlNfRElTQUJMRTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvbk1vZGUuRU5BQkxFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uTW9kZS5FTkFCTEVfRk9STVM6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVuZGVyaW5nSW50ZW50ICs9IF91dGlsLlJlbmRlcmluZ0ludGVudEZsYWcuQU5OT1RBVElPTlNfRk9STVM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25Nb2RlLkVOQUJMRV9TVE9SQUdFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlcmluZ0ludGVudCArPSBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLkFOTk9UQVRJT05TX1NUT1JBR0U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYW5ub3RhdGlvblN0b3JhZ2UgPSByZW5kZXJpbmdJbnRlbnQgJiBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLlBSSU5UICYmIHByaW50QW5ub3RhdGlvblN0b3JhZ2UgaW5zdGFuY2VvZiBfYW5ub3RhdGlvbl9zdG9yYWdlLlByaW50QW5ub3RhdGlvblN0b3JhZ2UgPyBwcmludEFubm90YXRpb25TdG9yYWdlIDogdGhpcy5hbm5vdGF0aW9uU3RvcmFnZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uTWFwID0gYW5ub3RhdGlvblN0b3JhZ2Uuc2VyaWFsaXphYmxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYGdldFJlbmRlcmluZ0ludGVudCAtIGludmFsaWQgYW5ub3RhdGlvbk1vZGU6ICR7YW5ub3RhdGlvbk1vZGV9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzT3BMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJpbmdJbnRlbnQgKz0gX3V0aWwuUmVuZGVyaW5nSW50ZW50RmxhZy5PUExJU1Q7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlcmluZ0ludGVudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlS2V5OiBgJHtyZW5kZXJpbmdJbnRlbnR9XyR7X2Fubm90YXRpb25fc3RvcmFnZS5Bbm5vdGF0aW9uU3RvcmFnZS5nZXRIYXNoKGFubm90YXRpb25NYXApfWAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uU3RvcmFnZU1hcDogYW5ub3RhdGlvbk1hcAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kZXN0cm95Q2FwYWJpbGl0eSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZGVzdHJveUNhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc3Ryb3llZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVzdHJveUNhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9wYXNzd29yZENhcGFiaWxpdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Bhc3N3b3JkQ2FwYWJpbGl0eS5yZWplY3QobmV3IEVycm9yKCJXb3JrZXIgd2FzIGRlc3Ryb3llZCBkdXJpbmcgb25QYXNzd29yZCBjYWxsYmFjayIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3YWl0T24gPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBwYWdlIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfcGFnZUNhY2hlKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2FpdE9uLnB1c2gocGFnZS5fZGVzdHJveSgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3BhZ2VDYWNoZSkuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wYWdlUHJvbWlzZXMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmhhc093blByb3BlcnR5KCJhbm5vdGF0aW9uU3RvcmFnZSIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFubm90YXRpb25TdG9yYWdlLnJlc2V0TW9kaWZpZWQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXJtaW5hdGVkID0gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIlRlcm1pbmF0ZSIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICB3YWl0T24ucHVzaCh0ZXJtaW5hdGVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgUHJvbWlzZS5hbGwod2FpdE9uKS50aGVuKCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbW9uT2Jqcy5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5mb250TG9hZGVyLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX21ldGhvZFByb21pc2VzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5maWx0ZXJGYWN0b3J5LmRlc3Ryb3koKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9uZXR3b3JrU3RyZWFtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbmV0d29ya1N0cmVhbS5jYW5jZWxBbGxSZXF1ZXN0cyhuZXcgX3V0aWwuQWJvcnRFeGNlcHRpb24oIldvcmtlciB3YXMgdGVybWluYXRlZC4iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5tZXNzYWdlSGFuZGxlcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWVzc2FnZUhhbmRsZXIuZGVzdHJveSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWVzc2FnZUhhbmRsZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kZXN0cm95Q2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIHRoaXMuZGVzdHJveUNhcGFiaWxpdHkucmVqZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZGVzdHJveUNhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0dXBNZXNzYWdlSGFuZGxlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkaW5nVGFzawogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdGhpczsKICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIub24oIkdldFJlYWRlciIsIChkYXRhLCBzaW5rKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KSh0aGlzLl9uZXR3b3JrU3RyZWFtLCAiR2V0UmVhZGVyIC0gbm8gYElQREZTdHJlYW1gIGluc3RhbmNlIGF2YWlsYWJsZS4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZWFkZXIgPSB0aGlzLl9uZXR3b3JrU3RyZWFtLmdldEZ1bGxSZWFkZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZWFkZXIub25Qcm9ncmVzcyA9IGV2dCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbGFzdFByb2dyZXNzID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkZWQ6IGV2dC5sb2FkZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsOiBldnQudG90YWwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpbmsub25QdWxsID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZWFkZXIucmVhZCgpLnRoZW4oZnVuY3Rpb24gKF9yZWY4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWY4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHZhbHVlIGluc3RhbmNlb2YgQXJyYXlCdWZmZXIsICJHZXRSZWFkZXIgLSBleHBlY3RlZCBhbiBBcnJheUJ1ZmZlci4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5lbnF1ZXVlKG5ldyBVaW50OEFycmF5KHZhbHVlKSwgMSwgW3ZhbHVlXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5lcnJvcihyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpbmsub25DYW5jZWwgPSByZWFzb24gPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZWFkZXIuY2FuY2VsKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5yZWFkeS5jYXRjaChyZWFkeVJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IHJlYWR5UmVhc29uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJSZWFkZXJIZWFkZXJzUmVhZHkiLCBkYXRhID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlYWRlcnNDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZnVsbFJlYWRlciA9IHRoaXMuX2Z1bGxSZWFkZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmdWxsUmVhZGVyLmhlYWRlcnNSZWFkeS50aGVuKCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWZ1bGxSZWFkZXIuaXNTdHJlYW1pbmdTdXBwb3J0ZWQgfHwgIWZ1bGxSZWFkZXIuaXNSYW5nZVN1cHBvcnRlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fbGFzdFByb2dyZXNzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2xvYWRpbmdUYXNrJG9uUHJvZ3JlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF9sb2FkaW5nVGFzayRvblByb2dyZSA9IGxvYWRpbmdUYXNrLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF9sb2FkaW5nVGFzayRvblByb2dyZSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2xvYWRpbmdUYXNrJG9uUHJvZ3JlLmNhbGwobG9hZGluZ1Rhc2ssIHRoaXMuX2xhc3RQcm9ncmVzcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZnVsbFJlYWRlci5vblByb2dyZXNzID0gZXZ0ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfbG9hZGluZ1Rhc2skb25Qcm9ncmUyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF9sb2FkaW5nVGFzayRvblByb2dyZTIgPSBsb2FkaW5nVGFzay5vblByb2dyZXNzKSA9PT0gbnVsbCB8fCBfbG9hZGluZ1Rhc2skb25Qcm9ncmUyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfbG9hZGluZ1Rhc2skb25Qcm9ncmUyLmNhbGwobG9hZGluZ1Rhc2ssIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkZWQ6IGV2dC5sb2FkZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWw6IGV2dC50b3RhbAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnNDYXBhYmlsaXR5LnJlc29sdmUoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1N0cmVhbWluZ1N1cHBvcnRlZDogZnVsbFJlYWRlci5pc1N0cmVhbWluZ1N1cHBvcnRlZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSYW5nZVN1cHBvcnRlZDogZnVsbFJlYWRlci5pc1JhbmdlU3VwcG9ydGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50TGVuZ3RoOiBmdWxsUmVhZGVyLmNvbnRlbnRMZW5ndGgKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIGhlYWRlcnNDYXBhYmlsaXR5LnJlamVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaGVhZGVyc0NhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJHZXRSYW5nZVJlYWRlciIsIChkYXRhLCBzaW5rKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KSh0aGlzLl9uZXR3b3JrU3RyZWFtLCAiR2V0UmFuZ2VSZWFkZXIgLSBubyBgSVBERlN0cmVhbWAgaW5zdGFuY2UgYXZhaWxhYmxlLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFuZ2VSZWFkZXIgPSB0aGlzLl9uZXR3b3JrU3RyZWFtLmdldFJhbmdlUmVhZGVyKGRhdGEuYmVnaW4sIGRhdGEuZW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghcmFuZ2VSZWFkZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW5rLmNsb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5vblB1bGwgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2VSZWFkZXIucmVhZCgpLnRoZW4oZnVuY3Rpb24gKF9yZWY5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWY5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHZhbHVlIGluc3RhbmNlb2YgQXJyYXlCdWZmZXIsICJHZXRSYW5nZVJlYWRlciAtIGV4cGVjdGVkIGFuIEFycmF5QnVmZmVyLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW5rLmVucXVldWUobmV3IFVpbnQ4QXJyYXkodmFsdWUpLCAxLCBbdmFsdWVdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KS5jYXRjaChyZWFzb24gPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW5rLmVycm9yKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5vbkNhbmNlbCA9IHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2VSZWFkZXIuY2FuY2VsKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2luay5yZWFkeS5jYXRjaChyZWFkeVJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IHJlYWR5UmVhc29uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJHZXREb2MiLCBfcmVmMTAgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZGZJbmZvCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjEwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbnVtUGFnZXMgPSBwZGZJbmZvLm51bVBhZ2VzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faHRtbEZvclhmYSA9IHBkZkluZm8uaHRtbEZvclhmYTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBwZGZJbmZvLmh0bWxGb3JYZmE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkaW5nVGFzay5fY2FwYWJpbGl0eS5yZXNvbHZlKG5ldyBQREZEb2N1bWVudFByb3h5KHBkZkluZm8sIHRoaXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJEb2NFeGNlcHRpb24iLCBmdW5jdGlvbiAoZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZWFzb247CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGV4Lm5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJQYXNzd29yZEV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbiA9IG5ldyBfdXRpbC5QYXNzd29yZEV4Y2VwdGlvbihleC5tZXNzYWdlLCBleC5jb2RlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiSW52YWxpZFBERkV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbiA9IG5ldyBfdXRpbC5JbnZhbGlkUERGRXhjZXB0aW9uKGV4Lm1lc3NhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJNaXNzaW5nUERGRXhjZXB0aW9uIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uID0gbmV3IF91dGlsLk1pc3NpbmdQREZFeGNlcHRpb24oZXgubWVzc2FnZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbiA9IG5ldyBfdXRpbC5VbmV4cGVjdGVkUmVzcG9uc2VFeGNlcHRpb24oZXgubWVzc2FnZSwgZXguc3RhdHVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiVW5rbm93bkVycm9yRXhjZXB0aW9uIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uID0gbmV3IF91dGlsLlVua25vd25FcnJvckV4Y2VwdGlvbihleC5tZXNzYWdlLCBleC5kZXRhaWxzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiRG9jRXhjZXB0aW9uIC0gZXhwZWN0ZWQgYSB2YWxpZCBFcnJvci4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRpbmdUYXNrLl9jYXBhYmlsaXR5LnJlamVjdChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIub24oIlBhc3N3b3JkUmVxdWVzdCIsIGV4Y2VwdGlvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXNzd29yZENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobG9hZGluZ1Rhc2sub25QYXNzd29yZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVwZGF0ZVBhc3N3b3JkID0gcGFzc3dvcmQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFzc3dvcmQgaW5zdGFuY2VvZiBFcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFzc3dvcmRDYXBhYmlsaXR5LnJlamVjdChwYXNzd29yZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXNzd29yZENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFzc3dvcmQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkaW5nVGFzay5vblBhc3N3b3JkKHVwZGF0ZVBhc3N3b3JkLCBleGNlcHRpb24uY29kZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFzc3dvcmRDYXBhYmlsaXR5LnJlamVjdChleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wYXNzd29yZENhcGFiaWxpdHkucmVqZWN0KG5ldyBfdXRpbC5QYXNzd29yZEV4Y2VwdGlvbihleGNlcHRpb24ubWVzc2FnZSwgZXhjZXB0aW9uLmNvZGUpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9wYXNzd29yZENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJEYXRhTG9hZGVkIiwgZGF0YSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2xvYWRpbmdUYXNrJG9uUHJvZ3JlMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfbG9hZGluZ1Rhc2skb25Qcm9ncmUzID0gbG9hZGluZ1Rhc2sub25Qcm9ncmVzcykgPT09IG51bGwgfHwgX2xvYWRpbmdUYXNrJG9uUHJvZ3JlMyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2xvYWRpbmdUYXNrJG9uUHJvZ3JlMy5jYWxsKGxvYWRpbmdUYXNrLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBkYXRhLmxlbmd0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b3RhbDogZGF0YS5sZW5ndGgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kb3dubG9hZEluZm9DYXBhYmlsaXR5LnJlc29sdmUoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBtZXNzYWdlSGFuZGxlci5vbigiU3RhcnRSZW5kZXJQYWdlIiwgZGF0YSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kZXN0cm95ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWdlID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wYWdlQ2FjaGUpLmdldChkYXRhLnBhZ2VJbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlLl9zdGFydFJlbmRlclBhZ2UoZGF0YS50cmFuc3BhcmVuY3ksIGRhdGEuY2FjaGVLZXkpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIub24oImNvbW1vbm9iaiIsIF9yZWYxMSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2dsb2JhbFRoaXMkRm9udEluc3BlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IFtpZCwgdHlwZSwgZXhwb3J0ZWREYXRhXSA9IF9yZWYxMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNvbW1vbk9ianMuaGFzKGlkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkZvbnQiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJhbXMgPSB0aGlzLl9wYXJhbXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgiZXJyb3IiIGluIGV4cG9ydGVkRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZXhwb3J0ZWRFcnJvciA9IGV4cG9ydGVkRGF0YS5lcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgRXJyb3IgZHVyaW5nIGZvbnQgbG9hZGluZzogJHtleHBvcnRlZEVycm9yfWApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzLnJlc29sdmUoaWQsIGV4cG9ydGVkRXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW5zcGVjdEZvbnQgPSBwYXJhbXMucGRmQnVnICYmIChfZ2xvYmFsVGhpcyRGb250SW5zcGUgPSBnbG9iYWxUaGlzLkZvbnRJbnNwZWN0b3IpICE9PSBudWxsICYmIF9nbG9iYWxUaGlzJEZvbnRJbnNwZSAhPT0gdm9pZCAwICYmIF9nbG9iYWxUaGlzJEZvbnRJbnNwZS5lbmFibGVkID8gKGZvbnQsIHVybCkgPT4gZ2xvYmFsVGhpcy5Gb250SW5zcGVjdG9yLmZvbnRBZGRlZChmb250LCB1cmwpIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udCA9IG5ldyBfZm9udF9sb2FkZXIuRm9udEZhY2VPYmplY3QoZXhwb3J0ZWREYXRhLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQ6IHBhcmFtcy5pc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlRm9udEZhY2U6IHBhcmFtcy5kaXNhYmxlRm9udEZhY2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVFcnJvcnM6IHBhcmFtcy5pZ25vcmVFcnJvcnMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnNwZWN0Rm9udAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5mb250TG9hZGVyLmJpbmQoZm9udCkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBtZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkZvbnRGYWxsYmFjayIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pLmZpbmFsbHkoKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFwYXJhbXMuZm9udEV4dHJhUHJvcGVydGllcyAmJiBmb250LmRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb250LmRhdGEgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzLnJlc29sdmUoaWQsIGZvbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiRm9udFBhdGgiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkltYWdlIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJQYXR0ZXJuIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzLnJlc29sdmUoaWQsIGV4cG9ydGVkRGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgR290IHVua25vd24gY29tbW9uIG9iamVjdCB0eXBlICR7dHlwZX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJvYmoiLCBfcmVmMTIgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IFtpZCwgcGFnZUluZGV4LCB0eXBlLCBpbWFnZURhdGFdID0gX3JlZjEyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGVzdHJveWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFnZVByb3h5ID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wYWdlQ2FjaGUpLmdldChwYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhZ2VQcm94eS5vYmpzLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJJbWFnZSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VQcm94eS5vYmpzLnJlc29sdmUoaWQsIGltYWdlRGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbWFnZURhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBsZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW1hZ2VEYXRhLmJpdG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBpbWFnZURhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVuZ3RoID0gd2lkdGggKiBoZWlnaHQgKiA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2ltYWdlRGF0YSRkYXRhOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxlbmd0aCA9ICgoX2ltYWdlRGF0YSRkYXRhID0gaW1hZ2VEYXRhLmRhdGEpID09PSBudWxsIHx8IF9pbWFnZURhdGEkZGF0YSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2ltYWdlRGF0YSRkYXRhLmxlbmd0aCkgfHwgMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsZW5ndGggPiBfdXRpbC5NQVhfSU1BR0VfU0laRV9UT19DQUNIRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VQcm94eS5fbWF5YmVDbGVhbnVwQWZ0ZXJSZW5kZXIgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlBhdHRlcm4iOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlUHJveHkub2Jqcy5yZXNvbHZlKGlkLCBpbWFnZURhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYEdvdCB1bmtub3duIG9iamVjdCB0eXBlICR7dHlwZX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJEb2NQcm9ncmVzcyIsIGRhdGEgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9sb2FkaW5nVGFzayRvblByb2dyZTQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kZXN0cm95ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX2xvYWRpbmdUYXNrJG9uUHJvZ3JlNCA9IGxvYWRpbmdUYXNrLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF9sb2FkaW5nVGFzayRvblByb2dyZTQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9sb2FkaW5nVGFzayRvblByb2dyZTQuY2FsbChsb2FkaW5nVGFzaywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRlZDogZGF0YS5sb2FkZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWw6IGRhdGEudG90YWwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgbWVzc2FnZUhhbmRsZXIub24oIkZldGNoQnVpbHRJbkNNYXAiLCBkYXRhID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdChuZXcgRXJyb3IoIldvcmtlciB3YXMgZGVzdHJveWVkLiIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jTWFwUmVhZGVyRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdChuZXcgRXJyb3IoIkNNYXBSZWFkZXJGYWN0b3J5IG5vdCBpbml0aWFsaXplZCwgc2VlIHRoZSBgdXNlV29ya2VyRmV0Y2hgIHBhcmFtZXRlci4iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jTWFwUmVhZGVyRmFjdG9yeS5mZXRjaChkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1lc3NhZ2VIYW5kbGVyLm9uKCJGZXRjaFN0YW5kYXJkRm9udERhdGEiLCBkYXRhID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdChuZXcgRXJyb3IoIldvcmtlciB3YXMgZGVzdHJveWVkLiIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5zdGFuZGFyZEZvbnREYXRhRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBQcm9taXNlLnJlamVjdChuZXcgRXJyb3IoIlN0YW5kYXJkRm9udERhdGFGYWN0b3J5IG5vdCBpbml0aWFsaXplZCwgc2VlIHRoZSBgdXNlV29ya2VyRmV0Y2hgIHBhcmFtZXRlci4iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5zdGFuZGFyZEZvbnREYXRhRmFjdG9yeS5mZXRjaChkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERhdGEoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0RGF0YSIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzYXZlRG9jdW1lbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlYWRlcjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuYW5ub3RhdGlvblN0b3JhZ2Uuc2l6ZSA8PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoInNhdmVEb2N1bWVudCBjYWxsZWQgd2hpbGUgYGFubm90YXRpb25TdG9yYWdlYCBpcyBlbXB0eSwgIiArICJwbGVhc2UgdXNlIHRoZSBnZXREYXRhLW1ldGhvZCBpbnN0ZWFkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiU2F2ZURvY3VtZW50IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNQdXJlWGZhOiAhIXRoaXMuX2h0bWxGb3JYZmEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBudW1QYWdlczogdGhpcy5fbnVtUGFnZXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uU3RvcmFnZTogdGhpcy5hbm5vdGF0aW9uU3RvcmFnZS5zZXJpYWxpemFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWxlbmFtZTogKChfdGhpcyRfZnVsbFJlYWRlciA9IHRoaXMuX2Z1bGxSZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVhZGVyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlYWRlci5maWxlbmFtZSkgPz8gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KS5maW5hbGx5KCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvblN0b3JhZ2UucmVzZXRNb2RpZmllZCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGFnZShwYWdlTnVtYmVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghTnVtYmVyLmlzSW50ZWdlcihwYWdlTnVtYmVyKSB8fCBwYWdlTnVtYmVyIDw9IDAgfHwgcGFnZU51bWJlciA+IHRoaXMuX251bVBhZ2VzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZWplY3QobmV3IEVycm9yKCJJbnZhbGlkIHBhZ2UgcmVxdWVzdC4iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFnZUluZGV4ID0gcGFnZU51bWJlciAtIDEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZWRQcm9taXNlID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wYWdlUHJvbWlzZXMpLmdldChwYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2FjaGVkUHJvbWlzZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNhY2hlZFByb21pc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJvbWlzZSA9IHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRQYWdlIiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZGV4CiAgICAgICAgICAgICAgICAgICAgICAgIH0pLnRoZW4ocGFnZUluZm8gPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGVzdHJveWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJUcmFuc3BvcnQgZGVzdHJveWVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWdlID0gbmV3IFBERlBhZ2VQcm94eShwYWdlSW5kZXgsIHBhZ2VJbmZvLCB0aGlzLCB0aGlzLl9wYXJhbXMucGRmQnVnKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfcGFnZUNhY2hlKS5zZXQocGFnZUluZGV4LCBwYWdlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwYWdlOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wYWdlUHJvbWlzZXMpLnNldChwYWdlSW5kZXgsIHByb21pc2UpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGFnZUluZGV4KHJlZikgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlZiAhPT0gIm9iamVjdCIgfHwgcmVmID09PSBudWxsIHx8ICFOdW1iZXIuaXNJbnRlZ2VyKHJlZi5udW0pIHx8IHJlZi5udW0gPCAwIHx8ICFOdW1iZXIuaXNJbnRlZ2VyKHJlZi5nZW4pIHx8IHJlZi5nZW4gPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZWplY3QobmV3IEVycm9yKCJJbnZhbGlkIHBhZ2VJbmRleCByZXF1ZXN0LiIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkdldFBhZ2VJbmRleCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG51bTogcmVmLm51bSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdlbjogcmVmLmdlbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0QW5ub3RhdGlvbnMocGFnZUluZGV4LCBpbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRBbm5vdGF0aW9ucyIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJbmRleCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RmllbGRPYmplY3RzKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY2FjaGVTaW1wbGVNZXRob2QsIF9jYWNoZVNpbXBsZU1ldGhvZDIpLmNhbGwodGhpcywgIkdldEZpZWxkT2JqZWN0cyIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXNKU0FjdGlvbnMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jYWNoZVNpbXBsZU1ldGhvZCwgX2NhY2hlU2ltcGxlTWV0aG9kMikuY2FsbCh0aGlzLCAiSGFzSlNBY3Rpb25zIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldENhbGN1bGF0aW9uT3JkZXJJZHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0Q2FsY3VsYXRpb25PcmRlcklkcyIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXREZXN0aW5hdGlvbnMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0RGVzdGluYXRpb25zIiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERlc3RpbmF0aW9uKGlkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgaWQgIT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gUHJvbWlzZS5yZWplY3QobmV3IEVycm9yKCJJbnZhbGlkIGRlc3RpbmF0aW9uIHJlcXVlc3QuIikpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0RGVzdGluYXRpb24iLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGFnZUxhYmVscygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRQYWdlTGFiZWxzIiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhZ2VMYXlvdXQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0UGFnZUxheW91dCIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYWdlTW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRQYWdlTW9kZSIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRWaWV3ZXJQcmVmZXJlbmNlcygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRWaWV3ZXJQcmVmZXJlbmNlcyIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRPcGVuQWN0aW9uKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkdldE9wZW5BY3Rpb24iLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0QXR0YWNobWVudHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0QXR0YWNobWVudHMiLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0SmF2YVNjcmlwdCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRKYXZhU2NyaXB0IiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldERvY0pTQWN0aW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXREb2NKU0FjdGlvbnMiLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGFnZUpTQWN0aW9ucyhwYWdlSW5kZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJHZXRQYWdlSlNBY3Rpb25zIiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZGV4CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRTdHJ1Y3RUcmVlKHBhZ2VJbmRleCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkdldFN0cnVjdFRyZWUiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlSW5kZXgKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE91dGxpbmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0T3V0bGluZSIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRPcHRpb25hbENvbnRlbnRDb25maWcoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1lc3NhZ2VIYW5kbGVyLnNlbmRXaXRoUHJvbWlzZSgiR2V0T3B0aW9uYWxDb250ZW50Q29uZmlnIiwgbnVsbCkudGhlbihyZXN1bHRzID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgX29wdGlvbmFsX2NvbnRlbnRfY29uZmlnLk9wdGlvbmFsQ29udGVudENvbmZpZyhyZXN1bHRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBlcm1pc3Npb25zKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkdldFBlcm1pc3Npb25zIiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE1ldGFkYXRhKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBuYW1lID0gIkdldE1ldGFkYXRhIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlZFByb21pc2UgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX21ldGhvZFByb21pc2VzKS5nZXQobmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjYWNoZWRQcm9taXNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FjaGVkUHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwcm9taXNlID0gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UobmFtZSwgbnVsbCkudGhlbihyZXN1bHRzID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlYWRlcjIsIF90aGlzJF9mdWxsUmVhZGVyMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5mbzogcmVzdWx0c1swXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtZXRhZGF0YTogcmVzdWx0c1sxXSA/IG5ldyBfbWV0YWRhdGEuTWV0YWRhdGEocmVzdWx0c1sxXSkgOiBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lOiAoKF90aGlzJF9mdWxsUmVhZGVyMiA9IHRoaXMuX2Z1bGxSZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVhZGVyMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2Z1bGxSZWFkZXIyLmZpbGVuYW1lKSA/PyBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnRMZW5ndGg6ICgoX3RoaXMkX2Z1bGxSZWFkZXIzID0gdGhpcy5fZnVsbFJlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX2Z1bGxSZWFkZXIzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlYWRlcjMuY29udGVudExlbmd0aCkgPz8gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbWV0aG9kUHJvbWlzZXMpLnNldChuYW1lLCBwcm9taXNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHByb21pc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE1hcmtJbmZvKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UoIkdldE1hcmtJbmZvIiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFzeW5jIHN0YXJ0Q2xlYW51cCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGtlZXBMb2FkZWRGb250cyA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRlc3Ryb3llZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGF3YWl0IHRoaXMubWVzc2FnZUhhbmRsZXIuc2VuZFdpdGhQcm9taXNlKCJDbGVhbnVwIiwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcGFnZSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3BhZ2VDYWNoZSkudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNsZWFudXBTdWNjZXNzZnVsID0gcGFnZS5jbGVhbnVwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWNsZWFudXBTdWNjZXNzZnVsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBzdGFydENsZWFudXA6IFBhZ2UgJHtwYWdlLnBhZ2VOdW1iZXJ9IGlzIGN1cnJlbnRseSByZW5kZXJpbmcuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgha2VlcExvYWRlZEZvbnRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZvbnRMb2FkZXIuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX21ldGhvZFByb21pc2VzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbHRlckZhY3RvcnkuZGVzdHJveSh0cnVlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGxvYWRpbmdQYXJhbXMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVBdXRvRmV0Y2gsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmFibGVYZmEKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuX3BhcmFtczsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJsb2FkaW5nUGFyYW1zIiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUF1dG9GZXRjaCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuYWJsZVhmYQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2FjaGVTaW1wbGVNZXRob2QyKG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgZGF0YSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjYWNoZWRQcm9taXNlID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9tZXRob2RQcm9taXNlcykuZ2V0KG5hbWUpOwogICAgICAgICAgICAgICAgICAgIGlmIChjYWNoZWRQcm9taXNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjYWNoZWRQcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBwcm9taXNlID0gdGhpcy5tZXNzYWdlSGFuZGxlci5zZW5kV2l0aFByb21pc2UobmFtZSwgZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9tZXRob2RQcm9taXNlcykuc2V0KG5hbWUsIHByb21pc2UpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBwcm9taXNlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgdmFyIF9vYmpzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2Vuc3VyZU9iaiA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgY2xhc3MgUERGT2JqZWN0cyB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZW5zdXJlT2JqKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX29ianMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IE9iamVjdC5jcmVhdGUobnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldChvYmpJZCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY2FsbGJhY2sgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2JqID0gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZW5zdXJlT2JqLCBfZW5zdXJlT2JqMikuY2FsbCh0aGlzLCBvYmpJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYmouY2FwYWJpbGl0eS5wcm9taXNlLnRoZW4oKCkgPT4gY2FsbGJhY2sob2JqLmRhdGEpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9iaiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfb2Jqcylbb2JqSWRdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIShvYmogIT09IG51bGwgJiYgb2JqICE9PSB2b2lkIDAgJiYgb2JqLmNhcGFiaWxpdHkuc2V0dGxlZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgUmVxdWVzdGluZyBvYmplY3QgdGhhdCBpc24ndCByZXNvbHZlZCB5ZXQgJHtvYmpJZH0uYCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG9iai5kYXRhOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXMob2JqSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2JqID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vYmpzKVtvYmpJZF07CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAob2JqID09PSBudWxsIHx8IG9iaiA9PT0gdm9pZCAwID8gdm9pZCAwIDogb2JqLmNhcGFiaWxpdHkuc2V0dGxlZCkgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlc29sdmUob2JqSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhdGEgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9iaiA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Vuc3VyZU9iaiwgX2Vuc3VyZU9iajIpLmNhbGwodGhpcywgb2JqSWQpOwogICAgICAgICAgICAgICAgICAgICAgICBvYmouZGF0YSA9IGRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIG9iai5jYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2xlYXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgb2JqSWQgaW4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vYmpzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9kYXRhJGJpdG1hcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vYmpzKVtvYmpJZF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhID09PSBudWxsIHx8IGRhdGEgPT09IHZvaWQgMCA/IHZvaWQgMCA6IChfZGF0YSRiaXRtYXAgPSBkYXRhLmJpdG1hcCkgPT09IG51bGwgfHwgX2RhdGEkYml0bWFwID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfZGF0YSRiaXRtYXAuY2xvc2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX29ianMsIE9iamVjdC5jcmVhdGUobnVsbCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9lbnN1cmVPYmoyKG9iaklkKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2JqID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vYmpzKVtvYmpJZF07CiAgICAgICAgICAgICAgICAgICAgaWYgKG9iaikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gb2JqOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vYmpzKVtvYmpJZF0gPSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHk6ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKSwKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YTogbnVsbAogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBSZW5kZXJUYXNrIHsKICAgICAgICAgICAgICAgICAgICAjaW50ZXJuYWxSZW5kZXJUYXNrID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihpbnRlcm5hbFJlbmRlclRhc2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jaW50ZXJuYWxSZW5kZXJUYXNrID0gaW50ZXJuYWxSZW5kZXJUYXNrOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uQ29udGludWUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJvbWlzZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI2ludGVybmFsUmVuZGVyVGFzay5jYXBhYmlsaXR5LnByb21pc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbmNlbCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGV4dHJhRGVsYXkgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2ludGVybmFsUmVuZGVyVGFzay5jYW5jZWwobnVsbCwgZXh0cmFEZWxheSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBzZXBhcmF0ZUFubm90cygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VwYXJhdGVBbm5vdHMKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuI2ludGVybmFsUmVuZGVyVGFzay5vcGVyYXRvckxpc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc2VwYXJhdGVBbm5vdHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uQ2FudmFzTWFwCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLiNpbnRlcm5hbFJlbmRlclRhc2s7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzZXBhcmF0ZUFubm90cy5mb3JtIHx8IHNlcGFyYXRlQW5ub3RzLmNhbnZhcyAmJiAoYW5ub3RhdGlvbkNhbnZhc01hcCA9PT0gbnVsbCB8fCBhbm5vdGF0aW9uQ2FudmFzTWFwID09PSB2b2lkIDAgPyB2b2lkIDAgOiBhbm5vdGF0aW9uQ2FudmFzTWFwLnNpemUpID4gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlJlbmRlclRhc2sgPSBSZW5kZXJUYXNrOwogICAgICAgICAgICAgICAgY2xhc3MgSW50ZXJuYWxSZW5kZXJUYXNrIHsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgI2NhbnZhc0luVXNlID0gbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihfcmVmMTMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2JqcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1vbk9ianMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uQ2FudmFzTWFwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzRmFjdG9yeSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlckZhY3RvcnksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUgPSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBkZkJ1ZyA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUNvbG9ycyA9IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYxMzsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYWxsYmFjayA9IGNhbGxiYWNrOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmFtcyA9IHBhcmFtczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vYmpzID0gb2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21tb25PYmpzID0gY29tbW9uT2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbm5vdGF0aW9uQ2FudmFzTWFwID0gYW5ub3RhdGlvbkNhbnZhc01hcDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vcGVyYXRvckxpc3RJZHggPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wZXJhdG9yTGlzdCA9IG9wZXJhdG9yTGlzdDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFnZUluZGV4ID0gcGFnZUluZGV4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkgPSBjYW52YXNGYWN0b3J5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbHRlckZhY3RvcnkgPSBmaWx0ZXJGYWN0b3J5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZCdWcgPSBwZGZCdWc7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFnZUNvbG9ycyA9IHBhZ2VDb2xvcnM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucnVubmluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmdyYXBoaWNzUmVhZHlDYWxsYmFjayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JhcGhpY3NSZWFkeSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUgPSB1c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUgPT09IHRydWUgJiYgdHlwZW9mIHdpbmRvdyAhPT0gInVuZGVmaW5lZCI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FuY2VsbGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50YXNrID0gbmV3IFJlbmRlclRhc2sodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhbmNlbEJvdW5kID0gdGhpcy5jYW5jZWwuYmluZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGludWVCb3VuZCA9IHRoaXMuX2NvbnRpbnVlLmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NjaGVkdWxlTmV4dEJvdW5kID0gdGhpcy5fc2NoZWR1bGVOZXh0LmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX25leHRCb3VuZCA9IHRoaXMuX25leHQuYmluZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FudmFzID0gcGFyYW1zLmNhbnZhc0NvbnRleHQuY2FudmFzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgY29tcGxldGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jYXBhYmlsaXR5LnByb21pc2UuY2F0Y2goZnVuY3Rpb24gKCkge30pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpbml0aWFsaXplR3JhcGhpY3MoX3JlZjE0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfZ2xvYmFsVGhpcyRTdGVwcGVyTWEsIF90aGlzJGdyYXBoaWNzUmVhZHlDYTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zcGFyZW5jeSA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uYWxDb250ZW50Q29uZmlnCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMTQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNhbmNlbGxlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9jYW52YXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChJbnRlcm5hbFJlbmRlclRhc2suI2NhbnZhc0luVXNlLmhhcyh0aGlzLl9jYW52YXMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJDYW5ub3QgdXNlIHRoZSBzYW1lIGNhbnZhcyBkdXJpbmcgbXVsdGlwbGUgcmVuZGVyKCkgb3BlcmF0aW9ucy4gIiArICJVc2UgZGlmZmVyZW50IGNhbnZhcyBvciBlbnN1cmUgcHJldmlvdXMgb3BlcmF0aW9ucyB3ZXJlICIgKyAiY2FuY2VsbGVkIG9yIGNvbXBsZXRlZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIEludGVybmFsUmVuZGVyVGFzay4jY2FudmFzSW5Vc2UuYWRkKHRoaXMuX2NhbnZhcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3BkZkJ1ZyAmJiAoX2dsb2JhbFRoaXMkU3RlcHBlck1hID0gZ2xvYmFsVGhpcy5TdGVwcGVyTWFuYWdlcikgIT09IG51bGwgJiYgX2dsb2JhbFRoaXMkU3RlcHBlck1hICE9PSB2b2lkIDAgJiYgX2dsb2JhbFRoaXMkU3RlcHBlck1hLmVuYWJsZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RlcHBlciA9IGdsb2JhbFRoaXMuU3RlcHBlck1hbmFnZXIuY3JlYXRlKHRoaXMuX3BhZ2VJbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0ZXBwZXIuaW5pdCh0aGlzLm9wZXJhdG9yTGlzdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0ZXBwZXIubmV4dEJyZWFrUG9pbnQgPSB0aGlzLnN0ZXBwZXIuZ2V0TmV4dEJyZWFrUG9pbnQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNDb250ZXh0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWNrZ3JvdW5kCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLnBhcmFtczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5nZnggPSBuZXcgX2NhbnZhcy5DYW52YXNHcmFwaGljcyhjYW52YXNDb250ZXh0LCB0aGlzLmNvbW1vbk9ianMsIHRoaXMub2JqcywgdGhpcy5jYW52YXNGYWN0b3J5LCB0aGlzLmZpbHRlckZhY3RvcnksIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbmFsQ29udGVudENvbmZpZwogICAgICAgICAgICAgICAgICAgICAgICB9LCB0aGlzLmFubm90YXRpb25DYW52YXNNYXApOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmdmeC5iZWdpbkRyYXdpbmcoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc3BhcmVuY3ksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiYWNrZ3JvdW5kCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wZXJhdG9yTGlzdElkeCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JhcGhpY3NSZWFkeSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRncmFwaGljc1JlYWR5Q2EgPSB0aGlzLmdyYXBoaWNzUmVhZHlDYWxsYmFjaykgPT09IG51bGwgfHwgX3RoaXMkZ3JhcGhpY3NSZWFkeUNhID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRncmFwaGljc1JlYWR5Q2EuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZ2Z4OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZXJyb3IgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBleHRyYURlbGF5ID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJ1bm5pbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW5jZWxsZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkZ2Z4ID0gdGhpcy5nZngpID09PSBudWxsIHx8IF90aGlzJGdmeCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZ2Z4LmVuZERyYXdpbmcodGhpcy5wYWdlQ29sb3JzKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgSW50ZXJuYWxSZW5kZXJUYXNrLiNjYW52YXNJblVzZS5kZWxldGUodGhpcy5fY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrKGVycm9yIHx8IG5ldyBfZGlzcGxheV91dGlscy5SZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb24oYFJlbmRlcmluZyBjYW5jZWxsZWQsIHBhZ2UgJHt0aGlzLl9wYWdlSW5kZXggKyAxfWAsICJjYW52YXMiLCBleHRyYURlbGF5KSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdENoYW5nZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRzdGVwcGVyOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuZ3JhcGhpY3NSZWFkeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmdyYXBoaWNzUmVhZHlDYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JhcGhpY3NSZWFkeUNhbGxiYWNrID0gdGhpcy5fY29udGludWVCb3VuZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkc3RlcHBlciA9IHRoaXMuc3RlcHBlcikgPT09IG51bGwgfHwgX3RoaXMkc3RlcHBlciA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkc3RlcHBlci51cGRhdGVPcGVyYXRvckxpc3QodGhpcy5vcGVyYXRvckxpc3QpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5ydW5uaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGludWUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NvbnRpbnVlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJ1bm5pbmcgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jYW5jZWxsZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy50YXNrLm9uQ29udGludWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGFzay5vbkNvbnRpbnVlKHRoaXMuX3NjaGVkdWxlTmV4dEJvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NjaGVkdWxlTmV4dCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zY2hlZHVsZU5leHQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl91c2VSZXF1ZXN0QW5pbWF0aW9uRnJhbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpbmRvdy5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUoKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX25leHRCb3VuZCgpLmNhdGNoKHRoaXMuX2NhbmNlbEJvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgUHJvbWlzZS5yZXNvbHZlKCkudGhlbih0aGlzLl9uZXh0Qm91bmQpLmNhdGNoKHRoaXMuX2NhbmNlbEJvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyBfbmV4dCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY2FuY2VsbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vcGVyYXRvckxpc3RJZHggPSB0aGlzLmdmeC5leGVjdXRlT3BlcmF0b3JMaXN0KHRoaXMub3BlcmF0b3JMaXN0LCB0aGlzLm9wZXJhdG9yTGlzdElkeCwgdGhpcy5fY29udGludWVCb3VuZCwgdGhpcy5zdGVwcGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMub3BlcmF0b3JMaXN0SWR4ID09PSB0aGlzLm9wZXJhdG9yTGlzdC5hcmdzQXJyYXkubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJ1bm5pbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLm9wZXJhdG9yTGlzdC5sYXN0Q2h1bmspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmdmeC5lbmREcmF3aW5nKHRoaXMucGFnZUNvbG9ycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2NhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbnRlcm5hbFJlbmRlclRhc2suI2NhbnZhc0luVXNlLmRlbGV0ZSh0aGlzLl9jYW52YXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjb25zdCB2ZXJzaW9uID0gJzMuNS4xMjInOwogICAgICAgICAgICAgICAgZXhwb3J0cy52ZXJzaW9uID0gdmVyc2lvbjsKICAgICAgICAgICAgICAgIGNvbnN0IGJ1aWxkID0gJzYyMjQ2NWRjMic7CiAgICAgICAgICAgICAgICBleHBvcnRzLmJ1aWxkID0gYnVpbGQ7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDEzOSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlByaW50QW5ub3RhdGlvblN0b3JhZ2UgPSBleHBvcnRzLkFubm90YXRpb25TdG9yYWdlID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfZWRpdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDApOwogICAgICAgICAgICAgICAgdmFyIF9tdXJtdXJoYXNoID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDQpOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKG9iaiwgcHJpdmF0ZVNldCkgeyBfY2hlY2tQcml2YXRlUmVkZWNsYXJhdGlvbihvYmosIHByaXZhdGVTZXQpOyBwcml2YXRlU2V0LmFkZChvYmopOyB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyhvYmosIHByaXZhdGVNYXAsIHZhbHVlKSB7IF9jaGVja1ByaXZhdGVSZWRlY2xhcmF0aW9uKG9iaiwgcHJpdmF0ZU1hcCk7IHByaXZhdGVNYXAuc2V0KG9iaiwgdmFsdWUpOyB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbi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ZpZWQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIEFubm90YXRpb25TdG9yYWdlIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRNb2RpZmllZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9tb2RpZmllZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9zdG9yYWdlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgTWFwKCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25TZXRNb2RpZmllZCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25SZXNldE1vZGlmaWVkID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vbkFubm90YXRpb25FZGl0b3IgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRWYWx1ZShrZXksIGRlZmF1bHRWYWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuZ2V0KGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZGVmYXVsdFZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBPYmplY3QuYXNzaWduKGRlZmF1bHRWYWx1ZSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSYXdWYWx1ZShrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuZ2V0KGtleSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbW92ZShrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zdG9yYWdlKS5kZWxldGUoa2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXNldE1vZGlmaWVkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB0aGlzLm9uQW5ub3RhdGlvbkVkaXRvciA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCB2YWx1ZSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3N0b3JhZ2UpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uQW5ub3RhdGlvbkVkaXRvcihudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRWYWx1ZShrZXksIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9iaiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuZ2V0KGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtb2RpZmllZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAob2JqICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2VudHJ5LCB2YWxdIG9mIE9iamVjdC5lbnRyaWVzKHZhbHVlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChvYmpbZW50cnldICE9PSB2YWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9kaWZpZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvYmpbZW50cnldID0gdmFsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGlmaWVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2V0KGtleSwgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtb2RpZmllZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0TW9kaWZpZWQsIF9zZXRNb2RpZmllZDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yICYmIHR5cGVvZiB0aGlzLm9uQW5ub3RhdGlvbkVkaXRvciA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vbkFubm90YXRpb25FZGl0b3IodmFsdWUuY29uc3RydWN0b3IuX3R5cGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhcyhrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuaGFzKGtleSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFsbCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZSA+IDAgPyAoMCwgX3V0aWwub2JqZWN0RnJvbU1hcCkoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zdG9yYWdlKSkgOiBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRBbGwob2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleSwgdmFsXSBvZiBPYmplY3QuZW50cmllcyhvYmopKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFZhbHVlKGtleSwgdmFsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgc2l6ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVzZXRNb2RpZmllZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbW9kaWZpZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX21vZGlmaWVkLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHRoaXMub25SZXNldE1vZGlmaWVkID09PSAiZnVuY3Rpb24iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vblJlc2V0TW9kaWZpZWQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJpbnQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHJpbnRBbm5vdGF0aW9uU3RvcmFnZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHNlcmlhbGl6YWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc3RvcmFnZSkuc2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xvbmUgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleSwgdmFsXSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3N0b3JhZ2UpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzZXJpYWxpemVkID0gdmFsIGluc3RhbmNlb2YgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yID8gdmFsLnNlcmlhbGl6ZSgpIDogdmFsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNlcmlhbGl6ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbG9uZS5zZXQoa2V5LCBzZXJpYWxpemVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xvbmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXRIYXNoKG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIW1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICIiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhhc2ggPSBuZXcgX211cm11cmhhc2guTXVybXVySGFzaDNfNjQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBba2V5LCB2YWxdIG9mIG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzaC51cGRhdGUoYCR7a2V5fToke0pTT04uc3RyaW5naWZ5KHZhbCl9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGhhc2guaGV4ZGlnZXN0KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uU3RvcmFnZSA9IEFubm90YXRpb25TdG9yYWdlOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3NldE1vZGlmaWVkMigpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbW9kaWZpZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfbW9kaWZpZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHRoaXMub25TZXRNb2RpZmllZCA9PT0gImZ1bmN0aW9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vblNldE1vZGlmaWVkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQcmludEFubm90YXRpb25TdG9yYWdlIGV4dGVuZHMgQW5ub3RhdGlvblN0b3JhZ2UgewogICAgICAgICAgICAgICAgICAgICNzZXJpYWxpemFibGUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNzZXJpYWxpemFibGUgPSBzdHJ1Y3R1cmVkQ2xvbmUocGFyZW50LnNlcmlhbGl6YWJsZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwcmludCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiU2hvdWxkIG5vdCBjYWxsIFByaW50QW5ub3RhdGlvblN0b3JhZ2UucHJpbnQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHNlcmlhbGl6YWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI3NlcmlhbGl6YWJsZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlByaW50QW5ub3RhdGlvblN0b3JhZ2UgPSBQcmludEFubm90YXRpb25TdG9yYWdlOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNDAgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF90b29scyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQxKTsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uRWRpdG9yIHsKICAgICAgICAgICAgICAgICAgICAjYm91bmRGb2N1c2luID0gdGhpcy5mb2N1c2luLmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgI2JvdW5kRm9jdXNvdXQgPSB0aGlzLmZvY3Vzb3V0LmJpbmQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgI2hhc0JlZW5TZWxlY3RlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICNpc0VkaXRpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAjaXNJbkVkaXRNb2RlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgX3VpTWFuYWdlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgI3pJbmRleCA9IEFubm90YXRpb25FZGl0b3IuX3pJbmRleCsrOwogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBfY29sb3JNYW5hZ2VyID0gbmV3IF90b29scy5Db2xvck1hbmFnZXIoKTsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgX3pJbmRleCA9IDE7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb25zdHJ1Y3RvciA9PT0gQW5ub3RhdGlvbkVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQW5ub3RhdGlvbkVkaXRvci4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudCA9IHBhcmFtZXRlcnMucGFyZW50OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlkID0gcGFyYW1ldGVycy5pZDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy53aWR0aCA9IHRoaXMuaGVpZ2h0ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlSW5kZXggPSBwYXJhbWV0ZXJzLnBhcmVudC5wYWdlSW5kZXg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmFtZSA9IHBhcmFtZXRlcnMubmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91aU1hbmFnZXIgPSBwYXJhbWV0ZXJzLnVpTWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb24sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByYXdEaW1zOiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VIZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMucGFyZW50LnZpZXdwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJvdGF0aW9uID0gcm90YXRpb247CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFnZURpbWVuc2lvbnMgPSBbcGFnZVdpZHRoLCBwYWdlSGVpZ2h0XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlVHJhbnNsYXRpb24gPSBbcGFnZVgsIHBhZ2VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3dpZHRoLCBoZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnggPSBwYXJhbWV0ZXJzLnggLyB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy55ID0gcGFyYW1ldGVycy55IC8gaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzQXR0YWNoZWRUb0RPTSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgZ2V0IF9kZWZhdWx0TGluZUNvbG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIl9kZWZhdWx0TGluZUNvbG9yIiwgdGhpcy5fY29sb3JNYW5hZ2VyLmdldEhleENvZGUoIkNhbnZhc1RleHQiKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZENvbW1hbmRzKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91aU1hbmFnZXIuYWRkQ29tbWFuZHMocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGN1cnJlbnRMYXllcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3VpTWFuYWdlci5jdXJyZW50TGF5ZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEluQmFja2dyb3VuZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUuekluZGV4ID0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0SW5Gb3JlZ3JvdW5kKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS56SW5kZXggPSB0aGlzLiN6SW5kZXg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFBhcmVudChwYXJlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmVudCAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlSW5kZXggPSBwYXJlbnQucGFnZUluZGV4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWdlRGltZW5zaW9ucyA9IHBhcmVudC5wYWdlRGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudCA9IHBhcmVudDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9jdXNpbihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuI2hhc0JlZW5TZWxlY3RlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0U2VsZWN0ZWQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNoYXNCZWVuU2VsZWN0ZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb2N1c291dChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkcGFyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNBdHRhY2hlZFRvRE9NKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGFyZ2V0ID0gZXZlbnQucmVsYXRlZFRhcmdldDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRhcmdldCAhPT0gbnVsbCAmJiB0YXJnZXQgIT09IHZvaWQgMCAmJiB0YXJnZXQuY2xvc2VzdChgIyR7dGhpcy5pZH1gKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghKChfdGhpcyRwYXJlbnQgPSB0aGlzLnBhcmVudCkgIT09IG51bGwgJiYgX3RoaXMkcGFyZW50ICE9PSB2b2lkIDAgJiYgX3RoaXMkcGFyZW50LmlzTXVsdGlwbGVTZWxlY3Rpb24pKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbW1pdE9yUmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tbWl0T3JSZW1vdmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tbWl0KCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZFRvQW5ub3RhdGlvblN0b3JhZ2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkVG9Bbm5vdGF0aW9uU3RvcmFnZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdWlNYW5hZ2VyLmFkZFRvQW5ub3RhdGlvblN0b3JhZ2UodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRyYWdzdGFydChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWN0ID0gdGhpcy5wYXJlbnQuZGl2LmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YXJ0WCA9IGV2ZW50LmNsaWVudFggLSByZWN0Lng7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhcnRZID0gZXZlbnQuY2xpZW50WSAtIHJlY3QueTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuZGF0YVRyYW5zZmVyLnNldERhdGEoInRleHQvcGxhaW4iLCB0aGlzLmlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuZGF0YVRyYW5zZmVyLmVmZmVjdEFsbG93ZWQgPSAibW92ZSI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEF0KHgsIHksIHR4LCB0eSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbd2lkdGgsIGhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIFt0eCwgdHldID0gdGhpcy5zY3JlZW5Ub1BhZ2VUcmFuc2xhdGlvbih0eCwgdHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnggPSAoeCArIHR4KSAvIHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnkgPSAoeSArIHR5KSAvIGhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUubGVmdCA9IGAkezEwMCAqIHRoaXMueH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUudG9wID0gYCR7MTAwICogdGhpcy55fSVgOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0cmFuc2xhdGUoeCwgeSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbd2lkdGgsIGhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIFt4LCB5XSA9IHRoaXMuc2NyZWVuVG9QYWdlVHJhbnNsYXRpb24oeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCArPSB4IC8gd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueSArPSB5IC8gaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS5sZWZ0ID0gYCR7MTAwICogdGhpcy54fSVgOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS50b3AgPSBgJHsxMDAgKiB0aGlzLnl9JWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNjcmVlblRvUGFnZVRyYW5zbGF0aW9uKHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0aGlzLnBhcmVudFJvdGF0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDkwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeSwgLXhdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxODA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsteCwgLXldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAyNzA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsteSwgeF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeCwgeV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHBhcmVudFNjYWxlKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdWlNYW5hZ2VyLnZpZXdQYXJhbWV0ZXJzLnJlYWxTY2FsZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHBhcmVudFJvdGF0aW9uKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fdWlNYW5hZ2VyLnZpZXdQYXJhbWV0ZXJzLnJvdGF0aW9uOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcGFyZW50RGltZW5zaW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhbFNjYWxlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLl91aU1hbmFnZXIudmlld1BhcmFtZXRlcnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYWdlV2lkdGgsIHBhZ2VIZWlnaHRdID0gdGhpcy5wYWdlRGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtwYWdlV2lkdGggKiByZWFsU2NhbGUsIHBhZ2VIZWlnaHQgKiByZWFsU2NhbGVdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXREaW1zKHdpZHRoLCBoZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS53aWR0aCA9IGAkezEwMCAqIHdpZHRoIC8gcGFyZW50V2lkdGh9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnN0eWxlLmhlaWdodCA9IGAkezEwMCAqIGhlaWdodCAvIHBhcmVudEhlaWdodH0lYDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZml4RGltcygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZGl2OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gc3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoUGVyY2VudCA9IHdpZHRoLmVuZHNXaXRoKCIlIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodFBlcmNlbnQgPSBoZWlnaHQuZW5kc1dpdGgoIiUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoUGVyY2VudCAmJiBoZWlnaHRQZXJjZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXdpZHRoUGVyY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUud2lkdGggPSBgJHsxMDAgKiBwYXJzZUZsb2F0KHdpZHRoKSAvIHBhcmVudFdpZHRofSVgOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaGVpZ2h0UGVyY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUuaGVpZ2h0ID0gYCR7MTAwICogcGFyc2VGbG9hdChoZWlnaHQpIC8gcGFyZW50SGVpZ2h0fSVgOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEluaXRpYWxUcmFuc2xhdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFswLCAwXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zZXRBdHRyaWJ1dGUoImRhdGEtZWRpdG9yLXJvdGF0aW9uIiwgKDM2MCAtIHRoaXMucm90YXRpb24pICUgMzYwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuY2xhc3NOYW1lID0gdGhpcy5uYW1lOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zZXRBdHRyaWJ1dGUoImlkIiwgdGhpcy5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnNldEF0dHJpYnV0ZSgidGFiSW5kZXgiLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRJbkZvcmVncm91bmQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYWRkRXZlbnRMaXN0ZW5lcigiZm9jdXNpbiIsIHRoaXMuI2JvdW5kRm9jdXNpbik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFkZEV2ZW50TGlzdGVuZXIoImZvY3Vzb3V0IiwgdGhpcy4jYm91bmRGb2N1c291dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFt0eCwgdHldID0gdGhpcy5nZXRJbml0aWFsVHJhbnNsYXRpb24oKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2xhdGUodHgsIHR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF90b29scy5iaW5kRXZlbnRzKSh0aGlzLCB0aGlzLmRpdiwgWyJkcmFnc3RhcnQiLCAicG9pbnRlcmRvd24iXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmRpdjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcG9pbnRlcmRvd24oZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNNYWMKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF91dGlsLkZlYXR1cmVUZXN0LnBsYXRmb3JtOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQuYnV0dG9uICE9PSAwIHx8IGV2ZW50LmN0cmxLZXkgJiYgaXNNYWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50LmN0cmxLZXkgJiYgIWlzTWFjIHx8IGV2ZW50LnNoaWZ0S2V5IHx8IGV2ZW50Lm1ldGFLZXkgJiYgaXNNYWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LnRvZ2dsZVNlbGVjdGVkKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0U2VsZWN0ZWQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jaGFzQmVlblNlbGVjdGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UmVjdCh0eCwgdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSB0aGlzLnBhcmVudFNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFnZVdpZHRoLCBwYWdlSGVpZ2h0XSA9IHRoaXMucGFnZURpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYWdlWCwgcGFnZVldID0gdGhpcy5wYWdlVHJhbnNsYXRpb247CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNoaWZ0WCA9IHR4IC8gc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNoaWZ0WSA9IHR5IC8gc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHggPSB0aGlzLnggKiBwYWdlV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHkgPSB0aGlzLnkgKiBwYWdlSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IHRoaXMud2lkdGggKiBwYWdlV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IHRoaXMuaGVpZ2h0ICogcGFnZUhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0aGlzLnJvdGF0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4ICsgc2hpZnRYICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5IC0gc2hpZnRZIC0gaGVpZ2h0ICsgcGFnZVksIHggKyBzaGlmdFggKyB3aWR0aCArIHBhZ2VYLCBwYWdlSGVpZ2h0IC0geSAtIHNoaWZ0WSArIHBhZ2VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgOTA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4ICsgc2hpZnRZICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5ICsgc2hpZnRYICsgcGFnZVksIHggKyBzaGlmdFkgKyBoZWlnaHQgKyBwYWdlWCwgcGFnZUhlaWdodCAtIHkgKyBzaGlmdFggKyB3aWR0aCArIHBhZ2VZXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMTgwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeCAtIHNoaWZ0WCAtIHdpZHRoICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5ICsgc2hpZnRZICsgcGFnZVksIHggLSBzaGlmdFggKyBwYWdlWCwgcGFnZUhlaWdodCAtIHkgKyBzaGlmdFkgKyBoZWlnaHQgKyBwYWdlWV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI3MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3ggLSBzaGlmdFkgLSBoZWlnaHQgKyBwYWdlWCwgcGFnZUhlaWdodCAtIHkgLSBzaGlmdFggLSB3aWR0aCArIHBhZ2VZLCB4IC0gc2hpZnRZICsgcGFnZVgsIHBhZ2VIZWlnaHQgLSB5IC0gc2hpZnRYICsgcGFnZVldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSZWN0SW5DdXJyZW50Q29vcmRzKHJlY3QsIHBhZ2VIZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3gxLCB5MSwgeDIsIHkyXSA9IHJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0geDIgLSB4MTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0geTIgLSB5MTsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0aGlzLnJvdGF0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4MSwgcGFnZUhlaWdodCAtIHkyLCB3aWR0aCwgaGVpZ2h0XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgOTA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFt4MSwgcGFnZUhlaWdodCAtIHkxLCBoZWlnaHQsIHdpZHRoXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMTgwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbeDIsIHBhZ2VIZWlnaHQgLSB5MSwgd2lkdGgsIGhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI3MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3gyLCBwYWdlSGVpZ2h0IC0geTIsIGhlaWdodCwgd2lkdGhdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgcm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBvbmNlQWRkZWQoKSB7fQogICAgICAgICAgICAgICAgICAgIGlzRW1wdHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5hYmxlRWRpdE1vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2lzSW5FZGl0TW9kZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRpc2FibGVFZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jaXNJbkVkaXRNb2RlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzSW5FZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI2lzSW5FZGl0TW9kZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2hvdWxkR2V0S2V5Ym9hcmRFdmVudHMoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgbmVlZHNUb0JlUmVidWlsdCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuZGl2ICYmICF0aGlzLmlzQXR0YWNoZWRUb0RPTTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVidWlsZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGRpdiA9IHRoaXMuZGl2KSA9PT0gbnVsbCB8fCBfdGhpcyRkaXYgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGRpdi5hZGRFdmVudExpc3RlbmVyKCJmb2N1c2luIiwgdGhpcy4jYm91bmRGb2N1c2luKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2VyaWFsaXplKCkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJBbiBlZGl0b3IgbXVzdCBiZSBzZXJpYWxpemFibGUiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGRlc2VyaWFsaXplKGRhdGEsIHBhcmVudCwgdWlNYW5hZ2VyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVkaXRvciA9IG5ldyB0aGlzLnByb3RvdHlwZS5jb25zdHJ1Y3Rvcih7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJlbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZDogcGFyZW50LmdldE5leHRJZCgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdWlNYW5hZ2VyCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iucm90YXRpb24gPSBkYXRhLnJvdGF0aW9uOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFnZVdpZHRoLCBwYWdlSGVpZ2h0XSA9IGVkaXRvci5wYWdlRGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3gsIHksIHdpZHRoLCBoZWlnaHRdID0gZWRpdG9yLmdldFJlY3RJbkN1cnJlbnRDb29yZHMoZGF0YS5yZWN0LCBwYWdlSGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnggPSB4IC8gcGFnZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IueSA9IHkgLyBwYWdlSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iud2lkdGggPSB3aWR0aCAvIHBhZ2VXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmhlaWdodCA9IGhlaWdodCAvIHBhZ2VIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlZGl0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbW92ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYucmVtb3ZlRXZlbnRMaXN0ZW5lcigiZm9jdXNpbiIsIHRoaXMuI2JvdW5kRm9jdXNpbik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnJlbW92ZUV2ZW50TGlzdGVuZXIoImZvY3Vzb3V0IiwgdGhpcy4jYm91bmRGb2N1c291dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQucmVtb3ZlKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZWxlY3QoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRkaXYyOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkZGl2MiA9IHRoaXMuZGl2KSA9PT0gbnVsbCB8fCBfdGhpcyRkaXYyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRkaXYyLmNsYXNzTGlzdC5hZGQoInNlbGVjdGVkRWRpdG9yIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVuc2VsZWN0KCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZGl2MzsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGRpdjMgPSB0aGlzLmRpdikgPT09IG51bGwgfHwgX3RoaXMkZGl2MyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZGl2My5jbGFzc0xpc3QucmVtb3ZlKCJzZWxlY3RlZEVkaXRvciIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGVQYXJhbXModHlwZSwgdmFsdWUpIHt9CiAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUVkaXRpbmcoKSB7fQogICAgICAgICAgICAgICAgICAgIGVuYWJsZUVkaXRpbmcoKSB7fQogICAgICAgICAgICAgICAgICAgIGdldCBwcm9wZXJ0aWVzVG9VcGRhdGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7fTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGNvbnRlbnREaXYoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmRpdjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGlzRWRpdGluZygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI2lzRWRpdGluZzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0IGlzRWRpdGluZyh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNpc0VkaXRpbmcgPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5zZXRTZWxlY3RlZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LnNldEFjdGl2ZUVkaXRvcih0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LnNldEFjdGl2ZUVkaXRvcihudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvciA9IEFubm90YXRpb25FZGl0b3I7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE0MSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLktleWJvYXJkTWFuYWdlciA9IGV4cG9ydHMuQ29tbWFuZE1hbmFnZXIgPSBleHBvcnRzLkNvbG9yTWFuYWdlciA9IGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvclVJTWFuY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dldElkKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYCR7X3V0aWwuQW5ub3RhdGlvbkVkaXRvclByZWZpeH0ke3RoaXMuI2lkKyt9YDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDb21tYW5kTWFuYWdlciB7CiAgICAgICAgICAgICAgICAgICAgI2NvbW1hbmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgI2xvY2tlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICNtYXhTaXplOwogICAgICAgICAgICAgICAgICAgICNwb3NpdGlvbiA9IC0xOwogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbWF4U2l6ZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogMTI4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNtYXhTaXplID0gbWF4U2l6ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuZG8sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUgPSBOYU4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbyA9IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobXVzdEV4ZWMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLiNsb2NrZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzYXZlID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY21kLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5kbywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuI3Bvc2l0aW9uID09PSAtMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuI2NvbW1hbmRzLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kcy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jcG9zaXRpb24gPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jY29tbWFuZHMucHVzaChzYXZlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAob3ZlcndyaXRlSWZTYW1lVHlwZSAmJiB0aGlzLiNjb21tYW5kc1t0aGlzLiNwb3NpdGlvbl0udHlwZSA9PT0gdHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGtlZXBVbmRvKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2F2ZS51bmRvID0gdGhpcy4jY29tbWFuZHNbdGhpcy4jcG9zaXRpb25dLnVuZG87CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kc1t0aGlzLiNwb3NpdGlvbl0gPSBzYXZlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5leHQgPSB0aGlzLiNwb3NpdGlvbiArIDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZXh0ID09PSB0aGlzLiNtYXhTaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kcy5zcGxpY2UoMCwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNwb3NpdGlvbiA9IG5leHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobmV4dCA8IHRoaXMuI2NvbW1hbmRzLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2NvbW1hbmRzLnNwbGljZShuZXh0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNjb21tYW5kcy5wdXNoKHNhdmUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1bmRvKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy4jcG9zaXRpb24gPT09IC0xKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jbG9ja2VkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jY29tbWFuZHNbdGhpcy4jcG9zaXRpb25dLnVuZG8oKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jbG9ja2VkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI3Bvc2l0aW9uIC09IDE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlZG8oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLiNwb3NpdGlvbiA8IHRoaXMuI2NvbW1hbmRzLmxlbmd0aCAtIDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI3Bvc2l0aW9uICs9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNsb2NrZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jY29tbWFuZHNbdGhpcy4jcG9zaXRpb25dLmNtZCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy4jbG9ja2VkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy4jcG9zaXRpb24gIT09IC0xOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG8oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLiNwb3NpdGlvbiA8IHRoaXMuI2NvbW1hbmRzLmxlbmd0aCAtIDE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlc3Ryb3koKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2NvbW1hbmRzID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkNvbW1hbmRNYW5hZ2VyID0gQ29tbWFuZE1hbmFnZXI7CiAgICAgICAgICAgICAgICB2YXIgX3NlcmlhbGl6ZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgY2xhc3MgS2V5Ym9hcmRNYW5hZ2VyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihjYWxsYmFja3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXJpYWxpemUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmJ1ZmZlciA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrcyA9IG5ldyBNYXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbGxLZXlzID0gbmV3IFNldCgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2tleXMsIGNhbGxiYWNrXSBvZiBjYWxsYmFja3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qga2V5IG9mIGtleXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc01hY0tleSA9IGtleS5zdGFydHNXaXRoKCJtYWMrIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzTWFjICYmIGlzTWFjS2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FsbGJhY2tzLnNldChrZXkuc2xpY2UoNCksIGNhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbGxLZXlzLmFkZChrZXkuc3BsaXQoIisiKS5hdCgtMSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIWlzTWFjICYmICFpc01hY0tleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrcy5zZXQoa2V5LCBjYWxsYmFjayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWxsS2V5cy5hZGQoa2V5LnNwbGl0KCIrIikuYXQoLTEpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZXhlYyhzZWxmLCBldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuYWxsS2V5cy5oYXMoZXZlbnQua2V5KSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbGxiYWNrID0gdGhpcy5jYWxsYmFja3MuZ2V0KF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NlcmlhbGl6ZSwgX3NlcmlhbGl6ZTIpLmNhbGwodGhpcywgZXZlbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrLmJpbmQoc2VsZikoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuc3RvcFByb3BhZ2F0aW9uKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5LZXlib2FyZE1hbmFnZXIgPSBLZXlib2FyZE1hbmFnZXI7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2VyaWFsaXplMihldmVudCkgewogICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5hbHRLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaCgiYWx0Iik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5jdHJsS2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYnVmZmVyLnB1c2goImN0cmwiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50Lm1ldGFLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaCgibWV0YSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQuc2hpZnRLZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaCgic2hpZnQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGhpcy5idWZmZXIucHVzaChldmVudC5rZXkpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ciA9IHRoaXMuYnVmZmVyLmpvaW4oIisiKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmJ1ZmZlci5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdHI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDb2xvck1hbmFnZXIgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBfY29sb3JzTWFwcGluZyA9IG5ldyBNYXAoW1siQ2FudmFzVGV4dCIsIFswLCAwLCAwXV0sIFsiQ2FudmFzIiwgWzI1NSwgMjU1LCAyNTVdXV0pOwogICAgICAgICAgICAgICAgICAgIGdldCBfY29sb3JzKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xvcnMgPSBuZXcgTWFwKFtbIkNhbnZhc1RleHQiLCBudWxsXSwgWyJDYW52YXMiLCBudWxsXV0pOwogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q29sb3JWYWx1ZXMpKGNvbG9ycyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiX2NvbG9ycyIsIGNvbG9ycyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnZlcnQoY29sb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmdiID0gKDAsIF9kaXNwbGF5X3V0aWxzLmdldFJHQikoY29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXdpbmRvdy5tYXRjaE1lZGlhKCIoZm9yY2VkLWNvbG9yczogYWN0aXZlKSIpLm1hdGNoZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZ2I7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBbbmFtZSwgUkdCXSBvZiB0aGlzLl9jb2xvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChSR0IuZXZlcnkoKHgsIGkpID0+IHggPT09IHJnYltpXSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gQ29sb3JNYW5hZ2VyLl9jb2xvcnNNYXBwaW5nLmdldChuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmdiOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRIZXhDb2RlKG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmdiID0gdGhpcy5fY29sb3JzLmdldChuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFyZ2IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvciguLi5yZ2IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQ29sb3JNYW5hZ2VyID0gQ29sb3JNYW5hZ2VyOwogICAgICAgICAgICAgICAgdmFyIF9hY3RpdmVFZGl0b3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYWxsRWRpdG9ycyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9hbGxMYXllcnMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYW5ub3RhdGlvblN0b3JhZ2UgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY29tbWFuZE1hbmFnZXIgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY3VycmVudFBhZ2VJbmRleCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9lZGl0b3JUeXBlcyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9lZGl0b3JzVG9SZXNjYWxlID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2V2ZW50QnVzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2lkTWFuYWdlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9pc0VuYWJsZWQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfbW9kZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZWxlY3RlZEVkaXRvcnMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDb3B5ID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kQ3V0ID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kUGFzdGUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRLZXlkb3duID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kT25FZGl0aW5nQWN0aW9uID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kT25QYWdlQ2hhbmdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRPblNjYWxlQ2hhbmdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRPblJvdGF0aW9uQ2hhbmdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfcHJldmlvdXNTdGF0ZXMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfY29udGFpbmVyID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2FkZEtleWJvYXJkTWFuYWdlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfYWRkQ29weVBhc3RlTGlzdGVuZXJzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX3JlbW92ZUNvcHlQYXN0ZUxpc3RlbmVycyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwYXRjaFVwZGF0ZVVJID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2VuYWJsZUFsbCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNhYmxlQWxsID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2FkZEVkaXRvclRvTGF5ZXIgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfaXNFbXB0eSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZWxlY3RFZGl0b3JzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihjb250YWluZXIsIGV2ZW50QnVzLCBhbm5vdGF0aW9uU3RvcmFnZSkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3NlbGVjdEVkaXRvcnMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2lzRW1wdHkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2FkZEVkaXRvclRvTGF5ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2Rpc2FibGVBbGwpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2VuYWJsZUFsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVVSSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3JlbW92ZUNvcHlQYXN0ZUxpc3RlbmVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfYWRkQ29weVBhc3RlTGlzdGVuZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2FkZEtleWJvYXJkTWFuYWdlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hY3RpdmVFZGl0b3IsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hbGxFZGl0b3JzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgTWFwKCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hbGxMYXllcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBNYXAoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2Fubm90YXRpb25TdG9yYWdlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY29tbWFuZE1hbmFnZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBDb21tYW5kTWFuYWdlcigpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY3VycmVudFBhZ2VJbmRleCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2VkaXRvclR5cGVzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZWRpdG9yc1RvUmVzY2FsZSwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbmV3IFNldCgpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZXZlbnRCdXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9pZE1hbmFnZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBJZE1hbmFnZXIoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2lzRW5hYmxlZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9tb2RlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5OT05FCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBuZXcgU2V0KCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZENvcHksIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY29weS5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRDdXQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY3V0LmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZFBhc3RlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLnBhc3RlLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZEtleWRvd24sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMua2V5ZG93bi5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRPbkVkaXRpbmdBY3Rpb24sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMub25FZGl0aW5nQWN0aW9uLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZE9uUGFnZUNoYW5naW5nLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLm9uUGFnZUNoYW5naW5nLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZE9uU2NhbGVDaGFuZ2luZywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5vblNjYWxlQ2hhbmdpbmcuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kT25Sb3RhdGlvbkNoYW5naW5nLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLm9uUm90YXRpb25DaGFuZ2luZy5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcHJldmlvdXNTdGF0ZXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VkaXRpbmc6IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzRW1wdHk6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvOiBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2NvbnRhaW5lciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb250YWluZXIsIGNvbnRhaW5lcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZXZlbnRCdXMsIGV2ZW50QnVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuX29uKCJlZGl0aW5nYWN0aW9uIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZE9uRWRpdGluZ0FjdGlvbikpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb24oInBhZ2VjaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblBhZ2VDaGFuZ2luZykpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb24oInNjYWxlY2hhbmdpbmciLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kT25TY2FsZUNoYW5naW5nKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZXZlbnRCdXMpLl9vbigicm90YXRpb25jaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblJvdGF0aW9uQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9hbm5vdGF0aW9uU3RvcmFnZSwgYW5ub3RhdGlvblN0b3JhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZpZXdQYXJhbWV0ZXJzID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhbFNjYWxlOiBfZGlzcGxheV91dGlscy5QaXhlbHNQZXJJbmNoLlBERl9UT19DU1NfVU5JVFMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbjogMAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb2ZmKCJlZGl0aW5nYWN0aW9uIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZE9uRWRpdGluZ0FjdGlvbikpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2V2ZW50QnVzKS5fb2ZmKCJwYWdlY2hhbmdpbmciLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kT25QYWdlQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuX29mZigic2NhbGVjaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblNjYWxlQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuX29mZigicm90YXRpb25jaGFuZ2luZyIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRPblJvdGF0aW9uQ2hhbmdpbmcpKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBsYXllciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxheWVyLmRlc3Ryb3koKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnNUb1Jlc2NhbGUpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfYWN0aXZlRWRpdG9yLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLmRlc3Ryb3koKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25QYWdlQ2hhbmdpbmcoX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VOdW1iZXIKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYyOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2N1cnJlbnRQYWdlSW5kZXgsIHBhZ2VOdW1iZXIgLSAxKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9jdXNNYWluQ29udGFpbmVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbnRhaW5lcikuZm9jdXMoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkU2hvdWxkUmVzY2FsZShlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzVG9SZXNjYWxlKS5hZGQoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlU2hvdWxkUmVzY2FsZShlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzVG9SZXNjYWxlKS5kZWxldGUoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25TY2FsZUNoYW5naW5nKF9yZWYzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52aWV3UGFyYW1ldGVycy5yZWFsU2NhbGUgPSBzY2FsZSAqIF9kaXNwbGF5X3V0aWxzLlBpeGVsc1BlckluY2guUERGX1RPX0NTU19VTklUUzsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzVG9SZXNjYWxlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLm9uU2NhbGVDaGFuZ2luZygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uUm90YXRpb25DaGFuZ2luZyhfcmVmNCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZXNSb3RhdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52aWV3UGFyYW1ldGVycy5yb3RhdGlvbiA9IHBhZ2VzUm90YXRpb247CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZFRvQW5ub3RhdGlvblN0b3JhZ2UoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZWRpdG9yLmlzRW1wdHkoKSAmJiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Fubm90YXRpb25TdG9yYWdlKSAmJiAhX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbm5vdGF0aW9uU3RvcmFnZSkuaGFzKGVkaXRvci5pZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYW5ub3RhdGlvblN0b3JhZ2UpLnNldFZhbHVlKGVkaXRvci5pZCwgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb3B5KGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWN0aXZlRWRpdG9yKS5jb21taXRPclJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5oYXNTZWxlY3Rpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlZGl0b3JzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFlZGl0b3IuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9ycy5wdXNoKGVkaXRvci5zZXJpYWxpemUoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvcnMubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuY2xpcGJvYXJkRGF0YS5zZXREYXRhKCJhcHBsaWNhdGlvbi9wZGZqcyIsIEpTT04uc3RyaW5naWZ5KGVkaXRvcnMpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3V0KGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29weShldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVsZXRlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhc3RlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnByZXZlbnREZWZhdWx0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhID0gZXZlbnQuY2xpcGJvYXJkRGF0YS5nZXREYXRhKCJhcHBsaWNhdGlvbi9wZGZqcyIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9IEpTT04ucGFyc2UoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhc3RlOiAiJHtleC5tZXNzYWdlfSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGRhdGEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51bnNlbGVjdEFsbCgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsYXllciA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWxsTGF5ZXJzKS5nZXQoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jdXJyZW50UGFnZUluZGV4KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBuZXdFZGl0b3JzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGVzZXJpYWxpemVkRWRpdG9yID0gbGF5ZXIuZGVzZXJpYWxpemUoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWRlc2VyaWFsaXplZEVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld0VkaXRvcnMucHVzaChkZXNlcmlhbGl6ZWRFZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIG5ld0VkaXRvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfYWRkRWRpdG9yVG9MYXllciwgX2FkZEVkaXRvclRvTGF5ZXIyKS5jYWxsKHRoaXMsIGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NlbGVjdEVkaXRvcnMsIF9zZWxlY3RFZGl0b3JzMikuY2FsbCh0aGlzLCBuZXdFZGl0b3JzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bmRvID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIG5ld0VkaXRvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENvbW1hbmRzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdW5kbywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYzogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhc3RlOiAiJHtleC5tZXNzYWdlfSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAga2V5ZG93bihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZ2V0QWN0aXZlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoISgoX3RoaXMkZ2V0QWN0aXZlID0gdGhpcy5nZXRBY3RpdmUoKSkgIT09IG51bGwgJiYgX3RoaXMkZ2V0QWN0aXZlICE9PSB2b2lkIDAgJiYgX3RoaXMkZ2V0QWN0aXZlLnNob3VsZEdldEtleWJvYXJkRXZlbnRzKCkpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBBbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyLl9rZXlib2FyZE1hbmFnZXIuZXhlYyh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25FZGl0aW5nQWN0aW9uKGRldGFpbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKFsidW5kbyIsICJyZWRvIiwgImRlbGV0ZSIsICJzZWxlY3RBbGwiXS5pbmNsdWRlcyhkZXRhaWxzLm5hbWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzW2RldGFpbHMubmFtZV0oKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRFZGl0aW5nU3RhdGUoaXNFZGl0aW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc0VkaXRpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2FkZEtleWJvYXJkTWFuYWdlciwgX2FkZEtleWJvYXJkTWFuYWdlcjIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hZGRDb3B5UGFzdGVMaXN0ZW5lcnMsIF9hZGRDb3B5UGFzdGVMaXN0ZW5lcnMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzRWRpdGluZzogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9tb2RlKSAhPT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuTk9ORSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VtcHR5OiBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9pc0VtcHR5LCBfaXNFbXB0eTIpLmNhbGwodGhpcyksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvOiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbW1hbmRNYW5hZ2VyKS5oYXNTb21ldGhpbmdUb1VuZG8oKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLmhhc1NvbWV0aGluZ1RvUmVkbygpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIsIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVtb3ZlQ29weVBhc3RlTGlzdGVuZXJzLCBfcmVtb3ZlQ29weVBhc3RlTGlzdGVuZXJzMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VkaXRpbmc6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZWdpc3RlckVkaXRvclR5cGVzKHR5cGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvclR5cGVzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZWRpdG9yVHlwZXMsIHR5cGVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3JUeXBlIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9yVHlwZXMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVVJLCBfZGlzcGF0Y2hVcGRhdGVVSTIpLmNhbGwodGhpcywgZWRpdG9yVHlwZS5kZWZhdWx0UHJvcGVydGllc1RvVXBkYXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRJZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaWRNYW5hZ2VyKS5nZXRJZCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgY3VycmVudExheWVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxMYXllcnMpLmdldChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2N1cnJlbnRQYWdlSW5kZXgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGN1cnJlbnRQYWdlSW5kZXgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2N1cnJlbnRQYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRMYXllcihsYXllcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuc2V0KGxheWVyLnBhZ2VJbmRleCwgbGF5ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0VuYWJsZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllci5lbmFibGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxheWVyLmRpc2FibGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW1vdmVMYXllcihsYXllcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuZGVsZXRlKGxheWVyLnBhZ2VJbmRleCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZU1vZGUobW9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX21vZGUsIG1vZGUpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuTk9ORSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRFZGl0aW5nU3RhdGUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzYWJsZUFsbCwgX2Rpc2FibGVBbGwyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRFZGl0aW5nU3RhdGUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9lbmFibGVBbGwsIF9lbmFibGVBbGwyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBsYXllciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllci51cGRhdGVNb2RlKG1vZGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZVRvb2xiYXIobW9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9tb2RlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZXZlbnRCdXMpLmRpc3BhdGNoKCJzd2l0Y2hhbm5vdGF0aW9uZWRpdG9ybW9kZSIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZVBhcmFtcyh0eXBlLCB2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9yVHlwZXMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IudXBkYXRlUGFyYW1zKHR5cGUsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvclR5cGUgb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JUeXBlcykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvclR5cGUudXBkYXRlRGVmYXVsdFBhcmFtcyh0eXBlLCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RWRpdG9ycyhwYWdlSW5kZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9ycyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbEVkaXRvcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLnBhZ2VJbmRleCA9PT0gcGFnZUluZGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9ycy5wdXNoKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGVkaXRvcnM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEVkaXRvcihpZCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5nZXQoaWQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRFZGl0b3IoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWxsRWRpdG9ycykuc2V0KGVkaXRvci5pZCwgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlRWRpdG9yKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5kZWxldGUoZWRpdG9yLmlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51bnNlbGVjdChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYW5ub3RhdGlvblN0b3JhZ2UpKSA9PT0gbnVsbCB8fCBfY2xhc3NQcml2YXRlRmllbGRHZXQyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfY2xhc3NQcml2YXRlRmllbGRHZXQyLnJlbW92ZShlZGl0b3IuaWQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRBY3RpdmVFZGl0b3IoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikgPT09IGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfYWN0aXZlRWRpdG9yLCBlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVVJLCBfZGlzcGF0Y2hVcGRhdGVVSTIpLmNhbGwodGhpcywgZWRpdG9yLnByb3BlcnRpZXNUb1VwZGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdG9nZ2xlU2VsZWN0ZWQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykuaGFzKGVkaXRvcikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5kZWxldGUoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiB0aGlzLmhhc1NlbGVjdGlvbgogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2VsZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlVUksIF9kaXNwYXRjaFVwZGF0ZVVJMikuY2FsbCh0aGlzLCBlZGl0b3IucHJvcGVydGllc1RvVXBkYXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU2VsZWN0ZWRFZGl0b3I6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFNlbGVjdGVkKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVkICE9PSBlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZC51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykuYWRkKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5zZWxlY3QoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVVSSwgX2Rpc3BhdGNoVXBkYXRlVUkyKS5jYWxsKHRoaXMsIGVkaXRvci5wcm9wZXJ0aWVzVG9VcGRhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTZWxlY3RlZEVkaXRvcjogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNTZWxlY3RlZChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5oYXMoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdW5zZWxlY3QoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykuZGVsZXRlKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NlbGVjdGVkRWRpdG9yOiB0aGlzLmhhc1NlbGVjdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGhhc1NlbGVjdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5zaXplICE9PSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1bmRvKCkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbW1hbmRNYW5hZ2VyKS51bmRvKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhhc1NvbWV0aGluZ1RvVW5kbzogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb21tYW5kTWFuYWdlcikuaGFzU29tZXRoaW5nVG9VbmRvKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0VtcHR5OiBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9pc0VtcHR5LCBfaXNFbXB0eTIpLmNhbGwodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlZG8oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLnJlZG8oKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZGlzcGF0Y2hVcGRhdGVTdGF0ZXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlczIpLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9VbmRvOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGFzU29tZXRoaW5nVG9SZWRvOiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbW1hbmRNYW5hZ2VyKS5oYXNTb21ldGhpbmdUb1JlZG8oKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzRW1wdHk6IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2lzRW1wdHksIF9pc0VtcHR5MikuY2FsbCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkQ29tbWFuZHMocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29tbWFuZE1hbmFnZXIpLmFkZChwYXJhbXMpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1VuZG86IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTb21ldGhpbmdUb1JlZG86IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNFbXB0eTogX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfaXNFbXB0eSwgX2lzRW1wdHkyKS5jYWxsKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZWxldGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmhhc1NlbGVjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVkaXRvcnMgPSBbLi4uX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgZWRpdG9ycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdW5kbyA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIGVkaXRvcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hZGRFZGl0b3JUb0xheWVyLCBfYWRkRWRpdG9yVG9MYXllcjIpLmNhbGwodGhpcywgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRDb21tYW5kcyh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bmRvLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbW1pdE9yUmVtb3ZlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MzsKICAgICAgICAgICAgICAgICAgICAgICAgKF9jbGFzc1ByaXZhdGVGaWVsZEdldDMgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikpID09PSBudWxsIHx8IF9jbGFzc1ByaXZhdGVGaWVsZEdldDMgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9jbGFzc1ByaXZhdGVGaWVsZEdldDMuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2VsZWN0QWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5jb21taXQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZWxlY3RFZGl0b3JzLCBfc2VsZWN0RWRpdG9yczIpLmNhbGwodGhpcywgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS52YWx1ZXMoKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVuc2VsZWN0QWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hY3RpdmVFZGl0b3IpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjdGl2ZUVkaXRvcikuY29tbWl0T3JSZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLnNpemUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3NlbGVjdGVkRWRpdG9ycykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci51bnNlbGVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfc2VsZWN0ZWRFZGl0b3JzKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kaXNwYXRjaFVwZGF0ZVN0YXRlcywgX2Rpc3BhdGNoVXBkYXRlU3RhdGVzMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNTZWxlY3RlZEVkaXRvcjogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzQWN0aXZlKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hY3RpdmVFZGl0b3IpID09PSBlZGl0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFjdGl2ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWN0aXZlRWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfbW9kZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyID0gQW5ub3RhdGlvbkVkaXRvclVJTWFuYWdlcjsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9hZGRLZXlib2FyZE1hbmFnZXIyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29udGFpbmVyKS5hZGRFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEtleWRvd24pKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9yZW1vdmVLZXlib2FyZE1hbmFnZXIyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29udGFpbmVyKS5yZW1vdmVFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEtleWRvd24pKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9hZGRDb3B5UGFzdGVMaXN0ZW5lcnMyKCkgewogICAgICAgICAgICAgICAgICAgIGRvY3VtZW50LmFkZEV2ZW50TGlzdGVuZXIoImNvcHkiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kQ29weSkpOwogICAgICAgICAgICAgICAgICAgIGRvY3VtZW50LmFkZEV2ZW50TGlzdGVuZXIoImN1dCIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY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gICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZXZlbnRCdXMpLmRpc3BhdGNoKCJhbm5vdGF0aW9uZWRpdG9yc3RhdGVzY2hhbmdlZCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbHM6IE9iamVjdC5hc3NpZ24oX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9wcmV2aW91c1N0YXRlcyksIGRldGFpbHMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9kaXNwYXRjaFVwZGF0ZVVJMihkZXRhaWxzKSB7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ldmVudEJ1cykuZGlzcGF0Y2goImFubm90YXRpb25lZGl0b3JwYXJhbXNjaGFuZ2VkIiwgewogICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbHMKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9lbmFibGVBbGwyKCkgewogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0VuYWJsZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaXNFbmFibGVkLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBsYXllciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxheWVyLmVuYWJsZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2Rpc2FibGVBbGwyKCkgewogICAgICAgICAgICAgICAgICAgIHRoaXMudW5zZWxlY3RBbGwoKTsKICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0VuYWJsZWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaXNFbmFibGVkLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbGF5ZXIgb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxMYXllcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllci5kaXNhYmxlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfYWRkRWRpdG9yVG9MYXllcjIoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGF5ZXIgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbExheWVycykuZ2V0KGVkaXRvci5wYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgICAgIGlmIChsYXllcikgewogICAgICAgICAgICAgICAgICAgICAgICBsYXllci5hZGRPclJlYnVpbGQoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZEVkaXRvcihlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9pc0VtcHR5MigpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5zaXplID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hbGxFZGl0b3JzKS5zaXplID09PSAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWxsRWRpdG9ycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlZGl0b3IuaXNFbXB0eSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9zZWxlY3RFZGl0b3JzMihlZGl0b3JzKSB7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgZWRpdG9ycykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9zZWxlY3RlZEVkaXRvcnMpLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgIC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vcnRzLmdldEN1cnJlbnRUcmFuc2Zvcm1JbnZlcnNlID0gZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2U7CiAgICAgICAgICAgICAgICBleHBvcnRzLmdldEZpbGVuYW1lRnJvbVVybCA9IGdldEZpbGVuYW1lRnJvbVVybDsKICAgICAgICAgICAgICAgIGV4cG9ydHMuZ2V0UGRmRmlsZW5hbWVGcm9tVXJsID0gZ2V0UGRmRmlsZW5hbWVGcm9tVXJsOwogICAgICAgICAgICAgICAgZXhwb3J0cy5nZXRSR0IgPSBnZXRSR0I7CiAgICAgICAgICAgICAgICBleHBvcnRzLmdldFhmYVBhZ2VWaWV3cG9ydCA9IGdldFhmYVBhZ2VWaWV3cG9ydDsKICAgICAgICAgICAgICAgIGV4cG9ydHMuaXNEYXRhU2NoZW1lID0gaXNEYXRhU2NoZW1lOwogICAgICAgICAgICAgICAgZXhwb3J0cy5pc1BkZkZpbGUgPSBpc1BkZkZpbGU7CiAgICAgICAgICAgICAgICBleHBvcnRzLmlzVmFsaWRGZXRjaFVybCA9IGlzVmFsaWRGZXRjaFVybDsKICAgICAgICAgICAgICAgIGV4cG9ydHMubG9hZFNjcmlwdCA9IGxvYWRTY3JpcHQ7CiAgICAgICAgICAgICAgICBleHBvcnRzLnNldExheWVyRGltZW5zaW9ucyA9IHNldExheWVyRGltZW5zaW9uczsKICAgICAgICAgICAgICAgIHZhciBfYmFzZV9mYWN0b3J5ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDMpOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyhvYmosIHByaXZhdGVTZXQpIHsgX2NoZWNrUHJpdmF0ZVJlZGVjbGFyYXRpb24ob2JqLCBwcml2YXRlU2V0KTsgcHJpdmF0ZVNldC5hZGQob2JqKTsgfQogICAgICAgICAgICAgICAg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mlwdG9yLnZhbHVlID0gdmFsdWU7IH0gfQogICAgICAgICAgICAgICAgY29uc3QgU1ZHX05TID0gImh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIjsKICAgICAgICAgICAgICAgIGNvbnN0IEFubm90YXRpb25QcmVmaXggPSAicGRmanNfaW50ZXJuYWxfaWRfIjsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvblByZWZpeCA9IEFubm90YXRpb25QcmVmaXg7CiAgICAgICAgICAgICAgICBjbGFzcyBQaXhlbHNQZXJJbmNoIHsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgQ1NTID0gOTYuMDsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgUERGID0gNzIuMDsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgUERGX1RPX0NTU19VTklUUyA9IHRoaXMuQ1NTIC8gdGhpcy5QREY7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBpeGVsc1BlckluY2ggPSBQaXhlbHNQZXJJbmNoOwogICAgICAgICAgICAgICAgdmFyIF9jYWNoZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9kZWZzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2RvY0lkID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2RvY3VtZW50ID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2hjbUZpbHRlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9oY21LZXkgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfaGNtVXJsID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2lkID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2NhY2hlMiA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9kZWZzMiA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9hcHBlbmRGZUZ1bmMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIERPTUZpbHRlckZhY3RvcnkgZXh0ZW5kcyBfYmFzZV9mYWN0b3J5LkJhc2VGaWx0ZXJGYWN0b3J5IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvY0lkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3duZXJEb2N1bWVudCA9IGdsb2JhbFRoaXMuZG9jdW1lbnQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfYXBwZW5kRmVGdW5jKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2RlZnMyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXQ6IF9nZXRfZGVmcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldDogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY2FjaGUyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXQ6IF9nZXRfY2FjaGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXQ6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2NhY2hlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9kZWZzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9kb2NJZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZG9jdW1lbnQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2hjbUZpbHRlciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfaGNtS2V5LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9oY21VcmwsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2lkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2RvY0lkLCBkb2NJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZG9jdW1lbnQsIG93bmVyRG9jdW1lbnQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRGaWx0ZXIobWFwcykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkaWQsIF90aGlzJGlkMjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFtYXBzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gIm5vbmUiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2YWx1ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUyKS5nZXQobWFwcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0YWJsZVIsIHRhYmxlRywgdGFibGVCLCBrZXk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXBzLmxlbmd0aCA9PT0gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFwUiA9IG1hcHNbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBuZXcgQXJyYXkoMjU2KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgMjU2OyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBidWZmZXJbaV0gPSBtYXBSW2ldIC8gMjU1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAga2V5ID0gdGFibGVSID0gdGFibGVHID0gdGFibGVCID0gYnVmZmVyLmpvaW4oIiwiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFttYXBSLCBtYXBHLCBtYXBCXSA9IG1hcHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXJSID0gbmV3IEFycmF5KDI1Nik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXJHID0gbmV3IEFycmF5KDI1Nik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXJCID0gbmV3IEFycmF5KDI1Nik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI1NjsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyUltpXSA9IG1hcFJbaV0gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyR1tpXSA9IG1hcEdbaV0gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyQltpXSA9IG1hcEJbaV0gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YWJsZVIgPSBidWZmZXJSLmpvaW4oIiwiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhYmxlRyA9IGJ1ZmZlckcuam9pbigiLCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFibGVCID0gYnVmZmVyQi5qb2luKCIsIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrZXkgPSBgJHt0YWJsZVJ9JHt0YWJsZUd9JHt0YWJsZUJ9YDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUyKS5nZXQoa2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlMikuc2V0KG1hcHMsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IGBnXyR7X2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kb2NJZCl9X3RyYW5zZmVyX21hcF8keyhfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2lkLCAoX3RoaXMkaWQgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2lkKSwgX3RoaXMkaWQyID0gX3RoaXMkaWQrKywgX3RoaXMkaWQpKSwgX3RoaXMkaWQyKX1gOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBgdXJsKCMke2lkfSlgOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlMikuc2V0KG1hcHMsIHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUyKS5zZXQoa2V5LCB1cmwpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWx0ZXIgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZmlsdGVyIiwgU1ZHX05TKTsKICAgICAgICAgICAgICAgICAgICAgICAgZmlsdGVyLnNldEF0dHJpYnV0ZSgiaWQiLCBpZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlci5zZXRBdHRyaWJ1dGUoImNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycyIsICJzUkdCIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZlQ29tcG9uZW50VHJhbnNmZXIgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZmVDb21wb25lbnRUcmFuc2ZlciIpOwogICAgICAgICAgICAgICAgICAgICAgICBmaWx0ZXIuYXBwZW5kKGZlQ29tcG9uZW50VHJhbnNmZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hcHBlbmRGZUZ1bmMsIF9hcHBlbmRGZUZ1bmMyKS5jYWxsKHRoaXMsIGZlQ29tcG9uZW50VHJhbnNmZXIsICJmZUZ1bmNSIiwgdGFibGVSKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfYXBwZW5kRmVGdW5jLCBfYXBwZW5kRmVGdW5jMikuY2FsbCh0aGlzLCBmZUNvbXBvbmVudFRyYW5zZmVyLCAiZmVGdW5jRyIsIHRhYmxlRyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2FwcGVuZEZlRnVuYywgX2FwcGVuZEZlRnVuYzIpLmNhbGwodGhpcywgZmVDb21wb25lbnRUcmFuc2ZlciwgImZlRnVuY0IiLCB0YWJsZUIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMyKS5hcHBlbmQoZmlsdGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVybDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkSENNRmlsdGVyKGZnQ29sb3IsIGJnQ29sb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9jbGFzc1ByaXZhdGVGaWVsZEdldDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGtleSA9IGAke2ZnQ29sb3J9LSR7YmdDb2xvcn1gOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oY21LZXkpID09PSBrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2hjbVVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9oY21LZXksIGtleSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGNtVXJsLCAibm9uZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaGNtRmlsdGVyKSkgPT09IG51bGwgfHwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0Mi5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFmZ0NvbG9yIHx8ICFiZ0NvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oY21VcmwpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVmczIpLnN0eWxlLmNvbG9yID0gZmdDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgZmdDb2xvciA9IGdldENvbXB1dGVkU3R5bGUoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kZWZzMikpLmdldFByb3BlcnR5VmFsdWUoImNvbG9yIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZnUkdCID0gZ2V0UkdCKGZnQ29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBmZ0NvbG9yID0gX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IoLi4uZmdSR0IpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMyKS5zdHlsZS5jb2xvciA9IGJnQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIGJnQ29sb3IgPSBnZXRDb21wdXRlZFN0eWxlKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVmczIpKS5nZXRQcm9wZXJ0eVZhbHVlKCJjb2xvciIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiZ1JHQiA9IGdldFJHQihiZ0NvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgYmdDb2xvciA9IF91dGlsLlV0aWwubWFrZUhleENvbG9yKC4uLmJnUkdCKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kZWZzMikuc3R5bGUuY29sb3IgPSAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZnQ29sb3IgPT09ICIjMDAwMDAwIiAmJiBiZ0NvbG9yID09PSAiI2ZmZmZmZiIgfHwgZmdDb2xvciA9PT0gYmdDb2xvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaGNtVXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXAgPSBuZXcgQXJyYXkoMjU2KTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPD0gMjU1OyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHggPSBpIC8gMjU1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwW2ldID0geCA8PSAwLjAzOTI4ID8geCAvIDEyLjkyIDogKCh4ICsgMC4wNTUpIC8gMS4wNTUpICoqIDIuNDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0YWJsZSA9IG1hcC5qb2luKCIsIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gYGdfJHtfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY0lkKX1faGNtX2ZpbHRlcmA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpbHRlciA9IF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGNtRmlsdGVyLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZmlsdGVyIiwgU1ZHX05TKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlci5zZXRBdHRyaWJ1dGUoImlkIiwgaWQpOwogICAgICAgICAgICAgICAgICAgICAgICBmaWx0ZXIuc2V0QXR0cmlidXRlKCJjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnMiLCAic1JHQiIpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZmVDb21wb25lbnRUcmFuc2ZlciA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZG9jdW1lbnQpLmNyZWF0ZUVsZW1lbnROUyhTVkdfTlMsICJmZUNvbXBvbmVudFRyYW5zZmVyIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbHRlci5hcHBlbmQoZmVDb21wb25lbnRUcmFuc2Zlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2FwcGVuZEZlRnVuYywgX2FwcGVuZEZlRnVuYzIpLmNhbGwodGhpcywgZmVDb21wb25lbnRUcmFuc2ZlciwgImZlRnVuY1IiLCB0YWJsZSk7CiAgICAgICAgICA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cmFuc2Zlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdldFN0ZXBzID0gKGMsIG4pID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0YXJ0ID0gZmdSR0JbY10gLyAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmQgPSBiZ1JHQltjXSAvIDI1NTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyciA9IG5ldyBBcnJheShuICsgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8PSBuOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcnJbaV0gPSBzdGFydCArIGkgLyBuICogKGVuZCAtIHN0YXJ0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcnIuam9pbigiLCIpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hcHBlbmRGZUZ1bmMsIF9hcHBlbmRGZUZ1bmMyKS5jYWxsKHRoaXMsIGZlQ29tcG9uZW50VHJhbnNmZXIsICJmZUZ1bmNSIiwgZ2V0U3RlcHMoMCwgNSkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hcHBlbmRGZUZ1bmMsIF9hcHBlbmRGZUZ1bmMyKS5jYWxsKHRoaXMsIGZlQ29tcG9uZW50VHJhbnNmZXIsICJmZUZ1bmNHIiwgZ2V0U3RlcHMoMSwgNSkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9hcHBlbmRGZUZ1bmMsIF9hcHBlbmRGZUZ1bmMyKS5jYWxsKHRoaXMsIGZlQ29tcG9uZW50VHJhbnNmZXIsICJmZUZ1bmNCIiwgZ2V0U3RlcHMoMiwgNSkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMyKS5hcHBlbmQoZmlsdGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9oY21VcmwsIGB1cmwoIyR7aWR9KWApOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oY21VcmwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQga2VlcEhDTSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChrZWVwSENNICYmIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaGNtVXJsKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMpLnBhcmVudE5vZGUucGFyZW50Tm9kZS5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfZGVmcywgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlKS5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jYWNoZSwgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9pZCwgMCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5ET01GaWx0ZXJGYWN0b3J5ID0gRE9NRmlsdGVyRmFjdG9yeTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9nZXRfY2FjaGUoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2FjaGUpIHx8IF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfY2FjaGUsIG5ldyBNYXAoKSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZ2V0X2RlZnMoKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RlZnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRpdiA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZG9jdW1lbnQpLmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gZGl2OwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLmNvbnRhaW4gPSAic3RyaWN0IjsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUud2lkdGggPSBzdHlsZS5oZWlnaHQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5wb3NpdGlvbiA9ICJhYnNvbHV0ZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLnRvcCA9IHN0eWxlLmxlZnQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS56SW5kZXggPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ZnID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kb2N1bWVudCkuY3JlYXRlRWxlbWVudE5TKFNWR19OUywgInN2ZyIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuc2V0QXR0cmlidXRlKCJ3aWR0aCIsIDApOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuc2V0QXR0cmlidXRlKCJoZWlnaHQiLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9kZWZzLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5jcmVhdGVFbGVtZW50TlMoU1ZHX05TLCAiZGVmcyIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LmFwcGVuZChzdmcpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuYXBwZW5kKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGVmcykpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2RvY3VtZW50KS5ib2R5LmFwcGVuZChkaXYpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kZWZzKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9hcHBlbmRGZUZ1bmMyKGZlQ29tcG9uZW50VHJhbnNmZXIsIGZ1bmMsIHRhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZmVGdW5jID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kb2N1bWVudCkuY3JlYXRlRWxlbWVudE5TKFNWR19OUywgZnVuYyk7CiAgICAgICAgICAgICAgICAgICAgZmVGdW5jLnNldEF0dHJpYnV0ZSgidHlwZSIsICJkaXNjcmV0ZSIpOwogICAgICAgICAgICAgICAgICAgIGZlRnVuYy5zZXRBdHRyaWJ1dGUoInRhYmxlVmFsdWVzIiwgdGFibGUpOwogICAgICAgICAgICAgICAgICAgIGZlQ29tcG9uZW50VHJhbnNmZXIuYXBwZW5kKGZlRnVuYyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBET01DYW52YXNGYWN0b3J5IGV4dGVuZHMgX2Jhc2VfZmFjdG9yeS5CYXNlQ2FudmFzRmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvd25lckRvY3VtZW50ID0gZ2xvYmFsVGhpcy5kb2N1bWVudAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9jdW1lbnQgPSBvd25lckRvY3VtZW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY3JlYXRlQ2FudmFzKHdpZHRoLCBoZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FudmFzID0gdGhpcy5fZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiY2FudmFzIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcy53aWR0aCA9IHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjYW52YXMuaGVpZ2h0ID0gaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FudmFzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRE9NQ2FudmFzRmFjdG9yeSA9IERPTUNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICBhc3luYyBmdW5jdGlvbiBmZXRjaERhdGEodXJsKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IGFzVHlwZWRBcnJheSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzVmFsaWRGZXRjaFVybCh1cmwsIGRvY3VtZW50LmJhc2VVUkkpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlc3BvbnNlID0gYXdhaXQgZmV0Y2godXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFyZXNwb25zZS5vaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKHJlc3BvbnNlLnN0YXR1c1RleHQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhc1R5cGVkQXJyYXkgPyBuZXcgVWludDhBcnJheShhd2FpdCByZXNwb25zZS5hcnJheUJ1ZmZlcigpKSA6ICgwLCBfdXRpbC5zdHJpbmdUb0J5dGVzKShhd2FpdCByZXNwb25zZS50ZXh0KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFByb21pc2UoKHJlc29sdmUsIHJlamVjdCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0ID0gbmV3IFhNTEh0dHBSZXF1ZXN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3Qub3BlbigiR0VUIiwgdXJsLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFzVHlwZWRBcnJheSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdC5yZXNwb25zZVR5cGUgPSAiYXJyYXlidWZmZXIiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3Qub25yZWFkeXN0YXRlY2hhbmdlID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlcXVlc3QucmVhZHlTdGF0ZSAhPT0gWE1MSHR0cFJlcXVlc3QuRE9ORSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXF1ZXN0LnN0YXR1cyA9PT0gMjAwIHx8IHJlcXVlc3Quc3RhdHVzID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFzVHlwZWRBcnJheSAmJiByZXF1ZXN0LnJlc3BvbnNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEgPSBuZXcgVWludDhBcnJheShyZXF1ZXN0LnJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKCFhc1R5cGVkQXJyYXkgJiYgcmVxdWVzdC5yZXNwb25zZVRleHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9ICgwLCBfdXRpbC5zdHJpbmdUb0J5dGVzKShyZXF1ZXN0LnJlc3BvbnNlVGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWplY3QobmV3IEVycm9yKHJlcXVlc3Quc3RhdHVzVGV4dCkpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0LnNlbmQobnVsbCk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBET01DTWFwUmVhZGVyRmFjdG9yeSBleHRlbmRzIF9iYXNlX2ZhY3RvcnkuQmFzZUNNYXBSZWFkZXJGYWN0b3J5IHsKICAgICAgICAgICAgICAgICAgICBfZmV0Y2hEYXRhKHVybCwgY29tcHJlc3Npb25UeXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmZXRjaERhdGEodXJsLCB0aGlzLmlzQ29tcHJlc3NlZCkudGhlbihkYXRhID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY01hcERhdGE6IGRhdGEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tcHJlc3Npb25UeXBlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkRPTUNNYXBSZWFkZXJGYWN0b3J5ID0gRE9NQ01hcFJlYWRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBET01TdGFuZGFyZEZvbnREYXRhRmFjdG9yeSBleHRlbmRzIF9iYXNlX2ZhY3RvcnkuQmFzZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5IHsKICAgICAgICAgICAgICAgICAgICBfZmV0Y2hEYXRhKHVybCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmV0Y2hEYXRhKHVybCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5ET01TdGFuZGFyZEZvbnREYXRhRmFjdG9yeSA9IERPTVN0YW5kYXJkRm9udERhdGFGYWN0b3J5OwogICAgICAgICAgICAgICAgY2xhc3MgRE9NU1ZHRmFjdG9yeSBleHRlbmRzIF9iYXNlX2ZhY3RvcnkuQmFzZVNWR0ZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIF9jcmVhdGVTVkcodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZG9jdW1lbnQuY3JlYXRlRWxlbWVudE5TKFNWR19OUywgdHlwZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5ET01TVkdGYWN0b3J5ID0gRE9NU1ZHRmFjdG9yeTsKICAgICAgICAgICAgICAgIGNsYXNzIFBhZ2VWaWV3cG9ydCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoX3JlZikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld0JveCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb24sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRYID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFkgPSAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9udEZsaXAgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52aWV3Qm94ID0gdmlld0JveDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zY2FsZSA9IHNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJvdGF0aW9uID0gcm90YXRpb247CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub2Zmc2V0WCA9IG9mZnNldFg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub2Zmc2V0WSA9IG9mZnNldFk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNlbnRlclggPSAodmlld0JveFsyXSArIHZpZXdCb3hbMF0pIC8gMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2VudGVyWSA9ICh2aWV3Qm94WzNdICsgdmlld0JveFsxXSkgLyAyOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcm90YXRlQSwgcm90YXRlQiwgcm90YXRlQywgcm90YXRlRDsKICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb24gJT0gMzYwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocm90YXRpb24gPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbiArPSAzNjA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChyb3RhdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxODA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlQSA9IC0xOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0ZUIgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0ZUMgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0ZUQgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSA5MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVBID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVCID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVDID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVEID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgMjcwOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0ZUEgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0ZUIgPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVDID0gLTE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlRCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlQSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlQiA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlQyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRlRCA9IC0xOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIlBhZ2VWaWV3cG9ydDogSW52YWxpZCByb3RhdGlvbiwgbXVzdCBiZSBhIG11bHRpcGxlIG9mIDkwIGRlZ3JlZXMuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRvbnRGbGlwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVDID0gLXJvdGF0ZUM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGVEID0gLXJvdGF0ZUQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG9mZnNldENhbnZhc1gsIG9mZnNldENhbnZhc1k7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB3aWR0aCwgaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocm90YXRlQSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0Q2FudmFzWCA9IE1hdGguYWJzKGNlbnRlclkgLSB2aWV3Qm94WzFdKSAqIHNjYWxlICsgb2Zmc2V0WDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldENhbnZhc1kgPSBNYXRoLmFicyhjZW50ZXJYIC0gdmlld0JveFswXSkgKiBzY2FsZSArIG9mZnNldFk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCA9ICh2aWV3Qm94WzNdIC0gdmlld0JveFsxXSkgKiBzY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodCA9ICh2aWV3Qm94WzJdIC0gdmlld0JveFswXSkgKiBzY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldENhbnZhc1ggPSBNYXRoLmFicyhjZW50ZXJYIC0gdmlld0JveFswXSkgKiBzY2FsZSArIG9mZnNldFg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRDYW52YXNZID0gTWF0aC5hYnMoY2VudGVyWSAtIHZpZXdCb3hbMV0pICogc2NhbGUgKyBvZmZzZXRZOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGggPSAodmlld0JveFsyXSAtIHZpZXdCb3hbMF0pICogc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQgPSAodmlld0JveFszXSAtIHZpZXdCb3hbMV0pICogc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm0gPSBbcm90YXRlQSAqIHNjYWxlLCByb3RhdGVCICogc2NhbGUsIHJvdGF0ZUMgKiBzY2FsZSwgcm90YXRlRCAqIHNjYWxlLCBvZmZzZXRDYW52YXNYIC0gcm90YXRlQSAqIHNjYWxlICogY2VudGVyWCAtIHJvdGF0ZUMgKiBzY2FsZSAqIGNlbnRlclksIG9mZnNldENhbnZhc1kgLSByb3RhdGVCICogc2NhbGUgKiBjZW50ZXJYIC0gcm90YXRlRCAqIHNjYWxlICogY2VudGVyWV07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMud2lkdGggPSB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5oZWlnaHQgPSBoZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCByYXdEaW1zKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3Qm94CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInJhd0RpbXMiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlV2lkdGg6IHZpZXdCb3hbMl0gLSB2aWV3Qm94WzBdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUhlaWdodDogdmlld0JveFszXSAtIHZpZXdCb3hbMV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlWDogdmlld0JveFswXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VZOiB2aWV3Qm94WzFdCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjbG9uZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlID0gdGhpcy5zY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uID0gdGhpcy5yb3RhdGlvbiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFggPSB0aGlzLm9mZnNldFgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZID0gdGhpcy5vZmZzZXRZLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9udEZsaXAgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB7fTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBQYWdlVmlld3BvcnQoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld0JveDogdGhpcy52aWV3Qm94LnNsaWNlKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0WCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb250RmxpcAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29udmVydFRvVmlld3BvcnRQb2ludCh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFt4LCB5XSwgdGhpcy50cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb252ZXJ0VG9WaWV3cG9ydFJlY3RhbmdsZShyZWN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRvcExlZnQgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFtyZWN0WzBdLCByZWN0WzFdXSwgdGhpcy50cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBib3R0b21SaWdodCA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oW3JlY3RbMl0sIHJlY3RbM11dLCB0aGlzLnRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbdG9wTGVmdFswXSwgdG9wTGVmdFsxXSwgYm90dG9tUmlnaHRbMF0sIGJvdHRvbVJpZ2h0WzFdXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29udmVydFRvUGRmUG9pbnQoeCwgeSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuVXRpbC5hcHBseUludmVyc2VUcmFuc2Zvcm0oW3gsIHldLCB0aGlzLnRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5QYWdlVmlld3BvcnQgPSBQYWdlVmlld3BvcnQ7CiAgICAgICAgICAgICAgICBjbGFzcyBSZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb24gZXh0ZW5kcyBfdXRpbC5CYXNlRXhjZXB0aW9uIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcihtc2csIHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGV4dHJhRGVsYXkgPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKG1zZywgIlJlbmRlcmluZ0NhbmNlbGxlZEV4Y2VwdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnR5cGUgPSB0eXBlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmV4dHJhRGVsYXkgPSBleHRyYURlbGF5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuUmVuZGVyaW5nQ2FuY2VsbGVkRXhjZXB0aW9uID0gUmVuZGVyaW5nQ2FuY2VsbGVkRXhjZXB0aW9uOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gaXNEYXRhU2NoZW1lKHVybCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IGlpID0gdXJsLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICBsZXQgaSA9IDA7CiAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGkgPCBpaSAmJiB1cmxbaV0udHJpbSgpID09PSAiIikgewogICAgICAgICAgICAgICAgICAgICAgICBpKys7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiB1cmwuc3Vic3RyaW5nKGksIGkgKyA1KS50b0xvd2VyQ2FzZSgpID09PSAiZGF0YToiOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gaXNQZGZGaWxlKGZpbGVuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHR5cGVvZiBmaWxlbmFtZSA9PT0gInN0cmluZyIgJiYgL1wucGRmJC9pLnRlc3QoZmlsZW5hbWUpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0RmlsZW5hbWVGcm9tVXJsKHVybCkgewogICAgICAgICAgICAgICAgICAgIGxldCBvbmx5U3RyaXBQYXRoID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICBpZiAoIW9ubHlTdHJpcFBhdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgW3VybF0gPSB1cmwuc3BsaXQoL1sjP10vLCAxKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVybC5zdWJzdHJpbmcodXJsLmxhc3RJbmRleE9mKCIvIikgKyAxKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldFBkZkZpbGVuYW1lRnJvbVVybCh1cmwpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgZGVmYXVsdEZpbGVuYW1lID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiAiZG9jdW1lbnQucGRmIjsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHVybCAhPT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRlZmF1bHRGaWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzRGF0YVNjaGVtZSh1cmwpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgnZ2V0UGRmRmlsZW5hbWVGcm9tVXJsOiBpZ25vcmUgImRhdGE6Ii1VUkwgZm9yIHBlcmZvcm1hbmNlIHJlYXNvbnMuJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBkZWZhdWx0RmlsZW5hbWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlVVJJID0gL14oPzooPzpbXjpdKzopP1wvXC9bXi9dKyk/KFtePyNdKikoXD9bXiNdKik/KCMuKik/JC87CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVGaWxlbmFtZSA9IC9bXi8/Iz1dK1wucGRmXGIoPyEuKlwucGRmXGIpL2k7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3BsaXRVUkkgPSByZVVSSS5leGVjKHVybCk7CiAgICAgICAgICAgICAgICAgICAgbGV0IHN1Z2dlc3RlZEZpbGVuYW1lID0gcmVGaWxlbmFtZS5leGVjKHNwbGl0VVJJWzFdKSB8fCByZUZpbGVuYW1lLmV4ZWMoc3BsaXRVUklbMl0pIHx8IHJlRmlsZW5hbWUuZXhlYyhzcGxpdFVSSVszXSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHN1Z2dlc3RlZEZpbGVuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1Z2dlc3RlZEZpbGVuYW1lID0gc3VnZ2VzdGVkRmlsZW5hbWVbMF07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdWdnZXN0ZWRGaWxlbmFtZS5pbmNsdWRlcygiJSIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1Z2dlc3RlZEZpbGVuYW1lID0gcmVGaWxlbmFtZS5leGVjKGRlY29kZVVSSUNvbXBvbmVudChzdWdnZXN0ZWRGaWxlbmFtZSkpWzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHt9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN1Z2dlc3RlZEZpbGVuYW1lIHx8IGRlZmF1bHRGaWxlbmFtZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFN0YXRUaW1lciB7CiAgICAgICAgICAgICAgICAgICAgc3RhcnRlZCA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgICAgICAgICAgICAgICAgdGltZXMgPSBbXTsKICAgICAgICAgICAgICAgICAgICB0aW1lKG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hbWUgaW4gdGhpcy5zdGFydGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYFRpbWVyIGlzIGFscmVhZHkgcnVubmluZyBmb3IgJHtuYW1lfWApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhcnRlZFtuYW1lXSA9IERhdGUubm93KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRpbWVFbmQobmFtZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIShuYW1lIGluIHRoaXMuc3RhcnRlZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgVGltZXIgaGFzIG5vdCBiZWVuIHN0YXJ0ZWQgZm9yICR7bmFtZX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRpbWVzLnB1c2goewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0OiB0aGlzLnN0YXJ0ZWRbbmFtZV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmQ6IERhdGUubm93KCkKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSB0aGlzLnN0YXJ0ZWRbbmFtZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRvU3RyaW5nKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvdXRCdWYgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGxvbmdlc3QgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUKICAgICAgICAgICAgICAgICAgICAgICAgfSBvZiB0aGlzLnRpbWVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb25nZXN0ID0gTWF0aC5tYXgobmFtZS5sZW5ndGgsIGxvbmdlc3QpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5kCiAgICAgICAgICAgICAgICAgICAgICAgIH0gb2YgdGhpcy50aW1lcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3V0QnVmLnB1c2goYCR7bmFtZS5wYWRFbmQobG9uZ2VzdCl9ICR7ZW5kIC0gc3RhcnR9bXNcbmApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBvdXRCdWYuam9pbigiIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5TdGF0VGltZXIgPSBTdGF0VGltZXI7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBpc1ZhbGlkRmV0Y2hVcmwodXJsLCBiYXNlVXJsKSB7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvdG9jb2wKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGJhc2VVcmwgPyBuZXcgVVJMKHVybCwgYmFzZVVybCkgOiBuZXcgVVJMKHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwcm90b2NvbCA9PT0gImh0dHA6IiB8fCBwcm90b2NvbCA9PT0gImh0dHBzOiI7CiAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGxvYWRTY3JpcHQoc3JjKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IHJlbW92ZVNjcmlwdEVsZW1lbnQgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjcmlwdCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInNjcmlwdCIpOwogICAgICAgICAgICAgICAgICAgICAgICBzY3JpcHQuc3JjID0gc3JjOwogICAgICAgICAgICAgICAgICAgICAgICBzY3JpcHQub25sb2FkID0gZnVuY3Rpb24gKGV2dCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlbW92ZVNjcmlwdEVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY3JpcHQucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKGV2dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIHNjcmlwdC5vbmVycm9yID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVqZWN0KG5ldyBFcnJvcihgQ2Fubm90IGxvYWQgc2NyaXB0IGF0OiAke3NjcmlwdC5zcmN9YCkpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAoZG9jdW1lbnQuaGVhZCB8fCBkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQpLmFwcGVuZChzY3JpcHQpOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZGVwcmVjYXRlZChkZXRhaWxzKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coIkRlcHJlY2F0ZWQgQVBJIHVzYWdlOiAiICsgZGV0YWlscyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBsZXQgcGRmRGF0ZVN0cmluZ1JlZ2V4OwogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0ZVN0cmluZyB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHRvRGF0ZU9iamVjdChpbnB1dCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlucHV0IHx8IHR5cGVvZiBpbnB1dCAhPT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghcGRmRGF0ZVN0cmluZ1JlZ2V4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwZGZEYXRlU3RyaW5nUmVnZXggPSBuZXcgUmVnRXhwKCJeRDoiICsgIihcXGR7NH0pIiArICIoXFxkezJ9KT8iICsgIihcXGR7Mn0pPyIgKyAiKFxcZHsyfSk/IiArICIoXFxkezJ9KT8iICsgIihcXGR7Mn0pPyIgKyAiKFtafCt8LV0pPyIgKyAiKFxcZHsyfSk/IiArICInPyIgKyAiKFxcZHsyfSk/IiArICInPyIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hdGNoZXMgPSBwZGZEYXRlU3RyaW5nUmVnZXguZXhlYyhpbnB1dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghbWF0Y2hlcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeWVhciA9IHBhcnNlSW50KG1hdGNoZXNbMV0sIDEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG1vbnRoID0gcGFyc2VJbnQobWF0Y2hlc1syXSwgMTApOwogICAgICAgICAgICAgICAgICAgICAgICBtb250aCA9IG1vbnRoID49IDEgJiYgbW9udGggPD0gMTIgPyBtb250aCAtIDEgOiAwOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZGF5ID0gcGFyc2VJbnQobWF0Y2hlc1szXSwgMTApOwogICAgICAgICAgICAgICAgICAgICAgICBkYXkgPSBkYXkgPj0gMSAmJiBkYXkgPD0gMzEgPyBkYXkgOiAxOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgaG91ciA9IHBhcnNlSW50KG1hdGNoZXNbNF0sIDEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgaG91ciA9IGhvdXIgPj0gMCAmJiBob3VyIDw9IDIzID8gaG91ciA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtaW51dGUgPSBwYXJzZUludChtYXRjaGVzWzVdLCAxMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1pbnV0ZSA9IG1pbnV0ZSA+PSAwICYmIG1pbnV0ZSA8PSA1OSA/IG1pbnV0ZSA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzZWNvbmQgPSBwYXJzZUludChtYXRjaGVzWzZdLCAxMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHNlY29uZCA9IHNlY29uZCA+PSAwICYmIHNlY29uZCA8PSA1OSA/IHNlY29uZCA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVuaXZlcnNhbFRpbWVSZWxhdGlvbiA9IG1hdGNoZXNbN10gfHwgIloiOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgb2Zmc2V0SG91ciA9IHBhcnNlSW50KG1hdGNoZXNbOF0sIDEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0SG91ciA9IG9mZnNldEhvdXIgPj0gMCAmJiBvZmZzZXRIb3VyIDw9IDIzID8gb2Zmc2V0SG91ciA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBvZmZzZXRNaW51dGUgPSBwYXJzZUludChtYXRjaGVzWzldLCAxMCkgfHwgMDsKICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0TWludXRlID0gb2Zmc2V0TWludXRlID49IDAgJiYgb2Zmc2V0TWludXRlIDw9IDU5ID8gb2Zmc2V0TWludXRlIDogMDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHVuaXZlcnNhbFRpbWVSZWxhdGlvbiA9PT0gIi0iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBob3VyICs9IG9mZnNldEhvdXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW51dGUgKz0gb2Zmc2V0TWludXRlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHVuaXZlcnNhbFRpbWVSZWxhdGlvbiA9PT0gIisiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBob3VyIC09IG9mZnNldEhvdXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW51dGUgLT0gb2Zmc2V0TWludXRlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgRGF0ZShEYXRlLlVUQyh5ZWFyLCBtb250aCwgZGF5LCBob3VyLCBtaW51dGUsIHNlY29uZCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuUERGRGF0ZVN0cmluZyA9IFBERkRhdGVTdHJpbmc7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRYZmFQYWdlVmlld3BvcnQoeGZhUGFnZSwgX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICBzY2FsZSA9IDEsCiAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uID0gMAogICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMjsKICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICB9ID0geGZhUGFnZS5hdHRyaWJ1dGVzLnN0eWxlOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHZpZXdCb3ggPSBbMCwgMCwgcGFyc2VJbnQod2lkdGgpLCBwYXJzZUludChoZWlnaHQpXTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFBhZ2VWaWV3cG9ydCh7CiAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdCb3gsCiAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlLAogICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbgogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0UkdCKGNvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKGNvbG9yLnN0YXJ0c1dpdGgoIiMiKSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xvclJHQiA9IHBhcnNlSW50KGNvbG9yLnNsaWNlKDEpLCAxNik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbKGNvbG9yUkdCICYgMHhmZjAwMDApID4+IDE2LCAoY29sb3JSR0IgJiAweDAwZmYwMCkgPj4gOCwgY29sb3JSR0IgJiAweDAwMDBmZl07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChjb2xvci5zdGFydHNXaXRoKCJyZ2IoIikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbG9yLnNsaWNlKDQsIC0xKS5zcGxpdCgiLCIpLm1hcCh4ID0+IHBhcnNlSW50KHgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGNvbG9yLnN0YXJ0c1dpdGgoInJnYmEoIikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbG9yLnNsaWNlKDUsIC0xKS5zcGxpdCgiLCIpLm1hcCh4ID0+IHBhcnNlSW50KHgpKS5zbGljZSgwLCAzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBOb3QgYSB2YWxpZCBjb2xvciBmb3JtYXQ6ICIke2NvbG9yfSJgKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzAsIDAsIDBdOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0Q29sb3JWYWx1ZXMoY29sb3JzKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3BhbiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInNwYW4iKTsKICAgICAgICAgICAgICAgICAgICBzcGFuLnN0eWxlLnZpc2liaWxpdHkgPSAiaGlkZGVuIjsKICAgICAgICAgICAgICAgICAgICBkb2N1bWVudC5ib2R5LmFwcGVuZChzcGFuKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG5hbWUgb2YgY29sb3JzLmtleXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICBzcGFuLnN0eWxlLmNvbG9yID0gbmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29tcHV0ZWRDb2xvciA9IHdpbmRvdy5nZXRDb21wdXRlZFN0eWxlKHNwYW4pLmNvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICBjb2xvcnMuc2V0KG5hbWUsIGdldFJHQihjb21wdXRlZENvbG9yKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNwYW4ucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRDdXJyZW50VHJhbnNmb3JtKGN0eCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgYSwKICAgICAgICAgICAgICAgICAgICAgICAgYiwKICAgICAgICAgICAgICAgICAgICAgICAgYywKICAgICAgICAgICAgICAgICAgICAgICAgZCwKICAgICAgICAgICAgICAgICAgICAgICAgZSwKICAgICAgICAgICAgICAgICAgICAgICAgZgogICAgICAgICAgICAgICAgICAgIH0gPSBjdHguZ2V0VHJhbnNmb3JtKCk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFthLCBiLCBjLCBkLCBlLCBmXTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldEN1cnJlbnRUcmFuc2Zvcm1JbnZlcnNlKGN0eCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgYSwKICAgICAgICAgICAgICAgICAgICAgICAgYiwKICAgICAgICAgICAgICAgICAgICAgICAgYywKICAgICAgICAgICAgICAgICAgICAgICAgZCwKICAgICAgICAgICAgICAgICAgICAgICAgZSwKICAgICAgICAgICAgICAgICAgICAgICAgZgogICAgICAgICAgICAgICAgICAgIH0gPSBjdHguZ2V0VHJhbnNmb3JtKCkuaW52ZXJ0U2VsZigpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBbYSwgYiwgYywgZCwgZSwgZl07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBzZXRMYXllckRpbWVuc2lvbnMoZGl2LCB2aWV3cG9ydCkgewogICAgICAgICAgICAgICAgICAgIGxldCBtdXN0RmxpcCA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgbGV0IG11c3RSb3RhdGUgPSBhcmd1bWVudHMubGVuZ3RoID4gMyAmJiBhcmd1bWVudHNbM10gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1szXSA6IHRydWU7CiAgICAgICAgICAgICAgICAgICAgaWYgKHZpZXdwb3J0IGluc3RhbmNlb2YgUGFnZVZpZXdwb3J0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VXaWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VIZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHZpZXdwb3J0LnJhd0RpbXM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBkaXY7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoU3RyID0gYGNhbGModmFyKC0tc2NhbGUtZmFjdG9yKSAqICR7cGFnZVdpZHRofXB4KWA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodFN0ciA9IGBjYWxjKHZhcigtLXNjYWxlLWZhY3RvcikgKiAke3BhZ2VIZWlnaHR9cHgpYDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFtdXN0RmxpcCB8fCB2aWV3cG9ydC5yb3RhdGlvbiAlIDE4MCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUud2lkdGggPSB3aWR0aFN0cjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLmhlaWdodCA9IGhlaWdodFN0cjsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLndpZHRoID0gaGVpZ2h0U3RyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUuaGVpZ2h0ID0gd2lkdGhTdHI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKG11c3RSb3RhdGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnNldEF0dHJpYnV0ZSgiZGF0YS1tYWluLXJvdGF0aW9uIiwgdmlld3BvcnQucm90YXRpb24pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQzICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQmFzZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gZXhwb3J0cy5CYXNlU1ZHRmFjdG9yeSA9IGV4cG9ydHMuQmFzZUZpbHRlckZhY3RvcnkgPSBleHBvcnRzLkJhc2VDYW52YXNGYWN0b3J5ID0gZXhwb3J0cy5CYXNlQ01hcFJlYWRlckZhY3RvcnkgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgY2xhc3MgQmFzZUZpbHRlckZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb25zdHJ1Y3RvciA9PT0gQmFzZUZpbHRlckZhY3RvcnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkNhbm5vdCBpbml0aWFsaXplIEJhc2VGaWx0ZXJGYWN0b3J5LiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZEZpbHRlcihtYXBzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAibm9uZSI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZEhDTUZpbHRlcihmZ0NvbG9yLCBiZ0NvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAibm9uZSI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlc3Ryb3koKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrZWVwSENNID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkJhc2VGaWx0ZXJGYWN0b3J5ID0gQmFzZUZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBCYXNlQ2FudmFzRmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNvbnN0cnVjdG9yID09PSBCYXNlQ2FudmFzRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQmFzZUNhbnZhc0ZhY3RvcnkuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3JlYXRlKHdpZHRoLCBoZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoIDw9IDAgfHwgaGVpZ2h0IDw9IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiSW52YWxpZCBjYW52YXMgc2l6ZSIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbnZhcyA9IHRoaXMuX2NyZWF0ZUNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQ6IGNhbnZhcy5nZXRDb250ZXh0KCIyZCIpCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlc2V0KGNhbnZhc0FuZENvbnRleHQsIHdpZHRoLCBoZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjYW52YXNBbmRDb250ZXh0LmNhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJDYW52YXMgaXMgbm90IHNwZWNpZmllZCIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3aWR0aCA8PSAwIHx8IGhlaWdodCA8PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgY2FudmFzIHNpemUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNBbmRDb250ZXh0LmNhbnZhcy53aWR0aCA9IHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNBbmRDb250ZXh0LmNhbnZhcy5oZWlnaHQgPSBoZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlc3Ryb3koY2FudmFzQW5kQ29udGV4dCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWNhbnZhc0FuZENvbnRleHQuY2FudmFzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkNhbnZhcyBpcyBub3Qgc3BlY2lmaWVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzQW5kQ29udGV4dC5jYW52YXMud2lkdGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNBbmRDb250ZXh0LmNhbnZhcy5oZWlnaHQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBjYW52YXNBbmRDb250ZXh0LmNhbnZhcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc0FuZENvbnRleHQuY29udGV4dCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9jcmVhdGVDYW52YXMod2lkdGgsIGhlaWdodCkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJBYnN0cmFjdCBtZXRob2QgYF9jcmVhdGVDYW52YXNgIGNhbGxlZC4iKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkJhc2VDYW52YXNGYWN0b3J5ID0gQmFzZUNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBCYXNlQ01hcFJlYWRlckZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VVcmwgPSBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNDb21wcmVzc2VkID0gdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IEJhc2VDTWFwUmVhZGVyRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQmFzZUNNYXBSZWFkZXJGYWN0b3J5LiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVVybCA9IGJhc2VVcmw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNDb21wcmVzc2VkID0gaXNDb21wcmVzc2VkOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyBmZXRjaChfcmVmMikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5iYXNlVXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ1RoZSBDTWFwICJiYXNlVXJsIiBwYXJhbWV0ZXIgbXVzdCBiZSBzcGVjaWZpZWQsIGVuc3VyZSB0aGF0ICcgKyAndGhlICJjTWFwVXJsIiBhbmQgImNNYXBQYWNrZWQiIEFQSSBwYXJhbWV0ZXJzIGFyZSBwcm92aWRlZC4nKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIW5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiQ01hcCBuYW1lIG11c3QgYmUgc3BlY2lmaWVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVybCA9IHRoaXMuYmFzZVVybCArIG5hbWUgKyAodGhpcy5pc0NvbXByZXNzZWQgPyAiLmJjbWFwIiA6ICIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29tcHJlc3Npb25UeXBlID0gdGhpcy5pc0NvbXByZXNzZWQgPyBfdXRpbC5DTWFwQ29tcHJlc3Npb25UeXBlLkJJTkFSWSA6IF91dGlsLkNNYXBDb21wcmVzc2lvblR5cGUuTk9ORTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2ZldGNoRGF0YSh1cmwsIGNvbXByZXNzaW9uVHlwZSkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5hYmxlIHRvIGxvYWQgJHt0aGlzLmlzQ29tcHJlc3NlZCA/ICJiaW5hcnkgIiA6ICIifUNNYXAgYXQ6ICR7dXJsfWApOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2ZldGNoRGF0YSh1cmwsIGNvbXByZXNzaW9uVHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJBYnN0cmFjdCBtZXRob2QgYF9mZXRjaERhdGFgIGNhbGxlZC4iKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkJhc2VDTWFwUmVhZGVyRmFjdG9yeSA9IEJhc2VDTWFwUmVhZGVyRmFjdG9yeTsKICAgICAgICAgICAgICAgIGNsYXNzIEJhc2VTdGFuZGFyZEZvbnREYXRhRmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoX3JlZjMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VVcmwgPSBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMzsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IEJhc2VTdGFuZGFyZEZvbnREYXRhRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQmFzZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5LiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVVybCA9IGJhc2VVcmw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFzeW5jIGZldGNoKF9yZWY0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWxlbmFtZQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5iYXNlVXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ1RoZSBzdGFuZGFyZCBmb250ICJiYXNlVXJsIiBwYXJhbWV0ZXIgbXVzdCBiZSBzcGVjaWZpZWQsIGVuc3VyZSB0aGF0ICcgKyAndGhlICJzdGFuZGFyZEZvbnREYXRhVXJsIiBBUEkgcGFyYW1ldGVyIGlzIHByb3ZpZGVkLicpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZmlsZW5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiRm9udCBmaWxlbmFtZSBtdXN0IGJlIHNwZWNpZmllZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBgJHt0aGlzLmJhc2VVcmx9JHtmaWxlbmFtZX1gOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fZmV0Y2hEYXRhKHVybCkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5hYmxlIHRvIGxvYWQgZm9udCBkYXRhIGF0OiAke3VybH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9mZXRjaERhdGEodXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkFic3RyYWN0IG1ldGhvZCBgX2ZldGNoRGF0YWAgY2FsbGVkLiIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQmFzZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gQmFzZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5OwogICAgICAgICAgICAgICAgY2xhc3MgQmFzZVNWR0ZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb25zdHJ1Y3RvciA9PT0gQmFzZVNWR0ZhY3RvcnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkNhbm5vdCBpbml0aWFsaXplIEJhc2VTVkdGYWN0b3J5LiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNyZWF0ZSh3aWR0aCwgaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBza2lwRGltZW5zaW9ucyA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3aWR0aCA8PSAwIHx8IGhlaWdodCA8PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkludmFsaWQgU1ZHIGRpbWVuc2lvbnMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdmcgPSB0aGlzLl9jcmVhdGVTVkcoInN2ZzpzdmciKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLnNldEF0dHJpYnV0ZSgidmVyc2lvbiIsICIxLjEiKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFza2lwRGltZW5zaW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLnNldEF0dHJpYnV0ZSgid2lkdGgiLCBgJHt3aWR0aH1weGApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLnNldEF0dHJpYnV0ZSgiaGVpZ2h0IiwgYCR7aGVpZ2h0fXB4YCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLnNldEF0dHJpYnV0ZSgicHJlc2VydmVBc3BlY3RSYXRpbyIsICJub25lIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5zZXRBdHRyaWJ1dGUoInZpZXdCb3giLCBgMCAwICR7d2lkdGh9ICR7aGVpZ2h0fWApOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3ZnOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjcmVhdGVFbGVtZW50KHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiB0eXBlICE9PSAic3RyaW5nIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJJbnZhbGlkIFNWRyBlbGVtZW50IHR5cGUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fY3JlYXRlU1ZHKHR5cGUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY3JlYXRlU1ZHKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQWJzdHJhY3QgbWV0aG9kIGBfY3JlYXRlU1ZHYCBjYWxsZWQuIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5CYXNlU1ZHRmFjdG9yeSA9IEJhc2VTVkdGYWN0b3J5OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNDQgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5NdXJtdXJIYXNoM182NCA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICBjb25zdCBTRUVEID0gMHhjM2QyZTFmMDsKICAgICAgICAgICAgICAgIGNvbnN0IE1BU0tfSElHSCA9IDB4ZmZmZjAwMDA7CiAgICAgICAgICAgICAgICBjb25zdCBNQVNLX0xPVyA9IDB4ZmZmZjsKICAgICAgICAgICAgICAgIGNsYXNzIE11cm11ckhhc2gzXzY0IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzZWVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaDEgPSBzZWVkID8gc2VlZCAmIDB4ZmZmZmZmZmYgOiBTRUVEOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmgyID0gc2VlZCA/IHNlZWQgJiAweGZmZmZmZmZmIDogU0VFRDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlKGlucHV0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhLCBsZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgaW5wdXQgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhID0gbmV3IFVpbnQ4QXJyYXkoaW5wdXQubGVuZ3RoICogMik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gaW5wdXQubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvZGUgPSBpbnB1dC5jaGFyQ29kZUF0KGkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjb2RlIDw9IDB4ZmYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtsZW5ndGgrK10gPSBjb2RlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFbbGVuZ3RoKytdID0gY29kZSA+Pj4gODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtsZW5ndGgrK10gPSBjb2RlICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoKDAsIF91dGlsLmlzQXJyYXlCdWZmZXIpKGlucHV0KSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9IGlucHV0LnNsaWNlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGggPSBkYXRhLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIldyb25nIGRhdGEgZm9ybWF0IGluIE11cm11ckhhc2gzXzY0X3VwZGF0ZS4gIiArICJJbnB1dCBtdXN0IGJlIGEgc3RyaW5nIG9yIGFycmF5LiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJsb2NrQ291bnRzID0gbGVuZ3RoID4+IDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRhaWxMZW5ndGggPSBsZW5ndGggLSBibG9ja0NvdW50cyAqIDQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGFVaW50MzIgPSBuZXcgVWludDMyQXJyYXkoZGF0YS5idWZmZXIsIDAsIGJsb2NrQ291bnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGsxID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsyID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGgxID0gdGhpcy5oMSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGgyID0gdGhpcy5oMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQzEgPSAweGNjOWUyZDUxLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgQzIgPSAweDFiODczNTkzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDMV9MT1cgPSBDMSAmIE1BU0tfTE9XLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgQzJfTE9XID0gQzIgJiBNQVNLX0xPVzsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBibG9ja0NvdW50czsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaSAmIDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrMSA9IGRhdGFVaW50MzJbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgazEgPSBrMSAqIEMxICYgTUFTS19ISUdIIHwgazEgKiBDMV9MT1cgJiBNQVNLX0xPVzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrMSA9IGsxIDw8IDE1IHwgazEgPj4+IDE3OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsxID0gazEgKiBDMiAmIE1BU0tfSElHSCB8IGsxICogQzJfTE9XICYgTUFTS19MT1c7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaDEgXj0gazE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaDEgPSBoMSA8PCAxMyB8IGgxID4+PiAxOTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoMSA9IGgxICogNSArIDB4ZTY1NDZiNjQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsyID0gZGF0YVVpbnQzMltpXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrMiA9IGsyICogQzEgJiBNQVNLX0hJR0ggfCBrMiAqIEMxX0xPVyAmIE1BU0tfTE9XOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsyID0gazIgPDwgMTUgfCBrMiA+Pj4gMTc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgazIgPSBrMiAqIEMyICYgTUFTS19ISUdIIHwgazIgKiBDMl9MT1cgJiBNQVNLX0xPVzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoMiBePSBrMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoMiA9IGgyIDw8IDEzIHwgaDIgPj4+IDE5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGgyID0gaDIgKiA1ICsgMHhlNjU0NmI2NDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBrMSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodGFpbExlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAzOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsxIF49IGRhdGFbYmxvY2tDb3VudHMgKiA0ICsgMl0gPDwgMTY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgazEgXj0gZGF0YVtibG9ja0NvdW50cyAqIDQgKyAxXSA8PCA4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsxIF49IGRhdGFbYmxvY2tDb3VudHMgKiA0XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrMSA9IGsxICogQzEgJiBNQVNLX0hJR0ggfCBrMSAqIEMxX0xPVyAmIE1BU0tfTE9XOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsxID0gazEgPDwgMTUgfCBrMSA+Pj4gMTc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgazEgPSBrMSAqIEMyICYgTUFTS19ISUdIIHwgazEgKiBDMl9MT1cgJiBNQVNLX0xPVzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmxvY2tDb3VudHMgJiAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGgxIF49IGsxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGgyIF49IGsxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmgxID0gaDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaDIgPSBoMjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaGV4ZGlnZXN0KCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgaDEgPSB0aGlzLmgxLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaDIgPSB0aGlzLmgyOwogICAgICAgICAgICAgICAgICAgICAgICBoMSBePSBoMiA+Pj4gMTsKICAgICAgICAgICAgICAgICAgICAgICAgaDEgPSBoMSAqIDB4ZWQ1NThjY2QgJiBNQVNLX0hJR0ggfCBoMSAqIDB4OGNjZCAmIE1BU0tfTE9XOwogICAgICAgICAgICAgICAgICAgICAgICBoMiA9IGgyICogMHhmZjUxYWZkNyAmIE1BU0tfSElHSCB8ICgoaDIgPDwgMTYgfCBoMSA+Pj4gMTYpICogMHhhZmQ3ZWQ1NSAmIE1BU0tfSElHSCkgPj4+IDE2OwogICAgICAgICAgICAgICAgICAgICAgICBoMSBePSBoMiA+Pj4gMTsKICAgICAgICAgICAgICAgICAgICAgICAgaDEgPSBoMSAqIDB4MWE4NWVjNTMgJiBNQVNLX0hJR0ggfCBoMSAqIDB4ZWM1MyAmIE1BU0tfTE9XOwogICAgICAgICAgICAgICAgICAgICAgICBoMiA9IGgyICogMHhjNGNlYjlmZSAmIE1BU0tfSElHSCB8ICgoaDIgPDwgMTYgfCBoMSA+Pj4gMTYpICogMHhiOWZlMWE4NSAmIE1BU0tfSElHSCkgPj4+IDE2OwogICAgICAgICAgICAgICAgICAgICAgICBoMSBePSBoMiA+Pj4gMTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChoMSA+Pj4gMCkudG9TdHJpbmcoMTYpLnBhZFN0YXJ0KDgsICIwIikgKyAoaDIgPj4+IDApLnRvU3RyaW5nKDE2KS5wYWRTdGFydCg4LCAiMCIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuTXVybXVySGFzaDNfNjQgPSBNdXJtdXJIYXNoM182NDsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQ1ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuRm9udExvYWRlciA9IGV4cG9ydHMuRm9udEZhY2VPYmplY3QgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9pc19ub2RlID0gX193X3BkZmpzX3JlcXVpcmVfXygzKTsKICAgICAgICAgICAgICAgIGNsYXNzIEZvbnRMb2FkZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG93bmVyRG9jdW1lbnQgPSBnbG9iYWxUaGlzLmRvY3VtZW50LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGVFbGVtZW50ID0gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9jdW1lbnQgPSBvd25lckRvY3VtZW50OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hdGl2ZUZvbnRGYWNlcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0eWxlRWxlbWVudCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubG9hZGluZ1JlcXVlc3RzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubG9hZFRlc3RGb250SWQgPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGROYXRpdmVGb250RmFjZShuYXRpdmVGb250RmFjZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hdGl2ZUZvbnRGYWNlcy5wdXNoKG5hdGl2ZUZvbnRGYWNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9jdW1lbnQuZm9udHMuYWRkKG5hdGl2ZUZvbnRGYWNlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaW5zZXJ0UnVsZShydWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5zdHlsZUVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3R5bGVFbGVtZW50ID0gdGhpcy5fZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic3R5bGUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RvY3VtZW50LmRvY3VtZW50RWxlbWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgiaGVhZCIpWzBdLmFwcGVuZCh0aGlzLnN0eWxlRWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3R5bGVTaGVldCA9IHRoaXMuc3R5bGVFbGVtZW50LnNoZWV0OwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZVNoZWV0Lmluc2VydFJ1bGUocnVsZSwgc3R5bGVTaGVldC5jc3NSdWxlcy5sZW5ndGgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjbGVhcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBuYXRpdmVGb250RmFjZSBvZiB0aGlzLm5hdGl2ZUZvbnRGYWNlcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9jdW1lbnQuZm9udHMuZGVsZXRlKG5hdGl2ZUZvbnRGYWNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hdGl2ZUZvbnRGYWNlcy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5zdHlsZUVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3R5bGVFbGVtZW50LnJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHlsZUVsZW1lbnQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFzeW5jIGJpbmQoZm9udCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9udC5hdHRhY2hlZCB8fCBmb250Lm1pc3NpbmdGaWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9udC5hdHRhY2hlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRm9udExvYWRpbmdBUElTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5hdGl2ZUZvbnRGYWNlID0gZm9udC5jcmVhdGVOYXRpdmVGb250RmFjZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5hdGl2ZUZvbnRGYWNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGROYXRpdmVGb250RmFjZShuYXRpdmVGb250RmFjZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgbmF0aXZlRm9udEZhY2UubG9hZGVkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgRmFpbGVkIHRvIGxvYWQgZm9udCAnJHtuYXRpdmVGb250RmFjZS5mYW1pbHl9JzogJyR7ZXh9Jy5gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9udC5kaXNhYmxlRm9udEZhY2UgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBleDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcnVsZSA9IGZvbnQuY3JlYXRlRm9udEZhY2VSdWxlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChydWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmluc2VydFJ1bGUocnVsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5pc1N5bmNGb250TG9hZGluZ1N1cHBvcnRlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGF3YWl0IG5ldyBQcm9taXNlKHJlc29sdmUgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlcXVlc3QgPSB0aGlzLl9xdWV1ZUxvYWRpbmdDYWxsYmFjayhyZXNvbHZlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wcmVwYXJlRm9udExvYWRFdmVudChmb250LCByZXF1ZXN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc0ZvbnRMb2FkaW5nQVBJU3VwcG9ydGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX2RvY3VtZW50OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoYXNGb250cyA9ICEhKChfdGhpcyRfZG9jdW1lbnQgPSB0aGlzLl9kb2N1bWVudCkgIT09IG51bGwgJiYgX3RoaXMkX2RvY3VtZW50ICE9PSB2b2lkIDAgJiYgX3RoaXMkX2RvY3VtZW50LmZvbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJpc0ZvbnRMb2FkaW5nQVBJU3VwcG9ydGVkIiwgaGFzRm9udHMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNTeW5jRm9udExvYWRpbmdTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdXBwb3J0ZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9pc19ub2RlLmlzTm9kZUpTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdXBwb3J0ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBuYXZpZ2F0b3IgIT09ICJ1bmRlZmluZWQiICYmIC9Nb3ppbGxhXC81LjAuKj9ydjpcZCsuKj8gR2Vja28vLnRlc3QobmF2aWdhdG9yLnVzZXJBZ2VudCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1cHBvcnRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJpc1N5bmNGb250TG9hZGluZ1N1cHBvcnRlZCIsIHN1cHBvcnRlZCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9xdWV1ZUxvYWRpbmdDYWxsYmFjayhjYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBjb21wbGV0ZVJlcXVlc3QoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KSghcmVxdWVzdC5kb25lLCAiY29tcGxldGVSZXF1ZXN0KCkgY2Fubm90IGJlIGNhbGxlZCB0d2ljZS4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3QuZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAobG9hZGluZ1JlcXVlc3RzLmxlbmd0aCA+IDAgJiYgbG9hZGluZ1JlcXVlc3RzWzBdLmRvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvdGhlclJlcXVlc3QgPSBsb2FkaW5nUmVxdWVzdHMuc2hpZnQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRUaW1lb3V0KG90aGVyUmVxdWVzdC5jYWxsYmFjaywgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGluZ1JlcXVlc3RzCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wbGV0ZTogY29tcGxldGVSZXF1ZXN0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2sKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAg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AiQVFFQklWaFlXRmhZV0ZoWVdGaFlXRmhZV0ZoWVdGaFlXRmhZV0ZoWVdGaFlXRmhZQUFBQkFRQUFEd0FDQVFFRUUvdDMiICsgIkRvdjZmQUg2ZkFUK2ZQcDgrbndIRG9zTUN2bTFDdm0xREF6NmZCUUFBQUFBQUFBQkFBQUFBTW1KYnpFQUFBQUF6Z1RqIiArICJGUUFBQUFET0JPUXBBQUVBQUFBQUFBQUFEQUFVQUFRQUFBQUJBQUFBQWdBQkFBQUFBQUFBQUFBRDZBQUFBQUFBQUE9PSIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIl9sb2FkVGVzdEZvbnQiLCB0ZXN0Rm9udCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9wcmVwYXJlRm9udExvYWRFdmVudChmb250LCByZXF1ZXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGludDMyKGRhdGEsIG9mZnNldCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGEuY2hhckNvZGVBdChvZmZzZXQpIDw8IDI0IHwgZGF0YS5jaGFyQ29kZUF0KG9mZnNldCArIDEpIDw8IDE2IHwgZGF0YS5jaGFyQ29kZUF0KG9mZnNldCArIDIpIDw8IDggfCBkYXRhLmNoYXJDb2RlQXQob2Zmc2V0ICsgMykgJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHNwbGljZVN0cmluZyhzLCBvZmZzZXQsIHJlbW92ZSwgaW5zZXJ0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVuazEgPSBzLnN1YnN0cmluZygwLCBvZmZzZXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2h1bmsyID0gcy5zdWJzdHJpbmcob2Zmc2V0ICsgcmVtb3ZlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjaHVuazEgKyBpbnNlcnQgKyBjaHVuazI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGksIGlpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXMgPSB0aGlzLl9kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLndpZHRoID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLmhlaWdodCA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IGNhbnZhcy5nZXRDb250ZXh0KCIyZCIpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY2FsbGVkID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gaXNGb250UmVhZHkobmFtZSwgY2FsbGJhY2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgrK2NhbGxlZCA+IDMwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJMb2FkIHRlc3QgZm9udCBuZXZlciBsb2FkZWQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2soKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZm9udCA9ICIzMHB4ICIgKyBuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxUZXh0KCIuIiwgMCwgMjApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW1hZ2VEYXRhID0gY3R4LmdldEltYWdlRGF0YSgwLCAwLCAxLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbWFnZURhdGEuZGF0YVszXSA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFjaygpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoaXNGb250UmVhZHkuYmluZChudWxsLCBuYW1lLCBjYWxsYmFjaykpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxvYWRUZXN0Rm9udElkID0gYGx0JHtEYXRlLm5vdygpfSR7dGhpcy5sb2FkVGVzdEZvbnRJZCsrfWA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhID0gdGhpcy5fbG9hZFRlc3RGb250OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDT01NRU5UX09GRlNFVCA9IDk3NjsKICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSA9IHNwbGljZVN0cmluZyhkYXRhLCBDT01NRU5UX09GRlNFVCwgbG9hZFRlc3RGb250SWQubGVuZ3RoLCBsb2FkVGVzdEZvbnRJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IENGRl9DSEVDS1NVTV9PRkZTRVQgPSAxNjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgWFhYWF9WQUxVRSA9IDB4NTg1ODU4NTg7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjaGVja3N1bSA9IGludDMyKGRhdGEsIENGRl9DSEVDS1NVTV9PRkZTRVQpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IGxvYWRUZXN0Rm9udElkLmxlbmd0aCAtIDM7IGkgPCBpaTsgaSArPSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGVja3N1bSA9IGNoZWNrc3VtIC0gWFhYWF9WQUxVRSArIGludDMyKGxvYWRUZXN0Rm9udElkLCBpKSB8IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPCBsb2FkVGVzdEZvbnRJZC5sZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrc3VtID0gY2hlY2tzdW0gLSBYWFhYX1ZBTFVFICsgaW50MzIobG9hZFRlc3RGb250SWQgKyAiWFhYIiwgaSkgfCAwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEgPSBzcGxpY2VTdHJpbmcoZGF0YSwgQ0ZGX0NIRUNLU1VNX09GRlNFVCwgNCwgKDAsIF91dGlsLnN0cmluZzMyKShjaGVja3N1bSkpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBgdXJsKGRhdGE6Zm9udC9vcGVudHlwZTtiYXNlNjQsJHtidG9hKGRhdGEpfSk7YDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcnVsZSA9IGBAZm9udC1mYWNlIHtmb250LWZhbWlseToiJHtsb2FkVGVzdEZvbnRJZH0iO3NyYzoke3VybH19YDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pbnNlcnRSdWxlKHJ1bGUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXYgPSB0aGlzLl9kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLnZpc2liaWxpdHkgPSAiaGlkZGVuIjsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLndpZHRoID0gZGl2LnN0eWxlLmhlaWdodCA9ICIxMHB4IjsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLnBvc2l0aW9uID0gImFic29sdXRlIjsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLnRvcCA9IGRpdi5zdHlsZS5sZWZ0ID0gIjBweCI7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbmFtZSBvZiBbZm9udC5sb2FkZWROYW1lLCBsb2FkVGVzdEZvbnRJZF0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNwYW4gPSB0aGlzLl9kb2N1bWVudC5jcmVhdGVFbGVtZW50KCJzcGFuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcGFuLnRleHRDb250ZW50ID0gIkhpIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNwYW4uc3R5bGUuZm9udEZhbWlseSA9IG5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXYuYXBwZW5kKHNwYW4pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RvY3VtZW50LmJvZHkuYXBwZW5kKGRpdik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlzRm9udFJlYWR5KGxvYWRUZXN0Rm9udElkLCAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0LmNvbXBsZXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRm9udExvYWRlciA9IEZvbnRMb2FkZXI7CiAgICAgICAgICAgICAgICBjbGFzcyBGb250RmFjZU9iamVjdCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IodHJhbnNsYXRlZERhdGEsIF9yZWYyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQgPSB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUZvbnRGYWNlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVFcnJvcnMgPSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluc3BlY3RGb250ID0gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcGlsZWRHbHlwaHMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGkgaW4gdHJhbnNsYXRlZERhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXNbaV0gPSB0cmFuc2xhdGVkRGF0YVtpXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzRXZhbFN1cHBvcnRlZCA9IGlzRXZhbFN1cHBvcnRlZCAhPT0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGlzYWJsZUZvbnRGYWNlID0gZGlzYWJsZUZvbnRGYWNlID09PSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlnbm9yZUVycm9ycyA9IGlnbm9yZUVycm9ycyA9PT0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faW5zcGVjdEZvbnQgPSBpbnNwZWN0Rm9udDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3JlYXRlTmF0aXZlRm9udEZhY2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfaW5zcGVjdEZvbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhIHx8IHRoaXMuZGlzYWJsZUZvbnRGYWNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbmF0aXZlRm9udEZhY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jc3NGb250SW5mbykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbmF0aXZlRm9udEZhY2UgPSBuZXcgRm9udEZhY2UodGhpcy5sb2FkZWROYW1lLCB0aGlzLmRhdGEsIHt9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNzcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3ZWlnaHQ6IHRoaXMuY3NzRm9udEluZm8uZm9udFdlaWdodAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNzc0ZvbnRJbmZvLml0YWxpY0FuZ2xlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3NzLnN0eWxlID0gYG9ibGlxdWUgJHt0aGlzLmNzc0ZvbnRJbmZvLml0YWxpY0FuZ2xlfWRlZ2A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYXRpdmVGb250RmFjZSA9IG5ldyBGb250RmFjZSh0aGlzLmNzc0ZvbnRJbmZvLmZvbnRGYW1pbHksIHRoaXMuZGF0YSwgY3NzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2luc3BlY3RGb250ID0gdGhpcy5faW5zcGVjdEZvbnQpID09PSBudWxsIHx8IF90aGlzJF9pbnNwZWN0Rm9udCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2luc3BlY3RGb250LmNhbGwodGhpcywgdGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuYXRpdmVGb250RmFjZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3JlYXRlRm9udEZhY2VSdWxlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX2luc3BlY3RGb250MjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEgfHwgdGhpcy5kaXNhYmxlRm9udEZhY2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSAoMCwgX3V0aWwuYnl0ZXNUb1N0cmluZykodGhpcy5kYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdXJsID0gYHVybChkYXRhOiR7dGhpcy5taW1ldHlwZX07YmFzZTY0LCR7YnRvYShkYXRhKX0pO2A7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBydWxlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY3NzRm9udEluZm8pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJ1bGUgPSBgQGZvbnQtZmFjZSB7Zm9udC1mYW1pbHk6IiR7dGhpcy5sb2FkZWROYW1lfSI7c3JjOiR7dXJsfX1gOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNzcyA9IGBmb250LXdlaWdodDogJHt0aGlzLmNzc0ZvbnRJbmZvLmZvbnRXZWlnaHR9O2A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jc3NGb250SW5mby5pdGFsaWNBbmdsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNzcyArPSBgZm9udC1zdHlsZTogb2JsaXF1ZSAke3RoaXMuY3NzRm9udEluZm8uaXRhbGljQW5nbGV9ZGVnO2A7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBydWxlID0gYEBmb250LWZhY2Uge2ZvbnQtZmFtaWx5OiIke3RoaXMuY3NzRm9udEluZm8uZm9udEZhbWlseX0iOyR7Y3NzfXNyYzoke3VybH19YDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2luc3BlY3RGb250MiA9IHRoaXMuX2luc3BlY3RGb250KSA9PT0gbnVsbCB8fCBfdGhpcyRfaW5zcGVjdEZvbnQyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfaW5zcGVjdEZvbnQyLmNhbGwodGhpcywgdGhpcywgdXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJ1bGU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhdGhHZW5lcmF0b3Iob2JqcywgY2hhcmFjdGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNvbXBpbGVkR2x5cGhzW2NoYXJhY3Rlcl0gIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29tcGlsZWRHbHlwaHNbY2hhcmFjdGVyXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY21kczsKICAgICAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZHMgPSBvYmpzLmdldCh0aGlzLmxvYWRlZE5hbWUgKyAiX3BhdGhfIiArIGNoYXJhY3Rlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaWdub3JlRXJyb3JzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgZXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYGdldFBhdGhHZW5lcmF0b3IgLSBpZ25vcmluZyBjaGFyYWN0ZXI6ICIke2V4fSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb21waWxlZEdseXBoc1tjaGFyYWN0ZXJdID0gZnVuY3Rpb24gKGMsIHNpemUpIHt9OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRXZhbFN1cHBvcnRlZCAmJiBfdXRpbC5GZWF0dXJlVGVzdC5pc0V2YWxTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGpzQnVmID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGN1cnJlbnQgb2YgY21kcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3MgPSBjdXJyZW50LmFyZ3MgIT09IHVuZGVmaW5lZCA/IGN1cnJlbnQuYXJncy5qb2luKCIsIikgOiAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqc0J1Zi5wdXNoKCJjLiIsIGN1cnJlbnQuY21kLCAiKCIsIGFyZ3MsICIpO1xuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb21waWxlZEdseXBoc1tjaGFyYWN0ZXJdID0gbmV3IEZ1bmN0aW9uKCJjIiwgInNpemUiLCBqc0J1Zi5qb2luKCIiKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29tcGlsZWRHbHlwaHNbY2hhcmFjdGVyXSA9IGZ1bmN0aW9uIChjLCBzaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGN1cnJlbnQgb2YgY21kcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LmNtZCA9PT0gInNjYWxlIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmFyZ3MgPSBbc2l6ZSwgLXNpemVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjW2N1cnJlbnQuY21kXS5hcHBseShjLCBjdXJyZW50LmFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuRm9udEZhY2VPYmplY3QgPSBGb250RmFjZU9iamVjdDsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQ2ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQ2FudmFzR3JhcGhpY3MgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwbGF5X3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDIpOwogICAgICAgICAgICAgICAgdmFyIF9wYXR0ZXJuX2hlbHBlciA9IF9fd19wZGZqc19yZXF1a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RSA9IDE1OwogICAgICAgICAgICAgICAgY29uc3QgRVhFQ1VUSU9OX1NURVBTID0gMTA7CiAgICAgICAgICAgICAgICBjb25zdCBNQVhfU0laRV9UT19DT01QSUxFID0gMTAwMDsKICAgICAgICAgICAgICAgIGNvbnN0IEZVTExfQ0hVTktfSEVJR0hUID0gMTY7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBtaXJyb3JDb250ZXh0T3BlcmF0aW9ucyhjdHgsIGRlc3RDdHgpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoY3R4Ll9yZW1vdmVNaXJyb3JpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJDb250ZXh0IGlzIGFscmVhZHkgZm9yd2FyZGluZyBvcGVyYXRpb25zLiIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFNhdmUgPSBjdHguc2F2ZTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFJlc3RvcmUgPSBjdHgucmVzdG9yZTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFJvdGF0ZSA9IGN0eC5yb3RhdGU7CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxTY2FsZSA9IGN0eC5zY2FsZTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFRyYW5zbGF0ZSA9IGN0eC50cmFuc2xhdGU7CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxUcmFuc2Zvcm0gPSBjdHgudHJhbnNmb3JtOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsU2V0VHJhbnNmb3JtID0gY3R4LnNldFRyYW5zZm9ybTsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbFJlc2V0VHJhbnNmb3JtID0gY3R4LnJlc2V0VHJhbnNmb3JtOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsQ2xpcCA9IGN0eC5jbGlwOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsTW92ZVRvID0gY3R4Lm1vdmVUbzsKICAgICAgICAgICAgICAgICAgICBjdHguX19vcmlnaW5hbExpbmVUbyA9IGN0eC5saW5lVG87CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxCZXppZXJDdXJ2ZVRvID0gY3R4LmJlemllckN1cnZlVG87CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxSZWN0ID0gY3R4LnJlY3Q7CiAgICAgICAgICAgICAgICAgICAgY3R4Ll9fb3JpZ2luYWxDbG9zZVBhdGggPSBjdHguY2xvc2VQYXRoOwogICAgICAgICAgICAgICAgICAgIGN0eC5fX29yaWdpbmFsQmVnaW5QYXRoID0gY3R4LmJlZ2luUGF0aDsKICAgICAgICAgICAgICAgICAgICBjdHguX3JlbW92ZU1pcnJvcmluZyA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUgPSBjdHguX19vcmlnaW5hbFNhdmU7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5yZXN0b3JlID0gY3R4Ll9fb3JpZ2luYWxSZXN0b3JlOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgucm90YXRlID0gY3R4Ll9fb3JpZ2luYWxSb3RhdGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZSA9IGN0eC5fX29yaWdpbmFsU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC50cmFuc2xhdGUgPSBjdHguX19vcmlnaW5hbFRyYW5zbGF0ZTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSA9IGN0eC5fX29yaWdpbmFsVHJhbnNmb3JtOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtID0gY3R4Ll9fb3JpZ2luYWxTZXRUcmFuc2Zvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5yZXNldFRyYW5zZm9ybSA9IGN0eC5fX29yaWdpbmFsUmVzZXRUcmFuc2Zvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5jbGlwID0gY3R4Ll9fb3JpZ2luYWxDbGlwOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgubW92ZVRvID0gY3R4Ll9fb3JpZ2luYWxNb3ZlVG87CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lVG8gPSBjdHguX19vcmlnaW5hbExpbmVUbzsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmJlemllckN1cnZlVG8gPSBjdHguX19vcmlnaW5hbEJlemllckN1cnZlVG87CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5yZWN0ID0gY3R4Ll9fb3JpZ2luYWxSZWN0OwogICAgICAgICAgICAgICAgICAgICAgICBjdHguY2xvc2VQYXRoID0gY3R4Ll9fb3JpZ2luYWxDbG9zZVBhdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZWdpblBhdGggPSBjdHguX19vcmlnaW5hbEJlZ2luUGF0aDsKICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIGN0eC5fcmVtb3ZlTWlycm9yaW5nOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUgPSBmdW5jdGlvbiBjdHhTYXZlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fX29yaWdpbmFsU2F2ZSgpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUgPSBmdW5jdGlvbiBjdHhSZXN0b3JlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fX29yaWdpbmFsUmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zbGF0ZSA9IGZ1bmN0aW9uIGN0eFRyYW5zbGF0ZSh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHgudHJhbnNsYXRlKHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxUcmFuc2xhdGUoeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjdHguc2NhbGUgPSBmdW5jdGlvbiBjdHhTY2FsZSh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHguc2NhbGUoeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbFNjYWxlKHgsIHkpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSA9IGZ1bmN0aW9uIGN0eFRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHgudHJhbnNmb3JtKGEsIGIsIGMsIGQsIGUsIGYpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxUcmFuc2Zvcm0oYSwgYiwgYywgZCwgZSwgZik7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtID0gZnVuY3Rpb24gY3R4U2V0VHJhbnNmb3JtKGEsIGIsIGMsIGQsIGUsIGYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdEN0eC5zZXRUcmFuc2Zvcm0oYSwgYiwgYywgZCwgZSwgZik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbFNldFRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGN0eC5yZXNldFRyYW5zZm9ybSA9IGZ1bmN0aW9uIGN0eFJlc2V0VHJhbnNmb3JtKCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LnJlc2V0VHJhbnNmb3JtKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbFJlc2V0VHJhbnNmb3JtKCk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjdHgucm90YXRlID0gZnVuY3Rpb24gY3R4Um90YXRlKGFuZ2xlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHgucm90YXRlKGFuZ2xlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fX29yaWdpbmFsUm90YXRlKGFuZ2xlKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGN0eC5jbGlwID0gZnVuY3Rpb24gY3R4Um90YXRlKHJ1bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdEN0eC5jbGlwKHJ1bGUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxDbGlwKHJ1bGUpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4Lm1vdmVUbyA9IGZ1bmN0aW9uICh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHgubW92ZVRvKHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxNb3ZlVG8oeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjdHgubGluZVRvID0gZnVuY3Rpb24gKHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdEN0eC5saW5lVG8oeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbExpbmVUbyh4LCB5KTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGN0eC5iZXppZXJDdXJ2ZVRvID0gZnVuY3Rpb24gKGNwMXgsIGNwMXksIGNwMngsIGNwMnksIHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdEN0eC5iZXppZXJDdXJ2ZVRvKGNwMXgsIGNwMXksIGNwMngsIGNwMnksIHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxCZXppZXJDdXJ2ZVRvKGNwMXgsIGNwMXksIGNwMngsIGNwMnksIHgsIHkpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY3R4LnJlY3QgPSBmdW5jdGlvbiAoeCwgeSwgd2lkdGgsIGhlaWdodCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LnJlY3QoeCwgeSwgd2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbFJlY3QoeCwgeSwgd2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjdHguY2xvc2VQYXRoID0gZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LmNsb3NlUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9fb3JpZ2luYWxDbG9zZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGN0eC5iZWdpblBhdGggPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHguYmVnaW5QYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX19vcmlnaW5hbEJlZ2luUGF0aCgpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDYWNoZWRDYW52YXNlcyB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoY2FudmFzRmFjdG9yeSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkgPSBjYW52YXNGYWN0b3J5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhY2hlID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0Q2FudmFzKGlkLCB3aWR0aCwgaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjYW52YXNFbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY2FjaGVbaWRdICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc0VudHJ5ID0gdGhpcy5jYWNoZVtpZF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkucmVzZXQoY2FudmFzRW50cnksIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzRW50cnkgPSB0aGlzLmNhbnZhc0ZhY3RvcnkuY3JlYXRlKHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYWNoZVtpZF0gPSBjYW52YXNFbnRyeTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FudmFzRW50cnk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlbGV0ZShpZCkgewogICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5jYWNoZVtpZF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsZWFyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGlkIGluIHRoaXMuY2FjaGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbnZhc0VudHJ5ID0gdGhpcy5jYWNoZVtpZF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhc0ZhY3RvcnkuZGVzdHJveShjYW52YXNFbnRyeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5jYWNoZVtpZF07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBkcmF3SW1hZ2VBdEludGVnZXJDb29yZHMoY3R4LCBzcmNJbWcsIHNyY1gsIHNyY1ksIHNyY1csIHNyY0gsIGRlc3RYLCBkZXN0WSwgZGVzdFcsIGRlc3RIKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgW2EsIGIsIGMsIGQsIHR4LCB0eV0gPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3R4KTsKICAgICAgICAgICAgICAgICAgICBpZiAoYiA9PT0gMCAmJiBjID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRsWCA9IGRlc3RYICogYSArIHR4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByVGxYID0gTWF0aC5yb3VuZCh0bFgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bFkgPSBkZXN0WSAqIGQgKyB0eTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgclRsWSA9IE1hdGgucm91bmQodGxZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnJYID0gKGRlc3RYICsgZGVzdFcpICogYSArIHR4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByV2lkdGggPSBNYXRoLmFicyhNYXRoLnJvdW5kKGJyWCkgLSByVGxYKSB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiclkgPSAoZGVzdFkgKyBkZXN0SCkgKiBkICsgdHk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJIZWlnaHQgPSBNYXRoLmFicyhNYXRoLnJvdW5kKGJyWSkgLSByVGxZKSB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKE1hdGguc2lnbihhKSwgMCwgMCwgTWF0aC5zaWduKGQpLCByVGxYLCByVGxZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZShzcmNJbWcsIHNyY1gsIHNyY1ksIHNyY1csIHNyY0gsIDAsIDAsIHJXaWR0aCwgckhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRUcmFuc2Zvcm0oYSwgYiwgYywgZCwgdHgsIHR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtyV2lkdGgsIHJIZWlnaHRdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoYSA9PT0gMCAmJiBkID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRsWCA9IGRlc3RZICogYyArIHR4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByVGxYID0gTWF0aC5yb3VuZCh0bFgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bFkgPSBkZXN0WCAqIGIgKyB0eTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgclRsWSA9IE1hdGgucm91bmQodGxZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnJYID0gKGRlc3RZICsgZGVzdEgpICogYyArIHR4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByV2lkdGggPSBNYXRoLmFicyhNYXRoLnJvdW5kKGJyWCkgLSByVGxYKSB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiclkgPSAoZGVzdFggKyBkZXN0VykgKiBiICsgdHk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJIZWlnaHQgPSBNYXRoLmFicyhNYXRoLnJvdW5kKGJyWSkgLSByVGxZKSB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDAsIE1hdGguc2lnbihiKSwgTWF0aC5zaWduKGMpLCAwLCByVGxYLCByVGxZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZShzcmNJbWcsIHNyY1gsIHNyY1ksIHNyY1csIHNyY0gsIDAsIDAsIHJIZWlnaHQsIHJXaWR0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRUcmFuc2Zvcm0oYSwgYiwgYywgZCwgdHgsIHR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtySGVpZ2h0LCByV2lkdGhdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjdHguZHJhd0ltYWdlKHNyY0ltZywgc3JjWCwgc3JjWSwgc3JjVywgc3JjSCwgZGVzdFgsIGRlc3RZLCBkZXN0VywgZGVzdEgpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlWCA9IE1hdGguaHlwb3QoYSwgYik7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVZID0gTWF0aC5oeXBvdChjLCBkKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3NjYWxlWCAqIGRlc3RXLCBzY2FsZVkgKiBkZXN0SF07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjb21waWxlVHlwZTNHbHlwaChpbWdEYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgaGVpZ2h0CiAgICAgICAgICAgICAgICAgICAgfSA9IGltZ0RhdGE7CiAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoID4gTUFYX1NJWkVfVE9fQ09NUElMRSB8fCBoZWlnaHQgPiBNQVhfU0laRV9UT19DT01QSUxFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBQT0lOVF9UT19QUk9DRVNTX0xJTUlUID0gMTAwMDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBQT0lOVF9UWVBFUyA9IG5ldyBVaW50OEFycmF5KFswLCAyLCA0LCAwLCAxLCAwLCA1LCA0LCA4LCAxMCwgMCwgOCwgMCwgMiwgMSwgMF0pOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoMSA9IHdpZHRoICsgMTsKICAgICAgICAgICAgICAgICAgICBsZXQgcG9pbnRzID0gbmV3IFVpbnQ4QXJyYXkod2lkdGgxICogKGhlaWdodCArIDEpKTsKICAgICAgICAgICAgICAgICAgICBsZXQgaSwgaiwgajA7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGluZVNpemUgPSB3aWR0aCArIDcgJiB+NzsKICAgICAgICAgICAgICAgICAgICBsZXQgZGF0YSA9IG5ldyBVaW50OEFycmF5KGxpbmVTaXplICogaGVpZ2h0KSwKICAgICAgICAgICAgICAgICAgICAgICAgcG9zID0gMDsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVsZW0gb2YgaW1nRGF0YS5kYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtYXNrID0gMTI4OwogICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAobWFzayA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFbcG9zKytdID0gZWxlbSAmIG1hc2sgPyAwIDogMjU1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFzayA+Pj0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBsZXQgY291bnQgPSAwOwogICAgICAgICAgICAgICAgICAgIHBvcyA9IDA7CiAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGFbcG9zXSAhPT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICBwb2ludHNbMF0gPSAxOwogICAgICAgICAgICAgICAgICAgICAgICArK2NvdW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGogPSAxOyBqIDwgd2lkdGg7IGorKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVtwb3NdICE9PSBkYXRhW3BvcyArIDFdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludHNbal0gPSBkYXRhW3Bvc10gPyAyIDogMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICsrY291bnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcG9zKys7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChkYXRhW3Bvc10gIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzW2pdID0gMjsKICAgICAgICAgICAgICAgICAgICAgICAgKytjb3VudDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMTsgaSA8IGhlaWdodDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvcyA9IGkgKiBsaW5lU2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgajAgPSBpICogd2lkdGgxOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVtwb3MgLSBsaW5lU2l6ZV0gIT09IGRhdGFbcG9zXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzW2owXSA9IGRhdGFbcG9zXSA/IDEgOiA4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKytjb3VudDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc3VtID0gKGRhdGFbcG9zXSA/IDQgOiAwKSArIChkYXRhW3BvcyAtIGxpbmVTaXplXSA/IDggOiAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChqID0gMTsgaiA8IHdpZHRoOyBqKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1bSA9IChzdW0gPj4gMikgKyAoZGF0YVtwb3MgKyAxXSA/IDQgOiAwKSArIChkYXRhW3BvcyAtIGxpbmVTaXplICsgMV0gPyA4IDogMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoUE9JTlRfVFlQRVNbc3VtXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50c1tqMCArIGpdID0gUE9JTlRfVFlQRVNbc3VtXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICArK2NvdW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9zKys7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGFbcG9zIC0gbGluZVNpemVdICE9PSBkYXRhW3Bvc10pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50c1tqMCArIGpdID0gZGF0YVtwb3NdID8gMiA6IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICArK2NvdW50OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjb3VudCA+IFBPSU5UX1RPX1BST0NFU1NfTElNSVQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBvcyA9IGxpbmVTaXplICogKGhlaWdodCAtIDEpOwogICAgICAgICAgICAgICAgICAgIGowID0gaSAqIHdpZHRoMTsKICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVtwb3NdICE9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50c1tqMF0gPSA4OwogICAgICAgICAgICAgICAgICAgICAgICArK2NvdW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGogPSAxOyBqIDwgd2lkdGg7IGorKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YVtwb3NdICE9PSBkYXRhW3BvcyArIDFdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludHNbajAgKyBqXSA9IGRhdGFbcG9zXSA/IDQgOiA4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKytjb3VudDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwb3MrKzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGFbcG9zXSAhPT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICBwb2ludHNbajAgKyBqXSA9IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICsrY291bnQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChjb3VudCA+IFBPSU5UX1RPX1BST0NFU1NfTElNSVQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0ZXBzID0gbmV3IEludDMyQXJyYXkoWzAsIHdpZHRoMSwgLTEsIDAsIC13aWR0aDEsIDAsIDAsIDAsIDFdKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRoID0gbmV3IFBhdGgyRCgpOwogICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGNvdW50ICYmIGkgPD0gaGVpZ2h0OyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHAgPSBpICogd2lkdGgxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmQgPSBwICsgd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlIChwIDwgZW5kICYmICFwb2ludHNbcF0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHArKzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAocCA9PT0gZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwYXRoLm1vdmVUbyhwICUgd2lkdGgxLCBpKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDAgPSBwOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgdHlwZSA9IHBvaW50c1twXTsKICAgICAgICAgICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RlcCA9IHN0ZXBzW3R5cGVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHAgKz0gc3RlcDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gd2hpbGUgKCFwb2ludHNbcF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHAgPSBwb2ludHNbcF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocHAgIT09IDUgJiYgcHAgIT09IDEwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZSA9IHBwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50c1twXSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUgPSBwcCAmIDB4MzMgKiB0eXBlID4+IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzW3BdICY9IHR5cGUgPj4gMiB8IHR5cGUgPDwgMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgubGluZVRvKHAgJSB3aWR0aDEsIHAgLyB3aWR0aDEgfCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghcG9pbnRzW3BdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLS1jb3VudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSB3aGlsZSAocDAgIT09IHApOwogICAgICAgICAgICAgICAgICAgICAgICAtLWk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRhdGEgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIHBvaW50cyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd091dGxpbmUgPSBmdW5jdGlvbiAoYykgewogICAgICAgICAgICAgICAgICAgICAgICBjLnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgYy5zY2FsZSgxIC8gd2lkdGgsIC0xIC8gaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgYy50cmFuc2xhdGUoMCwgLWhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGMuZmlsbChwYXRoKTsKICAgICAgICAgICAgICAgICAgICAgICAgYy5iZWdpblBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgYy5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gZHJhd091dGxpbmU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDYW52YXNFeHRyYVN0YXRlIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3Rvcih3aWR0aCwgaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWxwaGFJc1NoYXBlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZm9udFNpemUgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZvbnRTaXplU2NhbGUgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRNYXRyaXggPSBfdXRpbC5JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGV4dE1hdHJpeFNjYWxlID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5mb250TWF0cml4ID0gX3V0aWwuRk9OVF9JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGVhZGluZyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGluZVggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmVZID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jaGFyU3BhY2luZyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMud29yZFNwYWNpbmcgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRIU2NhbGUgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRSZW5kZXJpbmdNb2RlID0gX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuRklMTDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50ZXh0UmlzZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbENvbG9yID0gIiMwMDAwMDAiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cm9rZUNvbG9yID0gIiMwMDAwMDAiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhdHRlcm5GaWxsID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbEFscGhhID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJva2VBbHBoYSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGluZVdpZHRoID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hY3RpdmVTTWFzayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNmZXJNYXBzID0gIm5vbmUiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0YXJ0TmV3UGF0aEFuZENsaXBCb3goWzAsIDAsIHdpZHRoLCBoZWlnaHRdKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2xvbmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNsb25lID0gT2JqZWN0LmNyZWF0ZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2xvbmUuY2xpcEJveCA9IHRoaXMuY2xpcEJveC5zbGljZSgpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2xvbmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEN1cnJlbnRQb2ludCh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCA9IHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueSA9IHk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHVwZGF0ZVBhdGhNaW5NYXgodHJhbnNmb3JtLCB4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIFt4LCB5XSA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oW3gsIHldLCB0cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1pblggPSBNYXRoLm1pbih0aGlzLm1pblgsIHgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1pblkgPSBNYXRoLm1pbih0aGlzLm1pblksIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1heFggPSBNYXRoLm1heCh0aGlzLm1heFgsIHgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1heFkgPSBNYXRoLm1heCh0aGlzLm1heFksIHkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGVSZWN0TWluTWF4KHRyYW5zZm9ybSwgcmVjdCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMSA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0ocmVjdCwgdHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDIgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKHJlY3Quc2xpY2UoMiksIHRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWluWCA9IE1hdGgubWluKHRoaXMubWluWCwgcDFbMF0sIHAyWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5taW5ZID0gTWF0aC5taW4odGhpcy5taW5ZLCBwMVsxXSwgcDJbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1heFggPSBNYXRoLm1heCh0aGlzLm1heFgsIHAxWzBdLCBwMlswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWF4WSA9IE1hdGgubWF4KHRoaXMubWF4WSwgcDFbMV0sIHAyWzFdKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlU2NhbGluZ1BhdGhNaW5NYXgodHJhbnNmb3JtLCBtaW5NYXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX3V0aWwuVXRpbC5zY2FsZU1pbk1heCh0cmFuc2Zvcm0sIG1pbk1heCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWluWCA9IE1hdGgubWluKHRoaXMubWluWCwgbWluTWF4WzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tYXhYID0gTWF0aC5tYXgodGhpcy5tYXhYLCBtaW5NYXhbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1pblkgPSBNYXRoLm1pbih0aGlzLm1pblksIG1pbk1heFsyXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWF4WSA9IE1hdGgubWF4KHRoaXMubWF4WSwgbWluTWF4WzNdKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlQ3VydmVQYXRoTWluTWF4KHRyYW5zZm9ybSwgeDAsIHkwLCB4MSwgeTEsIHgyLCB5MiwgeDMsIHkzLCBtaW5NYXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYm94ID0gX3V0aWwuVXRpbC5iZXppZXJCb3VuZGluZ0JveCh4MCwgeTAsIHgxLCB5MSwgeDIsIHkyLCB4MywgeTMpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobWluTWF4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbMF0gPSBNYXRoLm1pbihtaW5NYXhbMF0sIGJveFswXSwgYm94WzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1pbk1heFsxXSA9IE1hdGgubWF4KG1pbk1heFsxXSwgYm94WzBdLCBib3hbMl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWluTWF4WzJdID0gTWF0aC5taW4obWluTWF4WzJdLCBib3hbMV0sIGJveFszXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtaW5NYXhbM10gPSBNYXRoLm1heChtaW5NYXhbM10sIGJveFsxXSwgYm94WzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnVwZGF0ZVJlY3RNaW5NYXgodHJhbnNmb3JtLCBib3gpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYXRoQm91bmRpbmdCb3goKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwYXRoVHlwZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogX3BhdHRlcm5faGVscGVyLlBhdGhUeXBlLkZJTEw7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0cmFuc2Zvcm0gPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJveCA9IFt0aGlzLm1pblgsIHRoaXMubWluWSwgdGhpcy5tYXhYLCB0aGlzLm1heFldOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGF0aFR5cGUgPT09IF9wYXR0ZXJuX2hlbHBlci5QYXRoVHlwZS5TVFJPS0UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdHJhbnNmb3JtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiU3Ryb2tlIGJvdW5kaW5nIGJveCBtdXN0IGluY2x1ZGUgdHJhbnNmb3JtLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSBfdXRpbC5VdGlsLnNpbmd1bGFyVmFsdWVEZWNvbXBvc2UyZFNjYWxlKHRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4U3Ryb2tlUGFkID0gc2NhbGVbMF0gKiB0aGlzLmxpbmVXaWR0aCAvIDI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5U3Ryb2tlUGFkID0gc2NhbGVbMV0gKiB0aGlzLmxpbmVXaWR0aCAvIDI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBib3hbMF0gLT0geFN0cm9rZVBhZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJveFsxXSAtPSB5U3Ryb2tlUGFkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm94WzJdICs9IHhTdHJva2VQYWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBib3hbM10gKz0geVN0cm9rZVBhZDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYm94OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGVDbGlwRnJvbVBhdGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGludGVyc2VjdCA9IF91dGlsLlV0aWwuaW50ZXJzZWN0KHRoaXMuY2xpcEJveCwgdGhpcy5nZXRQYXRoQm91bmRpbmdCb3goKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhcnROZXdQYXRoQW5kQ2xpcEJveChpbnRlcnNlY3QgfHwgWzAsIDAsIDAsIDBdKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNFbXB0eUNsaXAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLm1pblggPT09IEluZmluaXR5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGFydE5ld1BhdGhBbmRDbGlwQm94KGJveCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXBCb3ggPSBib3g7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWluWCA9IEluZmluaXR5OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1pblkgPSBJbmZpbml0eTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tYXhYID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tYXhZID0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0Q2xpcHBlZFBhdGhCb3VuZGluZ0JveCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHBhdGhUeXBlID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBfcGF0dGVybl9oZWxwZXIuUGF0aFR5cGUuRklMTDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRyYW5zZm9ybSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLlV0aWwuaW50ZXJzZWN0KHRoaXMuY2xpcEJveCwgdGhpcy5nZXRQYXRoQm91bmRpbmdCb3gocGF0aFR5cGUsIHRyYW5zZm9ybSkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHB1dEJpbmFyeUltYWdlRGF0YShjdHgsIGltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIEltYWdlRGF0YSAhPT0gInVuZGVmaW5lZCIgJiYgaW1nRGF0YSBpbnN0YW5jZW9mIEltYWdlRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBjdHgucHV0SW1hZ2VEYXRhKGltZ0RhdGEsIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGltZ0RhdGEuaGVpZ2h0LAogICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCA9IGltZ0RhdGEud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFydGlhbENodW5rSGVpZ2h0ID0gaGVpZ2h0ICUgRlVMTF9DSFVOS19IRUlHSFQ7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZnVsbENodW5rcyA9IChoZWlnaHQgLSBwYXJ0aWFsQ2h1bmtIZWlnaHQpIC8gRlVMTF9DSFVOS19IRUlHSFQ7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgdG90YWxDaHVua3MgPSBwYXJ0aWFsQ2h1bmtIZWlnaHQgPT09IDAgPyBmdWxsQ2h1bmtzIDogZnVsbENodW5rcyArIDE7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgY2h1bmtJbWdEYXRhID0gY3R4LmNyZWF0ZUltYWdlRGF0YSh3aWR0aCwgRlVMTF9DSFVOS19IRUlHSFQpOwogICAgICAgICAgICAgICAgICAgIGxldCBzcmNQb3MgPSAwLAogICAgICAgICAgICAgICAgICAgICAgICBkZXN0UG9zOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNyYyA9IGltZ0RhdGEuZGF0YTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBkZXN0ID0gY2h1bmtJbWdEYXRhLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgbGV0IGksIGosIHRoaXNDaHVua0hlaWdodCwgZWxlbXNJblRoaXNDaHVuazsKICAgICAgICAgICAgICAgICAgICBpZiAoaW1nRGF0YS5raW5kID09PSBfdXRpbC5JbWFnZUtpbmQuR1JBWVNDQUxFXzFCUFApIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3JjTGVuZ3RoID0gc3JjLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlc3QzMiA9IG5ldyBVaW50MzJBcnJheShkZXN0LmJ1ZmZlciwgMCwgZGVzdC5ieXRlTGVuZ3RoID4+IDIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZXN0MzJEYXRhTGVuZ3RoID0gZGVzdDMyLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZnVsbFNyY0RpZmYgPSB3aWR0aCArIDcgPj4gMzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2hpdGUgPSAweGZmZmZmZmZmOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBibGFjayA9IF91dGlsLkZlYXR1cmVUZXN0LmlzTGl0dGxlRW5kaWFuID8gMHhmZjAwMDAwMCA6IDB4MDAwMDAwZmY7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCB0b3RhbENodW5rczsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzQ2h1bmtIZWlnaHQgPSBpIDwgZnVsbENodW5rcyA/IEZVTExfQ0hVTktfSEVJR0hUIDogcGFydGlhbENodW5rSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFBvcyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgdGhpc0NodW5rSGVpZ2h0OyBqKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcmNEaWZmID0gc3JjTGVuZ3RoIC0gc3JjUG9zOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBrRW5kID0gc3JjRGlmZiA+IGZ1bGxTcmNEaWZmID8gd2lkdGggOiBzcmNEaWZmICogOCAtIDc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qga0VuZFVucm9sbGVkID0ga0VuZCAmIH43OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtYXNrID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgc3JjQnl0ZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yICg7IGsgPCBrRW5kVW5yb2xsZWQ7IGsgKz0gOCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcmNCeXRlID0gc3JjW3NyY1BvcysrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSBzcmNCeXRlICYgMTI4ID8gd2hpdGUgOiBibGFjazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSBzcmNCeXRlICYgNjQgPyB3aGl0ZSA6IGJsYWNrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0MzJbZGVzdFBvcysrXSA9IHNyY0J5dGUgJiAzMiA/IHdoaXRlIDogYmxhY2s7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3QzMltkZXN0UG9zKytdID0gc3JjQnl0ZSAmIDE2ID8gd2hpdGUgOiBibGFjazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSBzcmNCeXRlICYgOCA/IHdoaXRlIDogYmxhY2s7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3QzMltkZXN0UG9zKytdID0gc3JjQnl0ZSAmIDQgPyB3aGl0ZSA6IGJsYWNrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0MzJbZGVzdFBvcysrXSA9IHNyY0J5dGUgJiAyID8gd2hpdGUgOiBibGFjazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSBzcmNCeXRlICYgMSA/IHdoaXRlIDogYmxhY2s7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoOyBrIDwga0VuZDsgaysrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXNrID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcmNCeXRlID0gc3JjW3NyY1BvcysrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hc2sgPSAxMjg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSBzcmNCeXRlICYgbWFzayA/IHdoaXRlIDogYmxhY2s7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hc2sgPj49IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKGRlc3RQb3MgPCBkZXN0MzJEYXRhTGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdDMyW2Rlc3RQb3MrK10gPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnB1dEltYWdlRGF0YShjaHVua0ltZ0RhdGEsIDAsIGkgKiBGVUxMX0NIVU5LX0hFSUdIVCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGltZ0RhdGEua2luZCA9PT0gX3V0aWwuSW1hZ2VLaW5kLlJHQkFfMzJCUFApIHsKICAgICAgICAgICAgICAgICAgICAgICAgaiA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1zSW5UaGlzQ2h1bmsgPSB3aWR0aCAqIEZVTExfQ0hVTktfSEVJR0hUICogNDsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMDsgaSA8IGZ1bGxDaHVua3M7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdC5zZXQoc3JjLnN1YmFycmF5KHNyY1Bvcywgc3JjUG9zICsgZWxlbXNJblRoaXNDaHVuaykpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3JjUG9zICs9IGVsZW1zSW5UaGlzQ2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucHV0SW1hZ2VEYXRhKGNodW5rSW1nRGF0YSwgMCwgaik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBqICs9IEZVTExfQ0hVTktfSEVJR0hUOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpIDwgdG90YWxDaHVua3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1zSW5UaGlzQ2h1bmsgPSB3aWR0aCAqIHBhcnRpYWxDaHVua0hlaWdodCAqIDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0LnNldChzcmMuc3ViYXJyYXkoc3JjUG9zLCBzcmNQb3MgKyBlbGVtc0luVGhpc0NodW5rKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucHV0SW1hZ2VEYXRhKGNodW5rSW1nRGF0YSwgMCwgaik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGltZ0RhdGEua2luZCA9PT0gX3V0aWwuSW1hZ2VLaW5kLlJHQl8yNEJQUCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzQ2h1bmtIZWlnaHQgPSBGVUxMX0NIVU5LX0hFSUdIVDsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbXNJblRoaXNDaHVuayA9IHdpZHRoICogdGhpc0NodW5rSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgdG90YWxDaHVua3M7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPj0gZnVsbENodW5rcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXNDaHVua0hlaWdodCA9IHBhcnRpYWxDaHVua0hlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtc0luVGhpc0NodW5rID0gd2lkdGggKiB0aGlzQ2h1bmtIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0UG9zID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaiA9IGVsZW1zSW5UaGlzQ2h1bms7IGotLTspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBzcmNbc3JjUG9zKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcysrXSA9IHNyY1tzcmNQb3MrK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFtkZXN0UG9zKytdID0gc3JjW3NyY1BvcysrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucHV0SW1hZ2VEYXRhKGNodW5rSW1nRGF0YSwgMCwgaSAqIEZVTExfQ0hVTktfSEVJR0hUKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgYmFkIGltYWdlIGtpbmQ6ICR7aW1nRGF0YS5raW5kfWApOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHB1dEJpbmFyeUltYWdlTWFzayhjdHgsIGltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoaW1nRGF0YS5iaXRtYXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZShpbWdEYXRhLmJpdG1hcCwgMCwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gaW1nRGF0YS5oZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoID0gaW1nRGF0YS53aWR0aDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJ0aWFsQ2h1bmtIZWlnaHQgPSBoZWlnaHQgJSBGVUxMX0NIVU5LX0hFSUdIVDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBmdWxsQ2h1bmtzID0gKGhlaWdodCAtIHBhcnRpYWxDaHVua0hlaWdodCkgLyBGVUxMX0NIVU5LX0hFSUdIVDsKICAgICAgICAgICAgICAgICAgICBjb25zdCB0b3RhbENodW5rcyA9IHBhcnRpYWxDaHVua0hlaWdodCA9PT0gMCA/IGZ1bGxDaHVua3MgOiBmdWxsQ2h1bmtzICsgMTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVua0ltZ0RhdGEgPSBjdHguY3JlYXRlSW1hZ2VEYXRhKHdpZHRoLCBGVUxMX0NIVU5LX0hFSUdIVCk7CiAgICAgICAgICAgICAgICAgICAgbGV0IHNyY1BvcyA9IDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3JjID0gaW1nRGF0YS5kYXRhOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlc3QgPSBjaHVua0ltZ0RhdGEuZGF0YTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRvdGFsQ2h1bmtzOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGhpc0NodW5rSGVpZ2h0ID0gaSA8IGZ1bGxDaHVua3MgPyBGVUxMX0NIVU5LX0hFSUdIVCA6IHBhcnRpYWxDaHVua0hlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNyY1BvcwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gKDAsIF9pbWFnZV91dGlscy5jb252ZXJ0QmxhY2tBbmRXaGl0ZVRvUkdCQSkoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3JjLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3JjUG9zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVpZ2h0OiB0aGlzQ2h1bmtIZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub25CbGFja0NvbG9yOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnB1dEltYWdlRGF0YShjaHVua0ltZ0RhdGEsIDAsIGkgKiBGVUxMX0NIVU5LX0hFSUdIVCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29weUN0eFN0YXRlKHNvdXJjZUN0eCwgZGVzdEN0eCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHByb3BlcnRpZXMgPSBbInN0cm9rZVN0eWxlIiwgImZpbGxTdHlsZSIsICJmaWxsUnVsZSIsICJnbG9iYWxBbHBoYSIsICJsaW5lV2lkdGgiLCAibGluZUNhcCIsICJsaW5lSm9pbiIsICJtaXRlckxpbWl0IiwgImdsb2JhbENvbXBvc2l0ZU9wZXJhdGlvbiIsICJmb250IiwgImZpbHRlciJdOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcHJvcGVydHkgb2YgcHJvcGVydGllcykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoc291cmNlQ3R4W3Byb3BlcnR5XSAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4W3Byb3BlcnR5XSA9IHNvdXJjZUN0eFtwcm9wZXJ0eV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHNvdXJjZUN0eC5zZXRMaW5lRGFzaCAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RDdHguc2V0TGluZURhc2goc291cmNlQ3R4LmdldExpbmVEYXNoKCkpOwogICAgICAgICAgICAgICAgICAgICAgICBkZXN0Q3R4LmxpbmVEYXNoT2Zmc2V0ID0gc291cmNlQ3R4LmxpbmVEYXNoT2Zmc2V0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHJlc2V0Q3R4VG9EZWZhdWx0KGN0eCkgewogICAgICAgICAgICAgICAgICAgIGN0eC5zdHJva2VTdHlsZSA9IGN0eC5maWxsU3R5bGUgPSAiIzAwMDAwMCI7CiAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxSdWxlID0gIm5vbnplcm8iOwogICAgICAgICAgICAgICAgICAgIGN0eC5nbG9iYWxBbHBoYSA9IDE7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVXaWR0aCA9IDE7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVDYXAgPSAiYnV0dCI7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVKb2luID0gIm1pdGVyIjsKICAgICAgICAgICAgICAgICAgICBjdHgubWl0ZXJMaW1pdCA9IDEwOwogICAgICAgICAgICAgICAgICAgIGN0eC5nbG9iYWxDb21wb3NpdGVPcGVyYXRpb24gPSAic291cmNlLW92ZXIiOwogICAgICAgICAgICAgICAgICAgIGN0eC5mb250ID0gIjEwcHggc2Fucy1zZXJpZiI7CiAgICAgICAgICAgICAgICAgICAgaWYgKGN0eC5zZXRMaW5lRGFzaCAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRMaW5lRGFzaChbXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lRGFzaE9mZnNldCA9IDA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghX2lzX25vZGUuaXNOb2RlSlMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmZpbHRlciA9ICJub25lIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjb21wb3NlU01hc2tCYWNrZHJvcChieXRlcywgcjAsIGcwLCBiMCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxlbmd0aCA9IGJ5dGVzLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMzsgaSA8IGxlbmd0aDsgaSArPSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFscGhhID0gYnl0ZXNbaV07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhbHBoYSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZXNbaSAtIDNdID0gcjA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlc1tpIC0gMl0gPSBnMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2kgLSAxXSA9IGIwOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGFscGhhIDwgMjU1KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhbHBoYV8gPSAyNTUgLSBhbHBoYTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2kgLSAzXSA9IGJ5dGVzW2kgLSAzXSAqIGFscGhhICsgcjAgKiBhbHBoYV8gPj4gODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2kgLSAyXSA9IGJ5dGVzW2kgLSAyXSAqIGFscGhhICsgZzAgKiBhbHBoYV8gPj4gODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2kgLSAxXSA9IGJ5dGVzW2kgLSAxXSAqIGFscGhhICsgYjAgKiBhbHBoYV8gPj4gODsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNvbXBvc2VTTWFza0FscGhhKG1hc2tEYXRhLCBsYXllckRhdGEsIHRyYW5zZmVyTWFwKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuZ3RoID0gbWFza0RhdGEubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlID0gMSAvIDI1NTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMzsgaSA8IGxlbmd0aDsgaSArPSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFscGhhID0gdHJhbnNmZXJNYXAgPyB0cmFuc2Zlck1hcFttYXNrRGF0YVtpXV0gOiBtYXNrRGF0YVtpXTsKICAgICAgICAgICAgICAgICAgICAgICAgbGF5ZXJEYXRhW2ldID0gbGF5ZXJEYXRhW2ldICogYWxwaGEgKiBzY2FsZSB8IDA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29tcG9zZVNNYXNrTHVtaW5vc2l0eShtYXNrRGF0YSwgbGF5ZXJEYXRhLCB0cmFuc2Zlck1hcCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxlbmd0aCA9IG1hc2tEYXRhLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMzsgaSA8IGxlbmd0aDsgaSArPSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHkgPSBtYXNrRGF0YVtpIC0gM10gKiA3NyArIG1hc2tEYXRhW2kgLSAyXSAqIDE1MiArIG1hc2tEYXRhW2kgLSAxXSAqIDI4OwogICAgICAgICAgICAgICAgICAgICAgICBsYXllckRhdGFbaV0gPSB0cmFuc2Zlck1hcCA/IGxheWVyRGF0YVtpXSAqIHRyYW5zZmVyTWFwW3kgPj4gOF0gPj4gOCA6IGxheWVyRGF0YVtpXSAqIHkgPj4gMTY7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2VuZXJpY0NvbXBvc2VTTWFzayhtYXNrQ3R4LCBsYXllckN0eCwgd2lkdGgsIGhlaWdodCwgc3VidHlwZSwgYmFja2Ryb3AsIHRyYW5zZmVyTWFwLCBsYXllck9mZnNldFgsIGxheWVyT2Zmc2V0WSwgbWFza09mZnNldFgsIG1hc2tPZmZzZXRZKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgaGFzQmFja2Ryb3AgPSAhIWJhY2tkcm9wOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHIwID0gaGFzQmFja2Ryb3AgPyBiYWNrZHJvcFswXSA6IDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZzAgPSBoYXNCYWNrZHJvcCA/IGJhY2tkcm9wWzFdIDogMDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBiMCA9IGhhc0JhY2tkcm9wID8gYmFja2Ryb3BbMl0gOiAwOwogICAgICAgICAgICAgICAgICAgIGxldCBjb21wb3NlRm47CiAgICAgICAgICAgICAgICAgICAgaWYgKHN1YnR5cGUgPT09ICJMdW1pbm9zaXR5IikgewogICAgICAgICAgICAgICAgICAgICAgICBjb21wb3NlRm4gPSBjb21wb3NlU01hc2tMdW1pbm9zaXR5OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvc2VGbiA9IGNvbXBvc2VTTWFza0FscGhhOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBQSVhFTFNfVE9fUFJPQ0VTUyA9IDEwNDg1NzY7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgY2h1bmtTaXplID0gTWF0aC5taW4oaGVpZ2h0LCBNYXRoLmNlaWwoUElYRUxTX1RPX1BST0NFU1MgLyB3aWR0aCkpOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IHJvdyA9IDA7IHJvdyA8IGhlaWdodDsgcm93ICs9IGNodW5rU2l6ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVua0hlaWdodCA9IE1hdGgubWluKGNodW5rU2l6ZSwgaGVpZ2h0IC0gcm93KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFza0RhdGEgPSBtYXNrQ3R4LmdldEltYWdlRGF0YShsYXllck9mZnNldFggLSBtYXNrT2Zmc2V0WCwgcm93ICsgKGxheWVyT2Zmc2V0WSAtIG1hc2tPZmZzZXRZKSwgd2lkdGgsIGNodW5rSGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGF5ZXJEYXRhID0gbGF5ZXJDdHguZ2V0SW1hZ2VEYXRhKGxheWVyT2Zmc2V0WCwgcm93ICsgbGF5ZXJPZmZzZXRZLCB3aWR0aCwgY2h1bmtIZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaGFzQmFja2Ryb3ApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvc2VTTWFza0JhY2tkcm9wKG1hc2tEYXRhLmRhdGEsIHIwLCBnMCwgYjApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvc2VGbihtYXNrRGF0YS5kYXRhLCBsYXllckRhdGEuZGF0YSwgdHJhbnNmZXJNYXApOwogICAgICAgICAgICAgICAgICAgICAgICBsYXllckN0eC5wdXRJbWFnZURhdGEobGF5ZXJEYXRhLCBsYXllck9mZnNldFgsIHJvdyArIGxheWVyT2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29tcG9zZVNNYXNrKGN0eCwgc21hc2ssIGxheWVyQ3R4LCBsYXllckJveCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxheWVyT2Zmc2V0WCA9IGxheWVyQm94WzBdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxheWVyT2Zmc2V0WSA9IGxheWVyQm94WzFdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxheWVyV2lkdGggPSBsYXllckJveFsyXSAtIGxheWVyT2Zmc2V0WDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBsYXllckhlaWdodCA9IGxheWVyQm94WzNdIC0gbGF5ZXJPZmZzZXRZOwogICAgICAgICAgICAgICAgICAgIGlmIChsYXllcldpZHRoID09PSAwIHx8IGxheWVySGVpZ2h0ID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2VuZXJpY0NvbXBvc2VTTWFzayhzbWFzay5jb250ZXh0LCBsYXllckN0eCwgbGF5ZXJXaWR0aCwgbGF5ZXJIZWlnaHQsIHNtYXNrLnN1YnR5cGUsIHNtYXNrLmJhY2tkcm9wLCBzbWFzay50cmFuc2Zlck1hcCwgbGF5ZXJPZmZzZXRYLCBsYXllck9mZnNldFksIHNtYXNrLm9mZnNldFgsIHNtYXNrLm9mZnNldFkpOwogICAgICAgICAgICAgICAgICAgIGN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgY3R4Lmdsb2JhbEFscGhhID0gMTsKICAgICAgICAgICAgICAgICAgICBjdHguZ2xvYmFsQ29tcG9zaXRlT3BlcmF0aW9uID0gInNvdXJjZS1vdmVyIjsKICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDEsIDAsIDAsIDEsIDAsIDApOwogICAgICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UobGF5ZXJDdHguY2FudmFzLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ2V0SW1hZ2VTbW9vdGhpbmdFbmFibGVkKHRyYW5zZm9ybSwgaW50ZXJwb2xhdGUpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZSA9IF91dGlsLlV0aWwuc2luZ3VsYXJWYWx1ZURlY29tcG9zZTJkU2NhbGUodHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICBzY2FsZVswXSA9IE1hdGguZnJvdW5kKHNjYWxlWzBdKTsKICAgICAgICAgICAgICAgICAgICBzY2FsZVsxXSA9IE1hdGguZnJvdW5kKHNjYWxlWzFdKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBhY3R1YWxTY2FsZSA9IE1hdGguZnJvdW5kKChnbG9iYWxUaGlzLmRldmljZVBpeGVsUmF0aW8gfHwgMSkgKiBfZGlzcGxheV91dGlscy5QaXhlbHNQZXJJbmNoLlBERl9UT19DU1NfVU5JVFMpOwogICAgICAgICAgICAgICAgICAgIGlmIChpbnRlcnBvbGF0ZSAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpbnRlcnBvbGF0ZTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNjYWxlWzBdIDw9IGFjdHVhbFNjYWxlIHx8IHNjYWxlWzFdIDw9IGFjdHVhbFNjYWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0NBUF9TVFlMRVMgPSBbImJ1dHQiLCAicm91bmQiLCAic3F1YXJlIl07CiAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0pPSU5fU1RZTEVTID0gWyJtaXRlciIsICJyb3VuZCIsICJiZXZlbCJdOwogICAgICAgICAgICAgICAgY29uc3QgTk9STUFMX0NMSVAgPSB7fTsKICAgICAgICAgICAgICAgIGNvbnN0IEVPX0NMSVAgPSB7fTsKICAgICAgICAgICAgICAgIHZhciBfcmVzdG9yZUluaXRpYWxTdGF0ZSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgY2xhc3MgQ2FudmFzR3JhcGhpY3MgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKGNhbnZhc0N0eCwgY29tbW9uT2Jqcywgb2JqcywgY2FudmFzRmFjdG9yeSwgZmlsdGVyRmFjdG9yeSwgX3JlZiwgYW5ub3RhdGlvbkNhbnZhc01hcCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uYWxDb250ZW50Q29uZmlnLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFya2VkQ29udGVudFN0YWNrID0gbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9yZXN0b3JlSW5pdGlhbFN0YXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHggPSBjYW52YXNDdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudCA9IG5ldyBDYW52YXNFeHRyYVN0YXRlKHRoaXMuY3R4LmNhbnZhcy53aWR0aCwgdGhpcy5jdHguY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RhdGVTdGFjayA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBlbmRpbmdDbGlwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nRU9GaWxsID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVzID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy54b2JqcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbW9uT2JqcyA9IGNvbW1vbk9ianM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub2JqcyA9IG9ianM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzRmFjdG9yeSA9IGNhbnZhc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsdGVyRmFjdG9yeSA9IGZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JvdXBTdGFjayA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnByb2Nlc3NpbmdUeXBlMyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVRyYW5zZm9ybSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVRyYW5zZm9ybVN0YWNrID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JvdXBMZXZlbCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc21hc2tTdGFjayA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNtYXNrQ291bnRlciA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGVtcFNNYXNrID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdXNwZW5kZWRDdHggPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRlbnRWaXNpYmxlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tYXJrZWRDb250ZW50U3RhY2sgPSBtYXJrZWRDb250ZW50U3RhY2sgfHwgW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3B0aW9uYWxDb250ZW50Q29uZmlnID0gb3B0aW9uYWxDb250ZW50Q29uZmlnOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhY2hlZENhbnZhc2VzID0gbmV3IENhY2hlZENhbnZhc2VzKHRoaXMuY2FudmFzRmFjdG9yeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FjaGVkUGF0dGVybnMgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvbkNhbnZhc01hcCA9IGFubm90YXRpb25DYW52YXNNYXA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudmlld3BvcnRTY2FsZSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3V0cHV0U2NhbGVYID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vdXRwdXRTY2FsZVkgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRTY2FsZUZvclN0cm9raW5nID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkR2V0U2luZ2xlUGl4ZWxXaWR0aCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEJpdG1hcHNNYXAgPSBuZXcgTWFwKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE9iamVjdChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmYWxsYmFjayA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBkYXRhID09PSAic3RyaW5nIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGEuc3RhcnRzV2l0aCgiZ18iKSA/IHRoaXMuY29tbW9uT2Jqcy5nZXQoZGF0YSkgOiB0aGlzLm9ianMuZ2V0KGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxsYmFjazsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYmVnaW5EcmF3aW5nKF9yZWYyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zcGFyZW5jeSA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFja2dyb3VuZCA9IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYyOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IHRoaXMuY3R4LmNhbnZhcy53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gdGhpcy5jdHguY2FudmFzLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRGaWxsU3R5bGUgPSB0aGlzLmN0eC5maWxsU3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LmZpbGxTdHlsZSA9IGJhY2tncm91bmQgfHwgIiNmZmZmZmYiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5maWxsUmVjdCgwLCAwLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsbFN0eWxlID0gc2F2ZWRGaWxsU3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc3BhcmVuY3kpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50Q2FudmFzID0gdGhpcy5jYWNoZWRDYW52YXNlcy5nZXRDYW52YXMoInRyYW5zcGFyZW50Iiwgd2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbXBvc2l0ZUN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc3BhcmVudENhbnZhcyA9IHRyYW5zcGFyZW50Q2FudmFzLmNhbnZhczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4ID0gdHJhbnNwYXJlbnRDYW52YXMuY29udGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnRyYW5zZm9ybSguLi4oMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5jb21wb3NpdGVDdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc2V0Q3R4VG9EZWZhdWx0KHRoaXMuY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRyYW5zZm9ybSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgudHJhbnNmb3JtKC4uLnRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm91dHB1dFNjYWxlWCA9IHRyYW5zZm9ybVswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3V0cHV0U2NhbGVZID0gdHJhbnNmb3JtWzBdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnRyYW5zZm9ybSguLi52aWV3cG9ydC50cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZpZXdwb3J0U2NhbGUgPSB2aWV3cG9ydC5zY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5iYXNlVHJhbnNmb3JtID0gKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKHRoaXMuY3R4KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZXhlY3V0ZU9wZXJhdG9yTGlzdChvcGVyYXRvckxpc3QsIGV4ZWN1dGlvblN0YXJ0SWR4LCBjb250aW51ZUNhbGxiYWNrLCBzdGVwcGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3NBcnJheSA9IG9wZXJhdG9yTGlzdC5hcmdzQXJyYXk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZuQXJyYXkgPSBvcGVyYXRvckxpc3QuZm5BcnJheTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGkgPSBleGVjdXRpb25TdGFydElkeCB8fCAwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhcmdzQXJyYXlMZW4gPSBhcmdzQXJyYXkubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXJnc0FycmF5TGVuID09PSBpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVua09wZXJhdGlvbnMgPSBhcmdzQXJyYXlMZW4gLSBpID4gRVhFQ1VUSU9OX1NURVBTICYmIHR5cGVvZiBjb250aW51ZUNhbGxiYWNrID09PSAiZnVuY3Rpb24iOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmRUaW1lID0gY2h1bmtPcGVyYXRpb25zID8gRGF0ZS5ub3coKSArIEVYRUNVVElPTl9USU1FIDogMDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHN0ZXBzID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29tbW9uT2JqcyA9IHRoaXMuY29tbW9uT2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2JqcyA9IHRoaXMub2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGZuSWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlICh0cnVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RlcHBlciAhPT0gdW5kZWZpbmVkICYmIGkgPT09IHN0ZXBwZXIubmV4dEJyZWFrUG9pbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGVwcGVyLmJyZWFrSXQoaSwgY29udGludWVDYWxsYmFjayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbklkID0gZm5BcnJheVtpXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmbklkICE9PSBfdXRpbC5PUFMuZGVwZW5kZW5jeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXNbZm5JZF0uYXBwbHkodGhpcywgYXJnc0FycmF5W2ldKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBkZXBPYmpJZCBvZiBhcmdzQXJyYXlbaV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2Jqc1Bvb2wgPSBkZXBPYmpJZC5zdGFydHNXaXRoKCJnXyIpID8gY29tbW9uT2JqcyA6IG9ianM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb2Jqc1Bvb2wuaGFzKGRlcE9iaklkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Jqc1Bvb2wuZ2V0KGRlcE9iaklkLCBjb250aW51ZUNhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaSsrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IGFyZ3NBcnJheUxlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNodW5rT3BlcmF0aW9ucyAmJiArK3N0ZXBzID4gRVhFQ1VUSU9OX1NURVBTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKERhdGUubm93KCkgPiBlbmRUaW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlQ2FsbGJhY2soKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0ZXBzID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmREcmF3aW5nKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGFnZUNvbG9ycyA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVzdG9yZUluaXRpYWxTdGF0ZSwgX3Jlc3RvcmVJbml0aWFsU3RhdGUyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhY2hlZENhbnZhc2VzLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FjaGVkUGF0dGVybnMuY2xlYXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBjYWNoZSBvZiB0aGlzLl9jYWNoZWRCaXRtYXBzTWFwLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGNhbnZhcyBvZiBjYWNoZS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgSFRNTENhbnZhc0VsZW1lbnQgIT09ICJ1bmRlZmluZWQiICYmIGNhbnZhcyBpbnN0YW5jZW9mIEhUTUxDYW52YXNFbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcy53aWR0aCA9IGNhbnZhcy5oZWlnaHQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkQml0bWFwc01hcC5jbGVhcigpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFnZUNvbG9ycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGNtRmlsdGVySWQgPSB0aGlzLmZpbHRlckZhY3RvcnkuYWRkSENNRmlsdGVyKHBhZ2VDb2xvcnMuZm9yZWdyb3VuZCwgcGFnZUNvbG9ycy5iYWNrZ3JvdW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoY21GaWx0ZXJJZCAhPT0gIm5vbmUiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRGaWx0ZXIgPSB0aGlzLmN0eC5maWx0ZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsdGVyID0gaGNtRmlsdGVySWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZHJhd0ltYWdlKHRoaXMuY3R4LmNhbnZhcywgMCwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsdGVyID0gc2F2ZWRGaWx0ZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NjYWxlSW1hZ2UoaW1nLCBpbnZlcnNlVHJhbnNmb3JtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gaW1nLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBpbWcuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgd2lkdGhTY2FsZSA9IE1hdGgubWF4KE1hdGguaHlwb3QoaW52ZXJzZVRyYW5zZm9ybVswXSwgaW52ZXJzZVRyYW5zZm9ybVsxXSksIDEpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgaGVpZ2h0U2NhbGUgPSBNYXRoLm1heChNYXRoLmh5cG90KGludmVyc2VUcmFuc2Zvcm1bMl0sIGludmVyc2VUcmFuc2Zvcm1bM10pLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHBhaW50V2lkdGggPSB3aWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhaW50SGVpZ2h0ID0gaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgdG1wQ2FudmFzSWQgPSAicHJlc2NhbGUxIjsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRtcENhbnZhcywgdG1wQ3R4OwogICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAod2lkdGhTY2FsZSA+IDIgJiYgcGFpbnRXaWR0aCA+IDEgfHwgaGVpZ2h0U2NhbGUgPiAyICYmIHBhaW50SGVpZ2h0ID4gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG5ld1dpZHRoID0gcGFpbnRXaWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXdIZWlnaHQgPSBwYWludEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3aWR0aFNjYWxlID4gMiAmJiBwYWludFdpZHRoID4gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ld1dpZHRoID0gcGFpbnRXaWR0aCA+PSAxNjM4NCA/IE1hdGguZmxvb3IocGFpbnRXaWR0aCAvIDIpIC0gMSB8fCAxIDogTWF0aC5jZWlsKHBhaW50V2lkdGggLyAyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aFNjYWxlIC89IHBhaW50V2lkdGggLyBuZXdXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoZWlnaHRTY2FsZSA+IDIgJiYgcGFpbnRIZWlnaHQgPiAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3SGVpZ2h0ID0gcGFpbnRIZWlnaHQgPj0gMTYzODQgPyBNYXRoLmZsb29yKHBhaW50SGVpZ2h0IC8gMikgLSAxIHx8IDEgOiBNYXRoLmNlaWwocGFpbnRIZWlnaHQpIC8gMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHRTY2FsZSAvPSBwYWludEhlaWdodCAvIG5ld0hlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRtcENhbnZhcyA9IHRoaXMuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKHRtcENhbnZhc0lkLCBuZXdXaWR0aCwgbmV3SGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRtcEN0eCA9IHRtcENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LmNsZWFyUmVjdCgwLCAwLCBuZXdXaWR0aCwgbmV3SGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRtcEN0eC5kcmF3SW1hZ2UoaW1nLCAwLCAwLCBwYWludFdpZHRoLCBwYWludEhlaWdodCwgMCwgMCwgbmV3V2lkdGgsIG5ld0hlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWcgPSB0bXBDYW52YXMuY2FudmFzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRXaWR0aCA9IG5ld1dpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRIZWlnaHQgPSBuZXdIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXBDYW52YXNJZCA9IHRtcENhbnZhc0lkID09PSAicHJlc2NhbGUxIiA/ICJwcmVzY2FsZTIiIDogInByZXNjYWxlMSI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhaW50V2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWludEhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY3JlYXRlTWFza0NhbnZhcyhpbWcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVpZ2h0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBpbWc7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpbGxDb2xvciA9IHRoaXMuY3VycmVudC5maWxsQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzUGF0dGVybkZpbGwgPSB0aGlzLmN1cnJlbnQucGF0dGVybkZpbGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnRUcmFuc2Zvcm0gPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNhY2hlLCBjYWNoZUtleSwgc2NhbGVkLCBtYXNrQ2FudmFzOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoKGltZy5iaXRtYXAgfHwgaW1nLmRhdGEpICYmIGltZy5jb3VudCA+IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1haW5LZXkgPSBpbWcuYml0bWFwIHx8IGltZy5kYXRhLmJ1ZmZlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlS2V5ID0gSlNPTi5zdHJpbmdpZnkoaXNQYXR0ZXJuRmlsbCA/IGN1cnJlbnRUcmFuc2Zvcm0gOiBbY3VycmVudFRyYW5zZm9ybS5zbGljZSgwLCA0KSwgZmlsbENvbG9yXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZSA9IHRoaXMuX2NhY2hlZEJpdG1hcHNNYXAuZ2V0KG1haW5LZXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFjYWNoZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlID0gbmV3IE1hcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEJpdG1hcHNNYXAuc2V0KG1haW5LZXksIGNhY2hlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhY2hlZEltYWdlID0gY2FjaGUuZ2V0KGNhY2hlS2V5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjYWNoZWRJbWFnZSAmJiAhaXNQYXR0ZXJuRmlsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFggPSBNYXRoLnJvdW5kKE1hdGgubWluKGN1cnJlbnRUcmFuc2Zvcm1bMF0sIGN1cnJlbnRUcmFuc2Zvcm1bMl0pICsgY3VycmVudFRyYW5zZm9ybVs0XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2V0WSA9IE1hdGgucm91bmQoTWF0aC5taW4oY3VycmVudFRyYW5zZm9ybVsxXSwgY3VycmVudFRyYW5zZm9ybVszXSkgKyBjdXJyZW50VHJhbnNmb3JtWzVdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXM6IGNhY2hlZEltYWdlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZCA9IGNhY2hlZEltYWdlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc2NhbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXNrQ2FudmFzID0gdGhpcy5jYWNoZWRDYW52YXNlcy5nZXRDYW52YXMoIm1hc2tDYW52YXMiLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1dEJpbmFyeUltYWdlTWFzayhtYXNrQ2FudmFzLmNvbnRleHQsIGltZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG1hc2tUb0NhbnZhcyA9IF91dGlsLlV0aWwudHJhbnNmb3JtKGN1cnJlbnRUcmFuc2Zvcm0sIFsxIC8gd2lkdGgsIDAsIDAsIC0xIC8gaGVpZ2h0LCAwLCAwXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIG1hc2tUb0NhbnZhcyA9IF91dGlsLlV0aWwudHJhbnNmb3JtKG1hc2tUb0NhbnZhcywgWzEsIDAsIDAsIDEsIDAsIC1oZWlnaHRdKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29yZDEgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFswLCAwXSwgbWFza1RvQ2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29yZDIgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFt3aWR0aCwgaGVpZ2h0XSwgbWFza1RvQ2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IF91dGlsLlV0aWwubm9ybWFsaXplUmVjdChbY29yZDFbMF0sIGNvcmQxWzFdLCBjb3JkMlswXSwgY29yZDJbMV1dKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd25XaWR0aCA9IE1hdGgucm91bmQocmVjdFsyXSAtIHJlY3RbMF0pIHx8IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRyYXduSGVpZ2h0ID0gTWF0aC5yb3VuZChyZWN0WzNdIC0gcmVjdFsxXSkgfHwgMTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbENhbnZhcyA9IHRoaXMuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKCJmaWxsQ2FudmFzIiwgZHJhd25XaWR0aCwgZHJhd25IZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxsQ3R4ID0gZmlsbENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvZmZzZXRYID0gTWF0aC5taW4oY29yZDFbMF0sIGNvcmQyWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2V0WSA9IE1hdGgubWluKGNvcmQxWzFdLCBjb3JkMlsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxDdHgudHJhbnNsYXRlKC1vZmZzZXRYLCAtb2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxDdHgudHJhbnNmb3JtKC4uLm1hc2tUb0NhbnZhcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc2NhbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWQgPSB0aGlzLl9zY2FsZUltYWdlKG1hc2tDYW52YXMuY2FudmFzLCAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2UpKGZpbGxDdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZCA9IHNjYWxlZC5pbWc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2FjaGUgJiYgaXNQYXR0ZXJuRmlsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlLnNldChjYWNoZUtleSwgc2NhbGVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmaWxsQ3R4LmltYWdlU21vb3RoaW5nRW5hYmxlZCA9IGdldEltYWdlU21vb3RoaW5nRW5hYmxlZCgoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoZmlsbEN0eCksIGltZy5pbnRlcnBvbGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRyYXdJbWFnZUF0SW50ZWdlckNvb3JkcyhmaWxsQ3R4LCBzY2FsZWQsIDAsIDAsIHNjYWxlZC53aWR0aCwgc2NhbGVkLmhlaWdodCwgMCwgMCwgd2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxDdHguZ2xvYmFsQ29tcG9zaXRlT3BlcmF0aW9uID0gInNvdXJjZS1pbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGludmVyc2UgPSBfdXRpbC5VdGlsLnRyYW5zZm9ybSgoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2UpKGZpbGxDdHgpLCBbMSwgMCwgMCwgMSwgLW9mZnNldFgsIC1vZmZzZXRZXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGxDdHguZmlsbFN0eWxlID0gaXNQYXR0ZXJuRmlsbCA/IGZpbGxDb2xvci5nZXRQYXR0ZXJuKGN0eCwgdGhpcywgaW52ZXJzZSwgX3BhdHRlcm5faGVscGVyLlBhdGhUeXBlLkZJTEwpIDogZmlsbENvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICBmaWxsQ3R4LmZpbGxSZWN0KDAsIDAsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2FjaGUgJiYgIWlzUGF0dGVybkZpbGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FjaGVkQ2FudmFzZXMuZGVsZXRlKCJmaWxsQ2FudmFzIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZS5zZXQoY2FjaGVLZXksIGZpbGxDYW52YXMuY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzOiBmaWxsQ2FudmFzLmNhbnZhcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFg6IE1hdGgucm91bmQob2Zmc2V0WCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZOiBNYXRoLnJvdW5kKG9mZnNldFkpCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExpbmVXaWR0aCh3aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAod2lkdGggIT09IHRoaXMuY3VycmVudC5saW5lV2lkdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZFNjYWxlRm9yU3Ryb2tpbmcgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5saW5lV2lkdGggPSB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubGluZVdpZHRoID0gd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExpbmVDYXAoc3R5bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubGluZUNhcCA9IExJTkVfQ0FQX1NUWUxFU1tzdHlsZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExpbmVKb2luKHN0eWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LmxpbmVKb2luID0gTElORV9KT0lOX1NUWUxFU1tzdHlsZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldE1pdGVyTGltaXQobGltaXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubWl0ZXJMaW1pdCA9IGxpbWl0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXREYXNoKGRhc2hBcnJheSwgZGFzaFBoYXNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3R4LnNldExpbmVEYXNoICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRMaW5lRGFzaChkYXNoQXJyYXkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVEYXNoT2Zmc2V0ID0gZGFzaFBoYXNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFJlbmRlcmluZ0ludGVudChpbnRlbnQpIHt9CiAgICAgICAgICAgICAgICAgICAgc2V0RmxhdG5lc3MoZmxhdG5lc3MpIHt9CiAgICAgICAgICAgICAgICAgICAgc2V0R1N0YXRlKHN0YXRlcykgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IFtrZXksIHZhbHVlXSBvZiBzdGF0ZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoa2V5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTFciOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldExpbmVXaWR0aCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkxDIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRMaW5lQ2FwKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTEoiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldExpbmVKb2luKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTUwiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldE1pdGVyTGltaXQodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJEIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREYXNoKHZhbHVlWzBdLCB2YWx1ZVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlJJIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRSZW5kZXJpbmdJbnRlbnQodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJGTCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RmxhdG5lc3ModmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJGb250IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGb250KHZhbHVlWzBdLCB2YWx1ZVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkNBIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnN0cm9rZUFscGhhID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImNhIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmZpbGxBbHBoYSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5nbG9iYWxBbHBoYSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJCTSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4Lmdsb2JhbENvbXBvc2l0ZU9wZXJhdGlvbiA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJTTWFzayI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5hY3RpdmVTTWFzayA9IHZhbHVlID8gdGhpcy50ZW1wU01hc2sgOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRlbXBTTWFzayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2hlY2tTTWFza1N0YXRlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlRSIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsdGVyID0gdGhpcy5jdXJyZW50LnRyYW5zZmVyTWFwcyA9IHRoaXMuZmlsdGVyRmFjdG9yeS5hZGRGaWx0ZXIodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaW5TTWFza01vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhIXRoaXMuc3VzcGVuZGVkQ3R4OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjaGVja1NNYXNrU3RhdGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGluU01hc2tNb2RlID0gdGhpcy5pblNNYXNrTW9kZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY3VycmVudC5hY3RpdmVTTWFzayAmJiAhaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmVnaW5TTWFza01vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICghdGhpcy5jdXJyZW50LmFjdGl2ZVNNYXNrICYmIGluU01hc2tNb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFNNYXNrTW9kZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJlZ2luU01hc2tNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5pblNNYXNrTW9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJiZWdpblNNYXNrTW9kZSBjYWxsZWQgd2hpbGUgYWxyZWFkeSBpbiBzbWFzayBtb2RlIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd25XaWR0aCA9IHRoaXMuY3R4LmNhbnZhcy53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZHJhd25IZWlnaHQgPSB0aGlzLmN0eC5jYW52YXMuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYWNoZUlkID0gInNtYXNrR3JvdXBBdCIgKyB0aGlzLmdyb3VwTGV2ZWw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjcmF0Y2hDYW52YXMgPSB0aGlzLmNhY2hlZENhbnZhc2VzLmdldENhbnZhcyhjYWNoZUlkLCBkcmF3bldpZHRoLCBkcmF3bkhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3VzcGVuZGVkQ3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4ID0gc2NyYXRjaENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNldFRyYW5zZm9ybSguLi4oMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5zdXNwZW5kZWRDdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29weUN0eFN0YXRlKHRoaXMuc3VzcGVuZGVkQ3R4LCBjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICBtaXJyb3JDb250ZXh0T3BlcmF0aW9ucyhjdHgsIHRoaXMuc3VzcGVuZGVkQ3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRHU3RhdGUoW1siQk0iLCAic291cmNlLW92ZXIiXSwgWyJjYSIsIDFdLCBbIkNBIiwgMV1dKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5kU01hc2tNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiZW5kU01hc2tNb2RlIGNhbGxlZCB3aGlsZSBub3QgaW4gc21hc2sgbW9kZSIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4Ll9yZW1vdmVNaXJyb3JpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29weUN0eFN0YXRlKHRoaXMuY3R4LCB0aGlzLnN1c3BlbmRlZEN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4ID0gdGhpcy5zdXNwZW5kZWRDdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3VzcGVuZGVkQ3R4ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tcG9zZShkaXJ0eUJveCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY3VycmVudC5hY3RpdmVTTWFzaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZGlydHlCb3gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcnR5Qm94ID0gWzAsIDAsIHRoaXMuY3R4LmNhbnZhcy53aWR0aCwgdGhpcy5jdHguY2FudmFzLmhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXJ0eUJveFswXSA9IE1hdGguZmxvb3IoZGlydHlCb3hbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlydHlCb3hbMV0gPSBNYXRoLmZsb29yKGRpcnR5Qm94WzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcnR5Qm94WzJdID0gTWF0aC5jZWlsKGRpcnR5Qm94WzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpcnR5Qm94WzNdID0gTWF0aC5jZWlsKGRpcnR5Qm94WzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzbWFzayA9IHRoaXMuY3VycmVudC5hY3RpdmVTTWFzazsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3VzcGVuZGVkQ3R4ID0gdGhpcy5zdXNwZW5kZWRDdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbXBvc2VTTWFzayhzdXNwZW5kZWRDdHgsIHNtYXNrLCB0aGlzLmN0eCwgZGlydHlCb3gpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNldFRyYW5zZm9ybSgxLCAwLCAwLCAxLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xlYXJSZWN0KDAsIDAsIHRoaXMuY3R4LmNhbnZhcy53aWR0aCwgdGhpcy5jdHguY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2F2ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvcHlDdHhTdGF0ZSh0aGlzLmN0eCwgdGhpcy5zdXNwZW5kZWRDdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdXNwZW5kZWRDdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9sZCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdGF0ZVN0YWNrLnB1c2gob2xkKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50ID0gb2xkLmNsb25lKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlc3RvcmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnN0YXRlU3RhY2subGVuZ3RoID09PSAwICYmIHRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kU01hc2tNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuc3RhdGVTdGFjay5sZW5ndGggIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudCA9IHRoaXMuc3RhdGVTdGFjay5wb3AoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmluU01hc2tNb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdXNwZW5kZWRDdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvcHlDdHhTdGF0ZSh0aGlzLnN1c3BlbmRlZEN0eCwgdGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNoZWNrU01hc2tTdGF0ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nQ2xpcCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRTY2FsZUZvclN0cm9raW5nID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEdldFNpbmdsZVBpeGVsV2lkdGggPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkU2NhbGVGb3JTdHJva2luZyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZEdldFNpbmdsZVBpeGVsV2lkdGggPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RQYXRoKG9wcywgYXJncywgbWluTWF4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgeCA9IGN1cnJlbnQueCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBjdXJyZW50Lnk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdGFydFgsIHN0YXJ0WTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudFRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1NjYWxpbmdNYXRyaXggPSBjdXJyZW50VHJhbnNmb3JtWzBdID09PSAwICYmIGN1cnJlbnRUcmFuc2Zvcm1bM10gPT09IDAgfHwgY3VycmVudFRyYW5zZm9ybVsxXSA9PT0gMCAmJiBjdXJyZW50VHJhbnNmb3JtWzJdID09PSAwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtaW5NYXhGb3JCZXppZXIgPSBpc1NjYWxpbmdNYXRyaXggPyBtaW5NYXguc2xpY2UoMCkgOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaiA9IDAsIGlpID0gb3BzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAob3BzW2ldIHwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnJlY3RhbmdsZToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2lkdGggPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeHcgPSB4ICsgd2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHloID0geSArIGhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4Lm1vdmVUbyh4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoID09PSAwIHx8IGhlaWdodCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVUbyh4dywgeWgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVUbyh4dywgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgubGluZVRvKHh3LCB5aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgubGluZVRvKHgsIHloKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzU2NhbGluZ01hdHJpeCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC51cGRhdGVSZWN0TWluTWF4KGN1cnJlbnRUcmFuc2Zvcm0sIFt4LCB5LCB4dywgeWhdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm1vdmVUbzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4Lm1vdmVUbyh4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpc1NjYWxpbmdNYXRyaXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudXBkYXRlUGF0aE1pbk1heChjdXJyZW50VHJhbnNmb3JtLCB4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5saW5lVG86CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHggPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lVG8oeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNTY2FsaW5nTWF0cml4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnVwZGF0ZVBhdGhNaW5NYXgoY3VycmVudFRyYW5zZm9ybSwgeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY3VydmVUbzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRYID0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRZID0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaiArIDRdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5ID0gYXJnc1tqICsgNV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZXppZXJDdXJ2ZVRvKGFyZ3Nbal0sIGFyZ3NbaiArIDFdLCBhcmdzW2ogKyAyXSwgYXJnc1tqICsgM10sIHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnVwZGF0ZUN1cnZlUGF0aE1pbk1heChjdXJyZW50VHJhbnNmb3JtLCBzdGFydFgsIHN0YXJ0WSwgYXJnc1tqXSwgYXJnc1tqICsgMV0sIGFyZ3NbaiArIDJdLCBhcmdzW2ogKyAzXSwgeCwgeSwgbWluTWF4Rm9yQmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaiArPSA2OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jdXJ2ZVRvMjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRYID0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRZID0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmJlemllckN1cnZlVG8oeCwgeSwgYXJnc1tqXSwgYXJnc1tqICsgMV0sIGFyZ3NbaiArIDJdLCBhcmdzW2ogKyAzXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudXBkYXRlQ3VydmVQYXRoTWluTWF4KGN1cnJlbnRUcmFuc2Zvcm0sIHN0YXJ0WCwgc3RhcnRZLCB4LCB5LCBhcmdzW2pdLCBhcmdzW2ogKyAxXSwgYXJnc1tqICsgMl0sIGFyZ3NbaiArIDNdLCBtaW5NYXhGb3JCZXppZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ID0gYXJnc1tqICsgMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBhcmdzW2ogKyAzXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaiArPSA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jdXJ2ZVRvMzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRYID0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnRZID0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaiArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5ID0gYXJnc1tqICsgM107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZXppZXJDdXJ2ZVRvKGFyZ3Nbal0sIGFyZ3NbaiArIDFdLCB4LCB5LCB4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC51cGRhdGVDdXJ2ZVBhdGhNaW5NYXgoY3VycmVudFRyYW5zZm9ybSwgc3RhcnRYLCBzdGFydFksIGFyZ3Nbal0sIGFyZ3NbaiArIDFdLCB4LCB5LCB4LCB5LCBtaW5NYXhGb3JCZXppZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBqICs9IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmNsb3NlUGF0aDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmNsb3NlUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNTY2FsaW5nTWF0cml4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnVwZGF0ZVNjYWxpbmdQYXRoTWluTWF4KGN1cnJlbnRUcmFuc2Zvcm0sIG1pbk1heEZvckJlemllcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5zZXRDdXJyZW50UG9pbnQoeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsb3NlUGF0aCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0cm9rZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnN1bWVQYXRoID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3Ryb2tlQ29sb3IgPSB0aGlzLmN1cnJlbnQuc3Ryb2tlQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5nbG9iYWxBbHBoYSA9IHRoaXMuY3VycmVudC5zdHJva2VBbHBoYTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygc3Ryb2tlQ29sb3IgPT09ICJvYmplY3QiICYmIHN0cm9rZUNvbG9yICE9PSBudWxsICYmIHN0cm9rZUNvbG9yICE9PSB2b2lkIDAgJiYgc3Ryb2tlQ29sb3IuZ2V0UGF0dGVybikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnN0cm9rZVN0eWxlID0gc3Ryb2tlQ29sb3IuZ2V0UGF0dGVybihjdHgsIHRoaXMsICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtSW52ZXJzZSkoY3R4KSwgX3BhdHRlcm5faGVscGVyLlBhdGhUeXBlLlNUUk9LRSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXNjYWxlQW5kU3Ryb2tlKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJlc2NhbGVBbmRTdHJva2UodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNvbnN1bWVQYXRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnN1bWVQYXRoKHRoaXMuY3VycmVudC5nZXRDbGlwcGVkUGF0aEJvdW5kaW5nQm94KCkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5nbG9iYWxBbHBoYSA9IHRoaXMuY3VycmVudC5maWxsQWxwaGE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsb3NlU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsb3NlUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmaWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY29uc3VtZVBhdGggPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxsQ29sb3IgPSB0aGlzLmN1cnJlbnQuZmlsbENvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1BhdHRlcm5GaWxsID0gdGhpcy5jdXJyZW50LnBhdHRlcm5GaWxsOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbmVlZFJlc3RvcmUgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzUGF0dGVybkZpbGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsbFN0eWxlID0gZmlsbENvbG9yLmdldFBhdHRlcm4oY3R4LCB0aGlzLCAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2UpKGN0eCksIF9wYXR0ZXJuX2hlbHBlci5QYXRoVHlwZS5GSUxMKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5lZWRSZXN0b3JlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnRlcnNlY3QgPSB0aGlzLmN1cnJlbnQuZ2V0Q2xpcHBlZFBhdGhCb3VuZGluZ0JveCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb250ZW50VmlzaWJsZSAmJiBpbnRlcnNlY3QgIT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnBlbmRpbmdFT0ZpbGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsbCgiZXZlbm9kZCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0VPRmlsbCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsbCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZWVkUmVzdG9yZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY29uc3VtZVBhdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29uc3VtZVBhdGgoaW50ZXJzZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlb0ZpbGwoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0VPRmlsbCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGwoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cm9rZShmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29uc3VtZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW9GaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBlbmRpbmdFT0ZpbGwgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGxTdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2xvc2VGaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsb3NlUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGxTdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2xvc2VFT0ZpbGxTdHJva2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0VPRmlsbCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbFN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmRQYXRoKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnN1bWVQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsaXAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0NsaXAgPSBOT1JNQUxfQ0xJUDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW9DbGlwKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBlbmRpbmdDbGlwID0gRU9fQ0xJUDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYmVnaW5UZXh0KCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQudGV4dE1hdHJpeCA9IF91dGlsLklERU5USVRZX01BVFJJWDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnRleHRNYXRyaXhTY2FsZSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC54ID0gdGhpcy5jdXJyZW50LmxpbmVYID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnkgPSB0aGlzLmN1cnJlbnQubGluZVkgPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmRUZXh0KCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRocyA9IHRoaXMucGVuZGluZ1RleHRQYXRoczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYXRocyA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguYmVnaW5QYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmJlZ2luUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHBhdGggb2YgcGF0aHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRUcmFuc2Zvcm0oLi4ucGF0aC50cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zbGF0ZShwYXRoLngsIHBhdGgueSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoLmFkZFRvUGF0aChjdHgsIHBhdGguZm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5jbGlwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZWdpblBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHRoaXMucGVuZGluZ1RleHRQYXRoczsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0Q2hhclNwYWNpbmcoc3BhY2luZykgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuY2hhclNwYWNpbmcgPSBzcGFjaW5nOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRXb3JkU3BhY2luZyhzcGFjaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC53b3JkU3BhY2luZyA9IHNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEhTY2FsZShzY2FsZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQudGV4dEhTY2FsZSA9IHNjYWxlIC8gMTAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRMZWFkaW5nKGxlYWRpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmxlYWRpbmcgPSAtbGVhZGluZzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0Rm9udChmb250UmVmTmFtZSwgc2l6ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250T2JqID0gdGhpcy5jb21tb25PYmpzLmdldChmb250UmVmTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLmN1cnJlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZm9udE9iaikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBDYW4ndCBmaW5kIGZvbnQgZm9yICR7Zm9udFJlZk5hbWV9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5mb250TWF0cml4ID0gZm9udE9iai5mb250TWF0cml4IHx8IF91dGlsLkZPTlRfSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudC5mb250TWF0cml4WzBdID09PSAwIHx8IGN1cnJlbnQuZm9udE1hdHJpeFszXSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJJbnZhbGlkIGZvbnQgbWF0cml4IGZvciBmb250ICIgKyBmb250UmVmTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNpemUgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplID0gLXNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmZvbnREaXJlY3Rpb24gPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuZm9udERpcmVjdGlvbiA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmZvbnQgPSBmb250T2JqOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuZm9udFNpemUgPSBzaXplOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9udE9iai5pc1R5cGUzRm9udCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5hbWUgPSBmb250T2JqLmxvYWRlZE5hbWUgfHwgInNhbnMtc2VyaWYiOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYm9sZCA9ICJub3JtYWwiOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9udE9iai5ibGFjaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9sZCA9ICI5MDAiOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGZvbnRPYmouYm9sZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9sZCA9ICJib2xkIjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpdGFsaWMgPSBmb250T2JqLml0YWxpYyA/ICJpdGFsaWMiIDogIm5vcm1hbCI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHR5cGVmYWNlID0gYCIke25hbWV9IiwgJHtmb250T2JqLmZhbGxiYWNrTmFtZX1gOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYnJvd3NlckZvbnRTaXplID0gc2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNpemUgPCBNSU5fRk9OVF9TSVpFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicm93c2VyRm9udFNpemUgPSBNSU5fRk9OVF9TSVpFOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNpemUgPiBNQVhfRk9OVF9TSVpFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicm93c2VyRm9udFNpemUgPSBNQVhfRk9OVF9TSVpFOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5mb250U2l6ZVNjYWxlID0gc2l6ZSAvIGJyb3dzZXJGb250U2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZm9udCA9IGAke2l0YWxpY30gJHtib2xkfSAke2Jyb3dzZXJGb250U2l6ZX1weCAke3R5cGVmYWNlfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFRleHRSZW5kZXJpbmdNb2RlKG1vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnRleHRSZW5kZXJpbmdNb2RlID0gbW9kZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0VGV4dFJpc2UocmlzZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQudGV4dFJpc2UgPSByaXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBtb3ZlVGV4dCh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC54ID0gdGhpcy5jdXJyZW50LmxpbmVYICs9IHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC55ID0gdGhpcy5jdXJyZW50LmxpbmVZICs9IHk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldExlYWRpbmdNb3ZlVGV4dCh4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGVhZGluZygteSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubW92ZVRleHQoeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFRleHRNYXRyaXgoYSwgYiwgYywgZCwgZSwgZikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQudGV4dE1hdHJpeCA9IFthLCBiLCBjLCBkLCBlLCBmXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnRleHRNYXRyaXhTY2FsZSA9IE1hdGguaHlwb3QoYSwgYik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC54ID0gdGhpcy5jdXJyZW50LmxpbmVYID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnkgPSB0aGlzLmN1cnJlbnQubGluZVkgPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBuZXh0TGluZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb3ZlVGV4dCgwLCB0aGlzLmN1cnJlbnQubGVhZGluZyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50Q2hhcihjaGFyYWN0ZXIsIHgsIHksIHBhdHRlcm5UcmFuc2Zvcm0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLmN1cnJlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnQgPSBjdXJyZW50LmZvbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRleHRSZW5kZXJpbmdNb2RlID0gY3VycmVudC50ZXh0UmVuZGVyaW5nTW9kZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udFNpemUgPSBjdXJyZW50LmZvbnRTaXplIC8gY3VycmVudC5mb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxsU3Ryb2tlTW9kZSA9IHRleHRSZW5kZXJpbmdNb2RlICYgX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuRklMTF9TVFJPS0VfTUFTSzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNBZGRUb1BhdGhTZXQgPSAhISh0ZXh0UmVuZGVyaW5nTW9kZSAmIF91dGlsLlRleHRSZW5kZXJpbmdNb2RlLkFERF9UT19QQVRIX0ZMQUcpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXR0ZXJuRmlsbCA9IGN1cnJlbnQucGF0dGVybkZpbGwgJiYgIWZvbnQubWlzc2luZ0ZpbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBhZGRUb1BhdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250LmRpc2FibGVGb250RmFjZSB8fCBpc0FkZFRvUGF0aFNldCB8fCBwYXR0ZXJuRmlsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRkVG9QYXRoID0gZm9udC5nZXRQYXRoR2VuZXJhdG9yKHRoaXMuY29tbW9uT2JqcywgY2hhcmFjdGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9udC5kaXNhYmxlRm9udEZhY2UgfHwgcGF0dGVybkZpbGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgudHJhbnNsYXRlKHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmJlZ2luUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRkVG9QYXRoKGN0eCwgZm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhdHRlcm5UcmFuc2Zvcm0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKC4uLnBhdHRlcm5UcmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMIHx8IGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5maWxsKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZmlsbFN0cm9rZU1vZGUgPT09IF91dGlsLlRleHRSZW5kZXJpbmdNb2RlLlNUUk9LRSB8fCBmaWxsU3Ryb2tlTW9kZSA9PT0gX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuRklMTF9TVFJPS0UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc3Ryb2tlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMIHx8IGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5maWxsVGV4dChjaGFyYWN0ZXIsIHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5TVFJPS0UgfHwgZmlsbFN0cm9rZU1vZGUgPT09IF91dGlsLlRleHRSZW5kZXJpbmdNb2RlLkZJTExfU1RST0tFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnN0cm9rZVRleHQoY2hhcmFjdGVyLCB4LCB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNBZGRUb1BhdGhTZXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdGhzID0gdGhpcy5wZW5kaW5nVGV4dFBhdGhzIHx8ICh0aGlzLnBlbmRpbmdUZXh0UGF0aHMgPSBbXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRocy5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm06ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb250U2l6ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGRUb1BhdGgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc0ZvbnRTdWJwaXhlbEFBRW5hYmxlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dDogY3R4CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLmNhY2hlZENhbnZhc2VzLmdldENhbnZhcygiaXNGb250U3VicGl4ZWxBQUVuYWJsZWQiLCAxMCwgMTApOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2NhbGUoMS41LCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxUZXh0KCJJIiwgMCwgMTApOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gY3R4LmdldEltYWdlRGF0YSgwLCAwLCAxMCwgMTApLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBlbmFibGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAzOyBpIDwgZGF0YS5sZW5ndGg7IGkgKz0gNCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGFbaV0gPiAwICYmIGRhdGFbaV0gPCAyNTUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmFibGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgImlzRm9udFN1YnBpeGVsQUFFbmFibGVkIiwgZW5hYmxlZCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNob3dUZXh0KGdseXBocykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250ID0gY3VycmVudC5mb250OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9udC5pc1R5cGUzRm9udCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuc2hvd1R5cGUzVGV4dChnbHlwaHMpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRTaXplID0gY3VycmVudC5mb250U2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZvbnRTaXplID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250U2l6ZVNjYWxlID0gY3VycmVudC5mb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyU3BhY2luZyA9IGN1cnJlbnQuY2hhclNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdvcmRTcGFjaW5nID0gY3VycmVudC53b3JkU3BhY2luZzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udERpcmVjdGlvbiA9IGN1cnJlbnQuZm9udERpcmVjdGlvbjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dEhTY2FsZSA9IGN1cnJlbnQudGV4dEhTY2FsZSAqIGZvbnREaXJlY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdseXBoc0xlbmd0aCA9IGdseXBocy5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZlcnRpY2FsID0gZm9udC52ZXJ0aWNhbDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3BhY2luZ0RpciA9IHZlcnRpY2FsID8gMSA6IC0xOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZhdWx0Vk1ldHJpY3MgPSBmb250LmRlZmF1bHRWTWV0cmljczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2lkdGhBZHZhbmNlU2NhbGUgPSBmb250U2l6ZSAqIGN1cnJlbnQuZm9udE1hdHJpeFswXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2ltcGxlRmlsbFRleHQgPSBjdXJyZW50LnRleHRSZW5kZXJpbmdNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMICYmICFmb250LmRpc2FibGVGb250RmFjZSAmJiAhY3VycmVudC5wYXR0ZXJuRmlsbDsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSguLi5jdXJyZW50LnRleHRNYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgudHJhbnNsYXRlKGN1cnJlbnQueCwgY3VycmVudC55ICsgY3VycmVudC50ZXh0UmlzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250RGlyZWN0aW9uID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNjYWxlKHRleHRIU2NhbGUsIC0xKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZSh0ZXh0SFNjYWxlLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGF0dGVyblRyYW5zZm9ybTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQucGF0dGVybkZpbGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXR0ZXJuID0gY3VycmVudC5maWxsQ29sb3IuZ2V0UGF0dGVybihjdHgsIHRoaXMsICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtSW52ZXJzZSkoY3R4KSwgX3BhdHRlcm5faGVscGVyLlBhdGhUeXBlLkZJTEwpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVyblRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5maWxsU3R5bGUgPSBwYXR0ZXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBsaW5lV2lkdGggPSBjdXJyZW50LmxpbmVXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSBjdXJyZW50LnRleHRNYXRyaXhTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNjYWxlID09PSAwIHx8IGxpbmVXaWR0aCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbFN0cm9rZU1vZGUgPSBjdXJyZW50LnRleHRSZW5kZXJpbmdNb2RlICYgX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuRklMTF9TVFJPS0VfTUFTSzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmaWxsU3Ryb2tlTW9kZSA9PT0gX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuU1RST0tFIHx8IGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVXaWR0aCA9IHRoaXMuZ2V0U2luZ2xlUGl4ZWxXaWR0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVdpZHRoIC89IHNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250U2l6ZVNjYWxlICE9PSAxLjApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZShmb250U2l6ZVNjYWxlLCBmb250U2l6ZVNjYWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVXaWR0aCAvPSBmb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lV2lkdGggPSBsaW5lV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250LmlzSW52YWxpZFBERmpzRm9udCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hhcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB3aWR0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGdseXBoIG9mIGdseXBocykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYXJzLnB1c2goZ2x5cGgudW5pY29kZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGggKz0gZ2x5cGgud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsbFRleHQoY2hhcnMuam9pbigiIiksIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC54ICs9IHdpZHRoICogd2lkdGhBZHZhbmNlU2NhbGUgKiB0ZXh0SFNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcG9zZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgeCA9IDAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgZ2x5cGhzTGVuZ3RoOyArK2kpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdseXBoID0gZ2x5cGhzW2ldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBnbHlwaCA9PT0gIm51bWJlciIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ICs9IHNwYWNpbmdEaXIgKiBnbHlwaCAqIGZvbnRTaXplIC8gMTAwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCByZXN0b3JlTmVlZGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcGFjaW5nID0gKGdseXBoLmlzU3BhY2UgPyB3b3JkU3BhY2luZyA6IDApICsgY2hhclNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyYWN0ZXIgPSBnbHlwaC5mb250Q2hhcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFjY2VudCA9IGdseXBoLmFjY2VudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzY2FsZWRYLCBzY2FsZWRZOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHdpZHRoID0gZ2x5cGgud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmVydGljYWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2bWV0cmljID0gZ2x5cGgudm1ldHJpYyB8fCBkZWZhdWx0Vk1ldHJpY3M7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdnggPSAtKGdseXBoLnZtZXRyaWMgPyB2bWV0cmljWzFdIDogd2lkdGggKiAwLjUpICogd2lkdGhBZHZhbmNlU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdnkgPSB2bWV0cmljWzJdICogd2lkdGhBZHZhbmNlU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGggPSB2bWV0cmljID8gLXZtZXRyaWNbMF0gOiB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWRYID0gdnggLyBmb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZFkgPSAoeCArIHZ5KSAvIGZvbnRTaXplU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZFggPSB4IC8gZm9udFNpemVTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWRZID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250LnJlbWVhc3VyZSAmJiB3aWR0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtZWFzdXJlZFdpZHRoID0gY3R4Lm1lYXN1cmVUZXh0KGNoYXJhY3Rlcikud2lkdGggKiAxMDAwIC8gZm9udFNpemUgKiBmb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh3aWR0aCA8IG1lYXN1cmVkV2lkdGggJiYgdGhpcy5pc0ZvbnRTdWJwaXhlbEFBRW5hYmxlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyYWN0ZXJTY2FsZVggPSB3aWR0aCAvIG1lYXN1cmVkV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3RvcmVOZWVkZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2NhbGUoY2hhcmFjdGVyU2NhbGVYLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVkWCAvPSBjaGFyYWN0ZXJTY2FsZVg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh3aWR0aCAhPT0gbWVhc3VyZWRXaWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWRYICs9ICh3aWR0aCAtIG1lYXN1cmVkV2lkdGgpIC8gMjAwMCAqIGZvbnRTaXplIC8gZm9udFNpemVTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jb250ZW50VmlzaWJsZSAmJiAoZ2x5cGguaXNJbkZvbnQgfHwgZm9udC5taXNzaW5nRmlsZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2ltcGxlRmlsbFRleHQgJiYgIWFjY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsbFRleHQoY2hhcmFjdGVyLCBzY2FsZWRYLCBzY2FsZWRZKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhaW50Q2hhcihjaGFyYWN0ZXIsIHNjYWxlZFgsIHNjYWxlZFksIHBhdHRlcm5UcmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWNjZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZWRBY2NlbnRYID0gc2NhbGVkWCArIGZvbnRTaXplICogYWNjZW50Lm9mZnNldC54IC8gZm9udFNpemVTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlZEFjY2VudFkgPSBzY2FsZWRZIC0gZm9udFNpemUgKiBhY2NlbnQub2Zmc2V0LnkgLyBmb250U2l6ZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludENoYXIoYWNjZW50LmZvbnRDaGFyLCBzY2FsZWRBY2NlbnRYLCBzY2FsZWRBY2NlbnRZLCBwYXR0ZXJuVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjaGFyV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmVydGljYWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGFyV2lkdGggPSB3aWR0aCAqIHdpZHRoQWR2YW5jZVNjYWxlIC0gc3BhY2luZyAqIGZvbnREaXJlY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYXJXaWR0aCA9IHdpZHRoICogd2lkdGhBZHZhbmNlU2NhbGUgKyBzcGFjaW5nICogZm9udERpcmVjdGlvbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHggKz0gY2hhcldpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3RvcmVOZWVkZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2ZXJ0aWNhbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55IC09IHg7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnggKz0geCAqIHRleHRIU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21wb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNob3dUeXBlM1RleHQoZ2x5cGhzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250ID0gY3VycmVudC5mb250OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250U2l6ZSA9IGN1cnJlbnQuZm9udFNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnREaXJlY3Rpb24gPSBjdXJyZW50LmZvbnREaXJlY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNwYWNpbmdEaXIgPSBmb250LnZlcnRpY2FsID8gMSA6IC0xOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyU3BhY2luZyA9IGN1cnJlbnQuY2hhclNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdvcmRTcGFjaW5nID0gY3VycmVudC53b3JkU3BhY2luZzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dEhTY2FsZSA9IGN1cnJlbnQudGV4dEhTY2FsZSAqIGZvbnREaXJlY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRNYXRyaXggPSBjdXJyZW50LmZvbnRNYXRyaXggfHwgX3V0aWwuRk9OVF9JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdseXBoc0xlbmd0aCA9IGdseXBocy5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzVGV4dEludmlzaWJsZSA9IGN1cnJlbnQudGV4dFJlbmRlcmluZ01vZGUgPT09IF91dGlsLlRleHRSZW5kZXJpbmdNb2RlLklOVklTSUJMRTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGksIGdseXBoLCB3aWR0aCwgc3BhY2luZ0xlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzVGV4dEludmlzaWJsZSB8fCBmb250U2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZFNjYWxlRm9yU3Ryb2tpbmcgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRHZXRTaW5nbGVQaXhlbFdpZHRoID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSguLi5jdXJyZW50LnRleHRNYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgudHJhbnNsYXRlKGN1cnJlbnQueCwgY3VycmVudC55KTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNjYWxlKHRleHRIU2NhbGUsIGZvbnREaXJlY3Rpb24pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgZ2x5cGhzTGVuZ3RoOyArK2kpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdseXBoID0gZ2x5cGhzW2ldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBnbHlwaCA9PT0gIm51bWJlciIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzcGFjaW5nTGVuZ3RoID0gc3BhY2luZ0RpciAqIGdseXBoICogZm9udFNpemUgLyAxMDAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnRyYW5zbGF0ZShzcGFjaW5nTGVuZ3RoLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnggKz0gc3BhY2luZ0xlbmd0aCAqIHRleHRIU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcGFjaW5nID0gKGdseXBoLmlzU3BhY2UgPyB3b3JkU3BhY2luZyA6IDApICsgY2hhclNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvcGVyYXRvckxpc3QgPSBmb250LmNoYXJQcm9jT3BlcmF0b3JMaXN0W2dseXBoLm9wZXJhdG9yTGlzdElkXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb3BlcmF0b3JMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBUeXBlMyBjaGFyYWN0ZXIgIiR7Z2x5cGgub3BlcmF0b3JMaXN0SWR9IiBpcyBub3QgYXZhaWxhYmxlLmApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnByb2Nlc3NpbmdUeXBlMyA9IGdseXBoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZShmb250U2l6ZSwgZm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC50cmFuc2Zvcm0oLi4uZm9udE1hdHJpeCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leGVjdXRlT3BlcmF0b3JMaXN0KG9wZXJhdG9yTGlzdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0cmFuc2Zvcm1lZCA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oW2dseXBoLndpZHRoLCAwXSwgZm9udE1hdHJpeCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCA9IHRyYW5zZm9ybWVkWzBdICogZm9udFNpemUgKyBzcGFjaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zbGF0ZSh3aWR0aCwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnggKz0gd2lkdGggKiB0ZXh0SFNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucHJvY2Vzc2luZ1R5cGUzID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0Q2hhcldpZHRoKHhXaWR0aCwgeVdpZHRoKSB7fQogICAgICAgICAgICAgICAgICAgIHNldENoYXJXaWR0aEFuZEJvdW5kcyh4V2lkdGgsIHlXaWR0aCwgbGx4LCBsbHksIHVyeCwgdXJ5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnJlY3QobGx4LCBsbHksIHVyeCAtIGxseCwgdXJ5IC0gbGx5KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xpcCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0Q29sb3JOX1BhdHRlcm4oSVIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHBhdHRlcm47CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChJUlswXSA9PT0gIlRpbGluZ1BhdHRlcm4iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xvciA9IElSWzFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmFzZVRyYW5zZm9ybSA9IHRoaXMuYmFzZVRyYW5zZm9ybSB8fCAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FudmFzR3JhcGhpY3NGYWN0b3J5ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZUNhbnZhc0dyYXBoaWNzOiBjdHggPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IENhbnZhc0dyYXBoaWNzKGN0eCwgdGhpcy5jb21tb25PYmpzLCB0aGlzLm9ianMsIHRoaXMuY2FudmFzRmFjdG9yeSwgdGhpcy5maWx0ZXJGYWN0b3J5LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25hbENvbnRlbnRDb25maWc6IHRoaXMub3B0aW9uYWxDb250ZW50Q29uZmlnLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFya2VkQ29udGVudFN0YWNrOiB0aGlzLm1hcmtlZENvbnRlbnRTdGFjawogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVybiA9IG5ldyBfcGF0dGVybl9oZWxwZXIuVGlsaW5nUGF0dGVybihJUiwgY29sb3IsIHRoaXMuY3R4LCBjYW52YXNHcmFwaGljc0ZhY3RvcnksIGJhc2VUcmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVybiA9IHRoaXMuX2dldFBhdHRlcm4oSVJbMV0sIElSWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGF0dGVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0U3Ryb2tlQ29sb3JOKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuc3Ryb2tlQ29sb3IgPSB0aGlzLmdldENvbG9yTl9QYXR0ZXJuKGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEZpbGxDb2xvck4oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5maWxsQ29sb3IgPSB0aGlzLmdldENvbG9yTl9QYXR0ZXJuKGFyZ3VtZW50cyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5wYXR0ZXJuRmlsbCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZVJHQkNvbG9yKHIsIGcsIGIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihyLCBnLCBiKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc3Ryb2tlU3R5bGUgPSBjb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnN0cm9rZUNvbG9yID0gY29sb3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEZpbGxSR0JDb2xvcihyLCBnLCBiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IociwgZywgYik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LmZpbGxTdHlsZSA9IGNvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuZmlsbENvbG9yID0gY29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5wYXR0ZXJuRmlsbCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZ2V0UGF0dGVybihvYmpJZCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbWF0cml4ID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGF0dGVybjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY2FjaGVkUGF0dGVybnMuaGFzKG9iaklkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVybiA9IHRoaXMuY2FjaGVkUGF0dGVybnMuZ2V0KG9iaklkKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdHRlcm4gPSAoMCwgX3BhdHRlcm5faGVscGVyLmdldFNoYWRpbmdQYXR0ZXJuKSh0aGlzLmdldE9iamVjdChvYmpJZCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYWNoZWRQYXR0ZXJucy5zZXQob2JqSWQsIHBhdHRlcm4pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXRyaXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdHRlcm4ubWF0cml4ID0gbWF0cml4OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwYXR0ZXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzaGFkaW5nRmlsbChvYmpJZCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdHRlcm4gPSB0aGlzLl9nZXRQYXR0ZXJuKG9iaklkKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmZpbGxTdHlsZSA9IHBhdHRlcm4uZ2V0UGF0dGVybihjdHgsIHRoaXMsICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtSW52ZXJzZSkoY3R4KSwgX3BhdHRlcm5faGVscGVyLlBhdGhUeXBlLlNIQURJTkcpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnYgPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybUludmVyc2UpKGN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbnZhcyA9IGN0eC5jYW52YXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGNhbnZhcy53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGNhbnZhcy5oZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBibCA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oWzAsIDBdLCBpbnYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnIgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFswLCBoZWlnaHRdLCBpbnYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdWwgPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFt3aWR0aCwgMF0sIGludik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1ciA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oW3dpZHRoLCBoZWlnaHRdLCBpbnYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeDAgPSBNYXRoLm1pbihibFswXSwgYnJbMF0sIHVsWzBdLCB1clswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5MCA9IE1hdGgubWluKGJsWzFdLCBiclsxXSwgdWxbMV0sIHVyWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHgxID0gTWF0aC5tYXgoYmxbMF0sIGJyWzBdLCB1bFswXSwgdXJbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeTEgPSBNYXRoLm1heChibFsxXSwgYnJbMV0sIHVsWzFdLCB1clsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5maWxsUmVjdCh4MCwgeTAsIHgxIC0geDAsIHkxIC0geTApOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZmlsbFJlY3QoLTFlMTAsIC0xZTEwLCAyZTEwLCAyZTEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbXBvc2UodGhpcy5jdXJyZW50LmdldENsaXBwZWRQYXRoQm91bmRpbmdCb3goKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBiZWdpbklubGluZUltYWdlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJTaG91bGQgbm90IGNhbGwgYmVnaW5JbmxpbmVJbWFnZSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBiZWdpbkltYWdlRGF0YSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiU2hvdWxkIG5vdCBjYWxsIGJlZ2luSW1hZ2VEYXRhIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50Rm9ybVhPYmplY3RCZWdpbihtYXRyaXgsIGJib3gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmNvbnRlbnRWaXNpYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVRyYW5zZm9ybVN0YWNrLnB1c2godGhpcy5iYXNlVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkobWF0cml4KSAmJiBtYXRyaXgubGVuZ3RoID09PSA2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zZm9ybSguLi5tYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKSh0aGlzLmN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChiYm94KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGJib3hbMl0gLSBiYm94WzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gYmJveFszXSAtIGJib3hbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5yZWN0KGJib3hbMF0sIGJib3hbMV0sIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnVwZGF0ZVJlY3RNaW5NYXgoKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKHRoaXMuY3R4KSwgYmJveCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50Rm9ybVhPYmplY3RFbmQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmJhc2VUcmFuc2Zvcm0gPSB0aGlzLmJhc2VUcmFuc2Zvcm1TdGFjay5wb3AoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYmVnaW5Hcm91cChncm91cCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kU01hc2tNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuYWN0aXZlU01hc2sgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnRDdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFncm91cC5pc29sYXRlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJUT0RPOiBTdXBwb3J0IG5vbi1pc29sYXRlZCBncm91cHMuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLmtub2Nrb3V0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIktub2Nrb3V0IGdyb3VwcyBub3Qgc3VwcG9ydGVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnRUcmFuc2Zvcm0gPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3VycmVudEN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChncm91cC5tYXRyaXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRDdHgudHJhbnNmb3JtKC4uLmdyb3VwLm1hdHJpeCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFncm91cC5iYm94KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoIkJvdW5kaW5nIGJveCBpcyByZXF1aXJlZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYm91bmRzID0gX3V0aWwuVXRpbC5nZXRBeGlhbEFsaWduZWRCb3VuZGluZ0JveChncm91cC5iYm94LCAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3VycmVudEN0eCkpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXNCb3VuZHMgPSBbMCwgMCwgY3VycmVudEN0eC5jYW52YXMud2lkdGgsIGN1cnJlbnRDdHguY2FudmFzLmhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgICAgIGJvdW5kcyA9IF91dGlsLlV0aWwuaW50ZXJzZWN0KGJvdW5kcywgY2FudmFzQm91bmRzKSB8fCBbMCwgMCwgMCwgMF07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFggPSBNYXRoLmZsb29yKGJvdW5kc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFkgPSBNYXRoLmZsb29yKGJvdW5kc1sxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkcmF3bldpZHRoID0gTWF0aC5tYXgoTWF0aC5jZWlsKGJvdW5kc1syXSkgLSBvZmZzZXRYLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRyYXduSGVpZ2h0ID0gTWF0aC5tYXgoTWF0aC5jZWlsKGJvdW5kc1szXSkgLSBvZmZzZXRZLCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNjYWxlWCA9IDEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZVkgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZHJhd25XaWR0aCA+IE1BWF9HUk9VUF9TSVpFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZVggPSBkcmF3bldpZHRoIC8gTUFYX0dST1VQX1NJWkU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3bldpZHRoID0gTUFYX0dST1VQX1NJWkU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRyYXduSGVpZ2h0ID4gTUFYX0dST1VQX1NJWkUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWSA9IGRyYXduSGVpZ2h0IC8gTUFYX0dST1VQX1NJWkU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3bkhlaWdodCA9IE1BWF9HUk9VUF9TSVpFOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5zdGFydE5ld1BhdGhBbmRDbGlwQm94KFswLCAwLCBkcmF3bldpZHRoLCBkcmF3bkhlaWdodF0pOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY2FjaGVJZCA9ICJncm91cEF0IiArIHRoaXMuZ3JvdXBMZXZlbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLnNtYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWNoZUlkICs9ICJfc21hc2tfIiArIHRoaXMuc21hc2tDb3VudGVyKysgJSAyOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjcmF0Y2hDYW52YXMgPSB0aGlzLmNhY2hlZENhbnZhc2VzLmdldENhbnZhcyhjYWNoZUlkLCBkcmF3bldpZHRoLCBkcmF3bkhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdyb3VwQ3R4ID0gc2NyYXRjaENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICBncm91cEN0eC5zY2FsZSgxIC8gc2NhbGVYLCAxIC8gc2NhbGVZKTsKICAgICAgICAgICAgICAgICAgICAgICAgZ3JvdXBDdHgudHJhbnNsYXRlKC1vZmZzZXRYLCAtb2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGdyb3VwQ3R4LnRyYW5zZm9ybSguLi5jdXJyZW50VHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLnNtYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNtYXNrU3RhY2sucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzOiBzY3JhdGNoQ2FudmFzLmNhbnZhcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZXh0OiBncm91cEN0eCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWJ0eXBlOiBncm91cC5zbWFzay5zdWJ0eXBlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhY2tkcm9wOiBncm91cC5zbWFzay5iYWNrZHJvcCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zlck1hcDogZ3JvdXAuc21hc2sudHJhbnNmZXJNYXAgfHwgbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFydFRyYW5zZm9ybUludmVyc2U6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudEN0eC5zZXRUcmFuc2Zvcm0oMSwgMCwgMCwgMSwgMCwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Q3R4LnRyYW5zbGF0ZShvZmZzZXRYLCBvZmZzZXRZKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnRDdHguc2NhbGUoc2NhbGVYLCBzY2FsZVkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudEN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29weUN0eFN0YXRlKGN1cnJlbnRDdHgsIGdyb3VwQ3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHggPSBncm91cEN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRHU3RhdGUoW1siQk0iLCAic291cmNlLW92ZXIiXSwgWyJjYSIsIDFdLCBbIkNBIiwgMV1dKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5ncm91cFN0YWNrLnB1c2goY3VycmVudEN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZ3JvdXBMZXZlbCsrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmRHcm91cChncm91cCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmdyb3VwTGV2ZWwtLTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZ3JvdXBDdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5ncm91cFN0YWNrLnBvcCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eCA9IGN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguaW1hZ2VTbW9vdGhpbmdFbmFibGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChncm91cC5zbWFzaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50ZW1wU01hc2sgPSB0aGlzLnNtYXNrU3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnRNdHggPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zZXRUcmFuc2Zvcm0oLi4uY3VycmVudE10eCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXJ0eUJveCA9IF91dGlsLlV0aWwuZ2V0QXhpYWxBbGlnbmVkQm91bmRpbmdCb3goWzAsIDAsIGdyb3VwQ3R4LmNhbnZhcy53aWR0aCwgZ3JvdXBDdHguY2FudmFzLmhlaWdodF0sIGN1cnJlbnRNdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZHJhd0ltYWdlKGdyb3VwQ3R4LmNhbnZhcywgMCwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbXBvc2UoZGlydHlCb3gpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJlZ2luQW5ub3RhdGlvbihpZCwgcmVjdCwgdHJhbnNmb3JtLCBtYXRyaXgsIGhhc093bkNhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZXN0b3JlSW5pdGlhbFN0YXRlLCBfcmVzdG9yZUluaXRpYWxTdGF0ZTIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc2V0Q3R4VG9EZWZhdWx0KHRoaXMuY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuYmFzZVRyYW5zZm9ybSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc2V0VHJhbnNmb3JtKC4uLnRoaXMuYmFzZVRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkocmVjdCkgJiYgcmVjdC5sZW5ndGggPT09IDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gcmVjdFsyXSAtIHJlY3RbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSByZWN0WzNdIC0gcmVjdFsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChoYXNPd25DYW52YXMgJiYgdGhpcy5hbm5vdGF0aW9uQ2FudmFzTWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtID0gdHJhbnNmb3JtLnNsaWNlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtWzRdIC09IHJlY3RbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtWzVdIC09IHJlY3RbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdCA9IHJlY3Quc2xpY2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0WzBdID0gcmVjdFsxXSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdFsyXSA9IHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3RbM10gPSBoZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3NjYWxlWCwgc2NhbGVZXSA9IF91dGlsLlV0aWwuc2luZ3VsYXJWYWx1ZURlY29tcG9zZTJkU2NhbGUoKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKHRoaXMuY3R4KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydFNjYWxlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FudmFzV2lkdGggPSBNYXRoLmNlaWwod2lkdGggKiB0aGlzLm91dHB1dFNjYWxlWCAqIHZpZXdwb3J0U2NhbGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhbnZhc0hlaWdodCA9IE1hdGguY2VpbChoZWlnaHQgKiB0aGlzLm91dHB1dFNjYWxlWSAqIHZpZXdwb3J0U2NhbGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvbkNhbnZhcyA9IHRoaXMuY2FudmFzRmFjdG9yeS5jcmVhdGUoY2FudmFzV2lkdGgsIGNhbnZhc0hlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYW52YXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gdGhpcy5hbm5vdGF0aW9uQ2FudmFzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvbkNhbnZhc01hcC5zZXQoaWQsIGNhbnZhcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbm5vdGF0aW9uQ2FudmFzLnNhdmVkQ3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHggPSBjb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNldFRyYW5zZm9ybShzY2FsZVgsIDAsIDAsIC1zY2FsZVksIDAsIGhlaWdodCAqIHNjYWxlWSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzZXRDdHhUb0RlZmF1bHQodGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNldEN0eFRvRGVmYXVsdCh0aGlzLmN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgucmVjdChyZWN0WzBdLCByZWN0WzFdLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5jbGlwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmRQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50ID0gbmV3IENhbnZhc0V4dHJhU3RhdGUodGhpcy5jdHguY2FudmFzLndpZHRoLCB0aGlzLmN0eC5jYW52YXMuaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm0oLi4udHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm0oLi4ubWF0cml4KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5kQW5ub3RhdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuYW5ub3RhdGlvbkNhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHggPSB0aGlzLmFubm90YXRpb25DYW52YXMuc2F2ZWRDdHg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5hbm5vdGF0aW9uQ2FudmFzLnNhdmVkQ3R4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHRoaXMuYW5ub3RhdGlvbkNhbnZhczsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlTWFza1hPYmplY3QoaW1nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvdW50ID0gaW1nLmNvdW50OwogICAgICAgICAgICAgICAgICAgICAgICBpbWcgPSB0aGlzLmdldE9iamVjdChpbWcuZGF0YSwgaW1nKTsKICAgICAgICAgICAgICAgICAgICAgICAgaW1nLmNvdW50ID0gY291bnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBnbHlwaCA9IHRoaXMucHJvY2Vzc2luZ1R5cGUzOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ2x5cGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChnbHlwaC5jb21waWxlZCA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2x5cGguY29tcGlsZWQgPSBjb21waWxlVHlwZTNHbHlwaChpbWcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdseXBoLmNvbXBpbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ2x5cGguY29tcGlsZWQoY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFzayA9IHRoaXMuX2NyZWF0ZU1hc2tDYW52YXMoaW1nKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFza0NhbnZhcyA9IG1hc2suY2FudmFzOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDEsIDAsIDAsIDEsIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguZHJhd0ltYWdlKG1hc2tDYW52YXMsIG1hc2sub2Zmc2V0WCwgbWFzay5vZmZzZXRZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21wb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VNYXNrWE9iamVjdFJlcGVhdChpbWcsIHNjYWxlWCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc2tld1ggPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBza2V3WSA9IGFyZ3VtZW50cy5sZW5ndGggPiAzICYmIGFyZ3VtZW50c1szXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzNdIDogMDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNjYWxlWSA9IGFyZ3VtZW50cy5sZW5ndGggPiA0ID8gYXJndW1lbnRzWzRdIDogdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcG9zaXRpb25zID0gYXJndW1lbnRzLmxlbmd0aCA+IDUgPyBhcmd1bWVudHNbNV0gOiB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGltZyA9IHRoaXMuZ2V0T2JqZWN0KGltZy5kYXRhLCBpbWcpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudFRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgudHJhbnNmb3JtKHNjYWxlWCwgc2tld1gsIHNrZXdZLCBzY2FsZVksIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXNrID0gdGhpcy5fY3JlYXRlTWFza0NhbnZhcyhpbWcpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDEsIDAsIDAsIDEsIG1hc2sub2Zmc2V0WCAtIGN1cnJlbnRUcmFuc2Zvcm1bNF0sIG1hc2sub2Zmc2V0WSAtIGN1cnJlbnRUcmFuc2Zvcm1bNV0pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBwb3NpdGlvbnMubGVuZ3RoOyBpIDwgaWk7IGkgKz0gMikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHJhbnMgPSBfdXRpbC5VdGlsLnRyYW5zZm9ybShjdXJyZW50VHJhbnNmb3JtLCBbc2NhbGVYLCBza2V3WCwgc2tld1ksIHNjYWxlWSwgcG9zaXRpb25zW2ldLCBwb3NpdGlvbnNbaSArIDFdXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbeCwgeV0gPSBfdXRpbC5VdGlsLmFwcGx5VHJhbnNmb3JtKFswLCAwXSwgdHJhbnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZShtYXNrLmNhbnZhcywgeCwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21wb3NlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VNYXNrWE9iamVjdEdyb3VwKGltYWdlcykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbENvbG9yID0gdGhpcy5jdXJyZW50LmZpbGxDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNQYXR0ZXJuRmlsbCA9IHRoaXMuY3VycmVudC5wYXR0ZXJuRmlsbDsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBpbWFnZSBvZiBpbWFnZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBpbWFnZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hc2tDYW52YXMgPSB0aGlzLmNhY2hlZENhbnZhc2VzLmdldENhbnZhcygibWFza0NhbnZhcyIsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFza0N0eCA9IG1hc2tDYW52YXMuY29udGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hc2tDdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW1nID0gdGhpcy5nZXRPYmplY3QoZGF0YSwgaW1hZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHV0QmluYXJ5SW1hZ2VNYXNrKG1hc2tDdHgsIGltZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXNrQ3R4Lmdsb2JhbENvbXBvc2l0ZU9wZXJhdGlvbiA9ICJzb3VyY2UtaW4iOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFza0N0eC5maWxsU3R5bGUgPSBpc1BhdHRlcm5GaWxsID8gZmlsbENvbG9yLmdldFBhdHRlcm4obWFza0N0eCwgdGhpcywgKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm1JbnZlcnNlKShjdHgpLCBfcGF0dGVybl9oZWxwZXIuUGF0aFR5cGUuRklMTCkgOiBmaWxsQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXNrQ3R4LmZpbGxSZWN0KDAsIDAsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFza0N0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSguLi50cmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNjYWxlKDEsIC0xKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRyYXdJbWFnZUF0SW50ZWdlckNvb3JkcyhjdHgsIG1hc2tDYW52YXMuY2FudmFzLCAwLCAwLCB3aWR0aCwgaGVpZ2h0LCAwLCAtMSwgMSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcG9zZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwYWludEltYWdlWE9iamVjdChvYmpJZCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY29udGVudFZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbWdEYXRhID0gdGhpcy5nZXRPYmplY3Qob2JqSWQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiRGVwZW5kZW50IGltYWdlIGlzbid0IHJlYWR5IHlldCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFpbnRJbmxpbmVJbWFnZVhPYmplY3QoaW1nRGF0YSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50SW1hZ2VYT2JqZWN0UmVwZWF0KG9iaklkLCBzY2FsZVgsIHNjYWxlWSwgcG9zaXRpb25zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltZ0RhdGEgPSB0aGlzLmdldE9iamVjdChvYmpJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaW1nRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJEZXBlbmRlbnQgaW1hZ2UgaXNuJ3QgcmVhZHkgeWV0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2lkdGggPSBpbWdEYXRhLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBpbWdEYXRhLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFwID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IHBvc2l0aW9ucy5sZW5ndGg7IGkgPCBpaTsgaSArPSAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXAucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtOiBbc2NhbGVYLCAwLCAwLCBzY2FsZVksIHBvc2l0aW9uc1tpXSwgcG9zaXRpb25zW2kgKyAxXV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeDogMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5OiAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHc6IHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGg6IGhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludElubGluZUltYWdlWE9iamVjdEdyb3VwKGltZ0RhdGEsIG1hcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFwcGx5VHJhbnNmZXJNYXBzVG9DYW52YXMoY3R4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmN1cnJlbnQudHJhbnNmZXJNYXBzICE9PSAibm9uZSIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5maWx0ZXIgPSB0aGlzLmN1cnJlbnQudHJhbnNmZXJNYXBzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmRyYXdJbWFnZShjdHguY2FudmFzLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5maWx0ZXIgPSAibm9uZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGN0eC5jYW52YXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFwcGx5VHJhbnNmZXJNYXBzVG9CaXRtYXAoaW1nRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jdXJyZW50LnRyYW5zZmVyTWFwcyA9PT0gIm5vbmUiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaW1nRGF0YS5iaXRtYXA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYml0bWFwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGltZ0RhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRtcENhbnZhcyA9IHRoaXMuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKCJpbmxpbmVJbWFnZSIsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bXBDdHggPSB0bXBDYW52YXMuY29udGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LmZpbHRlciA9IHRoaXMuY3VycmVudC50cmFuc2Zlck1hcHM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRtcEN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LmZpbHRlciA9ICJub25lIjsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRtcENhbnZhcy5jYW52YXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50SW5saW5lSW1hZ2VYT2JqZWN0KGltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmNvbnRlbnRWaXNpYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgd2lkdGggPSBpbWdEYXRhLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBpbWdEYXRhLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9pc19ub2RlLmlzTm9kZUpTKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZmlsdGVyID0gIm5vbmUiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZSgxIC8gd2lkdGgsIC0xIC8gaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGltZ1RvUGFpbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbWdEYXRhLmJpdG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nVG9QYWludCA9IHRoaXMuYXBwbHlUcmFuc2Zlck1hcHNUb0JpdG1hcChpbWdEYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgSFRNTEVsZW1lbnQgPT09ICJmdW5jdGlvbiIgJiYgaW1nRGF0YSBpbnN0YW5jZW9mIEhUTUxFbGVtZW50IHx8ICFpbWdEYXRhLmRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZ1RvUGFpbnQgPSBpbWdEYXRhOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdG1wQ2FudmFzID0gdGhpcy5jYWNoZWRDYW52YXNlcy5nZXRDYW52YXMoImlubGluZUltYWdlIiwgd2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bXBDdHggPSB0bXBDYW52YXMuY29udGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1dEJpbmFyeUltYWdlRGF0YSh0bXBDdHgsIGltZ0RhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nVG9QYWludCA9IHRoaXMuYXBwbHlUcmFuc2Zlck1hcHNUb0NhbnZhcyh0bXBDdHgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlZCA9IHRoaXMuX3NjYWxlSW1hZ2UoaW1nVG9QYWludCwgKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm1JbnZlcnNlKShjdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmltYWdlU21vb3RoaW5nRW5hYmxlZCA9IGdldEltYWdlU21vb3RoaW5nRW5hYmxlZCgoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3R4KSwgaW1nRGF0YS5pbnRlcnBvbGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRyYXdJbWFnZUF0SW50ZWdlckNvb3JkcyhjdHgsIHNjYWxlZC5pbWcsIDAsIDAsIHNjYWxlZC5wYWludFdpZHRoLCBzY2FsZWQucGFpbnRIZWlnaHQsIDAsIC1oZWlnaHQsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbXBvc2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBhaW50SW5saW5lSW1hZ2VYT2JqZWN0R3JvdXAoaW1nRGF0YSwgbWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IHRoaXMuY3R4OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgaW1nVG9QYWludDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGltZ0RhdGEuYml0bWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWdUb1BhaW50ID0gaW1nRGF0YS5iaXRtYXA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3ID0gaW1nRGF0YS53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGggPSBpbWdEYXRhLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRtcENhbnZhcyA9IHRoaXMuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKCJpbmxpbmVJbWFnZSIsIHcsIGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdG1wQ3R4ID0gdG1wQ2FudmFzLmNvbnRleHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdXRCaW5hcnlJbWFnZURhdGEodG1wQ3R4LCBpbWdEYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZ1RvUGFpbnQgPSB0aGlzLmFwcGx5VHJhbnNmZXJNYXBzVG9DYW52YXModG1wQ3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVudHJ5IG9mIG1hcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNhdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC50cmFuc2Zvcm0oLi4uZW50cnkudHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZSgxLCAtMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3SW1hZ2VBdEludGVnZXJDb29yZHMoY3R4LCBpbWdUb1BhaW50LCBlbnRyeS54LCBlbnRyeS55LCBlbnRyeS53LCBlbnRyeS5oLCAwLCAtMSwgMSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcG9zZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwYWludFNvbGlkQ29sb3JJbWFnZU1hc2soKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5jb250ZW50VmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LmZpbGxSZWN0KDAsIDAsIDEsIDEpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbXBvc2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgbWFya1BvaW50KHRhZykge30KICAgICAgICAgICAgICAgICAgICBtYXJrUG9pbnRQcm9wcyh0YWcsIHByb3BlcnRpZXMpIHt9CiAgICAgICAgICAgICAgICAgICAgYmVnaW5NYXJrZWRDb250ZW50KHRhZykgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hcmtlZENvbnRlbnRTdGFjay5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpc2libGU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJlZ2luTWFya2VkQ29udGVudFByb3BzKHRhZywgcHJvcGVydGllcykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGFnID09PSAiT0MiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hcmtlZENvbnRlbnRTdGFjay5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aXNpYmxlOiB0aGlzLm9wdGlvbmFsQ29udGVudENvbmZpZy5pc1Zpc2libGUocHJvcGVydGllcykKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tYXJrZWRDb250ZW50U3RhY2sucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlzaWJsZTogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250ZW50VmlzaWJsZSA9IHRoaXMuaXNDb250ZW50VmlzaWJsZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmRNYXJrZWRDb250ZW50KCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hcmtlZENvbnRlbnRTdGFjay5wb3AoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250ZW50VmlzaWJsZSA9IHRoaXMuaXNDb250ZW50VmlzaWJsZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBiZWdpbkNvbXBhdCgpIHt9CiAgICAgICAgICAgICAgICAgICAgZW5kQ29tcGF0KCkge30KICAgICAgICAgICAgICAgICAgICBjb25zdW1lUGF0aChjbGlwQm94KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzRW1wdHkgPSB0aGlzLmN1cnJlbnQuaXNFbXB0eUNsaXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucGVuZGluZ0NsaXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC51cGRhdGVDbGlwRnJvbVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMucGVuZGluZ0NsaXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tcG9zZShjbGlwQm94KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSB0aGlzLmN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucGVuZGluZ0NsaXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNFbXB0eSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnBlbmRpbmdDbGlwID09PSBFT19DTElQKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5jbGlwKCJldmVub2RkIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmNsaXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBlbmRpbmdDbGlwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuc3RhcnROZXdQYXRoQW5kQ2xpcEJveCh0aGlzLmN1cnJlbnQuY2xpcEJveCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5iZWdpblBhdGgoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0U2luZ2xlUGl4ZWxXaWR0aCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9jYWNoZWRHZXRTaW5nbGVQaXhlbFdpZHRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtID0gKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKHRoaXMuY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtWzFdID09PSAwICYmIG1bMl0gPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRHZXRTaW5nbGVQaXhlbFdpZHRoID0gMSAvIE1hdGgubWluKE1hdGguYWJzKG1bMF0pLCBNYXRoLmFicyhtWzNdKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFic0RldCA9IE1hdGguYWJzKG1bMF0gKiBtWzNdIC0gbVsyXSAqIG1bMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vcm1YID0gTWF0aC5oeXBvdChtWzBdLCBtWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBub3JtWSA9IE1hdGguaHlwb3QobVsxXSwgbVszXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkR2V0U2luZ2xlUGl4ZWxXaWR0aCA9IE1hdGgubWF4KG5vcm1YLCBub3JtWSkgLyBhYnNEZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2NhY2hlZEdldFNpbmdsZVBpeGVsV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFNjYWxlRm9yU3Ryb2tpbmcoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5fY2FjaGVkU2NhbGVGb3JTdHJva2luZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVXaWR0aAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG0gPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkodGhpcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNjYWxlWCwgc2NhbGVZOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1bMV0gPT09IDAgJiYgbVsyXSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vcm1YID0gTWF0aC5hYnMobVswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgbm9ybVkgPSBNYXRoLmFicyhtWzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobGluZVdpZHRoID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWCA9IDEgLyBub3JtWDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVZID0gMSAvIG5vcm1ZOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlZFhMaW5lV2lkdGggPSBub3JtWCAqIGxpbmVXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVkWUxpbmVXaWR0aCA9IG5vcm1ZICogbGluZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZVggPSBzY2FsZWRYTGluZVdpZHRoIDwgMSA/IDEgLyBzY2FsZWRYTGluZVdpZHRoIDogMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVZID0gc2NhbGVkWUxpbmVXaWR0aCA8IDEgPyAxIC8gc2NhbGVkWUxpbmVXaWR0aCA6IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhYnNEZXQgPSBNYXRoLmFicyhtWzBdICogbVszXSAtIG1bMl0gKiBtWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBub3JtWCA9IE1hdGguaHlwb3QobVswXSwgbVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgbm9ybVkgPSBNYXRoLmh5cG90KG1bMl0sIG1bM10pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChsaW5lV2lkdGggPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVYID0gbm9ybVkgLyBhYnNEZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWSA9IG5vcm1YIC8gYWJzRGV0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJhc2VBcmVhID0gbGluZVdpZHRoICogYWJzRGV0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZVggPSBub3JtWSA+IGJhc2VBcmVhID8gbm9ybVkgLyBiYXNlQXJlYSA6IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWSA9IG5vcm1YID4gYmFzZUFyZWEgPyBub3JtWCAvIGJhc2VBcmVhIDogMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRTY2FsZUZvclN0cm9raW5nID0gW3NjYWxlWCwgc2NhbGVZXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fY2FjaGVkU2NhbGVGb3JTdHJva2luZzsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVzY2FsZUFuZFN0cm9rZShzYXZlUmVzdG9yZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVXaWR0aAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbc2NhbGVYLCBzY2FsZVldID0gdGhpcy5nZXRTY2FsZUZvclN0cm9raW5nKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5saW5lV2lkdGggPSBsaW5lV2lkdGggfHwgMTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNjYWxlWCA9PT0gMSAmJiBzY2FsZVkgPT09IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc2F2ZWRNYXRyaXgsIHNhdmVkRGFzaGVzLCBzYXZlZERhc2hPZmZzZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzYXZlUmVzdG9yZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2F2ZWRNYXRyaXggPSAoMCwgX2Rpc3BsYXlfdXRpbHMuZ2V0Q3VycmVudFRyYW5zZm9ybSkoY3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNhdmVkRGFzaGVzID0gY3R4LmdldExpbmVEYXNoKCkuc2xpY2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNhdmVkRGFzaE9mZnNldCA9IGN0eC5saW5lRGFzaE9mZnNldDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjdHguc2NhbGUoc2NhbGVYLCBzY2FsZVkpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZSA9IE1hdGgubWF4KHNjYWxlWCwgc2NhbGVZKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnNldExpbmVEYXNoKGN0eC5nZXRMaW5lRGFzaCgpLm1hcCh4ID0+IHggLyBzY2FsZSkpOwogICAgICAgICAgICAgICAgICAgICAgICBjdHgubGluZURhc2hPZmZzZXQgLz0gc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNhdmVSZXN0b3JlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKC4uLnNhdmVkTWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zZXRMaW5lRGFzaChzYXZlZERhc2hlcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHgubGluZURhc2hPZmZzZXQgPSBzYXZlZERhc2hPZmZzZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNDb250ZW50VmlzaWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IHRoaXMubWFya2VkQ29udGVudFN0YWNrLmxlbmd0aCAtIDE7IGkgPj0gMDsgaS0tKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMubWFya2VkQ29udGVudFN0YWNrW2ldLnZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5DYW52YXNHcmFwaGljcyA9IENhbnZhc0dyYXBoaWNzOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3Jlc3RvcmVJbml0aWFsU3RhdGUyKCkgewogICAgICAgICAgICAgICAgICAgIHdoaWxlICh0aGlzLnN0YXRlU3RhY2subGVuZ3RoIHx8IHRoaXMuaW5TTWFza01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy50cmFuc3BhcmVudENhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eCA9IHRoaXMuY29tcG9zaXRlQ3R4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5zYXZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNldFRyYW5zZm9ybSgxLCAwLCAwLCAxLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguZHJhd0ltYWdlKHRoaXMudHJhbnNwYXJlbnRDYW52YXMsIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5yZXN0b3JlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNwYXJlbnRDYW52YXMgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgb3AgaW4gX3V0aWwuT1BTKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKENhbnZhc0dyYXBoaWNzLnByb3RvdHlwZVtvcF0gIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICBDYW52YXNHcmFwaGljcy5wcm90b3R5cGVbX3V0aWwuT1BTW29wXV0gPSBDYW52YXNHcmFwaGljcy5wcm90b3R5cGVbb3BdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQ3ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuVGlsaW5nUGF0dGVybiA9IGV4cG9ydHMuUGF0aFR5cGUgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICBleHBvcnRzLmdldFNoYWRpbmdQYXR0ZXJuID0gZ2V0U2hhZGluZ1BhdHRlcm47CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwbGF5X3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDIpOwogICAgICAgICAgICAgICAgY29uc3QgUGF0aFR5cGUgPSB7CiAgICAgICAgICAgICAgICAgICAgRklMTDogIkZpbGwiLAogICAgICAgICAgICAgICAgICAgIFNUUk9LRTogIlN0cm9rZSIsCiAgICAgICAgICAgICAgICAgICAgU0hBRElORzogIlNoYWRpbmciCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgZXhwb3J0cy5QYXRoVHlwZSA9IFBhdGhUeXBlOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gYXBwbHlCb3VuZGluZ0JveChjdHgsIGJib3gpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWJib3gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGJib3hbMl0gLSBiYm94WzBdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGJib3hbM10gLSBiYm94WzFdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlZ2lvbiA9IG5ldyBQYXRoMkQoKTsKICAgICAgICAgICAgICAgICAgICByZWdpb24ucmVjdChiYm94WzBdLCBiYm94WzFdLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICBjdHguY2xpcChyZWdpb24pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgQmFzZVNoYWRpbmdQYXR0ZXJuIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IEJhc2VTaGFkaW5nUGF0dGVybikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiQ2Fubm90IGluaXRpYWxpemUgQmFzZVNoYWRpbmdQYXR0ZXJuLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhdHRlcm4oKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkFic3RyYWN0IG1ldGhvZCBgZ2V0UGF0dGVybmAgY2FsbGVkLiIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFJhZGlhbEF4aWFsU2hhZGluZ1BhdHRlcm4gZXh0ZW5kcyBCYXNlU2hhZGluZ1BhdHRlcm4gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKElSKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3R5cGUgPSBJUlsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmJveCA9IElSWzJdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb2xvclN0b3BzID0gSVJbM107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3AwID0gSVJbNF07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3AxID0gSVJbNV07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3IwID0gSVJbNl07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3IxID0gSVJbN107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWF0cml4ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NyZWF0ZUdyYWRpZW50KGN0eCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZ3JhZDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3R5cGUgPT09ICJheGlhbCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWQgPSBjdHguY3JlYXRlTGluZWFyR3JhZGllbnQodGhpcy5fcDBbMF0sIHRoaXMuX3AwWzFdLCB0aGlzLl9wMVswXSwgdGhpcy5fcDFbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX3R5cGUgPT09ICJyYWRpYWwiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkID0gY3R4LmNyZWF0ZVJhZGlhbEdyYWRpZW50KHRoaXMuX3AwWzBdLCB0aGlzLl9wMFsxXSwgdGhpcy5fcjAsIHRoaXMuX3AxWzBdLCB0aGlzLl9wMVsxXSwgdGhpcy5fcjEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgY29sb3JTdG9wIG9mIHRoaXMuX2NvbG9yU3RvcHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWQuYWRkQ29sb3JTdG9wKGNvbG9yU3RvcFswXSwgY29sb3JTdG9wWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZ3JhZDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UGF0dGVybihjdHgsIG93bmVyLCBpbnZlcnNlLCBwYXRoVHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGF0dGVybjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhdGhUeXBlID09PSBQYXRoVHlwZS5TVFJPS0UgfHwgcGF0aFR5cGUgPT09IFBhdGhUeXBlLkZJTEwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG93bmVyQkJveCA9IG93bmVyLmN1cnJlbnQuZ2V0Q2xpcHBlZFBhdGhCb3VuZGluZ0JveChwYXRoVHlwZSwgKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKGN0eCkpIHx8IFswLCAwLCAwLCAwXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gTWF0aC5jZWlsKG93bmVyQkJveFsyXSAtIG93bmVyQkJveFswXSkgfHwgMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IE1hdGguY2VpbChvd25lckJCb3hbM10gLSBvd25lckJCb3hbMV0pIHx8IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bXBDYW52YXMgPSBvd25lci5jYWNoZWRDYW52YXNlcy5nZXRDYW52YXMoInBhdHRlcm4iLCB3aWR0aCwgaGVpZ2h0LCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRtcEN0eCA9IHRtcENhbnZhcy5jb250ZXh0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LmNsZWFyUmVjdCgwLCAwLCB0bXBDdHguY2FudmFzLndpZHRoLCB0bXBDdHguY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXBDdHguYmVnaW5QYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXBDdHgucmVjdCgwLCAwLCB0bXBDdHguY2FudmFzLndpZHRoLCB0bXBDdHguY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXBDdHgudHJhbnNsYXRlKC1vd25lckJCb3hbMF0sIC1vd25lckJCb3hbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW52ZXJzZSA9IF91dGlsLlV0aWwudHJhbnNmb3JtKGludmVyc2UsIFsxLCAwLCAwLCAxLCBvd25lckJCb3hbMF0sIG93bmVyQkJveFsxXV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LnRyYW5zZm9ybSguLi5vd25lci5iYXNlVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLm1hdHJpeCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRtcEN0eC50cmFuc2Zvcm0oLi4udGhpcy5tYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwbHlCb3VuZGluZ0JveCh0bXBDdHgsIHRoaXMuX2Jib3gpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LmZpbGxTdHlsZSA9IHRoaXMuX2NyZWF0ZUdyYWRpZW50KHRtcEN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXBDdHguZmlsbCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVybiA9IGN0eC5jcmVhdGVQYXR0ZXJuKHRtcENhbnZhcy5jYW52YXMsICJuby1yZXBlYXQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRvbU1hdHJpeCA9IG5ldyBET01NYXRyaXgoaW52ZXJzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXR0ZXJuLnNldFRyYW5zZm9ybShkb21NYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYXBwbHlCb3VuZGluZ0JveChjdHgsIHRoaXMuX2Jib3gpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0dGVybiA9IHRoaXMuX2NyZWF0ZUdyYWRpZW50KGN0eCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhdHRlcm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZHJhd1RyaWFuZ2xlKGRhdGEsIGNvbnRleHQsIHAxLCBwMiwgcDMsIGMxLCBjMiwgYzMpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjb29yZHMgPSBjb250ZXh0LmNvb3JkcywKICAgICAgICAgICAgICAgICAgICAgICAgY29sb3JzID0gY29udGV4dC5jb2xvcnM7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgYnl0ZXMgPSBkYXRhLmRhdGEsCiAgICAgICAgICAgICAgICAgICAgICAgIHJvd1NpemUgPSBkYXRhLndpZHRoICogNDsKICAgICAgICAgICAgICAgICAgICBsZXQgdG1wOwogICAgICAgICAgICAgICAgICAgIGlmIChjb29yZHNbcDEgKyAxXSA+IGNvb3Jkc1twMiArIDFdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRtcCA9IHAxOwogICAgICAgICAgICAgICAgICAgICAgICBwMSA9IHAyOwogICAgICAgICAgICAgICAgICAgICAgICBwMiA9IHRtcDsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wID0gYzE7CiAgICAgICAgICAgICAgICAgICAgICAgIGMxID0gYzI7CiAgICAgICAgICAgICAgICAgICAgICAgIGMyID0gdG1wOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoY29vcmRzW3AyICsgMV0gPiBjb29yZHNbcDMgKyAxXSkgewogICAgICAgICAgICAgICAgICAgICAgICB0bXAgPSBwMjsKICAgICAgICAgICAgICAgICAgICAgICAgcDIgPSBwMzsKICAgICAgICAgICAgICAgICAgICAgICAgcDMgPSB0bXA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRtcCA9IGMyOwogICAgICAgICAgICAgICAgICAgICAgICBjMiA9IGMzOwogICAgICAgICAgICAgICAgICAgICAgICBjMyA9IHRtcDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGNvb3Jkc1twMSArIDFdID4gY29vcmRzW3AyICsgMV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wID0gcDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHAxID0gcDI7CiAgICAgICAgICAgICAgICAgICAgICAgIHAyID0gdG1wOwogICAgICAgICAgICAgICAgICAgICAgICB0bXAgPSBjMTsKICAgICAgICAgICAgICAgICAgICAgICAgYzEgPSBjMjsKICAgICAgICAgICAgICAgICAgICAgICAgYzIgPSB0bXA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHgxID0gKGNvb3Jkc1twMV0gKyBjb250ZXh0Lm9mZnNldFgpICogY29udGV4dC5zY2FsZVg7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgeTEgPSAoY29vcmRzW3AxICsgMV0gKyBjb250ZXh0Lm9mZnNldFkpICogY29udGV4dC5zY2FsZVk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgeDIgPSAoY29vcmRzW3AyXSArIGNvbnRleHQub2Zmc2V0WCkgKiBjb250ZXh0LnNjYWxlWDsKICAgICAgICAgICAgICAgICAgICBjb25zdCB5MiA9IChjb29yZHNbcDIgKyAxXSArIGNvbnRleHQub2Zmc2V0WSkgKiBjb250ZXh0LnNjYWxlWTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB4MyA9IChjb29yZHNbcDNdICsgY29udGV4dC5vZmZzZXRYKSAqIGNvbnRleHQuc2NhbGVYOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHkzID0gKGNvb3Jkc1twMyArIDFdICsgY29udGV4dC5vZmZzZXRZKSAqIGNvbnRleHQuc2NhbGVZOwogICAgICAgICAgICAgICAgICAgIGlmICh5MSA+PSB5MykgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IGMxciA9IGNvbG9yc1tjMV0sCiAgICAgICAgICAgICAgICAgICAgICAgIGMxZyA9IGNvbG9yc1tjMSArIDFdLAogICAgICAgICAgICAgICAgICAgICAgICBjMWIgPSBjb2xvcnNbYzEgKyAyXTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjMnIgPSBjb2xvcnNbYzJdLAogICAgICAgICAgICAgICAgICAgICAgICBjMmcgPSBjb2xvcnNbYzIgKyAxXSwKICAgICAgICAgICAgICAgICAgICAgICAgYzJiID0gY29sb3JzW2MyICsgMl07CiAgICAgICAgICAgICAgICAgICAgY29uc3QgYzNyID0gY29sb3JzW2MzXSwKICAgICAgICAgICAgICAgICAgICAgICAgYzNnID0gY29sb3JzW2MzICsgMV0sCiAgICAgICAgICAgICAgICAgICAgICAgIGMzYiA9IGNvbG9yc1tjMyArIDJdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IG1pblkgPSBNYXRoLnJvdW5kKHkxKSwKICAgICAgICAgICAgICAgICAgICAgICAgbWF4WSA9IE1hdGgucm91bmQoeTMpOwogICAgICAgICAgICAgICAgICAgIGxldCB4YSwgY2FyLCBjYWcsIGNhYjsKICAgICAgICAgICAgICAgICAgICBsZXQgeGIsIGNiciwgY2JnLCBjYmI7CiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgeSA9IG1pblk7IHkgPD0gbWF4WTsgeSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh5IDwgeTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHkgPCB5MSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gKHkxIC0geSkgLyAoeTEgLSB5Mik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB4YSA9IHgxIC0gKHgxIC0geDIpICogazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhciA9IGMxciAtIChjMXIgLSBjMnIpICogazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhZyA9IGMxZyAtIChjMWcgLSBjMmcpICogazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhYiA9IGMxYiAtIChjMWIgLSBjMmIpICogazsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHkgPiB5MykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh5MiA9PT0geTMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgayA9ICh5MiAtIHkpIC8gKHkyIC0geTMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgeGEgPSB4MiAtICh4MiAtIHgzKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXIgPSBjMnIgLSAoYzJyIC0gYzNyKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWcgPSBjMmcgLSAoYzJnIC0gYzNnKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWIgPSBjMmIgLSAoYzJiIC0gYzNiKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGs7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh5IDwgeTEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGsgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHkgPiB5MykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgayA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gKHkxIC0geSkgLyAoeTEgLSB5Myk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgeGIgPSB4MSAtICh4MSAtIHgzKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNiciA9IGMxciAtIChjMXIgLSBjM3IpICogazsKICAgICAgICAgICAgICAgICAgICAgICAgY2JnID0gYzFnIC0gKGMxZyAtIGMzZykgKiBrOwogICAgICAgICAgICAgICAgICAgICAgICBjYmIgPSBjMWIgLSAoYzFiIC0gYzNiKSAqIGs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHgxXyA9IE1hdGgucm91bmQoTWF0aC5taW4oeGEsIHhiKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHgyXyA9IE1hdGgucm91bmQoTWF0aC5tYXgoeGEsIHhiKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBqID0gcm93U2l6ZSAqIHkgKyB4MV8gKiA0OwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCB4ID0geDFfOyB4IDw9IHgyXzsgeCsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gKHhhIC0geCkgLyAoeGEgLSB4Yik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoayA8IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoayA+IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBrID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2orK10gPSBjYXIgLSAoY2FyIC0gY2JyKSAqIGsgfCAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZXNbaisrXSA9IGNhZyAtIChjYWcgLSBjYmcpICogayB8IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlc1tqKytdID0gY2FiIC0gKGNhYiAtIGNiYikgKiBrIHwgMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2orK10gPSAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBkcmF3RmlndXJlKGRhdGEsIGZpZ3VyZSwgY29udGV4dCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBzID0gZmlndXJlLmNvb3JkczsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjcyA9IGZpZ3VyZS5jb2xvcnM7CiAgICAgICAgICAgICAgICAgICAgbGV0IGksIGlpOwogICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZmlndXJlLnR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAibGF0dGljZSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2ZXJ0aWNlc1BlclJvdyA9IGZpZ3VyZS52ZXJ0aWNlc1BlclJvdzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvd3MgPSBNYXRoLmZsb29yKHBzLmxlbmd0aCAvIHZlcnRpY2VzUGVyUm93KSAtIDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xzID0gdmVydGljZXNQZXJSb3cgLSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMDsgaSA8IHJvd3M7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBxID0gaSAqIHZlcnRpY2VzUGVyUm93OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgY29sczsgaisrLCBxKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZHJhd1RyaWFuZ2xlKGRhdGEsIGNvbnRleHQsIHBzW3FdLCBwc1txICsgMV0sIHBzW3EgKyB2ZXJ0aWNlc1BlclJvd10sIGNzW3FdLCBjc1txICsgMV0sIGNzW3EgKyB2ZXJ0aWNlc1BlclJvd10pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3VHJpYW5nbGUoZGF0YSwgY29udGV4dCwgcHNbcSArIHZlcnRpY2VzUGVyUm93ICsgMV0sIHBzW3EgKyAxXSwgcHNbcSArIHZlcnRpY2VzUGVyUm93XSwgY3NbcSArIHZlcnRpY2VzUGVyUm93ICsgMV0sIGNzW3EgKyAxXSwgY3NbcSArIHZlcnRpY2VzUGVyUm93XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgInRyaWFuZ2xlcyI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IHBzLmxlbmd0aDsgaSA8IGlpOyBpICs9IDMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3VHJpYW5nbGUoZGF0YSwgY29udGV4dCwgcHNbaV0sIHBzW2kgKyAxXSwgcHNbaSArIDJdLCBjc1tpXSwgY3NbaSArIDFdLCBjc1tpICsgMl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoImlsbGVnYWwgZmlndXJlIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgTWVzaFNoYWRpbmdQYXR0ZXJuIGV4dGVuZHMgQmFzZVNoYWRpbmdQYXR0ZXJuIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihJUikgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb29yZHMgPSBJUlsyXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29sb3JzID0gSVJbM107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZpZ3VyZXMgPSBJUls0XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYm91bmRzID0gSVJbNV07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Jib3ggPSBJUls3XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmFja2dyb3VuZCA9IElSWzhdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hdHJpeCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9jcmVhdGVNZXNoQ2FudmFzKGNvbWJpbmVkU2NhbGUsIGJhY2tncm91bmRDb2xvciwgY2FjaGVkQ2FudmFzZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgRVhQRUNURURfU0NBTEUgPSAxLjE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IE1BWF9QQVRURVJOX1NJWkUgPSAzMDAwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBCT1JERVJfU0laRSA9IDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFggPSBNYXRoLmZsb29yKHRoaXMuX2JvdW5kc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9mZnNldFkgPSBNYXRoLmZsb29yKHRoaXMuX2JvdW5kc1sxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJvdW5kc1dpZHRoID0gTWF0aC5jZWlsKHRoaXMuX2JvdW5kc1syXSkgLSBvZmZzZXRYOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBib3VuZHNIZWlnaHQgPSBNYXRoLmNlaWwodGhpcy5fYm91bmRzWzNdKSAtIG9mZnNldFk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gTWF0aC5taW4oTWF0aC5jZWlsKE1hdGguYWJzKGJvdW5kc1dpZHRoICogY29tYmluZWRTY2FsZVswXSAqIEVYUEVDVEVEX1NDQUxFKSksIE1BWF9QQVRURVJOX1NJWkUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBNYXRoLm1pbihNYXRoLmNlaWwoTWF0aC5hYnMoYm91bmRzSGVpZ2h0ICogY29tYmluZWRTY2FsZVsxXSAqIEVYUEVDVEVEX1NDQUxFKSksIE1BWF9QQVRURVJOX1NJWkUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZVggPSBib3VuZHNXaWR0aCAvIHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZVkgPSBib3VuZHNIZWlnaHQgLyBoZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRleHQgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb29yZHM6IHRoaXMuX2Nvb3JkcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbG9yczogdGhpcy5fY29sb3JzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0WDogLW9mZnNldFgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZOiAtb2Zmc2V0WSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWDogMSAvIHNjYWxlWCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWTogMSAvIHNjYWxlWQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWRkZWRXaWR0aCA9IHdpZHRoICsgQk9SREVSX1NJWkUgKiAyOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWRkZWRIZWlnaHQgPSBoZWlnaHQgKyBCT1JERVJfU0laRSAqIDI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRtcENhbnZhcyA9IGNhY2hlZENhbnZhc2VzLmdldENhbnZhcygibWVzaCIsIHBhZGRlZFdpZHRoLCBwYWRkZWRIZWlnaHQsIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdG1wQ3R4ID0gdG1wQ2FudmFzLmNvbnRleHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSB0bXBDdHguY3JlYXRlSW1hZ2VEYXRhKHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmFja2dyb3VuZENvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBieXRlcyA9IGRhdGEuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGJ5dGVzLmxlbmd0aDsgaSA8IGlpOyBpICs9IDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlc1tpXSA9IGJhY2tncm91bmRDb2xvclswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBieXRlc1tpICsgMV0gPSBiYWNrZ3JvdW5kQ29sb3JbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnl0ZXNbaSArIDJdID0gYmFja2dyb3VuZENvbG9yWzJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJ5dGVzW2kgKyAzXSA9IDI1NTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGZpZ3VyZSBvZiB0aGlzLl9maWd1cmVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkcmF3RmlndXJlKGRhdGEsIGZpZ3VyZSwgY29udGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdG1wQ3R4LnB1dEltYWdlRGF0YShkYXRhLCBCT1JERVJfU0laRSwgQk9SREVSX1NJWkUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXMgPSB0bXBDYW52YXMuY2FudmFzOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0WDogb2Zmc2V0WCAtIEJPUkRFUl9TSVpFICogc2NhbGVYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0WTogb2Zmc2V0WSAtIEJPUkRFUl9TSVpFICogc2NhbGVZLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVYLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVZCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFBhdHRlcm4oY3R4LCBvd25lciwgaW52ZXJzZSwgcGF0aFR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgYXBwbHlCb3VuZGluZ0JveChjdHgsIHRoaXMuX2Jib3gpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYXRoVHlwZSA9PT0gUGF0aFR5cGUuU0hBRElORykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGUgPSBfdXRpbC5VdGlsLnNpbmd1bGFyVmFsdWVEZWNvbXBvc2UyZFNjYWxlKCgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShjdHgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlID0gX3V0aWwuVXRpbC5zaW5ndWxhclZhbHVlRGVjb21wb3NlMmRTY2FsZShvd25lci5iYXNlVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLm1hdHJpeCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hdHJpeFNjYWxlID0gX3V0aWwuVXRpbC5zaW5ndWxhclZhbHVlRGVjb21wb3NlMmRTY2FsZSh0aGlzLm1hdHJpeCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGUgPSBbc2NhbGVbMF0gKiBtYXRyaXhTY2FsZVswXSwgc2NhbGVbMV0gKiBtYXRyaXhTY2FsZVsxXV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGVtcG9yYXJ5UGF0dGVybkNhbnZhcyA9IHRoaXMuX2NyZWF0ZU1lc2hDYW52YXMoc2NhbGUsIHBhdGhUeXBlID09PSBQYXRoVHlwZS5TSEFESU5HID8gbnVsbCA6IHRoaXMuX2JhY2tncm91bmQsIG93bmVyLmNhY2hlZENhbnZhc2VzKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhdGhUeXBlICE9PSBQYXRoVHlwZS5TSEFESU5HKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKC4uLm93bmVyLmJhc2VUcmFuc2Zvcm0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMubWF0cml4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zZm9ybSguLi50aGlzLm1hdHJpeCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY3R4LnRyYW5zbGF0ZSh0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzLm9mZnNldFgsIHRlbXBvcmFyeVBhdHRlcm5DYW52YXMub2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eC5zY2FsZSh0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzLnNjYWxlWCwgdGVtcG9yYXJ5UGF0dGVybkNhbnZhcy5zY2FsZVkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3R4LmNyZWF0ZVBhdHRlcm4odGVtcG9yYXJ5UGF0dGVybkNhbnZhcy5jYW52YXMsICJuby1yZXBlYXQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBEdW1teVNoYWRpbmdQYXR0ZXJuIGV4dGVuZHMgQmFzZVNoYWRpbmdQYXR0ZXJuIHsKICAgICAgICAgICAgICAgICAgICBnZXRQYXR0ZXJuKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gImhvdHBpbmsiOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldFNoYWRpbmdQYXR0ZXJuKElSKSB7CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChJUlswXSkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJSYWRpYWxBeGlhbCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFJhZGlhbEF4aWFsU2hhZGluZ1BhdHRlcm4oSVIpOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJNZXNoIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgTWVzaFNoYWRpbmdQYXR0ZXJuKElSKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiRHVtbXkiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBEdW1teVNoYWRpbmdQYXR0ZXJuKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5rbm93biBJUiB0eXBlOiAke0lSWzBdfWApOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY29uc3QgUGFpbnRUeXBlID0gewogICAgICAgICAgICAgICAgICAgIENPTE9SRUQ6IDEsCiAgICAgICAgICAgICAgICAgICAgVU5DT0xPUkVEOiAyCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgY2xhc3MgVGlsaW5nUGF0dGVybiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGdldCBNQVhfUEFUVEVSTl9TSVpFKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIk1BWF9QQVRURVJOX1NJWkUiLCAzMDAwKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoSVIsIGNvbG9yLCBjdHgsIGNhbnZhc0dyYXBoaWNzRmFjdG9yeSwgYmFzZVRyYW5zZm9ybSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wZXJhdG9yTGlzdCA9IElSWzJdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hdHJpeCA9IElSWzNdIHx8IFsxLCAwLCAwLCAxLCAwLCAwXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5iYm94ID0gSVJbNF07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueHN0ZXAgPSBJUls1XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy55c3RlcCA9IElSWzZdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhaW50VHlwZSA9IElSWzddOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRpbGluZ1R5cGUgPSBJUls4XTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2xvciA9IGNvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eCA9IGN0eDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXNHcmFwaGljc0ZhY3RvcnkgPSBjYW52YXNHcmFwaGljc0ZhY3Rvcnk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmFzZVRyYW5zZm9ybSA9IGJhc2VUcmFuc2Zvcm07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNyZWF0ZVBhdHRlcm5DYW52YXMob3duZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3BlcmF0b3JMaXN0ID0gdGhpcy5vcGVyYXRvckxpc3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJib3ggPSB0aGlzLmJib3g7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHhzdGVwID0gdGhpcy54c3RlcDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeXN0ZXAgPSB0aGlzLnlzdGVwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWludFR5cGUgPSB0aGlzLnBhaW50VHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGlsaW5nVHlwZSA9IHRoaXMudGlsaW5nVHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY29sb3IgPSB0aGlzLmNvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW52YXNHcmFwaGljc0ZhY3RvcnkgPSB0aGlzLmNhbnZhc0dyYXBoaWNzRmFjdG9yeTsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJUaWxpbmdUeXBlOiAiICsgdGlsaW5nVHlwZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHgwID0gYmJveFswXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkwID0gYmJveFsxXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHgxID0gYmJveFsyXSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkxID0gYmJveFszXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF0cml4U2NhbGUgPSBfdXRpbC5VdGlsLnNpbmd1bGFyVmFsdWVEZWNvbXBvc2UyZFNjYWxlKHRoaXMubWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VyTWF0cml4U2NhbGUgPSBfdXRpbC5VdGlsLnNpbmd1bGFyVmFsdWVEZWNvbXBvc2UyZFNjYWxlKHRoaXMuYmFzZVRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbWJpbmVkU2NhbGUgPSBbbWF0cml4U2NhbGVbMF0gKiBjdXJNYXRyaXhTY2FsZVswXSwgbWF0cml4U2NhbGVbMV0gKiBjdXJNYXRyaXhTY2FsZVsxXV07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRpbXggPSB0aGlzLmdldFNpemVBbmRTY2FsZSh4c3RlcCwgdGhpcy5jdHguY2FudmFzLndpZHRoLCBjb21iaW5lZFNjYWxlWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGlteSA9IHRoaXMuZ2V0U2l6ZUFuZFNjYWxlKHlzdGVwLCB0aGlzLmN0eC5jYW52YXMuaGVpZ2h0LCBjb21iaW5lZFNjYWxlWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdG1wQ2FudmFzID0gb3duZXIuY2FjaGVkQ2FudmFzZXMuZ2V0Q2FudmFzKCJwYXR0ZXJuIiwgZGlteC5zaXplLCBkaW15LnNpemUsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bXBDdHggPSB0bXBDYW52YXMuY29udGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZ3JhcGhpY3MgPSBjYW52YXNHcmFwaGljc0ZhY3RvcnkuY3JlYXRlQ2FudmFzR3JhcGhpY3ModG1wQ3R4KTsKICAgICAgICAgICAgICAgICAgICAgICAgZ3JhcGhpY3MuZ3JvdXBMZXZlbCA9IG93bmVyLmdyb3VwTGV2ZWw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RmlsbEFuZFN0cm9rZVN0eWxlVG9Db250ZXh0KGdyYXBoaWNzLCBwYWludFR5cGUsIGNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFkanVzdGVkWDAgPSB4MDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFkanVzdGVkWTAgPSB5MDsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFkanVzdGVkWDEgPSB4MTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGFkanVzdGVkWTEgPSB5MTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHgwIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRqdXN0ZWRYMCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGp1c3RlZFgxICs9IE1hdGguYWJzKHgwKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoeTAgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGp1c3RlZFkwID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFkanVzdGVkWTEgKz0gTWF0aC5hYnMoeTApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRtcEN0eC50cmFuc2xhdGUoLShkaW14LnNjYWxlICogYWRqdXN0ZWRYMCksIC0oZGlteS5zY2FsZSAqIGFkanVzdGVkWTApKTsKICAgICAgICAgICAgICAgICAgICAgICAgZ3JhcGhpY3MudHJhbnNmb3JtKGRpbXguc2NhbGUsIDAsIDAsIGRpbXkuc2NhbGUsIDAsIDApOwogICAgICAgICAgICAgICAgICAgICAgICB0bXBDdHguc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXBCYm94KGdyYXBoaWNzLCBhZGp1c3RlZFgwLCBhZGp1c3RlZFkwLCBhZGp1c3RlZFgxLCBhZGp1c3RlZFkxKTsKICAgICAgICAgICAgICAgICAgICAgICAgZ3JhcGhpY3MuYmFzZVRyYW5zZm9ybSA9ICgwLCBfZGlzcGxheV91dGlscy5nZXRDdXJyZW50VHJhbnNmb3JtKShncmFwaGljcy5jdHgpOwogICAgICAgICAgICAgICAgICAgICAgICBncmFwaGljcy5leGVjdXRlT3BlcmF0b3JMaXN0KG9wZXJhdG9yTGlzdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGdyYXBoaWNzLmVuZERyYXdpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhczogdG1wQ2FudmFzLmNhbnZhcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWDogZGlteC5zY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlWTogZGlteS5zY2FsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFg6IGFkanVzdGVkWDAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZOiBhZGp1c3RlZFkwCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFNpemVBbmRTY2FsZShzdGVwLCByZWFsT3V0cHV0U2l6ZSwgc2NhbGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3RlcCA9IE1hdGguYWJzKHN0ZXApOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXhTaXplID0gTWF0aC5tYXgoVGlsaW5nUGF0dGVybi5NQVhfUEFUVEVSTl9TSVpFLCByZWFsT3V0cHV0U2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzaXplID0gTWF0aC5jZWlsKHN0ZXAgKiBzY2FsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzaXplID49IG1heFNpemUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNpemUgPSBtYXhTaXplOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGUgPSBzaXplIC8gc3RlcDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaXplCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNsaXBCYm94KGdyYXBoaWNzLCB4MCwgeTAsIHgxLCB5MSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiYm94V2lkdGggPSB4MSAtIHgwOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiYm94SGVpZ2h0ID0geTEgLSB5MDsKICAgICAgICAgICAgICAgICAgICAgICAgZ3JhcGhpY3MuY3R4LnJlY3QoeDAsIHkwLCBiYm94V2lkdGgsIGJib3hIZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBncmFwaGljcy5jdXJyZW50LnVwZGF0ZVJlY3RNaW5NYXgoKDAsIF9kaXNwbGF5X3V0aWxzLmdldEN1cnJlbnRUcmFuc2Zvcm0pKGdyYXBoaWNzLmN0eCksIFt4MCwgeTAsIHgxLCB5MV0pOwogICAgICAgICAgICAgICAgICAgICAgICBncmFwaGljcy5jbGlwKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGdyYXBoaWNzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0RmlsbEFuZFN0cm9rZVN0eWxlVG9Db250ZXh0KGdyYXBoaWNzLCBwYWludFR5cGUsIGNvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRleHQgPSBncmFwaGljcy5jdHgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50ID0gZ3JhcGhpY3MuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChwYWludFR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgUGFpbnRUeXBlLkNPTE9SRUQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3R4ID0gdGhpcy5jdHg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dC5maWxsU3R5bGUgPSBjdHguZmlsbFN0eWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQuc3Ryb2tlU3R5bGUgPSBjdHguc3Ryb2tlU3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5maWxsQ29sb3IgPSBjdHguZmlsbFN0eWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuc3Ryb2tlQ29sb3IgPSBjdHguc3Ryb2tlU3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFBhaW50VHlwZS5VTkNPTE9SRUQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3NzQ29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihjb2xvclswXSwgY29sb3JbMV0sIGNvbG9yWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZXh0LmZpbGxTdHlsZSA9IGNzc0NvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRleHQuc3Ryb2tlU3R5bGUgPSBjc3NDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmZpbGxDb2xvciA9IGNzc0NvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuc3Ryb2tlQ29sb3IgPSBjc3NDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBVbnN1cHBvcnRlZCBwYWludCB0eXBlOiAke3BhaW50VHlwZX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRQYXR0ZXJuKGN0eCwgb3duZXIsIGludmVyc2UsIHBhdGhUeXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBtYXRyaXggPSBpbnZlcnNlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGF0aFR5cGUgIT09IFBhdGhUeXBlLlNIQURJTkcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hdHJpeCA9IF91dGlsLlV0aWwudHJhbnNmb3JtKG1hdHJpeCwgb3duZXIuYmFzZVRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5tYXRyaXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXRyaXggPSBfdXRpbC5VdGlsLnRyYW5zZm9ybShtYXRyaXgsIHRoaXMubWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzID0gdGhpcy5jcmVhdGVQYXR0ZXJuQ2FudmFzKG93bmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRvbU1hdHJpeCA9IG5ldyBET01NYXRyaXgobWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgZG9tTWF0cml4ID0gZG9tTWF0cml4LnRyYW5zbGF0ZSh0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzLm9mZnNldFgsIHRlbXBvcmFyeVBhdHRlcm5DYW52YXMub2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRvbU1hdHJpeCA9IGRvbU1hdHJpeC5zY2FsZSgxIC8gdGVtcG9yYXJ5UGF0dGVybkNhbnZhcy5zY2FsZVgsIDEgLyB0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzLnNjYWxlWSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdHRlcm4gPSBjdHguY3JlYXRlUGF0dGVybih0ZW1wb3JhcnlQYXR0ZXJuQ2FudmFzLmNhbnZhcywgInJlcGVhdCIpOwogICAgICAgICAgICAgICAgICAgICAgICBwYXR0ZXJuLnNldFRyYW5zZm9ybShkb21NYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGF0dGVybjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlRpbGluZ1BhdHRlcm4gPSBUaWxpbmdQYXR0ZXJuOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNDggKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5jb252ZXJ0QmxhY2tBbmRXaGl0ZVRvUkdCQSA9IGNvbnZlcnRCbGFja0FuZFdoaXRlVG9SR0JBOwogICAgICAgICAgICAgICAgZXhwb3J0cy5jb252ZXJ0VG9SR0JBID0gY29udmVydFRvUkdCQTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuZ3JheVRvUkdCQSA9IGdyYXlUb1JHQkE7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29udmVydFRvUkdCQShwYXJhbXMpIHsKICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKHBhcmFtcy5raW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuSW1hZ2VLaW5kLkdSQVlTQ0FMRV8xQlBQOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbnZlcnRCbGFja0FuZFdoaXRlVG9SR0JBKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuSW1hZ2VLaW5kLlJHQl8yNEJQUDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBjb252ZXJ0UkdCVG9SR0JBKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29udmVydEJsYWNrQW5kV2hpdGVUb1JHQkEoX3JlZikgewogICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHNyYywKICAgICAgICAgICAgICAgICAgICAgICAgc3JjUG9zID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdCwKICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodCwKICAgICAgICAgICAgICAgICAgICAgICAgbm9uQmxhY2tDb2xvciA9IDB4ZmZmZmZmZmYsCiAgICAgICAgICAgICAgICAgICAgICAgIGludmVyc2VEZWNvZGUgPSBmYWxzZQogICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJsYWNrID0gX3V0aWwuRmVhdHVyZVRlc3QuaXNMaXR0bGVFbmRpYW4gPyAweGZmMDAwMDAwIDogMHgwMDAwMDBmZjsKICAgICAgICAgICAgICAgICAgICBjb25zdCBbemVyb01hcHBpbmcsIG9uZU1hcHBpbmddID0gaW52ZXJzZURlY29kZSA/IFtub25CbGFja0NvbG9yLCBibGFja10gOiBbYmxhY2ssIG5vbkJsYWNrQ29sb3JdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoSW5Tb3VyY2UgPSB3aWR0aCA+PiAzOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoUmVtYWluZGVyID0gd2lkdGggJiA3OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNyY0xlbmd0aCA9IHNyYy5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgZGVzdCA9IG5ldyBVaW50MzJBcnJheShkZXN0LmJ1ZmZlcik7CiAgICAgICAgICAgICAgICAgICAgbGV0IGRlc3RQb3MgPSAwOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgaGVpZ2h0OyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBtYXggPSBzcmNQb3MgKyB3aWR0aEluU291cmNlOyBzcmNQb3MgPCBtYXg7IHNyY1BvcysrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbGVtID0gc3JjUG9zIDwgc3JjTGVuZ3RoID8gc3JjW3NyY1Bvc10gOiAyNTU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMGIxMDAwMDAwMCA/IG9uZU1hcHBpbmcgOiB6ZXJvTWFwcGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcysrXSA9IGVsZW0gJiAwYjEwMDAwMDAgPyBvbmVNYXBwaW5nIDogemVyb01hcHBpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMGIxMDAwMDAgPyBvbmVNYXBwaW5nIDogemVyb01hcHBpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMGIxMDAwMCA/IG9uZU1hcHBpbmcgOiB6ZXJvTWFwcGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcysrXSA9IGVsZW0gJiAwYjEwMDAgPyBvbmVNYXBwaW5nIDogemVyb01hcHBpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMGIxMDAgPyBvbmVNYXBwaW5nIDogemVyb01hcHBpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMGIxMCA/IG9uZU1hcHBpbmcgOiB6ZXJvTWFwcGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcysrXSA9IGVsZW0gJiAwYjEgPyBvbmVNYXBwaW5nIDogemVyb01hcHBpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoUmVtYWluZGVyID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbGVtID0gc3JjUG9zIDwgc3JjTGVuZ3RoID8gc3JjW3NyY1BvcysrXSA6IDI1NTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCB3aWR0aFJlbWFpbmRlcjsgaisrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBlbGVtICYgMSA8PCA3IC0gaiA/IG9uZU1hcHBpbmcgOiB6ZXJvTWFwcGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICBzcmNQb3MsCiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RQb3MKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gY29udmVydFJHQlRvUkdCQShfcmVmMikgewogICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHNyYywKICAgICAgICAgICAgICAgICAgICAgICAgc3JjUG9zID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdCwKICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFBvcyA9IDAsCiAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgbGV0IGkgPSAwOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxlbjMyID0gc3JjLmxlbmd0aCA+PiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNyYzMyID0gbmV3IFVpbnQzMkFycmF5KHNyYy5idWZmZXIsIHNyY1BvcywgbGVuMzIpOwogICAgICAgICAgICAgICAgICAgIGlmIChfdXRpbC5GZWF0dXJlVGVzdC5pc0xpdHRsZUVuZGlhbikgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKDsgaSA8IGxlbjMyIC0gMjsgaSArPSAzLCBkZXN0UG9zICs9IDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHMxID0gc3JjMzJbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzMiA9IHNyYzMyW2kgKyAxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHMzID0gc3JjMzJbaSArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFtkZXN0UG9zXSA9IHMxIHwgMHhmZjAwMDAwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcyArIDFdID0gczEgPj4+IDI0IHwgczIgPDwgOCB8IDB4ZmYwMDAwMDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MgKyAyXSA9IHMyID4+PiAxNiB8IHMzIDw8IDE2IHwgMHhmZjAwMDAwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcyArIDNdID0gczMgPj4+IDggfCAweGZmMDAwMDAwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGogPSBpICogNCwgamogPSBzcmMubGVuZ3RoOyBqIDwgamo7IGogKz0gMykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFtkZXN0UG9zKytdID0gc3JjW2pdIHwgc3JjW2ogKyAxXSA8PCA4IHwgc3JjW2ogKyAyXSA8PCAxNiB8IDB4ZmYwMDAwMDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKDsgaSA8IGxlbjMyIC0gMjsgaSArPSAzLCBkZXN0UG9zICs9IDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHMxID0gc3JjMzJbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzMiA9IHNyYzMyW2kgKyAxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHMzID0gc3JjMzJbaSArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVzdFtkZXN0UG9zXSA9IHMxIHwgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcyArIDFdID0gczEgPDwgMjQgfCBzMiA+Pj4gOCB8IDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MgKyAyXSA9IHMyIDw8IDE2IHwgczMgPj4+IDE2IHwgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbZGVzdFBvcyArIDNdID0gczMgPDwgOCB8IDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaiA9IGkgKiA0LCBqaiA9IHNyYy5sZW5ndGg7IGogPCBqajsgaiArPSAzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBzcmNbal0gPDwgMjQgfCBzcmNbaiArIDFdIDw8IDE2IHwgc3JjW2ogKyAyXSA8PCA4IHwgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICBzcmNQb3MsCiAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RQb3MKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZ3JheVRvUkdCQShzcmMsIGRlc3QpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoX3V0aWwuRmVhdHVyZVRlc3QuaXNMaXR0bGVFbmRpYW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gc3JjLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc3RbaV0gPSBzcmNbaV0gKiAweDEwMTAxIHwgMHhmZjAwMDAwMDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IHNyYy5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXN0W2ldID0gc3JjW2ldICogMHgxMDEwMTAwIHwgMHgwMDAwMDBmZjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTQ5ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMpID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuR2xvYmFsV29ya2VyT3B0aW9ucyA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIGNvbnN0IEdsb2JhbFdvcmtlck9wdGlvbnMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5HbG9iYWxXb3JrZXJPcHRpb25zID0gR2xvYmFsV29ya2VyT3B0aW9uczsKICAgICAgICAgICAgICAgIEdsb2JhbFdvcmtlck9wdGlvbnMud29ya2VyUG9ydCA9IG51bGw7CiAgICAgICAgICAgICAgICBHbG9iYWxXb3JrZXJPcHRpb25zLndvcmtlclNyYyA9ICIiOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNTAgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5NZXNzYWdlSGFuZGxlciA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICBjb25zdCBDYWxsYmFja0tpbmQgPSB7CiAgICAgICAgICAgICAgICAgICAgVU5LTk9XTjogMCwKICAgICAgICAgICAgICAgICAgICBEQVRBOiAxLAogICAgICAgICAgICAgICAgICAgIEVSUk9SOiAyCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgY29uc3QgU3RyZWFtS2luZCA9IHsKICAgICAgICAgICAgICAgICAgICBVTktOT1dOOiAwLAogICAgICAgICAgICAgICAgICAgIENBTkNFTDogMSwKICAgICAgICAgICAgICAgICAgICBDQU5DRUxfQ09NUExFVEU6IDIsCiAgICAgICAgICAgICAgICAgICAgQ0xPU0U6IDMsCiAgICAgICAgICAgICAgICAgICAgRU5RVUVVRTogNCwKICAgICAgICAgICAgICAgICAgICBFUlJPUjogNSwKICAgICAgICAgICAgICAgICAgICBQVUxMOiA2LAogICAgICAgICAgICAgICAgICAgIFBVTExfQ09NUExFVEU6IDcsCiAgICAgICAgICAgICAgICAgICAgU1RBUlRfQ09NUExFVEU6IDgKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBmdW5jdGlvbiB3cmFwUmVhc29uKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgIGlmICghKHJlYXNvbiBpbnN0YW5jZW9mIEVycm9yIHx8IHR5cGVvZiByZWFzb24gPT09ICJvYmplY3QiICYmIHJlYXNvbiAhPT0gbnVsbCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgnd3JhcFJlYXNvbjogRXhwZWN0ZWQgInJlYXNvbiIgdG8gYmUgYSAocG9zc2libHkgY2xvbmVkKSBFcnJvci4nKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChyZWFzb24ubmFtZSkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJBYm9ydEV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF91dGlsLkFib3J0RXhjZXB0aW9uKHJlYXNvbi5tZXNzYWdlKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTWlzc2luZ1BERkV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF91dGlsLk1pc3NpbmdQREZFeGNlcHRpb24ocmVhc29uLm1lc3NhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJQYXNzd29yZEV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF91dGlsLlBhc3N3b3JkRXhjZXB0aW9uKHJlYXNvbi5tZXNzYWdlLCByZWFzb24uY29kZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF91dGlsLlVuZXhwZWN0ZWRSZXNwb25zZUV4Y2VwdGlvbihyZWFzb24ubWVzc2FnZSwgcmVhc29uLnN0YXR1cyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlVua25vd25FcnJvckV4Y2VwdGlvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF91dGlsLlVua25vd25FcnJvckV4Y2VwdGlvbihyZWFzb24ubWVzc2FnZSwgcmVhc29uLmRldGFpbHMpOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBfdXRpbC5Vbmtub3duRXJyb3JFeGNlcHRpb24ocmVhc29uLm1lc3NhZ2UsIHJlYXNvbi50b1N0cmluZygpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBNZXNzYWdlSGFuZGxlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc291cmNlTmFtZSwgdGFyZ2V0TmFtZSwgY29tT2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc291cmNlTmFtZSA9IHNvdXJjZU5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGFyZ2V0TmFtZSA9IHRhcmdldE5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tT2JqID0gY29tT2JqOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrSWQgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cmVhbUlkID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJlYW1TaW5rcyA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RyZWFtQ29udHJvbGxlcnMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbGxiYWNrQ2FwYWJpbGl0aWVzID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hY3Rpb25IYW5kbGVyID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb25Db21PYmpPbk1lc3NhZ2UgPSBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gZXZlbnQuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnRhcmdldE5hbWUgIT09IHRoaXMuc291cmNlTmFtZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnN0cmVhbSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Byb2Nlc3NTdHJlYW1NZXNzYWdlKGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmNhbGxiYWNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FsbGJhY2tJZCA9IGRhdGEuY2FsbGJhY2tJZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYXBhYmlsaXR5ID0gdGhpcy5jYWxsYmFja0NhcGFiaWxpdGllc1tjYWxsYmFja0lkXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWNhcGFiaWxpdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBDYW5ub3QgcmVzb2x2ZSBjYWxsYmFjayAke2NhbGxiYWNrSWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSB0aGlzLmNhbGxiYWNrQ2FwYWJpbGl0aWVzW2NhbGxiYWNrSWRdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmNhbGxiYWNrID09PSBDYWxsYmFja0tpbmQuREFUQSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXBhYmlsaXR5LnJlc29sdmUoZGF0YS5kYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGRhdGEuY2FsbGJhY2sgPT09IENhbGxiYWNrS2luZC5FUlJPUikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXBhYmlsaXR5LnJlamVjdCh3cmFwUmVhc29uKGRhdGEucmVhc29uKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJVbmV4cGVjdGVkIGNhbGxiYWNrIGNhc2UiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWN0aW9uID0gdGhpcy5hY3Rpb25IYW5kbGVyW2RhdGEuYWN0aW9uXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghYWN0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBVbmtub3duIGFjdGlvbiBmcm9tIHdvcmtlcjogJHtkYXRhLmFjdGlvbn1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmNhbGxiYWNrSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYlNvdXJjZU5hbWUgPSB0aGlzLnNvdXJjZU5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2JUYXJnZXROYW1lID0gZGF0YS5zb3VyY2VOYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoYWN0aW9uKGRhdGEuZGF0YSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pLnRoZW4oZnVuY3Rpb24gKHJlc3VsdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZTogY2JTb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZTogY2JUYXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2s6IENhbGxiYWNrS2luZC5EQVRBLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FsbGJhY2tJZDogZGF0YS5jYWxsYmFja0lkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YTogcmVzdWx0CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWU6IGNiU291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldE5hbWU6IGNiVGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrOiBDYWxsYmFja0tpbmQuRVJST1IsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYWxsYmFja0lkOiBkYXRhLmNhbGxiYWNrSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFzb246IHdyYXBSZWFzb24ocmVhc29uKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5zdHJlYW1JZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVN0cmVhbVNpbmsoZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWN0aW9uKGRhdGEuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iai5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIiwgdGhpcy5fb25Db21PYmpPbk1lc3NhZ2UpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBvbihhY3Rpb25OYW1lLCBoYW5kbGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFoID0gdGhpcy5hY3Rpb25IYW5kbGVyOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWhbYWN0aW9uTmFtZV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVGhlcmUgaXMgYWxyZWFkeSBhbiBhY3Rpb25OYW1lIGNhbGxlZCAiJHthY3Rpb25OYW1lfSJgKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBhaFthY3Rpb25OYW1lXSA9IGhhbmRsZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNlbmQoYWN0aW9uTmFtZSwgZGF0YSwgdHJhbnNmZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWU6IHRoaXMuc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldE5hbWU6IHRoaXMudGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFjdGlvbjogYWN0aW9uTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEKICAgICAgICAgICAgICAgICAgICAgICAgfSwgdHJhbnNmZXJzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2VuZFdpdGhQcm9taXNlKGFjdGlvbk5hbWUsIGRhdGEsIHRyYW5zZmVycykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYWxsYmFja0lkID0gdGhpcy5jYWxsYmFja0lkKys7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FsbGJhY2tDYXBhYmlsaXRpZXNbY2FsbGJhY2tJZF0gPSBjYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWU6IHRoaXMuc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lOiB0aGlzLnRhcmdldE5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWN0aW9uOiBhY3Rpb25OYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbGxiYWNrSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwgdHJhbnNmZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHkucmVqZWN0KGV4KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZW5kV2l0aFN0cmVhbShhY3Rpb25OYW1lLCBkYXRhLCBxdWV1ZWluZ1N0cmF0ZWd5LCB0cmFuc2ZlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RyZWFtSWQgPSB0aGlzLnN0cmVhbUlkKyssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lID0gdGhpcy5zb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSA9IHRoaXMudGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iaiA9IHRoaXMuY29tT2JqOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFJlYWRhYmxlU3RyZWFtKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0OiBjb250cm9sbGVyID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGFydENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJlYW1Db250cm9sbGVyc1tzdHJlYW1JZF0gPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRyb2xsZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0Q2FsbDogc3RhcnRDYXBhYmlsaXR5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdWxsQ2FsbDogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FuY2VsQ2FsbDogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNDbG9zZWQ6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY3Rpb246IGFjdGlvbk5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXNpcmVkU2l6ZTogY29udHJvbGxlci5kZXNpcmVkU2l6ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIHRyYW5zZmVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN0YXJ0Q2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1bGw6IGNvbnRyb2xsZXIgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHB1bGxDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RyZWFtQ29udHJvbGxlcnNbc3RyZWFtSWRdLnB1bGxDYWxsID0gcHVsbENhcGFiaWxpdHk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLlBVTEwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXNpcmVkU2l6ZTogY29udHJvbGxlci5kZXNpcmVkU2l6ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwdWxsQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbmNlbDogcmVhc29uID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KShyZWFzb24gaW5zdGFuY2VvZiBFcnJvciwgImNhbmNlbCBtdXN0IGhhdmUgYSB2YWxpZCByZWFzb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjYW5jZWxDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RyZWFtQ29udHJvbGxlcnNbc3RyZWFtSWRdLmNhbmNlbENhbGwgPSBjYW5jZWxDYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3RyZWFtQ29udHJvbGxlcnNbc3RyZWFtSWRdLmlzQ2xvc2VkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuQ0FOQ0VMLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uOiB3cmFwUmVhc29uKHJlYXNvbikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FuY2VsQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9LCBxdWV1ZWluZ1N0cmF0ZWd5KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NyZWF0ZVN0cmVhbVNpbmsoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdHJlYW1JZCA9IGRhdGEuc3RyZWFtSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lID0gdGhpcy5zb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSA9IGRhdGEuc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iaiA9IHRoaXMuY29tT2JqOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzZWxmID0gdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFjdGlvbiA9IHRoaXMuYWN0aW9uSGFuZGxlcltkYXRhLmFjdGlvbl07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0cmVhbVNpbmsgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbnF1ZXVlKGNodW5rKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNpemUgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRyYW5zZmVycyA9IGFyZ3VtZW50cy5sZW5ndGggPiAyID8gYXJndW1lbnRzWzJdIDogdW5kZWZpbmVkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGFzdERlc2lyZWRTaXplID0gdGhpcy5kZXNpcmVkU2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlc2lyZWRTaXplIC09IHNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxhc3REZXNpcmVkU2l6ZSA+IDAgJiYgdGhpcy5kZXNpcmVkU2l6ZSA8PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2lua0NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVhZHkgPSB0aGlzLnNpbmtDYXBhYmlsaXR5LnByb21pc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldE5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5FTlFVRVVFLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCB0cmFuc2ZlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsb3NlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc0NhbmNlbGxlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLkNMT1NFLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSBzZWxmLnN0cmVhbVNpbmtzW3N0cmVhbUlkXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnJvcihyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KShyZWFzb24gaW5zdGFuY2VvZiBFcnJvciwgImVycm9yIG11c3QgaGF2ZSBhIHZhbGlkIHJlYXNvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc0NhbmNlbGxlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLkVSUk9SLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhc29uOiB3cmFwUmVhc29uKHJlYXNvbikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaW5rQ2FwYWJpbGl0eTogKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb25QdWxsOiBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb25DYW5jZWw6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0NhbmNlbGxlZDogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXNpcmVkU2l6ZTogZGF0YS5kZXNpcmVkU2l6ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWR5OiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbVNpbmsuc2lua0NhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1TaW5rLnJlYWR5ID0gc3RyZWFtU2luay5zaW5rQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cmVhbVNpbmtzW3N0cmVhbUlkXSA9IHN0cmVhbVNpbms7CiAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKGFjdGlvbihkYXRhLmRhdGEsIHN0cmVhbVNpbmspKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSkudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuU1RBUlRfQ09NUExFVEUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3VjY2VzczogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5TVEFSVF9DT01QTEVURSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFzb246IHdyYXBSZWFzb24ocmVhc29uKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfcHJvY2Vzc1N0cmVhbU1lc3NhZ2UoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdHJlYW1JZCA9IGRhdGEuc3RyZWFtSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lID0gdGhpcy5zb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSA9IGRhdGEuc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iaiA9IHRoaXMuY29tT2JqOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdHJlYW1Db250cm9sbGVyID0gdGhpcy5zdHJlYW1Db250cm9sbGVyc1tzdHJlYW1JZF0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1TaW5rID0gdGhpcy5zdHJlYW1TaW5rc1tzdHJlYW1JZF07CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZGF0YS5zdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgU3RyZWFtS2luZC5TVEFSVF9DT01QTEVURToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5zdWNjZXNzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUNvbnRyb2xsZXIuc3RhcnRDYWxsLnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1Db250cm9sbGVyLnN0YXJ0Q2FsbC5yZWplY3Qod3JhcFJlYXNvbihkYXRhLnJlYXNvbikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgU3RyZWFtS2luZC5QVUxMX0NPTVBMRVRFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnN1Y2Nlc3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtQ29udHJvbGxlci5wdWxsQ2FsbC5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtQ29udHJvbGxlci5wdWxsQ2FsbC5yZWplY3Qod3JhcFJlYXNvbihkYXRhLnJlYXNvbikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgU3RyZWFtS2luZC5QVUxMOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc3RyZWFtU2luaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldE5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuUFVMTF9DT01QTEVURSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3VjY2VzczogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdHJlYW1TaW5rLmRlc2lyZWRTaXplIDw9IDAgJiYgZGF0YS5kZXNpcmVkU2l6ZSA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtU2luay5zaW5rQ2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbVNpbmsuZGVzaXJlZFNpemUgPSBkYXRhLmRlc2lyZWRTaXplOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmUoc3RyZWFtU2luay5vblB1bGwgJiYgc3RyZWFtU2luay5vblB1bGwoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSkudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5QVUxMX0NPTVBMRVRFLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtSWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWNjZXNzOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sIGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLlBVTExfQ09NUExFVEUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbjogd3JhcFJlYXNvbihyZWFzb24pCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBTdHJlYW1LaW5kLkVOUVVFVUU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmFzc2VydCkoc3RyZWFtQ29udHJvbGxlciwgImVucXVldWUgc2hvdWxkIGhhdmUgc3RyZWFtIGNvbnRyb2xsZXIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RyZWFtQ29udHJvbGxlci5pc0Nsb3NlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtQ29udHJvbGxlci5jb250cm9sbGVyLmVucXVldWUoZGF0YS5jaHVuayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFN0cmVhbUtpbmQuQ0xPU0U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmFzc2VydCkoc3RyZWFtQ29udHJvbGxlciwgImNsb3NlIHNob3VsZCBoYXZlIHN0cmVhbSBjb250cm9sbGVyIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0cmVhbUNvbnRyb2xsZXIuaXNDbG9zZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUNvbnRyb2xsZXIuaXNDbG9zZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUNvbnRyb2xsZXIuY29udHJvbGxlci5jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RlbGV0ZVN0cmVhbUNvbnRyb2xsZXIoc3RyZWFtQ29udHJvbGxlciwgc3RyZWFtSWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBTdHJlYW1LaW5kLkVSUk9SOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHN0cmVhbUNvbnRyb2xsZXIsICJlcnJvciBzaG91bGQgaGF2ZSBzdHJlYW0gY29udHJvbGxlciIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUNvbnRyb2xsZXIuY29udHJvbGxlci5lcnJvcih3cmFwUmVhc29uKGRhdGEucmVhc29uKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGVsZXRlU3RyZWFtQ29udHJvbGxlcihzdHJlYW1Db250cm9sbGVyLCBzdHJlYW1JZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFN0cmVhbUtpbmQuQ0FOQ0VMX0NPTVBMRVRFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnN1Y2Nlc3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtQ29udHJvbGxlci5jYW5jZWxDYWxsLnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1Db250cm9sbGVyLmNhbmNlbENhbGwucmVqZWN0KHdyYXBSZWFzb24oZGF0YS5yZWFzb24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGVsZXRlU3RyZWFtQ29udHJvbGxlcihzdHJlYW1Db250cm9sbGVyLCBzdHJlYW1JZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIFN0cmVhbUtpbmQuQ0FOQ0VMOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc3RyZWFtU2luaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZShzdHJlYW1TaW5rLm9uQ2FuY2VsICYmIHN0cmVhbVNpbmsub25DYW5jZWwod3JhcFJlYXNvbihkYXRhLnJlYXNvbikpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLkNBTkNFTF9DT01QTEVURSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3VjY2VzczogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5DQU5DRUxfQ09NUExFVEUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYXNvbjogd3JhcFJlYXNvbihyZWFzb24pCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbVNpbmsuc2lua0NhcGFiaWxpdHkucmVqZWN0KHdyYXBSZWFzb24oZGF0YS5yZWFzb24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJlYW1TaW5rLmlzQ2FuY2VsbGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5zdHJlYW1TaW5rc1tzdHJlYW1JZF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiVW5leHBlY3RlZCBzdHJlYW0gY2FzZSIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFzeW5jIF9kZWxldGVTdHJlYW1Db250cm9sbGVyKHN0cmVhbUNvbnRyb2xsZXIsIHN0cmVhbUlkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGF3YWl0IFByb21pc2UuYWxsU2V0dGxlZChbc3RyZWFtQ29udHJvbGxlci5zdGFydENhbGwgJiYgc3RyZWFtQ29udHJvbGxlci5zdGFydENhbGwucHJvbWlzZSwgc3RyZWFtQ29udHJvbGxlci5wdWxsQ2FsbCAmJiBzdHJlYW1Db250cm9sbGVyLnB1bGxDYWxsLnByb21pc2UsIHN0cmVhbUNvbnRyb2xsZXIuY2FuY2VsQ2FsbCAmJiBzdHJlYW1Db250cm9sbGVyLmNhbmNlbENhbGwucHJvbWlzZV0pOwogICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgdGhpcy5zdHJlYW1Db250cm9sbGVyc1tzdHJlYW1JZF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRlc3Ryb3koKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tT2JqLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLCB0aGlzLl9vbkNvbU9iak9uTWVzc2FnZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5NZXNzYWdlSGFuZGxlciA9IE1lc3NhZ2VIYW5kbGVyOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNTEgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5NZXRhZGF0YSA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICBjbGFzcyBNZXRhZGF0YSB7CiAgICAgICAgICAgICAgICAgICAgI21ldGFkYXRhTWFwOwogICAgICAgICAgICAgICAgICAgICNkYXRhOwogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcnNlZERhdGEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByYXdEYXRhCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiNtZXRhZGF0YU1hcCA9IHBhcnNlZERhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuI2RhdGEgPSByYXdEYXRhOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSYXcoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLiNkYXRhOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQobmFtZSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy4jbWV0YWRhdGFNYXAuZ2V0KG5hbWUpID8/IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEFsbCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5vYmplY3RGcm9tTWFwKSh0aGlzLiNtZXRhZGF0YU1hcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGhhcyhuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLiNtZXRhZGF0YU1hcC5oYXMobmFtZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5NZXRhZGF0YSA9IE1ldGFkYXRhOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNTIgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5PcHRpb25hbENvbnRlbnRDb25maWcgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9tdXJtdXJoYXNoID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDQpOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NsYXNzUHJpdmF0ZU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yB9IGVsc2UgeyBpZiAoIWRlc2NyaXB0b3Iud3JpdGFibGUpIHsgdGhyb3cgbmV3IFR5cGVFcnJvcigiYXR0ZW1wdGVkIHRvIHNldCByZWFkIG9ubHkgcHJpdmF0ZSBmaWVsZCIpOyB9IGRlc2NyaXB0b3IudmFsdWUgPSB2YWx1ZTsgfSB9CiAgICAgICAgICAgICAgICBjb25zdCBJTlRFUk5BTCA9IFN5bWJvbCgiSU5URVJOQUwiKTsKICAgICAgICAgICAgICAgIGNsYXNzIE9wdGlvbmFsQ29udGVudEdyb3VwIHsKICAgICAgICAgICAgICAgICAgICAjdmlzaWJsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobmFtZSwgaW50ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmFtZSA9IG5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaW50ZW50ID0gaW50ZW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgdmlzaWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuI3Zpc2libGU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zZXRWaXNpYmxlKGludGVybmFsLCB2aXNpYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlcm5hbCAhPT0gSU5URVJOQUwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkludGVybmFsIG1ldGhvZCBgX3NldFZpc2libGVgIGNhbGxlZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLiN2aXNpYmxlID0gdmlzaWJsZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB2YXIgX2NhY2hlZEdldEhhc2ggPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfZ3JvdXBzID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2luaXRpYWxIYXNoID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX29yZGVyID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24gPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIE9wdGlvbmFsQ29udGVudENvbmZpZyB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfY2FjaGVkR2V0SGFzaCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2dyb3VwcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbmV3IE1hcCgpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfaW5pdGlhbEhhc2gsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9vcmRlciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5uYW1lID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jcmVhdG9yID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm5hbWUgPSBkYXRhLm5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3JlYXRvciA9IGRhdGEuY3JlYXRvcjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9vcmRlciwgZGF0YS5vcmRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZ3JvdXAgb2YgZGF0YS5ncm91cHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5zZXQoZ3JvdXAuaWQsIG5ldyBPcHRpb25hbENvbnRlbnRHcm91cChncm91cC5uYW1lLCBncm91cC5pbnRlbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5iYXNlU3RhdGUgPT09ICJPRkYiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGdyb3VwIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyb3VwLl9zZXRWaXNpYmxlKElOVEVSTkFMLCBmYWxzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvbiBvZiBkYXRhLm9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuZ2V0KG9uKS5fc2V0VmlzaWJsZShJTlRFUk5BTCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvZmYgb2YgZGF0YS5vZmYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQob2ZmKS5fc2V0VmlzaWJsZShJTlRFUk5BTCwgZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaW5pdGlhbEhhc2gsIHRoaXMuZ2V0SGFzaCgpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNWaXNpYmxlKGdyb3VwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3Vwcykuc2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFncm91cCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJPcHRpb25hbCBjb250ZW50IGdyb3VwIG5vdCBkZWZpbmVkLiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLnR5cGUgPT09ICJPQ0ciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5oYXMoZ3JvdXAuaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBPcHRpb25hbCBjb250ZW50IGdyb3VwIG5vdCBmb3VuZDogJHtncm91cC5pZH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuZ2V0KGdyb3VwLmlkKS52aXNpYmxlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGdyb3VwLnR5cGUgPT09ICJPQ01EIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGdyb3VwLmV4cHJlc3Npb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZXZhbHVhdGVWaXNpYmlsaXR5RXhwcmVzc2lvbiwgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24yKS5jYWxsKHRoaXMsIGdyb3VwLmV4cHJlc3Npb24pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFncm91cC5wb2xpY3kgfHwgZ3JvdXAucG9saWN5ID09PSAiQW55T24iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBpZCBvZiBncm91cC5pZHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuaGFzKGlkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBPcHRpb25hbCBjb250ZW50IGdyb3VwIG5vdCBmb3VuZDogJHtpZH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuZ2V0KGlkKS52aXNpYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGdyb3VwLnBvbGljeSA9PT0gIkFsbE9uIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaWQgb2YgZ3JvdXAuaWRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpLnZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZ3JvdXAucG9saWN5ID09PSAiQW55T2ZmIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaWQgb2YgZ3JvdXAuaWRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpLnZpc2libGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZ3JvdXAucG9saWN5ID09PSAiQWxsT2ZmIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaWQgb2YgZ3JvdXAuaWRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmhhcyhpZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmdldChpZCkudmlzaWJsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBVbmtub3duIG9wdGlvbmFsIGNvbnRlbnQgcG9saWN5ICR7Z3JvdXAucG9saWN5fS5gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgVW5rbm93biBncm91cCB0eXBlICR7Z3JvdXAudHlwZX0uYCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXRWaXNpYmlsaXR5KGlkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2aXNpYmxlID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5oYXMoaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYE9wdGlvbmFsIGNvbnRlbnQgZ3JvdXAgbm90IGZvdW5kOiAke2lkfWApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpLl9zZXRWaXNpYmxlKElOVEVSTkFMLCAhIXZpc2libGUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2NhY2hlZEdldEhhc2gsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaGFzSW5pdGlhbFZpc2liaWxpdHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmdldEhhc2goKSA9PT0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pbml0aWFsSGFzaCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE9yZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5zaXplKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9vcmRlcikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX29yZGVyKS5zbGljZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbLi4uX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpLmtleXMoKV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEdyb3VwcygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5zaXplID4gMCA/ICgwLCBfdXRpbC5vYmplY3RGcm9tTWFwKShfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykpIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0R3JvdXAoaWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoaWQpIHx8IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEhhc2goKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NhY2hlZEdldEhhc2gpICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jYWNoZWRHZXRIYXNoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoYXNoID0gbmV3IF9tdXJtdXJoYXNoLk11cm11ckhhc2gzXzY0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2lkLCBncm91cF0gb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ncm91cHMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNoLnVwZGF0ZShgJHtpZH06JHtncm91cC52aXNpYmxlfWApOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2NhY2hlZEdldEhhc2gsIGhhc2guaGV4ZGlnZXN0KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuT3B0aW9uYWxDb250ZW50Q29uZmlnID0gT3B0aW9uYWxDb250ZW50Q29uZmlnOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24yKGFycmF5KSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuZ3RoID0gYXJyYXkubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGlmIChsZW5ndGggPCAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBvcGVyYXRvciA9IGFycmF5WzBdOwogICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAxOyBpIDwgbGVuZ3RoOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudCA9IGFycmF5W2ldOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgc3RhdGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGVsZW1lbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZSA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2V2YWx1YXRlVmlzaWJpbGl0eUV4cHJlc3Npb24sIF9ldmFsdWF0ZVZpc2liaWxpdHlFeHByZXNzaW9uMikuY2FsbCh0aGlzLCBlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2dyb3VwcykuaGFzKGVsZW1lbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGF0ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZ3JvdXBzKS5nZXQoZWxlbWVudCkudmlzaWJsZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgT3B0aW9uYWwgY29udGVudCBncm91cCBub3QgZm91bmQ6ICR7ZWxlbWVudH1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAob3BlcmF0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkFuZCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFzdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiT3IiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJOb3QiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhc3RhdGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBvcGVyYXRvciA9PT0gIkFuZCI7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE1MyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkRhdGFUcmFuc3BvcnRTdHJlYW0gPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwbGF5X3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDIpOwogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0YVRyYW5zcG9ydFN0cmVhbSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IoX3JlZiwgcGRmRGF0YVJhbmdlVHJhbnNwb3J0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbml0aWFsRGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByb2dyZXNzaXZlRG9uZSA9IGZhbHNlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudERpc3Bvc2l0aW9uRmlsZW5hbWUgPSBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZVJhbmdlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlU3RyZWFtID0gZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWY7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHBkZkRhdGFSYW5nZVRyYW5zcG9ydCwgJ1BERkRhdGFUcmFuc3BvcnRTdHJlYW0gLSBtaXNzaW5nIHJlcXVpcmVkICJwZGZEYXRhUmFuZ2VUcmFuc3BvcnQiIGFyZ3VtZW50LicpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9xdWV1ZWRDaHVua3MgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcHJvZ3Jlc3NpdmVEb25lID0gcHJvZ3Jlc3NpdmVEb25lOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZW50RGlzcG9zaXRpb25GaWxlbmFtZSA9IGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoKGluaXRpYWxEYXRhID09PSBudWxsIHx8IGluaXRpYWxEYXRhID09PSB2b2lkIDAgPyB2b2lkIDAgOiBpbml0aWFsRGF0YS5sZW5ndGgpID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnVmZmVyID0gaW5pdGlhbERhdGEgaW5zdGFuY2VvZiBVaW50OEFycmF5ICYmIGluaXRpYWxEYXRhLmJ5dGVMZW5ndGggPT09IGluaXRpYWxEYXRhLmJ1ZmZlci5ieXRlTGVuZ3RoID8gaW5pdGlhbERhdGEuYnVmZmVyIDogbmV3IFVpbnQ4QXJyYXkoaW5pdGlhbERhdGEpLmJ1ZmZlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rcy5wdXNoKGJ1ZmZlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0ID0gcGRmRGF0YVJhbmdlVHJhbnNwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZCA9ICFkaXNhYmxlU3RyZWFtOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1JhbmdlU3VwcG9ydGVkID0gIWRpc2FibGVSYW5nZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGVudExlbmd0aCA9IGxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZVJlYWRlcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0LmFkZFJhbmdlTGlzdGVuZXIoKGJlZ2luLCBjaHVuaykgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb25SZWNlaXZlRGF0YSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmVnaW4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0LmFkZFByb2dyZXNzTGlzdGVuZXIoKGxvYWRlZCwgdG90YWwpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX29uUHJvZ3Jlc3MoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRlZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0b3RhbAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQuYWRkUHJvZ3Jlc3NpdmVSZWFkTGlzdGVuZXIoY2h1bmsgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fb25SZWNlaXZlRGF0YSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGRmRGF0YVJhbmdlVHJhbnNwb3J0LmFkZFByb2dyZXNzaXZlRG9uZUxpc3RlbmVyKCgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX29uUHJvZ3Jlc3NpdmVEb25lKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQudHJhbnNwb3J0UmVhZHkoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX29uUmVjZWl2ZURhdGEoX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlZ2luLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2h1bmsKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IF9yZWYyOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBjaHVuayBpbnN0YW5jZW9mIFVpbnQ4QXJyYXkgJiYgY2h1bmsuYnl0ZUxlbmd0aCA9PT0gY2h1bmsuYnVmZmVyLmJ5dGVMZW5ndGggPyBjaHVuay5idWZmZXIgOiBuZXcgVWludDhBcnJheShjaHVuaykuYnVmZmVyOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmVnaW4gPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIuX2VucXVldWUoYnVmZmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmtzLnB1c2goYnVmZmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvdW5kID0gdGhpcy5fcmFuZ2VSZWFkZXJzLnNvbWUoZnVuY3Rpb24gKHJhbmdlUmVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJhbmdlUmVhZGVyLl9iZWdpbiAhPT0gYmVnaW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYW5nZVJlYWRlci5fZW5xdWV1ZShidWZmZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KShmb3VuZCwgIl9vblJlY2VpdmVEYXRhIC0gbm8gYFBERkRhdGFUcmFuc3BvcnRTdHJlYW1SYW5nZVJlYWRlcmAgaW5zdGFuY2UgZm91bmQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IF9wcm9ncmVzc2l2ZURhdGFMZW5ndGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWE7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoKF90aGlzJF9mdWxsUmVxdWVzdFJlYSA9IHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSA9PT0gbnVsbCB8fCBfdGhpcyRfZnVsbFJlcXVlc3RSZWEgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYS5fbG9hZGVkKSA/PyAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25Qcm9ncmVzcyhldnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2dC50b3RhbCA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3JhbmdlUmVhZGVycyQsIF90aGlzJF9yYW5nZVJlYWRlcnMkJDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfcmFuZ2VSZWFkZXJzJCA9IHRoaXMuX3JhbmdlUmVhZGVyc1swXSkgPT09IG51bGwgfHwgX3RoaXMkX3JhbmdlUmVhZGVycyQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IChfdGhpcyRfcmFuZ2VSZWFkZXJzJCQgPSBfdGhpcyRfcmFuZ2VSZWFkZXJzJC5vblByb2dyZXNzKSA9PT0gbnVsbCB8fCBfdGhpcyRfcmFuZ2VSZWFkZXJzJCQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9yYW5nZVJlYWRlcnMkJC5jYWxsKF90aGlzJF9yYW5nZVJlYWRlcnMkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBldnQubG9hZGVkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLCBfdGhpcyRfZnVsbFJlcXVlc3RSZWEzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9mdWxsUmVxdWVzdFJlYTIgPSB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogKF90aGlzJF9mdWxsUmVxdWVzdFJlYTMgPSBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVxdWVzdFJlYTMgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYTMuY2FsbChfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBldnQubG9hZGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsOiBldnQudG90YWwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9vblByb2dyZXNzaXZlRG9uZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9mdWxsUmVxdWVzdFJlYTQ7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfZnVsbFJlcXVlc3RSZWE0ID0gdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVxdWVzdFJlYTQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYTQucHJvZ3Jlc3NpdmVEb25lKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Byb2dyZXNzaXZlRG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9yZW1vdmVSYW5nZVJlYWRlcihyZWFkZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaSA9IHRoaXMuX3JhbmdlUmVhZGVycy5pbmRleE9mKHJlYWRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpID49IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlUmVhZGVycy5zcGxpY2UoaSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RnVsbFJlYWRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmFzc2VydCkoIXRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyLCAiUERGRGF0YVRyYW5zcG9ydFN0cmVhbS5nZXRGdWxsUmVhZGVyIGNhbiBvbmx5IGJlIGNhbGxlZCBvbmNlLiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBxdWV1ZWRDaHVua3MgPSB0aGlzLl9xdWV1ZWRDaHVua3M7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJlYWRlcih0aGlzLCBxdWV1ZWRDaHVua3MsIHRoaXMuX3Byb2dyZXNzaXZlRG9uZSwgdGhpcy5fY29udGVudERpc3Bvc2l0aW9uRmlsZW5hbWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSYW5nZVJlYWRlcihiZWdpbiwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbmQgPD0gdGhpcy5fcHJvZ3Jlc3NpdmVEYXRhTGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWFkZXIgPSBuZXcgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJhbmdlUmVhZGVyKHRoaXMsIGJlZ2luLCBlbmQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQucmVxdWVzdERhdGFSYW5nZShiZWdpbiwgZW5kKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VSZWFkZXJzLnB1c2gocmVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlYWRlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsQWxsUmVxdWVzdHMocmVhc29uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWE1OwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhNSA9IHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSA9PT0gbnVsbCB8fCBfdGhpcyRfZnVsbFJlcXVlc3RSZWE1ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlcXVlc3RSZWE1LmNhbmNlbChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlYWRlciBvZiB0aGlzLl9yYW5nZVJlYWRlcnMuc2xpY2UoMCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRlci5jYW5jZWwocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9wZGZEYXRhUmFuZ2VUcmFuc3BvcnQuYWJvcnQoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkRhdGFUcmFuc3BvcnRTdHJlYW0gPSBQREZEYXRhVHJhbnNwb3J0U3RyZWFtOwogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJlYWRlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc3RyZWFtLCBxdWV1ZWRDaHVua3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHByb2dyZXNzaXZlRG9uZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAyICYmIGFyZ3VtZW50c1syXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzJdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjb250ZW50RGlzcG9zaXRpb25GaWxlbmFtZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAzICYmIGFyZ3VtZW50c1szXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzNdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RyZWFtID0gc3RyZWFtOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gcHJvZ3Jlc3NpdmVEb25lIHx8IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9maWxlbmFtZSA9ICgwLCBfZGlzcGxheV91dGlscy5pc1BkZkZpbGUpKGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lKSA/IGNvbnRlbnREaXNwb3NpdGlvbkZpbGVuYW1lIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmtzID0gcXVldWVkQ2h1bmtzIHx8IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZWQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGNodW5rIG9mIHRoaXMuX3F1ZXVlZENodW5rcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVkICs9IGNodW5rLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc1JlYWR5ID0gUHJvbWlzZS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0cmVhbS5fZnVsbFJlcXVlc3RSZWFkZXIgPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZW5xdWV1ZShjaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSA9IHRoaXMuX3JlcXVlc3RzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0Q2FwYWJpbGl0eS5yZXNvbHZlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogY2h1bmssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmtzLnB1c2goY2h1bmspOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlZCArPSBjaHVuay5ieXRlTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaGVhZGVyc1JlYWR5KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5faGVhZGVyc1JlYWR5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgZmlsZW5hbWUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9maWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGlzUmFuZ2VTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9zdHJlYW0uX2lzUmFuZ2VTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3N0cmVhbS5faXNTdHJlYW1pbmdTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBjb250ZW50TGVuZ3RoKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fc3RyZWFtLl9jb250ZW50TGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcXVldWVkQ2h1bmtzLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gdGhpcy5fcXVldWVkQ2h1bmtzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLnB1c2gocmVxdWVzdENhcGFiaWxpdHkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwcm9ncmVzc2l2ZURvbmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9kb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUERGRGF0YVRyYW5zcG9ydFN0cmVhbVJhbmdlUmVhZGVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzdHJlYW0sIGJlZ2luLCBlbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RyZWFtID0gc3RyZWFtOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9iZWdpbiA9IGJlZ2luOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbmQgPSBlbmQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZW5xdWV1ZShjaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rID0gY2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0c0NhcGFiaWxpdHkgPSB0aGlzLl9yZXF1ZXN0cy5zaGlmdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdHNDYXBhYmlsaXR5LnJlc29sdmUoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlcXVlc3RDYXBhYmlsaXR5IG9mIHRoaXMuX3JlcXVlc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB1bmRlZmluZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3N0cmVhbS5fcmVtb3ZlUmFuZ2VSZWFkZXIodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcXVldWVkQ2h1bmspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gdGhpcy5fcXVldWVkQ2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9xdWV1ZWRDaHVuayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLnB1c2gocmVxdWVzdENhcGFiaWxpdHkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdHJlYW0uX3JlbW92ZVJhbmdlUmVhZGVyKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTU0ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMpID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuWGZhVGV4dCA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIGNsYXNzIFhmYVRleHQgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB0ZXh0Q29udGVudCh4ZmEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXRlbXMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3V0cHV0ID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZXM6IE9iamVjdC5jcmVhdGUobnVsbCkKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gd2Fsayhub2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX25vZGUkYXR0cmlidXRlczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghbm9kZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdHIgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbmFtZSA9IG5vZGUubmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuYW1lID09PSAiI3RleHQiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyID0gbm9kZS52YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIVhmYVRleHQuc2hvdWxkQnVpbGRUZXh0KG5hbWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChub2RlICE9PSBudWxsICYmIG5vZGUgIT09IHZvaWQgMCAmJiAoX25vZGUkYXR0cmlidXRlcyA9IG5vZGUuYXR0cmlidXRlcykgIT09IG51bGwgJiYgX25vZGUkYXR0cmlidXRlcyAhPT0gdm9pZCAwICYmIF9ub2RlJGF0dHJpYnV0ZXMudGV4dENvbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIgPSBub2RlLmF0dHJpYnV0ZXMudGV4dENvbnRlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKG5vZGUudmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIgPSBub2RlLnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0ciAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zLnB1c2goewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghbm9kZS5jaGlsZHJlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgY2hpbGQgb2Ygbm9kZS5jaGlsZHJlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdhbGsoY2hpbGQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHdhbGsoeGZhKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG91dHB1dDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHNob3VsZEJ1aWxkVGV4dChuYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAhKG5hbWUgPT09ICJ0ZXh0YXJlYSIgfHwgbmFtZSA9PT0gImlucHV0IiB8fCBuYW1lID09PSAib3B0aW9uIiB8fCBuYW1lID09PSAic2VsZWN0Iik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5YZmFUZXh0ID0gWGZhVGV4dDsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTU1ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuTm9kZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gZXhwb3J0cy5Ob2RlRmlsdGVyRmFjdG9yeSA9IGV4cG9ydHMuTm9kZUNhbnZhc0ZhY3RvcnkgPSBleHBvcnRzLk5vZGVDTWFwUmVhZGVyRmFjdG9yeSA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfYmFzZV9mYWN0b3J5ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDMpOwogICAgICAgICAgICAgICAgOwogICAgICAgICAgICAgICAgY29uc3QgZmV0Y2hEYXRhID0gZnVuY3Rpb24gKHVybCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZzID0gcmVxdWlyZSgiZnMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgZnMucmVhZEZpbGUodXJsLCAoZXJyb3IsIGRhdGEpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlcnJvciB8fCAhZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlamVjdChuZXcgRXJyb3IoZXJyb3IpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKG5ldyBVaW50OEFycmF5KGRhdGEpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgY2xhc3MgTm9kZUZpbHRlckZhY3RvcnkgZXh0ZW5kcyBfYmFzZV9mYWN0b3J5LkJhc2VGaWx0ZXJGYWN0b3J5IHt9CiAgICAgICAgICAgICAgICBleHBvcnRzLk5vZGVGaWx0ZXJGYWN0b3J5ID0gTm9kZUZpbHRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBOb2RlQ2FudmFzRmFjdG9yeSBleHRlbmRzIF9iYXNlX2ZhY3RvcnkuQmFzZUNhbnZhc0ZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIF9jcmVhdGVDYW52YXMod2lkdGgsIGhlaWdodCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDYW52YXMgPSByZXF1aXJlKCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIENhbnZhcy5jcmVhdGVDYW52YXMod2lkdGgsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Ob2RlQ2FudmFzRmFjdG9yeSA9IE5vZGVDYW52YXNGYWN0b3J5OwogICAgICAgICAgICAgICAgY2xhc3MgTm9kZUNNYXBSZWFkZXJGYWN0b3J5IGV4dGVuZHMgX2Jhc2VfZmFjdG9yeS5CYXNlQ01hcFJlYWRlckZhY3RvcnkgewogICAgICAgICAgICAgICAgICAgIF9mZXRjaERhdGEodXJsLCBjb21wcmVzc2lvblR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZldGNoRGF0YSh1cmwpLnRoZW4oZGF0YSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNNYXBEYXRhOiBkYXRhLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbXByZXNzaW9uVHlwZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Ob2RlQ01hcFJlYWRlckZhY3RvcnkgPSBOb2RlQ01hcFJlYWRlckZhY3Rvcnk7CiAgICAgICAgICAgICAgICBjbGFzcyBOb2RlU3RhbmRhcmRGb250RGF0YUZhY3RvcnkgZXh0ZW5kcyBfYmFzZV9mYWN0b3J5LkJhc2VTdGFuZGFyZEZvbnREYXRhRmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgX2ZldGNoRGF0YSh1cmwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZldGNoRGF0YSh1cmwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuTm9kZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5ID0gTm9kZVN0YW5kYXJkRm9udERhdGFGYWN0b3J5OwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNTYgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZOb2RlU3RyZWFtID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfbmV0d29ya191dGlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTU3KTsKICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGNvbnN0IGZzID0gcmVxdWlyZSgiZnMiKTsKICAgICAgICAgICAgICAgIGNvbnN0IGh0dHAgPSByZXF1aXJlKCJodHRwIik7CiAgICAgICAgICAgICAgICBjb25zdCBodHRwcyA9IHJlcXVpcmUoImh0dHBzIik7CiAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSByZXF1aXJlKCJ1cmwiKTsKICAgICAgICAgICAgICAgIGNvbnN0IGZpbGVVcmlSZWdleCA9IC9eZmlsZTpcL1wvXC9bYS16QS1aXTpcLy87CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBwYXJzZVVybChzb3VyY2VVcmwpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJzZWRVcmwgPSB1cmwucGFyc2Uoc291cmNlVXJsKTsKICAgICAgICAgICAgICAgICAgICBpZiAocGFyc2VkVXJsLnByb3RvY29sID09PSAiZmlsZToiIHx8IHBhcnNlZFVybC5ob3N0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZWRVcmw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICgvXlthLXpdOlsvXFxdL2kudGVzdChzb3VyY2VVcmwpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1cmwucGFyc2UoYGZpbGU6Ly8vJHtzb3VyY2VVcmx9YCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghcGFyc2VkVXJsLmhvc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcGFyc2VkVXJsLnByb3RvY29sID0gImZpbGU6IjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlZFVybDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBERk5vZGVTdHJlYW0gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNvdXJjZSA9IHNvdXJjZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51cmwgPSBwYXJzZVVybChzb3VyY2UudXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc0h0dHAgPSB0aGlzLnVybC5wcm90b2NvbCA9PT0gImh0dHA6IiB8fCB0aGlzLnVybC5wcm90b2NvbCA9PT0gImh0dHBzOiI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNGc1VybCA9IHRoaXMudXJsLnByb3RvY29sID09PSAiZmlsZToiOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmh0dHBIZWFkZXJzID0gdGhpcy5pc0h0dHAgJiYgc291cmNlLmh0dHBIZWFkZXJzIHx8IHt9OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlUmVxdWVzdFJlYWRlcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IF9wcm9ncmVzc2l2ZURhdGFMZW5ndGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWE7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoKF90aGlzJF9mdWxsUmVxdWVzdFJlYSA9IHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSA9PT0gbnVsbCB8fCBfdGhpcyRfZnVsbFJlcXVlc3RSZWEgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9mdWxsUmVxdWVzdFJlYS5fbG9hZGVkKSA/PyAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRGdWxsUmVhZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KSghdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIsICJQREZOb2RlU3RyZWFtLmdldEZ1bGxSZWFkZXIgY2FuIG9ubHkgYmUgY2FsbGVkIG9uY2UuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyID0gdGhpcy5pc0ZzVXJsID8gbmV3IFBERk5vZGVTdHJlYW1Gc0Z1bGxSZWFkZXIodGhpcykgOiBuZXcgUERGTm9kZVN0cmVhbUZ1bGxSZWFkZXIodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0UmFuZ2VSZWFkZXIoc3RhcnQsIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW5kIDw9IHRoaXMuX3Byb2dyZXNzaXZlRGF0YUxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFuZ2VSZWFkZXIgPSB0aGlzLmlzRnNVcmwgPyBuZXcgUERGTm9kZVN0cmVhbUZzUmFuZ2VSZWFkZXIodGhpcywgc3RhcnQsIGVuZCkgOiBuZXcgUERGTm9kZVN0cmVhbVJhbmdlUmVhZGVyKHRoaXMsIHN0YXJ0LCBlbmQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLnB1c2gocmFuZ2VSZWFkZXIpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmFuZ2VSZWFkZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbmNlbEFsbFJlcXVlc3RzKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMjsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9mdWxsUmVxdWVzdFJlYTIgPSB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMi5jYW5jZWwocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZWFkZXIgb2YgdGhpcy5fcmFuZ2VSZXF1ZXN0UmVhZGVycy5zbGljZSgwKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhZGVyLmNhbmNlbChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5QREZOb2RlU3RyZWFtID0gUERGTm9kZVN0cmVhbTsKICAgICAgICAgICAgICAgIGNsYXNzIEJhc2VGdWxsUmVhZGVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdXJsID0gc3RyZWFtLnVybDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25Qcm9ncmVzcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNvdXJjZSA9IHN0cmVhbS5zb3VyY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRlbnRMZW5ndGggPSBzb3VyY2UubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZWQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9maWxlbmFtZSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHNvdXJjZS5kaXNhYmxlUmFuZ2UgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlQ2h1bmtTaXplID0gc291cmNlLnJhbmdlQ2h1bmtTaXplOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3JhbmdlQ2h1bmtTaXplICYmICF0aGlzLl9kaXNhYmxlUmFuZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNTdHJlYW1pbmdTdXBwb3J0ZWQgPSAhc291cmNlLmRpc2FibGVTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQgPSAhc291cmNlLmRpc2FibGVSYW5nZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGFibGVTdHJlYW0gPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkQ2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc0NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBoZWFkZXJzUmVhZHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9oZWFkZXJzQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgZmlsZW5hbWUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9maWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGNvbnRlbnRMZW5ndGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9jb250ZW50TGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNSYW5nZVN1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2lzU3RyZWFtaW5nU3VwcG9ydGVkOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkb25Qcm9ncmVzczsKICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgdGhpcy5fcmVhZENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2RvbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9zdG9yZWRFcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgdGhpcy5fc3RvcmVkRXJyb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2h1bmsgPSB0aGlzLl9yZWFkYWJsZVN0cmVhbS5yZWFkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaHVuayA9PT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5yZWFkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVkICs9IGNodW5rLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJG9uUHJvZ3Jlc3MgPSB0aGlzLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF90aGlzJG9uUHJvZ3Jlc3MgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJG9uUHJvZ3Jlc3MuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2FkZWQ6IHRoaXMuX2xvYWRlZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRvdGFsOiB0aGlzLl9jb250ZW50TGVuZ3RoCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBuZXcgVWludDhBcnJheShjaHVuaykuYnVmZmVyOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGJ1ZmZlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbmNlbChyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9yZWFkYWJsZVN0cmVhbSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZXJyb3IocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkYWJsZVN0cmVhbS5kZXN0cm95KHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9lcnJvcihyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSByZWFzb247CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldFJlYWRhYmxlU3RyZWFtKHJlYWRhYmxlU3RyZWFtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRhYmxlU3RyZWFtID0gcmVhZGFibGVTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJyZWFkYWJsZSIsICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJlbmQiLCAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkYWJsZVN0cmVhbS5kZXN0cm95KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJlcnJvciIsIHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lcnJvcihyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZCAmJiB0aGlzLl9pc1JhbmdlU3VwcG9ydGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lcnJvcihuZXcgX3V0aWwuQWJvcnRFeGNlcHRpb24oInN0cmVhbWluZyBpcyBkaXNhYmxlZCIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fc3RvcmVkRXJyb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRhYmxlU3RyZWFtLmRlc3Ryb3kodGhpcy5fc3RvcmVkRXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgQmFzZVJhbmdlUmVhZGVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdXJsID0gc3RyZWFtLnVybDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25Qcm9ncmVzcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlZCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRhYmxlU3RyZWFtID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNvdXJjZSA9IHN0cmVhbS5zb3VyY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2lzU3RyZWFtaW5nU3VwcG9ydGVkID0gIXNvdXJjZS5kaXNhYmxlU3RyZWFtOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNTdHJlYW1pbmdTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgcmVhZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJG9uUHJvZ3Jlc3MyOwogICAgICAgICAgICAgICAgICAgICAgICBhd2FpdCB0aGlzLl9yZWFkQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3JlZEVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyB0aGlzLl9zdG9yZWRFcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVuayA9IHRoaXMuX3JlYWRhYmxlU3RyZWFtLnJlYWQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNodW5rID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkQ2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJlYWQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sb2FkZWQgKz0gY2h1bmsubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkb25Qcm9ncmVzczIgPSB0aGlzLm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF90aGlzJG9uUHJvZ3Jlc3MyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRvblByb2dyZXNzMi5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRlZDogdGhpcy5fbG9hZGVkCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBuZXcgVWludDhBcnJheShjaHVuaykuYnVmZmVyOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGJ1ZmZlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbmNlbChyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLl9yZWFkYWJsZVN0cmVhbSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZXJyb3IocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkYWJsZVN0cmVhbS5kZXN0cm95KHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9lcnJvcihyZWFzb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSByZWFzb247CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldFJlYWRhYmxlU3RyZWFtKHJlYWRhYmxlU3RyZWFtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRhYmxlU3RyZWFtID0gcmVhZGFibGVTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJyZWFkYWJsZSIsICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJlbmQiLCAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkYWJsZVN0cmVhbS5kZXN0cm95KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRhYmxlU3RyZWFtLm9uKCJlcnJvciIsIHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lcnJvcihyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3JlZEVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkYWJsZVN0cmVhbS5kZXN0cm95KHRoaXMuX3N0b3JlZEVycm9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNyZWF0ZVJlcXVlc3RPcHRpb25zKHBhcnNlZFVybCwgaGVhZGVycykgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHByb3RvY29sOiBwYXJzZWRVcmwucHJvdG9jb2wsCiAgICAgICAgICAgICAgICAgICAgICAgIGF1dGg6IHBhcnNlZFVybC5hdXRoLAogICAgICAgICAgICAgICAgICAgICAgICBob3N0OiBwYXJzZWRVcmwuaG9zdG5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHBvcnQ6IHBhcnNlZFVybC5wb3J0LAogICAgICAgICAgICAgICAgICAgICAgICBwYXRoOiBwYXJzZWRVcmwucGF0aCwKICAgICAgICAgICAgICAgICAgICAgICAgbWV0aG9kOiAiR0VUIiwKICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVycwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQREZOb2RlU3RyZWFtRnVsbFJlYWRlciBleHRlbmRzIEJhc2VGdWxsUmVhZGVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihzdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIoc3RyZWFtKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGFuZGxlUmVzcG9uc2UgPSByZXNwb25zZSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmVzcG9uc2Uuc3RhdHVzQ29kZSA9PT0gNDA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZXJyb3IgPSBuZXcgX3V0aWwuTWlzc2luZ1BERkV4Y2VwdGlvbihgTWlzc2luZyBQREYgIiR7dGhpcy5fdXJsfSIuYCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSBlcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9oZWFkZXJzQ2FwYWJpbGl0eS5yZWplY3QoZXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hlYWRlcnNDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldFJlYWRhYmxlU3RyZWFtKHJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdldFJlc3BvbnNlSGVhZGVyID0gbmFtZSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3JlYWRhYmxlU3RyZWFtLmhlYWRlcnNbbmFtZS50b0xvd2VyQ2FzZSgpXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxsb3dSYW5nZVJlcXVlc3RzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1Z2dlc3RlZExlbmd0aAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9ICgwLCBfbmV0d29ya191dGlscy52YWxpZGF0ZVJhbmdlUmVxdWVzdENhcGFiaWxpdGllcykoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldFJlc3BvbnNlSGVhZGVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzSHR0cDogc3RyZWFtLmlzSHR0cCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYW5nZUNodW5rU2l6ZTogdGhpcy5fcmFuZ2VDaHVua1NpemUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzYWJsZVJhbmdlOiB0aGlzLl9kaXNhYmxlUmFuZ2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNSYW5nZVN1cHBvcnRlZCA9IGFsbG93UmFuZ2VSZXF1ZXN0czsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRlbnRMZW5ndGggPSBzdWdnZXN0ZWRMZW5ndGggfHwgdGhpcy5fY29udGVudExlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZpbGVuYW1lID0gKDAsIF9uZXR3b3JrX3V0aWxzLmV4dHJhY3RGaWxlbmFtZUZyb21IZWFkZXIpKGdldFJlc3BvbnNlSGVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl91cmwucHJvdG9jb2wgPT09ICJodHRwOiIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3QgPSBodHRwLnJlcXVlc3QoY3JlYXRlUmVxdWVzdE9wdGlvbnModGhpcy5fdXJsLCBzdHJlYW0uaHR0cEhlYWRlcnMpLCBoYW5kbGVSZXNwb25zZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0ID0gaHR0cHMucmVxdWVzdChjcmVhdGVSZXF1ZXN0T3B0aW9ucyh0aGlzLl91cmwsIHN0cmVhbS5odHRwSGVhZGVycyksIGhhbmRsZVJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0Lm9uKCJlcnJvciIsIHJlYXNvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IHJlYXNvbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hlYWRlcnNDYXBhYmlsaXR5LnJlamVjdChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdC5lbmQoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQREZOb2RlU3RyZWFtUmFuZ2VSZWFkZXIgZXh0ZW5kcyBCYXNlUmFuZ2VSZWFkZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHN0cmVhbSwgc3RhcnQsIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihzdHJlYW0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9odHRwSGVhZGVycyA9IHt9OwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHByb3BlcnR5IGluIHN0cmVhbS5odHRwSGVhZGVycykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmFsdWUgPSBzdHJlYW0uaHR0cEhlYWRlcnNbcHJvcGVydHldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2h0dHBIZWFkZXJzW3Byb3BlcnR5XSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2h0dHBIZWFkZXJzLlJhbmdlID0gYGJ5dGVzPSR7c3RhcnR9LSR7ZW5kIC0gMX1gOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoYW5kbGVSZXNwb25zZSA9IHJlc3BvbnNlID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXNwb25zZS5zdGF0dXNDb2RlID09PSA0MDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlcnJvciA9IG5ldyBfdXRpbC5NaXNzaW5nUERGRXhjZXB0aW9uKGBNaXNzaW5nIFBERiAiJHt0aGlzLl91cmx9Ii5gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IGVycm9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldFJlYWRhYmxlU3RyZWFtKHJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl91cmwucHJvdG9jb2wgPT09ICJodHRwOiIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3QgPSBodHRwLnJlcXVlc3QoY3JlYXRlUmVxdWVzdE9wdGlvbnModGhpcy5fdXJsLCB0aGlzLl9odHRwSGVhZGVycyksIGhhbmRsZVJlc3BvbnNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3QgPSBodHRwcy5yZXF1ZXN0KGNyZWF0ZVJlcXVlc3RPcHRpb25zKHRoaXMuX3VybCwgdGhpcy5faHR0cEhlYWRlcnMpLCBoYW5kbGVSZXNwb25zZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdC5vbigiZXJyb3IiLCByZWFzb24gPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSByZWFzb247CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0LmVuZCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBERk5vZGVTdHJlYW1Gc0Z1bGxSZWFkZXIgZXh0ZW5kcyBCYXNlRnVsbFJlYWRlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc3RyZWFtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHN0cmVhbSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwYXRoID0gZGVjb2RlVVJJQ29tcG9uZW50KHRoaXMuX3VybC5wYXRoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGVVcmlSZWdleC50ZXN0KHRoaXMuX3VybC5ocmVmKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0aCA9IHBhdGgucmVwbGFjZSgvXlwvLywgIiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZzLmxzdGF0KHBhdGgsIChlcnJvciwgc3RhdCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVycm9yLmNvZGUgPT09ICJFTk9FTlQiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVycm9yID0gbmV3IF91dGlsLk1pc3NpbmdQREZFeGNlcHRpb24oYE1pc3NpbmcgUERGICIke3BhdGh9Ii5gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSBlcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9oZWFkZXJzQ2FwYWJpbGl0eS5yZWplY3QoZXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRlbnRMZW5ndGggPSBzdGF0LnNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRSZWFkYWJsZVN0cmVhbShmcy5jcmVhdGVSZWFkU3RyZWFtKHBhdGgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hlYWRlcnNDYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUERGTm9kZVN0cmVhbUZzUmFuZ2VSZWFkZXIgZXh0ZW5kcyBCYXNlUmFuZ2VSZWFkZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHN0cmVhbSwgc3RhcnQsIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihzdHJlYW0pOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGF0aCA9IGRlY29kZVVSSUNvbXBvbmVudCh0aGlzLl91cmwucGF0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmaWxlVXJpUmVnZXgudGVzdCh0aGlzLl91cmwuaHJlZikpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGggPSBwYXRoLnJlcGxhY2UoL15cLy8sICIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRSZWFkYWJsZVN0cmVhbShmcy5jcmVhdGVSZWFkU3RyZWFtKHBhdGgsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0YXJ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5kOiBlbmQgLSAxCiAgICAgICAgICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE1NyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLmNyZWF0ZVJlc3BvbnNlU3RhdHVzRXJyb3IgPSBjcmVhdGVSZXNwb25zZVN0YXR1c0Vycm9yOwogICAgICAgICAgICAgICAgZXhwb3J0cy5leHRyYWN0RmlsZW5hbWVGcm9tSGVhZGVyID0gZXh0cmFjdEZpbGVuYW1lRnJvbUhlYWRlcjsKICAgICAgICAgICAgICAgIGV4cG9ydHMudmFsaWRhdGVSYW5nZVJlcXVlc3RDYXBhYmlsaXRpZXMgPSB2YWxpZGF0ZVJhbmdlUmVxdWVzdENhcGFiaWxpdGllczsKICAgICAgICAgICAgICAgIGV4cG9ydHMudmFsaWRhdGVSZXNwb25zZVN0YXR1cyA9IHZhbGlkYXRlUmVzcG9uc2VTdGF0dXM7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9jb250ZW50X2Rpc3Bvc2l0aW9uID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNwbGF5X3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDIpOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gdmFsaWRhdGVSYW5nZVJlcXVlc3RDYXBhYmlsaXRpZXMoX3JlZikgewogICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgIGdldFJlc3BvbnNlSGVhZGVyLAogICAgICAgICAgICAgICAgICAgICAgICBpc0h0dHAsCiAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlQ2h1bmtTaXplLAogICAgICAgICAgICAgICAgICAgICAgICBkaXNhYmxlUmFuZ2UKICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICBjb25zdCByZXR1cm5WYWx1ZXMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGFsbG93UmFuZ2VSZXF1ZXN0czogZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgIHN1Z2dlc3RlZExlbmd0aDogdW5kZWZpbmVkCiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBsZW5ndGggPSBwYXJzZUludChnZXRSZXNwb25zZUhlYWRlcigiQ29udGVudC1MZW5ndGgiKSwgMTApOwogICAgICAgICAgICAgICAgICAgIGlmICghTnVtYmVyLmlzSW50ZWdlcihsZW5ndGgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVyblZhbHVlcy5zdWdnZXN0ZWRMZW5ndGggPSBsZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgaWYgKGxlbmd0aCA8PSAyICogcmFuZ2VDaHVua1NpemUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJldHVyblZhbHVlczsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKGRpc2FibGVSYW5nZSB8fCAhaXNIdHRwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChnZXRSZXNwb25zZUhlYWRlcigiQWNjZXB0LVJhbmdlcyIpICE9PSAiYnl0ZXMiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRlbnRFbmNvZGluZyA9IGdldFJlc3BvbnNlSGVhZGVyKCJDb250ZW50LUVuY29kaW5nIikgfHwgImlkZW50aXR5IjsKICAgICAgICAgICAgICAgICAgICBpZiAoY29udGVudEVuY29kaW5nICE9PSAiaWRlbnRpdHkiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZXM7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVyblZhbHVlcy5hbGxvd1JhbmdlUmVxdWVzdHMgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIHJldHVybiByZXR1cm5WYWx1ZXM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBleHRyYWN0RmlsZW5hbWVGcm9tSGVhZGVyKGdldFJlc3BvbnNlSGVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgY29udGVudERpc3Bvc2l0aW9uID0gZ2V0UmVzcG9uc2VIZWFkZXIoIkNvbnRlbnQtRGlzcG9zaXRpb24iKTsKICAgICAgICAgICAgICAgICAgICBpZiAoY29udGVudERpc3Bvc2l0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmaWxlbmFtZSA9ICgwLCBfY29udGVudF9kaXNwb3NpdGlvbi5nZXRGaWxlbmFtZUZyb21Db250ZW50RGlzcG9zaXRpb25IZWFkZXIpKGNvbnRlbnREaXNwb3NpdGlvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmaWxlbmFtZS5pbmNsdWRlcygiJSIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVuYW1lID0gZGVjb2RlVVJJQ29tcG9uZW50KGZpbGVuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7fQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoMCwgX2Rpc3BsYXlfdXRpbHMuaXNQZGZGaWxlKShmaWxlbmFtZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmaWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNyZWF0ZVJlc3BvbnNlU3RhdHVzRXJyb3Ioc3RhdHVzLCB1cmwpIHsKICAgICAgICAgICAgICAgICAgICBpZiAoc3RhdHVzID09PSA0MDQgfHwgc3RhdHVzID09PSAwICYmIHVybC5zdGFydHNXaXRoKCJmaWxlOiIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgX3V0aWwuTWlzc2luZ1BERkV4Y2VwdGlvbignTWlzc2luZyBQREYgIicgKyB1cmwgKyAnIi4nKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBfdXRpbC5VbmV4cGVjdGVkUmVzcG9uc2VFeGNlcHRpb24oYFVuZXhwZWN0ZWQgc2VydmVyIHJlc3BvbnNlICgke3N0YXR1c30pIHdoaWxlIHJldHJpZXZpbmcgUERGICIke3VybH0iLmAsIHN0YXR1cyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiB2YWxpZGF0ZVJlc3BvbnNlU3RhdHVzKHN0YXR1cykgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBzdGF0dXMgPT09IDIwMCB8fCBzdGF0dXMgPT09IDIwNjsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTU4ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuZ2V0RmlsZW5hbWVGcm9tQ29udGVudERpc3Bvc2l0aW9uSGVhZGVyID0gZ2V0RmlsZW5hbWVGcm9tQ29udGVudERpc3Bvc2l0aW9uSGVhZGVyOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldEZpbGVuYW1lRnJvbUNvbnRlbnREaXNwb3NpdGlvbkhlYWRlcihjb250ZW50RGlzcG9zaXRpb24pIHsKICAgICAgICAgICAgICAgICAgICBsZXQgbmVlZHNFbmNvZGluZ0ZpeHVwID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICBsZXQgdG1wID0gdG9QYXJhbVJlZ0V4cCgiZmlsZW5hbWVcXCoiLCAiaSIpLmV4ZWMoY29udGVudERpc3Bvc2l0aW9uKTsKICAgICAgICAgICAgICAgICAgICBpZiAodG1wKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRtcCA9IHRtcFsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGZpbGVuYW1lID0gcmZjMjYxNnVucXVvdGUodG1wKTsKICAgICAgICAgICAgICAgICAgICAgICAgZmlsZW5hbWUgPSB1bmVzY2FwZShmaWxlbmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVuYW1lID0gcmZjNTk4N2RlY29kZShmaWxlbmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVuYW1lID0gcmZjMjA0N2RlY29kZShmaWxlbmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmaXh1cEVuY29kaW5nKGZpbGVuYW1lKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdG1wID0gcmZjMjIzMWdldHBhcmFtKGNvbnRlbnREaXNwb3NpdGlvbik7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRtcCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxlbmFtZSA9IHJmYzIwNDdkZWNvZGUodG1wKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZpeHVwRW5jb2RpbmcoZmlsZW5hbWUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0bXAgPSB0b1BhcmFtUmVnRXhwKCJmaWxlbmFtZSIsICJpIikuZXhlYyhjb250ZW50RGlzcG9zaXRpb24pOwogICAgICAgICAgICAgICAgICAgIGlmICh0bXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wID0gdG1wWzFdOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgZmlsZW5hbWUgPSByZmMyNjE2dW5xdW90ZSh0bXApOwogICAgICAgICAgICAgICAgICAgICAgICBmaWxlbmFtZSA9IHJmYzIwNDdkZWNvZGUoZmlsZW5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZml4dXBFbmNvZGluZyhmaWxlbmFtZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHRvUGFyYW1SZWdFeHAoYXR0cmlidXRlUGF0dGVybiwgZmxhZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBSZWdFeHAoIig/Ol58OylcXHMqIiArIGF0dHJpYnV0ZVBhdHRlcm4gKyAiXFxzKj1cXHMqIiArICIoIiArICdbXiI7XFxzXVteO1xcc10qJyArICJ8IiArICciKD86W14iXFxcXF18XFxcXCI/KSsiPycgKyAiKSIsIGZsYWdzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gdGV4dGRlY29kZShlbmNvZGluZywgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuY29kaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIS9eW1x4MDAtXHhGRl0rJC8udGVzdCh2YWx1ZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlY29kZXIgPSBuZXcgVGV4dERlY29kZXIoZW5jb2RpbmcsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmF0YWw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSAoMCwgX3V0aWwuc3RyaW5nVG9CeXRlcykodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlID0gZGVjb2Rlci5kZWNvZGUoYnVmZmVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZWVkc0VuY29kaW5nRml4dXAgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHt9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBmaXh1cEVuY29kaW5nKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZWVkc0VuY29kaW5nRml4dXAgJiYgL1tceDgwLVx4ZmZdLy50ZXN0KHZhbHVlKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSB0ZXh0ZGVjb2RlKCJ1dGYtOCIsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChuZWVkc0VuY29kaW5nRml4dXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHRleHRkZWNvZGUoImlzby04ODU5LTEiLCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiByZmMyMjMxZ2V0cGFyYW0oY29udGVudERpc3Bvc2l0aW9uU3RyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hdGNoZXMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG1hdGNoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpdGVyID0gdG9QYXJhbVJlZ0V4cCgiZmlsZW5hbWVcXCooKD8hMFxcZClcXGQrKShcXCo/KSIsICJpZyIpOwogICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoKG1hdGNoID0gaXRlci5leGVjKGNvbnRlbnREaXNwb3NpdGlvblN0cikpICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgWywgbiwgcXVvdCwgcGFydF0gPSBtYXRjaDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG4gPSBwYXJzZUludChuLCAxMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobiBpbiBtYXRjaGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG4gPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF0Y2hlc1tuXSA9IFtxdW90LCBwYXJ0XTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJ0cyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBuID0gMDsgbiA8IG1hdGNoZXMubGVuZ3RoOyArK24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghKG4gaW4gbWF0Y2hlcykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBbcXVvdCwgcGFydF0gPSBtYXRjaGVzW25dOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFydCA9IHJmYzI2MTZ1bnF1b3RlKHBhcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHF1b3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJ0ID0gdW5lc2NhcGUocGFydCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG4gPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFydCA9IHJmYzU5ODdkZWNvZGUocGFydCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFydHMucHVzaChwYXJ0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGFydHMuam9pbigiIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHJmYzI2MTZ1bnF1b3RlKHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZS5zdGFydHNXaXRoKCciJykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhcnRzID0gdmFsdWUuc2xpY2UoMSkuc3BsaXQoJ1xcIicpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBwYXJ0cy5sZW5ndGg7ICsraSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHF1b3RpbmRleCA9IHBhcnRzW2ldLmluZGV4T2YoJyInKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocXVvdGluZGV4ICE9PSAtMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJ0c1tpXSA9IHBhcnRzW2ldLnNsaWNlKDAsIHF1b3RpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcnRzLmxlbmd0aCA9IGkgKyAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJ0c1tpXSA9IHBhcnRzW2ldLnJlcGxhY2VBbGwoL1xcKC4pL2csICIkMSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUgPSBwYXJ0cy5qb2luKCciJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiByZmM1OTg3ZGVjb2RlKGV4dHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVuY29kaW5nZW5kID0gZXh0dmFsdWUuaW5kZXhPZigiJyIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZW5jb2RpbmdlbmQgPT09IC0xKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZXh0dmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZW5jb2RpbmcgPSBleHR2YWx1ZS5zbGljZSgwLCBlbmNvZGluZ2VuZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxhbmd2YWx1ZSA9IGV4dHZhbHVlLnNsaWNlKGVuY29kaW5nZW5kICsgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gbGFuZ3ZhbHVlLnJlcGxhY2UoL15bXiddKicvLCAiIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0ZXh0ZGVjb2RlKGVuY29kaW5nLCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHJmYzIwNDdkZWNvZGUodmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF2YWx1ZS5zdGFydHNXaXRoKCI9PyIpIHx8IC9bXHgwMC1ceDE5XHg4MC1ceGZmXS8udGVzdCh2YWx1ZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsdWUucmVwbGFjZUFsbCgvPVw/KFtcdy1dKilcPyhbUXFCYl0pXD8oKD86W14/XXxcPyg/IT0pKSopXD89L2csIGZ1bmN0aW9uIChtYXRjaGVzLCBjaGFyc2V0LCBlbmNvZGluZywgdGV4dCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuY29kaW5nID09PSAicSIgfHwgZW5jb2RpbmcgPT09ICJRIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHQgPSB0ZXh0LnJlcGxhY2VBbGwoIl8iLCAiICIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHQgPSB0ZXh0LnJlcGxhY2VBbGwoLz0oWzAtOWEtZkEtRl17Mn0pL2csIGZ1bmN0aW9uIChtYXRjaCwgaGV4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBTdHJpbmcuZnJvbUNoYXJDb2RlKHBhcnNlSW50KGhleCwgMTYpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGV4dGRlY29kZShjaGFyc2V0LCB0ZXh0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dCA9IGF0b2IodGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGNhdGNoIChlKSB7fQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRleHRkZWNvZGUoY2hhcnNldCwgdGV4dCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gIiI7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE1OSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERk5ldHdvcmtTdHJlYW0gPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9uZXR3b3JrX3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTcpOwogICAgICAgICAgICAgICAgOwogICAgICAgICAgICAgICAgY29uc3QgT0tfUkVTUE9OU0UgPSAyMDA7CiAgICAgICAgICAgICAgICBjb25zdCBQQVJUSUFMX0NPTlRFTlRfUkVTUE9OU0UgPSAyMDY7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRBcnJheUJ1ZmZlcih4aHIpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0geGhyLnJlc3BvbnNlOwogICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgZGF0YSAhPT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGE7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiAoMCwgX3V0aWwuc3RyaW5nVG9CeXRlcykoZGF0YSkuYnVmZmVyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgTmV0d29ya01hbmFnZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHVybCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYXJncyA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudXJsID0gdXJsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzSHR0cCA9IC9eaHR0cHM/Oi9pLnRlc3QodXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5odHRwSGVhZGVycyA9IHRoaXMuaXNIdHRwICYmIGFyZ3MuaHR0cEhlYWRlcnMgfHwgT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy53aXRoQ3JlZGVudGlhbHMgPSBhcmdzLndpdGhDcmVkZW50aWFscyB8fCBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5nZXRYaHIgPSBhcmdzLmdldFhociB8fCBmdW5jdGlvbiBOZXR3b3JrTWFuYWdlcl9nZXRYaHIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFhNTEh0dHBSZXF1ZXN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VyclhocklkID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nUmVxdWVzdHMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXF1ZXN0UmFuZ2UoYmVnaW4sIGVuZCwgbGlzdGVuZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3MgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBiZWdpbiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuZAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHByb3AgaW4gbGlzdGVuZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmdzW3Byb3BdID0gbGlzdGVuZXJzW3Byb3BdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnJlcXVlc3QoYXJncyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlcXVlc3RGdWxsKGxpc3RlbmVycykgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5yZXF1ZXN0KGxpc3RlbmVycyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlcXVlc3QoYXJncykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4aHIgPSB0aGlzLmdldFhocigpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4aHJJZCA9IHRoaXMuY3VyclhocklkKys7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBlbmRpbmdSZXF1ZXN0ID0gdGhpcy5wZW5kaW5nUmVxdWVzdHNbeGhySWRdID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgeGhyCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIHhoci5vcGVuKCJHRVQiLCB0aGlzLnVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHhoci53aXRoQ3JlZGVudGlhbHMgPSB0aGlzLndpdGhDcmVkZW50aWFsczsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBwcm9wZXJ0eSBpbiB0aGlzLmh0dHBIZWFkZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IHRoaXMuaHR0cEhlYWRlcnNbcHJvcGVydHldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhoci5zZXRSZXF1ZXN0SGVhZGVyKHByb3BlcnR5LCB2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNIdHRwICYmICJiZWdpbiIgaW4gYXJncyAmJiAiZW5kIiBpbiBhcmdzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB4aHIuc2V0UmVxdWVzdEhlYWRlcigiUmFuZ2UiLCBgYnl0ZXM9JHthcmdzLmJlZ2lufS0ke2FyZ3MuZW5kIC0gMX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlbmRpbmdSZXF1ZXN0LmV4cGVjdGVkU3RhdHVzID0gUEFSVElBTF9DT05URU5UX1JFU1BPTlNFOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3QuZXhwZWN0ZWRTdGF0dXMgPSBPS19SRVNQT05TRTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB4aHIucmVzcG9uc2VUeXBlID0gImFycmF5YnVmZmVyIjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFyZ3Mub25FcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgeGhyLm9uZXJyb3IgPSBmdW5jdGlvbiAoZXZ0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXJncy5vbkVycm9yKHhoci5zdGF0dXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB4aHIub25yZWFkeXN0YXRlY2hhbmdlID0gdGhpcy5vblN0YXRlQ2hhbmdlLmJpbmQodGhpcywgeGhySWQpOwogICAgICAgICAgICAgICAgICAgICAgICB4aHIub25wcm9ncmVzcyA9IHRoaXMub25Qcm9ncmVzcy5iaW5kKHRoaXMsIHhocklkKTsKICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3Qub25IZWFkZXJzUmVjZWl2ZWQgPSBhcmdzLm9uSGVhZGVyc1JlY2VpdmVkOwogICAgICAgICAgICAgICAgICAgICAgICBwZW5kaW5nUmVxdWVzdC5vbkRvbmUgPSBhcmdzLm9uRG9uZTsKICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3Qub25FcnJvciA9IGFyZ3Mub25FcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3Qub25Qcm9ncmVzcyA9IGFyZ3Mub25Qcm9ncmVzczsKICAgICAgICAgICAgICAgICAgICAgICAgeGhyLnNlbmQobnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB4aHJJZDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25Qcm9ncmVzcyh4aHJJZCwgZXZ0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGVuZGluZ1JlcXVlc3Qkb25Qcm87CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBlbmRpbmdSZXF1ZXN0ID0gdGhpcy5wZW5kaW5nUmVxdWVzdHNbeGhySWRdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXBlbmRpbmdSZXF1ZXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgKF9wZW5kaW5nUmVxdWVzdCRvblBybyA9IHBlbmRpbmdSZXF1ZXN0Lm9uUHJvZ3Jlc3MpID09PSBudWxsIHx8IF9wZW5kaW5nUmVxdWVzdCRvblBybyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3BlbmRpbmdSZXF1ZXN0JG9uUHJvLmNhbGwocGVuZGluZ1JlcXVlc3QsIGV2dCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIG9uU3RhdGVDaGFuZ2UoeGhySWQsIGV2dCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwZW5kaW5nUmVxdWVzdCA9IHRoaXMucGVuZGluZ1JlcXVlc3RzW3hocklkXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFwZW5kaW5nUmVxdWVzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHhociA9IHBlbmRpbmdSZXF1ZXN0LnhocjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhoci5yZWFkeVN0YXRlID49IDIgJiYgcGVuZGluZ1JlcXVlc3Qub25IZWFkZXJzUmVjZWl2ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBlbmRpbmdSZXF1ZXN0Lm9uSGVhZGVyc1JlY2VpdmVkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxldGUgcGVuZGluZ1JlcXVlc3Qub25IZWFkZXJzUmVjZWl2ZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhoci5yZWFkeVN0YXRlICE9PSA0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCEoeGhySWQgaW4gdGhpcy5wZW5kaW5nUmVxdWVzdHMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHRoaXMucGVuZGluZ1JlcXVlc3RzW3hocklkXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhoci5zdGF0dXMgPT09IDAgJiYgdGhpcy5pc0h0dHApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGVuZGluZ1JlcXVlc3Qkb25FcnI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3BlbmRpbmdSZXF1ZXN0JG9uRXJyID0gcGVuZGluZ1JlcXVlc3Qub25FcnJvcikgPT09IG51bGwgfHwgX3BlbmRpbmdSZXF1ZXN0JG9uRXJyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfcGVuZGluZ1JlcXVlc3Qkb25FcnIuY2FsbChwZW5kaW5nUmVxdWVzdCwgeGhyLnN0YXR1cyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeGhyU3RhdHVzID0geGhyLnN0YXR1cyB8fCBPS19SRVNQT05TRTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2tfcmVzcG9uc2Vfb25fcmFuZ2VfcmVxdWVzdCA9IHhoclN0YXR1cyA9PT0gT0tfUkVTUE9OU0UgJiYgcGVuZGluZ1JlcXVlc3QuZXhwZWN0ZWRTdGF0dXMgPT09IFBBUlRJQUxfQ09OVEVOVF9SRVNQT05TRTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFva19yZXNwb25zZV9vbl9yYW5nZV9yZXF1ZXN0ICYmIHhoclN0YXR1cyAhPT0gcGVuZGluZ1JlcXVlc3QuZXhwZWN0ZWRTdGF0dXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGVuZGluZ1JlcXVlc3Qkb25FcnIyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF9wZW5kaW5nUmVxdWVzdCRvbkVycjIgPSBwZW5kaW5nUmVxdWVzdC5vbkVycm9yKSA9PT0gbnVsbCB8fCBfcGVuZGluZ1JlcXVlc3Qkb25FcnIyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfcGVuZGluZ1JlcXVlc3Qkb25FcnIyLmNhbGwocGVuZGluZ1JlcXVlc3QsIHhoci5zdGF0dXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gZ2V0QXJyYXlCdWZmZXIoeGhyKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHhoclN0YXR1cyA9PT0gUEFSVElBTF9DT05URU5UX1JFU1BPTlNFKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByYW5nZUhlYWRlciA9IHhoci5nZXRSZXNwb25zZUhlYWRlcigiQ29udGVudC1SYW5nZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF0Y2hlcyA9IC9ieXRlcyAoXGQrKS0oXGQrKVwvKFxkKykvLmV4ZWMocmFuZ2VIZWFkZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3Qub25Eb25lKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiZWdpbjogcGFyc2VJbnQobWF0Y2hlc1sxXSwgMTApLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNodW5rCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaHVuaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3Qub25Eb25lKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiZWdpbjogMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaHVuawogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BlbmRpbmdSZXF1ZXN0JG9uRXJyMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfcGVuZGluZ1JlcXVlc3Qkb25FcnIzID0gcGVuZGluZ1JlcXVlc3Qub25FcnJvcikgPT09IG51bGwgfHwgX3BlbmRpbmdSZXF1ZXN0JG9uRXJyMyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3BlbmRpbmdSZXF1ZXN0JG9uRXJyMy5jYWxsKHBlbmRpbmdSZXF1ZXN0LCB4aHIuc3RhdHVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSZXF1ZXN0WGhyKHhocklkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnBlbmRpbmdSZXF1ZXN0c1t4aHJJZF0ueGhyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpc1BlbmRpbmdSZXF1ZXN0KHhocklkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB4aHJJZCBpbiB0aGlzLnBlbmRpbmdSZXF1ZXN0czsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWJvcnRSZXF1ZXN0KHhocklkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHhociA9IHRoaXMucGVuZGluZ1JlcXVlc3RzW3hocklkXS54aHI7CiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGV0ZSB0aGlzLnBlbmRpbmdSZXF1ZXN0c1t4aHJJZF07CiAgICAgICAgICAgICAgICAgICAgICAgIHhoci5hYm9ydCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBERk5ldHdvcmtTdHJlYW0gewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zb3VyY2UgPSBzb3VyY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX21hbmFnZXIgPSBuZXcgTmV0d29ya01hbmFnZXIoc291cmNlLnVybCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaHR0cEhlYWRlcnM6IHNvdXJjZS5odHRwSGVhZGVycywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpdGhDcmVkZW50aWFsczogc291cmNlLndpdGhDcmVkZW50aWFscwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VDaHVua1NpemUgPSBzb3VyY2UucmFuZ2VDaHVua1NpemU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VSZXF1ZXN0UmVhZGVycyA9IFtdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25SYW5nZVJlcXVlc3RSZWFkZXJDbG9zZWQocmVhZGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGkgPSB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLmluZGV4T2YocmVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPj0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VSZXF1ZXN0UmVhZGVycy5zcGxpY2UoaSwgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0RnVsbFJlYWRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLmFzc2VydCkoIXRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyLCAiUERGTmV0d29ya1N0cmVhbS5nZXRGdWxsUmVhZGVyIGNhbiBvbmx5IGJlIGNhbGxlZCBvbmNlLiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlciA9IG5ldyBQREZOZXR3b3JrU3RyZWFtRnVsbFJlcXVlc3RSZWFkZXIodGhpcy5fbWFuYWdlciwgdGhpcy5fc291cmNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXRSYW5nZVJlYWRlcihiZWdpbiwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlYWRlciA9IG5ldyBQREZOZXR3b3JrU3RyZWFtUmFuZ2VSZXF1ZXN0UmVhZGVyKHRoaXMuX21hbmFnZXIsIGJlZ2luLCBlbmQpOwogICAgICAgICAgICAgICAgICAgICAgICByZWFkZXIub25DbG9zZWQgPSB0aGlzLl9vblJhbmdlUmVxdWVzdFJlYWRlckNsb3NlZC5iaW5kKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLnB1c2gocmVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlYWRlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsQWxsUmVxdWVzdHMocmVhc29uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWE7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfZnVsbFJlcXVlc3RSZWEgPSB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlcXVlc3RSZWEuY2FuY2VsKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcmVhZGVyIG9mIHRoaXMuX3JhbmdlUmVxdWVzdFJlYWRlcnMuc2xpY2UoMCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlYWRlci5jYW5jZWwocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuUERGTmV0d29ya1N0cmVhbSA9IFBERk5ldHdvcmtTdHJlYW07CiAgICAgICAgICAgICAgICBjbGFzcyBQREZOZXR3b3JrU3RyZWFtRnVsbFJlcXVlc3RSZWFkZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKG1hbmFnZXIsIHNvdXJjZSkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tYW5hZ2VyID0gbWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYXJncyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uSGVhZGVyc1JlY2VpdmVkOiB0aGlzLl9vbkhlYWRlcnNSZWNlaXZlZC5iaW5kKHRoaXMpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb25Eb25lOiB0aGlzLl9vbkRvbmUuYmluZCh0aGlzKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uRXJyb3I6IHRoaXMuX29uRXJyb3IuYmluZCh0aGlzKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uUHJvZ3Jlc3M6IHRoaXMuX29uUHJvZ3Jlc3MuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91cmwgPSBzb3VyY2UudXJsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mdWxsUmVxdWVzdElkID0gbWFuYWdlci5yZXF1ZXN0RnVsbChhcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc1JlY2VpdmVkQ2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGlzYWJsZVJhbmdlID0gc291cmNlLmRpc2FibGVSYW5nZSB8fCBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGVudExlbmd0aCA9IHNvdXJjZS5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlQ2h1bmtTaXplID0gc291cmNlLnJhbmdlQ2h1bmtTaXplOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3JhbmdlQ2h1bmtTaXplICYmICF0aGlzLl9kaXNhYmxlUmFuZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNTdHJlYW1pbmdTdXBwb3J0ZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNSYW5nZVN1cHBvcnRlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYWNoZWRDaHVua3MgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdG9yZWRFcnJvciA9IHVuZGVmaW5lZDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZmlsZW5hbWUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25IZWFkZXJzUmVjZWl2ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZ1bGxSZXF1ZXN0WGhySWQgPSB0aGlzLl9mdWxsUmVxdWVzdElkOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmdWxsUmVxdWVzdFhociA9IHRoaXMuX21hbmFnZXIuZ2V0UmVxdWVzdFhocihmdWxsUmVxdWVzdFhocklkKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZ2V0UmVzcG9uc2VIZWFkZXIgPSBuYW1lID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdWxsUmVxdWVzdFhoci5nZXRSZXNwb25zZUhlYWRlcihuYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxsb3dSYW5nZVJlcXVlc3RzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3VnZ2VzdGVkTGVuZ3RoCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSAoMCwgX25ldHdvcmtfdXRpbHMudmFsaWRhdGVSYW5nZVJlcXVlc3RDYXBhYmlsaXRpZXMpKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdldFJlc3BvbnNlSGVhZGVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNIdHRwOiB0aGlzLl9tYW5hZ2VyLmlzSHR0cCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJhbmdlQ2h1bmtTaXplOiB0aGlzLl9yYW5nZUNodW5rU2l6ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVSYW5nZTogdGhpcy5fZGlzYWJsZVJhbmdlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYWxsb3dSYW5nZVJlcXVlc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1JhbmdlU3VwcG9ydGVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZW50TGVuZ3RoID0gc3VnZ2VzdGVkTGVuZ3RoIHx8IHRoaXMuX2NvbnRlbnRMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZpbGVuYW1lID0gKDAsIF9uZXR3b3JrX3V0aWxzLmV4dHJhY3RGaWxlbmFtZUZyb21IZWFkZXIpKGdldFJlc3BvbnNlSGVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX21hbmFnZXIuYWJvcnRSZXF1ZXN0KGZ1bGxSZXF1ZXN0WGhySWQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hlYWRlcnNSZWNlaXZlZENhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25Eb25lKGRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSB0aGlzLl9yZXF1ZXN0cy5zaGlmdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3RDYXBhYmlsaXR5LnJlc29sdmUoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZGF0YS5jaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FjaGVkQ2h1bmtzLnB1c2goZGF0YS5jaHVuayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZG9uZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9jYWNoZWRDaHVua3MubGVuZ3RoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgb2YgdGhpcy5fcmVxdWVzdHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlcXVlc3RDYXBhYmlsaXR5LnJlc29sdmUoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB1bmRlZmluZWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVxdWVzdHMubGVuZ3RoID0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX29uRXJyb3Ioc3RhdHVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3N0b3JlZEVycm9yID0gKDAsIF9uZXR3b3JrX3V0aWxzLmNyZWF0ZVJlc3BvbnNlU3RhdHVzRXJyb3IpKHN0YXR1cywgdGhpcy5fdXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc1JlY2VpdmVkQ2FwYWJpbGl0eS5yZWplY3QodGhpcy5fc3RvcmVkRXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlcXVlc3RDYXBhYmlsaXR5IG9mIHRoaXMuX3JlcXVlc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0Q2FwYWJpbGl0eS5yZWplY3QodGhpcy5fc3RvcmVkRXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NhY2hlZENodW5rcy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25Qcm9ncmVzcyhldnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJG9uUHJvZ3Jlc3M7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRvblByb2dyZXNzID0gdGhpcy5vblByb2dyZXNzKSA9PT0gbnVsbCB8fCBfdGhpcyRvblByb2dyZXNzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRvblByb2dyZXNzLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBldnQubG9hZGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWw6IGV2dC5sZW5ndGhDb21wdXRhYmxlID8gZXZ0LnRvdGFsIDogdGhpcy5fY29udGVudExlbmd0aAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGZpbGVuYW1lKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fZmlsZW5hbWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1JhbmdlU3VwcG9ydGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5faXNSYW5nZVN1cHBvcnRlZDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGlzU3RyZWFtaW5nU3VwcG9ydGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5faXNTdHJlYW1pbmdTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBjb250ZW50TGVuZ3RoKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fY29udGVudExlbmd0aDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGhlYWRlcnNSZWFkeSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2hlYWRlcnNSZWNlaXZlZENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgcmVhZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3JlZEVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyB0aGlzLl9zdG9yZWRFcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fY2FjaGVkQ2h1bmtzLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gdGhpcy5fY2FjaGVkQ2h1bmtzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLnB1c2gocmVxdWVzdENhcGFiaWxpdHkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc1JlY2VpdmVkQ2FwYWJpbGl0eS5yZWplY3QocmVhc29uKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fbWFuYWdlci5pc1BlbmRpbmdSZXF1ZXN0KHRoaXMuX2Z1bGxSZXF1ZXN0SWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tYW5hZ2VyLmFib3J0UmVxdWVzdCh0aGlzLl9mdWxsUmVxdWVzdElkKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mdWxsUmVxdWVzdFJlYWRlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUERGTmV0d29ya1N0cmVhbVJhbmdlUmVxdWVzdFJlYWRlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IobWFuYWdlciwgYmVnaW4sIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9tYW5hZ2VyID0gbWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYXJncyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uRG9uZTogdGhpcy5fb25Eb25lLmJpbmQodGhpcyksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvbkVycm9yOiB0aGlzLl9vbkVycm9yLmJpbmQodGhpcyksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvblByb2dyZXNzOiB0aGlzLl9vblByb2dyZXNzLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdXJsID0gbWFuYWdlci51cmw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RJZCA9IG1hbmFnZXIucmVxdWVzdFJhbmdlKGJlZ2luLCBlbmQsIGFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9xdWV1ZWRDaHVuayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RvbmUgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSB1bmRlZmluZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25Qcm9ncmVzcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25DbG9zZWQgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY2xvc2UoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRvbkNsb3NlZDsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJG9uQ2xvc2VkID0gdGhpcy5vbkNsb3NlZCkgPT09IG51bGwgfHwgX3RoaXMkb25DbG9zZWQgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJG9uQ2xvc2VkLmNhbGwodGhpcywgdGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9vbkRvbmUoZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaHVuayA9IGRhdGEuY2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSA9IHRoaXMuX3JlcXVlc3RzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0Q2FwYWJpbGl0eS5yZXNvbHZlKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogY2h1bmssCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcXVldWVkQ2h1bmsgPSBjaHVuazsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jbG9zZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfb25FcnJvcihzdGF0dXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc3RvcmVkRXJyb3IgPSAoMCwgX25ldHdvcmtfdXRpbHMuY3JlYXRlUmVzcG9uc2VTdGF0dXNFcnJvcikoc3RhdHVzLCB0aGlzLl91cmwpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlcXVlc3RDYXBhYmlsaXR5IG9mIHRoaXMuX3JlcXVlc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXF1ZXN0Q2FwYWJpbGl0eS5yZWplY3QodGhpcy5fc3RvcmVkRXJyb3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3F1ZXVlZENodW5rID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX29uUHJvZ3Jlc3MoZXZ0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc1N0cmVhbWluZ1N1cHBvcnRlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJG9uUHJvZ3Jlc3MyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJG9uUHJvZ3Jlc3MyID0gdGhpcy5vblByb2dyZXNzKSA9PT0gbnVsbCB8fCBfdGhpcyRvblByb2dyZXNzMiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkb25Qcm9ncmVzczIuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiBldnQubG9hZGVkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNTdHJlYW1pbmdTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgcmVhZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX3N0b3JlZEVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyB0aGlzLl9zdG9yZWRFcnJvcjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fcXVldWVkQ2h1bmsgIT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNodW5rID0gdGhpcy5fcXVldWVkQ2h1bms7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9xdWV1ZWRDaHVuayA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjaHVuaywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdW5kZWZpbmVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmU6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVxdWVzdENhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlcXVlc3RzLnB1c2gocmVxdWVzdENhcGFiaWxpdHkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVxdWVzdENhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kb25lID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZXF1ZXN0Q2FwYWJpbGl0eSBvZiB0aGlzLl9yZXF1ZXN0cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWVzdENhcGFiaWxpdHkucmVzb2x2ZSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHVuZGVmaW5lZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZXF1ZXN0cy5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fbWFuYWdlci5pc1BlbmRpbmdSZXF1ZXN0KHRoaXMuX3JlcXVlc3RJZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX21hbmFnZXIuYWJvcnRSZXF1ZXN0KHRoaXMuX3JlcXVlc3RJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2xvc2UoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2MCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkZldGNoU3RyZWFtID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfbmV0d29ya191dGlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTU3KTsKICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNyZWF0ZUZldGNoT3B0aW9ucyhoZWFkZXJzLCB3aXRoQ3JlZGVudGlhbHMsIGFib3J0Q29udHJvbGxlcikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgIG1ldGhvZDogIkdFVCIsCiAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcnMsCiAgICAgICAgICAgICAgICAgICAgICAgIHNpZ25hbDogYWJvcnRDb250cm9sbGVyLnNpZ25hbCwKICAgICAgICAgICAgICAgICAgICAgICAgbW9kZTogImNvcnMiLAogICAgICAgICAgICAgICAgICAgICAgICBjcmVkZW50aWFsczogd2l0aENyZWRlbnRpYWxzID8gImluY2x1ZGUiIDogInNhbWUtb3JpZ2luIiwKICAgICAgICAgICAgICAgICAgICAgICAgcmVkaXJlY3Q6ICJmb2xsb3ciCiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNyZWF0ZUhlYWRlcnMoaHR0cEhlYWRlcnMpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWFkZXJzID0gbmV3IEhlYWRlcnMoKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHByb3BlcnR5IGluIGh0dHBIZWFkZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gaHR0cEhlYWRlcnNbcHJvcGVydHldOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodmFsdWUgPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVycy5hcHBlbmQocHJvcGVydHksIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGhlYWRlcnM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRBcnJheUJ1ZmZlcih2YWwpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodmFsIGluc3RhbmNlb2YgVWludDhBcnJheSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdmFsLmJ1ZmZlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHZhbCBpbnN0YW5jZW9mIEFycmF5QnVmZmVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0QXJyYXlCdWZmZXIgLSB1bmV4cGVjdGVkIGRhdGEgZm9ybWF0OiAke3ZhbH1gKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFVpbnQ4QXJyYXkodmFsKS5idWZmZXI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBQREZGZXRjaFN0cmVhbSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc291cmNlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc291cmNlID0gc291cmNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzSHR0cCA9IC9eaHR0cHM/Oi9pLnRlc3Qoc291cmNlLnVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaHR0cEhlYWRlcnMgPSB0aGlzLmlzSHR0cCAmJiBzb3VyY2UuaHR0cEhlYWRlcnMgfHwge307CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmFuZ2VSZXF1ZXN0UmVhZGVycyA9IFtdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgX3Byb2dyZXNzaXZlRGF0YUxlbmd0aCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJF9mdWxsUmVxdWVzdFJlYTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICgoX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhID0gdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9mdWxsUmVxdWVzdFJlYSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhLl9sb2FkZWQpID8/IDA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEZ1bGxSZWFkZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKCF0aGlzLl9mdWxsUmVxdWVzdFJlYWRlciwgIlBERkZldGNoU3RyZWFtLmdldEZ1bGxSZWFkZXIgY2FuIG9ubHkgYmUgY2FsbGVkIG9uY2UuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyID0gbmV3IFBERkZldGNoU3RyZWFtUmVhZGVyKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fZnVsbFJlcXVlc3RSZWFkZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldFJhbmdlUmVhZGVyKGJlZ2luLCBlbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVuZCA8PSB0aGlzLl9wcm9ncmVzc2l2ZURhdGFMZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlYWRlciA9IG5ldyBQREZGZXRjaFN0cmVhbVJhbmdlUmVhZGVyKHRoaXMsIGJlZ2luLCBlbmQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLnB1c2gocmVhZGVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlYWRlcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsQWxsUmVxdWVzdHMocmVhc29uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkX2Z1bGxSZXF1ZXN0UmVhMiA9IHRoaXMuX2Z1bGxSZXF1ZXN0UmVhZGVyKSA9PT0gbnVsbCB8fCBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRfZnVsbFJlcXVlc3RSZWEyLmNhbmNlbChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlYWRlciBvZiB0aGlzLl9yYW5nZVJlcXVlc3RSZWFkZXJzLnNsaWNlKDApKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkZXIuY2FuY2VsKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlBERkZldGNoU3RyZWFtID0gUERGRmV0Y2hTdHJlYW07CiAgICAgICAgICAgICAgICBjbGFzcyBQREZGZXRjaFN0cmVhbVJlYWRlciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3Ioc3RyZWFtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3N0cmVhbSA9IHN0cmVhbTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVkID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZmlsZW5hbWUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzb3VyY2UgPSBzdHJlYW0uc291cmNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl93aXRoQ3JlZGVudGlhbHMgPSBzb3VyY2Uud2l0aENyZWRlbnRpYWxzIHx8IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZW50TGVuZ3RoID0gc291cmNlLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc0NhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHNvdXJjZS5kaXNhYmxlUmFuZ2UgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JhbmdlQ2h1bmtTaXplID0gc291cmNlLnJhbmdlQ2h1bmtTaXplOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX3JhbmdlQ2h1bmtTaXplICYmICF0aGlzLl9kaXNhYmxlUmFuZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc2FibGVSYW5nZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYWJvcnRDb250cm9sbGVyID0gbmV3IEFib3J0Q29udHJvbGxlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZCA9ICFzb3VyY2UuZGlzYWJsZVN0cmVhbTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNSYW5nZVN1cHBvcnRlZCA9ICFzb3VyY2UuZGlzYWJsZVJhbmdlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9oZWFkZXJzID0gY3JlYXRlSGVhZGVycyh0aGlzLl9zdHJlYW0uaHR0cEhlYWRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBzb3VyY2UudXJsOwogICAgICAgICAgICAgICAgICAgICAgICBmZXRjaCh1cmwsIGNyZWF0ZUZldGNoT3B0aW9ucyh0aGlzLl9oZWFkZXJzLCB0aGlzLl93aXRoQ3JlZGVudGlhbHMsIHRoaXMuX2Fib3J0Q29udHJvbGxlcikpLnRoZW4ocmVzcG9uc2UgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCEoMCwgX25ldHdvcmtfdXRpbHMudmFsaWRhdGVSZXNwb25zZVN0YXR1cykocmVzcG9uc2Uuc3RhdHVzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93ICgwLCBfbmV0d29ya191dGlscy5jcmVhdGVSZXNwb25zZVN0YXR1c0Vycm9yKShyZXNwb25zZS5zdGF0dXMsIHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkZXIgPSByZXNwb25zZS5ib2R5LmdldFJlYWRlcigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faGVhZGVyc0NhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZ2V0UmVzcG9uc2VIZWFkZXIgPSBuYW1lID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmVzcG9uc2UuaGVhZGVycy5nZXQobmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFsbG93UmFuZ2VSZXF1ZXN0cywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWdnZXN0ZWRMZW5ndGgKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSAoMCwgX25ldHdvcmtfdXRpbHMudmFsaWRhdGVSYW5nZVJlcXVlc3RDYXBhYmlsaXRpZXMpKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZXRSZXNwb25zZUhlYWRlciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0h0dHA6IHRoaXMuX3N0cmVhbS5pc0h0dHAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmFuZ2VDaHVua1NpemU6IHRoaXMuX3JhbmdlQ2h1bmtTaXplLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc2FibGVSYW5nZTogdGhpcy5fZGlzYWJsZVJhbmdlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQgPSBhbGxvd1JhbmdlUmVxdWVzdHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250ZW50TGVuZ3RoID0gc3VnZ2VzdGVkTGVuZ3RoIHx8IHRoaXMuX2NvbnRlbnRMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9maWxlbmFtZSA9ICgwLCBfbmV0d29ya191dGlscy5leHRyYWN0RmlsZW5hbWVGcm9tSGVhZGVyKShnZXRSZXNwb25zZUhlYWRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuX2lzU3RyZWFtaW5nU3VwcG9ydGVkICYmIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbmNlbChuZXcgX3V0aWwuQWJvcnRFeGNlcHRpb24oIlN0cmVhbWluZyBpcyBkaXNhYmxlZC4iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0pLmNhdGNoKHRoaXMuX2hlYWRlcnNDYXBhYmlsaXR5LnJlamVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub25Qcm9ncmVzcyA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBoZWFkZXJzUmVhZHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9oZWFkZXJzQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgZmlsZW5hbWUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9maWxlbmFtZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IGNvbnRlbnRMZW5ndGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9jb250ZW50TGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNSYW5nZVN1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2lzUmFuZ2VTdXBwb3J0ZWQ7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBpc1N0cmVhbWluZ1N1cHBvcnRlZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2lzU3RyZWFtaW5nU3VwcG9ydGVkOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhc3luYyByZWFkKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkb25Qcm9ncmVzczsKICAgICAgICAgICAgICAgICAgICAgICAgYXdhaXQgdGhpcy5faGVhZGVyc0NhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBhd2FpdCB0aGlzLl9yZWFkZXIucmVhZCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9uZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb25lCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlZCArPSB2YWx1ZS5ieXRlTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkb25Qcm9ncmVzcyA9IHRoaXMub25Qcm9ncmVzcykgPT09IG51bGwgfHwgX3RoaXMkb25Qcm9ncmVzcyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkb25Qcm9ncmVzcy5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRlZDogdGhpcy5fbG9hZGVkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdG90YWw6IHRoaXMuX2NvbnRlbnRMZW5ndGgKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZ2V0QXJyYXlCdWZmZXIodmFsdWUpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3JlYWRlcjsKICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJF9yZWFkZXIgPSB0aGlzLl9yZWFkZXIpID09PSBudWxsIHx8IF90aGlzJF9yZWFkZXIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9yZWFkZXIuY2FuY2VsKHJlYXNvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Fib3J0Q29udHJvbGxlci5hYm9ydCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBERkZldGNoU3RyZWFtUmFuZ2VSZWFkZXIgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHN0cmVhbSwgYmVnaW4sIGVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zdHJlYW0gPSBzdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2xvYWRlZCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNvdXJjZSA9IHN0cmVhbS5zb3VyY2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3dpdGhDcmVkZW50aWFscyA9IHNvdXJjZS53aXRoQ3JlZGVudGlhbHMgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZCA9ICFzb3VyY2UuZGlzYWJsZVN0cmVhbTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYWJvcnRDb250cm9sbGVyID0gbmV3IEFib3J0Q29udHJvbGxlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9oZWFkZXJzID0gY3JlYXRlSGVhZGVycyh0aGlzLl9zdHJlYW0uaHR0cEhlYWRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9oZWFkZXJzLmFwcGVuZCgiUmFuZ2UiLCBgYnl0ZXM9JHtiZWdpbn0tJHtlbmQgLSAxfWApOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1cmwgPSBzb3VyY2UudXJsOwogICAgICAgICAgICAgICAgICAgICAgICBmZXRjaCh1cmwsIGNyZWF0ZUZldGNoT3B0aW9ucyh0aGlzLl9oZWFkZXJzLCB0aGlzLl93aXRoQ3JlZGVudGlhbHMsIHRoaXMuX2Fib3J0Q29udHJvbGxlcikpLnRoZW4ocmVzcG9uc2UgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCEoMCwgX25ldHdvcmtfdXRpbHMudmFsaWRhdGVSZXNwb25zZVN0YXR1cykocmVzcG9uc2Uuc3RhdHVzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93ICgwLCBfbmV0d29ya191dGlscy5jcmVhdGVSZXNwb25zZVN0YXR1c0Vycm9yKShyZXNwb25zZS5zdGF0dXMsIHVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkQ2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9yZWFkZXIgPSByZXNwb25zZS5ib2R5LmdldFJlYWRlcigpOwogICAgICAgICAgICAgICAgICAgICAgICB9KS5jYXRjaCh0aGlzLl9yZWFkQ2FwYWJpbGl0eS5yZWplY3QpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9uUHJvZ3Jlc3MgPSBudWxsOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNTdHJlYW1pbmdTdXBwb3J0ZWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9pc1N0cmVhbWluZ1N1cHBvcnRlZDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXN5bmMgcmVhZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJG9uUHJvZ3Jlc3MyOwogICAgICAgICAgICAgICAgICAgICAgICBhd2FpdCB0aGlzLl9yZWFkQ2FwYWJpbGl0eS5wcm9taXNlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGF3YWl0IHRoaXMuX3JlYWRlci5yZWFkKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvbmUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbG9hZGVkICs9IHZhbHVlLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRvblByb2dyZXNzMiA9IHRoaXMub25Qcm9ncmVzcykgPT09IG51bGwgfHwgX3RoaXMkb25Qcm9ncmVzczIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJG9uUHJvZ3Jlc3MyLmNhbGwodGhpcywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbG9hZGVkOiB0aGlzLl9sb2FkZWQKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZ2V0QXJyYXlCdWZmZXIodmFsdWUpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKHJlYXNvbikgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkX3JlYWRlcjI7CiAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRfcmVhZGVyMiA9IHRoaXMuX3JlYWRlcikgPT09IG51bGwgfHwgX3RoaXMkX3JlYWRlcjIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJF9yZWFkZXIyLmNhbmNlbChyZWFzb24pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9hYm9ydENvbnRyb2xsZXIuYWJvcnQoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2MSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLlRleHRMYXllclJlbmRlclRhc2sgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICBleHBvcnRzLnJlbmRlclRleHRMYXllciA9IHJlbmRlclRleHRMYXllcjsKICAgICAgICAgICAgICAgIGV4cG9ydHMudXBkYXRlVGV4dExheWVyID0gdXBkYXRlVGV4dExheWVyOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfZGlzcGxheV91dGlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQyKTsKICAgICAgICAgICAgICAgIGNvbnN0IE1BWF9URVhUX0RJVlNfVE9fUkVOREVSID0gMTAwMDAwOwogICAgICAgICAgICAgICAgY29uc3QgREVGQVVMVF9GT05UX1NJWkUgPSAzMDsKICAgICAgICAgICAgICAgIGNvbnN0IERFRkFVTFRfRk9OVF9BU0NFTlQgPSAwLjg7CiAgICAgICAgICAgICAgICBjb25zdCBhc2NlbnRDYWNoZSA9IG5ldyBNYXAoKTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGdldEN0eChzaXplLCBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCkgewogICAgICAgICAgICAgICAgICAgIGxldCBjdHg7CiAgICAgICAgICAgICAgICAgICAgaWYgKGlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkICYmIF91dGlsLkZlYXR1cmVUZXN0LmlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eCA9IG5ldyBPZmZzY3JlZW5DYW52YXMoc2l6ZSwgc2l6ZSkuZ2V0Q29udGV4dCgiMmQiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbHBoYTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2FudmFzID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiY2FudmFzIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhcy53aWR0aCA9IGNhbnZhcy5oZWlnaHQgPSBzaXplOwogICAgICAgICAgICAgICAgICAgICAgICBjdHggPSBjYW52YXMuZ2V0Q29udGV4dCgiMmQiLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbHBoYTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBjdHg7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRBc2NlbnQoZm9udEZhbWlseSwgaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjYWNoZWRBc2NlbnQgPSBhc2NlbnRDYWNoZS5nZXQoZm9udEZhbWlseSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGNhY2hlZEFzY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY2FjaGVkQXNjZW50OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBjdHggPSBnZXRDdHgoREVGQVVMVF9GT05UX1NJWkUsIGlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkKTsKICAgICAgICAgICAgICAgICAgICBjdHguZm9udCA9IGAke0RFRkFVTFRfRk9OVF9TSVpFfXB4ICR7Zm9udEZhbWlseX1gOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IG1ldHJpY3MgPSBjdHgubWVhc3VyZVRleHQoIiIpOwogICAgICAgICAgICAgICAgICAgIGxldCBhc2NlbnQgPSBtZXRyaWNzLmZvbnRCb3VuZGluZ0JveEFzY2VudDsKICAgICAgICAgICAgICAgICAgICBsZXQgZGVzY2VudCA9IE1hdGguYWJzKG1ldHJpY3MuZm9udEJvdW5kaW5nQm94RGVzY2VudCk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGFzY2VudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByYXRpbyA9IGFzY2VudCAvIChhc2NlbnQgKyBkZXNjZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgYXNjZW50Q2FjaGUuc2V0KGZvbnRGYW1pbHksIHJhdGlvKTsKICAgICAgICAgICAgICAgICAgICAgICAgY3R4LmNhbnZhcy53aWR0aCA9IGN0eC5jYW52YXMuaGVpZ2h0ID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJhdGlvOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjdHguc3Ryb2tlU3R5bGUgPSAicmVkIjsKICAgICAgICAgICAgICAgICAgICBjdHguY2xlYXJSZWN0KDAsIDAsIERFRkFVTFRfRk9OVF9TSVpFLCBERUZBVUxUX0ZPTlRfU0laRSk7CiAgICAgICAgICAgICAgICAgICAgY3R4LnN0cm9rZVRleHQoImciLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICBsZXQgcGl4ZWxzID0gY3R4LmdldEltYWdlRGF0YSgwLCAwLCBERUZBVUxUX0ZPTlRfU0laRSwgREVGQVVMVF9GT05UX1NJWkUpLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgZGVzY2VudCA9IDA7CiAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IHBpeGVscy5sZW5ndGggLSAxIC0gMzsgaSA+PSAwOyBpIC09IDQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBpeGVsc1tpXSA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlc2NlbnQgPSBNYXRoLmNlaWwoaSAvIDQgLyBERUZBVUxUX0ZPTlRfU0laRSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjdHguY2xlYXJSZWN0KDAsIDAsIERFRkFVTFRfRk9OVF9TSVpFLCBERUZBVUxUX0ZPTlRfU0laRSk7CiAgICAgICAgICAgICAgICAgICAgY3R4LnN0cm9rZVRleHQoIkEiLCAwLCBERUZBVUxUX0ZPTlRfU0laRSk7CiAgICAgICAgICAgICAgICAgICAgcGl4ZWxzID0gY3R4LmdldEltYWdlRGF0YSgwLCAwLCBERUZBVUxUX0ZPTlRfU0laRSwgREVGQVVMVF9GT05UX1NJWkUpLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgYXNjZW50ID0gMDsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBwaXhlbHMubGVuZ3RoOyBpIDwgaWk7IGkgKz0gNCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGl4ZWxzW2ldID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYXNjZW50ID0gREVGQVVMVF9GT05UX1NJWkUgLSBNYXRoLmZsb29yKGkgLyA0IC8gREVGQVVMVF9GT05UX1NJWkUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY3R4LmNhbnZhcy53aWR0aCA9IGN0eC5jYW52YXMuaGVpZ2h0ID0gMDsKICAgICAgICAgICAgICAgICAgICBpZiAoYXNjZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJhdGlvID0gYXNjZW50IC8gKGFzY2VudCArIGRlc2NlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICBhc2NlbnRDYWNoZS5zZXQoZm9udEZhbWlseSwgcmF0aW8pOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcmF0aW87CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFzY2VudENhY2hlLnNldChmb250RmFtaWx5LCBERUZBVUxUX0ZPTlRfQVNDRU5UKTsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gREVGQVVMVF9GT05UX0FTQ0VOVDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGFwcGVuZFRleHQodGFzaywgZ2VvbSwgc3R5bGVzKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dERpdiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInNwYW4iKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXh0RGl2UHJvcGVydGllcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgYW5nbGU6IDAsCiAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc1dpZHRoOiAwLAogICAgICAgICAgICAgICAgICAgICAgICBoYXNUZXh0OiBnZW9tLnN0ciAhPT0gIiIsCiAgICAgICAgICAgICAgICAgICAgICAgIGhhc0VPTDogZ2VvbS5oYXNFT0wsCiAgICAgICAgICAgICAgICAgICAgICAgIGZvbnRTaXplOiAwCiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB0YXNrLl90ZXh0RGl2cy5wdXNoKHRleHREaXYpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHR4ID0gX3V0aWwuVXRpbC50cmFuc2Zvcm0odGFzay5fdHJhbnNmb3JtLCBnZW9tLnRyYW5zZm9ybSk7CiAgICAgICAgICAgICAgICAgICAgbGV0IGFuZ2xlID0gTWF0aC5hdGFuMih0eFsxXSwgdHhbMF0pOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0eWxlID0gc3R5bGVzW2dlb20uZm9udE5hbWVdOwogICAgICAgICAgICAgICAgICAgIGlmIChzdHlsZS52ZXJ0aWNhbCkgewogICAgICAgICAgICAgICAgICAgICAgICBhbmdsZSArPSBNYXRoLlBJIC8gMjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udEhlaWdodCA9IE1hdGguaHlwb3QodHhbMl0sIHR4WzNdKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250QXNjZW50ID0gZm9udEhlaWdodCAqIGdldEFzY2VudChzdHlsZS5mb250RmFtaWx5LCB0YXNrLl9pc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCk7CiAgICAgICAgICAgICAgICAgICAgbGV0IGxlZnQsIHRvcDsKICAgICAgICAgICAgICAgICAgICBpZiAoYW5nbGUgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGVmdCA9IHR4WzRdOwogICAgICAgICAgICAgICAgICAgICAgICB0b3AgPSB0eFs1XSAtIGZvbnRBc2NlbnQ7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGVmdCA9IHR4WzRdICsgZm9udEFzY2VudCAqIE1hdGguc2luKGFuZ2xlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdG9wID0gdHhbNV0gLSBmb250QXNjZW50ICogTWF0aC5jb3MoYW5nbGUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZUZhY3RvclN0ciA9ICJjYWxjKHZhcigtLXNjYWxlLWZhY3RvcikqIjsKICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXZTdHlsZSA9IHRleHREaXYuc3R5bGU7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRhc2suX2NvbnRhaW5lciA9PT0gdGFzay5fcm9vdENvbnRhaW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICBkaXZTdHlsZS5sZWZ0ID0gYCR7KDEwMCAqIGxlZnQgLyB0YXNrLl9wYWdlV2lkdGgpLnRvRml4ZWQoMil9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpdlN0eWxlLnRvcCA9IGAkeygxMDAgKiB0b3AgLyB0YXNrLl9wYWdlSGVpZ2h0KS50b0ZpeGVkKDIpfSVgOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpdlN0eWxlLmxlZnQgPSBgJHtzY2FsZUZhY3RvclN0cn0ke2xlZnQudG9GaXhlZCgyKX1weClgOwogICAgICAgICAgICAgICAgICAgICAgICBkaXZTdHlsZS50b3AgPSBgJHtzY2FsZUZhY3RvclN0cn0ke3RvcC50b0ZpeGVkKDIpfXB4KWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRpdlN0eWxlLmZvbnRTaXplID0gYCR7c2NhbGVGYWN0b3JTdHJ9JHtmb250SGVpZ2h0LnRvRml4ZWQoMil9cHgpYDsKICAgICAgICAgICAgICAgICAgICBkaXZTdHlsZS5mb250RmFtaWx5ID0gc3R5bGUuZm9udEZhbWlseTsKICAgICAgICAgICAgICAgICAgICB0ZXh0RGl2UHJvcGVydGllcy5mb250U2l6ZSA9IGZvbnRIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgdGV4dERpdi5zZXRBdHRyaWJ1dGUoInJvbGUiLCAicHJlc2VudGF0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgdGV4dERpdi50ZXh0Q29udGVudCA9IGdlb20uc3RyOwogICAgICAgICAgICAgICAgICAgIHRleHREaXYuZGlyID0gZ2VvbS5kaXI7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRhc2suX2ZvbnRJbnNwZWN0b3JFbmFibGVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRleHREaXYuZGF0YXNldC5mb250TmFtZSA9IGdlb20uZm9udE5hbWU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmIChhbmdsZSAhPT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICB0ZXh0RGl2UHJvcGVydGllcy5hbmdsZSA9IGFuZ2xlICogKDE4MCAvIE1hdGguUEkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBsZXQgc2hvdWxkU2NhbGVUZXh0ID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgaWYgKGdlb20uc3RyLmxlbmd0aCA+IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc2hvdWxkU2NhbGVUZXh0ID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGdlb20uc3RyICE9PSAiICIgJiYgZ2VvbS50cmFuc2Zvcm1bMF0gIT09IGdlb20udHJhbnNmb3JtWzNdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFic1NjYWxlWCA9IE1hdGguYWJzKGdlb20udHJhbnNmb3JtWzBdKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFic1NjYWxlWSA9IE1hdGguYWJzKGdlb20udHJhbnNmb3JtWzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFic1NjYWxlWCAhPT0gYWJzU2NhbGVZICYmIE1hdGgubWF4KGFic1NjYWxlWCwgYWJzU2NhbGVZKSAvIE1hdGgubWluKGFic1NjYWxlWCwgYWJzU2NhbGVZKSA+IDEuNSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2hvdWxkU2NhbGVUZXh0ID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAoc2hvdWxkU2NhbGVUZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRleHREaXZQcm9wZXJ0aWVzLmNhbnZhc1dpZHRoID0gc3R5bGUudmVydGljYWwgPyBnZW9tLmhlaWdodCA6IGdlb20ud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRhc2suX3RleHREaXZQcm9wZXJ0aWVzLnNldCh0ZXh0RGl2LCB0ZXh0RGl2UHJvcGVydGllcyk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHRhc2suX2lzUmVhZGFibGVTdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGFzay5fbGF5b3V0VGV4dCh0ZXh0RGl2KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBsYXlvdXQocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICBkaXYsCiAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlLAogICAgICAgICAgICAgICAgICAgICAgICBwcm9wZXJ0aWVzLAogICAgICAgICAgICAgICAgICAgICAgICBjdHgsCiAgICAgICAgICAgICAgICAgICAgICAgIHByZXZGb250U2l6ZSwKICAgICAgICAgICAgICAgICAgICAgICAgcHJldkZvbnRGYW1pbHkKICAgICAgICAgICAgICAgICAgICB9ID0gcGFyYW1zOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICB9ID0gZGl2OwogICAgICAgICAgICAgICAgICAgIGxldCB0cmFuc2Zvcm0gPSAiIjsKICAgICAgICAgICAgICAgICAgICBpZiAocHJvcGVydGllcy5jYW52YXNXaWR0aCAhPT0gMCAmJiBwcm9wZXJ0aWVzLmhhc1RleHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9udEZhbWlseQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gc3R5bGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhbnZhc1dpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9udFNpemUKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHByb3BlcnRpZXM7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwcmV2Rm9udFNpemUgIT09IGZvbnRTaXplIHx8IHByZXZGb250RmFtaWx5ICE9PSBmb250RmFtaWx5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdHguZm9udCA9IGAke2ZvbnRTaXplICogc2NhbGV9cHggJHtmb250RmFtaWx5fWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbXMucHJldkZvbnRTaXplID0gZm9udFNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXJhbXMucHJldkZvbnRGYW1pbHkgPSBmb250RmFtaWx5OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBjdHgubWVhc3VyZVRleHQoZGl2LnRleHRDb250ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJhbnNmb3JtID0gYHNjYWxlWCgke2NhbnZhc1dpZHRoICogc2NhbGUgLyB3aWR0aH0pYDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBpZiAocHJvcGVydGllcy5hbmdsZSAhPT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICB0cmFuc2Zvcm0gPSBgcm90YXRlKCR7cHJvcGVydGllcy5hbmdsZX1kZWcpICR7dHJhbnNmb3JtfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICh0cmFuc2Zvcm0ubGVuZ3RoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS50cmFuc2Zvcm0gPSB0cmFuc2Zvcm07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gcmVuZGVyKHRhc2spIHsKICAgICAgICAgICAgICAgICAgICBpZiAodGFzay5fY2FuY2VsZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXh0RGl2cyA9IHRhc2suX3RleHREaXZzOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhcGFiaWxpdHkgPSB0YXNrLl9jYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRleHREaXZzTGVuZ3RoID0gdGV4dERpdnMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0RGl2c0xlbmd0aCA+IE1BWF9URVhUX0RJVlNfVE9fUkVOREVSKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghdGFzay5faXNSZWFkYWJsZVN0cmVhbSkgewogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHRleHREaXYgb2YgdGV4dERpdnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhc2suX2xheW91dFRleHQodGV4dERpdik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FwYWJpbGl0eS5yZXNvbHZlKCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBUZXh0TGF5ZXJSZW5kZXJUYXNrIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihfcmVmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfZ2xvYmFsVGhpcyRGb250SW5zcGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0Q29udGVudFNvdXJjZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dERpdnMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0RGl2UHJvcGVydGllcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHRDb250ZW50SXRlbXNTdHIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdGV4dENvbnRlbnRTb3VyY2UgPSB0ZXh0Q29udGVudFNvdXJjZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5faXNSZWFkYWJsZVN0cmVhbSA9IHRleHRDb250ZW50U291cmNlIGluc3RhbmNlb2YgUmVhZGFibGVTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRhaW5lciA9IHRoaXMuX3Jvb3RDb250YWluZXIgPSBjb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RleHREaXZzID0gdGV4dERpdnMgfHwgW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3RleHRDb250ZW50SXRlbXNTdHIgPSB0ZXh0Q29udGVudEl0ZW1zU3RyIHx8IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCA9IGlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9mb250SW5zcGVjdG9yRW5hYmxlZCA9ICEhKChfZ2xvYmFsVGhpcyRGb250SW5zcGUgPSBnbG9iYWxUaGlzLkZvbnRJbnNwZWN0b3IpICE9PSBudWxsICYmIF9nbG9iYWxUaGlzJEZvbnRJbnNwZSAhPT0gdm9pZCAwICYmIF9nbG9iYWxUaGlzJEZvbnRJbnNwZS5lbmFibGVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGVyID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdGV4dERpdlByb3BlcnRpZXMgPSB0ZXh0RGl2UHJvcGVydGllcyB8fCBuZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYW5jZWxlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sYXlvdXRUZXh0UGFyYW1zID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldkZvbnRTaXplOiBudWxsLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldkZvbnRGYW1pbHk6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXY6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZTogdmlld3BvcnQuc2NhbGUgKiAoZ2xvYmFsVGhpcy5kZXZpY2VQaXhlbFJhdGlvIHx8IDEpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvcGVydGllczogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eDogZ2V0Q3R4KDAsIGlzT2Zmc2NyZWVuQ2FudmFzU3VwcG9ydGVkKQogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlV2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlSGVpZ2h0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlWQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdmlld3BvcnQucmF3RGltczsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdHJhbnNmb3JtID0gWzEsIDAsIDAsIC0xLCAtcGFnZVgsIHBhZ2VZICsgcGFnZUhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3BhZ2VXaWR0aCA9IHBhZ2VXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcGFnZUhlaWdodCA9IHBhZ2VIZWlnaHQ7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfZGlzcGxheV91dGlscy5zZXRMYXllckRpbWVuc2lvbnMpKGNvbnRhaW5lciwgdmlld3BvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYXBhYmlsaXR5LnByb21pc2UuZmluYWxseSgoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9sYXlvdXRUZXh0UGFyYW1zID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfSkuY2F0Y2goKCkgPT4ge30pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgcHJvbWlzZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2NhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FuY2VsKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jYW5jZWxlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9yZWFkZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRlci5jYW5jZWwobmV3IF91dGlsLkFib3J0RXhjZXB0aW9uKCJUZXh0TGF5ZXIgdGFzayBjYW5jZWxsZWQuIikpLmNhdGNoKCgpID0+IHt9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3JlYWRlciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY2FwYWJpbGl0eS5yZWplY3QobmV3IF91dGlsLkFib3J0RXhjZXB0aW9uKCJUZXh0TGF5ZXIgdGFzayBjYW5jZWxsZWQuIikpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfcHJvY2Vzc0l0ZW1zKGl0ZW1zLCBzdHlsZUNhY2hlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaXRlbSBvZiBpdGVtcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGl0ZW0uc3RyID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXRlbS50eXBlID09PSAiYmVnaW5NYXJrZWRDb250ZW50UHJvcHMiIHx8IGl0ZW0udHlwZSA9PT0gImJlZ2luTWFya2VkQ29udGVudCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFyZW50ID0gdGhpcy5fY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250YWluZXIgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJzcGFuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJtYXJrZWRDb250ZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpdGVtLmlkICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250YWluZXIuc2V0QXR0cmlidXRlKCJpZCIsIGAke2l0ZW0uaWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50LmFwcGVuZCh0aGlzLl9jb250YWluZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoaXRlbS50eXBlID09PSAiZW5kTWFya2VkQ29udGVudCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY29udGFpbmVyID0gdGhpcy5fY29udGFpbmVyLnBhcmVudE5vZGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdGV4dENvbnRlbnRJdGVtc1N0ci5wdXNoKGl0ZW0uc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFwcGVuZFRleHQodGhpcywgaXRlbSwgc3R5bGVDYWNoZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2xheW91dFRleHQodGV4dERpdikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0ZXh0RGl2UHJvcGVydGllcyA9IHRoaXMuX2xheW91dFRleHRQYXJhbXMucHJvcGVydGllcyA9IHRoaXMuX3RleHREaXZQcm9wZXJ0aWVzLmdldCh0ZXh0RGl2KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fbGF5b3V0VGV4dFBhcmFtcy5kaXYgPSB0ZXh0RGl2OwogICAgICAgICAgICAgICAgICAgICAgICBsYXlvdXQodGhpcy5fbGF5b3V0VGV4dFBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0RGl2UHJvcGVydGllcy5oYXNUZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jb250YWluZXIuYXBwZW5kKHRleHREaXYpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0ZXh0RGl2UHJvcGVydGllcy5oYXNFT0wpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJyID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiYnIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyLnNldEF0dHJpYnV0ZSgicm9sZSIsICJwcmVzZW50YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NvbnRhaW5lci5hcHBlbmQoYnIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9yZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNhcGFiaWxpdHkgPSAoMCwgX3V0aWwuY3JlYXRlUHJvbWlzZUNhcGFiaWxpdHkpKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzdHlsZUNhY2hlID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2lzUmVhZGFibGVTdHJlYW0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHB1bXAgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGVyLnJlYWQoKS50aGVuKF9yZWYyID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9uZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkb25lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXBhYmlsaXR5LnJlc29sdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPYmplY3QuYXNzaWduKHN0eWxlQ2FjaGUsIHZhbHVlLnN0eWxlcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Byb2Nlc3NJdGVtcyh2YWx1ZS5pdGVtcywgc3R5bGVDYWNoZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHB1bXAoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LCBjYXBhYmlsaXR5LnJlamVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fcmVhZGVyID0gdGhpcy5fdGV4dENvbnRlbnRTb3VyY2UuZ2V0UmVhZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwdW1wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5fdGV4dENvbnRlbnRTb3VyY2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZXMKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLl90ZXh0Q29udGVudFNvdXJjZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3Byb2Nlc3NJdGVtcyhpdGVtcywgc3R5bGVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdObyAidGV4dENvbnRlbnRTb3VyY2UiIHBhcmFtZXRlciBzcGVjaWZpZWQuJyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY2FwYWJpbGl0eS5wcm9taXNlLnRoZW4oKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGVDYWNoZSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXIodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sIHRoaXMuX2NhcGFiaWxpdHkucmVqZWN0KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLlRleHRMYXllclJlbmRlclRhc2sgPSBUZXh0TGF5ZXJSZW5kZXJUYXNrOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gcmVuZGVyVGV4dExheWVyKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgIGlmICghcGFyYW1zLnRleHRDb250ZW50U291cmNlICYmIChwYXJhbXMudGV4dENvbnRlbnQgfHwgcGFyYW1zLnRleHRDb250ZW50U3RyZWFtKSkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuZGVwcmVjYXRlZCkoIlRoZSBUZXh0TGF5ZXJSZW5kZXIgYHRleHRDb250ZW50YC9gdGV4dENvbnRlbnRTdHJlYW1gIHBhcmFtZXRlcnMgIiArICJ3aWxsIGJlIHJlbW92ZWQgaW4gdGhlIGZ1dHVyZSwgcGxlYXNlIHVzZSBgdGV4dENvbnRlbnRTb3VyY2VgIGluc3RlYWQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtcy50ZXh0Q29udGVudFNvdXJjZSA9IHBhcmFtcy50ZXh0Q29udGVudCB8fCBwYXJhbXMudGV4dENvbnRlbnRTdHJlYW07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLAogICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydAogICAgICAgICAgICAgICAgICAgIH0gPSBwYXJhbXM7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3R5bGUgPSBnZXRDb21wdXRlZFN0eWxlKGNvbnRhaW5lcik7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgdmlzaWJpbGl0eSA9IHN0eWxlLmdldFByb3BlcnR5VmFsdWUoInZpc2liaWxpdHkiKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2FsZUZhY3RvciA9IHBhcnNlRmxvYXQoc3R5bGUuZ2V0UHJvcGVydHlWYWx1ZSgiLS1zY2FsZS1mYWN0b3IiKSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHZpc2liaWxpdHkgPT09ICJ2aXNpYmxlIiAmJiAoIXNjYWxlRmFjdG9yIHx8IE1hdGguYWJzKHNjYWxlRmFjdG9yIC0gdmlld3BvcnQuc2NhbGUpID4gMWUtMTUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoIlRoZSBgLS1zY2FsZS1mYWN0b3JgIENTUy12YXJpYWJsZSBtdXN0IGJlIHNldCwgIiArICJ0byB0aGUgc2FtZSB2YWx1ZSBhcyBgdmlld3BvcnQuc2NhbGVgLCAiICsgImVpdGhlciBvbiB0aGUgYGNvbnRhaW5lcmAtZWxlbWVudCBpdHNlbGYgb3IgaGlnaGVyIHVwIGluIHRoZSBET00uIik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgVGV4dExheWVyUmVuZGVyVGFzayhwYXJhbXMpOwogICAgICAgICAgICAgICAgICAgIHRhc2suX3JlbmRlcigpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB0YXNrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gdXBkYXRlVGV4dExheWVyKF9yZWYzKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLAogICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgdGV4dERpdnMsCiAgICAgICAgICAgICAgICAgICAgICAgIHRleHREaXZQcm9wZXJ0aWVzLAogICAgICAgICAgICAgICAgICAgICAgICBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCwKICAgICAgICAgICAgICAgICAgICAgICAgbXVzdFJvdGF0ZSA9IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RSZXNjYWxlID0gdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMzsKICAgICAgICAgICAgICAgICAgICBpZiAobXVzdFJvdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuc2V0TGF5ZXJEaW1lbnNpb25zKShjb250YWluZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uOiB2aWV3cG9ydC5yb3RhdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKG11c3RSZXNjYWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IGdldEN0eCgwLCBpc09mZnNjcmVlbkNhbnZhc1N1cHBvcnRlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHNjYWxlID0gdmlld3BvcnQuc2NhbGUgKiAoZ2xvYmFsVGhpcy5kZXZpY2VQaXhlbFJhdGlvIHx8IDEpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJhbXMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2Rm9udFNpemU6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2Rm9udEZhbWlseTogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpdjogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvcGVydGllczogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN0eAogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGRpdiBvZiB0ZXh0RGl2cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zLnByb3BlcnRpZXMgPSB0ZXh0RGl2UHJvcGVydGllcy5nZXQoZGl2KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtcy5kaXYgPSBkaXY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXlvdXQocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTYyICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkVkaXRvckxheWVyID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfdG9vbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0MSk7CiAgICAgICAgICAgICAgICB2YXIgX2ZyZWV0ZXh0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjMpOwogICAgICAgICAgICAgICAgdmFyIF9pbmsgPSBfX3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kaXRvciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9jcmVhdGVBbmRBZGROZXdFZGl0b3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfY2xlYW51cCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgY2xhc3MgQW5ub3RhdGlvbkVkaXRvckxheWVyIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihvcHRpb25zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfY2xlYW51cCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfY3JlYXRlQW5kQWRkTmV3RWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9jcmVhdGVOZXdFZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2NoYW5nZVBhcmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9hY2Nlc3NpYmlsaXR5TWFuYWdlciwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdm9pZCAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYWxsb3dDbGljaywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZFBvaW50ZXJ1cCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5wb2ludGVydXAuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kUG9pbnRlcmRvd24sIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMucG9pbnRlcmRvd24uYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2VkaXRvcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ldyBNYXAoKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2hhZFBvaW50ZXJEb3duLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2lzQ2xlYW5pbmdVcCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF91aU1hbmFnZXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFBbm5vdGF0aW9uRWRpdG9yTGF5ZXIuX2luaXRpYWxpemVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBBbm5vdGF0aW9uRWRpdG9yTGF5ZXIuX2luaXRpYWxpemVkID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9mcmVldGV4dC5GcmVlVGV4dEVkaXRvci5pbml0aWFsaXplKG9wdGlvbnMubDEwbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfaW5rLklua0VkaXRvci5pbml0aWFsaXplKG9wdGlvbnMubDEwbik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9ucy51aU1hbmFnZXIucmVnaXN0ZXJFZGl0b3JUeXBlcyhbX2ZyZWV0ZXh0LkZyZWVUZXh0RWRpdG9yLCBfaW5rLklua0VkaXRvcl0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3VpTWFuYWdlciwgb3B0aW9ucy51aU1hbmFnZXIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhZ2VJbmRleCA9IG9wdGlvbnMucGFnZUluZGV4OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdiA9IG9wdGlvbnMuZGl2OwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2FjY2Vzc2liaWxpdHlNYW5hZ2VyLCBvcHRpb25zLmFjY2Vzc2liaWxpdHlNYW5hZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmFkZExheWVyKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBnZXQgaXNFbXB0eSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9ycykuc2l6ZSA9PT0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlVG9vbGJhcihtb2RlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS51cGRhdGVUb29sYmFyKG1vZGUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGVNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgbW9kZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY2xlYW51cCwgX2NsZWFudXAyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAobW9kZSA9PT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZElua0VkaXRvcklmTmVlZGVkKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGlzYWJsZUNsaWNrKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuYWJsZUNsaWNrKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnVuc2VsZWN0QWxsKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtb2RlICE9PSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5OT05FKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QudG9nZ2xlKCJmcmVlVGV4dEVkaXRpbmciLCBtb2RlID09PSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5GUkVFVEVYVCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QudG9nZ2xlKCJpbmtFZGl0aW5nIiwgbW9kZSA9PT0gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmhpZGRlbiA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZElua0VkaXRvcklmTmVlZGVkKGlzQ29tbWl0dGluZykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ29tbWl0dGluZyAmJiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuZ2V0TW9kZSgpICE9PSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5JTkspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlzQ29tbWl0dGluZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlZGl0b3IuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5zZXRJbkJhY2tncm91bmQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlZGl0b3IgPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jcmVhdGVBbmRBZGROZXdFZGl0b3IsIF9jcmVhdGVBbmRBZGROZXdFZGl0b3IyKS5jYWxsKHRoaXMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9mZnNldFg6IDAsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRZOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2V0SW5CYWNrZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldEVkaXRpbmdTdGF0ZShpc0VkaXRpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnNldEVkaXRpbmdTdGF0ZShpc0VkaXRpbmcpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGRDb21tYW5kcyhwYXJhbXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmFkZENvbW1hbmRzKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGVuYWJsZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuc3R5bGUucG9pbnRlckV2ZW50cyA9ICJhdXRvIjsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9lZGl0b3JzKS52YWx1ZXMoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmVuYWJsZUVkaXRpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkaXNhYmxlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5zdHlsZS5wb2ludGVyRXZlbnRzID0gIm5vbmUiOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuZGlzYWJsZUVkaXRpbmcoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jbGVhbnVwLCBfY2xlYW51cDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmhpZGRlbiA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0QWN0aXZlRWRpdG9yKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50QWN0aXZlID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldEFjdGl2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudEFjdGl2ZSA9PT0gZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnNldEFjdGl2ZUVkaXRvcihlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmFibGVDbGljaygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYWRkRXZlbnRMaXN0ZW5lcigicG9pbnRlcmRvd24iLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kUG9pbnRlcmRvd24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYWRkRXZlbnRMaXN0ZW5lcigicG9pbnRlcnVwIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZFBvaW50ZXJ1cCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkaXNhYmxlQ2xpY2soKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZFBvaW50ZXJkb3duKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJ1cCIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRQb2ludGVydXApKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYXR0YWNoKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLnNldChlZGl0b3IuaWQsIGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRldGFjaChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9jbGFzc1ByaXZhdGVGaWVsZEdldDI7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9ycykuZGVsZXRlKGVkaXRvci5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIChfY2xhc3NQcml2YXRlRmllbGRHZXQyID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9hY2Nlc3NpYmlsaXR5TWFuYWdlcikpID09PSBudWxsIHx8IF9jbGFzc1ByaXZhdGVGaWVsZEdldDIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9jbGFzc1ByaXZhdGVGaWVsZEdldDIucmVtb3ZlUG9pbnRlckluVGV4dExheWVyKGVkaXRvci5jb250ZW50RGl2KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikucmVtb3ZlRWRpdG9yKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGV0YWNoKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5kaXYuc3R5bGUuZGlzcGxheSA9ICJub25lIjsKICAgICAgICAgICAgICAgICAgICAgICAgc2V0VGltZW91dCgoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuZGl2LnN0eWxlLmRpc3BsYXkgPSAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5kaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IuaXNBdHRhY2hlZFRvRE9NID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9jdW1lbnQuYWN0aXZlRWxlbWVudCA9PT0gZG9jdW1lbnQuYm9keSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5mb2N1c01haW5Db250YWluZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0NsZWFuaW5nVXApKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZElua0VkaXRvcklmTmVlZGVkKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhZGQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NoYW5nZVBhcmVudCwgX2NoYW5nZVBhcmVudDIpLmNhbGwodGhpcywgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmFkZEVkaXRvcihlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmF0dGFjaChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWVkaXRvci5pc0F0dGFjaGVkVG9ET00pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRpdiA9IGVkaXRvci5yZW5kZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFwcGVuZChkaXYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmlzQXR0YWNoZWRUb0RPTSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb3ZlRWRpdG9ySW5ET00oZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLm9uY2VBZGRlZCgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuYWRkVG9Bbm5vdGF0aW9uU3RvcmFnZShlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBtb3ZlRWRpdG9ySW5ET00oZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfY2xhc3NQcml2YXRlRmllbGRHZXQzOwogICAgICAgICAgICAgICAgICAgICAgICAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0MyA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYWNjZXNzaWJpbGl0eU1hbmFnZXIpKSA9PT0gbnVsbCB8fCBfY2xhc3NQcml2YXRlRmllbGRHZXQzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfY2xhc3NQcml2YXRlRmllbGRHZXQzLm1vdmVFbGVtZW50SW5ET00odGhpcy5kaXYsIGVkaXRvci5kaXYsIGVkaXRvci5jb250ZW50RGl2LCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkT3JSZWJ1aWxkKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWRpdG9yLm5lZWRzVG9CZVJlYnVpbHQoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnJlYnVpbGQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgYWRkQU5ld0VkaXRvcihlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRPclJlYnVpbGQoZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdW5kbyA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRDb21tYW5kcyh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1bmRvLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGFkZFVuZG9hYmxlRWRpdG9yKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjbWQgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZE9yUmVidWlsZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bmRvID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnJlbW92ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENvbW1hbmRzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNtZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVuZG8sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYzogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldE5leHRJZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5nZXRJZCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXNlcmlhbGl6ZShkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZGF0YS5hbm5vdGF0aW9uVHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5GUkVFVEVYVDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2ZyZWV0ZXh0LkZyZWVUZXh0RWRpdG9yLmRlc2VyaWFsaXplKGRhdGEsIHRoaXMsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JUeXBlLklOSzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2luay5JbmtFZGl0b3IuZGVzZXJpYWxpemUoZGF0YSwgdGhpcywgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0U2VsZWN0ZWQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5zZXRTZWxlY3RlZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0b2dnbGVTZWxlY3RlZChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnRvZ2dsZVNlbGVjdGVkKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzU2VsZWN0ZWQoZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuaXNTZWxlY3RlZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1bnNlbGVjdChlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLnVuc2VsZWN0KGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHBvaW50ZXJ1cChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5idXR0b24gIT09IDAgfHwgZXZlbnQuY3RybEtleSAmJiBpc01hYykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50YXJnZXQgIT09IHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2hhZFBvaW50ZXJEb3duKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGFkUG9pbnRlckRvd24sIGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FsbG93Q2xpY2spKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2FsbG93Q2xpY2ssIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NyZWF0ZUFuZEFkZE5ld0VkaXRvciwgX2NyZWF0ZUFuZEFkZE5ld0VkaXRvcjIpLmNhbGwodGhpcywgZXZlbnQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwb2ludGVyZG93bihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5idXR0b24gIT09IDAgfHwgZXZlbnQuY3RybEtleSAmJiBpc01hYykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50YXJnZXQgIT09IHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9oYWRQb2ludGVyRG93biwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVkaXRvciA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5nZXRBY3RpdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9hbGxvd0NsaWNrLCAhZWRpdG9yIHx8IGVkaXRvci5pc0VtcHR5KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkcm9wKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gZXZlbnQuZGF0YVRyYW5zZmVyLmdldERhdGEoInRleHQvcGxhaW4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9yID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldEVkaXRvcihpZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZWRpdG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQucHJldmVudERlZmF1bHQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQuZGF0YVRyYW5zZmVyLmRyb3BFZmZlY3QgPSAibW92ZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NoYW5nZVBhcmVudCwgX2NoYW5nZVBhcmVudDIpLmNhbGwodGhpcywgZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IHRoaXMuZGl2LmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbmRYID0gZXZlbnQuY2xpZW50WCAtIHJlY3QueDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZW5kWSA9IGV2ZW50LmNsaWVudFkgLSByZWN0Lnk7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci50cmFuc2xhdGUoZW5kWCAtIGVkaXRvci5zdGFydFgsIGVuZFkgLSBlZGl0b3Iuc3RhcnRZKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb3ZlRWRpdG9ySW5ET00oZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmRpdi5mb2N1cygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkcmFnb3ZlcihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBldmVudC5wcmV2ZW50RGVmYXVsdCgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkZXN0cm95KCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCgoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NCA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5nZXRBY3RpdmUoKSkgPT09IG51bGwgfHwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NC5wYXJlbnQpID09PSB0aGlzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3VpTWFuYWdlcikuc2V0QWN0aXZlRWRpdG9yKG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWRpdG9yIG9mIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZWRpdG9ycykudmFsdWVzKCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfY2xhc3NQcml2YXRlRmllbGRHZXQ1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF9jbGFzc1ByaXZhdGVGaWVsZEdldDUgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FjY2Vzc2liaWxpdHlNYW5hZ2VyKSkgPT09IG51bGwgfHwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0NS5yZW1vdmVQb2ludGVySW5UZXh0TGF5ZXIoZWRpdG9yLmNvbnRlbnREaXYpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLnNldFBhcmVudChudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5pc0F0dGFjaGVkVG9ET00gPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5kaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLmNsZWFyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfdWlNYW5hZ2VyKS5yZW1vdmVMYXllcih0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKF9yZWYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZpZXdwb3J0ID0gdmlld3BvcnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfZGlzcGxheV91dGlscy5zZXRMYXllckRpbWVuc2lvbnMpKHRoaXMuZGl2LCB2aWV3cG9ydCk7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdG9vbHMuYmluZEV2ZW50cykodGhpcywgdGhpcy5kaXYsIFsiZHJhZ292ZXIiLCAiZHJvcCJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlZGl0b3Igb2YgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldEVkaXRvcnModGhpcy5wYWdlSW5kZXgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudXBkYXRlTW9kZSgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB1cGRhdGUoX3JlZjIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmMjsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmNvbW1pdE9yUmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudmlld3BvcnQgPSB2aWV3cG9ydDsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF9kaXNwbGF5X3V0aWxzLnNldExheWVyRGltZW5zaW9ucykodGhpcy5kaXYsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uOiB2aWV3cG9ydC5yb3RhdGlvbgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51cGRhdGVNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwYWdlRGltZW5zaW9ucygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZUhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdGhpcy52aWV3cG9ydC5yYXdEaW1zOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3BhZ2VXaWR0aCwgcGFnZUhlaWdodF07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5Bbm5vdGF0aW9uRWRpdG9yTGF5ZXIgPSBBbm5vdGF0aW9uRWRpdG9yTGF5ZXI7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2hhbmdlUGFyZW50MihlZGl0b3IpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgX2VkaXRvciRwYXJlbnQ7CiAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvci5wYXJlbnQgPT09IHRoaXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0aGlzLmF0dGFjaChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIChfZWRpdG9yJHBhcmVudCA9IGVkaXRvci5wYXJlbnQpID09PSBudWxsIHx8IF9lZGl0b3IkcGFyZW50ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfZWRpdG9yJHBhcmVudC5kZXRhY2goZWRpdG9yKTsKICAgICAgICAgICAgICAgICAgICBlZGl0b3Iuc2V0UGFyZW50KHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGlmIChlZGl0b3IuZGl2ICYmIGVkaXRvci5pc0F0dGFjaGVkVG9ET00pIHsKICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmRpdi5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYXBwZW5kKGVkaXRvci5kaXYpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jcmVhdGVOZXdFZGl0b3IyKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpLmdldE1vZGUoKSkgewogICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JUeXBlLkZSRUVURVhUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBfZnJlZXRleHQuRnJlZVRleHRFZGl0b3IocGFyYW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5JTks6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IF9pbmsuSW5rRWRpdG9yKHBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NyZWF0ZUFuZEFkZE5ld0VkaXRvcjIoZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IHRoaXMuZ2V0TmV4dElkKCk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9yID0gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlTmV3RWRpdG9yLCBfY3JlYXRlTmV3RWRpdG9yMikuY2FsbCh0aGlzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmVudDogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgIHg6IGV2ZW50Lm9mZnNldFgsCiAgICAgICAgICAgICAgICAgICAgICAgIHk6IGV2ZW50Lm9mZnNldFksCiAgICAgICAgICAgICAgICAgICAgICAgIHVpTWFuYWdlcjogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF91aU1hbmFnZXIpCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGVkaXRvcikgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZChlZGl0b3IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gZWRpdG9yOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NsZWFudXAyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaXNDbGVhbmluZ1VwLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVkaXRvciBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvcnMpLnZhbHVlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlZGl0b3IuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9pc0NsZWFuaW5nVXAsIGZhbHNlKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShBbm5vdGF0aW9uRWRpdG9yTGF5ZXIsICJfaW5pdGlhbGl6ZWQiLCBmYWxzZSk7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2MyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkZyZWVUZXh0RWRpdG9yID0gdm9pZCAwOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfdG9vbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fK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8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF91cGRhdGVDb2xvciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9leHRyYWN0VGV4dCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZXRFZGl0b3JEaW1lbnNpb25zID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBjbGFzcyBGcmVlVGV4dEVkaXRvciBleHRlbmRzIF9lZGl0b3IuQW5ub3RhdGlvbkVkaXRvciB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIC4uLnBhcmFtcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6ICJmcmVlVGV4dEVkaXRvciIKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc2V0RWRpdG9yRGltZW5zaW9ucyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZXh0cmFjdFRleHQpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX3VwZGF0ZUNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF91cGRhdGVGb250U2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZEVkaXRvckRpdkJsdXIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuZWRpdG9yRGl2Qmx1ci5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRFZGl0b3JEaXZGb2N1cywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5lZGl0b3JEaXZGb2N1cy5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRFZGl0b3JEaXZJbnB1dCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdGhpcy5lZGl0b3JEaXZJbnB1dC5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRFZGl0b3JEaXZLZXlkb3duLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLmVkaXRvckRpdktleWRvd24uYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2NvbG9yLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2b2lkIDAKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9jb250ZW50LCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAiIgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2VkaXRvckRpdklkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBgJHt0aGlzLmlkfS1lZGl0b3JgCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfaGFzQWxyZWFkeUJlZW5Db21taXR0ZWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfZm9udFNpemUsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHZvaWQgMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb2xvciwgcGFyYW1zLmNvbG9yIHx8IEZyZWVUZXh0RWRpdG9yLl9kZWZhdWx0Q29sb3IgfHwgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9kZWZhdWx0TGluZUNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9mb250U2l6ZSwgcGFyYW1zLmZvbnRTaXplIHx8IEZyZWVUZXh0RWRpdG9yLl9kZWZhdWx0Rm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgaW5pdGlhbGl6ZShsMTBuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2wxMG5Qcm9taXNlID0gbmV3IE1hcChbImZyZWVfdGV4dDJfZGVmYXVsdF9jb250ZW50IiwgImVkaXRvcl9mcmVlX3RleHQyX2FyaWFfbGFiZWwiXS5tYXAoc3RyID0+IFtzdHIsIGwxMG4uZ2V0KHN0cildKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0eWxlID0gZ2V0Q29tcHV0ZWRTdHlsZShkb2N1bWVudC5kb2N1bWVudEVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9pbnRlcm5hbFBhZGRpbmcgPSBwYXJzZUZsb2F0KHN0eWxlLmdldFByb3BlcnR5VmFsdWUoIi0tZnJlZXRleHQtcGFkZGluZyIpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHVwZGF0ZURlZmF1bHRQYXJhbXModHlwZSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLkZSRUVURVhUX1NJWkU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRnJlZVRleHRFZGl0b3IuX2RlZmF1bHRGb250U2l6ZSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9DT0xPUjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBGcmVlVGV4dEVkaXRvci5fZGVmYXVsdENvbG9yID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlUGFyYW1zKHR5cGUsIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9TSVpFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3VwZGF0ZUZvbnRTaXplLCBfdXBkYXRlRm9udFNpemUyKS5jYWxsKHRoaXMsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfQ09MT1I6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlQ29sb3IsIF91cGRhdGVDb2xvcjIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXQgZGVmYXVsdFByb3BlcnRpZXNUb1VwZGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfU0laRSwgRnJlZVRleHRFZGl0b3IuX2RlZmF1bHRGb250U2l6ZV0sIFtfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9DT0xPUiwgRnJlZVRleHRFZGl0b3IuX2RlZmF1bHRDb2xvciB8fCBfZWRpdG9yLkFubm90YXRpb25FZGl0b3IuX2RlZmF1bHRMaW5lQ29sb3JdXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IHByb3BlcnRpZXNUb1VwZGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfU0laRSwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9mb250U2l6ZSldLCBbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuRlJFRVRFWFRfQ09MT1IsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY29sb3IpXV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldEluaXRpYWxUcmFuc2xhdGlvbigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGUgPSB0aGlzLnBhcmVudFNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gWy1GcmVlVGV4dEVkaXRvci5faW50ZXJuYWxQYWRkaW5nICogc2NhbGUsIC0oRnJlZVRleHRFZGl0b3IuX2ludGVybmFsUGFkZGluZyArIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZm9udFNpemUpKSAqIHNjYWxlXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVidWlsZCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVidWlsZCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kaXYgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNBdHRhY2hlZFRvRE9NKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5hZGQodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZW5hYmxlRWRpdE1vZGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzSW5FZGl0TW9kZSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0RWRpdGluZ1N0YXRlKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQudXBkYXRlVG9vbGJhcihfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yVHlwZS5GUkVFVEVYVCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyLmVuYWJsZUVkaXRNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3ZlcmxheURpdi5jbGFzc0xpc3QucmVtb3ZlKCJlbmFibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmNvbnRlbnRFZGl0YWJsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmRyYWdnYWJsZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5yZW1vdmVBdHRyaWJ1dGUoImFyaWEtYWN0aXZlZGVzY2VuZGFudCIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5hZGRFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEVkaXRvckRpdktleWRvd24pKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuYWRkRXZlbnRMaXN0ZW5lcigiZm9jdXMiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kRWRpdG9yRGl2Rm9jdXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuYWRkRXZlbnRMaXN0ZW5lcigiYmx1ciIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRFZGl0b3JEaXZCbHVyKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmFkZEV2ZW50TGlzdGVuZXIoImlucHV0IiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZEVkaXRvckRpdklucHV0KSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRpc2FibGVFZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmlzSW5FZGl0TW9kZSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuc2V0RWRpdGluZ1N0YXRlKHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB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3VzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXZlbnRTY3JvbGw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmRpdi5jbGFzc0xpc3QuYWRkKCJmcmVlVGV4dEVkaXRpbmciKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZm9jdXNpbihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5mb2N1c2luKGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50LnRhcmdldCAhPT0gdGhpcy5lZGl0b3JEaXYpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmZvY3VzKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25jZUFkZGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy53aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuZm9jdXMoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaXNFbXB0eSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICF0aGlzLmVkaXRvckRpdiB8fCB0aGlzLmVkaXRvckRpdi5pbm5lclRleHQudHJpbSgpID09PSAiIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVtb3ZlKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzRWRpdGluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5zZXRFZGl0aW5nU3RhdGUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmRpdi5jbGFzc0xpc3QuYWRkKCJmcmVlVGV4dEVkaXRpbmciKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbW1pdCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmlzSW5FZGl0TW9kZSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9oYXNBbHJlYWR5QmVlbkNvbW1pdHRlZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfaGFzQWxyZWFkeUJlZW5Db21taXR0ZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYXJlbnQuYWRkVW5kb2FibGVFZGl0b3IodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXNhYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb250ZW50LCBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9leHRyYWN0VGV4dCwgX2V4dHJhY3RUZXh0MikuY2FsbCh0aGlzKS50cmltRW5kKCkpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRFZGl0b3JEaW1lbnNpb25zLCBfc2V0RWRpdG9yRGltZW5zaW9uczIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNob3VsZEdldEtleWJvYXJkRXZlbnRzKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5pc0luRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZGJsY2xpY2soZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmFibGVFZGl0TW9kZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5mb2N1cygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBrZXlkb3duKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50YXJnZXQgPT09IHRoaXMuZGl2ICYmIGV2ZW50LmtleSA9PT0gIkVudGVyIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmFibGVFZGl0TW9kZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuZm9jdXMoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlZGl0b3JEaXZLZXlkb3duKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIEZyZWVUZXh0RWRpdG9yLl9rZXlib2FyZE1hbmFnZXIuZXhlYyh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGVkaXRvckRpdkZvY3VzKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZWRpdG9yRGl2Qmx1cihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmlzRWRpdGluZyA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlZGl0b3JEaXZJbnB1dChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5kaXYuY2xhc3NMaXN0LnRvZ2dsZSgiZnJlZVRleHRFZGl0aW5nIiwgdGhpcy5pc0VtcHR5KCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBkaXNhYmxlRWRpdGluZygpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuc2V0QXR0cmlidXRlKCJyb2xlIiwgImNvbW1lbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYucmVtb3ZlQXR0cmlidXRlKCJhcmlhLW11bHRpbGluZSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmFibGVFZGl0aW5nKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5zZXRBdHRyaWJ1dGUoInJvbGUiLCAidGV4dGJveCIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5zZXRBdHRyaWJ1dGUoImFyaWEtbXVsdGlsaW5lIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJhc2VYLCBiYXNlWTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMud2lkdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VYID0gdGhpcy54OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFzZVkgPSB0aGlzLnk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVuZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LmNsYXNzTmFtZSA9ICJpbnRlcm5hbCI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZWRpdG9yRGl2LnNldEF0dHJpYnV0ZSgiaWQiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2VkaXRvckRpdklkKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlRWRpdGluZygpOwogICAgICAgICAgICAgICAgICAgICAgICBGcmVlVGV4dEVkaXRvci5fbDEwblByb21pc2UuZ2V0KCJlZGl0b3JfZnJlZV90ZXh0Ml9hcmlhX2xhYmVsIikudGhlbihtc2cgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGVkaXRvckRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoX3RoaXMkZWRpdG9yRGl2ID0gdGhpcy5lZGl0b3JEaXYpID09PSBudWxsIHx8IF90aGlzJGVkaXRvckRpdiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZWRpdG9yRGl2LnNldEF0dHJpYnV0ZSgiYXJpYS1sYWJlbCIsIG1zZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBGcmVlVGV4dEVkaXRvci5fbDEwblByb21pc2UuZ2V0KCJmcmVlX3RleHQyX2RlZmF1bHRfY29udGVudCIpLnRoZW4obXNnID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRlZGl0b3JEaXYyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChfdGhpcyRlZGl0b3JEaXYyID0gdGhpcy5lZGl0b3JEaXYpID09PSBudWxsIHx8IF90aGlzJGVkaXRvckRpdjIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGVkaXRvckRpdjIuc2V0QXR0cmlidXRlKCJkZWZhdWx0LWNvbnRlbnQiLCBtc2cpOwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuY29udGVudEVkaXRhYmxlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZWRpdG9yRGl2OwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5mb250U2l6ZSA9IGBjYWxjKCR7X2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9mb250U2l6ZSl9cHggKiB2YXIoLS1zY2FsZS1mYWN0b3IpKWA7CiAgICAgICAgICAgICAgICAgICAgICAgIHN0eWxlLmNvbG9yID0gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb2xvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFwcGVuZCh0aGlzLmVkaXRvckRpdik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3ZlcmxheURpdiA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm92ZXJsYXlEaXYuY2xhc3NMaXN0LmFkZCgib3ZlcmxheSIsICJlbmFibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmFwcGVuZCh0aGlzLm92ZXJsYXlEaXYpOwogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3Rvb2xzLmJpbmRFdmVudHMpKHRoaXMsIHRoaXMuZGl2LCBbImRibGNsaWNrIiwgImtleWRvd24iXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLndpZHRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFyZW50V2lkdGgsIHBhcmVudEhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldEF0KGJhc2VYICogcGFyZW50V2lkdGgsIGJhc2VZICogcGFyZW50SGVpZ2h0LCB0aGlzLndpZHRoICogcGFyZW50V2lkdGgsIHRoaXMuaGVpZ2h0ICogcGFyZW50SGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbGluZSBvZiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbnRlbnQpLnNwbGl0KCJcbiIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGl2ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2LmFwcGVuZChsaW5lID8gZG9jdW1lbnQuY3JlYXRlVGV4dE5vZGUobGluZSkgOiBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJiciIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5hcHBlbmQoZGl2KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmRyYWdnYWJsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVkaXRvckRpdi5jb250ZW50RWRpdGFibGUgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmRyYWdnYWJsZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuY29udGVudEVkaXRhYmxlID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBjb250ZW50RGl2KCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5lZGl0b3JEaXY7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBkZXNlcmlhbGl6ZShkYXRhLCBwYXJlbnQsIHVpTWFuYWdlcikgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlZGl0b3IgPSBzdXBlci5kZXNlcmlhbGl6ZShkYXRhLCBwYXJlbnQsIHVpTWFuYWdlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9mb250U2l6ZSwgZGF0YS5mb250U2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9jb2xvciwgX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IoLi4uZGF0YS5jb2xvcikpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQoZWRpdG9yLCBfY29udGVudCwgZGF0YS52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBlZGl0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNlcmlhbGl6ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYWRkaW5nID0gRnJlZVRleHRFZGl0b3IuX2ludGVybmFsUGFkZGluZyAqIHRoaXMucGFyZW50U2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSB0aGlzLmdldFJlY3QocGFkZGluZywgcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9jb2xvck1hbmFnZXIuY29udmVydCh0aGlzLmlzQXR0YWNoZWRUb0RPTSA/IGdldENvbXB1dGVkU3R5bGUodGhpcy5lZGl0b3JEaXYpLmNvbG9yIDogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb2xvcikpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvblR5cGU6IF91dGlsLkFubm90YXRpb25FZGl0b3JUeXBlLkZSRUVURVhULAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sb3IsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb250U2l6ZTogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9mb250U2l6ZSksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jb250ZW50KSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VJbmRleDogdGhpcy5wYWdlSW5kZXgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb246IHRoaXMucm90YXRpb24KICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkZyZWVUZXh0RWRpdG9yID0gRnJlZVRleHRFZGl0b3I7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfdXBkYXRlRm9udFNpemUyKGZvbnRTaXplKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2V0Rm9udHNpemUgPSBzaXplID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lZGl0b3JEaXYuc3R5bGUuZm9udFNpemUgPSBgY2FsYygke3NpemV9cHggKiB2YXIoLS1zY2FsZS1mYWN0b3IpKWA7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNsYXRlKDAsIC0oc2l6ZSAtIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZm9udFNpemUpKSAqIHRoaXMucGFyZW50U2NhbGUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2ZvbnRTaXplLCBzaXplKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0RWRpdG9yRGltZW5zaW9ucywgX3NldEVkaXRvckRpbWVuc2lvbnMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRGb250c2l6ZSA9IF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZm9udFNpemUpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldEZvbnRzaXplKGZvbnRTaXplKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgdW5kbzogKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0Rm9udHNpemUoc2F2ZWRGb250c2l6ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RFeGVjOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5GUkVFVEVYVF9TSVpFLAogICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbzogdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3VwZGF0ZUNvbG9yMihjb2xvcikgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNhdmVkQ29sb3IgPSBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2NvbG9yKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENvbW1hbmRzKHsKICAgICAgICAgICAgICAgICAgICAgICAgY21kOiAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2NvbG9yLCB0aGlzLmVkaXRvckRpdi5zdHlsZS5jb2xvciA9IGNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgdW5kbzogKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9jb2xvciwgdGhpcy5lZGl0b3JEaXYuc3R5bGUuY29sb3IgPSBzYXZlZENvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLkZSRUVURVhUX0NPTE9SLAogICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbzogdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2V4dHJhY3RUZXh0MigpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBkaXZzID0gdGhpcy5lZGl0b3JEaXYuZ2V0RWxlbWVudHNCeVRhZ05hbWUoImRpdiIpOwogICAgICAgICAgICAgICAgICAgIGlmIChkaXZzLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5lZGl0b3JEaXYuaW5uZXJUZXh0OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBidWZmZXIgPSBbXTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGRpdiBvZiBkaXZzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJ1ZmZlci5wdXNoKGRpdi5pbm5lclRleHQucmVwbGFjZSgvXHJcbj98XG4vLCAiIikpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gYnVmZmVyLmpvaW4oIlxuIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0RWRpdG9yRGltZW5zaW9uczIoKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgIGxldCByZWN0OwogICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzQXR0YWNoZWRUb0RPTSkgewogICAgICAgICAgICAgICAgICAgICAgICByZWN0ID0gdGhpcy5kaXYuZ2V0Qm91bmRpbmdDbGllbnRSZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudExheWVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzYXZlZERpc3BsYXkgPSBkaXYuc3R5bGUuZGlzcGxheTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LnN0eWxlLmRpc3BsYXkgPSAiaGlkZGVuIjsKICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudExheWVyLmRpdi5hcHBlbmQodGhpcy5kaXYpOwogICAgICAgICAgICAgICAgICAgICAgICByZWN0ID0gZGl2LmdldEJvdW5kaW5nQ2xpZW50UmVjdCgpOwogICAgICAgICAgICAgICAgICAgICAgICBkaXYucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpdi5zdHlsZS5kaXNwbGF5ID0gc2F2ZWREaXNwbGF5OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB0aGlzLndpZHRoID0gcmVjdC53aWR0aCAvIHBhcmVudFdpZHRoOwogICAgICAgICAgICAgICAgICAgIHRoaXMuaGVpZ2h0ID0gcmVjdC5oZWlnaHQgLyBwYXJlbnRIZWlnaHQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfZnJlZVRleHREZWZhdWx0Q29udGVudCIsICIiKTsKICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShGcmVlVGV4dEVkaXRvciwgIl9sMTBuUHJvbWlzZSIsIHZvaWQgMCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfaW50ZXJuYWxQYWRkaW5nIiwgMCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfZGVmYXVsdENvbG9yIiwgbnVsbCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfZGVmYXVsdEZvbnRTaXplIiwgMTApOwogICAgICAgICAgICAgICAgX2RlZmluZVByb3BlcnR5KEZyZWVUZXh0RWRpdG9yLCAiX2tleWJvYXJkTWFuYWdlciIsIG5ldyBfdG9vbHMuS2V5Ym9hcmRNYW5hZ2VyKFtbWyJjdHJsK0VudGVyIiwgIm1hYyttZXRhK0VudGVyIiwgIkVzY2FwZSIsICJtYWMrRXNjYXBlIl0sIEZyZWVUZXh0RWRpdG9yLnByb3RvdHlwZS5jb21taXRPclJlbW92ZV1dKSk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoRnJlZVRleHRFZGl0b3IsICJfdHlwZSIsICJmcmVldGV4dCIpOwoKICAgICAgICAgICAgICAgIC8qKiovIH0pLAogICAgICAgICAgICAvKiAxNjQgKi8KICAgICAgICAgICAgLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW9kdWxlIiwgKHsKICAgICAgICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgZXhwb3J0cy5JbmtFZGl0b3IgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgImZpdEN1cnZlIiwgKHsKICAgICAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3BkZmpzRml0Q3VydmUuZml0Q3VydmU7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgICAgIHZhciBfZWRpdG9yID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDApOwogICAgICAgICAgICAgICAgdmFyIF9wZGZqc0ZpdEN1cnZlID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjUpOwogICAgICAgICAgICAgICAgdmFyIF90b29scyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQxKTsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyhvYmosIHByaXZhdGVTZXQpIHsgX2NoZWNrUHJpdmF0ZVJlZGVjbGFyYXRpb24ob2JqLCBwcml2YXRlU2V0KTsgcHJpdmF0ZVNldC5hZGQob2JqKTsgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2RlZmluZVByb3BlcnR5KG9iaiwga2V5LCB2YWx1ZSkgeyBrZXkgPSBfdG9Qcm9wZXJ0eUtleShrZXkpOyBpZiAoa2V5IGluIG9iaikgeyBPYmplY3QuZGVmaW5lUHJvcGVydHkob2JqLCBrZXksIHsgdmFsdWU6IHZhbHVlLCBlbnVtZXJhYmxlOiB0cnVlLCBjb25maWd1cmFibGU6IHRydWUsIHdyaXRhYmxlOiB0cnVlIH0pOyB9IGVsc2UgeyBvYmpba2V5XSA9IHZhbHVlOyB9IHJldHVybiBvYmo7IH0KICAgICAgICAgICAgIC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YgKCFwcml2YXRlU2V0LmhhcyhyZWNlaXZlcikpIHsgdGhyb3cgbmV3IFR5cGVFcnJvcigiYXR0ZW1wdGVkIHRvIGdldCBwcml2YXRlIGZpZWxkIG9uIG5vbi1pbnN0YW5jZSIpOyB9IHJldHVybiBmbjsgfQogICAgICAgICAgICAgICAgY29uc3QgUkVTSVpFUl9TSVpFID0gMTY7CiAgICAgICAgICAgICAgICB2YXIgX2FzcGVjdFJhdGlvID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2Jhc2VIZWlnaHQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYmFzZVdpZHRoID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2JvdW5kQ2FudmFzUG9pbnRlcm1vdmUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDYW52YXNQb2ludGVybGVhdmUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDYW52YXNQb2ludGVydXAgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfYm91bmRDYW52YXNQb2ludGVyZG93biA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9kaXNhYmxlRWRpdGluZyA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9pc0NhbnZhc0luaXRpYWxpemVkID0gLyojX19QVVJFX18qL25ldyBXZWFrTWFwKCk7CiAgICAgICAgICAgICAgICB2YXIgX2xhc3RQb2ludCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9vYnNlcnZlciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9yZWFsV2lkdGggPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtNYXAoKTsKICAgICAgICAgICAgICAgIHZhciBfcmVhbEhlaWdodCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF9yZXF1ZXN0RnJhbWVDYWxsYmFjayA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha01hcCgpOwogICAgICAgICAgICAgICAgdmFyIF91cGRhdGVUaGlja25lc3MgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfdXBkYXRlQ29sb3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfdXBkYXRlT3BhY2l0eSA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9nZXRJbml0aWFsQkJveCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZXRTdHJva2UgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfc3RhcnREcmF3aW5nID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2RyYXcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfc3RvcERyYXdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfcmVkcmF3ID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2VuZERyYXdpbmcgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfY3JlYXRlQ2FudmFzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2NyZWF0ZU9ic2VydmVyID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX3NldENhbnZhc0RpbXMgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfc2V0U2NhbGVGYWN0b3IgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfdXBkYXRlVHJhbnNmb3JtID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX3NlcmlhbGl6ZVBhdGhzID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2V4dHJhY3RQb2ludHNPbkJlemllciA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9pc0FsbW9zdEZsYXQgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIHZhciBfZ2V0QmJveCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9nZXRQYWRkaW5nID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICB2YXIgX2ZpdFRvQ29udGVudCA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9zZXRNaW5EaW1zID0gLyojX19QVVJFX18qL25ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBjbGFzcyBJbmtFZGl0b3IgZXh0ZW5kcyBfZWRpdG9yLkFubm90YXRpb25FZGl0b3IgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtcykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcih7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAuLi5wYXJhbXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiAiaW5rRWRpdG9yIgogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRNaW5EaW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9maXRUb0NvbnRlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2dldFBhZGRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2dldEJib3gpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2lzQWxtb3N0RmxhdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZXh0cmFjdFBvaW50c09uQmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXJpYWxpemVQYXRocyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfdXBkYXRlVHJhbnNmb3JtKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRTY2FsZUZhY3Rvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc2V0Q2FudmFzRGltcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfY3JlYXRlT2JzZXJ2ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2NyZWF0ZUNhbnZhcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZW5kRHJhd2luZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfcmVkcmF3KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zdG9wRHJhd2luZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfZHJhdyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc3RhcnREcmF3aW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF9zZXRTdHJva2UpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2dldEluaXRpYWxCQm94KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF91cGRhdGVPcGFjaXR5KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEluaXRTcGVjKHRoaXMsIF91cGRhdGVDb2xvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfdXBkYXRlVGhpY2tuZXNzKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2FzcGVjdFJhdGlvLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYmFzZUhlaWdodCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2Jhc2VXaWR0aCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kQ2FudmFzUG9pbnRlcm1vdmUsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY2FudmFzUG9pbnRlcm1vdmUuYmluZCh0aGlzKQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2JvdW5kQ2FudmFzUG9pbnRlcmxlYXZlLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLmNhbnZhc1BvaW50ZXJsZWF2ZS5iaW5kKHRoaXMpCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVydXAsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdyaXRhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuY2FudmFzUG9pbnRlcnVwLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJkb3duLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0aGlzLmNhbnZhc1BvaW50ZXJkb3duLmJpbmQodGhpcykKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9kaXNhYmxlRWRpdGluZywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEluaXRTcGVjKHRoaXMsIF9pc0NhbnZhc0luaXRpYWxpemVkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX2xhc3RQb2ludCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogbnVsbAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX29ic2VydmVyLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcmVhbFdpZHRoLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiAwCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRJbml0U3BlYyh0aGlzLCBfcmVhbEhlaWdodCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogMAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkSW5pdFNwZWModGhpcywgX3JlcXVlc3RGcmFtZUNhbGxiYWNrLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0YWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBudWxsCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbG9yID0gcGFyYW1zLmNvbG9yIHx8IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGhpY2tuZXNzID0gcGFyYW1zLnRoaWNrbmVzcyB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wYWNpdHkgPSBwYXJhbXMub3BhY2l0eSB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhdGhzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmV6aWVyUGF0aDJEID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudFBhdGggPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zY2FsZUZhY3RvciA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNsYXRpb25YID0gdGhpcy50cmFuc2xhdGlvblkgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnkgPSAwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgaW5pdGlhbGl6ZShsMTBuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2wxMG5Qcm9taXNlID0gbmV3IE1hcChbImVkaXRvcl9pbmtfY2FudmFzX2FyaWFfbGFiZWwiLCAiZWRpdG9yX2luazJfYXJpYV9sYWJlbCJdLm1hcChzdHIgPT4gW3N0ciwgbDEwbi5nZXQoc3RyKV0pKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHVwZGF0ZURlZmF1bHRQYXJhbXModHlwZSwgdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19USElDS05FU1M6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSW5rRWRpdG9yLl9kZWZhdWx0VGhpY2tuZXNzID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19DT0xPUjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbmtFZGl0b3IuX2RlZmF1bHRDb2xvciA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfT1BBQ0lUWToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJbmtFZGl0b3IuX2RlZmF1bHRPcGFjaXR5ID0gdmFsdWUgLyAxMDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlUGFyYW1zKHR5cGUsIHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfVEhJQ0tORVNTOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3VwZGF0ZVRoaWNrbmVzcywgX3VwZGF0ZVRoaWNrbmVzczIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfQ09MT1I6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlQ29sb3IsIF91cGRhdGVDb2xvcjIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfT1BBQ0lUWToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF91cGRhdGVPcGFjaXR5LCBfdXBkYXRlT3BhY2l0eTIpLmNhbGwodGhpcywgdmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBnZXQgZGVmYXVsdFByb3BlcnRpZXNUb1VwZGF0ZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtbX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuSU5LX1RISUNLTkVTUywgSW5rRWRpdG9yLl9kZWZhdWx0VGhpY2tuZXNzXSwgW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19DT0xPUiwgSW5rRWRpdG9yLl9kZWZhdWx0Q29sb3IgfHwgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9kZWZhdWx0TGluZUNvbG9yXSwgW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19PUEFDSVRZLCBNYXRoLnJvdW5kKElua0VkaXRvci5fZGVmYXVsdE9wYWNpdHkgKiAxMDApXV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGdldCBwcm9wZXJ0aWVzVG9VcGRhdGUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19USElDS05FU1MsIHRoaXMudGhpY2tuZXNzIHx8IElua0VkaXRvci5fZGVmYXVsdFRoaWNrbmVzc10sIFtfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfQ09MT1IsIHRoaXMuY29sb3IgfHwgSW5rRWRpdG9yLl9kZWZhdWx0Q29sb3IgfHwgX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9kZWZhdWx0TGluZUNvbG9yXSwgW191dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19PUEFDSVRZLCBNYXRoLnJvdW5kKDEwMCAqICh0aGlzLm9wYWNpdHkgPz8gSW5rRWRpdG9yLl9kZWZhdWx0T3BhY2l0eSkpXV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlYnVpbGQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyLnJlYnVpbGQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGl2ID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmNhbnZhcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlQ2FudmFzLCBfY3JlYXRlQ2FudmFzMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2NyZWF0ZU9ic2VydmVyLCBfY3JlYXRlT2JzZXJ2ZXIyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0F0dGFjaGVkVG9ET00pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmFkZCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldENhbnZhc0RpbXMsIF9zZXRDYW52YXNEaW1zMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9maXRUb0NvbnRlbnQsIF9maXRUb0NvbnRlbnQyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW1vdmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmNhbnZhcyA9PT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29tbWl0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMud2lkdGggPSB0aGlzLmNhbnZhcy5oZWlnaHQgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX29ic2VydmVyKS5kaXNjb25uZWN0KCk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfb2JzZXJ2ZXIsIG51bGwpOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0UGFyZW50KHBhcmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMucGFyZW50ICYmIHBhcmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fdWlNYW5hZ2VyLnJlbW92ZVNob3VsZFJlc2NhbGUodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5wYXJlbnQgJiYgcGFyZW50ID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl91aU1hbmFnZXIuYWRkU2hvdWxkUmVzY2FsZSh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5zZXRQYXJlbnQocGFyZW50KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25TY2FsZUNoYW5naW5nKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFyZW50V2lkdGgsIHBhcmVudEhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gdGhpcy53aWR0aCAqIHBhcmVudFdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSB0aGlzLmhlaWdodCAqIHBhcmVudEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1lbnNpb25zKHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBlbmFibGVFZGl0TW9kZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGlzYWJsZUVkaXRpbmcpIHx8IHRoaXMuY2FudmFzID09PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIuZW5hYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuZHJhZ2dhYmxlID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmFkZEV2ZW50TGlzdGVuZXIoInBvaW50ZXJkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJkb3duKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmFkZEV2ZW50TGlzdGVuZXIoInBvaW50ZXJ1cCIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVydXApKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZGlzYWJsZUVkaXRNb2RlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaXNJbkVkaXRNb2RlKCkgfHwgdGhpcy5jYW52YXMgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5kaXNhYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuZHJhZ2dhYmxlID0gIXRoaXMuaXNFbXB0eSgpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QucmVtb3ZlKCJlZGl0aW5nIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJkb3duIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJkb3duKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJ1cCIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVydXApKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgb25jZUFkZGVkKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5kcmFnZ2FibGUgPSAhdGhpcy5pc0VtcHR5KCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlzRW1wdHkoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnBhdGhzLmxlbmd0aCA9PT0gMCB8fCB0aGlzLnBhdGhzLmxlbmd0aCA9PT0gMSAmJiB0aGlzLnBhdGhzWzBdLmxlbmd0aCA9PT0gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29tbWl0KCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kaXNhYmxlRWRpdGluZykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdXBlci5jb21taXQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc0VkaXRpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXNhYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRJbkZvcmVncm91bmQoKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9kaXNhYmxlRWRpdGluZywgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmNsYXNzTGlzdC5hZGQoImRpc2FibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2ZpdFRvQ29udGVudCwgX2ZpdFRvQ29udGVudDIpLmNhbGwodGhpcywgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFyZW50LmFkZElua0VkaXRvcklmTmVlZGVkKHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhcmVudC5tb3ZlRWRpdG9ySW5ET00odGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmZvY3VzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByZXZlbnRTY3JvbGw6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZvY3VzaW4oZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIuZm9jdXNpbihldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlRWRpdE1vZGUoKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FudmFzUG9pbnRlcmRvd24oZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV2ZW50LmJ1dHRvbiAhPT0gMCB8fCAhdGhpcy5pc0luRWRpdE1vZGUoKSB8fCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Rpc2FibGVFZGl0aW5nKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SW5Gb3JlZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC50eXBlICE9PSAibW91c2UiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5mb2N1cygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnN0b3BQcm9wYWdhdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5hZGRFdmVudExpc3RlbmVyKCJwb2ludGVybGVhdmUiLCBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2JvdW5kQ2FudmFzUG9pbnRlcmxlYXZlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmFkZEV2ZW50TGlzdGVuZXIoInBvaW50ZXJtb3ZlIiwgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9ib3VuZENhbnZhc1BvaW50ZXJtb3ZlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3N0YXJ0RHJhd2luZywgX3N0YXJ0RHJhd2luZzIpLmNhbGwodGhpcywgZXZlbnQub2Zmc2V0WCwgZXZlbnQub2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbnZhc1BvaW50ZXJtb3ZlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnN0b3BQcm9wYWdhdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9kcmF3LCBfZHJhdzIpLmNhbGwodGhpcywgZXZlbnQub2Zmc2V0WCwgZXZlbnQub2Zmc2V0WSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNhbnZhc1BvaW50ZXJ1cChldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQuYnV0dG9uICE9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuaXNJbkVkaXRNb2RlKCkgJiYgdGhpcy5jdXJyZW50UGF0aC5sZW5ndGggIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnN0b3BQcm9wYWdhdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZW5kRHJhd2luZywgX2VuZERyYXdpbmcyKS5jYWxsKHRoaXMsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SW5CYWNrZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY2FudmFzUG9pbnRlcmxlYXZlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2VuZERyYXdpbmcsIF9lbmREcmF3aW5nMikuY2FsbCh0aGlzLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SW5CYWNrZ3JvdW5kKCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGl2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJhc2VYLCBiYXNlWTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMud2lkdGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJhc2VYID0gdGhpcy54OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmFzZVkgPSB0aGlzLnk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIucmVuZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIElua0VkaXRvci5fbDEwblByb21pc2UuZ2V0KCJlZGl0b3JfaW5rMl9hcmlhX2xhYmVsIikudGhlbihtc2cgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoX3RoaXMkZGl2ID0gdGhpcy5kaXYpID09PSBudWxsIHx8IF90aGlzJGRpdiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkZGl2LnNldEF0dHJpYnV0ZSgiYXJpYS1sYWJlbCIsIG1zZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbeCwgeSwgdywgaF0gPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9nZXRJbml0aWFsQkJveCwgX2dldEluaXRpYWxCQm94MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRBdCh4LCB5LCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1zKHcsIGgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jcmVhdGVDYW52YXMsIF9jcmVhdGVDYW52YXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy53aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhcmVudFdpZHRoLCBwYXJlbnRIZWlnaHRdID0gdGhpcy5wYXJlbnREaW1lbnNpb25zOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRBdChiYXNlWCAqIHBhcmVudFdpZHRoLCBiYXNlWSAqIHBhcmVudEhlaWdodCwgdGhpcy53aWR0aCAqIHBhcmVudFdpZHRoLCB0aGlzLmhlaWdodCAqIHBhcmVudEhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX2lzQ2FudmFzSW5pdGlhbGl6ZWQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0Q2FudmFzRGltcywgX3NldENhbnZhc0RpbXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1zKHRoaXMud2lkdGggKiBwYXJlbnRXaWR0aCwgdGhpcy5oZWlnaHQgKiBwYXJlbnRIZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVkcmF3LCBfcmVkcmF3MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldE1pbkRpbXMsIF9zZXRNaW5EaW1zMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGl2LmNsYXNzTGlzdC5hZGQoImRpc2FibGVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRpdi5jbGFzc0xpc3QuYWRkKCJlZGl0aW5nIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuYWJsZUVkaXRNb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlT2JzZXJ2ZXIsIF9jcmVhdGVPYnNlcnZlcjIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmRpdjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0RGltZW5zaW9ucyh3aWR0aCwgaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvdW5kZWRXaWR0aCA9IE1hdGgucm91bmQod2lkdGgpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByb3VuZGVkSGVpZ2h0ID0gTWF0aC5yb3VuZChoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZWFsV2lkdGgpID09PSByb3VuZGVkV2lkdGggJiYgX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZWFsSGVpZ2h0KSA9PT0gcm91bmRlZEhlaWdodCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfcmVhbFdpZHRoLCByb3VuZGVkV2lkdGgpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3JlYWxIZWlnaHQsIHJvdW5kZWRIZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5zdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FzcGVjdFJhdGlvKSAmJiBNYXRoLmFicyhfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2FzcGVjdFJhdGlvKSAtIHdpZHRoIC8gaGVpZ2h0KSA+IDFlLTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodCA9IE1hdGguY2VpbCh3aWR0aCAvIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RGltcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbcGFyZW50V2lkdGgsIHBhcmVudEhlaWdodF0gPSB0aGlzLnBhcmVudERpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMud2lkdGggPSB3aWR0aCAvIHBhcmVudFdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmhlaWdodCA9IGhlaWdodCAvIHBhcmVudEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfZGlzYWJsZUVkaXRpbmcpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRTY2FsZUZhY3RvciwgX3NldFNjYWxlRmFjdG9yMikuY2FsbCh0aGlzLCB3aWR0aCwgaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRDYW52YXNEaW1zLCBfc2V0Q2FudmFzRGltczIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnN0eWxlLnZpc2liaWxpdHkgPSAidmlzaWJsZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZml4RGltcygpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgZGVzZXJpYWxpemUoZGF0YSwgcGFyZW50LCB1aU1hbmFnZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWRpdG9yID0gc3VwZXIuZGVzZXJpYWxpemUoZGF0YSwgcGFyZW50LCB1aU1hbmFnZXIpOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3IudGhpY2tuZXNzID0gZGF0YS50aGlja25lc3M7CiAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5jb2xvciA9IF91dGlsLlV0aWwubWFrZUhleENvbG9yKC4uLmRhdGEuY29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICBlZGl0b3Iub3BhY2l0eSA9IGRhdGEub3BhY2l0eTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3BhZ2VXaWR0aCwgcGFnZUhlaWdodF0gPSBlZGl0b3IucGFnZURpbWVuc2lvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gZWRpdG9yLndpZHRoICogcGFnZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBlZGl0b3IuaGVpZ2h0ICogcGFnZUhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVGYWN0b3IgPSBlZGl0b3IucGFyZW50U2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZGRpbmcgPSBkYXRhLnRoaWNrbmVzcyAvIDI7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9hc3BlY3RSYXRpbywgd2lkdGggLyBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQoZWRpdG9yLCBfZGlzYWJsZUVkaXRpbmcsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQoZWRpdG9yLCBfcmVhbFdpZHRoLCBNYXRoLnJvdW5kKHdpZHRoKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9yZWFsSGVpZ2h0LCBNYXRoLnJvdW5kKGhlaWdodCkpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlemllcgogICAgICAgICAgICAgICAgICAgICAgICB9IG9mIGRhdGEucGF0aHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdGggPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVkaXRvci5wYXRocy5wdXNoKHBhdGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHAwID0gc2NhbGVGYWN0b3IgKiAoYmV6aWVyWzBdIC0gcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcDEgPSBzY2FsZUZhY3RvciAqIChoZWlnaHQgLSBiZXppZXJbMV0gLSBwYWRkaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAyLCBpaSA9IGJlemllci5sZW5ndGg7IGkgPCBpaTsgaSArPSA2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDEwID0gc2NhbGVGYWN0b3IgKiAoYmV6aWVyW2ldIC0gcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDExID0gc2NhbGVGYWN0b3IgKiAoaGVpZ2h0IC0gYmV6aWVyW2kgKyAxXSAtIHBhZGRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAyMCA9IHNjYWxlRmFjdG9yICogKGJlemllcltpICsgMl0gLSBwYWRkaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMjEgPSBzY2FsZUZhY3RvciAqIChoZWlnaHQgLSBiZXppZXJbaSArIDNdIC0gcGFkZGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDMwID0gc2NhbGVGYWN0b3IgKiAoYmV6aWVyW2kgKyA0XSAtIHBhZGRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAzMSA9IHNjYWxlRmFjdG9yICogKGhlaWdodCAtIGJlemllcltpICsgNV0gLSBwYWRkaW5nKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYXRoLnB1c2goW1twMCwgcDFdLCBbcDEwLCBwMTFdLCBbcDIwLCBwMjFdLCBbcDMwLCBwMzFdXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcDAgPSBwMzA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcDEgPSBwMzE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRoMkQgPSBfY2xhc3NTdGF0aWNQcml2YXRlTWV0aG9kR2V0KHRoaXMsIElua0VkaXRvciwgX2J1aWxkUGF0aDJEKS5jYWxsKHRoaXMsIHBhdGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWRpdG9yLmJlemllclBhdGgyRC5wdXNoKHBhdGgyRCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmJveCA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQoZWRpdG9yLCBfZ2V0QmJveCwgX2dldEJib3gyKS5jYWxsKGVkaXRvcik7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldChlZGl0b3IsIF9iYXNlV2lkdGgsIE1hdGgubWF4KFJFU0laRVJfU0laRSwgYmJveFsyXSAtIGJib3hbMF0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KGVkaXRvciwgX2Jhc2VIZWlnaHQsIE1hdGgubWF4KFJFU0laRVJfU0laRSwgYmJveFszXSAtIGJib3hbMV0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldChlZGl0b3IsIF9zZXRTY2FsZUZhY3RvciwgX3NldFNjYWxlRmFjdG9yMikuY2FsbChlZGl0b3IsIHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZWRpdG9yOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzZXJpYWxpemUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IHRoaXMuZ2V0UmVjdCgwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gdGhpcy5yb3RhdGlvbiAlIDE4MCA9PT0gMCA/IHJlY3RbM10gLSByZWN0WzFdIDogcmVjdFsyXSAtIHJlY3RbMF07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gX2VkaXRvci5Bbm5vdGF0aW9uRWRpdG9yLl9jb2xvck1hbmFnZXIuY29udmVydCh0aGlzLmN0eC5zdHJva2VTdHlsZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uVHlwZTogX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sb3IsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlja25lc3M6IHRoaXMudGhpY2tuZXNzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgb3BhY2l0eTogdGhpcy5vcGFjaXR5LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGF0aHM6IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NlcmlhbGl6ZVBhdGhzLCBfc2VyaWFsaXplUGF0aHMyKS5jYWxsKHRoaXMsIHRoaXMuc2NhbGVGYWN0b3IgLyB0aGlzLnBhcmVudFNjYWxlLCB0aGlzLnRyYW5zbGF0aW9uWCwgdGhpcy50cmFuc2xhdGlvblksIGhlaWdodCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlSW5kZXg6IHRoaXMucGFnZUluZGV4LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uOiB0aGlzLnJvdGF0aW9uCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZXhwb3J0cy5JbmtFZGl0b3IgPSBJbmtFZGl0b3I7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfdXBkYXRlVGhpY2tuZXNzMih0aGlja25lc3MpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBzYXZlZFRoaWNrbmVzcyA9IHRoaXMudGhpY2tuZXNzOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGhpY2tuZXNzID0gdGhpY2tuZXNzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZml0VG9Db250ZW50LCBfZml0VG9Db250ZW50MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgdW5kbzogKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50aGlja25lc3MgPSBzYXZlZFRoaWNrbmVzczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2ZpdFRvQ29udGVudCwgX2ZpdFRvQ29udGVudDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RFeGVjOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZS5JTktfVEhJQ0tORVNTLAogICAgICAgICAgICAgICAgICAgICAgICBvdmVyd3JpdGVJZlNhbWVUeXBlOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICBrZWVwVW5kbzogdHJ1ZQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3VwZGF0ZUNvbG9yMihjb2xvcikgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHNhdmVkQ29sb3IgPSB0aGlzLmNvbG9yOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29sb3IgPSBjb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgIHVuZG86ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29sb3IgPSBzYXZlZENvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVkcmF3LCBfcmVkcmF3MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgbXVzdEV4ZWM6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IF91dGlsLkFubm90YXRpb25FZGl0b3JQYXJhbXNUeXBlLklOS19DT0xPUiwKICAgICAgICAgICAgICAgICAgICAgICAgb3ZlcndyaXRlSWZTYW1lVHlwZTogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAga2VlcFVuZG86IHRydWUKICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF91cGRhdGVPcGFjaXR5MihvcGFjaXR5KSB7CiAgICAgICAgICAgICAgICAgICAgb3BhY2l0eSAvPSAxMDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRPcGFjaXR5ID0gdGhpcy5vcGFjaXR5OwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3BhY2l0eSA9IG9wYWNpdHk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZWRyYXcsIF9yZWRyYXcyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICB1bmRvOiAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm9wYWNpdHkgPSBzYXZlZE9wYWNpdHk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9yZWRyYXcsIF9yZWRyYXcyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICBtdXN0RXhlYzogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogX3V0aWwuQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUuSU5LX09QQUNJVFksCiAgICAgICAgICAgICAgICAgICAgICAgIG92ZXJ3cml0ZUlmU2FtZVR5cGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgIGtlZXBVbmRvOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZ2V0SW5pdGlhbEJCb3gyKCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50Um90YXRpb24sCiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmVudERpbWVuc2lvbnM6IFt3aWR0aCwgaGVpZ2h0XQogICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgIHN3aXRjaCAocGFyZW50Um90YXRpb24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSA5MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbMCwgaGVpZ2h0LCBoZWlnaHQsIHdpZHRoXTsKICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAxODA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3dpZHRoLCBoZWlnaHQsIHdpZHRoLCBoZWlnaHRdOwogICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDI3MDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbd2lkdGgsIDAsIGhlaWdodCwgd2lkdGhdOwogICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFswLCAwLCB3aWR0aCwgaGVpZ2h0XTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0U3Ryb2tlMigpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgIGN0eCwKICAgICAgICAgICAgICAgICAgICAgICAgY29sb3IsCiAgICAgICAgICAgICAgICAgICAgICAgIG9wYWNpdHksCiAgICAgICAgICAgICAgICAgICAgICAgIHRoaWNrbmVzcywKICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50U2NhbGUsCiAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlRmFjdG9yCiAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVXaWR0aCA9IHRoaWNrbmVzcyAqIHBhcmVudFNjYWxlIC8gc2NhbGVGYWN0b3I7CiAgICAgICAgICAgICAgICAgICAgY3R4LmxpbmVDYXAgPSAicm91bmQiOwogICAgICAgICAgICAgICAgICAgIGN0eC5saW5lSm9pbiA9ICJyb3VuZCI7CiAgICAgICAgICAgICAgICAgICAgY3R4Lm1pdGVyTGltaXQgPSAxMDsKICAgICAgICAgICAgICAgICAgICBjdHguc3Ryb2tlU3R5bGUgPSBgJHtjb2xvcn0keygwLCBfdG9vbHMub3BhY2l0eVRvSGV4KShvcGFjaXR5KX1gOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3N0YXJ0RHJhd2luZzIoeCwgeSkgewogICAgICAgICAgICAgICAgICAgIHRoaXMuaXNFZGl0aW5nID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICBpZiAoIV9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfaXNDYW52YXNJbml0aWFsaXplZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9pc0NhbnZhc0luaXRpYWxpemVkLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0Q2FudmFzRGltcywgX3NldENhbnZhc0RpbXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRoaWNrbmVzcyB8fD0gSW5rRWRpdG9yLl9kZWZhdWx0VGhpY2tuZXNzOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbG9yIHx8PSBJbmtFZGl0b3IuX2RlZmF1bHRDb2xvciB8fCBfZWRpdG9yLkFubm90YXRpb25FZGl0b3IuX2RlZmF1bHRMaW5lQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMub3BhY2l0eSA/Pz0gSW5rRWRpdG9yLl9kZWZhdWx0T3BhY2l0eTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50UGF0aC5wdXNoKFt4LCB5XSk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9sYXN0UG9pbnQsIG51bGwpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldFN0cm9rZSwgX3NldFN0cm9rZTIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguYmVnaW5QYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHgubW92ZVRvKHgsIHkpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfcmVxdWVzdEZyYW1lQ2FsbGJhY2ssICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX3JlcXVlc3RGcmFtZUNhbGxiYWNrKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2xhc3RQb2ludCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnNldFRyYW5zZm9ybSgxLCAwLCAwLCAxLCAwLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5jbGVhclJlY3QoMCwgMCwgdGhpcy5jYW52YXMud2lkdGgsIHRoaXMuY2FudmFzLmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eC5saW5lVG8oLi4uX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9sYXN0UG9pbnQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfbGFzdFBvaW50LCBudWxsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3R4LnN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHdpbmRvdy5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZXF1ZXN0RnJhbWVDYWxsYmFjaykpOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHdpbmRvdy5yZXF1ZXN0QW5pbWF0aW9uRnJhbWUoX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9yZXF1ZXN0RnJhbWVDYWxsYmFjaykpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2RyYXcyKHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBbbGFzdFgsIGxhc3RZXSA9IHRoaXMuY3VycmVudFBhdGguYXQoLTEpOwogICAgICAgICAgICAgICAgICAgIGlmICh4ID09PSBsYXN0WCAmJiB5ID09PSBsYXN0WSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudFBhdGgucHVzaChbeCwgeV0pOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfbGFzdFBvaW50LCBbeCwgeV0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3N0b3BEcmF3aW5nMih4LCB5KSB7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9yZXF1ZXN0RnJhbWVDYWxsYmFjaywgbnVsbCk7CiAgICAgICAgICAgICAgICAgICAgeCA9IE1hdGgubWluKE1hdGgubWF4KHgsIDApLCB0aGlzLmNhbnZhcy53aWR0aCk7CiAgICAgICAgICAgICAgICAgICAgeSA9IE1hdGgubWluKE1hdGgubWF4KHksIDApLCB0aGlzLmNhbnZhcy5oZWlnaHQpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IFtsYXN0WCwgbGFzdFldID0gdGhpcy5jdXJyZW50UGF0aC5hdCgtMSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKHggIT09IGxhc3RYIHx8IHkgIT09IGxhc3RZKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudFBhdGgucHVzaChbeCwgeV0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBsZXQgYmV6aWVyOwogICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmN1cnJlbnRQYXRoLmxlbmd0aCAhPT0gMSkgewogICAgICAgICAgICAgICAgICAgICAgICBiZXppZXIgPSAoMCwgX3BkZmpzRml0Q3VydmUuZml0Q3VydmUpKHRoaXMuY3VycmVudFBhdGgsIDMwLCBudWxsKTsKICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4eSA9IFt4LCB5XTsKICAgICAgICAgICAgICAgICAgICAgICAgYmV6aWVyID0gW1t4eSwgeHkuc2xpY2UoKSwgeHkuc2xpY2UoKSwgeHldXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGF0aDJEID0gX2NsYXNzU3RhdGljUHJpdmF0ZU1ldGhvZEdldChJbmtFZGl0b3IsIElua0VkaXRvciwgX2J1aWxkUGF0aDJEKS5jYWxsKElua0VkaXRvciwgYmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnRQYXRoLmxlbmd0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgY21kID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhdGhzLnB1c2goYmV6aWVyKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5iZXppZXJQYXRoMkQucHVzaChwYXRoMkQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJlYnVpbGQoKTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHVuZG8gPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGF0aHMucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYmV6aWVyUGF0aDJELnBvcCgpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5wYXRocy5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVtb3ZlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY2FudmFzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfY3JlYXRlQ2FudmFzLCBfY3JlYXRlQ2FudmFzMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9jcmVhdGVPYnNlcnZlciwgX2NyZWF0ZU9ic2VydmVyMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2ZpdFRvQ29udGVudCwgX2ZpdFRvQ29udGVudDIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkQ29tbWFuZHMoewogICAgICAgICAgICAgICAgICAgICAgICBjbWQsCiAgICAgICAgICAgICAgICAgICAgICAgIHVuZG8sCiAgICAgICAgICAgICAgICAgICAgICAgIG11c3RFeGVjOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfcmVkcmF3MigpIHsKICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5pc0VtcHR5KCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlVHJhbnNmb3JtLCBfdXBkYXRlVHJhbnNmb3JtMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRTdHJva2UsIF9zZXRTdHJva2UyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgY2FudmFzLAogICAgICAgICAgICAgICAgICAgICAgICBjdHgKICAgICAgICAgICAgICAgICAgICB9ID0gdGhpczsKICAgICAgICAgICAgICAgICAgICBjdHguc2V0VHJhbnNmb3JtKDEsIDAsIDAsIDEsIDAsIDApOwogICAgICAgICAgICAgICAgICAgIGN0eC5jbGVhclJlY3QoMCwgMCwgY2FudmFzLndpZHRoLCBjYW52YXMuaGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF91cGRhdGVUcmFuc2Zvcm0sIF91cGRhdGVUcmFuc2Zvcm0yKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcGF0aCBvZiB0aGlzLmJlemllclBhdGgyRCkgewogICAgICAgICAgICAgICAgICAgICAgICBjdHguc3Ryb2tlKHBhdGgpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9lbmREcmF3aW5nMihldmVudCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3N0b3BEcmF3aW5nLCBfc3RvcERyYXdpbmcyKS5jYWxsKHRoaXMsIGV2ZW50Lm9mZnNldFgsIGV2ZW50Lm9mZnNldFkpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLnJlbW92ZUV2ZW50TGlzdGVuZXIoInBvaW50ZXJsZWF2ZSIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVybGVhdmUpKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy5yZW1vdmVFdmVudExpc3RlbmVyKCJwb2ludGVybW92ZSIsIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYm91bmRDYW52YXNQb2ludGVybW92ZSkpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuYWRkVG9Bbm5vdGF0aW9uU3RvcmFnZSgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2NyZWF0ZUNhbnZhczIoKSB7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJjYW52YXMiKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy53aWR0aCA9IHRoaXMuY2FudmFzLmhlaWdodCA9IDA7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jYW52YXMuY2xhc3NOYW1lID0gImlua0VkaXRvckNhbnZhcyI7CiAgICAgICAgICAgICAgICAgICAgSW5rRWRpdG9yLl9sMTBuUHJvbWlzZS5nZXQoImVkaXRvcl9pbmtfY2FudmFzX2FyaWFfbGFiZWwiKS50aGVuKG1zZyA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRjYW52YXM7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAoX3RoaXMkY2FudmFzID0gdGhpcy5jYW52YXMpID09PSBudWxsIHx8IF90aGlzJGNhbnZhcyA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkY2FudmFzLnNldEF0dHJpYnV0ZSgiYXJpYS1sYWJlbCIsIG1zZyk7CiAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5kaXYuYXBwZW5kKHRoaXMuY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICB0aGlzLmN0eCA9IHRoaXMuY2FudmFzLmdldENvbnRleHQoIjJkIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY3JlYXRlT2JzZXJ2ZXIyKCkgewogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfb2JzZXJ2ZXIsIG5ldyBSZXNpemVPYnNlcnZlcihlbnRyaWVzID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IGVudHJpZXNbMF0uY29udGVudFJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZWN0LndpZHRoICYmIHJlY3QuaGVpZ2h0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldERpbWVuc2lvbnMocmVjdC53aWR0aCwgcmVjdC5oZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfb2JzZXJ2ZXIpLm9ic2VydmUodGhpcy5kaXYpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3NldENhbnZhc0RpbXMyKCkgewogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9pc0NhbnZhc0luaXRpYWxpemVkKSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYXJlbnRXaWR0aCwgcGFyZW50SGVpZ2h0XSA9IHRoaXMucGFyZW50RGltZW5zaW9uczsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNhbnZhcy53aWR0aCA9IE1hdGguY2VpbCh0aGlzLndpZHRoICogcGFyZW50V2lkdGgpOwogICAgICAgICAgICAgICAgICAgIHRoaXMuY2FudmFzLmhlaWdodCA9IE1hdGguY2VpbCh0aGlzLmhlaWdodCAqIHBhcmVudEhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfdXBkYXRlVHJhbnNmb3JtLCBfdXBkYXRlVHJhbnNmb3JtMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9zZXRTY2FsZUZhY3RvcjIod2lkdGgsIGhlaWdodCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZGRpbmcgPSBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9nZXRQYWRkaW5nLCBfZ2V0UGFkZGluZzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVGYWN0b3JXID0gKHdpZHRoIC0gcGFkZGluZykgLyBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Jhc2VXaWR0aCk7CiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NhbGVGYWN0b3JIID0gKGhlaWdodCAtIHBhZGRpbmcpIC8gX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9iYXNlSGVpZ2h0KTsKICAgICAgICAgICAgICAgICAgICB0aGlzLnNjYWxlRmFjdG9yID0gTWF0aC5taW4oc2NhbGVGYWN0b3JXLCBzY2FsZUZhY3RvckgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3VwZGF0ZVRyYW5zZm9ybTIoKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFkZGluZyA9IF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2dldFBhZGRpbmcsIF9nZXRQYWRkaW5nMikuY2FsbCh0aGlzKSAvIDI7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5jdHguc2V0VHJhbnNmb3JtKHRoaXMuc2NhbGVGYWN0b3IsIDAsIDAsIHRoaXMuc2NhbGVGYWN0b3IsIHRoaXMudHJhbnNsYXRpb25YICogdGhpcy5zY2FsZUZhY3RvciArIHBhZGRpbmcsIHRoaXMudHJhbnNsYXRpb25ZICogdGhpcy5zY2FsZUZhY3RvciArIHBhZGRpbmcpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2J1aWxkUGF0aDJEKGJlemllcikgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhdGgyRCA9IG5ldyBQYXRoMkQoKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBiZXppZXIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbZmlyc3QsIGNvbnRyb2wxLCBjb250cm9sMiwgc2Vjb25kXSA9IGJlemllcltpXTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgyRC5tb3ZlVG8oLi4uZmlyc3QpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHBhdGgyRC5iZXppZXJDdXJ2ZVRvKGNvbnRyb2wxWzBdLCBjb250cm9sMVsxXSwgY29udHJvbDJbMF0sIGNvbnRyb2wyWzFdLCBzZWNvbmRbMF0sIHNlY29uZFsxXSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBwYXRoMkQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2VyaWFsaXplUGF0aHMyKHMsIHR4LCB0eSwgaCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IE5VTUJFUl9PRl9QT0lOVFNfT05fQkVaSUVSX0NVUlZFID0gNDsKICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXRocyA9IFtdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZGRpbmcgPSB0aGlzLnRoaWNrbmVzcyAvIDI7CiAgICAgICAgICAgICAgICAgICAgbGV0IGJ1ZmZlciwgcG9pbnRzOwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgYmV6aWVyIG9mIHRoaXMucGF0aHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50cyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBiZXppZXIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW2ZpcnN0LCBjb250cm9sMSwgY29udHJvbDIsIHNlY29uZF0gPSBiZXppZXJbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMTAgPSBzICogKGZpcnN0WzBdICsgdHgpICsgcGFkZGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAxMSA9IGggLSBzICogKGZpcnN0WzFdICsgdHkpIC0gcGFkZGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHAyMCA9IHMgKiAoY29udHJvbDFbMF0gKyB0eCkgKyBwYWRkaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDIxID0gaCAtIHMgKiAoY29udHJvbDFbMV0gKyB0eSkgLSBwYWRkaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcDMwID0gcyAqIChjb250cm9sMlswXSArIHR4KSArIHBhZGRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwMzEgPSBoIC0gcyAqIChjb250cm9sMlsxXSArIHR5KSAtIHBhZGRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwNDAgPSBzICogKHNlY29uZFswXSArIHR4KSArIHBhZGRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwNDEgPSBoIC0gcyAqIChzZWNvbmRbMV0gKyB0eSkgLSBwYWRkaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgPT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBidWZmZXIucHVzaChwMTAsIHAxMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzLnB1c2gocDEwLCBwMTEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyLnB1c2gocDIwLCBwMjEsIHAzMCwgcDMxLCBwNDAsIHA0MSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9leHRyYWN0UG9pbnRzT25CZXppZXIsIF9leHRyYWN0UG9pbnRzT25CZXppZXIyKS5jYWxsKHRoaXMsIHAxMCwgcDExLCBwMjAsIHAyMSwgcDMwLCBwMzEsIHA0MCwgcDQxLCBOVU1CRVJfT0ZfUE9JTlRTX09OX0JFWklFUl9DVVJWRSwgcG9pbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwYXRocy5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlemllcjogYnVmZmVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gcGF0aHM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZXh0cmFjdFBvaW50c09uQmV6aWVyMihwMTAsIHAxMSwgcDIwLCBwMjEsIHAzMCwgcDMxLCBwNDAsIHA0MSwgbiwgcG9pbnRzKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX2lzQWxtb3N0RmxhdCwgX2lzQWxtb3N0RmxhdDIpLmNhbGwodGhpcywgcDEwLCBwMTEsIHAyMCwgcDIxLCBwMzAsIHAzMSwgcDQwLCBwNDEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50cy5wdXNoKHA0MCwgcDQxKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8IG4gLSAxOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdCA9IGkgLyBuOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtdCA9IDEgLSB0OwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTEwID0gdCAqIHAxMCArIG10ICogcDIwOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTExID0gdCAqIHAxMSArIG10ICogcDIxOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTIwID0gdCAqIHAyMCArIG10ICogcDMwOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcTIxID0gdCAqIHAyMSArIG10ICogcDMxOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBxMzAgPSB0ICogcDMwICsgbXQgKiBwNDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHEzMSA9IHQgKiBwMzEgKyBtdCAqIHA0MTsKICAgICAgICAgICAgICAgICAgICAgICAgcTEwID0gdCAqIHExMCArIG10ICogcTIwOwogICAgICAgICAgICAgICAgICAgICAgICBxMTEgPSB0ICogcTExICsgbXQgKiBxMjE7CiAgICAgICAgICAgICAgICAgICAgICAgIHEyMCA9IHQgKiBxMjAgKyBtdCAqIHEzMDsKICAgICAgICAgICAgICAgICAgICAgICAgcTIxID0gdCAqIHEyMSArIG10ICogcTMxOwogICAgICAgICAgICAgICAgICAgICAgICBxMTAgPSB0ICogcTEwICsgbXQgKiBxMjA7CiAgICAgICAgICAgICAgICAgICAgICAgIHExMSA9IHQgKiBxMTEgKyBtdCAqIHEyMTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9pbnRzLnB1c2gocTEwLCBxMTEpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwb2ludHMucHVzaChwNDAsIHA0MSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfaXNBbG1vc3RGbGF0MihwMTAsIHAxMSwgcDIwLCBwMjEsIHAzMCwgcDMxLCBwNDAsIHA0MSkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHRvbCA9IDEwOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGF4ID0gKDMgKiBwMjAgLSAyICogcDEwIC0gcDQwKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGF5ID0gKDMgKiBwMjEgLSAyICogcDExIC0gcDQxKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJ4ID0gKDMgKiBwMzAgLSBwMTAgLSAyICogcDQwKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGJ5ID0gKDMgKiBwMzEgLSBwMTEgLSAyICogcDQxKSAqKiAyOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBNYXRoLm1heChheCwgYngpICsgTWF0aC5tYXgoYXksIGJ5KSA8PSB0b2w7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfZ2V0QmJveDIoKSB7CiAgICAgICAgICAgICAgICAgICAgbGV0IHhNaW4gPSBJbmZpbml0eTsKICAgICAgICAgICAgICAgICAgICBsZXQgeE1heCA9IC1JbmZpbml0eTsKICAgICAgICAgICAgICAgICAgICBsZXQgeU1pbiA9IEluZmluaXR5OwogICAgICAgICAgICAgICAgICAgIGxldCB5TWF4ID0gLUluZmluaXR5OwogICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcGF0aCBvZiB0aGlzLnBhdGhzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgW2ZpcnN0LCBjb250cm9sMSwgY29udHJvbDIsIHNlY29uZF0gb2YgcGF0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmJveCA9IF91dGlsLlV0aWwuYmV6aWVyQm91bmRpbmdCb3goLi4uZmlyc3QsIC4uLmNvbnRyb2wxLCAuLi5jb250cm9sMiwgLi4uc2Vjb25kKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhNaW4gPSBNYXRoLm1pbih4TWluLCBiYm94WzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHlNaW4gPSBNYXRoLm1pbih5TWluLCBiYm94WzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhNYXggPSBNYXRoLm1heCh4TWF4LCBiYm94WzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHlNYXggPSBNYXRoLm1heCh5TWF4LCBiYm94WzNdKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gW3hNaW4sIHlNaW4sIHhNYXgsIHlNYXhdOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2dldFBhZGRpbmcyKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfY2xhc3NQcml2YXRlRmllbGRHZXQodGhpcywgX2Rpc2FibGVFZGl0aW5nKSA/IE1hdGguY2VpbCh0aGlzLnRoaWNrbmVzcyAqIHRoaXMucGFyZW50U2NhbGUpIDogMDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9maXRUb0NvbnRlbnQyKCkgewogICAgICAgICAgICAgICAgICAgIGxldCBmaXJzdFRpbWUgPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmlzRW1wdHkoKSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9kaXNhYmxlRWRpdGluZykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfcmVkcmF3LCBfcmVkcmF3MikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBiYm94ID0gX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfZ2V0QmJveCwgX2dldEJ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AgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRNaW5EaW1zLCBfc2V0TWluRGltczIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJldlRyYW5zbGF0aW9uWCA9IHRoaXMudHJhbnNsYXRpb25YOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHByZXZUcmFuc2xhdGlvblkgPSB0aGlzLnRyYW5zbGF0aW9uWTsKICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zbGF0aW9uWCA9IC1iYm94WzBdOwogICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNsYXRpb25ZID0gLWJib3hbMV07CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0Q2FudmFzRGltcywgX3NldENhbnZhc0RpbXMyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3JlZHJhdywgX3JlZHJhdzIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9yZWFsV2lkdGgsIHdpZHRoKTsKICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlRmllbGRTZXQodGhpcywgX3JlYWxIZWlnaHQsIGhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREaW1zKHdpZHRoLCBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IHVuc2NhbGVkUGFkZGluZyA9IGZpcnN0VGltZSA/IHBhZGRpbmcgLyB0aGlzLnNjYWxlRmFjdG9yIC8gMiA6IDA7CiAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2xhdGUocHJldlRyYW5zbGF0aW9uWCAtIHRoaXMudHJhbnNsYXRpb25YIC0gdW5zY2FsZWRQYWRkaW5nLCBwcmV2VHJhbnNsYXRpb25ZIC0gdGhpcy50cmFuc2xhdGlvblkgLSB1bnNjYWxlZFBhZGRpbmcpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gX3NldE1pbkRpbXMyKCkgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUKICAgICAgICAgICAgICAgICAgICB9ID0gdGhpcy5kaXY7CiAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pID49IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUubWluSGVpZ2h0ID0gYCR7UkVTSVpFUl9TSVpFfXB4YDsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUubWluV2lkdGggPSBgJHtNYXRoLnJvdW5kKF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pICogUkVTSVpFUl9TSVpFKX1weGA7CiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUubWluV2lkdGggPSBgJHtSRVNJWkVSX1NJWkV9cHhgOwogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5taW5IZWlnaHQgPSBgJHtNYXRoLnJvdW5kKFJFU0laRVJfU0laRSAvIF9jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfYXNwZWN0UmF0aW8pKX1weGA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgX2RlZmluZVByb3BlcnR5KElua0VkaXRvciwgIl9kZWZhdWx0Q29sb3IiLCBudWxsKTsKICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShJbmtFZGl0b3IsICJfZGVmYXVsdE9wYWNpdHkiLCAxKTsKICAgICAgICAgICAgICAgIF9kZWZpbmVQcm9wZXJ0eShJbmtFZGl0b3IsICJfZGVmYXVsdFRoaWNrbmVzcyIsIDEpOwogICAgICAgICAgICAgICAgX2RlZmluZVByb3BlcnR5KElua0VkaXRvciwgIl9sMTBuUHJvbWlzZSIsIHZvaWQgMCk7CiAgICAgICAgICAgICAgICBfZGVmaW5lUHJvcGVydHkoSW5rRWRpdG9yLCAiX3R5cGUiLCAiaW5rIik7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2NSAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLmZpdEN1cnZlID0gdm9pZCAwOwogICAgICAgICAgICAgICAgY29uc3QgZml0Q3VydmUgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE2Nik7CiAgICAgICAgICAgICAgICBleHBvcnRzLmZpdEN1cnZlID0gZml0Q3VydmU7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2NiAqLwogICAgICAgICAgICAvKioqLyAoKG1vZHVsZSkgPT4gewoKICAgICAgICAgICAgICAgICJ1c2Ugc3RyaWN0IjsKCgogICAgICAgICAgICAgICAgZnVuY3Rpb24gZml0Q3VydmUocG9pbnRzLCBtYXhFcnJvciwgcHJvZ3Jlc3NDYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShwb2ludHMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBUeXBlRXJyb3IoIkZpcnN0IGFyZ3VtZW50IHNob3VsZCBiZSBhbiBhcnJheSIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBwb2ludHMuZm9yRWFjaChwb2ludCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShwb2ludCkgfHwgcG9pbnQuc29tZShpdGVtID0+IHR5cGVvZiBpdGVtICE9PSAnbnVtYmVyJykgfHwgcG9pbnQubGVuZ3RoICE9PSBwb2ludHNbMF0ubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBFcnJvcigiRWFjaCBwb2ludCBzaG91bGQgYmUgYW4gYXJyYXkgb2YgbnVtYmVycy4gRWFjaCBwb2ludCBzaG91bGQgaGF2ZSB0aGUgc2FtZSBhbW91bnQgb2YgbnVtYmVycy4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHBvaW50cyA9IHBvaW50cy5maWx0ZXIoKHBvaW50LCBpKSA9PiBpID09PSAwIHx8ICFwb2ludC5ldmVyeSgodmFsLCBqKSA9PiB2YWwgPT09IHBvaW50c1tpIC0gMV1bal0pKTsKICAgICAgICAgICAgICAgICAgICBpZiAocG9pbnRzLmxlbmd0aCA8IDIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtdOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBjb25zdCBsZW4gPSBwb2ludHMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGxlZnRUYW5nZW50ID0gY3JlYXRlVGFuZ2VudChwb2ludHNbMV0sIHBvaW50c1swXSk7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgcmlnaHRUYW5nZW50ID0gY3JlYXRlVGFuZ2VudChwb2ludHNbbGVuIC0gMl0sIHBvaW50c1tsZW4gLSAxXSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZpdEN1YmljKHBvaW50cywgbGVmdFRhbmdlbnQsIHJpZ2h0VGFuZ2VudCwgbWF4RXJyb3IsIHByb2dyZXNzQ2FsbGJhY2spOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZnVuY3Rpb24gZml0Q3ViaWMocG9pbnRzLCBsZWZ0VGFuZ2VudCwgcmlnaHRUYW5nZW50LCBlcnJvciwgcHJvZ3Jlc3NDYWxsYmFjaykgewogICAgICAgICAgICAgICAgICAgIGNvbnN0IE1heEl0ZXJhdGlvbnMgPSAyMDsKICAgICAgICAgICAgICAgICAgICB2YXIgYmV6Q3VydmUsIHUsIHVQcmltZSwgbWF4RXJyb3IsIHByZXZFcnIsIHNwbGl0UG9pbnQsIHByZXZTcGxpdCwgY2VudGVyVmVjdG9yLCB0b0NlbnRlclRhbmdlbnQsIGZyb21DZW50ZXJUYW5nZW50LCBiZXppZXJzLCBkaXN0LCBpOwogICAgICAgICAgICAgICAgICAgIGlmIChwb2ludHMubGVuZ3RoID09PSAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpc3QgPSBtYXRocy52ZWN0b3JMZW4obWF0aHMuc3VidHJhY3QocG9pbnRzWzBdLCBwb2ludHNbMV0pKSAvIDMuMDsKICAgICAgICAgICAgICAgICAgICAgICAgYmV6Q3VydmUgPSBbcG9pbnRzWzBdLCBtYXRocy5hZGRBcnJheXMocG9pbnRzWzBdLCBtYXRocy5tdWxJdGVtcyhsZWZ0VGFuZ2VudCwgZGlzdCkpLCBtYXRocy5hZGRBcnJheXMocG9pbnRzWzFdLCBtYXRocy5tdWxJdGVtcyhyaWdodFRhbmdlbnQsIGRpc3QpKSwgcG9pbnRzWzFdXTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtiZXpDdXJ2ZV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHUgPSBjaG9yZExlbmd0aFBhcmFtZXRlcml6ZShwb2ludHMpOwogICAgICAgICAgICAgICAgICAgIFtiZXpDdXJ2ZSwgbWF4RXJyb3IsIHNwbGl0UG9pbnRdID0gZ2VuZXJhdGVBbmRSZXBvcnQocG9pbnRzLCB1LCB1LCBsZWZ0VGFuZ2VudCwgcmlnaHRUYW5nZW50LCBwcm9ncmVzc0NhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICBpZiAobWF4RXJyb3IgPT09IDAgfHwgbWF4RXJyb3IgPCBlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gW2JlekN1cnZlXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKG1heEVycm9yIDwgZXJyb3IgKiBlcnJvcikgewogICAgICAgICAgICAgICAgICAgICAgICB1UHJpbWUgPSB1OwogICAgICAgICAgICAgICAgICAgICAgICBwcmV2RXJyID0gbWF4RXJyb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIHByZXZTcGxpdCA9IHNwbGl0UG9pbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBNYXhJdGVyYXRpb25zOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHVQcmltZSA9IHJlcGFyYW1ldGVyaXplKGJlekN1cnZlLCBwb2ludHMsIHVQcmltZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBbYmV6Q3VydmUsIG1heEVycm9yLCBzcGxpdFBvaW50XSA9IGdlbmVyYXRlQW5kUmVwb3J0KHBvaW50cywgdSwgdVByaW1lLCBsZWZ0VGFuZ2VudCwgcmlnaHRUYW5nZW50LCBwcm9ncmVzc0NhbGxiYWNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXhFcnJvciA8IGVycm9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFtiZXpDdXJ2ZV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHNwbGl0UG9pbnQgPT09IHByZXZTcGxpdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBlcnJDaGFuZ2UgPSBtYXhFcnJvciAvIHByZXZFcnI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVyckNoYW5nZSA+IC45OTk5ICYmIGVyckNoYW5nZSA8IDEuMDAwMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2RXJyID0gbWF4RXJyb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2U3BsaXQgPSBzcGxpdFBvaW50OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGJlemllcnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICBjZW50ZXJWZWN0b3IgPSBtYXRocy5zdWJ0cmFjdChwb2ludHNbc3BsaXRQb2ludCAtIDFdLCBwb2ludHNbc3BsaXRQb2ludCArIDFdKTsKICAgICAgICAgICAgICAgICAgICBpZiAoY2VudGVyVmVjdG9yLmV2ZXJ5KHZhbCA9PiB2YWwgPT09IDApKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNlbnRlclZlY3RvciA9IG1hdGhzLnN1YnRyYWN0KHBvaW50c1tzcGxpdFBvaW50IC0gMV0sIHBvaW50c1tzcGxpdFBvaW50XSk7CiAgICAgICAgICAgICAgICAgICAgICAgIFtjZW50ZXJWZWN0b3JbMF0sIGNlbnRlclZlY3RvclsxXV0gPSBbLWNlbnRlclZlY3RvclsxXSwgY2VudGVyVmVjdG9yWzBdXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdG9DZW50ZXJUYW5nZW50ID0gb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mFtc09yaWcpOwogICAgICAgICAgICAgICAgICAgIGlmIChwcm9ncmVzc0NhbGxiYWNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHByb2dyZXNzQ2FsbGJhY2soewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmV6OiBiZXpDdXJ2ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50czogcG9pbnRzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFyYW1zOiBwYXJhbXNPcmlnLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWF4RXJyOiBtYXhFcnJvciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1heFBvaW50OiBzcGxpdFBvaW50CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gW2JlekN1cnZlLCBtYXhFcnJvciwgc3BsaXRQb2ludF07CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZW5lcmF0ZUJlemllcihwb2ludHMsIHBhcmFtZXRlcnMsIGxlZnRUYW5nZW50LCByaWdodFRhbmdlbnQpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgYmV6Q3VydmUsCiAgICAgICAgICAgICAgICAgICAgICAgIEEsCiAgICAgICAgICAgICAgICAgICAgICAgIGEsCiAgICAgICAgICAgICAgICAgICAgICAgIEMsCiAgICAgICAgICAgICAgICAgICAgICAgIFgsCiAgICAgICAgICAgICAgICAgICAgICAgIGRldF9DMF9DMSwKICAgICAgICAgICAgICAgICAgICAgICAgZGV0X0MwX1gsCiAgICAgICAgICAgICAgICAgICAgICAgIGRldF9YX0MxLAogICAgICAgICAgICAgICAgICAgICAgICBhbHBoYV9sLAogICAgICAgICAgICAgICAgICAgICAgICBhbHBoYV9yLAogICAgICAgICAgICAgICAgICAgICAgICBlcHNpbG9uLAogICAgICAgICAgICAgICAgICAgICAgICBzZWdMZW5ndGgsCiAgICAgICAgICAgICAgICAgICAgICAgIGksCiAgICAgICAgICAgICAgICAgICAgICAgIGxlbiwKICAgICAgICAgICAgICAgICAgICAgICAgdG1wLAogICAgICAgICAgICAgICAgICAgICAgICB1LAogICAgICAgICAgICAgICAgICAgICAgICB1eCwKICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3RQb2ludCA9IHBvaW50c1swXSwKICAgICAgICAgICAgICAgICAgICAgICAgbGFzdFBvaW50ID0gcG9pbnRzW3BvaW50cy5sZW5ndGggLSAxXTsKICAgICAgICAgICAgICAgICAgICBiZXpDdXJ2ZSA9IFtmaXJzdFBvaW50LCBudWxsLCBudWxsLCBsYXN0UG9pbnRdOwogICAgICAgICAgICAgICAgICAgIEEgPSBtYXRocy56ZXJvc19YeDJ4MihwYXJhbWV0ZXJzLmxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgZm9yIChpID0gMCwgbGVuID0gcGFyYW1ldGVycy5sZW5ndGg7IGkgPCBsZW47IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICB1ID0gcGFyYW1ldGVyc1tpXTsKICAgICAgICAgICAgICAgICAgICAgICAgdXggPSAxIC0gdTsKICAgICAgICAgICAgICAgICAgICAgICAgYSA9IEFbaV07CiAgICAgICAgICAgICAgICAgICAgICAgIGFbMF0gPSBtYXRocy5tdWxJdGVtcyhsZWZ0VGFuZ2VudCwgMyAqIHUgKiAodXggKiB1eCkpOwogICAgICAgICAgICAgICAgICAgICAgICBhWzFdID0gbWF0aHMubXVsSXRlbXMocmlnaHRUYW5nZW50LCAzICogdXggKiAodSAqIHUpKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgQyA9IFtbMCwgMF0sIFswLCAwXV07CiAgICAgICAgICAgICAgICAgICAgWCA9IFswLCAwXTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBsZW4gPSBwb2ludHMubGVuZ3RoOyBpIDwgbGVuOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgdSA9IHBhcmFtZXRlcnNbaV07CiAgICAgICAgICAgICAgICAgICAgICAgIGEgPSBBW2ldOwogICAgICAgICAgICAgICAgICAgICAgICBDWzBdWzBdICs9IG1hdGhzLmRvdChhWzBdLCBhWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgQ1swXVsxXSArPSBtYXRocy5kb3QoYVswXSwgYVsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIENbMV1bMF0gKz0gbWF0aHMuZG90KGFbMF0sIGFbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICBDWzFdWzFdICs9IG1hdGhzLmRvdChhWzFdLCBhWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgdG1wID0gbWF0aHMuc3VidHJhY3QocG9pbnRzW2ldLCBiZXppZXIucShbZmlyc3RQb2ludCwgZmlyc3RQb2ludCwgbGFzdFBvaW50LCBsYXN0UG9pbnRdLCB1KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIFhbMF0gKz0gbWF0aHMuZG90KGFbMF0sIHRtcCk7CiAgICAgICAgICAgICAgICAgICAgICAgIFhbMV0gKz0gbWF0aHMuZG90KGFbMV0sIHRtcCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGRldF9DMF9DMSA9IENbMF1bMF0gKiBDWzFdWzFdIC0gQ1sxXVswXSAqIENbMF1bMV07CiAgICAgICAgICAgICAgICAgICAgZGV0X0MwX1ggPSBDWzBdWzBdICogWFsxXSAtIENbMV1bMF0gKiBYWzBdOwogICAgICAgICAgICAgICAgICAgIGRldF9YX0MxID0gWFswXSAqIENbMV1bMV0gLSBYWzFdICogQ1swXVsxXTsKICAgICAgICAgICAgICAgICAgICBhbHBoYV9sID0gZGV0X0MwX0MxID09PSAwID8gMCA6IGRldF9YX0MxIC8gZGV0X0MwX0MxOwogICAgICAgICAgICAgICAgICAgIGFscGhhX3IgPSBkZXRfQzBfQzEgPT09IDAgPyAwIDogZGV0X0MwX1ggLyBkZXRfQzBfQzE7CiAgICAgICAgICAgICAgICAgICAgc2VnTGVuZ3RoID0gbWF0aHMudmVjdG9yTGVuKG1hdGhzLnN1YnRyYWN0KGZpcnN0UG9pbnQsIGxhc3RQb2ludCkpOwogICAgICAgICAgICAgICAgICAgIGVwc2lsb24gPSAxLjBlLTYgKiBzZWdMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgaWYgKGFscGhhX2wgPCBlcHNpbG9uIHx8IGFscGhhX3IgPCBlcHNpbG9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJlekN1cnZlWzFdID0gbWF0aHMuYWRkQXJyYXlzKGZpcnN0UG9pbnQsIG1hdGhzLm11bEl0ZW1zKGxlZnRUYW5nZW50LCBzZWdMZW5ndGggLyAzLjApKTsKICAgICAgICAgICAgICAgICAgICAgICAgYmV6Q3VydmVbMl0gPSBtYXRocy5hZGRBcnJheXMobGFzdFBvaW50LCBtYXRocy5tdWxJdGVtcyhyaWdodFRhbmdlbnQsIHNlZ0xlbmd0aCAvIDMuMCkpOwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGJlekN1cnZlWzFdID0gbWF0aHMuYWRkQXJyYXlzKGZpcnN0UG9pbnQsIG1hdGhzLm11bEl0ZW1zKGxlZnRUYW5nZW50LCBhbHBoYV9sKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGJlekN1cnZlWzJdID0gbWF0aHMuYWRkQXJyYXlzKGxhc3RQb2ludCwgbWF0aHMubXVsSXRlbXMocmlnaHRUYW5nZW50LCBhbHBoYV9yKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJldHVybiBiZXpDdXJ2ZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHJlcGFyYW1ldGVyaXplKGJlemllciwgcG9pbnRzLCBwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHBhcmFtZXRlcnMubWFwKChwLCBpKSA9PiBuZXd0b25SYXBoc29uUm9vdEZpbmQoYmV6aWVyLCBwb2ludHNbaV0sIHApKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG5ld3RvblJhcGhzb25Sb290RmluZChiZXosIHBvaW50LCB1KSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIGQgPSBtYXRocy5zdWJ0cmFjdChiZXppZXIucShiZXosIHUpLCBwb2ludCksCiAgICAgICAgICAgICAgICAgICAgICAgIHFwcmltZSA9IGJlemllci5xcHJpbWUoYmV6LCB1KSwKICAgICAgICAgICAgICAgICAgICAgICAgbnVtZXJhdG9yID0gbWF0aHMubXVsTWF0cml4KGQsIHFwcmltZSksCiAgICAgICAgICAgICAgICAgICAgICAgIGRlbm9taW5hdG9yID0gbWF0aHMuc3VtKG1hdGhzLnNxdWFyZUl0ZW1zKHFwcmltZSkpICsgMiAqIG1hdGhzLm11bE1hdHJpeChkLCBiZXppZXIucXByaW1lcHJpbWUoYmV6LCB1KSk7CiAgICAgICAgICAgICAgICAgICAgaWYgKGRlbm9taW5hdG9yID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1OwogICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB1IC0gbnVtZXJhdG9yIC8gZGVub21pbmF0b3I7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gY2hvcmRMZW5ndGhQYXJhbWV0ZXJpemUocG9pbnRzKSB7CiAgICAgICAgICAgICAgICAgICAgdmFyIHUgPSBbXSwKICAgICAgICAgICAgICAgICAgICAgICAgY3VyclUsCiAgICAgICAgICAgICAgICAgICAgICAgIHByZXZVLAogICAgICAgICAgICAgICAgICAgICAgICBwcmV2UDsKICAgICAgICAgICAgICAgICAgICBwb2ludHMuZm9yRWFjaCgocCwgaSkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICBjdXJyVSA9IGkgPyBwcmV2VSArIG1hdGhzLnZlY3RvckxlbihtYXRocy5zdWJ0cmFjdChwLCBwcmV2UCkpIDogMDsKICAgICAgICAgICAgICAgICAgICAgICAgdS5wdXNoKGN1cnJVKTsKICAgICAgICAgICAgICAgICAgICAgICAgcHJldlUgPSBjdXJyVTsKICAgICAgICAgICAgICAgICAgICAgICAgcHJldlAgPSBwOwogICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIHUgPSB1Lm1hcCh4ID0+IHggLyBwcmV2VSk7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICA7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjb21wdXRlTWF4RXJyb3IocG9pbnRzLCBiZXosIHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgZGlzdCwgbWF4RGlzdCwgc3BsaXRQb2ludCwgdiwgaSwgY291bnQsIHBvaW50LCB0OwogICAgICAgICAgICAgICAgICAgIG1heERpc3QgPSAwOwogICAgICAgICAgICAgICAgICAgIHNwbGl0UG9pbnQgPSBNYXRoLmZsb29yKHBvaW50cy5sZW5ndGggLyAyKTsKICAgICAgICAgICAgICAgICAgICBjb25zdCB0X2Rpc3RNYXAgPSBtYXBUdG9SZWxhdGl2ZURpc3RhbmNlcyhiZXosIDEwKTsKICAgICAgICAgICAgICAgICAgICBmb3IgKGkgPSAwLCBjb3VudCA9IHBvaW50cy5sZW5ndGg7IGkgPCBjb3VudDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50ID0gcG9pbnRzW2ldOwogICAgICAgICAgICAgICAgICAgICAgICB0ID0gZmluZF90KGJleiwgcGFyYW1ldGVyc1tpXSwgdF9kaXN0TWFwLCAxMCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHYgPSBtYXRocy5zdWJ0cmFjdChiZXppZXIucShiZXosIHQpLCBwb2ludCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGRpc3QgPSB2WzBdICogdlswXSArIHZbMV0gKiB2WzFdOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGlzdCA+IG1heERpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1heERpc3QgPSBkaXN0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3BsaXRQb2ludCA9IGk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFttYXhEaXN0LCBzcGxpdFBvaW50XTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIDsKICAgICAgICAgICAgICAgIHZhciBtYXBUdG9SZWxhdGl2ZURpc3RhbmNlcyA9IGZ1bmN0aW9uIChiZXosIEJfcGFydHMpIHsKICAgICAgICAgICAgICAgICAgICB2YXIgQl90X2N1cnI7CiAgICAgICAgICAgICAgICAgICAgdmFyIEJfdF9kaXN0ID0gWzBdOwogICAgICAgICAgICAgICAgICAgIHZhciBCX3RfcHJldiA9IGJlelswXTsKICAgICAgICAgICAgICAgICAgICB2YXIgc3VtTGVuID0gMDsKICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMTsgaSA8PSBCX3BhcnRzOyBpKyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgQl90X2N1cnIgPSBiZXppZXIucShiZXosIGkgLyBCX3BhcnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VtTGVuICs9IG1hdGhzLnZlY3RvckxlbihtYXRocy5zdWJ0cmFjdChCX3RfY3VyciwgQl90X3ByZXYpKTsKICAgICAgICAgICAgICAgICAgICAgICAgQl90X2Rpc3QucHVzaChzdW1MZW4pOwogICAgICAgICAgICAgICAgICAgICAgICBCX3RfcHJldiA9IEJfdF9jdXJyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBCX3RfZGlzdCA9IEJfdF9kaXN0Lm1hcCh4ID0+IHggLyBzdW1MZW4pOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBCX3RfZGlzdDsKICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBmaW5kX3QoYmV6LCBwYXJhbSwgdF9kaXN0TWFwLCBCX3BhcnRzKSB7CiAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmFtIDwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmFtID4gMSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gMTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgdmFyIGxlbk1heCwgbGVuTWluLCB0TWF4LCB0TWluLCB0OwogICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAxOyBpIDw9IEJfcGFydHM7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFyYW0gPD0gdF9kaXN0TWFwW2ldKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0TWluID0gKGkgLSAxKSAvIEJfcGFydHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0TWF4ID0gaSAvIEJfcGFydHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW5NaW4gPSB0X2Rpc3RNYXBbaSAtIDFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGVuTWF4ID0gdF9kaXN0TWFwW2ldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdCA9IChwYXJhbSAtIGxlbk1pbikgLyAobGVuTWF4IC0gbGVuTWluKSAqICh0TWF4IC0gdE1pbikgKyB0TWluOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBjcmVhdGVUYW5nZW50KHBvaW50QSwgcG9pbnRCKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hdGhzLm5vcm1hbGl6ZShtYXRocy5zdWJ0cmFjdChwb2ludEEsIHBvaW50QikpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgbWF0aHMgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB6ZXJvc19YeDJ4Mih4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB6cyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoeC0tKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB6cy5wdXNoKFswLCAwXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHpzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgbXVsSXRlbXMoaXRlbXMsIG11bHRpcGxpZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW1zLm1hcCh4ID0+IHggKiBtdWx0aXBsaWVyKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIG11bE1hdHJpeChtMSwgbTIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG0xLnJlZHVjZSgoc3VtLCB4MSwgaSkgPT4gc3VtICsgeDEgKiBtMltpXSwgMCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBzdWJ0cmFjdChhcnIxLCBhcnIyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBhcnIxLm1hcCgoeDEsIGkpID0+IHgxIC0gYXJyMltpXSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBhZGRBcnJheXMoYXJyMSwgYXJyMikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYXJyMS5tYXAoKHgxLCBpKSA9PiB4MSArIGFycjJbaV0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgYWRkSXRlbXMoaXRlbXMsIGFkZGl0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtcy5tYXAoeCA9PiB4ICsgYWRkaXRpb24pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgc3VtKGl0ZW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtcy5yZWR1Y2UoKHN1bSwgeCkgPT4gc3VtICsgeCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBkb3QobTEsIG0yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBtYXRocy5tdWxNYXRyaXgobTEsIG0yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHZlY3Rvckxlbih2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBNYXRoLmh5cG90KC4uLnYpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgZGl2SXRlbXMoaXRlbXMsIGRpdmlzb3IpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGl0ZW1zLm1hcCh4ID0+IHggLyBkaXZpc29yKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHNxdWFyZUl0ZW1zKGl0ZW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpdGVtcy5tYXAoeCA9PiB4ICogeCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBub3JtYWxpemUodikgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5kaXZJdGVtcyh2LCB0aGlzLnZlY3Rvckxlbih2KSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgYmV6aWVyIHsKICAgICAgICAgICAgICAgICAgICBzdGF0aWMgcShjdHJsUG9seSwgdCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgdHggPSAxLjAgLSB0OwogICAgICAgICAgICAgICAgICAgICAgICB2YXIgcEEgPSBtYXRocy5tdWxJdGVtcyhjdHJsUG9seVswXSwgdHggKiB0eCAqIHR4KSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBCID0gbWF0aHMubXVsSXRlbXMoY3RybFBvbHlbMV0sIDMgKiB0eCAqIHR4ICogdCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwQyA9IG1hdGhzLm11bEl0ZW1zKGN0cmxQb2x5WzJdLCAzICogdHggKiB0ICogdCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwRCA9IG1hdGhzLm11bEl0ZW1zKGN0cmxQb2x5WzNdLCB0ICogdCAqIHQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbWF0aHMuYWRkQXJyYXlzKG1hdGhzLmFkZEFycmF5cyhwQSwgcEIpLCBtYXRocy5hZGRBcnJheXMocEMsIHBEKSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBxcHJpbWUoY3RybFBvbHksIHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHR4ID0gMS4wIC0gdDsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHBBID0gbWF0aHMubXVsSXRlbXMobWF0aHMuc3VidHJhY3QoY3RybFBvbHlbMV0sIGN0cmxQb2x5WzBdKSwgMyAqIHR4ICogdHgpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcEIgPSBtYXRocy5tdWxJdGVtcyhtYXRocy5zdWJ0cmFjdChjdHJsUG9seVsyXSwgY3RybFBvbHlbMV0pLCA2ICogdHggKiB0KSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBDID0gbWF0aHMubXVsSXRlbXMobWF0aHMuc3VidHJhY3QoY3RybFBvbHlbM10sIGN0cmxQb2x5WzJdKSwgMyAqIHQgKiB0KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hdGhzLmFkZEFycmF5cyhtYXRocy5hZGRBcnJheXMocEEsIHBCKSwgcEMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgcXByaW1lcHJpbWUoY3RybFBvbHksIHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hdGhzLmFkZEFycmF5cyhtYXRocy5tdWxJdGVtcyhtYXRocy5hZGRBcnJheXMobWF0aHMuc3VidHJhY3QoY3RybFBvbHlbMl0sIG1hdGhzLm11bEl0ZW1zKGN0cmxQb2x5WzFdLCAyKSksIGN0cmxQb2x5WzBdKSwgNiAqICgxLjAgLSB0KSksIG1hdGhzLm11bEl0ZW1zKG1hdGhzLmFkZEFycmF5cyhtYXRocy5zdWJ0cmFjdChjdHJsUG9seVszXSwgbWF0aHMubXVsSXRlbXMoY3RybFBvbHlbMl0sIDIpKSwgY3RybFBvbHlbMV0pLCA2ICogdCkpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIG1vZHVsZS5leHBvcnRzID0gZml0Q3VydmU7CiAgICAgICAgICAgICAgICBtb2R1bGUuZXhwb3J0cy5maXRDdWJpYyA9IGZpdEN1YmljOwogICAgICAgICAgICAgICAgbW9kdWxlLmV4cG9ydHMuY3JlYXRlVGFuZ2VudCA9IGNyZWF0ZVRhbmdlbnQ7CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2NyAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkFubm90YXRpb25MYXllciA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIHZhciBfdXRpbCA9IF9fd19wZGZqc19yZXF1aXJlX18oMSk7CiAgICAgICAgICAgICAgICB2YXIgX2Rpc3BsYXlfdXRpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0Mik7CiAgICAgICAgICAgICAgICB2YXIgX2Fubm90YXRpb25fc3RvcmFnZSA9IF9fd19wZGZqc19yZXF1aXJlX18oMTM5KTsKICAgICAgICAgICAgICAgIHZhciBfc2NyaXB0aW5nX3V0aWxzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjgpOwogICAgICAgICAgICAgICAgdmFyIF94ZmFfbGF5ZXIgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE2OSk7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfY2xhc3NTdGF0aWNQcml2YXRlTWV0aG9kR2V0KHJlY2VpdmVyLCBjbGFzc0NvbnN0cnVjdG9yLCBtZXRob2QpIHsgX2NsYXNzQ2hlY2tQcml2YXRlU3RhdGljQWNjZXNzKHJlY2VpdmVyLCBjbGFzc0NvbnN0cnVjdG9yKTsgcmV0dXJu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CBERUZBVUxUX0ZPTlRfU0laRSA9IDk7CiAgICAgICAgICAgICAgICBjb25zdCBHZXRFbGVtZW50c0J5TmFtZVNldCA9IG5ldyBXZWFrU2V0KCk7CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBnZXRSZWN0RGltcyhyZWN0KSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGg6IHJlY3RbMl0gLSByZWN0WzBdLAogICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQ6IHJlY3RbM10gLSByZWN0WzFdCiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIEFubm90YXRpb25FbGVtZW50RmFjdG9yeSB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIGNyZWF0ZShwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN1YnR5cGUgPSBwYXJhbWV0ZXJzLmRhdGEuYW5ub3RhdGlvblR5cGU7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoc3VidHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5MSU5LOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgTGlua0Fubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5URVhUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgVGV4dEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5XSURHRVQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmllbGRUeXBlID0gcGFyYW1ldGVycy5kYXRhLmZpZWxkVHlwZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGZpZWxkVHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJUeCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFRleHRXaWRnZXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiQnRuIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYXJhbWV0ZXJzLmRhdGEucmFkaW9CdXR0b24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFJhZGlvQnV0dG9uV2lkZ2V0QW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHBhcmFtZXRlcnMuZGF0YS5jaGVja0JveCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgQ2hlY2tib3hXaWRnZXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgUHVzaEJ1dHRvbldpZGdldEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJDaCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IENob2ljZVdpZGdldEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFdpZGdldEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5QT1BVUDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFBvcHVwQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkZSRUVURVhUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgRnJlZVRleHRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuTElORToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IExpbmVBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuU1FVQVJFOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgU3F1YXJlQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkNJUkNMRToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IENpcmNsZUFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5QT0xZTElORToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IFBvbHlsaW5lQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkNBUkVUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgQ2FyZXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuSU5LOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgSW5rQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLlBPTFlHT046CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBQb2x5Z29uQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25UeXBlLkhJR0hMSUdIVDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEhpZ2hsaWdodEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5VTkRFUkxJTkU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBVbmRlcmxpbmVBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuU1FVSUdHTFk6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBTcXVpZ2dseUFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5TVFJJS0VPVVQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBTdHJpa2VPdXRBbm5vdGF0aW9uRWxlbWVudChwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvblR5cGUuU1RBTVA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG5ldyBTdGFtcEFubm90YXRpb25FbGVtZW50KHBhcmFtZXRlcnMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uVHlwZS5GSUxFQVRUQUNITUVOVDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gbmV3IEZpbGVBdHRhY2htZW50QW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBuZXcgQW5ub3RhdGlvbkVsZW1lbnQocGFyYW1ldGVycyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlID0gZmFsc2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXIgPSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZVF1YWRyaWxhdGVyYWxzID0gZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDoge307CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaXNSZW5kZXJhYmxlID0gaXNSZW5kZXJhYmxlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRhdGEgPSBwYXJhbWV0ZXJzLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGF5ZXIgPSBwYXJhbWV0ZXJzLmxheWVyOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhZ2UgPSBwYXJhbWV0ZXJzLnBhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudmlld3BvcnQgPSBwYXJhbWV0ZXJzLnZpZXdwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmtTZXJ2aWNlID0gcGFyYW1ldGVycy5saW5rU2VydmljZTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kb3dubG9hZE1hbmFnZXIgPSBwYXJhbWV0ZXJzLmRvd25sb2FkTWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pbWFnZVJlc291cmNlc1BhdGggPSBwYXJhbWV0ZXJzLmltYWdlUmVzb3VyY2VzUGF0aDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZW5kZXJGb3JtcyA9IHBhcmFtZXRlcnMucmVuZGVyRm9ybXM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3ZnRmFjdG9yeSA9IHBhcmFtZXRlcnMuc3ZnRmFjdG9yeTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbm5vdGF0aW9uU3RvcmFnZSA9IHBhcmFtZXRlcnMuYW5ub3RhdGlvblN0b3JhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5hYmxlU2NyaXB0aW5nID0gcGFyYW1ldGVycy5lbmFibGVTY3JpcHRpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaGFzSlNBY3Rpb25zID0gcGFyYW1ldGVycy5oYXNKU0FjdGlvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2ZpZWxkT2JqZWN0cyA9IHBhcmFtZXRlcnMuZmllbGRPYmplY3RzOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNSZW5kZXJhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lciA9IHRoaXMuX2NyZWF0ZUNvbnRhaW5lcihpZ25vcmVCb3JkZXIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjcmVhdGVRdWFkcmlsYXRlcmFscykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5xdWFkcmlsYXRlcmFscyA9IHRoaXMuX2NyZWF0ZVF1YWRyaWxhdGVyYWxzKGlnbm9yZUJvcmRlcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NyZWF0ZUNvbnRhaW5lcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGlnbm9yZUJvcmRlciA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXM7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRhaW5lciA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoInNlY3Rpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnNldEF0dHJpYnV0ZSgiZGF0YS1hbm5vdGF0aW9uLWlkIiwgZGF0YS5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLm5vUm90YXRlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuY2xhc3NMaXN0LmFkZCgibm9yb3RhdGUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlV2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlSGVpZ2h0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZVgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlWQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gdmlld3BvcnQucmF3RGltczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSBfdXRpbC5VdGlsLm5vcm1hbGl6ZVJlY3QoW2RhdGEucmVjdFswXSwgcGFnZS52aWV3WzNdIC0gZGF0YS5yZWN0WzFdICsgcGFnZS52aWV3WzFdLCBkYXRhLnJlY3RbMl0sIHBhZ2Uudmlld1szXSAtIGRhdGEucmVjdFszXSArIHBhZ2Uudmlld1sxXV0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWlnbm9yZUJvcmRlciAmJiBkYXRhLmJvcmRlclN0eWxlLndpZHRoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLmJvcmRlcldpZHRoID0gYCR7ZGF0YS5ib3JkZXJTdHlsZS53aWR0aH1weGA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBob3Jpem9udGFsUmFkaXVzID0gZGF0YS5ib3JkZXJTdHlsZS5ob3Jpem9udGFsQ29ybmVyUmFkaXVzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmVydGljYWxSYWRpdXMgPSBkYXRhLmJvcmRlclN0eWxlLnZlcnRpY2FsQ29ybmVyUmFkaXVzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGhvcml6b250YWxSYWRpdXMgPiAwIHx8IHZlcnRpY2FsUmFkaXVzID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJhZGl1cyA9IGBjYWxjKCR7aG9yaXpvbnRhbFJhZGl1c31weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpIC8gY2FsYygke3ZlcnRpY2FsUmFkaXVzfXB4ICogdmFyKC0tc2NhbGUtZmFjdG9yKSlgOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lci5zdHlsZS5ib3JkZXJSYWRpdXMgPSByYWRpdXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMgaW5zdGFuY2VvZiBSYWRpb0J1dHRvbldpZGdldEFubm90YXRpb25FbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmFkaXVzID0gYGNhbGMoJHt3aWR0aH1weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpIC8gY2FsYygke2hlaWdodH1weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpYDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyUmFkaXVzID0gcmFkaXVzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChkYXRhLmJvcmRlclN0eWxlLnN0eWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlLlNPTElEOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyU3R5bGUgPSAic29saWQiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25Cb3JkZXJTdHlsZVR5cGUuREFTSEVEOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyU3R5bGUgPSAiZGFzaGVkIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlLkJFVkVMRUQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5pbXBsZW1lbnRlZCBib3JkZXIgc3R5bGU6IGJldmVsZWQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5Bbm5vdGF0aW9uQm9yZGVyU3R5bGVUeXBlLklOU0VUOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlVuaW1wbGVtZW50ZWQgYm9yZGVyIHN0eWxlOiBpbnNldCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkFubm90YXRpb25Cb3JkZXJTdHlsZVR5cGUuVU5ERVJMSU5FOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuYm9yZGVyQm90dG9tU3R5bGUgPSAic29saWQiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJvcmRlckNvbG9yID0gZGF0YS5ib3JkZXJDb2xvciB8fCBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJvcmRlckNvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLmJvcmRlckNvbG9yID0gX3V0aWwuVXRpbC5tYWtlSGV4Q29sb3IoYm9yZGVyQ29sb3JbMF0gfCAwLCBib3JkZXJDb2xvclsxXSB8IDAsIGJvcmRlckNvbG9yWzJdIHwgMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lci5zdHlsZS5ib3JkZXJXaWR0aCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLmxlZnQgPSBgJHsxMDAgKiAocmVjdFswXSAtIHBhZ2VYKSAvIHBhZ2VXaWR0aH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLnRvcCA9IGAkezEwMCAqIChyZWN0WzFdIC0gcGFnZVkpIC8gcGFnZUhlaWdodH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb24KICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLmhhc093bkNhbnZhcyB8fCByb3RhdGlvbiA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLnN0eWxlLndpZHRoID0gYCR7MTAwICogd2lkdGggLyBwYWdlV2lkdGh9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUuaGVpZ2h0ID0gYCR7MTAwICogaGVpZ2h0IC8gcGFnZUhlaWdodH0lYDsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0Um90YXRpb24ocm90YXRpb24sIGNvbnRhaW5lcik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc2V0Um90YXRpb24oYW5nbGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbnRhaW5lciA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VXaWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VIZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMudmlld3BvcnQucmF3RGltczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKHRoaXMuZGF0YS5yZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGVsZW1lbnRXaWR0aCwgZWxlbWVudEhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFuZ2xlICUgMTgwID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50V2lkdGggPSAxMDAgKiB3aWR0aCAvIHBhZ2VXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnRIZWlnaHQgPSAxMDAgKiBoZWlnaHQgLyBwYWdlSGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudFdpZHRoID0gMTAwICogaGVpZ2h0IC8gcGFnZVdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudEhlaWdodCA9IDEwMCAqIHdpZHRoIC8gcGFnZUhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc3R5bGUud2lkdGggPSBgJHtlbGVtZW50V2lkdGh9JWA7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lci5zdHlsZS5oZWlnaHQgPSBgJHtlbGVtZW50SGVpZ2h0fSVgOwogICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuc2V0QXR0cmlidXRlKCJkYXRhLW1haW4tcm90YXRpb24iLCAoMzYwIC0gYW5nbGUpICUgMzYwKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZ2V0IF9jb21tb25BY3Rpb25zKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzZXRDb2xvciA9IChqc05hbWUsIHN0eWxlTmFtZSwgZXZlbnQpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gZXZlbnQuZGV0YWlsW2pzTmFtZV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC50YXJnZXQuc3R5bGVbc3R5bGVOYW1lXSA9IF9zY3JpcHRpbmdfdXRpbHMuQ29sb3JDb252ZXJ0ZXJzW2Ake2NvbG9yWzBdfV9IVE1MYF0oY29sb3Iuc2xpY2UoMSkpOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIl9jb21tb25BY3Rpb25zIiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzcGxheTogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhpZGRlbiA9IGV2ZW50LmRldGFpbC5kaXNwbGF5ICUgMiA9PT0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5zdHlsZS52aXNpYmlsaXR5ID0gaGlkZGVuID8gImhpZGRlbiIgOiAidmlzaWJsZSI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hbm5vdGF0aW9uU3RvcmFnZS5zZXRWYWx1ZSh0aGlzLmRhdGEuaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGlkZGVuLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmludDogZXZlbnQuZGV0YWlsLmRpc3BsYXkgPT09IDAgfHwgZXZlbnQuZGV0YWlsLmRpc3BsYXkgPT09IDMKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmludDogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvblN0b3JhZ2Uuc2V0VmFsdWUodGhpcy5kYXRhLmlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHByaW50OiBldmVudC5kZXRhaWwucHJpbnQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaWRkZW46IGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5zdHlsZS52aXNpYmlsaXR5ID0gZXZlbnQuZGV0YWlsLmhpZGRlbiA/ICJoaWRkZW4iIDogInZpc2libGUiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvblN0b3JhZ2Uuc2V0VmFsdWUodGhpcy5kYXRhLmlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhpZGRlbjogZXZlbnQuZGV0YWlsLmhpZGRlbgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvY3VzOiBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0VGltZW91dCgoKSA9PiBldmVudC50YXJnZXQuZm9jdXMoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2ZW50U2Nyb2xsOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pLCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c2VyTmFtZTogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnRhcmdldC50aXRsZSA9IGV2ZW50LmRldGFpbC51c2VyTmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFkb25seTogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChldmVudC5kZXRhaWwucmVhZG9ubHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnNldEF0dHJpYnV0ZSgicmVhZG9ubHkiLCAiIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnJlbW92ZUF0dHJpYnV0ZSgicmVhZG9ubHkiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVxdWlyZWQ6IGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRSZXF1aXJlZChldmVudC50YXJnZXQsIGV2ZW50LmRldGFpbC5yZXF1aXJlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgYmdDb2xvcjogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldENvbG9yKCJiZ0NvbG9yIiwgImJhY2tncm91bmRDb2xvciIsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWxsQ29sb3I6IGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRDb2xvcigiZmlsbENvbG9yIiwgImJhY2tncm91bmRDb2xvciIsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmZ0NvbG9yOiBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0Q29sb3IoImZnQ29sb3IiLCAiY29sb3IiLCBldmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dENvbG9yOiBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0Q29sb3IoInRleHRDb2xvciIsICJjb2xvciIsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBib3JkZXJDb2xvcjogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldENvbG9yKCJib3JkZXJDb2xvciIsICJib3JkZXJDb2xvciIsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJva2VDb2xvcjogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNldENvbG9yKCJzdHJva2VDb2xvciIsICJib3JkZXJDb2xvciIsIGV2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByb3RhdGlvbjogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFuZ2xlID0gZXZlbnQuZGV0YWlsLnJvdGF0aW9uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0Um90YXRpb24oYW5nbGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYW5ub3RhdGlvblN0b3JhZ2Uuc2V0VmFsdWUodGhpcy5kYXRhLmlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdGF0aW9uOiBhbmdsZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2Rpc3BhdGNoRXZlbnRGcm9tU2FuZGJveChhY3Rpb25zLCBqc0V2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbW1vbkFjdGlvbnMgPSB0aGlzLl9jb21tb25BY3Rpb25zOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG5hbWUgb2YgT2JqZWN0LmtleXMoanNFdmVudC5kZXRhaWwpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhY3Rpb24gPSBhY3Rpb25zW25hbWVdIHx8IGNvbW1vbkFjdGlvbnNbbmFtZV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY3Rpb24gPT09IG51bGwgfHwgYWN0aW9uID09PSB2b2lkIDAgPyB2b2lkIDAgOiBhY3Rpb24oanNFdmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldERlZmF1bHRQcm9wZXJ0aWVzRnJvbUpTKGVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmVuYWJsZVNjcmlwdGluZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0b3JlZERhdGEgPSB0aGlzLmFubm90YXRpb25TdG9yYWdlLmdldFJhd1ZhbHVlKHRoaXMuZGF0YS5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc3RvcmVkRGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbW1vbkFjdGlvbnMgPSB0aGlzLl9jb21tb25BY3Rpb25zOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IFthY3Rpb25OYW1lLCBkZXRhaWxdIG9mIE9iamVjdC5lbnRyaWVzKHN0b3JlZERhdGEpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhY3Rpb24gPSBjb21tb25BY3Rpb25zW2FjdGlvbk5hbWVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGV2ZW50UHJveHkgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbDogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgW2FjdGlvbk5hbWVdOiBkZXRhaWwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGFyZ2V0OiBlbGVtZW50CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY3Rpb24oZXZlbnRQcm94eSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVsZXRlIHN0b3JlZERhdGFbYWN0aW9uTmFtZV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2NyZWF0ZVF1YWRyaWxhdGVyYWxzKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgaWdub3JlQm9yZGVyID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEucXVhZFBvaW50cykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcXVhZHJpbGF0ZXJhbHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2F2ZWRSZWN0ID0gdGhpcy5kYXRhLnJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcXVhZFBvaW50IG9mIHRoaXMuZGF0YS5xdWFkUG9pbnRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRhdGEucmVjdCA9IFtxdWFkUG9pbnRbMl0ueCwgcXVhZFBvaW50WzJdLnksIHF1YWRQb2ludFsxXS54LCBxdWFkUG9pbnRbMV0ueV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBxdWFkcmlsYXRlcmFscy5wdXNoKHRoaXMuX2NyZWF0ZUNvbnRhaW5lcihpZ25vcmVCb3JkZXIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRhdGEucmVjdCA9IHNhdmVkUmVjdDsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHF1YWRyaWxhdGVyYWxzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfY3JlYXRlUG9wdXAodHJpZ2dlciwgZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY29udGFpbmVyID0gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnF1YWRyaWxhdGVyYWxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cmlnZ2VyID0gdHJpZ2dlciB8fCB0aGlzLnF1YWRyaWxhdGVyYWxzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyID0gdGhpcy5xdWFkcmlsYXRlcmFsc1swXTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRyaWdnZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyaWdnZXIgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyaWdnZXIuY2xhc3NMaXN0LmFkZCgicG9wdXBUcmlnZ2VyQXJlYSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLmFwcGVuZCh0cmlnZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb3B1cEVsZW1lbnQgPSBuZXcgUG9wdXBFbGVtZW50KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRyaWdnZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2xvcjogZGF0YS5jb2xvciwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlT2JqOiBkYXRhLnRpdGxlT2JqLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9kaWZpY2F0aW9uRGF0ZTogZGF0YS5tb2RpZmljYXRpb25EYXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudHNPYmo6IGRhdGEuY29udGVudHNPYmosCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByaWNoVGV4dDogZGF0YS5yaWNoVGV4dCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhpZGVXcmFwcGVyOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb3B1cCA9IHBvcHVwRWxlbWVudC5yZW5kZXIoKTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9wdXAuc3R5bGUubGVmdCA9ICIxMDAlIjsKICAgICAgICAgICAgICAgICAgICAgICAgY29udGFpbmVyLmFwcGVuZChwb3B1cCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9yZW5kZXJRdWFkcmlsYXRlcmFscyhjbGFzc05hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBxdWFkcmlsYXRlcmFsIG9mIHRoaXMucXVhZHJpbGF0ZXJhbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHF1YWRyaWxhdGVyYWwuY2xhc3NMaXN0LmFkZChjbGFzc05hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLnF1YWRyaWxhdGVyYWxzOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC51bnJlYWNoYWJsZSkoIkFic3RyYWN0IG1ldGhvZCBgQW5ub3RhdGlvbkVsZW1lbnQucmVuZGVyYCBjYWxsZWQiKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2dldEVsZW1lbnRzQnlOYW1lKG5hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNraXBJZCA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmllbGRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9maWVsZE9iamVjdHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpZWxkT2JqID0gdGhpcy5fZmllbGRPYmplY3RzW25hbWVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpZWxkT2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHBvcnRWYWx1ZXMKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IG9mIGZpZWxkT2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChwYWdlID09PSAtMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlkID09PSBza2lwSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGV4cG9ydFZhbHVlID0gdHlwZW9mIGV4cG9ydFZhbHVlcyA9PT0gInN0cmluZyIgPyBleHBvcnRWYWx1ZXMgOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkb21FbGVtZW50ID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcihgW2RhdGEtZWxlbWVudC1pZD0iJHtpZH0iXWApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZG9tRWxlbWVudCAmJiAhR2V0RWxlbWVudHNCeU5hbWVTZXQuaGFzKGRvbUVsZW1lbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYF9nZXRFbGVtZW50c0J5TmFtZSAtIGVsZW1lbnQgbm90IGFsbG93ZWQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZHMucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4cG9ydFZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9tRWxlbWVudAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmllbGRzOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZG9tRWxlbWVudCBvZiBkb2N1bWVudC5nZXRFbGVtZW50c0J5TmFtZShuYW1lKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4cG9ydFZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZG9tRWxlbWVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gZG9tRWxlbWVudC5nZXRBdHRyaWJ1dGUoImRhdGEtZWxlbWVudC1pZCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlkID09PSBza2lwSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghR2V0RWxlbWVudHNCeU5hbWVTZXQuaGFzKGRvbUVsZW1lbnQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZHMucHVzaCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXhwb3J0VmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZG9tRWxlbWVudAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZpZWxkczsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB2YXIgX3NldEludGVybmFsTGluayA9IC8qI19fUFVSRV9fKi9uZXcgV2Vha1NldCgpOwogICAgICAgICAgICAgICAgdmFyIF9iaW5kU2V0T0NHU3RhdGUgPSAvKiNfX1BVUkVfXyovbmV3IFdlYWtTZXQoKTsKICAgICAgICAgICAgICAgIGNsYXNzIExpbmtBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBvcHRpb25zID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlbmRlcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXI6ICEhKG9wdGlvbnMgIT09IG51bGwgJiYgb3B0aW9ucyAhPT0gdm9pZCAwICYmIG9wdGlvbnMuaWdub3JlQm9yZGVyKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZVF1YWRyaWxhdGVyYWxzOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kSW5pdFNwZWModGhpcywgX2JpbmRTZXRPQ0dTdGF0ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RJbml0U3BlYyh0aGlzLCBfc2V0SW50ZXJuYWxMaW5rKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5pc1Rvb2x0aXBPbmx5ID0gcGFyYW1ldGVycy5kYXRhLmlzVG9vbHRpcE9ubHk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtTZXJ2aWNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsaW5rID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiYSIpOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5rLnNldEF0dHJpYnV0ZSgiZGF0YS1lbGVtZW50LWlkIiwgZGF0YS5pZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpc0JvdW5kID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnVybCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlua1NlcnZpY2UuYWRkTGlua0F0dHJpYnV0ZXMobGluaywgZGF0YS51cmwsIGRhdGEubmV3V2luZG93KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzQm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGRhdGEuYWN0aW9uKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9iaW5kTmFtZWRBY3Rpb24obGluaywgZGF0YS5hY3Rpb24pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNCb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZGF0YS5hdHRhY2htZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9iaW5kQXR0YWNobWVudChsaW5rLCBkYXRhLmF0dGFjaG1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNCb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZGF0YS5zZXRPQ0dTdGF0ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfYmluZFNldE9DR1N0YXRlLCBfYmluZFNldE9DR1N0YXRlMikuY2FsbCh0aGlzLCBsaW5rLCBkYXRhLnNldE9DR1N0YXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzQm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGRhdGEuZGVzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmluZExpbmsobGluaywgZGF0YS5kZXN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzQm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEuYWN0aW9ucyAmJiAoZGF0YS5hY3Rpb25zLkFjdGlvbiB8fCBkYXRhLmFjdGlvbnNbIk1vdXNlIFVwIl0gfHwgZGF0YS5hY3Rpb25zWyJNb3VzZSBEb3duIl0pICYmIHRoaXMuZW5hYmxlU2NyaXB0aW5nICYmIHRoaXMuaGFzSlNBY3Rpb25zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmluZEpTQWN0aW9uKGxpbmssIGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzQm91bmQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEucmVzZXRGb3JtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fYmluZFJlc2V0Rm9ybUFjdGlvbihsaW5rLCBkYXRhLnJlc2V0Rm9ybSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNCb3VuZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuaXNUb29sdGlwT25seSAmJiAhaXNCb3VuZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2JpbmRMaW5rKGxpbmssICIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc0JvdW5kID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5xdWFkcmlsYXRlcmFscykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuX3JlbmRlclF1YWRyaWxhdGVyYWxzKCJsaW5rQW5ub3RhdGlvbiIpLm1hcCgocXVhZHJpbGF0ZXJhbCwgaW5kZXgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsaW5rRWxlbWVudCA9IGluZGV4ID09PSAwID8gbGluayA6IGxpbmsuY2xvbmVOb2RlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcXVhZHJpbGF0ZXJhbC5hcHBlbmQobGlua0VsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBxdWFkcmlsYXRlcmFsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCgibGlua0Fubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzQm91bmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChsaW5rKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9iaW5kTGluayhsaW5rLCBkZXN0aW5hdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICBsaW5rLmhyZWYgPSB0aGlzLmxpbmtTZXJ2aWNlLmdldERlc3RpbmF0aW9uSGFzaChkZXN0aW5hdGlvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmsub25jbGljayA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkZXN0aW5hdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGlua1NlcnZpY2UuZ29Ub0Rlc3RpbmF0aW9uKGRlc3RpbmF0aW9uKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRlc3RpbmF0aW9uIHx8IGRlc3RpbmF0aW9uID09PSAiIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0SW50ZXJuYWxMaW5rLCBfc2V0SW50ZXJuYWxMaW5rMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfYmluZE5hbWVkQWN0aW9uKGxpbmssIGFjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICBsaW5rLmhyZWYgPSB0aGlzLmxpbmtTZXJ2aWNlLmdldEFuY2hvclVybCgiIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmsub25jbGljayA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGlua1NlcnZpY2UuZXhlY3V0ZU5hbWVkQWN0aW9uKGFjdGlvbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldEludGVybmFsTGluaywgX3NldEludGVybmFsTGluazIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9iaW5kQXR0YWNobWVudChsaW5rLCBhdHRhY2htZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmsuaHJlZiA9IHRoaXMubGlua1NlcnZpY2UuZ2V0QW5jaG9yVXJsKCIiKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluay5vbmNsaWNrID0gKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGRvd25sb2FkTWFuYWdlcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRkb3dubG9hZE1hbmFnZXIgPSB0aGlzLmRvd25sb2FkTWFuYWdlcikgPT09IG51bGwgfHwgX3RoaXMkZG93bmxvYWRNYW5hZ2VyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRkb3dubG9hZE1hbmFnZXIub3Blbk9yRG93bmxvYWREYXRhKHRoaXMuY29udGFpbmVyLCBhdHRhY2htZW50LmNvbnRlbnQsIGF0dGFjaG1lbnQuZmlsZW5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NQcml2YXRlTWV0aG9kR2V0KHRoaXMsIF9zZXRJbnRlcm5hbExpbmssIF9zZXRJbnRlcm5hbExpbmsyKS5jYWxsKHRoaXMpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfYmluZEpTQWN0aW9uKGxpbmssIGRhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGluay5ocmVmID0gdGhpcy5saW5rU2VydmljZS5nZXRBbmNob3JVcmwoIiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXAgPSBuZXcgTWFwKFtbIkFjdGlvbiIsICJvbmNsaWNrIl0sIFsiTW91c2UgVXAiLCAib25tb3VzZXVwIl0sIFsiTW91c2UgRG93biIsICJvbm1vdXNlZG93biJdXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgbmFtZSBvZiBPYmplY3Qua2V5cyhkYXRhLmFjdGlvbnMpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBqc05hbWUgPSBtYXAuZ2V0KG5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFqc05hbWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtbanNOYW1lXSA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkbGlua1NlcnZpY2UkZXZlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRsaW5rU2VydmljZSRldmUgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmUgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGxpbmtTZXJ2aWNlJGV2ZS5kaXNwYXRjaCgiZGlzcGF0Y2hldmVudGluc2FuZGJveCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlOiB0aGlzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWw6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkOiBkYXRhLmlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWxpbmsub25jbGljaykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluay5vbmNsaWNrID0gKCkgPT4gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzUHJpdmF0ZU1ldGhvZEdldCh0aGlzLCBfc2V0SW50ZXJuYWxMaW5rLCBfc2V0SW50ZXJuYWxMaW5rMikuY2FsbCh0aGlzKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX2JpbmRSZXNldEZvcm1BY3Rpb24obGluaywgcmVzZXRGb3JtKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG90aGVyQ2xpY2tBY3Rpb24gPSBsaW5rLm9uY2xpY2s7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb3RoZXJDbGlja0FjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluay5ocmVmID0gdGhpcy5saW5rU2VydmljZS5nZXRBbmNob3JVcmwoIiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldEludGVybmFsTGluaywgX3NldEludGVybmFsTGluazIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5fZmllbGRPYmplY3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYF9iaW5kUmVzZXRGb3JtQWN0aW9uIC0gInJlc2V0Rm9ybSIgYWN0aW9uIG5vdCBzdXBwb3J0ZWQsIGAgKyAiZW5zdXJlIHRoYXQgdGhlIGBmaWVsZE9iamVjdHNgIHBhcmFtZXRlciBpcyBwcm92aWRlZC4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb3RoZXJDbGlja0FjdGlvbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmsub25jbGljayA9ICgpID0+IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmsub25jbGljayA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG90aGVyQ2xpY2tBY3Rpb24gPT09IG51bGwgfHwgb3RoZXJDbGlja0FjdGlvbiA9PT0gdm9pZCAwID8gdm9pZCAwIDogb3RoZXJDbGlja0FjdGlvbigpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpZWxkczogcmVzZXRGb3JtRmllbGRzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlZnM6IHJlc2V0Rm9ybVJlZnMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5jbHVkZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHJlc2V0Rm9ybTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFsbEZpZWxkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc2V0Rm9ybUZpZWxkcy5sZW5ndGggIT09IDAgfHwgcmVzZXRGb3JtUmVmcy5sZW5ndGggIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWVsZElkcyA9IG5ldyBTZXQocmVzZXRGb3JtUmVmcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBmaWVsZE5hbWUgb2YgcmVzZXRGb3JtRmllbGRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpZWxkcyA9IHRoaXMuX2ZpZWxkT2JqZWN0c1tmaWVsZE5hbWVdIHx8IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gb2YgZmllbGRzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZElkcy5hZGQoaWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZmllbGRzIG9mIE9iamVjdC52YWx1ZXModGhpcy5fZmllbGRPYmplY3RzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGZpZWxkIG9mIGZpZWxkcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpZWxkSWRzLmhhcyhmaWVsZC5pZCkgPT09IGluY2x1ZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbGxGaWVsZHMucHVzaChmaWVsZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZmllbGRzIG9mIE9iamVjdC52YWx1ZXModGhpcy5fZmllbGRPYmplY3RzKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbGxGaWVsZHMucHVzaCguLi5maWVsZHMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0b3JhZ2UgPSB0aGlzLmFubm90YXRpb25TdG9yYWdlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWxsSWRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGZpZWxkIG9mIGFsbEZpZWxkcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZmllbGQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWxsSWRzLnB1c2goaWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZmllbGQudHlwZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJ0ZXh0IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmFsdWUgPSBmaWVsZC5kZWZhdWx0VmFsdWUgfHwgIiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiY2hlY2tib3giOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJyYWRpb2J1dHRvbiI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gZmllbGQuZGVmYXVsdFZhbHVlID09PSBmaWVsZC5leHBvcnRWYWx1ZXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiY29tYm9ib3giOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJsaXN0Ym94IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmFsdWUgPSBmaWVsZC5kZWZhdWx0VmFsdWUgfHwgIiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkb21FbGVtZW50ID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcihgW2RhdGEtZWxlbWVudC1pZD0iJHtpZH0iXWApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZG9tRWxlbWVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKCFHZXRFbGVtZW50c0J5TmFtZVNldC5oYXMoZG9tRWxlbWVudCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBfYmluZFJlc2V0Rm9ybUFjdGlvbiAtIGVsZW1lbnQgbm90IGFsbG93ZWQ6ICR7aWR9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb21FbGVtZW50LmRpc3BhdGNoRXZlbnQobmV3IEV2ZW50KCJyZXNldGZvcm0iKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5lbmFibGVTY3JpcHRpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkbGlua1NlcnZpY2UkZXZlMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkbGlua1NlcnZpY2UkZXZlMiA9IHRoaXMubGlua1NlcnZpY2UuZXZlbnRCdXMpID09PSBudWxsIHx8IF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTIgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTIuZGlzcGF0Y2goImRpc3BhdGNoZXZlbnRpbnNhbmRib3giLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGV0YWlsOiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZDogImFwcCIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZHM6IGFsbElkcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6ICJSZXNldEZvcm0iCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0SW50ZXJuYWxMaW5rMigpIHsKICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5zZXRBdHRyaWJ1dGUoImRhdGEtaW50ZXJuYWwtbGluayIsICIiKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGZ1bmN0aW9uIF9iaW5kU2V0T0NHU3RhdGUyKGxpbmssIGFjdGlvbikgewogICAgICAgICAgICAgICAgICAgIGxpbmsuaHJlZiA9IHRoaXMubGlua1NlcnZpY2UuZ2V0QW5jaG9yVXJsKCIiKTsKICAgICAgICAgICAgICAgICAgICBsaW5rLm9uY2xpY2sgPSAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGlua1NlcnZpY2UuZXhlY3V0ZVNldE9DR1N0YXRlKGFjdGlvbik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIF9jbGFzc1ByaXZhdGVNZXRob2RHZXQodGhpcywgX3NldEludGVybmFsTGluaywgX3NldEludGVybmFsTGluazIpLmNhbGwodGhpcyk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBUZXh0QW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsLCBfcGFyYW1ldGVycyRkYXRhJGNvbnQsIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGwgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bCAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bC5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udCA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2ggIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2guc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInRleHRBbm5vdGF0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltYWdlID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiaW1nIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlLnNyYyA9IHRoaXMuaW1hZ2VSZXNvdXJjZXNQYXRoICsgImFubm90YXRpb24tIiArIHRoaXMuZGF0YS5uYW1lLnRvTG93ZXJDYXNlKCkgKyAiLnN2ZyI7CiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlLmFsdCA9ICJbe3t0eXBlfX0gQW5ub3RhdGlvbl0iOwogICAgICAgICAgICAgICAgICAgICAgICBpbWFnZS5kYXRhc2V0LmwxMG5JZCA9ICJ0ZXh0X2Fubm90YXRpb25fdHlwZSI7CiAgICAgICAgICAgICAgICAgICAgICAgIGltYWdlLmRhdGFzZXQubDEwbkFyZ3MgPSBKU09OLnN0cmluZ2lmeSh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0eXBlOiB0aGlzLmRhdGEubmFtZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKGltYWdlLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChpbWFnZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBXaWRnZXRBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEuYWx0ZXJuYXRpdmVUZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci50aXRsZSA9IHRoaXMuZGF0YS5hbHRlcm5hdGl2ZVRleHQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZ2V0S2V5TW9kaWZpZXIoZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNXaW4sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc01hYwogICAgICAgICAgICAgICAgICAgICAgICB9ID0gX3V0aWwuRmVhdHVyZVRlc3QucGxhdGZvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBpc1dpbiAmJiBldmVudC5jdHJsS2V5IHx8IGlzTWFjICYmIGV2ZW50Lm1ldGFLZXk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zZXRFdmVudExpc3RlbmVyKGVsZW1lbnQsIGJhc2VOYW1lLCBldmVudE5hbWUsIHZhbHVlR2V0dGVyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChiYXNlTmFtZS5pbmNsdWRlcygibW91c2UiKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKGJhc2VOYW1lLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTMgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmUzID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRsaW5rU2VydmljZSRldmUzLmRpc3BhdGNoKCJkaXNwYXRjaGV2ZW50aW5zYW5kYm94IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbDogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IHRoaXMuZGF0YS5pZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6IGV2ZW50TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2YWx1ZUdldHRlcihldmVudCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzaGlmdDogZXZlbnQuc2hpZnRLZXksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb2RpZmllcjogdGhpcy5fZ2V0S2V5TW9kaWZpZXIoZXZlbnQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKGJhc2VOYW1lLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTQgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmU0ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRsaW5rU2VydmljZSRldmU0LmRpc3BhdGNoKCJkaXNwYXRjaGV2ZW50aW5zYW5kYm94IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbDogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQ6IHRoaXMuZGF0YS5pZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6IGV2ZW50TmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB2YWx1ZUdldHRlcihldmVudCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldEV2ZW50TGlzdGVuZXJzKGVsZW1lbnQsIG5hbWVzLCBnZXR0ZXIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBbYmFzZU5hbWUsIGV2ZW50TmFtZV0gb2YgbmFtZXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRkYXRhJGFjdGlvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnROYW1lID09PSAiQWN0aW9uIiB8fCAoX3RoaXMkZGF0YSRhY3Rpb25zID0gdGhpcy5kYXRhLmFjdGlvbnMpICE9PSBudWxsICYmIF90aGlzJGRhdGEkYWN0aW9ucyAhPT0gdm9pZCAwICYmIF90aGlzJGRhdGEkYWN0aW9uc1tldmVudE5hbWVdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RXZlbnRMaXN0ZW5lcihlbGVtZW50LCBiYXNlTmFtZSwgZXZlbnROYW1lLCBnZXR0ZXIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zZXRCYWNrZ3JvdW5kQ29sb3IoZWxlbWVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb2xvciA9IHRoaXMuZGF0YS5iYWNrZ3JvdW5kQ29sb3IgfHwgbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zdHlsZS5iYWNrZ3JvdW5kQ29sb3IgPSBjb2xvciA9PT0gbnVsbCA/ICJ0cmFuc3BhcmVudCIgOiBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihjb2xvclswXSwgY29sb3JbMV0sIGNvbG9yWzJdKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldFRleHRTdHlsZShlbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFRFWFRfQUxJR05NRU5UID0gWyJsZWZ0IiwgImNlbnRlciIsICJyaWdodCJdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb250Q29sb3IKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZGF0YS5kZWZhdWx0QXBwZWFyYW5jZURhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRTaXplID0gdGhpcy5kYXRhLmRlZmF1bHRBcHBlYXJhbmNlRGF0YS5mb250U2l6ZSB8fCBERUZBVUxUX0ZPTlRfU0laRTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3R5bGUgPSBlbGVtZW50LnN0eWxlOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgY29tcHV0ZWRGb250U2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQk9SREVSX1NJWkUgPSAyOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByb3VuZFRvT25lRGVjaW1hbCA9IHggPT4gTWF0aC5yb3VuZCgxMCAqIHgpIC8gMTA7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEubXVsdGlMaW5lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBNYXRoLmFicyh0aGlzLmRhdGEucmVjdFszXSAtIHRoaXMuZGF0YS5yZWN0WzFdIC0gQk9SREVSX1NJWkUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbnVtYmVyT2ZMaW5lcyA9IE1hdGgucm91bmQoaGVpZ2h0IC8gKF91dGlsLkxJTkVfRkFDVE9SICogZm9udFNpemUpKSB8fCAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGluZUhlaWdodCA9IGhlaWdodCAvIG51bWJlck9mTGluZXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wdXRlZEZvbnRTaXplID0gTWF0aC5taW4oZm9udFNpemUsIHJvdW5kVG9PbmVEZWNpbWFsKGxpbmVIZWlnaHQgLyBfdXRpbC5MSU5FX0ZBQ1RPUikpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gTWF0aC5hYnModGhpcy5kYXRhLnJlY3RbM10gLSB0aGlzLmRhdGEucmVjdFsxXSAtIEJPUkRFUl9TSVpFKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbXB1dGVkRm9udFNpemUgPSBNYXRoLm1pbihmb250U2l6ZSwgcm91bmRUb09uZURlY2ltYWwoaGVpZ2h0IC8gX3V0aWwuTElORV9GQUNUT1IpKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS5mb250U2l6ZSA9IGBjYWxjKCR7Y29tcHV0ZWRGb250U2l6ZX1weCAqIHZhcigtLXNjYWxlLWZhY3RvcikpYDsKICAgICAgICAgICAgICAgICAgICAgICAgc3R5bGUuY29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihmb250Q29sb3JbMF0sIGZvbnRDb2xvclsxXSwgZm9udENvbG9yWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGF0YS50ZXh0QWxpZ25tZW50ICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHlsZS50ZXh0QWxpZ24gPSBURVhUX0FMSUdOTUVOVFt0aGlzLmRhdGEudGV4dEFsaWdubWVudF07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgX3NldFJlcXVpcmVkKGVsZW1lbnQsIGlzUmVxdWlyZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGlzUmVxdWlyZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc2V0QXR0cmlidXRlKCJyZXF1aXJlZCIsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5yZW1vdmVBdHRyaWJ1dGUoInJlcXVpcmVkIik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGUoImFyaWEtcmVxdWlyZWQiLCBpc1JlcXVpcmVkKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBUZXh0V2lkZ2V0QW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBXaWRnZXRBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1JlbmRlcmFibGUgPSBwYXJhbWV0ZXJzLnJlbmRlckZvcm1zIHx8ICFwYXJhbWV0ZXJzLmRhdGEuaGFzQXBwZWFyYW5jZSAmJiAhIXBhcmFtZXRlcnMuZGF0YS5maWVsZFZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlbmRlcmFibGUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHNldFByb3BlcnR5T25TaWJsaW5ncyhiYXNlLCBrZXksIHZhbHVlLCBrZXlJblN0b3JhZ2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RvcmFnZSA9IHRoaXMuYW5ub3RhdGlvblN0b3JhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWxlbWVudCBvZiB0aGlzLl9nZXRFbGVtZW50c0J5TmFtZShiYXNlLm5hbWUsIGJhc2UuaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWxlbWVudC5kb21FbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5kb21FbGVtZW50W2tleV0gPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoZWxlbWVudC5pZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFtrZXlJblN0b3JhZ2VdOiB2YWx1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdG9yYWdlID0gdGhpcy5hbm5vdGF0aW9uU3RvcmFnZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaWQgPSB0aGlzLmRhdGEuaWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInRleHRXaWRnZXRBbm5vdGF0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBlbGVtZW50ID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucmVuZGVyRm9ybXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0b3JlZERhdGEgPSBzdG9yYWdlLmdldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuZGF0YS5maWVsZFZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0ZXh0Q29udGVudCA9IHN0b3JlZERhdGEuZm9ybWF0dGVkVmFsdWUgfHwgc3RvcmVkRGF0YS52YWx1ZSB8fCAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1heExlbiA9IHN0b3JhZ2UuZ2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGFyTGltaXQ6IHRoaXMuZGF0YS5tYXhMZW4KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pLmNoYXJMaW1pdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXhMZW4gJiYgdGV4dENvbnRlbnQubGVuZ3RoID4gbWF4TGVuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dENvbnRlbnQgPSB0ZXh0Q29udGVudC5zbGljZSgwLCBtYXhMZW4pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudERhdGEgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXNlclZhbHVlOiB0ZXh0Q29udGVudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JtYXR0ZWRWYWx1ZTogbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXN0Q29tbWl0dGVkVmFsdWU6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tbWl0S2V5OiAxCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGF0YS5tdWx0aUxpbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgidGV4dGFyZWEiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnRleHRDb250ZW50ID0gdGV4dENvbnRlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZGF0YS5kb05vdFNjcm9sbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnN0eWxlLm92ZXJmbG93WSA9ICJoaWRkZW4iOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImlucHV0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50eXBlID0gInRleHQiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc2V0QXR0cmlidXRlKCJ2YWx1ZSIsIHRleHRDb250ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kYXRhLmRvTm90U2Nyb2xsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc3R5bGUub3ZlcmZsb3dYID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgR2V0RWxlbWVudHNCeU5hbWVTZXQuYWRkKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGUoImRhdGEtZWxlbWVudC1pZCIsIGlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuZGlzYWJsZWQgPSB0aGlzLmRhdGEucmVhZE9ubHk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50Lm5hbWUgPSB0aGlzLmRhdGEuZmllbGROYW1lOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50YWJJbmRleCA9IERFRkFVTFRfVEFCX0lOREVYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0UmVxdWlyZWQoZWxlbWVudCwgdGhpcy5kYXRhLnJlcXVpcmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXhMZW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50Lm1heExlbmd0aCA9IG1heExlbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigiaW5wdXQiLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZXZlbnQudGFyZ2V0LnZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRQcm9wZXJ0eU9uU2libGluZ3MoZWxlbWVudCwgInZhbHVlIiwgZXZlbnQudGFyZ2V0LnZhbHVlLCAidmFsdWUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJyZXNldGZvcm0iLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGVmYXVsdFZhbHVlID0gdGhpcy5kYXRhLmRlZmF1bHRGaWVsZFZhbHVlID8/ICIiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQudmFsdWUgPSBlbGVtZW50RGF0YS51c2VyVmFsdWUgPSBkZWZhdWx0VmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEuZm9ybWF0dGVkVmFsdWUgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgYmx1ckxpc3RlbmVyID0gZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9ybWF0dGVkVmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZWxlbWVudERhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZvcm1hdHRlZFZhbHVlICE9PSBudWxsICYmIGZvcm1hdHRlZFZhbHVlICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnZhbHVlID0gZm9ybWF0dGVkVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnRhcmdldC5zY3JvbGxMZWZ0ID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5lbmFibGVTY3JpcHRpbmcgJiYgdGhpcy5oYXNKU0FjdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZGF0YSRhY3Rpb25zMjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoImZvY3VzIiwgZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGV2ZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZWxlbWVudERhdGEudXNlclZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXQudmFsdWUgPSBlbGVtZW50RGF0YS51c2VyVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEubGFzdENvbW1pdHRlZFZhbHVlID0gdGFyZ2V0LnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50RGF0YS5jb21taXRLZXkgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigidXBkYXRlZnJvbXNhbmRib3giLCBqc0V2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYWN0aW9ucyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEudXNlclZhbHVlID0gZXZlbnQuZGV0YWlsLnZhbHVlID8/ICIiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGVsZW1lbnREYXRhLnVzZXJWYWx1ZS50b1N0cmluZygpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnZhbHVlID0gZWxlbWVudERhdGEudXNlclZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcm1hdHRlZFZhbHVlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3JtYXR0ZWRWYWx1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBldmVudC5kZXRhaWw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEuZm9ybWF0dGVkVmFsdWUgPSBmb3JtYXR0ZWRWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZm9ybWF0dGVkVmFsdWUgIT09IG51bGwgJiYgZm9ybWF0dGVkVmFsdWUgIT09IHVuZGVmaW5lZCAmJiBldmVudC50YXJnZXQgIT09IGRvY3VtZW50LmFjdGl2ZUVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LnZhbHVlID0gZm9ybWF0dGVkVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9ybWF0dGVkVmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxSYW5nZShldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV2ZW50LnRhcmdldC5zZXRTZWxlY3Rpb25SYW5nZSguLi5ldmVudC5kZXRhaWwuc2VsUmFuZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYXJMaW1pdDogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmU1OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hhckxpbWl0CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGV2ZW50LmRldGFpbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBldmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hhckxpbWl0ID09PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldC5yZW1vdmVBdHRyaWJ1dGUoIm1heExlbmd0aCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldC5zZXRBdHRyaWJ1dGUoIm1heExlbmd0aCIsIGNoYXJMaW1pdCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHZhbHVlID0gZWxlbWVudERhdGEudXNlclZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdmFsdWUgfHwgdmFsdWUubGVuZ3RoIDw9IGNoYXJMaW1pdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlID0gdmFsdWUuc2xpY2UoMCwgY2hhckxpbWl0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0YXJnZXQudmFsdWUgPSBlbGVtZW50RGF0YS51c2VyVmFsdWUgPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTUgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmU1ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRsaW5rU2VydmljZSRldmU1LmRpc3BhdGNoKCJkaXNwYXRjaGV2ZW50aW5zYW5kYm94IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRldGFpbDogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiAiS2V5c3Ryb2tlIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lsbENvbW1pdDogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1pdEtleTogMSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbFN0YXJ0OiB0YXJnZXQuc2VsZWN0aW9uU3RhcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxFbmQ6IHRhcmdldC5zZWxlY3Rpb25FbmQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kaXNwYXRjaEV2ZW50RnJvbVNhbmRib3goYWN0aW9ucywganNFdmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJrZXlkb3duIiwgZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkbGlua1NlcnZpY2UkZXZlNjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEuY29tbWl0S2V5ID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbW1pdEtleSA9IC0xOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXZlbnQua2V5ID09PSAiRXNjYXBlIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tbWl0S2V5ID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChldmVudC5rZXkgPT09ICJFbnRlciIgJiYgIXRoaXMuZGF0YS5tdWx0aUxpbmUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1pdEtleSA9IDI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoZXZlbnQua2V5ID09PSAiVGFiIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEuY29tbWl0S2V5ID0gMzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY29tbWl0S2V5ID09PSAtMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBldmVudC50YXJnZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbGVtZW50RGF0YS5sYXN0Q29tbWl0dGVkVmFsdWUgPT09IHZhbHVlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEubGFzdENvbW1pdHRlZFZhbHVlID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnREYXRhLnVzZXJWYWx1ZSA9IHZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkbGlua1NlcnZpY2UkZXZlNiA9IHRoaXMubGlua1NlcnZpY2UuZXZlbnRCdXMpID09PSBudWxsIHx8IF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTYgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTYuZGlzcGF0Y2goImRpc3BhdGNoZXZlbnRpbnNhbmRib3giLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzb3VyY2U6IHRoaXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWw6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiAiS2V5c3Ryb2tlIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWxsQ29tbWl0OiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1pdEtleSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxTdGFydDogZXZlbnQudGFyZ2V0LnNlbGVjdGlvblN0YXJ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbEVuZDogZXZlbnQudGFyZ2V0LnNlbGVjdGlvbkVuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBfYmx1ckxpc3RlbmVyID0gYmx1ckxpc3RlbmVyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJsdXJMaXN0ZW5lciA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJibHVyIiwgZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWV2ZW50LnJlbGF0ZWRUYXJnZXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZXZlbnQudGFyZ2V0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50RGF0YS51c2VyVmFsdWUgPSB2YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVsZW1lbnREYXRhLmxhc3RDb21taXR0ZWRWYWx1ZSAhPT0gdmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmU3OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTcgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmU3ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRsaW5rU2VydmljZSRldmU3LmRpc3BhdGNoKCJkaXNwYXRjaGV2ZW50aW5zYW5kYm94IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWw6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6ICJLZXlzdHJva2UiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lsbENvbW1pdDogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tbWl0S2V5OiBlbGVtZW50RGF0YS5jb21taXRLZXksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbFN0YXJ0OiBldmVudC50YXJnZXQuc2VsZWN0aW9uU3RhcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbEVuZDogZXZlbnQudGFyZ2V0LnNlbGVjdGlvbkVuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9ibHVyTGlzdGVuZXIoZXZlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoX3RoaXMkZGF0YSRhY3Rpb25zMiA9IHRoaXMuZGF0YS5hY3Rpb25zKSAhPT0gbnVsbCAmJiBfdGhpcyRkYXRhJGFjdGlvbnMyICE9PSB2b2lkIDAgJiYgX3RoaXMkZGF0YSRhY3Rpb25zMi5LZXlzdHJva2UpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJiZWZvcmVpbnB1dCIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmU4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudERhdGEubGFzdENvbW1pdHRlZFZhbHVlID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRhcmdldAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGV2ZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGlvblN0YXJ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGlvbkVuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRhcmdldDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzZWxTdGFydCA9IHNlbGVjdGlvblN0YXJ0LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbEVuZCA9IHNlbGVjdGlvbkVuZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZXZlbnQuaW5wdXRUeXBlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiZGVsZXRlV29yZEJhY2t3YXJkIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1hdGNoID0gdmFsdWUuc3Vic3RyaW5nKDAsIHNlbGVjdGlvblN0YXJ0KS5tYXRjaCgvXHcqW15cd10qJC8pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobWF0Y2gpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbFN0YXJ0IC09IG1hdGNoWzBdLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiZGVsZXRlV29yZEZvcndhcmQiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF0Y2ggPSB2YWx1ZS5zdWJzdHJpbmcoc2VsZWN0aW9uU3RhcnQpLm1hdGNoKC9eW15cd10qXHcqLyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXRjaCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsRW5kICs9IG1hdGNoWzBdLmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiZGVsZXRlQ29udGVudEJhY2t3YXJkIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNlbGVjdGlvblN0YXJ0ID09PSBzZWxlY3Rpb25FbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbFN0YXJ0IC09IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiZGVsZXRlQ29udGVudEZvcndhcmQiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZWN0aW9uU3RhcnQgPT09IHNlbGVjdGlvbkVuZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsRW5kICs9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC5wcmV2ZW50RGVmYXVsdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGxpbmtTZXJ2aWNlJGV2ZTggPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmU4ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRsaW5rU2VydmljZSRldmU4LmRpc3BhdGNoKCJkaXNwYXRjaGV2ZW50aW5zYW5kYm94IiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWw6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6ICJLZXlzdHJva2UiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hhbmdlOiBkYXRhIHx8ICIiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWxsQ29tbWl0OiBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsU3RhcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbEVuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RXZlbnRMaXN0ZW5lcnMoZWxlbWVudCwgW1siZm9jdXMiLCAiRm9jdXMiXSwgWyJibHVyIiwgIkJsdXIiXSwgWyJtb3VzZWRvd24iLCAiTW91c2UgRG93biJdLCBbIm1vdXNlZW50ZXIiLCAiTW91c2UgRW50ZXIiXSwgWyJtb3VzZWxlYXZlIiwgIk1vdXNlIEV4aXQiXSwgWyJtb3VzZXVwIiwgIk1vdXNlIFVwIl1dLCBldmVudCA9PiBldmVudC50YXJnZXQudmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGJsdXJMaXN0ZW5lcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigiYmx1ciIsIGJsdXJMaXN0ZW5lcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kYXRhLmNvbWIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWVsZFdpZHRoID0gdGhpcy5kYXRhLnJlY3RbMl0gLSB0aGlzLmRhdGEucmVjdFswXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb21iV2lkdGggPSBmaWVsZFdpZHRoIC8gbWF4TGVuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuY2xhc3NMaXN0LmFkZCgiY29tYiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc3R5bGUubGV0dGVyU3BhY2luZyA9IGBjYWxjKCR7Y29tYldpZHRofXB4ICogdmFyKC0tc2NhbGUtZmFjdG9yKSAtIDFjaClgOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50ZXh0Q29udGVudCA9IHRoaXMuZGF0YS5maWVsZFZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zdHlsZS52ZXJ0aWNhbEFsaWduID0gIm1pZGRsZSI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnN0eWxlLmRpc3BsYXkgPSAidGFibGUtY2VsbCI7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0VGV4dFN0eWxlKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRCYWNrZ3JvdW5kQ29sb3IoZWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldERlZmF1bHRQcm9wZXJ0aWVzRnJvbUpTKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoZWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDaGVja2JveFdpZGdldEFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgV2lkZ2V0QW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlOiBwYXJhbWV0ZXJzLnJlbmRlckZvcm1zCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0b3JhZ2UgPSB0aGlzLmFubm90YXRpb25TdG9yYWdlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gdGhpcy5kYXRhOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IGRhdGEuaWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2YWx1ZSA9IHN0b3JhZ2UuZ2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBkYXRhLmV4cG9ydFZhbHVlID09PSBkYXRhLmZpZWxkVmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgfSkudmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHZhbHVlICE9PSAiT2ZmIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCgiYnV0dG9uV2lkZ2V0QW5ub3RhdGlvbiIsICJjaGVja0JveCIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiaW5wdXQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgR2V0RWxlbWVudHNCeU5hbWVTZXQuYWRkKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZSgiZGF0YS1lbGVtZW50LWlkIiwgaWQpOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmRpc2FibGVkID0gZGF0YS5yZWFkT25seTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0UmVxdWlyZWQoZWxlbWVudCwgdGhpcy5kYXRhLnJlcXVpcmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50eXBlID0gImNoZWNrYm94IjsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5uYW1lID0gZGF0YS5maWVsZE5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGUoImNoZWNrZWQiLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZSgiZXhwb3J0VmFsdWUiLCBkYXRhLmV4cG9ydFZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50YWJJbmRleCA9IERFRkFVTFRfVEFCX0lOREVYOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoImNoYW5nZSIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrZWQKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBldmVudC50YXJnZXQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGNoZWNrYm94IG9mIHRoaXMuX2dldEVsZW1lbnRzQnlOYW1lKG5hbWUsIGlkKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1ckNoZWNrZWQgPSBjaGVja2VkICYmIGNoZWNrYm94LmV4cG9ydFZhbHVlID09PSBkYXRhLmV4cG9ydFZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGVja2JveC5kb21FbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrYm94LmRvbUVsZW1lbnQuY2hlY2tlZCA9IGN1ckNoZWNrZWQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoY2hlY2tib3guaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGN1ckNoZWNrZWQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogY2hlY2tlZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoInJlc2V0Zm9ybSIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlZmF1bHRWYWx1ZSA9IGRhdGEuZGVmYXVsdEZpZWxkVmFsdWUgfHwgIk9mZiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC50YXJnZXQuY2hlY2tlZCA9IGRlZmF1bHRWYWx1ZSA9PT0gZGF0YS5leHBvcnRWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmVuYWJsZVNjcmlwdGluZyAmJiB0aGlzLmhhc0pTQWN0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJ1cGRhdGVmcm9tc2FuZGJveCIsIGpzRXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFjdGlvbnMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC50YXJnZXQuY2hlY2tlZCA9IGV2ZW50LmRldGFpbC52YWx1ZSAhPT0gIk9mZiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGV2ZW50LnRhcmdldC5jaGVja2VkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGlzcGF0Y2hFdmVudEZyb21TYW5kYm94KGFjdGlvbnMsIGpzRXZlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRFdmVudExpc3RlbmVycyhlbGVtZW50LCBbWyJjaGFuZ2UiLCAiVmFsaWRhdGUiXSwgWyJjaGFuZ2UiLCAiQWN0aW9uIl0sIFsiZm9jdXMiLCAiRm9jdXMiXSwgWyJibHVyIiwgIkJsdXIiXSwgWyJtb3VzZWRvd24iLCAiTW91c2UgRG93biJdLCBbIm1vdXNlZW50ZXIiLCAiTW91c2UgRW50ZXIiXSwgWyJtb3VzZWxlYXZlIiwgIk1vdXNlIEV4aXQiXSwgWyJtb3VzZXVwIiwgIk1vdXNlIFVwIl1dLCBldmVudCA9PiBldmVudC50YXJnZXQuY2hlY2tlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0QmFja2dyb3VuZENvbG9yKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXREZWZhdWx0UHJvcGVydGllc0Zyb21KUyhlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuYXBwZW5kKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUmFkaW9CdXR0b25XaWRnZXRBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIFdpZGdldEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHBhcmFtZXRlcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVuZGVyYWJsZTogcGFyYW1ldGVycy5yZW5kZXJGb3JtcwogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJidXR0b25XaWRnZXRBbm5vdGF0aW9uIiwgInJhZGlvQnV0dG9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0b3JhZ2UgPSB0aGlzLmFubm90YXRpb25TdG9yYWdlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gdGhpcy5kYXRhOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZCA9IGRhdGEuaWQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCB2YWx1ZSA9IHN0b3JhZ2UuZ2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBkYXRhLmZpZWxkVmFsdWUgPT09IGRhdGEuYnV0dG9uVmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgfSkudmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZSA9IHZhbHVlICE9PSBkYXRhLmJ1dHRvblZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBlbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiaW5wdXQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgR2V0RWxlbWVudHNCeU5hbWVTZXQuYWRkKGVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZSgiZGF0YS1lbGVtZW50LWlkIiwgaWQpOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmRpc2FibGVkID0gZGF0YS5yZWFkT25seTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0UmVxdWlyZWQoZWxlbWVudCwgdGhpcy5kYXRhLnJlcXVpcmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC50eXBlID0gInJhZGlvIjsKICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5uYW1lID0gZGF0YS5maWVsZE5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGUoImNoZWNrZWQiLCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnRhYkluZGV4ID0gREVGQVVMVF9UQUJfSU5ERVg7CiAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigiY2hhbmdlIiwgZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5hbWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hlY2tlZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGV2ZW50LnRhcmdldDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcmFkaW8gb2YgdGhpcy5fZ2V0RWxlbWVudHNCeU5hbWUobmFtZSwgaWQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShyYWRpby5pZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmFsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogY2hlY2tlZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoInJlc2V0Zm9ybSIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRlZmF1bHRWYWx1ZSA9IGRhdGEuZGVmYXVsdEZpZWxkVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC50YXJnZXQuY2hlY2tlZCA9IGRlZmF1bHRWYWx1ZSAhPT0gbnVsbCAmJiBkZWZhdWx0VmFsdWUgIT09IHVuZGVmaW5lZCAmJiBkZWZhdWx0VmFsdWUgPT09IGRhdGEuYnV0dG9uVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5lbmFibGVTY3JpcHRpbmcgJiYgdGhpcy5oYXNKU0FjdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBkZkJ1dHRvblZhbHVlID0gZGF0YS5idXR0b25WYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigidXBkYXRlZnJvbXNhbmRib3giLCBqc0V2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhY3Rpb25zID0gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2hlY2tlZCA9IHBkZkJ1dHRvblZhbHVlID09PSBldmVudC5kZXRhaWwudmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJhZGlvIG9mIHRoaXMuX2dldEVsZW1lbnRzQnlOYW1lKGV2ZW50LnRhcmdldC5uYW1lKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1ckNoZWNrZWQgPSBjaGVja2VkICYmIHJhZGlvLmlkID09PSBpZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocmFkaW8uZG9tRWxlbWVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByYWRpby5kb21FbGVtZW50LmNoZWNrZWQgPSBjdXJDaGVja2VkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKHJhZGlvLmlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBjdXJDaGVja2VkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc3BhdGNoRXZlbnRGcm9tU2FuZGJveChhY3Rpb25zLCBqc0V2ZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RXZlbnRMaXN0ZW5lcnMoZWxlbWVudCwgW1siY2hhbmdlIiwgIlZhbGlkYXRlIl0sIFsiY2hhbmdlIiwgIkFjdGlvbiJdLCBbImZvY3VzIiwgIkZvY3VzIl0sIFsiYmx1ciIsICJCbHVyIl0sIFsibW91c2Vkb3duIiwgIk1vdXNlIERvd24iXSwgWyJtb3VzZWVudGVyIiwgIk1vdXNlIEVudGVyIl0sIFsibW91c2VsZWF2ZSIsICJNb3VzZSBFeGl0Il0sIFsibW91c2V1cCIsICJNb3VzZSBVcCJdXSwgZXZlbnQgPT4gZXZlbnQudGFyZ2V0LmNoZWNrZWQpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldEJhY2tncm91bmRDb2xvcihlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RGVmYXVsdFByb3BlcnRpZXNGcm9tSlMoZWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFB1c2hCdXR0b25XaWRnZXRBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIExpbmtBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXI6IHBhcmFtZXRlcnMuZGF0YS5oYXNBcHBlYXJhbmNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRhaW5lciA9IHN1cGVyLnJlbmRlcigpOwogICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIuY2xhc3NMaXN0LmFkZCgiYnV0dG9uV2lkZ2V0QW5ub3RhdGlvbiIsICJwdXNoQnV0dG9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEuYWx0ZXJuYXRpdmVUZXh0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXIudGl0bGUgPSB0aGlzLmRhdGEuYWx0ZXJuYXRpdmVUZXh0OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmtFbGVtZW50ID0gY29udGFpbmVyLmxhc3RDaGlsZDsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuZW5hYmxlU2NyaXB0aW5nICYmIHRoaXMuaGFzSlNBY3Rpb25zICYmIGxpbmtFbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXREZWZhdWx0UHJvcGVydGllc0Zyb21KUyhsaW5rRWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5rRWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJ1cGRhdGVmcm9tc2FuZGJveCIsIGpzRXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Rpc3BhdGNoRXZlbnRGcm9tU2FuZGJveCh7fSwganNFdmVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIENob2ljZVdpZGdldEFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgV2lkZ2V0QW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlOiBwYXJhbWV0ZXJzLnJlbmRlckZvcm1zCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoImNob2ljZVdpZGdldEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RvcmFnZSA9IHRoaXMuYW5ub3RhdGlvblN0b3JhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkID0gdGhpcy5kYXRhLmlkOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdG9yZWREYXRhID0gc3RvcmFnZS5nZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRoaXMuZGF0YS5maWVsZFZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzZWxlY3RFbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic2VsZWN0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIEdldEVsZW1lbnRzQnlOYW1lU2V0LmFkZChzZWxlY3RFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5zZXRBdHRyaWJ1dGUoImRhdGEtZWxlbWVudC1pZCIsIGlkKTsKICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5kaXNhYmxlZCA9IHRoaXMuZGF0YS5yZWFkT25seTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0UmVxdWlyZWQoc2VsZWN0RWxlbWVudCwgdGhpcy5kYXRhLnJlcXVpcmVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5uYW1lID0gdGhpcy5kYXRhLmZpZWxkTmFtZTsKICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC50YWJJbmRleCA9IERFRkFVTFRfVEFCX0lOREVYOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYWRkQW5FbXB0eUVudHJ5ID0gdGhpcy5kYXRhLmNvbWJvICYmIHRoaXMuZGF0YS5vcHRpb25zLmxlbmd0aCA+IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhLmNvbWJvKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LnNpemUgPSB0aGlzLmRhdGEub3B0aW9ucy5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5kYXRhLm11bHRpU2VsZWN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5tdWx0aXBsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJyZXNldGZvcm0iLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZhdWx0VmFsdWUgPSB0aGlzLmRhdGEuZGVmYXVsdEZpZWxkVmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG9wdGlvbiBvZiBzZWxlY3RFbGVtZW50Lm9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb24uc2VsZWN0ZWQgPSBvcHRpb24udmFsdWUgPT09IGRlZmF1bHRWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgb3B0aW9uIG9mIHRoaXMuZGF0YS5vcHRpb25zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvcHRpb25FbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgib3B0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25FbGVtZW50LnRleHRDb250ZW50ID0gb3B0aW9uLmRpc3BsYXlWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbkVsZW1lbnQudmFsdWUgPSBvcHRpb24uZXhwb3J0VmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RvcmVkRGF0YS52YWx1ZS5pbmNsdWRlcyhvcHRpb24uZXhwb3J0VmFsdWUpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uRWxlbWVudC5zZXRBdHRyaWJ1dGUoInNlbGVjdGVkIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYWRkQW5FbXB0eUVudHJ5ID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LmFwcGVuZChvcHRpb25FbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcmVtb3ZlRW1wdHlFbnRyeSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhZGRBbkVtcHR5RW50cnkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vbmVPcHRpb25FbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgib3B0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub25lT3B0aW9uRWxlbWVudC52YWx1ZSA9ICIgIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vbmVPcHRpb25FbGVtZW50LnNldEF0dHJpYnV0ZSgiaGlkZGVuIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub25lT3B0aW9uRWxlbWVudC5zZXRBdHRyaWJ1dGUoInNlbGVjdGVkIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LnByZXBlbmQobm9uZU9wdGlvbkVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVtb3ZlRW1wdHlFbnRyeSA9ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBub25lT3B0aW9uRWxlbWVudC5yZW1vdmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LnJlbW92ZUV2ZW50TGlzdGVuZXIoImlucHV0IiwgcmVtb3ZlRW1wdHlFbnRyeSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVtb3ZlRW1wdHlFbnRyeSA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJpbnB1dCIsIHJlbW92ZUVtcHR5RW50cnkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGdldFZhbHVlID0gaXNFeHBvcnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbmFtZSA9IGlzRXhwb3J0ID8gInZhbHVlIiA6ICJ0ZXh0Q29udGVudCI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9ucywKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdWx0aXBsZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHNlbGVjdEVsZW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIW11bHRpcGxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG9wdGlvbnMuc2VsZWN0ZWRJbmRleCA9PT0gLTEgPyBudWxsIDogb3B0aW9uc1tvcHRpb25zLnNlbGVjdGVkSW5kZXhdW25hbWVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEFycmF5LnByb3RvdHlwZS5maWx0ZXIuY2FsbChvcHRpb25zLCBvcHRpb24gPT4gb3B0aW9uLnNlbGVjdGVkKS5tYXAob3B0aW9uID0+IG9wdGlvbltuYW1lXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzZWxlY3RlZFZhbHVlcyA9IGdldFZhbHVlKGZhbHNlKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZ2V0SXRlbXMgPSBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvcHRpb25zID0gZXZlbnQudGFyZ2V0Lm9wdGlvbnM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gQXJyYXkucHJvdG90eXBlLm1hcC5jYWxsKG9wdGlvbnMsIG9wdGlvbiA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlzcGxheVZhbHVlOiBvcHRpb24udGV4dENvbnRlbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4cG9ydFZhbHVlOiBvcHRpb24udmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmVuYWJsZVNjcmlwdGluZyAmJiB0aGlzLmhhc0pTQWN0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJ1cGRhdGVmcm9tc2FuZGJveCIsIGpzRXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFjdGlvbnMgPSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3JlbW92ZUVtcHR5RW50cnk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoX3JlbW92ZUVtcHR5RW50cnkgPSByZW1vdmVFbXB0eUVudHJ5KSA9PT0gbnVsbCB8fCBfcmVtb3ZlRW1wdHlFbnRyeSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3JlbW92ZUVtcHR5RW50cnkoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZhbHVlID0gZXZlbnQuZGV0YWlsLnZhbHVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdmFsdWVzID0gbmV3IFNldChBcnJheS5pc0FycmF5KHZhbHVlKSA/IHZhbHVlIDogW3ZhbHVlXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG9wdGlvbiBvZiBzZWxlY3RFbGVtZW50Lm9wdGlvbnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb24uc2VsZWN0ZWQgPSB2YWx1ZXMuaGFzKG9wdGlvbi52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGdldFZhbHVlKHRydWUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtdWx0aXBsZVNlbGVjdGlvbihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5tdWx0aXBsZSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlbW92ZShldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3B0aW9ucyA9IHNlbGVjdEVsZW1lbnQub3B0aW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGluZGV4ID0gZXZlbnQuZGV0YWlsLnJlbW92ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbnNbaW5kZXhdLnNlbGVjdGVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LnJlbW92ZShpbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3B0aW9ucy5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaSA9IEFycmF5LnByb3RvdHlwZS5maW5kSW5kZXguY2FsbChvcHRpb25zLCBvcHRpb24gPT4gb3B0aW9uLnNlbGVjdGVkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaSA9PT0gLTEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uc1swXS5zZWxlY3RlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBnZXRWYWx1ZSh0cnVlKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtczogZ2V0SXRlbXMoZXZlbnQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGVhcihldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHNlbGVjdEVsZW1lbnQubGVuZ3RoICE9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5yZW1vdmUoMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlbXM6IFtdCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnNlcnQoZXZlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRleCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXNwbGF5VmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXhwb3J0VmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBldmVudC5kZXRhaWwuaW5zZXJ0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2VsZWN0Q2hpbGQgPSBzZWxlY3RFbGVtZW50LmNoaWxkcmVuW2luZGV4XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9wdGlvbkVsZW1lbnQgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJvcHRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbkVsZW1lbnQudGV4dENvbnRlbnQgPSBkaXNwbGF5VmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25FbGVtZW50LnZhbHVlID0gZXhwb3J0VmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZWN0Q2hpbGQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RDaGlsZC5iZWZvcmUob3B0aW9uRWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdEVsZW1lbnQuYXBwZW5kKG9wdGlvbkVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBnZXRWYWx1ZSh0cnVlKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtczogZ2V0SXRlbXMoZXZlbnQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtcyhldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW1zCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZXZlbnQuZGV0YWlsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHNlbGVjdEVsZW1lbnQubGVuZ3RoICE9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5yZW1vdmUoMCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGl0ZW0gb2YgaXRlbXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpc3BsYXlWYWx1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXhwb3J0VmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gaXRlbTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvcHRpb25FbGVtZW50ID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgib3B0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3B0aW9uRWxlbWVudC50ZXh0Q29udGVudCA9IGRpc3BsYXlWYWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb25FbGVtZW50LnZhbHVlID0gZXhwb3J0VmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5hcHBlbmQob3B0aW9uRWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc2VsZWN0RWxlbWVudC5vcHRpb25zLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50Lm9wdGlvbnNbMF0uc2VsZWN0ZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBnZXRWYWx1ZSh0cnVlKSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtczogZ2V0SXRlbXMoZXZlbnQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmRpY2VzKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbmRpY2VzID0gbmV3IFNldChldmVudC5kZXRhaWwuaW5kaWNlcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG9wdGlvbiBvZiBldmVudC50YXJnZXQub3B0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wdGlvbi5zZWxlY3RlZCA9IGluZGljZXMuaGFzKG9wdGlvbi5pbmRleCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlLnNldFZhbHVlKGlkLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IGdldFZhbHVlKHRydWUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdGVkVmFsdWVzID0gZ2V0VmFsdWUoZmFsc2UpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlZGl0YWJsZShldmVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXZlbnQudGFyZ2V0LmRpc2FibGVkID0gIWV2ZW50LmRldGFpbC5lZGl0YWJsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGlzcGF0Y2hFdmVudEZyb21TYW5kYm94KGFjdGlvbnMsIGpzRXZlbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoImlucHV0IiwgZXZlbnQgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmU5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGV4cG9ydFZhbHVlID0gZ2V0VmFsdWUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZXhwb3J0VmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBldmVudC5wcmV2ZW50RGVmYXVsdCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRsaW5rU2VydmljZSRldmU5ID0gdGhpcy5saW5rU2VydmljZS5ldmVudEJ1cykgPT09IG51bGwgfHwgX3RoaXMkbGlua1NlcnZpY2UkZXZlOSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkbGlua1NlcnZpY2UkZXZlOS5kaXNwYXRjaCgiZGlzcGF0Y2hldmVudGluc2FuZGJveCIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlOiB0aGlzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZXRhaWw6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbmFtZTogIktleXN0cm9rZSIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogc2VsZWN0ZWRWYWx1ZXMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGFuZ2VFeDogZXhwb3J0VmFsdWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWxsQ29tbWl0OiBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1pdEtleTogMSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtleURvd246IGZhbHNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RXZlbnRMaXN0ZW5lcnMoc2VsZWN0RWxlbWVudCwgW1siZm9jdXMiLCAiRm9jdXMiXSwgWyJibHVyIiwgIkJsdXIiXSwgWyJtb3VzZWRvd24iLCAiTW91c2UgRG93biJdLCBbIm1vdXNlZW50ZXIiLCAiTW91c2UgRW50ZXIiXSwgWyJtb3VzZWxlYXZlIiwgIk1vdXNlIEV4aXQiXSwgWyJtb3VzZXVwIiwgIk1vdXNlIFVwIl0sIFsiaW5wdXQiLCAiQWN0aW9uIl0sIFsiaW5wdXQiLCAiVmFsaWRhdGUiXV0sIGV2ZW50ID0+IGV2ZW50LnRhcmdldC52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoImlucHV0IiwgZnVuY3Rpb24gKGV2ZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZ2V0VmFsdWUodHJ1ZSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEuY29tYm8pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldFRleHRTdHlsZShzZWxlY3RFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHt9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX3NldEJhY2tncm91bmRDb2xvcihzZWxlY3RFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fc2V0RGVmYXVsdFByb3BlcnRpZXNGcm9tSlMoc2VsZWN0RWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChzZWxlY3RFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBvcHVwQW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIElHTk9SRV9UWVBFUyA9IG5ldyBTZXQoWyJMaW5lIiwgIlNxdWFyZSIsICJDaXJjbGUiLCAiUG9seUxpbmUiLCAiUG9seWdvbiIsICJJbmsiXSk7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX2RhdGEkdGl0bGVPYmosIF9kYXRhJGNvbnRlbnRzT2JqLCBfZGF0YSRyaWNoVGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YQogICAgICAgICAgICAgICAgICAgICAgICB9ID0gcGFyYW1ldGVyczsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gIVBvcHVwQW5ub3RhdGlvbkVsZW1lbnQuSUdOT1JFX1RZUEVTLmhhcyhkYXRhLnBhcmVudFR5cGUpICYmICEhKChfZGF0YSR0aXRsZU9iaiA9IGRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9kYXRhJHRpdGxlT2JqICE9PSB2b2lkIDAgJiYgX2RhdGEkdGl0bGVPYmouc3RyIHx8IChfZGF0YSRjb250ZW50c09iaiA9IGRhdGEuY29udGVudHNPYmopICE9PSBudWxsICYmIF9kYXRhJGNvbnRlbnRzT2JqICE9PSB2b2lkIDAgJiYgX2RhdGEkY29udGVudHNPYmouc3RyIHx8IChfZGF0YSRyaWNoVGV4dCA9IGRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9kYXRhJHJpY2hUZXh0ICE9PSB2b2lkIDAgJiYgX2RhdGEkcmljaFRleHQuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInBvcHVwQW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwYXJlbnRFbGVtZW50cyA9IHRoaXMubGF5ZXIucXVlcnlTZWxlY3RvckFsbChgW2RhdGEtYW5ub3RhdGlvbi1pZD0iJHt0aGlzLmRhdGEucGFyZW50SWR9Il1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBhcmVudEVsZW1lbnRzLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBvcHVwID0gbmV3IFBvcHVwRWxlbWVudCh7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250YWluZXI6IHRoaXMuY29udGFpbmVyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlcjogQXJyYXkuZnJvbShwYXJlbnRFbGVtZW50cyksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2xvcjogdGhpcy5kYXRhLmNvbG9yLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGl0bGVPYmo6IHRoaXMuZGF0YS50aXRsZU9iaiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGlmaWNhdGlvbkRhdGU6IHRoaXMuZGF0YS5tb2RpZmljYXRpb25EYXRlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudHNPYmo6IHRoaXMuZGF0YS5jb250ZW50c09iaiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJpY2hUZXh0OiB0aGlzLmRhdGEucmljaFRleHQKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBhZ2UgPSB0aGlzLnBhZ2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSBfdXRpbC5VdGlsLm5vcm1hbGl6ZVJlY3QoW3RoaXMuZGF0YS5wYXJlbnRSZWN0WzBdLCBwYWdlLnZpZXdbM10gLSB0aGlzLmRhdGEucGFyZW50UmVjdFsxXSArIHBhZ2Uudmlld1sxXSwgdGhpcy5kYXRhLnBhcmVudFJlY3RbMl0sIHBhZ2Uudmlld1szXSAtIHRoaXMuZGF0YS5wYXJlbnRSZWN0WzNdICsgcGFnZS52aWV3WzFdXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBvcHVwTGVmdCA9IHJlY3RbMF0gKyB0aGlzLmRhdGEucGFyZW50UmVjdFsyXSAtIHRoaXMuZGF0YS5wYXJlbnRSZWN0WzBdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb3B1cFRvcCA9IHJlY3RbMV07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VXaWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VIZWlnaHQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlWCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2VZCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSB0aGlzLnZpZXdwb3J0LnJhd0RpbXM7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLnN0eWxlLmxlZnQgPSBgJHsxMDAgKiAocG9wdXBMZWZ0IC0gcGFnZVgpIC8gcGFnZVdpZHRofSVgOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5zdHlsZS50b3AgPSBgJHsxMDAgKiAocG9wdXBUb3AgLSBwYWdlWSkgLyBwYWdlSGVpZ2h0fSVgOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQocG9wdXAucmVuZGVyKCkpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUG9wdXBFbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyID0gcGFyYW1ldGVycy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJpZ2dlciA9IHBhcmFtZXRlcnMudHJpZ2dlcjsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb2xvciA9IHBhcmFtZXRlcnMuY29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGl0bGVPYmogPSBwYXJhbWV0ZXJzLnRpdGxlT2JqOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1vZGlmaWNhdGlvbkRhdGUgPSBwYXJhbWV0ZXJzLm1vZGlmaWNhdGlvbkRhdGU7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGVudHNPYmogPSBwYXJhbWV0ZXJzLmNvbnRlbnRzT2JqOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJpY2hUZXh0ID0gcGFyYW1ldGVycy5yaWNoVGV4dDsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5oaWRlV3JhcHBlciA9IHBhcmFtZXRlcnMuaGlkZVdyYXBwZXIgfHwgZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGlubmVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJHJpY2hUZXh0LCBfdGhpcyRjb250ZW50c09iajsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQkFDS0dST1VORF9FTkxJR0hUID0gMC43OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3cmFwcGVyID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIHdyYXBwZXIuY2xhc3NMaXN0LmFkZCgicG9wdXBXcmFwcGVyIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuaGlkZUVsZW1lbnQgPSB0aGlzLmhpZGVXcmFwcGVyID8gd3JhcHBlciA6IHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmhpZGVFbGVtZW50LmhpZGRlbiA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBvcHVwID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgiZGl2Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvcHVwLmNsYXNzTGlzdC5hZGQoInBvcHVwIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gdGhpcy5jb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNvbG9yKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByID0gQkFDS0dST1VORF9FTkxJR0hUICogKDI1NSAtIGNvbG9yWzBdKSArIGNvbG9yWzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZyA9IEJBQ0tHUk9VTkRfRU5MSUdIVCAqICgyNTUgLSBjb2xvclsxXSkgKyBjb2xvclsxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGIgPSBCQUNLR1JPVU5EX0VOTElHSFQgKiAoMjU1IC0gY29sb3JbMl0pICsgY29sb3JbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb3B1cC5zdHlsZS5iYWNrZ3JvdW5kQ29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihyIHwgMCwgZyB8IDAsIGIgfCAwKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0aXRsZSA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImgxIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRpdGxlLmRpciA9IHRoaXMudGl0bGVPYmouZGlyOwogICAgICAgICAgICAgICAgICAgICAgICB0aXRsZS50ZXh0Q29udGVudCA9IHRoaXMudGl0bGVPYmouc3RyOwogICAgICAgICAgICAgICAgICAgICAgICBwb3B1cC5hcHBlbmQodGl0bGUpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRlT2JqZWN0ID0gX2Rpc3BsYXlfdXRpbHMuUERGRGF0ZVN0cmluZy50b0RhdGVPYmplY3QodGhpcy5tb2RpZmljYXRpb25EYXRlKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGVPYmplY3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG1vZGlmaWNhdGlvbkRhdGUgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJzcGFuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb2RpZmljYXRpb25EYXRlLmNsYXNzTGlzdC5hZGQoInBvcHVwRGF0ZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9kaWZpY2F0aW9uRGF0ZS50ZXh0Q29udGVudCA9ICJ7e2RhdGV9fSwge3t0aW1lfX0iOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbW9kaWZpY2F0aW9uRGF0ZS5kYXRhc2V0LmwxMG5JZCA9ICJhbm5vdGF0aW9uX2RhdGVfc3RyaW5nIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZGlmaWNhdGlvbkRhdGUuZGF0YXNldC5sMTBuQXJncyA9IEpTT04uc3RyaW5naWZ5KHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRlOiBkYXRlT2JqZWN0LnRvTG9jYWxlRGF0ZVN0cmluZygpLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpbWU6IGRhdGVPYmplY3QudG9Mb2NhbGVUaW1lU3RyaW5nKCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9wdXAuYXBwZW5kKG1vZGlmaWNhdGlvbkRhdGUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgoX3RoaXMkcmljaFRleHQgPSB0aGlzLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfdGhpcyRyaWNoVGV4dCAhPT0gdm9pZCAwICYmIF90aGlzJHJpY2hUZXh0LnN0ciAmJiAoISgoX3RoaXMkY29udGVudHNPYmogPSB0aGlzLmNvbnRlbnRzT2JqKSAhPT0gbnVsbCAmJiBfdGhpcyRjb250ZW50c09iaiAhPT0gdm9pZCAwICYmIF90aGlzJGNvbnRlbnRzT2JqLnN0cikgfHwgdGhpcy5jb250ZW50c09iai5zdHIgPT09IHRoaXMucmljaFRleHQuc3RyKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgX3hmYV9sYXllci5YZmFMYXllci5yZW5kZXIoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhmYUh0bWw6IHRoaXMucmljaFRleHQuaHRtbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbnRlbnQ6ICJyaWNoVGV4dCIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2OiBwb3B1cAogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb3B1cC5sYXN0Q2hpbGQuY2xhc3NMaXN0LmFkZCgicmljaFRleHQiLCAicG9wdXBDb250ZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjb250ZW50cyA9IHRoaXMuX2Zvcm1hdENvbnRlbnRzKHRoaXMuY29udGVudHNPYmopOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcG9wdXAuYXBwZW5kKGNvbnRlbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIUFycmF5LmlzQXJyYXkodGhpcy50cmlnZ2VyKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmlnZ2VyID0gW3RoaXMudHJpZ2dlcl07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBlbGVtZW50IG9mIHRoaXMudHJpZ2dlcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCJjbGljayIsIHRoaXMuX3RvZ2dsZS5iaW5kKHRoaXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigibW91c2VvdmVyIiwgdGhpcy5fc2hvdy5iaW5kKHRoaXMsIGZhbHNlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoIm1vdXNlb3V0IiwgdGhpcy5faGlkZS5iaW5kKHRoaXMsIGZhbHNlKSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcG9wdXAuYWRkRXZlbnRMaXN0ZW5lcigiY2xpY2siLCB0aGlzLl9oaWRlLmJpbmQodGhpcywgdHJ1ZSkpOwogICAgICAgICAgICAgICAgICAgICAgICB3cmFwcGVyLmFwcGVuZChwb3B1cCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB3cmFwcGVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZm9ybWF0Q29udGVudHMoX3JlZikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RyLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGlyCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgicCIpOwogICAgICAgICAgICAgICAgICAgICAgICBwLmNsYXNzTGlzdC5hZGQoInBvcHVwQ29udGVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBwLmRpciA9IGRpcjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGluZXMgPSBzdHIuc3BsaXQoLyg/OlxyXG4/fFxuKS8pOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBsaW5lcy5sZW5ndGg7IGkgPCBpaTsgKytpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBsaW5lID0gbGluZXNbaV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwLmFwcGVuZChkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZShsaW5lKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaSA8IGlpIC0gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHAuYXBwZW5kKGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImJyIikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBwOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfdG9nZ2xlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5waW5uZWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2hpZGUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zaG93KHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9zaG93KCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcGluID0gYXJndW1lbnRzLmxlbmd0aCA+IDAgJiYgYXJndW1lbnRzWzBdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMF0gOiBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHBpbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5waW5uZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmhpZGVFbGVtZW50LmhpZGRlbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5oaWRlRWxlbWVudC5oaWRkZW4gPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLnN0eWxlLnpJbmRleCA9IHBhcnNlSW50KHRoaXMuY29udGFpbmVyLnN0eWxlLnpJbmRleCkgKyAxMDAwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIF9oaWRlKCkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgdW5waW4gPSBhcmd1bWVudHMubGVuZ3RoID4gMCAmJiBhcmd1bWVudHNbMF0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1swXSA6IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh1bnBpbikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5waW5uZWQgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaGlkZUVsZW1lbnQuaGlkZGVuICYmICF0aGlzLnBpbm5lZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5oaWRlRWxlbWVudC5oaWRkZW4gPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuc3R5bGUuekluZGV4ID0gcGFyc2VJbnQodGhpcy5jb250YWluZXIuc3R5bGUuekluZGV4KSAtIDEwMDA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KIC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ICAgICAgICAgICAgICAgIGlnbm9yZUJvcmRlcjogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50ZXh0Q29udGVudCA9IHBhcmFtZXRlcnMuZGF0YS50ZXh0Q29udGVudDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJmcmVlVGV4dEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMudGV4dENvbnRlbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnRlbnQgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCJkaXYiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQuY2xhc3NMaXN0LmFkZCgiYW5ub3RhdGlvblRleHRDb250ZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50LnNldEF0dHJpYnV0ZSgicm9sZSIsICJjb21tZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGxpbmUgb2YgdGhpcy50ZXh0Q29udGVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmVTcGFuID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic3BhbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVTcGFuLnRleHRDb250ZW50ID0gbGluZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250ZW50LmFwcGVuZChsaW5lU3Bhbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoY29udGVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIExpbmVBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGFyYW1ldGVycyRkYXRhJHRpdGwzLCBfcGFyYW1ldGVycyRkYXRhJGNvbnQzLCBfcGFyYW1ldGVycyRkYXRhJHJpY2gzOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1JlbmRlcmFibGUgPSAhIShwYXJhbWV0ZXJzLmRhdGEuaGFzUG9wdXAgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDMgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDMgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGwzLnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRjb250MyA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250MyAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDMuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJHJpY2gzID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2gzICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMy5zdHIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlbmRlcmFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXI6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCgibGluZUFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHRoaXMuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUod2lkdGgsIGhlaWdodCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmUgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOmxpbmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluZS5zZXRBdHRyaWJ1dGUoIngxIiwgZGF0YS5yZWN0WzJdIC0gZGF0YS5saW5lQ29vcmRpbmF0ZXNbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5lLnNldEF0dHJpYnV0ZSgieTEiLCBkYXRhLnJlY3RbM10gLSBkYXRhLmxpbmVDb29yZGluYXRlc1sxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGxpbmUuc2V0QXR0cmlidXRlKCJ4MiIsIGRhdGEucmVjdFsyXSAtIGRhdGEubGluZUNvb3JkaW5hdGVzWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluZS5zZXRBdHRyaWJ1dGUoInkyIiwgZGF0YS5yZWN0WzNdIC0gZGF0YS5saW5lQ29vcmRpbmF0ZXNbM10pOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlLXdpZHRoIiwgZGF0YS5ib3JkZXJTdHlsZS53aWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGluZS5zZXRBdHRyaWJ1dGUoInN0cm9rZSIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBsaW5lLnNldEF0dHJpYnV0ZSgiZmlsbCIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuYXBwZW5kKGxpbmUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoc3ZnKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAobGluZSwgZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBTcXVhcmVBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfcGFyYW1ldGVycyRkYXRhJHRpdGw0LCBfcGFyYW1ldGVycyRkYXRhJGNvbnQ0LCBfcGFyYW1ldGVycyRkYXRhJHJpY2g0OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc1JlbmRlcmFibGUgPSAhIShwYXJhbWV0ZXJzLmRhdGEuaGFzUG9wdXAgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDQgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDQgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw0LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRjb250NCA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250NCAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDQuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJHJpY2g0ID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2g0ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNC5zdHIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpc1JlbmRlcmFibGUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZ25vcmVCb3JkZXI6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCgic3F1YXJlQW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkYXRhID0gdGhpcy5kYXRhOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aWR0aCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlaWdodAogICAgICAgICAgICAgICAgICAgICAgICB9ID0gZ2V0UmVjdERpbXMoZGF0YS5yZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ZnID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZSh3aWR0aCwgaGVpZ2h0LCB0cnVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYm9yZGVyV2lkdGggPSBkYXRhLmJvcmRlclN0eWxlLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcXVhcmUgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOnJlY3QiKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3F1YXJlLnNldEF0dHJpYnV0ZSgieCIsIGJvcmRlcldpZHRoIC8gMik7CiAgICAgICAgICAgICAgICAgICAgICAgIHNxdWFyZS5zZXRBdHRyaWJ1dGUoInkiLCBib3JkZXJXaWR0aCAvIDIpOwogICAgICAgICAgICAgICAgICAgICAgICBzcXVhcmUuc2V0QXR0cmlidXRlKCJ3aWR0aCIsIHdpZHRoIC0gYm9yZGVyV2lkdGgpOwogICAgICAgICAgICAgICAgICAgICAgICBzcXVhcmUuc2V0QXR0cmlidXRlKCJoZWlnaHQiLCBoZWlnaHQgLSBib3JkZXJXaWR0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgIHNxdWFyZS5zZXRBdHRyaWJ1dGUoInN0cm9rZS13aWR0aCIsIGJvcmRlcldpZHRoIHx8IDEpOwogICAgICAgICAgICAgICAgICAgICAgICBzcXVhcmUuc2V0QXR0cmlidXRlKCJzdHJva2UiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3F1YXJlLnNldEF0dHJpYnV0ZSgiZmlsbCIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICBzdmcuYXBwZW5kKHNxdWFyZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChzdmcpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cChzcXVhcmUsIGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgQ2lyY2xlQW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNSwgX3BhcmFtZXRlcnMkZGF0YSRjb250NSwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGw1ID0gcGFyYW1ldGVycy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw1ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNS5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDUgPSBwYXJhbWV0ZXJzLmRhdGEuY29udGVudHNPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDUgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQ1LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoNSA9IHBhcmFtZXRlcnMuZGF0YS5yaWNoVGV4dCkgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNSAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDUuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoImNpcmNsZUFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHRoaXMuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUod2lkdGgsIGhlaWdodCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJvcmRlcldpZHRoID0gZGF0YS5ib3JkZXJTdHlsZS53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2lyY2xlID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzplbGxpcHNlIik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNpcmNsZS5zZXRBdHRyaWJ1dGUoImN4Iiwgd2lkdGggLyAyKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2lyY2xlLnNldEF0dHJpYnV0ZSgiY3kiLCBoZWlnaHQgLyAyKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2lyY2xlLnNldEF0dHJpYnV0ZSgicngiLCB3aWR0aCAvIDIgLSBib3JkZXJXaWR0aCAvIDIpOwogICAgICAgICAgICAgICAgICAgICAgICBjaXJjbGUuc2V0QXR0cmlidXRlKCJyeSIsIGhlaWdodCAvIDIgLSBib3JkZXJXaWR0aCAvIDIpOwogICAgICAgICAgICAgICAgICAgICAgICBjaXJjbGUuc2V0QXR0cmlidXRlKCJzdHJva2Utd2lkdGgiLCBib3JkZXJXaWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgY2lyY2xlLnNldEF0dHJpYnV0ZSgic3Ryb2tlIiwgInRyYW5zcGFyZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIGNpcmNsZS5zZXRBdHRyaWJ1dGUoImZpbGwiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLmFwcGVuZChjaXJjbGUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoc3ZnKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAoY2lyY2xlLCBkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFBvbHlsaW5lQW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNiwgX3BhcmFtZXRlcnMkZGF0YSRjb250NiwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGw2ID0gcGFyYW1ldGVycy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw2ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsNi5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDYgPSBwYXJhbWV0ZXJzLmRhdGEuY29udGVudHNPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDYgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQ2LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoNiA9IHBhcmFtZXRlcnMuZGF0YS5yaWNoVGV4dCkgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoNiAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDYuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lckNsYXNzTmFtZSA9ICJwb2x5bGluZUFubm90YXRpb24iOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN2Z0VsZW1lbnROYW1lID0gInN2Zzpwb2x5bGluZSI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXIuY2xhc3NMaXN0LmFkZCh0aGlzLmNvbnRhaW5lckNsYXNzTmFtZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSB0aGlzLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVpZ2h0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBnZXRSZWN0RGltcyhkYXRhLnJlY3QpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdmcgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlKHdpZHRoLCBoZWlnaHQsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcG9pbnRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgY29vcmRpbmF0ZSBvZiBkYXRhLnZlcnRpY2VzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4ID0gY29vcmRpbmF0ZS54IC0gZGF0YS5yZWN0WzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeSA9IGRhdGEucmVjdFszXSAtIGNvb3JkaW5hdGUueTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvaW50cy5wdXNoKHggKyAiLCIgKyB5KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMgPSBwb2ludHMuam9pbigiICIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBwb2x5bGluZSA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KHRoaXMuc3ZnRWxlbWVudE5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICBwb2x5bGluZS5zZXRBdHRyaWJ1dGUoInBvaW50cyIsIHBvaW50cyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlLXdpZHRoIiwgZGF0YS5ib3JkZXJTdHlsZS53aWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9seWxpbmUuc2V0QXR0cmlidXRlKCJzdHJva2UiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgcG9seWxpbmUuc2V0QXR0cmlidXRlKCJmaWxsIiwgInRyYW5zcGFyZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5hcHBlbmQocG9seWxpbmUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5hcHBlbmQoc3ZnKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAocG9seWxpbmUsIGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgUG9seWdvbkFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgUG9seWxpbmVBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBzdXBlcihwYXJhbWV0ZXJzKTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXJDbGFzc05hbWUgPSAicG9seWdvbkFubm90YXRpb24iOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN2Z0VsZW1lbnROYW1lID0gInN2Zzpwb2x5Z29uIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDYXJldEFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgQW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICA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gKF9wYXJhbWV0ZXJzJGRhdGEkcmljaDggPSBwYXJhbWV0ZXJzLmRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDggIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2g4LnN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHBhcmFtZXRlcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVuZGVyYWJsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlnbm9yZUJvcmRlcjogdHJ1ZQogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb250YWluZXJDbGFzc05hbWUgPSAiaW5rQW5ub3RhdGlvbiI7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3ZnRWxlbWVudE5hbWUgPSAic3ZnOnBvbHlsaW5lIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKHRoaXMuY29udGFpbmVyQ2xhc3NOYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZGF0YSA9IHRoaXMuZGF0YTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGgsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGdldFJlY3REaW1zKGRhdGEucmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUod2lkdGgsIGhlaWdodCwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW5rTGlzdCBvZiBkYXRhLmlua0xpc3RzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgcG9pbnRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGNvb3JkaW5hdGUgb2YgaW5rTGlzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHggPSBjb29yZGluYXRlLnggLSBkYXRhLnJlY3RbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeSA9IGRhdGEucmVjdFszXSAtIGNvb3JkaW5hdGUueTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMucHVzaChgJHt4fSwke3l9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2ludHMgPSBwb2ludHMuam9pbigiICIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcG9seWxpbmUgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCh0aGlzLnN2Z0VsZW1lbnROYW1lKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgicG9pbnRzIiwgcG9pbnRzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlLXdpZHRoIiwgZGF0YS5ib3JkZXJTdHlsZS53aWR0aCB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvbHlsaW5lLnNldEF0dHJpYnV0ZSgic3Ryb2tlIiwgInRyYW5zcGFyZW50Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwb2x5bGluZS5zZXRBdHRyaWJ1dGUoImZpbGwiLCAidHJhbnNwYXJlbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKHBvbHlsaW5lLCBkYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5hcHBlbmQocG9seWxpbmUpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZChzdmcpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgSGlnaGxpZ2h0QW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsOSwgX3BhcmFtZXRlcnMkZGF0YSRjb250OSwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoOTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGw5ID0gcGFyYW1ldGVycy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGw5ICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsOS5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDkgPSBwYXJhbWV0ZXJzLmRhdGEuY29udGVudHNPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDkgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQ5LnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoOSA9IHBhcmFtZXRlcnMuZGF0YS5yaWNoVGV4dCkgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoOSAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDkuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUXVhZHJpbGF0ZXJhbHM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucXVhZHJpbGF0ZXJhbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9yZW5kZXJRdWFkcmlsYXRlcmFscygiaGlnaGxpZ2h0QW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoImhpZ2hsaWdodEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFVuZGVybGluZUFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgQW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgI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OwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhLmhhc1BvcHVwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cChudWxsLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnF1YWRyaWxhdGVyYWxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcmVuZGVyUXVhZHJpbGF0ZXJhbHMoInVuZGVybGluZUFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJ1bmRlcmxpbmVBbm5vdGF0aW9uIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmNvbnRhaW5lcjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBTcXVpZ2dseUFubm90YXRpb25FbGVtZW50IGV4dGVuZHMgQW5ub3RhdGlvbkVsZW1lbnQgewogICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKHBhcmFtZXRlcnMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDExLCBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMSwgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTE7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlzUmVuZGVyYWJsZSA9ICEhKHBhcmFtZXRlcnMuZGF0YS5oYXNQb3B1cCB8fCAoX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTEgPSBwYXJhbWV0ZXJzLmRhdGEudGl0bGVPYmopICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkdGl0bDExICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTEuc3RyIHx8IChfcGFyYW1ldGVycyRkYXRhJGNvbnQxMSA9IHBhcmFtZXRlcnMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSRjb250MTEgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMS5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkcmljaDExID0gcGFyYW1ldGVycy5kYXRhLnJpY2hUZXh0KSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJHJpY2gxMSAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDExLnN0cik7CiAgICAgICAgICAgICAgICAgICAgICAgIHN1cGVyKHBhcmFtZXRlcnMsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzUmVuZGVyYWJsZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlnbm9yZUJvcmRlcjogdHJ1ZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyZWF0ZVF1YWRyaWxhdGVyYWxzOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5kYXRhLmhhc1BvcHVwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cChudWxsLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnF1YWRyaWxhdGVyYWxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fcmVu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mRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDEyICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTIuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JlYXRlUXVhZHJpbGF0ZXJhbHM6IHRydWUKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHJlbmRlcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2NyZWF0ZVBvcHVwKG51bGwsIHRoaXMuZGF0YSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucXVhZHJpbGF0ZXJhbHMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9yZW5kZXJRdWFkcmlsYXRlcmFscygic3RyaWtlb3V0QW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInN0cmlrZW91dEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNsYXNzIFN0YW1wQW5ub3RhdGlvbkVsZW1lbnQgZXh0ZW5kcyBBbm5vdGF0aW9uRWxlbWVudCB7CiAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0b3IocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTMsIF9wYXJhbWV0ZXJzJGRhdGEkY29udDEzLCBfcGFyYW1ldGVycyRkYXRhJHJpY2gxMzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXNSZW5kZXJhYmxlID0gISEocGFyYW1ldGVycy5kYXRhLmhhc1BvcHVwIHx8IChfcGFyYW1ldGVycyRkYXRhJHRpdGwxMyA9IHBhcmFtZXRlcnMuZGF0YS50aXRsZU9iaikgIT09IG51bGwgJiYgX3BhcmFtZXRlcnMkZGF0YSR0aXRsMTMgIT09IHZvaWQgMCAmJiBfcGFyYW1ldGVycyRkYXRhJHRpdGwxMy5zdHIgfHwgKF9wYXJhbWV0ZXJzJGRhdGEkY29udDEzID0gcGFyYW1ldGVycy5kYXRhLmNvbnRlbnRzT2JqKSAhPT0gbnVsbCAmJiBfcGFyYW1ldGVycyRkYXRhJGNvbnQxMyAhPT0gdm9pZCAwICYmIF9wYXJhbWV0ZXJzJGRhdGEkY29udDEzLnN0ciB8fCAoX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTMgPSBwYXJhbWV0ZXJzLmRhdGEucmljaFRleHQpICE9PSBudWxsICYmIF9wYXJhbWV0ZXJzJGRhdGEkcmljaDEzICE9PSB2b2lkIDAgJiYgX3BhcmFtZXRlcnMkZGF0YSRyaWNoMTMuc3RyKTsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWdub3JlQm9yZGVyOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICByZW5kZXIoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmNsYXNzTGlzdC5hZGQoInN0YW1wQW5ub3RhdGlvbiIpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuZGF0YS5oYXNQb3B1cCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fY3JlYXRlUG9wdXAobnVsbCwgdGhpcy5kYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5jb250YWluZXI7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY2xhc3MgRmlsZUF0dGFjaG1lbnRBbm5vdGF0aW9uRWxlbWVudCBleHRlbmRzIEFubm90YXRpb25FbGVtZW50IHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcihwYXJhbWV0ZXJzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRsaW5rU2VydmljZSRldmUxMDsKICAgICAgICAgICAgICAgICAgICAgICAgc3VwZXIocGFyYW1ldGVycywgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaXNSZW5kZXJhYmxlOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWxlbmFtZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRlbnQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IHRoaXMuZGF0YS5maWxlOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGVuYW1lID0gKDAsIF9kaXNwbGF5X3V0aWxzLmdldEZpbGVuYW1lRnJvbVVybCkoZmlsZW5hbWUsIHRydWUpOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRlbnQgPSBjb250ZW50OwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkbGlua1NlcnZpY2UkZXZlMTAgPSB0aGlzLmxpbmtTZXJ2aWNlLmV2ZW50QnVzKSA9PT0gbnVsbCB8fCBfdGhpcyRsaW5rU2VydmljZSRldmUxMCA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkbGlua1NlcnZpY2UkZXZlMTAuZGlzcGF0Y2goImZpbGVhdHRhY2htZW50YW5ub3RhdGlvbiIsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZTogdGhpcywKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpbGVuYW1lLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGVudAogICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgcmVuZGVyKCkgewogICAgICAgICAgICAgICAgICAgICAgICB2YXIgX3RoaXMkZGF0YSR0aXRsZU9iaiwgX3RoaXMkZGF0YSRjb250ZW50c09iOwogICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbnRhaW5lci5jbGFzc0xpc3QuYWRkKCJmaWxlQXR0YWNobWVudEFubm90YXRpb24iKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHRyaWdnZXI7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmRhdGEuaGFzQXBwZWFyYW5jZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlciA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImRpdiIpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlciA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoImltZyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlci5zcmMgPSBgJHt0aGlzLmltYWdlUmVzb3VyY2VzUGF0aH1hbm5vdGF0aW9uLSR7L3BhcGVyY2xpcC9pLnRlc3QodGhpcy5kYXRhLm5hbWUpID8gInBhcGVyY2xpcCIgOiAicHVzaHBpbiJ9LnN2Z2A7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlci5jbGFzc0xpc3QuYWRkKCJwb3B1cFRyaWdnZXJBcmVhIik7CiAgICAgICAgICAgICAgICAgICAgICAgIHRyaWdnZXIuYWRkRXZlbnRMaXN0ZW5lcigiZGJsY2xpY2siLCB0aGlzLl9kb3dubG9hZC5iaW5kKHRoaXMpKTsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmRhdGEuaGFzUG9wdXAgJiYgKChfdGhpcyRkYXRhJHRpdGxlT2JqID0gdGhpcy5kYXRhLnRpdGxlT2JqKSAhPT0gbnVsbCAmJiBfdGhpcyRkYXRhJHRpdGxlT2JqICE9PSB2b2lkIDAgJiYgX3RoaXMkZGF0YSR0aXRsZU9iai5zdHIgfHwgKF90aGlzJGRhdGEkY29udGVudHNPYiA9IHRoaXMuZGF0YS5jb250ZW50c09iaikgIT09IG51bGwgJiYgX3RoaXMkZGF0YSRjb250ZW50c09iICE9PSB2b2lkIDAgJiYgX3RoaXMkZGF0YSRjb250ZW50c09iLnN0ciB8fCB0aGlzLmRhdGEucmljaFRleHQpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9jcmVhdGVQb3B1cCh0cmlnZ2VyLCB0aGlzLmRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY29udGFpbmVyLmFwcGVuZCh0cmlnZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuY29udGFpbmVyOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBfZG93bmxvYWQoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRkb3dubG9hZE1hbmFnZXIyOwogICAgICAgICAgICAgICAgICAgICAgICAoX3RoaXMkZG93bmxvYWRNYW5hZ2VyMiA9IHRoaXMuZG93bmxvYWRNYW5hZ2VyKSA9PT0gbnVsbCB8fCBfdGhpcyRkb3dubG9hZE1hbmFnZXIyID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRkb3dubG9hZE1hbmFnZXIyLm9wZW5PckRvd25sb2FkRGF0YSh0aGlzLmNvbnRhaW5lciwgdGhpcy5jb250ZW50LCB0aGlzLmZpbGVuYW1lKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBBbm5vdGF0aW9uTGF5ZXIgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyByZW5kZXIocGFyYW1zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFubm90YXRpb25zLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGl2LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlld3BvcnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhY2Nlc3NpYmlsaXR5TWFuYWdlcgogICAgICAgICAgICAgICAgICAgICAgICB9ID0gcGFyYW1zOwogICAgICAgICAgICAgICAgICAgICAgICAoMCwgX2Rpc3BsYXlfdXRpbHMuc2V0TGF5ZXJEaW1lbnNpb25zKShkaXYsIHZpZXdwb3J0KTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudFBhcmFtcyA9IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGE6IG51bGwsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsYXllcjogZGl2LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZTogcGFyYW1zLnBhZ2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aWV3cG9ydCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtTZXJ2aWNlOiBwYXJhbXMubGlua1NlcnZpY2UsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb3dubG9hZE1hbmFnZXI6IHBhcmFtcy5kb3dubG9hZE1hbmFnZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWFnZVJlc291cmNlc1BhdGg6IHBhcmFtcy5pbWFnZVJlc291cmNlc1BhdGggfHwgIiIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJGb3JtczogcGFyYW1zLnJlbmRlckZvcm1zICE9PSBmYWxzZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN2Z0ZhY3Rvcnk6IG5ldyBfZGlzcGxheV91dGlscy5ET01TVkdGYWN0b3J5KCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uU3RvcmFnZTogcGFyYW1zLmFubm90YXRpb25TdG9yYWdlIHx8IG5ldyBfYW5ub3RhdGlvbl9zdG9yYWdlLkFubm90YXRpb25TdG9yYWdlKCksCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmFibGVTY3JpcHRpbmc6IHBhcmFtcy5lbmFibGVTY3JpcHRpbmcgPT09IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBoYXNKU0FjdGlvbnM6IHBhcmFtcy5oYXNKU0FjdGlvbnMsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZE9iamVjdHM6IHBhcmFtcy5maWVsZE9iamVjdHMKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHpJbmRleCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZGF0YSBvZiBhbm5vdGF0aW9ucykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGEubm9IVE1MKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5hbm5vdGF0aW9uVHlwZSAhPT0gX3V0aWwuQW5ub3RhdGlvblR5cGUuUE9QVVApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdpZHRoLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoZWlnaHQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gZ2V0UmVjdERpbXMoZGF0YS5yZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAod2lkdGggPD0gMCB8fCBoZWlnaHQgPD0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50UGFyYW1zLmRhdGEgPSBkYXRhOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZWxlbWVudCA9IEFubm90YXRpb25FbGVtZW50RmFjdG9yeS5jcmVhdGUoZWxlbWVudFBhcmFtcyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWVsZW1lbnQuaXNSZW5kZXJhYmxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZW5kZXJlZCA9IGVsZW1lbnQucmVuZGVyKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZGF0YS5oaWRkZW4pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJlZC5zdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShyZW5kZXJlZCkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlbmRlcmVkRWxlbWVudCBvZiByZW5kZXJlZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZW5kZXJlZEVsZW1lbnQuc3R5bGUuekluZGV4ID0gekluZGV4Kys7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1N0YXRpY1ByaXZhdGVNZXRob2RHZXQoQW5ub3RhdGlvbkxheWVyLCBBbm5vdGF0aW9uTGF5ZXIsIF9hcHBlbmRFbGVtZW50KS5jYWxsKEFubm90YXRpb25MYXllciwgcmVuZGVyZWRFbGVtZW50LCBkYXRhLmlkLCBkaXYsIGFjY2Vzc2liaWxpdHlNYW5hZ2VyKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlbmRlcmVkLnN0eWxlLnpJbmRleCA9IHpJbmRleCsrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChlbGVtZW50IGluc3RhbmNlb2YgUG9wdXBBbm5vdGF0aW9uRWxlbWVudCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXYucHJlcGVuZChyZW5kZXJlZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgX2NsYXNzU3RhdGljUHJpdmF0ZU1ldGhvZEdldChBbm5vdGF0aW9uTGF5ZXIsIEFubm90YXRpb25MYXllciwgX2FwcGVuZEVsZW1lbnQpLmNhbGwoQW5ub3RhdGlvbkxheWVyLCByZW5kZXJlZCwgZGF0YS5pZCwgZGl2LCBhY2Nlc3NpYmlsaXR5TWFuYWdlcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9jbGFzc1N0YXRpY1ByaXZhdGVNZXRob2RHZXQodGhpcywgQW5ub3RhdGlvbkxheWVyLCBfc2V0QW5ub3RhdGlvbkNhbnZhc01hcCkuY2FsbCh0aGlzLCBkaXYsIHBhcmFtcy5hbm5vdGF0aW9uQ2FudmFzTWFwKTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHVwZGF0ZShwYXJhbXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvbkNhbnZhc01hcCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRpdiwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZpZXdwb3J0CiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBwYXJhbXM7CiAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfZGlzcGxheV91dGlscy5zZXRMYXllckRpbWVuc2lvbnMpKGRpdiwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm90YXRpb246IHZpZXdwb3J0LnJvdGF0aW9uCiAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICBfY2xhc3NTdGF0aWNQcml2YXRlTWV0aG9kR2V0KHRoaXMsIEFubm90YXRpb25MYXllciwgX3NldEFubm90YXRpb25DYW52YXNNYXApLmNhbGwodGhpcywgZGl2LCBhbm5vdGF0aW9uQ2FudmFzTWFwKTsKICAgICAgICAgICAgICAgICAgICAgICAgZGl2LmhpZGRlbiA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuQW5ub3RhdGlvbkxheWVyID0gQW5ub3RhdGlvbkxheWVyOwogICAgICAgICAgICAgICAgZnVuY3Rpb24gX2FwcGVuZEVsZW1lbnQoZWxlbWVudCwgaWQsIGRpdiwgYWNjZXNzaWJpbGl0eU1hbmFnZXIpIHsKICAgICAgICAgICAgICAgICAgICBjb25zdCBjb250ZW50RWxlbWVudCA9IGVsZW1lbnQuZmlyc3RDaGlsZCB8fCBlbGVtZW50OwogICAgICAgICAgICAgICAgICAgIGNvbnRlbnRFbGVtZW50LmlkID0gYCR7X2Rpc3BsYXlfdXRpbHMuQW5ub3RhdGlvblByZWZpeH0ke2lkfWA7CiAgICAgICAgICAgICAgICAgICAgZGl2LmFwcGVuZChlbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICBhY2Nlc3NpYmlsaXR5TWFuYWdlciA9PT0gbnVsbCB8fCBhY2Nlc3NpYmlsaXR5TWFuYWdlciA9PT0gdm9pZCAwID8gdm9pZCAwIDogYWNjZXNzaWJpbGl0eU1hbmFnZXIubW92ZUVsZW1lbnRJbkRPTShkaXYsIGVsZW1lbnQsIGNvbnRlbnRFbGVtZW50LCBmYWxzZSk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmdW5jdGlvbiBfc2V0QW5ub3RhdGlvbkNhbnZhc01hcChkaXYsIGFubm90YXRpb25DYW52YXNNYXApIHsKICAgICAgICAgICAgICAgICAgICBpZiAoIWFubm90YXRpb25DYW52YXNNYXApIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IFtpZCwgY2FudmFzXSBvZiBhbm5vdGF0aW9uQ2FudmFzTWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGVsZW1lbnQgPSBkaXYucXVlcnlTZWxlY3RvcihgW2RhdGEtYW5ub3RhdGlvbi1pZD0iJHtpZH0iXWApOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpcnN0Q2hpbGQKICAgICAgICAgICAgICAgICAgICAgICAgfSA9IGVsZW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghZmlyc3RDaGlsZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5hcHBlbmQoY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChmaXJzdENoaWxkLm5vZGVOYW1lID09PSAiQ0FOVkFTIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3RDaGlsZC5yZXBsYWNlV2l0aChjYW52YXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZmlyc3RDaGlsZC5iZWZvcmUoY2FudmFzKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBhbm5vdGF0aW9uQ2FudmFzTWFwLmNsZWFyKCk7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgLyoqKi8gfSksCiAgICAgICAgICAgIC8qIDE2OCAqLwogICAgICAgICAgICAvKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzKSA9PiB7CgogICAgICAgICAgICAgICAgInVzZSBzdHJpY3QiOwoKCiAgICAgICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0cnVlCiAgICAgICAgICAgICAgICB9KSk7CiAgICAgICAgICAgICAgICBleHBvcnRzLkNvbG9yQ29udmVydGVycyA9IHZvaWQgMDsKICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG1ha2VDb2xvckNvbXAobikgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBNYXRoLmZsb29yKE1hdGgubWF4KDAsIE1hdGgubWluKDEsIG4pKSAqIDI1NSkudG9TdHJpbmcoMTYpLnBhZFN0YXJ0KDIsICIwIik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBjbGFzcyBDb2xvckNvbnZlcnRlcnMgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBDTVlLX0coX3JlZikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW2MsIHksIG0sIGtdID0gX3JlZjsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsiRyIsIDEgLSBNYXRoLm1pbigxLCAwLjMgKiBjICsgMC41OSAqIG0gKyAwLjExICogeSArIGspXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIEdfQ01ZSyhfcmVmMikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW2ddID0gX3JlZjI7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIkNNWUsiLCAwLCAwLCAwLCAxIC0gZ107CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBHX1JHQihfcmVmMykgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW2ddID0gX3JlZjM7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIlJHQiIsIGcsIGcsIGddOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgR19IVE1MKF9yZWY0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBbZ10gPSBfcmVmNDsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgRyA9IG1ha2VDb2xvckNvbXAoZyk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgIyR7R30ke0d9JHtHfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBSR0JfRyhfcmVmNSkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW3IsIGcsIGJdID0gX3JlZjU7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIkciLCAwLjMgKiByICsgMC41OSAqIGcgKyAwLjExICogYl07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBSR0JfSFRNTChfcmVmNikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgW3IsIGcsIGJdID0gX3JlZjY7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFIgPSBtYWtlQ29sb3JDb21wKHIpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBHID0gbWFrZUNvbG9yQ29tcChnKTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgQiA9IG1ha2VDb2xvckNvbXAoYik7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgIyR7Un0ke0d9JHtCfWA7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBUX0hUTUwoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAiIzAwMDAwMDAwIjsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIENNWUtfUkdCKF9yZWY3KSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBbYywgeSwgbSwga10gPSBfcmVmNzsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsiUkdCIiwgMSAtIE1hdGgubWluKDEsIGMgKyBrKSwgMSAtIE1hdGgubWluKDEsIG0gKyBrKSwgMSAtIE1hdGgubWluKDEsIHkgKyBrKV07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBDTVlLX0hUTUwoY29tcG9uZW50cykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZ2IgPSB0aGlzLkNNWUtfUkdCKGNvbXBvbmVudHMpLnNsaWNlKDEpOwogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy5SR0JfSFRNTChyZ2IpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBzdGF0aWMgUkdCX0NNWUsoX3JlZjgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IFtyLCBnLCBiXSA9IF9yZWY4OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjID0gMSAtIHI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG0gPSAxIC0gZzsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeSA9IDEgLSBiOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBrID0gTWF0aC5taW4oYywgbSwgeSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbIkNNWUsiLCBjLCBtLCB5LCBrXTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBleHBvcnRzLkNvbG9yQ29udmVydGVycyA9IENvbG9yQ29udmVydGVyczsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTY5ICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuWGZhTGF5ZXIgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX3hmYV90ZXh0ID0gX193X3BkZmpzX3JlcXVpcmVfXygxNTQpOwogICAgICAgICAgICAgICAgY2xhc3MgWGZhTGF5ZXIgewogICAgICAgICAgICAgICAgICAgIHN0YXRpYyBzZXR1cFN0b3JhZ2UoaHRtbCwgaWQsIGVsZW1lbnQsIHN0b3JhZ2UsIGludGVudCkgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdG9yZWREYXRhID0gc3RvcmFnZS5nZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG51bGwKICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoZWxlbWVudC5uYW1lKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJ0ZXh0YXJlYSI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0b3JlZERhdGEudmFsdWUgIT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC50ZXh0Q29udGVudCA9IHN0b3JlZERhdGEudmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlbnQgPT09ICJwcmludCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGh0bWwuYWRkRXZlbnRMaXN0ZW5lcigiaW5wdXQiLCBldmVudCA9PiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBldmVudC50YXJnZXQudmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJpbnB1dCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVsZW1lbnQuYXR0cmlidXRlcy50eXBlID09PSAicmFkaW8iIHx8IGVsZW1lbnQuYXR0cmlidXRlcy50eXBlID09PSAiY2hlY2tib3giKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzdG9yZWREYXRhLnZhbHVlID09PSBlbGVtZW50LmF0dHJpYnV0ZXMueGZhT24pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGh0bWwuc2V0QXR0cmlidXRlKCJjaGVja2VkIiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoc3RvcmVkRGF0YS52YWx1ZSA9PT0gZWxlbWVudC5hdHRyaWJ1dGVzLnhmYU9mZikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5yZW1vdmVBdHRyaWJ1dGUoImNoZWNrZWQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW50ZW50ID09PSAicHJpbnQiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBodG1sLmFkZEV2ZW50TGlzdGVuZXIoImNoYW5nZSIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZXZlbnQudGFyZ2V0LmNoZWNrZWQgPyBldmVudC50YXJnZXQuZ2V0QXR0cmlidXRlKCJ4ZmFPbiIpIDogZXZlbnQudGFyZ2V0LmdldEF0dHJpYnV0ZSgieGZhT2ZmIikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RvcmVkRGF0YS52YWx1ZSAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5zZXRBdHRyaWJ1dGUoInZhbHVlIiwgc3RvcmVkRGF0YS52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGludGVudCA9PT0gInByaW50IikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5hZGRFdmVudExpc3RlbmVyKCJpbnB1dCIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3JhZ2Uuc2V0VmFsdWUoaWQsIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZXZlbnQudGFyZ2V0LnZhbHVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAic2VsZWN0IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RvcmVkRGF0YS52YWx1ZSAhPT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG9wdGlvbiBvZiBlbGVtZW50LmNoaWxkcmVuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3B0aW9uLmF0dHJpYnV0ZXMudmFsdWUgPT09IHN0b3JlZERhdGEudmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcHRpb24uYXR0cmlidXRlcy5zZWxlY3RlZCA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5hZGRFdmVudExpc3RlbmVyKCJpbnB1dCIsIGV2ZW50ID0+IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3B0aW9ucyA9IGV2ZW50LnRhcmdldC5vcHRpb25zOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2YWx1ZSA9IG9wdGlvbnMuc2VsZWN0ZWRJbmRleCA9PT0gLTEgPyAiIiA6IG9wdGlvbnNbb3B0aW9ucy5zZWxlY3RlZEluZGV4XS52YWx1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZS5zZXRWYWx1ZShpZCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWUKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgc3RhdGljIHNldEF0dHJpYnV0ZXMoX3JlZikgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdG9yYWdlID0gbnVsbCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludGVudCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtTZXJ2aWNlCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBfcmVmOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdHRyaWJ1dGVzCiAgICAgICAgICAgICAgICAgICAgICAgIH0gPSBlbGVtZW50OwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpc0hUTUxBbmNob3JFbGVtZW50ID0gaHRtbCBpbnN0YW5jZW9mIEhUTUxBbmNob3JFbGVtZW50OwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXR0cmlidXRlcy50eXBlID09PSAicmFkaW8iKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhdHRyaWJ1dGVzLm5hbWUgPSBgJHthdHRyaWJ1dGVzLm5hbWV9LSR7aW50ZW50fWA7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBba2V5LCB2YWx1ZV0gb2YgT2JqZWN0LmVudHJpZXMoYXR0cmlidXRlcykpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2YWx1ZSA9PT0gbnVsbCB8fCB2YWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGtleSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImNsYXNzIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlLmxlbmd0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5zZXRBdHRyaWJ1dGUoa2V5LCB2YWx1ZS5qb2luKCIgIikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImRhdGFJZCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgImlkIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5zZXRBdHRyaWJ1dGUoImRhdGEtZWxlbWVudC1pZCIsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAic3R5bGUiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPYmplY3QuYXNzaWduKGh0bWwuc3R5bGUsIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAidGV4dENvbnRlbnQiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBodG1sLnRleHRDb250ZW50ID0gdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghaXNIVE1MQW5jaG9yRWxlbWVudCB8fCBrZXkgIT09ICJocmVmIiAmJiBrZXkgIT09ICJuZXdXaW5kb3ciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBodG1sLnNldEF0dHJpYnV0ZShrZXksIHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc0hUTUxBbmNob3JFbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5rU2VydmljZS5hZGRMaW5rQXR0cmlidXRlcyhodG1sLCBhdHRyaWJ1dGVzLmhyZWYsIGF0dHJpYnV0ZXMubmV3V2luZG93KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3RvcmFnZSAmJiBhdHRyaWJ1dGVzLmRhdGFJZCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXR1cFN0b3JhZ2UoaHRtbCwgYXR0cmlidXRlcy5kYXRhSWQsIGVsZW1lbnQsIHN0b3JhZ2UpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyByZW5kZXIocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdG9yYWdlID0gcGFyYW1ldGVycy5hbm5vdGF0aW9uU3RvcmFnZTsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGlua1NlcnZpY2UgPSBwYXJhbWV0ZXJzLmxpbmtTZXJ2aWNlOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByb290ID0gcGFyYW1ldGVycy54ZmFIdG1sOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbnRlbnQgPSBwYXJhbWV0ZXJzLmludGVudCB8fCAiZGlzcGxheSI7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvb3RIdG1sID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudChyb290Lm5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocm9vdC5hdHRyaWJ1dGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldEF0dHJpYnV0ZXMoewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGh0bWw6IHJvb3RIdG1sLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQ6IHJvb3QsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmtTZXJ2aWNlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdGFjayA9IFtbcm9vdCwgLTEsIHJvb3RIdG1sXV07CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvb3REaXYgPSBwYXJhbWV0ZXJzLmRpdjsKICAgICAgICAgICAgICAgICAgICAgICAgcm9vdERpdi5hcHBlbmQocm9vdEh0bWwpOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFyYW1ldGVycy52aWV3cG9ydCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHJhbnNmb3JtID0gYG1hdHJpeCgke3BhcmFtZXRlcnMudmlld3BvcnQudHJhbnNmb3JtLmpvaW4oIiwiKX0pYDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvb3REaXYuc3R5bGUudHJhbnNmb3JtID0gdHJhbnNmb3JtOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnRlbnQgIT09ICJyaWNoVGV4dCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvb3REaXYuc2V0QXR0cmlidXRlKCJjbGFzcyIsICJ4ZmFMYXllciB4ZmFGb250Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dERpdnMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfY2hpbGQkYXR0cmlidXRlczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFtwYXJlbnQsIGksIGh0bWxdID0gc3RhY2suYXQoLTEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGkgKyAxID09PSBwYXJlbnQuY2hpbGRyZW4ubGVuZ3RoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGlsZCA9IHBhcmVudC5jaGlsZHJlblsrK3N0YWNrLmF0KC0xKVsxXV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGQgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuYW1lCiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9ID0gY2hpbGQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobmFtZSA9PT0gIiN0ZXh0IikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vZGUgPSBkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZShjaGlsZC52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGV4dERpdnMucHVzaChub2RlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBodG1sLmFwcGVuZChub2RlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjaGlsZEh0bWw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hpbGQgIT09IG51bGwgJiYgY2hpbGQgIT09IHZvaWQgMCAmJiAoX2NoaWxkJGF0dHJpYnV0ZXMgPSBjaGlsZC5hdHRyaWJ1dGVzKSAhPT0gbnVsbCAmJiBfY2hpbGQkYXR0cmlidXRlcyAhPT0gdm9pZCAwICYmIF9jaGlsZCRhdHRyaWJ1dGVzLnhtbG5zKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hpbGRIdG1sID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudE5TKGNoaWxkLmF0dHJpYnV0ZXMueG1sbnMsIG5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGlsZEh0bWwgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KG5hbWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbC5hcHBlbmQoY2hpbGRIdG1sKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGlsZC5hdHRyaWJ1dGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRBdHRyaWJ1dGVzKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHRtbDogY2hpbGRIdG1sLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50OiBjaGlsZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcmFnZSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50ZW50LAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5rU2VydmljZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNoaWxkLmNoaWxkcmVuICYmIGNoaWxkLmNoaWxkcmVuLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdGFjay5wdXNoKFtjaGlsZCwgLTEsIGNoaWxkSHRtbF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChjaGlsZC52YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG5vZGUgPSBkb2N1bWVudC5jcmVhdGVUZXh0Tm9kZShjaGlsZC52YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF94ZmFfdGV4dC5YZmFUZXh0LnNob3VsZEJ1aWxkVGV4dChuYW1lKSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0RGl2cy5wdXNoKG5vZGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjaGlsZEh0bWwuYXBwZW5kKG5vZGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZWwgb2Ygcm9vdERpdi5xdWVyeVNlbGVjdG9yQWxsKCIueGZhTm9uSW50ZXJhY3RpdmUgaW5wdXQsIC54ZmFOb25JbnRlcmFjdGl2ZSB0ZXh0YXJlYSIpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbC5zZXRBdHRyaWJ1dGUoInJlYWRPbmx5IiwgdHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHREaXZzCiAgICAgICAgICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0YXRpYyB1cGRhdGUocGFyYW1ldGVycykgewogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0cmFuc2Zvcm0gPSBgbWF0cml4KCR7cGFyYW1ldGVycy52aWV3cG9ydC50cmFuc2Zvcm0uam9pbigiLCIpfSlgOwogICAgICAgICAgICAgICAgICAgICAgICBwYXJhbWV0ZXJzLmRpdi5zdHlsZS50cmFuc2Zvcm0gPSB0cmFuc2Zvcm07CiAgICAgICAgICAgICAgICAgICAgICAgIHBhcmFtZXRlcnMuZGl2LmhpZGRlbiA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGV4cG9ydHMuWGZhTGF5ZXIgPSBYZmFMYXllcjsKCiAgICAgICAgICAgICAgICAvKioqLyB9KSwKICAgICAgICAgICAgLyogMTcwICovCiAgICAgICAgICAgIC8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiAgICAgICAgICAgICAgICAidXNlIHN0cmljdCI7CgoKICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgIGV4cG9ydHMuU1ZHR3JhcGhpY3MgPSB2b2lkIDA7CiAgICAgICAgICAgICAgICB2YXIgX2Rpc3BsYXlfdXRpbHMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0Mik7CiAgICAgICAgICAgICAgICB2YXIgX3V0aWwgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEpOwogICAgICAgICAgICAgICAgdmFyIF9pc19ub2RlID0gX193X3BkZmpzX3JlcXVpcmVfXygzKTsKICAgICAgICAgICAgICAgIGxldCBTVkdHcmFwaGljcyA9IGNsYXNzIHsKICAgICAgICAgICAgICAgICAgICBjb25zdHJ1Y3RvcigpIHsKICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLnVucmVhY2hhYmxlKSgiTm90IGltcGxlbWVudGVkOiBTVkdHcmFwaGljcyIpOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgICBleHBvcnRzLlNWR0dyYXBoaWNzID0gU1ZHR3JhcGhpY3M7CiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgY29uc3QgU1ZHX0RFRkFVTFRTID0gewogICAgICAgICAgICAgICAgICAgICAgICBmb250U3R5bGU6ICJub3JtYWwiLAogICAgICAgICAgICAgICAgICAgICAgICBmb250V2VpZ2h0OiAibm9ybWFsIiwKICAgICAgICAgICAgICAgICAgICAgICAgZmlsbENvbG9yOiAiIzAwMDAwMCIKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IFhNTF9OUyA9ICJodHRwOi8vd3d3LnczLm9yZy9YTUwvMTk5OC9uYW1lc3BhY2UiOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IFhMSU5LX05TID0gImh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IExJTkVfQ0FQX1NUWUxFUyA9IFsiYnV0dCIsICJyb3VuZCIsICJzcXVhcmUiXTsKICAgICAgICAgICAgICAgICAgICBjb25zdCBMSU5FX0pPSU5fU1RZTEVTID0gWyJtaXRlciIsICJyb3VuZCIsICJiZXZlbCJdOwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGNyZWF0ZU9iamVjdFVSTCA9IGZ1bmN0aW9uIChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjb250ZW50VHlwZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogIiI7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmb3JjZURhdGFTY2hlbWEgPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICBpZiAoVVJMLmNyZWF0ZU9iamVjdFVSTCAmJiB0eXBlb2YgQmxvYiAhPT0gInVuZGVmaW5lZCIgJiYgIWZvcmNlRGF0YVNjaGVtYSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFVSTC5jcmVhdGVPYmplY3RVUkwobmV3IEJsb2IoW2RhdGFdLCB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZTogY29udGVudFR5cGUKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkaWdpdHMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLz0iOwogICAgICAgICAgICAgICAgICAgICAgICBsZXQgYnVmZmVyID0gYGRhdGE6JHtjb250ZW50VHlwZX07YmFzZTY0LGA7CiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGRhdGEubGVuZ3RoOyBpIDwgaWk7IGkgKz0gMykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYjEgPSBkYXRhW2ldICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGIyID0gZGF0YVtpICsgMV0gJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYjMgPSBkYXRhW2kgKyAyXSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkMSA9IGIxID4+IDIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZDIgPSAoYjEgJiAzKSA8PCA0IHwgYjIgPj4gNDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQzID0gaSArIDEgPCBpaSA/IChiMiAmIDB4ZikgPDwgMiB8IGIzID4+IDYgOiA2NDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGQ0ID0gaSArIDIgPCBpaSA/IGIzICYgMHgzZiA6IDY0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnVmZmVyICs9IGRpZ2l0c1tkMV0gKyBkaWdpdHNbZDJdICsgZGlnaXRzW2QzXSArIGRpZ2l0c1tkNF07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGJ1ZmZlcjsKICAgICAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbnZlcnRJbWdEYXRhVG9QbmcgPSBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFBOR19IRUFERVIgPSBuZXcgVWludDhBcnJheShbMHg4OSwgMHg1MCwgMHg0ZSwgMHg0NywgMHgwZCwgMHgwYSwgMHgxYSwgMHgwYV0pOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBDSFVOS19XUkFQUEVSX1NJWkUgPSAxMjsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3JjVGFibGUgPSBuZXcgSW50MzJBcnJheSgyNTYpOwogICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI1NjsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgYyA9IGk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBoID0gMDsgaCA8IDg7IGgrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjICYgMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjID0gMHhlZGI4ODMyMCBeIGMgPj4gMSAmIDB4N2ZmZmZmZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYyA9IGMgPj4gMSAmIDB4N2ZmZmZmZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3JjVGFibGVbaV0gPSBjOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGNyYzMyKGRhdGEsIHN0YXJ0LCBlbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBjcmMgPSAtMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSBzdGFydDsgaSA8IGVuZDsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYSA9IChjcmMgXiBkYXRhW2ldKSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYiA9IGNyY1RhYmxlW2FdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNyYyA9IGNyYyA+Pj4gOCBeIGI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JjIF4gLTE7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gd3JpdGVQbmdDaHVuayh0eXBlLCBib2R5LCBkYXRhLCBvZmZzZXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwID0gb2Zmc2V0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbGVuID0gYm9keS5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhW3BdID0gbGVuID4+IDI0ICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFbcCArIDFdID0gbGVuID4+IDE2ICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFbcCArIDJdID0gbGVuID4+IDggJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtwICsgM10gPSBsZW4gJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcCArPSA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtwXSA9IHR5cGUuY2hhckNvZGVBdCgwKSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhW3AgKyAxXSA9IHR5cGUuY2hhckNvZGVBdCgxKSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhW3AgKyAyXSA9IHR5cGUuY2hhckNvZGVBdCgyKSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhW3AgKyAzXSA9IHR5cGUuY2hhckNvZGVBdCgzKSAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwICs9IDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLnNldChib2R5LCBwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHAgKz0gYm9keS5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjcmMgPSBjcmMzMihkYXRhLCBvZmZzZXQgKyA0LCBwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFbcF0gPSBjcmMgPj4gMjQgJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtwICsgMV0gPSBjcmMgPj4gMTYgJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVtwICsgMl0gPSBjcmMgPj4gOCAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhW3AgKyAzXSA9IGNyYyAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb24gYWRsZXIzMihkYXRhLCBzdGFydCwgZW5kKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgYSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgYiA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCBpID0gc3RhcnQ7IGkgPCBlbmQ7ICsraSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGEgPSAoYSArIChkYXRhW2ldICYgMHhmZikpICUgNjU1MjE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYiA9IChiICsgYSkgJSA2NTUyMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBiIDw8IDE2IHwgYTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBkZWZsYXRlU3luYyhsaXRlcmFscykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFfaXNfbm9kZS5pc05vZGVKUykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBkZWZsYXRlU3luY1VuY29tcHJlc3NlZChsaXRlcmFscyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBpbnB1dDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFyc2VJbnQocHJvY2Vzcy52ZXJzaW9ucy5ub2RlKSA+PSA4KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlucHV0ID0gbGl0ZXJhbHM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5wdXQgPSBCdWZmZXIuZnJvbShsaXRlcmFscyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG91dHB1dCA9IHJlcXVpcmUoInpsaWIiKS5kZWZsYXRlU3luYyhpbnB1dCwgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXZlbDogOQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBvdXRwdXQgaW5zdGFuY2VvZiBVaW50OEFycmF5ID8gb3V0cHV0IDogbmV3IFVpbnQ4QXJyYXkob3V0cHV0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIk5vdCBjb21wcmVzc2luZyBQTkcgYmVjYXVzZSB6bGliLmRlZmxhdGVTeW5jIGlzIHVuYXZhaWxhYmxlOiAiICsgZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZGVmbGF0ZVN5bmNVbmNvbXByZXNzZWQobGl0ZXJhbHMpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIGRlZmxhdGVTeW5jVW5jb21wcmVzc2VkKGxpdGVyYWxzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgbGVuID0gbGl0ZXJhbHMubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWF4QmxvY2tMZW5ndGggPSAweGZmZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZsYXRlQmxvY2tzID0gTWF0aC5jZWlsKGxlbiAvIG1heEJsb2NrTGVuZ3RoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGlkYXQgPSBuZXcgVWludDhBcnJheSgyICsgbGVuICsgZGVmbGF0ZUJsb2NrcyAqIDUgKyA0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBwaSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHg3ODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSAweDljOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHBvcyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAobGVuID4gbWF4QmxvY2tMZW5ndGgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHgwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHgwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHgwMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0LnNldChsaXRlcmFscy5zdWJhcnJheShwb3MsIHBvcyArIG1heEJsb2NrTGVuZ3RoKSwgcGkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBpICs9IG1heEJsb2NrTGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBvcyArPSBtYXhCbG9ja0xlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZW4gLT0gbWF4QmxvY2tMZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gMHgwMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSBsZW4gJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWRhdFtwaSsrXSA9IGxlbiA+PiA4ICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSB+bGVuICYgMHhmZmZmICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSAofmxlbiAmIDB4ZmZmZikgPj4gOCAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0LnNldChsaXRlcmFscy5zdWJhcnJheShwb3MpLCBwaSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBwaSArPSBsaXRlcmFscy5sZW5ndGggLSBwb3M7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhZGxlciA9IGFkbGVyMzIobGl0ZXJhbHMsIDAsIGxpdGVyYWxzLmxlbmd0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZGF0W3BpKytdID0gYWRsZXIgPj4gMjQgJiAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWRhdFtwaSsrXSA9IGFkbGVyID4+IDE2ICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSBhZGxlciA+PiA4ICYgMHhmZjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkYXRbcGkrK10gPSBhZGxlciAmIDB4ZmY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gaWRhdDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBlbmNvZGUoaW1nRGF0YSwga2luZCwgZm9yY2VEYXRhU2NoZW1hLCBpc01hc2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gaW1nRGF0YS53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGltZ0RhdGEuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJpdERlcHRoLCBjb2xvclR5cGUsIGxpbmVTaXplOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYnl0ZXMgPSBpbWdEYXRhLmRhdGE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzd2l0Y2ggKGtpbmQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkltYWdlS2luZC5HUkFZU0NBTEVfMUJQUDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29sb3JUeXBlID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYml0RGVwdGggPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaW5lU2l6ZSA9IHdpZHRoICsgNyA+PiAzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLkltYWdlS2luZC5SR0JfMjRCUFA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbG9yVHlwZSA9IDI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJpdERlcHRoID0gODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVNpemUgPSB3aWR0aCAqIDM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuSW1hZ2VLaW5kLlJHQkFfMzJCUFA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbG9yVHlwZSA9IDY7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJpdERlcHRoID0gODsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGluZVNpemUgPSB3aWR0aCAqIDQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiaW52YWxpZCBmb3JtYXQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpdGVyYWxzID0gbmV3IFVpbnQ4QXJyYXkoKDEgKyBsaW5lU2l6ZSkgKiBoZWlnaHQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG9mZnNldExpdGVyYWxzID0gMCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRCeXRlcyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCB5ID0gMDsgeSA8IGhlaWdodDsgKyt5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGl0ZXJhbHNbb2Zmc2V0TGl0ZXJhbHMrK10gPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxpdGVyYWxzLnNldChieXRlcy5zdWJhcnJheShvZmZzZXRCeXRlcywgb2Zmc2V0Qnl0ZXMgKyBsaW5lU2l6ZSksIG9mZnNldExpdGVyYWxzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRCeXRlcyArPSBsaW5lU2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXRMaXRlcmFscyArPSBsaW5lU2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChraW5kID09PSBfdXRpbC5JbWFnZUtpbmQuR1JBWVNDQUxFXzFCUFAgJiYgaXNNYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0TGl0ZXJhbHMgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IHkgPSAwOyB5IDwgaGVpZ2h0OyB5KyspIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0TGl0ZXJhbHMrKzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBsaW5lU2l6ZTsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsaXRlcmFsc1tvZmZzZXRMaXRlcmFscysrXSBePSAweGZmOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaWhkciA9IG5ldyBVaW50OEFycmF5KFt3aWR0aCA+PiAyNCAmIDB4ZmYsIHdpZHRoID4+IDE2ICYgMHhmZiwgd2lkdGggPj4gOCAmIDB4ZmYsIHdpZHRoICYgMHhmZiwgaGVpZ2h0ID4+IDI0ICYgMHhmZiwgaGVpZ2h0ID4+IDE2ICYgMHhmZiwgaGVpZ2h0ID4+IDggJiAweGZmLCBoZWlnaHQgJiAweGZmLCBiaXREZXB0aCwgY29sb3JUeXBlLCAweDAwLCAweDAwLCAweDAwXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpZGF0ID0gZGVmbGF0ZVN5bmMobGl0ZXJhbHMpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcG5nTGVuZ3RoID0gUE5HX0hFQURFUi5sZW5ndGggKyBDSFVOS19XUkFQUEVSX1NJWkUgKiAzICsgaWhkci5sZW5ndGggKyBpZGF0Lmxlbmd0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRhdGEgPSBuZXcgVWludDhBcnJheShwbmdMZW5ndGgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG9mZnNldCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLnNldChQTkdfSEVBREVSLCBvZmZzZXQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Zmc2V0ICs9IFBOR19IRUFERVIubGVuZ3RoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgd3JpdGVQbmdDaHVuaygiSUhEUiIsIGloZHIsIGRhdGEsIG9mZnNldCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXQgKz0gQ0hVTktfV1JBUFBFUl9TSVpFICsgaWhkci5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0ZVBuZ0NodW5rKCJJREFUQSIsIGlkYXQsIGRhdGEsIG9mZnNldCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZmZzZXQgKz0gQ0hVTktfV1JBUFBFUl9TSVpFICsgaWRhdC5sZW5ndGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB3cml0ZVBuZ0NodW5rKCJJRU5EIiwgbmV3IFVpbnQ4QXJyYXkoMCksIGRhdGEsIG9mZnNldCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gY3JlYXRlT2JqZWN0VVJMKGRhdGEsICJpbWFnZS9wbmciLCBmb3JjZURhdGFTY2hlbWEpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmdW5jdGlvbiBjb252ZXJ0SW1nRGF0YVRvUG5nKGltZ0RhdGEsIGZvcmNlRGF0YVNjaGVtYSwgaXNNYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBraW5kID0gaW1nRGF0YS5raW5kID09PSB1bmRlZmluZWQgPyBfdXRpbC5JbWFnZUtpbmQuR1JBWVNDQUxFXzFCUFAgOiBpbWdEYXRhLmtpbmQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZW5jb2RlKGltZ0RhdGEsIGtpbmQsIGZvcmNlRGF0YVNjaGVtYSwgaXNNYXNrKTsKICAgICAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgICAgICB9KCk7CiAgICAgICAgICAgICAgICAgICAgY2xhc3MgU1ZHRXh0cmFTdGF0ZSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5mb250U2l6ZVNjYWxlID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZm9udFdlaWdodCA9IFNWR19ERUZBVUxUUy5mb250V2VpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5mb250U2l6ZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRNYXRyaXggPSBfdXRpbC5JREVOVElUWV9NQVRSSVg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZvbnRNYXRyaXggPSBfdXRpbC5GT05UX0lERU5USVRZX01BVFJJWDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubGVhZGluZyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRSZW5kZXJpbmdNb2RlID0gX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuRklMTDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGV4dE1hdHJpeFNjYWxlID0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnkgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5saW5lWCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmVZID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2hhclNwYWNpbmcgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy53b3JkU3BhY2luZyA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRleHRIU2NhbGUgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50ZXh0UmlzZSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGxDb2xvciA9IFNWR19ERUZBVUxUUy5maWxsQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cm9rZUNvbG9yID0gIiMwMDAwMDAiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5maWxsQWxwaGEgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJva2VBbHBoYSA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmVXaWR0aCA9IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmVKb2luID0gIiI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmxpbmVDYXAgPSAiIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWl0ZXJMaW1pdCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRhc2hBcnJheSA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kYXNoUGhhc2UgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kZXBlbmRlbmNpZXMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuYWN0aXZlQ2xpcFVybCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXBHcm91cCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1hc2tJZCA9ICIiOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNsb25lKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIE9iamVjdC5jcmVhdGUodGhpcyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0Q3VycmVudFBvaW50KHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueCA9IHg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnkgPSB5OwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIG9wTGlzdFRvVHJlZShvcExpc3QpIHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IG9wVHJlZSA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0bXAgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvcExpc3RFbGVtZW50IG9mIG9wTGlzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9wTGlzdEVsZW1lbnQuZm4gPT09ICJzYXZlIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wVHJlZS5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm5JZDogOTIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZuOiAiZ3JvdXAiLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtczogW10KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0bXAucHVzaChvcFRyZWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wVHJlZSA9IG9wVHJlZS5hdCgtMSkuaXRlbXM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAob3BMaXN0RWxlbWVudC5mbiA9PT0gInJlc3RvcmUiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb3BUcmVlID0gdG1wLnBvcCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvcFRyZWUucHVzaChvcExpc3RFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gb3BUcmVlOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBmdW5jdGlvbiBwZih2YWx1ZSkgewogICAgICAgICAgICAgICAgICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcih2YWx1ZSkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZS50b1N0cmluZygpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHMgPSB2YWx1ZS50b0ZpeGVkKDEwKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGkgPSBzLmxlbmd0aCAtIDE7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzW2ldICE9PSAiMCIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBzOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGktLTsKICAgICAgICAgICAgICAgICAgICAgICAgfSB3aGlsZSAoc1tpXSA9PT0gIjAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHMuc3Vic3RyaW5nKDAsIHNbaV0gPT09ICIuIiA/IGkgOiBpICsgMSk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGZ1bmN0aW9uIHBtKG0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1bNF0gPT09IDAgJiYgbVs1XSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1bMV0gPT09IDAgJiYgbVsyXSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtWzBdID09PSAxICYmIG1bM10gPT09IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICIiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYHNjYWxlKCR7cGYobVswXSl9ICR7cGYobVszXSl9KWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobVswXSA9PT0gbVszXSAmJiBtWzFdID09PSAtbVsyXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGEgPSBNYXRoLmFjb3MobVswXSkgKiAxODAgLyBNYXRoLlBJOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgcm90YXRlKCR7cGYoYSl9KWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAobVswXSA9PT0gMSAmJiBtWzFdID09PSAwICYmIG1bMl0gPT09IDAgJiYgbVszXSA9PT0gMSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgdHJhbnNsYXRlKCR7cGYobVs0XSl9ICR7cGYobVs1XSl9KWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGBtYXRyaXgoJHtwZihtWzBdKX0gJHtwZihtWzFdKX0gJHtwZihtWzJdKX0gJHtwZihtWzNdKX0gJHtwZihtWzRdKX0gYCArIGAke3BmKG1bNV0pfSlgOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICBsZXQgY2xpcENvdW50ID0gMDsKICAgICAgICAgICAgICAgICAgICBsZXQgbWFza0NvdW50ID0gMDsKICAgICAgICAgICAgICAgICAgICBsZXQgc2hhZGluZ0NvdW50ID0gMDsKICAgICAgICAgICAgICAgICAgICBleHBvcnRzLlNWR0dyYXBoaWNzID0gU1ZHR3JhcGhpY3MgPSBjbGFzcyB7CiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0cnVjdG9yKGNvbW1vbk9ianMsIG9ianMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBmb3JjZURhdGFTY2hlbWEgPSBhcmd1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF9kaXNwbGF5X3V0aWxzLmRlcHJlY2F0ZWQpKCJUaGUgU1ZHIGJhY2stZW5kIGlzIG5vIGxvbmdlciBtYWludGFpbmVkIGFuZCAqbWF5KiBiZSByZW1vdmVkIGluIHRoZSBmdXR1cmUuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN2Z0ZhY3RvcnkgPSBuZXcgX2Rpc3BsYXlfdXRpbHMuRE9NU1ZHRmFjdG9yeSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50ID0gbmV3IFNWR0V4dHJhU3RhdGUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNmb3JtTWF0cml4ID0gX3V0aWwuSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm1TdGFjayA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leHRyYVN0YWNrID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNvbW1vbk9ianMgPSBjb21tb25PYmpzOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5vYmpzID0gb2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0NsaXAgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nRU9GaWxsID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVtYmVkRm9udHMgPSBmYWxzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW1iZWRkZWRGb250cyA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNzc1N0eWxlID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZm9yY2VEYXRhU2NoZW1hID0gISFmb3JjZURhdGFTY2hlbWE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9vcGVyYXRvcklkTWFwcGluZyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvcCBpbiBfdXRpbC5PUFMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9vcGVyYXRvcklkTWFwcGluZ1tfdXRpbC5PUFNbb3BdXSA9IG9wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGdldE9iamVjdChkYXRhKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZmFsbGJhY2sgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGRhdGEgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRhdGEuc3RhcnRzV2l0aCgiZ18iKSA/IHRoaXMuY29tbW9uT2Jqcy5nZXQoZGF0YSkgOiB0aGlzLm9ianMuZ2V0KGRhdGEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbGxiYWNrOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNhdmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zZm9ybVN0YWNrLnB1c2godGhpcy50cmFuc2Zvcm1NYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2xkID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leHRyYVN0YWNrLnB1c2gob2xkKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudCA9IG9sZC5jbG9uZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3RvcmUoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zZm9ybU1hdHJpeCA9IHRoaXMudHJhbnNmb3JtU3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQgPSB0aGlzLmV4dHJhU3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBlbmRpbmdDbGlwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudGdycCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZ3JvdXAoaXRlbXMpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2F2ZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leGVjdXRlT3BUcmVlKGl0ZW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucmVzdG9yZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGxvYWREZXBlbmRlbmNpZXMob3BlcmF0b3JMaXN0KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmbkFycmF5ID0gb3BlcmF0b3JMaXN0LmZuQXJyYXk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhcmdzQXJyYXkgPSBvcGVyYXRvckxpc3QuYXJnc0FycmF5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZm5BcnJheS5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZuQXJyYXlbaV0gIT09IF91dGlsLk9QUy5kZXBlbmRlbmN5KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG9iaiBvZiBhcmdzQXJyYXlbaV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb2Jqc1Bvb2wgPSBvYmouc3RhcnRzV2l0aCgiZ18iKSA/IHRoaXMuY29tbW9uT2JqcyA6IHRoaXMub2JqczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcHJvbWlzZSA9IG5ldyBQcm9taXNlKHJlc29sdmUgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgb2Jqc1Bvb2wuZ2V0KG9iaiwgcmVzb2x2ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuZGVwZW5kZW5jaWVzLnB1c2gocHJvbWlzZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFByb21pc2UuYWxsKHRoaXMuY3VycmVudC5kZXBlbmRlbmNpZXMpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHRyYW5zZm9ybShhLCBiLCBjLCBkLCBlLCBmKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0cmFuc2Zvcm1NYXRyaXggPSBbYSwgYiwgYywgZCwgZSwgZl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zZm9ybU1hdHJpeCA9IF91dGlsLlV0aWwudHJhbnNmb3JtKHRoaXMudHJhbnNmb3JtTWF0cml4LCB0cmFuc2Zvcm1NYXRyaXgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50Z3JwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBnZXRTVkcob3BlcmF0b3JMaXN0LCB2aWV3cG9ydCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52aWV3cG9ydCA9IHZpZXdwb3J0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ZnRWxlbWVudCA9IHRoaXMuX2luaXRpYWxpemUodmlld3BvcnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMubG9hZERlcGVuZGVuY2llcyhvcGVyYXRvckxpc3QpLnRoZW4oKCkgPT4gewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMudHJhbnNmb3JtTWF0cml4ID0gX3V0aWwuSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZXhlY3V0ZU9wVHJlZSh0aGlzLmNvbnZlcnRPcExpc3Qob3BlcmF0b3JMaXN0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN2Z0VsZW1lbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjb252ZXJ0T3BMaXN0KG9wZXJhdG9yTGlzdCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgb3BlcmF0b3JJZE1hcHBpbmcgPSB0aGlzLl9vcGVyYXRvcklkTWFwcGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3NBcnJheSA9IG9wZXJhdG9yTGlzdC5hcmdzQXJyYXk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmbkFycmF5ID0gb3BlcmF0b3JMaXN0LmZuQXJyYXk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvcExpc3QgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGZuQXJyYXkubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZuSWQgPSBmbkFycmF5W2ldOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9wTGlzdC5wdXNoKHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm5JZCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm46IG9wZXJhdG9ySWRNYXBwaW5nW2ZuSWRdLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmdzOiBhcmdzQXJyYXlbaV0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBvcExpc3RUb1RyZWUob3BMaXN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBleGVjdXRlT3BUcmVlKG9wVHJlZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBvcFRyZWVFbGVtZW50IG9mIG9wVHJlZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZuID0gb3BUcmVlRWxlbWVudC5mbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmbklkID0gb3BUcmVlRWxlbWVudC5mbklkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3MgPSBvcFRyZWVFbGVtZW50LmFyZ3M7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChmbklkIHwgMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5iZWdpblRleHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmJlZ2luVGV4dCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmRlcGVuZGVuY3k6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0TGVhZGluZzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGVhZGluZyhhcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRMZWFkaW5nTW92ZVRleHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldExlYWRpbmdNb3ZlVGV4dChhcmdzWzBdLCBhcmdzWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRGb250OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGb250KGFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNob3dUZXh0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zaG93VGV4dChhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zaG93U3BhY2VkVGV4dDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2hvd1RleHQoYXJnc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kVGV4dDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kVGV4dCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm1vdmVUZXh0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5tb3ZlVGV4dChhcmdzWzBdLCBhcmdzWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRDaGFyU3BhY2luZzoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0Q2hhclNwYWNpbmcoYXJnc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0V29yZFNwYWNpbmc6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFdvcmRTcGFjaW5nKGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEhTY2FsZToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0SFNjYWxlKGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFRleHRNYXRyaXg6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFRleHRNYXRyaXgoYXJnc1swXSwgYXJnc1sxXSwgYXJnc1syXSwgYXJnc1szXSwgYXJnc1s0XSwgYXJnc1s1XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0VGV4dFJpc2U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFRleHRSaXNlKGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFRleHRSZW5kZXJpbmdNb2RlOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRUZXh0UmVuZGVyaW5nTW9kZShhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRMaW5lV2lkdGg6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldExpbmVXaWR0aChhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRMaW5lSm9pbjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGluZUpvaW4oYXJnc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0TGluZUNhcDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGluZUNhcChhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRNaXRlckxpbWl0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRNaXRlckxpbWl0KGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZpbGxSR0JDb2xvcjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RmlsbFJHQkNvbG9yKGFyZ3NbMF0sIGFyZ3NbMV0sIGFyZ3NbMl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFN0cm9rZVJHQkNvbG9yOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRTdHJva2VSR0JDb2xvcihhcmdzWzBdLCBhcmdzWzFdLCBhcmdzWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRTdHJva2VDb2xvck46CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldFN0cm9rZUNvbG9yTihhcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRGaWxsQ29sb3JOOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGaWxsQ29sb3JOKGFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNoYWRpbmdGaWxsOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zaGFkaW5nRmlsbChhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXREYXNoOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXREYXNoKGFyZ3NbMF0sIGFyZ3NbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFJlbmRlcmluZ0ludGVudDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0UmVuZGVyaW5nSW50ZW50KGFyZ3NbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZsYXRuZXNzOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGbGF0bmVzcyhhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRHU3RhdGU6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldEdTdGF0ZShhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5maWxsOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5maWxsKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW9GaWxsOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lb0ZpbGwoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zdHJva2U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmZpbGxTdHJva2U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGxTdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5lb0ZpbGxTdHJva2U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVvRmlsbFN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmNsaXA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoIm5vbnplcm8iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5lb0NsaXA6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoImV2ZW5vZGQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5wYWludFNvbGlkQ29sb3JJbWFnZU1hc2s6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnBhaW50U29saWRDb2xvckltYWdlTWFzaygpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnBhaW50SW1hZ2VYT2JqZWN0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludEltYWdlWE9iamVjdChhcmdzWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5wYWludElubGluZUltYWdlWE9iamVjdDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFpbnRJbmxpbmVJbWFnZVhPYmplY3QoYXJnc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMucGFpbnRJbWFnZU1hc2tYT2JqZWN0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludEltYWdlTWFza1hPYmplY3QoYXJnc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMucGFpbnRGb3JtWE9iamVjdEJlZ2luOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludEZvcm1YT2JqZWN0QmVnaW4oYXJnc1swXSwgYXJnc1sxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMucGFpbnRGb3JtWE9iamVjdEVuZDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFpbnRGb3JtWE9iamVjdEVuZCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmNsb3NlUGF0aDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xvc2VQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY2xvc2VTdHJva2U6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsb3NlU3Ryb2tlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY2xvc2VGaWxsU3Ryb2tlOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbG9zZUZpbGxTdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jbG9zZUVPRmlsbFN0cm9rZToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xvc2VFT0ZpbGxTdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5uZXh0TGluZToKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubmV4dExpbmUoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy50cmFuc2Zvcm06CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnRyYW5zZm9ybShhcmdzWzBdLCBhcmdzWzFdLCBhcmdzWzJdLCBhcmdzWzNdLCBhcmdzWzRdLCBhcmdzWzVdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jb25zdHJ1Y3RQYXRoOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jb25zdHJ1Y3RQYXRoKGFyZ3NbMF0sIGFyZ3NbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmVuZFBhdGg6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIDkyOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5ncm91cChvcFRyZWVFbGVtZW50Lml0ZW1zKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBVbmltcGxlbWVudGVkIG9wZXJhdG9yICR7Zm59YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0V29yZFNwYWNpbmcod29yZFNwYWNpbmcpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC53b3JkU3BhY2luZyA9IHdvcmRTcGFjaW5nOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldENoYXJTcGFjaW5nKGNoYXJTcGFjaW5nKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuY2hhclNwYWNpbmcgPSBjaGFyU3BhY2luZzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBuZXh0TGluZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubW92ZVRleHQoMCwgdGhpcy5jdXJyZW50LmxlYWRpbmcpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldFRleHRNYXRyaXgoYSwgYiwgYywgZCwgZSwgZikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudGV4dE1hdHJpeCA9IGN1cnJlbnQubGluZU1hdHJpeCA9IFthLCBiLCBjLCBkLCBlLCBmXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudGV4dE1hdHJpeFNjYWxlID0gTWF0aC5oeXBvdChhLCBiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueCA9IGN1cnJlbnQubGluZVggPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55ID0gY3VycmVudC5saW5lWSA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Lnhjb29yZHMgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueWNvb3JkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3BhbiA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6dHNwYW4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgImZvbnQtZmFtaWx5IiwgY3VycmVudC5mb250RmFtaWx5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgImZvbnQtc2l6ZSIsIGAke3BmKGN1cnJlbnQuZm9udFNpemUpfXB4YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgcGYoLWN1cnJlbnQueSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50eHRFbGVtZW50ID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2Zzp0ZXh0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnR4dEVsZW1lbnQuYXBwZW5kKGN1cnJlbnQudHNwYW4pOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGJlZ2luVGV4dCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLmN1cnJlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnggPSBjdXJyZW50LmxpbmVYID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueSA9IGN1cnJlbnQubGluZVkgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50ZXh0TWF0cml4ID0gX3V0aWwuSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5saW5lTWF0cml4ID0gX3V0aWwuSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50ZXh0TWF0cml4U2NhbGUgPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3BhbiA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6dHNwYW4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHh0RWxlbWVudCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6dGV4dCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50eHRncnAgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOmciKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueGNvb3JkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55Y29vcmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgbW92ZVRleHQoeCwgeSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueCA9IGN1cnJlbnQubGluZVggKz0geDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueSA9IGN1cnJlbnQubGluZVkgKz0geTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueGNvb3JkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55Y29vcmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2Zzp0c3BhbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3Bhbi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZm9udC1mYW1pbHkiLCBjdXJyZW50LmZvbnRGYW1pbHkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3Bhbi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZm9udC1zaXplIiwgYCR7cGYoY3VycmVudC5mb250U2l6ZSl9cHhgKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCBwZigtY3VycmVudC55KSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2hvd1RleHQoZ2x5cGhzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9udCA9IGN1cnJlbnQuZm9udDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRTaXplID0gY3VycmVudC5mb250U2l6ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250U2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRTaXplU2NhbGUgPSBjdXJyZW50LmZvbnRTaXplU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaGFyU3BhY2luZyA9IGN1cnJlbnQuY2hhclNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3b3JkU3BhY2luZyA9IGN1cnJlbnQud29yZFNwYWNpbmc7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmb250RGlyZWN0aW9uID0gY3VycmVudC5mb250RGlyZWN0aW9uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdGV4dEhTY2FsZSA9IGN1cnJlbnQudGV4dEhTY2FsZSAqIGZvbnREaXJlY3Rpb247CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2ZXJ0aWNhbCA9IGZvbnQudmVydGljYWw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzcGFjaW5nRGlyID0gdmVydGljYWwgPyAxIDogLTE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZhdWx0Vk1ldHJpY3MgPSBmb250LmRlZmF1bHRWTWV0cmljczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoQWR2YW5jZVNjYWxlID0gZm9udFNpemUgKiBjdXJyZW50LmZvbnRNYXRyaXhbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgeCA9IDA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGdseXBoIG9mIGdseXBocykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChnbHlwaCA9PT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ICs9IGZvbnREaXJlY3Rpb24gKiB3b3JkU3BhY2luZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgZ2x5cGggPT09ICJudW1iZXIiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHggKz0gc3BhY2luZ0RpciAqIGdseXBoICogZm9udFNpemUgLyAxMDAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3BhY2luZyA9IChnbHlwaC5pc1NwYWNlID8gd29yZFNwYWNpbmcgOiAwKSArIGNoYXJTcGFjaW5nOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNoYXJhY3RlciA9IGdseXBoLmZvbnRDaGFyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzY2FsZWRYLCBzY2FsZWRZOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB3aWR0aCA9IGdseXBoLndpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2ZXJ0aWNhbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgdng7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHZtZXRyaWMgPSBnbHlwaC52bWV0cmljIHx8IGRlZmF1bHRWTWV0cmljczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdnggPSBnbHlwaC52bWV0cmljID8gdm1ldHJpY1sxXSA6IHdpZHRoICogMC41OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2eCA9IC12eCAqIHdpZHRoQWR2YW5jZVNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB2eSA9IHZtZXRyaWNbMl0gKiB3aWR0aEFkdmFuY2VTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2lkdGggPSB2bWV0cmljID8gLXZtZXRyaWNbMF0gOiB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVkWCA9IHZ4IC8gZm9udFNpemVTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2NhbGVkWSA9ICh4ICsgdnkpIC8gZm9udFNpemVTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzY2FsZWRYID0geCAvIGZvbnRTaXplU2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNjYWxlZFkgPSAwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ2x5cGguaXNJbkZvbnQgfHwgZm9udC5taXNzaW5nRmlsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Lnhjb29yZHMucHVzaChjdXJyZW50LnggKyBzY2FsZWRYKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZlcnRpY2FsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Lnljb29yZHMucHVzaCgtY3VycmVudC55ICsgc2NhbGVkWSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3Bhbi50ZXh0Q29udGVudCArPSBjaGFyYWN0ZXI7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHt9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNoYXJXaWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmVydGljYWwpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2hhcldpZHRoID0gd2lkdGggKiB3aWR0aEFkdmFuY2VTY2FsZSAtIHNwYWNpbmcgKiBmb250RGlyZWN0aW9uOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYXJXaWR0aCA9IHdpZHRoICogd2lkdGhBZHZhbmNlU2NhbGUgKyBzcGFjaW5nICogZm9udERpcmVjdGlvbjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCArPSBjaGFyV2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ4IiwgY3VycmVudC54Y29vcmRzLm1hcChwZikuam9pbigiICIpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh2ZXJ0aWNhbCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCBjdXJyZW50Lnljb29yZHMubWFwKHBmKS5qb2luKCIgIikpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgcGYoLWN1cnJlbnQueSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZlcnRpY2FsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55IC09IHg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueCArPSB4ICogdGV4dEhTY2FsZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgImZvbnQtZmFtaWx5IiwgY3VycmVudC5mb250RmFtaWx5KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgImZvbnQtc2l6ZSIsIGAke3BmKGN1cnJlbnQuZm9udFNpemUpfXB4YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudC5mb250U3R5bGUgIT09IFNWR19ERUZBVUxUUy5mb250U3R5bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJmb250LXN0eWxlIiwgY3VycmVudC5mb250U3R5bGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQuZm9udFdlaWdodCAhPT0gU1ZHX0RFRkFVTFRTLmZvbnRXZWlnaHQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJmb250LXdlaWdodCIsIGN1cnJlbnQuZm9udFdlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWxsU3Ryb2tlTW9kZSA9IGN1cnJlbnQudGV4dFJlbmRlcmluZ01vZGUgJiBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRV9NQVNLOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMIHx8IGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LmZpbGxDb2xvciAhPT0gU1ZHX0RFRkFVTFRTLmZpbGxDb2xvcikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgY3VycmVudC5maWxsQ29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudC5maWxsQWxwaGEgPCAxKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHNwYW4uc2V0QXR0cmlidXRlTlMobnVsbCwgImZpbGwtb3BhY2l0eSIsIGN1cnJlbnQuZmlsbEFscGhhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKGN1cnJlbnQudGV4dFJlbmRlcmluZ01vZGUgPT09IF91dGlsLlRleHRSZW5kZXJpbmdNb2RlLkFERF9UT19QQVRIKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3Bhbi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZmlsbCIsICJ0cmFuc3BhcmVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuLnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgIm5vbmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmaWxsU3Ryb2tlTW9kZSA9PT0gX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuU1RST0tFIHx8IGZpbGxTdHJva2VNb2RlID09PSBfdXRpbC5UZXh0UmVuZGVyaW5nTW9kZS5GSUxMX1NUUk9LRSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGxpbmVXaWR0aFNjYWxlID0gMSAvIChjdXJyZW50LnRleHRNYXRyaXhTY2FsZSB8fCAxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRTdHJva2VBdHRyaWJ1dGVzKGN1cnJlbnQudHNwYW4sIGxpbmVXaWR0aFNjYWxlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCB0ZXh0TWF0cml4ID0gY3VycmVudC50ZXh0TWF0cml4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQudGV4dFJpc2UgIT09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0TWF0cml4ID0gdGV4dE1hdHJpeC5zbGljZSgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRleHRNYXRyaXhbNV0gKz0gY3VycmVudC50ZXh0UmlzZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHh0RWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAidHJhbnNmb3JtIiwgYCR7cG0odGV4dE1hdHJpeCl9IHNjYWxlKCR7cGYodGV4dEhTY2FsZSl9LCAtMSlgKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHh0RWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhYTUxfTlMsICJ4bWw6c3BhY2UiLCAicHJlc2VydmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQudHh0RWxlbWVudC5hcHBlbmQoY3VycmVudC50c3Bhbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnR4dGdycC5hcHBlbmQoY3VycmVudC50eHRFbGVtZW50KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Vuc3VyZVRyYW5zZm9ybUdyb3VwKCkuYXBwZW5kKGN1cnJlbnQudHh0RWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0TGVhZGluZ01vdmVUZXh0KHgsIHkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGVhZGluZygteSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLm1vdmVUZXh0KHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGFkZEZvbnRTdHlsZShmb250T2JqKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWZvbnRPYmouZGF0YSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiYWRkRm9udFN0eWxlOiBObyBmb250IGRhdGEgYXZhaWxhYmxlLCAiICsgJ2Vuc3VyZSB0aGF0IHRoZSAiZm9udEV4dHJhUHJvcGVydGllcyIgQVBJIHBhcmFtZXRlciBpcyBzZXQuJyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXRoaXMuY3NzU3R5bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNzc1N0eWxlID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpzdHlsZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3NzU3R5bGUuc2V0QXR0cmlidXRlTlMobnVsbCwgInR5cGUiLCAidGV4dC9jc3MiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlZnMuYXBwZW5kKHRoaXMuY3NzU3R5bGUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdXJsID0gY3JlYXRlT2JqZWN0VVJMKGZvbnRPYmouZGF0YSwgZm9udE9iai5taW1ldHlwZSwgdGhpcy5mb3JjZURhdGFTY2hlbWEpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jc3NTdHlsZS50ZXh0Q29udGVudCArPSBgQGZvbnQtZmFjZSB7IGZvbnQtZmFtaWx5OiAiJHtmb250T2JqLmxvYWRlZE5hbWV9IjtgICsgYCBzcmM6IHVybCgke3VybH0pOyB9XG5gOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldEZvbnQoZGV0YWlscykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvbnRPYmogPSB0aGlzLmNvbW1vbk9ianMuZ2V0KGRldGFpbHNbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHNpemUgPSBkZXRhaWxzWzFdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5mb250ID0gZm9udE9iajsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmVtYmVkRm9udHMgJiYgIWZvbnRPYmoubWlzc2luZ0ZpbGUgJiYgIXRoaXMuZW1iZWRkZWRGb250c1tmb250T2JqLmxvYWRlZE5hbWVdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRGb250U3R5bGUoZm9udE9iaik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbWJlZGRlZEZvbnRzW2ZvbnRPYmoubG9hZGVkTmFtZV0gPSBmb250T2JqOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5mb250TWF0cml4ID0gZm9udE9iai5mb250TWF0cml4IHx8IF91dGlsLkZPTlRfSURFTlRJVFlfTUFUUklYOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGJvbGQgPSAibm9ybWFsIjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmb250T2JqLmJsYWNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYm9sZCA9ICI5MDAiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmIChmb250T2JqLmJvbGQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBib2xkID0gImJvbGQiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaXRhbGljID0gZm9udE9iai5pdGFsaWMgPyAiaXRhbGljIiA6ICJub3JtYWwiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNpemUgPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2l6ZSA9IC1zaXplOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuZm9udERpcmVjdGlvbiA9IC0xOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmZvbnREaXJlY3Rpb24gPSAxOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5mb250U2l6ZSA9IHNpemU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmZvbnRGYW1pbHkgPSBmb250T2JqLmxvYWRlZE5hbWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmZvbnRXZWlnaHQgPSBib2xkOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5mb250U3R5bGUgPSBpdGFsaWM7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LnRzcGFuID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2Zzp0c3BhbiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC50c3Bhbi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAieSIsIHBmKC1jdXJyZW50LnkpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQueGNvb3JkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC55Y29vcmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZW5kVGV4dCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfY3VycmVudCR0eHRFbGVtZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LnRleHRSZW5kZXJpbmdNb2RlICYgX3V0aWwuVGV4dFJlbmRlcmluZ01vZGUuQUREX1RPX1BBVEhfRkxBRyAmJiAoX2N1cnJlbnQkdHh0RWxlbWVudCA9IGN1cnJlbnQudHh0RWxlbWVudCkgIT09IG51bGwgJiYgX2N1cnJlbnQkdHh0RWxlbWVudCAhPT0gdm9pZCAwICYmIF9jdXJyZW50JHR4dEVsZW1lbnQuaGFzQ2hpbGROb2RlcygpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5lbGVtZW50ID0gY3VycmVudC50eHRFbGVtZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY2xpcCgibm9uemVybyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW5kUGF0aCgpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldExpbmVXaWR0aCh3aWR0aCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHdpZHRoID4gMCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5saW5lV2lkdGggPSB3aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzZXRMaW5lQ2FwKHN0eWxlKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQubGluZUNhcCA9IExJTkVfQ0FQX1NUWUxFU1tzdHlsZV07CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0TGluZUpvaW4oc3R5bGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5saW5lSm9pbiA9IExJTkVfSk9JTl9TVFlMRVNbc3R5bGVdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldE1pdGVyTGltaXQobGltaXQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5taXRlckxpbWl0ID0gbGltaXQ7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0U3Ryb2tlQWxwaGEoc3Ryb2tlQWxwaGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5zdHJva2VBbHBoYSA9IHN0cm9rZUFscGhhOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZVJHQkNvbG9yKHIsIGcsIGIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5zdHJva2VDb2xvciA9IF91dGlsLlV0aWwubWFrZUhleENvbG9yKHIsIGcsIGIpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldEZpbGxBbHBoYShmaWxsQWxwaGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5maWxsQWxwaGEgPSBmaWxsQWxwaGE7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0RmlsbFJHQkNvbG9yKHIsIGcsIGIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5maWxsQ29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvcihyLCBnLCBiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC50c3BhbiA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6dHNwYW4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC54Y29vcmRzID0gW107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQueWNvb3JkcyA9IFtdOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldFN0cm9rZUNvbG9yTihhcmdzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuc3Ryb2tlQ29sb3IgPSB0aGlzLl9tYWtlQ29sb3JOX1BhdHRlcm4oYXJncyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0RmlsbENvbG9yTihhcmdzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuZmlsbENvbG9yID0gdGhpcy5fbWFrZUNvbG9yTl9QYXR0ZXJuKGFyZ3MpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNoYWRpbmdGaWxsKGFyZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gdGhpcy52aWV3cG9ydC53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IHRoaXMudmlld3BvcnQuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW52ID0gX3V0aWwuVXRpbC5pbnZlcnNlVHJhbnNmb3JtKHRoaXMudHJhbnNmb3JtTWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGJsID0gX3V0aWwuVXRpbC5hcHBseVRyYW5zZm9ybShbMCwgMF0sIGludik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBiciA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oWzAsIGhlaWdodF0sIGludik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB1bCA9IF91dGlsLlV0aWwuYXBwbHlUcmFuc2Zvcm0oW3dpZHRoLCAwXSwgaW52KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHVyID0gX3V0aWwuVXRpbC5hcHBseVRyYW5zZm9ybShbd2lkdGgsIGhlaWdodF0sIGludik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB4MCA9IE1hdGgubWluKGJsWzBdLCBiclswXSwgdWxbMF0sIHVyWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHkwID0gTWF0aC5taW4oYmxbMV0sIGJyWzFdLCB1bFsxXSwgdXJbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeDEgPSBNYXRoLm1heChibFswXSwgYnJbMF0sIHVsWzBdLCB1clswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB5MSA9IE1hdGgubWF4KGJsWzFdLCBiclsxXSwgdWxbMV0sIHVyWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJlY3QgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOnJlY3QiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIngiLCB4MCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgeTApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAid2lkdGgiLCB4MSAtIHgwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgImhlaWdodCIsIHkxIC0geTApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZmlsbCIsIHRoaXMuX21ha2VTaGFkaW5nUGF0dGVybihhcmdzKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5jdXJyZW50LmZpbGxBbHBoYSA8IDEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsLW9wYWNpdHkiLCB0aGlzLmN1cnJlbnQuZmlsbEFscGhhKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2Vuc3VyZVRyYW5zZm9ybUdyb3VwKCkuYXBwZW5kKHJlY3QpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9tYWtlQ29sb3JOX1BhdHRlcm4oYXJncykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFyZ3NbMF0gPT09ICJUaWxpbmdQYXR0ZXJuIikgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9tYWtlVGlsaW5nUGF0dGVybihhcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLl9tYWtlU2hhZGluZ1BhdHRlcm4oYXJncyk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgX21ha2VUaWxpbmdQYXR0ZXJuKGFyZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yID0gYXJnc1sxXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG9wZXJhdG9yTGlzdCA9IGFyZ3NbMl07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBtYXRyaXggPSBhcmdzWzNdIHx8IF91dGlsLklERU5USVRZX01BVFJJWDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IFt4MCwgeTAsIHgxLCB5MV0gPSBhcmdzWzRdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeHN0ZXAgPSBhcmdzWzVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeXN0ZXAgPSBhcmdzWzZdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcGFpbnRUeXBlID0gYXJnc1s3XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRpbGluZ0lkID0gYHNoYWRpbmcke3NoYWRpbmdDb3VudCsrfWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBbdHgwLCB0eTAsIHR4MSwgdHkxXSA9IF91dGlsLlV0aWwubm9ybWFsaXplUmVjdChbLi4uX3V0aWwuVXRpbC5hcHBseVRyYW5zZm9ybShbeDAsIHkwXSwgbWF0cml4KSwgLi4uX3V0aWwuVXRpbC5hcHBseVRyYW5zZm9ybShbeDEsIHkxXSwgbWF0cml4KV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgW3hzY2FsZSwgeXNjYWxlXSA9IF91dGlsLlV0aWwuc2luZ3VsYXJWYWx1ZURlY29tcG9zZTJkU2NhbGUobWF0cml4KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHR4c3RlcCA9IHhzdGVwICogeHNjYWxlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgdHlzdGVwID0geXN0ZXAgKiB5c2NhbGU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0aWxpbmcgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOnBhdHRlcm4iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRpbGluZy5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaWQiLCB0aWxpbmdJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aWxpbmcuc2V0QXR0cmlidXRlTlMobnVsbCwgInBhdHRlcm5Vbml0cyIsICJ1c2VyU3BhY2VPblVzZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGlsaW5nLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ3aWR0aCIsIHR4c3RlcCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aWxpbmcuc2V0QXR0cmlidXRlTlMobnVsbCwgImhlaWdodCIsIHR5c3RlcCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aWxpbmcuc2V0QXR0cmlidXRlTlMobnVsbCwgIngiLCBgJHt0eDB9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aWxpbmcuc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCBgJHt0eTB9YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdmcgPSB0aGlzLnN2ZzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zZm9ybU1hdHJpeCA9IHRoaXMudHJhbnNmb3JtTWF0cml4OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbENvbG9yID0gdGhpcy5jdXJyZW50LmZpbGxDb2xvcjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN0cm9rZUNvbG9yID0gdGhpcy5jdXJyZW50LnN0cm9rZUNvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYmJveCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUodHgxIC0gdHgwLCB0eTEgLSB0eTApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdmcgPSBiYm94OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm1NYXRyaXggPSBtYXRyaXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAocGFpbnRUeXBlID09PSAyKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3NzQ29sb3IgPSBfdXRpbC5VdGlsLm1ha2VIZXhDb2xvciguLi5jb2xvcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmZpbGxDb2xvciA9IGNzc0NvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5zdHJva2VDb2xvciA9IGNzc0NvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5leGVjdXRlT3BUcmVlKHRoaXMuY29udmVydE9wTGlzdChvcGVyYXRvckxpc3QpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3ZnID0gc3ZnOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm1NYXRyaXggPSB0cmFuc2Zvcm1NYXRyaXg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmN1cnJlbnQuZmlsbENvbG9yID0gZmlsbENvbG9yOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnN0cm9rZUNvbG9yID0gc3Ryb2tlQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aWxpbmcuYXBwZW5kKGJib3guY2hpbGROb2Rlc1swXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlZnMuYXBwZW5kKHRpbGluZyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYHVybCgjJHt0aWxpbmdJZH0pYDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfbWFrZVNoYWRpbmdQYXR0ZXJuKGFyZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgYXJncyA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhcmdzID0gdGhpcy5vYmpzLmdldChhcmdzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoYXJnc1swXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlJhZGlhbEF4aWFsIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2hhZGluZ0lkID0gYHNoYWRpbmcke3NoYWRpbmdDb3VudCsrfWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGNvbG9yU3RvcHMgPSBhcmdzWzNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgZ3JhZGllbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3aXRjaCAoYXJnc1sxXSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiYXhpYWwiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHBvaW50MCA9IGFyZ3NbNF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcG9pbnQxID0gYXJnc1s1XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6bGluZWFyR3JhZGllbnQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaWQiLCBzaGFkaW5nSWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJncmFkaWVudFVuaXRzIiwgInVzZXJTcGFjZU9uVXNlIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgIngxIiwgcG9pbnQwWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAieTEiLCBwb2ludDBbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ4MiIsIHBvaW50MVswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgInkyIiwgcG9pbnQxWzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgInJhZGlhbCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZm9jYWxQb2ludCA9IGFyZ3NbNF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2lyY2xlUG9pbnQgPSBhcmdzWzVdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZvY2FsUmFkaXVzID0gYXJnc1s2XTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjaXJjbGVSYWRpdXMgPSBhcmdzWzddOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50ID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpyYWRpYWxHcmFkaWVudCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJpZCIsIHNoYWRpbmdJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImdyYWRpZW50VW5pdHMiLCAidXNlclNwYWNlT25Vc2UiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiY3giLCBjaXJjbGVQb2ludFswXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImN5IiwgY2lyY2xlUG9pbnRbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyYWRpZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJyIiwgY2lyY2xlUmFkaXVzKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZngiLCBmb2NhbFBvaW50WzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZnkiLCBmb2NhbFBvaW50WzFdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmFkaWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZnIiLCBmb2NhbFJhZGl1cyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5rbm93biBSYWRpYWxBeGlhbCB0eXBlOiAke2FyZ3NbMV19YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBjb2xvclN0b3Agb2YgY29sb3JTdG9wcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3RvcCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6c3RvcCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RvcC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAib2Zmc2V0IiwgY29sb3JTdG9wWzBdKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN0b3Auc2V0QXR0cmlidXRlTlMobnVsbCwgInN0b3AtY29sb3IiLCBjb2xvclN0b3BbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ3JhZGllbnQuYXBwZW5kKHN0b3ApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVmcy5hcHBlbmQoZ3JhZGllbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gYHVybCgjJHtzaGFkaW5nSWR9KWA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTWVzaCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5pbXBsZW1lbnRlZCBwYXR0ZXJuIE1lc2giKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiRHVtbXkiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gImhvdHBpbmsiOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5rbm93biBJUiB0eXBlOiAke2FyZ3NbMF19YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0RGFzaChkYXNoQXJyYXksIGRhc2hQaGFzZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmRhc2hBcnJheSA9IGRhc2hBcnJheTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5kYXNoUGhhc2UgPSBkYXNoUGhhc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY29uc3RydWN0UGF0aChvcHMsIGFyZ3MpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLmN1cnJlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgeCA9IGN1cnJlbnQueCwKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5ID0gY3VycmVudC55OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGQgPSBbXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxldCBqID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgb3Agb2Ygb3BzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChvcCB8IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMucmVjdGFuZ2xlOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHh3ID0geCArIHdpZHRoOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgeWggPSB5ICsgaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZC5wdXNoKCJNIiwgcGYoeCksIHBmKHkpLCAiTCIsIHBmKHh3KSwgcGYoeSksICJMIiwgcGYoeHcpLCBwZih5aCksICJMIiwgcGYoeCksIHBmKHloKSwgIloiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tb3ZlVG86CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ID0gYXJnc1tqKytdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGQucHVzaCgiTSIsIHBmKHgpLCBwZih5KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSBfdXRpbC5PUFMubGluZVRvOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaisrXTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSBhcmdzW2orK107CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkLnB1c2goIkwiLCBwZih4KSwgcGYoeSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmN1cnZlVG86CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ID0gYXJnc1tqICsgNF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB5ID0gYXJnc1tqICsgNV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkLnB1c2goIkMiLCBwZihhcmdzW2pdKSwgcGYoYXJnc1tqICsgMV0pLCBwZihhcmdzW2ogKyAyXSksIHBmKGFyZ3NbaiArIDNdKSwgcGYoeCksIHBmKHkpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGogKz0gNjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jdXJ2ZVRvMjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGQucHVzaCgiQyIsIHBmKHgpLCBwZih5KSwgcGYoYXJnc1tqXSksIHBmKGFyZ3NbaiArIDFdKSwgcGYoYXJnc1tqICsgMl0pLCBwZihhcmdzW2ogKyAzXSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaiArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaiArIDNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaiArPSA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmN1cnZlVG8zOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeCA9IGFyZ3NbaiArIDJdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeSA9IGFyZ3NbaiArIDNdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZC5wdXNoKCJDIiwgcGYoYXJnc1tqXSksIHBmKGFyZ3NbaiArIDFdKSwgcGYoeCksIHBmKHkpLCBwZih4KSwgcGYoeSkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaiArPSA0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmNsb3NlUGF0aDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGQucHVzaCgiWiIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZCA9IGQuam9pbigiICIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGN1cnJlbnQucGF0aCAmJiBvcHMubGVuZ3RoID4gMCAmJiBvcHNbMF0gIT09IF91dGlsLk9QUy5yZWN0YW5nbGUgJiYgb3BzWzBdICE9PSBfdXRpbC5PUFMubW92ZVRvKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZCA9IGN1cnJlbnQucGF0aC5nZXRBdHRyaWJ1dGVOUyhudWxsLCAiZCIpICsgZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5wYXRoID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpwYXRoIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZW5zdXJlVHJhbnNmb3JtR3JvdXAoKS5hcHBlbmQoY3VycmVudC5wYXRoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQucGF0aC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZCIsIGQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5wYXRoLnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgIm5vbmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuZWxlbWVudCA9IGN1cnJlbnQucGF0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuc2V0Q3VycmVudFBvaW50KHgsIHkpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGVuZFBhdGgoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5wYXRoID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy5wZW5kaW5nQ2xpcCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghY3VycmVudC5lbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nQ2xpcCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xpcElkID0gYGNsaXBwYXRoJHtjbGlwQ291bnQrK31gOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xpcFBhdGggPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOmNsaXBQYXRoIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwUGF0aC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaWQiLCBjbGlwSWQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcFBhdGguc2V0QXR0cmlidXRlTlMobnVsbCwgInRyYW5zZm9ybSIsIHBtKHRoaXMudHJhbnNmb3JtTWF0cml4KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjbGlwRWxlbWVudCA9IGN1cnJlbnQuZWxlbWVudC5jbG9uZU5vZGUodHJ1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5wZW5kaW5nQ2xpcCA9PT0gImV2ZW5vZGQiKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcEVsZW1lbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImNsaXAtcnVsZSIsICJldmVub2RkIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsaXBFbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJjbGlwLXJ1bGUiLCAibm9uemVybyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wZW5kaW5nQ2xpcCA9IG51bGw7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwUGF0aC5hcHBlbmQoY2xpcEVsZW1lbnQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kZWZzLmFwcGVuZChjbGlwUGF0aCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudC5hY3RpdmVDbGlwVXJsKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5jbGlwR3JvdXAgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcHJldiBvZiB0aGlzLmV4dHJhU3RhY2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJldi5jbGlwR3JvdXAgPSBudWxsOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwUGF0aC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiY2xpcC1wYXRoIiwgY3VycmVudC5hY3RpdmVDbGlwVXJsKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQuYWN0aXZlQ2xpcFVybCA9IGB1cmwoIyR7Y2xpcElkfSlgOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50Z3JwID0gbnVsbDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBjbGlwKHR5cGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGVuZGluZ0NsaXAgPSB0eXBlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNsb3NlUGF0aCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGN1cnJlbnQgPSB0aGlzLmN1cnJlbnQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY3VycmVudC5wYXRoKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZCA9IGAke2N1cnJlbnQucGF0aC5nZXRBdHRyaWJ1dGVOUyhudWxsLCAiZCIpfVpgOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGN1cnJlbnQucGF0aC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZCIsIGQpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldExlYWRpbmcobGVhZGluZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmxlYWRpbmcgPSAtbGVhZGluZzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzZXRUZXh0UmlzZSh0ZXh0UmlzZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnRleHRSaXNlID0gdGV4dFJpc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc2V0VGV4dFJlbmRlcmluZ01vZGUodGV4dFJlbmRlcmluZ01vZGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC50ZXh0UmVuZGVyaW5nTW9kZSA9IHRleHRSZW5kZXJpbmdNb2RlOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIHNldEhTY2FsZShzY2FsZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LnRleHRIU2NhbGUgPSBzY2FsZSAvIDEwMDsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBzZXRSZW5kZXJpbmdJbnRlbnQoaW50ZW50KSB7fQogICAgICAgICAgICAgICAgICAgICAgICBzZXRGbGF0bmVzcyhmbGF0bmVzcykge30KICAgICAgICAgICAgICAgICAgICAgICAgc2V0R1N0YXRlKHN0YXRlcykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBba2V5LCB2YWx1ZV0gb2Ygc3RhdGVzKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3dpdGNoIChrZXkpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTFciOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRMaW5lV2lkdGgodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIkxDIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0TGluZUNhcCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTEoiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRMaW5lSm9pbih2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiTUwiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRNaXRlckxpbWl0KHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJEIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0RGFzaCh2YWx1ZVswXSwgdmFsdWVbMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNhc2UgIlJJIjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0UmVuZGVyaW5nSW50ZW50KHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJGTCI6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNldEZsYXRuZXNzKHZhbHVlKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjYXNlICJGb250IjoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc2V0Rm9udCh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiQ0EiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRTdHJva2VBbHBoYSh2YWx1ZSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2FzZSAiY2EiOgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zZXRGaWxsQWxwaGEodmFsdWUpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYFVuaW1wbGVtZW50ZWQgZ3JhcGhpYyBzdGF0ZSBvcGVyYXRvciAke2tleX1gKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmaWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LmVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50LmVsZW1lbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImZpbGwiLCBjdXJyZW50LmZpbGxDb2xvcik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5lbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsLW9wYWNpdHkiLCBjdXJyZW50LmZpbGxBbHBoYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5lbmRQYXRoKCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgc3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjdXJyZW50LmVsZW1lbnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9zZXRTdHJva2VBdHRyaWJ1dGVzKGN1cnJlbnQuZWxlbWVudCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY3VycmVudC5lbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgIm5vbmUiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfc2V0U3Ryb2tlQXR0cmlidXRlcyhlbGVtZW50KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZXQgbGluZVdpZHRoU2NhbGUgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IDE7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjdXJyZW50ID0gdGhpcy5jdXJyZW50OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGRhc2hBcnJheSA9IGN1cnJlbnQuZGFzaEFycmF5OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGxpbmVXaWR0aFNjYWxlICE9PSAxICYmIGRhc2hBcnJheS5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZGFzaEFycmF5ID0gZGFzaEFycmF5Lm1hcChmdW5jdGlvbiAodmFsdWUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGxpbmVXaWR0aFNjYWxlICogdmFsdWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJzdHJva2UiLCBjdXJyZW50LnN0cm9rZUNvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsZW1lbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgInN0cm9rZS1vcGFjaXR5IiwgY3VycmVudC5zdHJva2VBbHBoYSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJzdHJva2UtbWl0ZXJsaW1pdCIsIHBmKGN1cnJlbnQubWl0ZXJMaW1pdCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAic3Ryb2tlLWxpbmVjYXAiLCBjdXJyZW50LmxpbmVDYXApOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAic3Ryb2tlLWxpbmVqb2luIiwgY3VycmVudC5saW5lSm9pbik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJzdHJva2Utd2lkdGgiLCBwZihsaW5lV2lkdGhTY2FsZSAqIGN1cnJlbnQubGluZVdpZHRoKSArICJweCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAic3Ryb2tlLWRhc2hhcnJheSIsIGRhc2hBcnJheS5tYXAocGYpLmpvaW4oIiAiKSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbGVtZW50LnNldEF0dHJpYnV0ZU5TKG51bGwsICJzdHJva2UtZGFzaG9mZnNldCIsIHBmKGxpbmVXaWR0aFNjYWxlICogY3VycmVudC5kYXNoUGhhc2UpICsgInB4Iik7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgZW9GaWxsKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIF90aGlzJGN1cnJlbnQkZWxlbWVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIChfdGhpcyRjdXJyZW50JGVsZW1lbnQgPSB0aGlzLmN1cnJlbnQuZWxlbWVudCkgPT09IG51bGwgfHwgX3RoaXMkY3VycmVudCRlbGVtZW50ID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfdGhpcyRjdXJyZW50JGVsZW1lbnQuc2V0QXR0cmlidXRlTlMobnVsbCwgImZpbGwtcnVsZSIsICJldmVub2RkIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZpbGwoKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBmaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdHJva2UoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbCgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGVvRmlsbFN0cm9rZSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBfdGhpcyRjdXJyZW50JGVsZW1lbnQyOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgKF90aGlzJGN1cnJlbnQkZWxlbWVudDIgPSB0aGlzLmN1cnJlbnQuZWxlbWVudCkgPT09IG51bGwgfHwgX3RoaXMkY3VycmVudCRlbGVtZW50MiA9PT0gdm9pZCAwID8gdm9pZCAwIDogX3RoaXMkY3VycmVudCRlbGVtZW50Mi5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZmlsbC1ydWxlIiwgImV2ZW5vZGQiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbFN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNsb3NlU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbG9zZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3Ryb2tlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgY2xvc2VGaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbG9zZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZmlsbFN0cm9rZSgpOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIGNsb3NlRU9GaWxsU3Ryb2tlKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jbG9zZVBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZW9GaWxsU3Ryb2tlKCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRTb2xpZENvbG9ySW1hZ2VNYXNrKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgcmVjdCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6cmVjdCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAieCIsICIwIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgIjAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIndpZHRoIiwgIjFweCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaGVpZ2h0IiwgIjFweCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiZmlsbCIsIHRoaXMuY3VycmVudC5maWxsQ29sb3IpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZW5zdXJlVHJhbnNmb3JtR3JvdXAoKS5hcHBlbmQocmVjdCk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRJbWFnZVhPYmplY3Qob2JqSWQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltZ0RhdGEgPSB0aGlzLmdldE9iamVjdChvYmpJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWltZ0RhdGEpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYERlcGVuZGVudCBpbWFnZSB3aXRoIG9iamVjdCBJRCAke29iaklkfSBpcyBub3QgcmVhZHkgeWV0YCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5wYWludElubGluZUltYWdlWE9iamVjdChpbWdEYXRhKTsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwYWludElubGluZUltYWdlWE9iamVjdChpbWdEYXRhLCBtYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB3aWR0aCA9IGltZ0RhdGEud2lkdGg7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBoZWlnaHQgPSBpbWdEYXRhLmhlaWdodDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltZ1NyYyA9IGNvbnZlcnRJbWdEYXRhVG9QbmcoaW1nRGF0YSwgdGhpcy5mb3JjZURhdGFTY2hlbWEsICEhbWFzayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBjbGlwcmVjdCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6cmVjdCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIngiLCAiMCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCAiMCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIndpZHRoIiwgcGYod2lkdGgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsaXByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJoZWlnaHQiLCBwZihoZWlnaHQpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuY3VycmVudC5lbGVtZW50ID0gY2xpcHJlY3Q7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoIm5vbnplcm8iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGltZ0VsID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzppbWFnZSIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nRWwuc2V0QXR0cmlidXRlTlMoWExJTktfTlMsICJ4bGluazpocmVmIiwgaW1nU3JjKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZ0VsLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ4IiwgIjAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltZ0VsLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgcGYoLWhlaWdodCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nRWwuc2V0QXR0cmlidXRlTlMobnVsbCwgIndpZHRoIiwgcGYod2lkdGgpICsgInB4Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbWdFbC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaGVpZ2h0IiwgcGYoaGVpZ2h0KSArICJweCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaW1nRWwuc2V0QXR0cmlidXRlTlMobnVsbCwgInRyYW5zZm9ybSIsIGBzY2FsZSgke3BmKDEgLyB3aWR0aCl9ICR7cGYoLTEgLyBoZWlnaHQpfSlgKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChtYXNrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFzay5hcHBlbmQoaW1nRWwpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbnN1cmVUcmFuc2Zvcm1Hcm91cCgpLmFwcGVuZChpbWdFbCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRJbWFnZU1hc2tYT2JqZWN0KGltZykgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW1nRGF0YSA9IHRoaXMuZ2V0T2JqZWN0KGltZy5kYXRhLCBpbWcpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGltZ0RhdGEuYml0bWFwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJwYWludEltYWdlTWFza1hPYmplY3Q6IEltYWdlQml0bWFwIHN1cHBvcnQgaXMgbm90IGltcGxlbWVudGVkLCAiICsgImVuc3VyZSB0aGF0IHRoZSBgaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWRgIEFQSSBwYXJhbWV0ZXIgaXMgZGlzYWJsZWQuIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY3VycmVudCA9IHRoaXMuY3VycmVudDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gaW1nRGF0YS53aWR0aDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGhlaWdodCA9IGltZ0RhdGEuaGVpZ2h0OwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgZmlsbENvbG9yID0gY3VycmVudC5maWxsQ29sb3I7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjdXJyZW50Lm1hc2tJZCA9IGBtYXNrJHttYXNrQ291bnQrK31gOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbWFzayA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6bWFzayIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFzay5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaWQiLCBjdXJyZW50Lm1hc2tJZCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWN0ID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpyZWN0Iik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ4IiwgIjAiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgInkiLCAiMCIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAid2lkdGgiLCBwZih3aWR0aCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaGVpZ2h0IiwgcGYoaGVpZ2h0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJmaWxsIiwgZmlsbENvbG9yKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIm1hc2siLCBgdXJsKCMke2N1cnJlbnQubWFza0lkfSlgKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuZGVmcy5hcHBlbmQobWFzayk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbnN1cmVUcmFuc2Zvcm1Hcm91cCgpLmFwcGVuZChyZWN0KTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucGFpbnRJbmxpbmVJbWFnZVhPYmplY3QoaW1nRGF0YSwgbWFzayk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgcGFpbnRGb3JtWE9iamVjdEJlZ2luKG1hdHJpeCwgYmJveCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkobWF0cml4KSAmJiBtYXRyaXgubGVuZ3RoID09PSA2KSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50cmFuc2Zvcm0obWF0cml4WzBdLCBtYXRyaXhbMV0sIG1hdHJpeFsyXSwgbWF0cml4WzNdLCBtYXRyaXhbNF0sIG1hdHJpeFs1XSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYmJveCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHdpZHRoID0gYmJveFsyXSAtIGJib3hbMF07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaGVpZ2h0ID0gYmJveFszXSAtIGJib3hbMV07CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xpcHJlY3QgPSB0aGlzLnN2Z0ZhY3RvcnkuY3JlYXRlRWxlbWVudCgic3ZnOnJlY3QiKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAieCIsIGJib3hbMF0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNsaXByZWN0LnNldEF0dHJpYnV0ZU5TKG51bGwsICJ5IiwgYmJveFsxXSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcHJlY3Quc2V0QXR0cmlidXRlTlMobnVsbCwgIndpZHRoIiwgcGYod2lkdGgpKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjbGlwcmVjdC5zZXRBdHRyaWJ1dGVOUyhudWxsLCAiaGVpZ2h0IiwgcGYoaGVpZ2h0KSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmVsZW1lbnQgPSBjbGlwcmVjdDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmNsaXAoIm5vbnplcm8iKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmVuZFBhdGgoKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBwYWludEZvcm1YT2JqZWN0RW5kKCkge30KICAgICAgICAgICAgICAgICAgICAgICAgX2luaXRpYWxpemUodmlld3BvcnQpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN2ZyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGUodmlld3BvcnQud2lkdGgsIHZpZXdwb3J0LmhlaWdodCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBkZWZpbml0aW9ucyA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6ZGVmcyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ZnLmFwcGVuZChkZWZpbml0aW9ucyk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRlZnMgPSBkZWZpbml0aW9uczsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHJvb3RHcm91cCA9IHRoaXMuc3ZnRmFjdG9yeS5jcmVhdGVFbGVtZW50KCJzdmc6ZyIpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcm9vdEdyb3VwLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ0cmFuc2Zvcm0iLCBwbSh2aWV3cG9ydC50cmFuc2Zvcm0pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN2Zy5hcHBlbmQocm9vdEdyb3VwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuc3ZnID0gcm9vdEdyb3VwOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN2ZzsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgICBfZW5zdXJlQ2xpcEdyb3VwKCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCF0aGlzLmN1cnJlbnQuY2xpcEdyb3VwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgY2xpcEdyb3VwID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpnIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY2xpcEdyb3VwLnNldEF0dHJpYnV0ZU5TKG51bGwsICJjbGlwLXBhdGgiLCB0aGlzLmN1cnJlbnQuYWN0aXZlQ2xpcFVybCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zdmcuYXBwZW5kKGNsaXBHcm91cCk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5jdXJyZW50LmNsaXBHcm91cCA9IGNsaXBHcm91cDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0aGlzLmN1cnJlbnQuY2xpcEdyb3VwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgIF9lbnN1cmVUcmFuc2Zvcm1Hcm91cCgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdGhpcy50Z3JwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50Z3JwID0gdGhpcy5zdmdGYWN0b3J5LmNyZWF0ZUVsZW1lbnQoInN2ZzpnIik7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy50Z3JwLnNldEF0dHJpYnV0ZU5TKG51bGwsICJ0cmFuc2Zvcm0iLCBwbSh0aGlzLnRyYW5zZm9ybU1hdHJpeCkpOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLmN1cnJlbnQuYWN0aXZlQ2xpcFVybCkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9lbnN1cmVDbGlwR3JvdXAoKS5hcHBlbmQodGhpcy50Z3JwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnN2Zy5hcHBlbmQodGhpcy50Z3JwKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGhpcy50Z3JwOwogICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvKioqLyB9KQogICAgICAgICAgICAvKioqKioqLyAJXSk7CiAgICAgICAgLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KICAgICAgICAvKioqKioqLyAJLy8gVGhlIG1vZHVsZSBjYWNoZQogICAgICAgIC8qKioqKiovIAl2YXIgX193ZWJwYWNrX21vZHVsZV9jYWNoZV9fID0ge307CiAgICAgICAgLyoqKioqKi8KICAgICAgICAvKioqKioqLyAJLy8gVGhlIHJlcXVpcmUgZnVuY3Rpb24KICAgICAgICAvKioqKioqLyAJZnVuY3Rpb24gX193X3BkZmpzX3JlcXVpcmVfXyhtb2R1bGVJZCkgewogICAgICAgICAgICAvKioqKioqLyAJCS8vIENoZWNrIGlmIG1vZHVsZSBpcyBpbiBjYWNoZQogICAgICAgICAgICAvKioqKioqLyAJCXZhciBjYWNoZWRNb2R1bGUgPSBfX3dlYnBhY2tfbW9kdWxlX2NhY2hlX19bbW9kdWxlSWRdOwogICAgICAgICAgICAvKioqKioqLyAJCWlmIChjYWNoZWRNb2R1bGUgIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgICAgLyoqKioqKi8gCQkJcmV0dXJuIGNhY2hlZE1vZHVsZS5leHBvcnRzOwogICAgICAgICAgICAgICAgLyoqKioqKi8gCQl9CiAgICAgICAgICAgIC8qKioqKiovIAkJLy8gQ3JlYXRlIGEgbmV3IG1vZHVsZSAoYW5kIHB1dCBpdCBpbnRvIHRoZSBjYWNoZSkKICAgICAgICAgICAgLyoqKioqKi8gCQl2YXIgbW9kdWxlID0gX193ZWJwYWNrX21vZHVsZV9jYWNoZV9fW21vZHVsZUlkXSA9IHsKICAgICAgICAgICAgICAgIC8qKioqKiovIAkJCS8vIG5vIG1vZHVsZS5pZCBuZWVkZWQKICAgICAgICAgICAgICAgIC8qKioqKiovIAkJCS8vIG5vIG1vZHVsZS5sb2FkZWQgbmVlZGVkCiAgICAgICAgICAgICAgICAvKioqKioqLyAJCQlleHBvcnRzOiB7fQogICAgICAgICAgICAgICAgLyoqKioqKi8gCQl9OwogICAgICAgICAgICAvKioqKioqLwogICAgICAgICAgICAvKioqKioqLyAJCS8vIEV4ZWN1dGUgdGhlIG1vZHVsZSBmdW5jdGlvbgogICAgICAgICAgICAvKioqKioqLyAJCV9fd2VicGFja19tb2R1bGVzX19bbW9kdWxlSWRdKG1vZHVsZSwgbW9kdWxlLmV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pOwogICAgICAgICAgICAvKioqKioqLwogICAgICAgICAgICAvKioqKioqLyAJCS8vIFJldHVybiB0aGUgZXhwb3J0cyBvZiB0aGUgbW9kdWxlCiAgICAgICAgICAgIC8qKioqKiovIAkJcmV0dXJuIG1vZHVsZS5leHBvcnRzOwogICAgICAgICAgICAvKioqKioqLyAJfQogICAgICAgIC8qKioqKiovCiAgICAgICAgLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KICAgICAgICB2YXIgX193ZWJwYWNrX2V4cG9ydHNfXyA9IHt9OwovLyBUaGlzIGVudHJ5IG5lZWQgdG8gYmUgd3JhcHBlZCBpbiBhbiBJSUZFIGJlY2F1c2UgaXQgbmVlZCB0byBiZSBpbiBzdHJpY3QgbW9kZS4KICAgICAgICAoKCkgPT4gewogICAgICAgICAgICAidXNlIHN0cmljdCI7CiAgICAgICAgICAgIHZhciBleHBvcnRzID0gX193ZWJwYWNrX2V4cG9ydHNfXzsKCgogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIl9fZXNNb2R1bGUiLCAoewogICAgICAgICAgICAgICAgdmFsdWU6IHRydWUKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIkFib3J0RXhjZXB0aW9uIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuQWJvcnRFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJBbm5vdGF0aW9uRWRpdG9yTGF5ZXIiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfYW5ub3RhdGlvbl9lZGl0b3JfbGF5ZXIuQW5ub3RhdGlvbkVkaXRvckxheWVyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiQW5ub3RhdGlvbkVkaXRvclBhcmFtc1R5cGUiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfdXRpbC5Bbm5vdGF0aW9uRWRpdG9yUGFyYW1zVHlwZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIkFubm90YXRpb25FZGl0b3JUeXBlIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJBbm5vdGF0aW9uRWRpdG9yVUlNYW5hZ2VyIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3Rvb2xzLkFubm90YXRpb25FZGl0b3JVSU1hbmFnZXI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJBbm5vdGF0aW9uTGF5ZXIiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfYW5ub3RhdGlvbl9sYXllci5Bbm5vdGF0aW9uTGF5ZXI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJBbm5vdGF0aW9uTW9kZSIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLkFubm90YXRpb25Nb2RlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiQ01hcENvbXByZXNzaW9uVHlwZSIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLkNNYXBDb21wcmVzc2lvblR5cGU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJGZWF0dXJlVGVzdCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLkZlYXR1cmVUZXN0OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiR2xvYmFsV29ya2VyT3B0aW9ucyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF93b3JrZXJfb3B0aW9ucy5HbG9iYWxXb3JrZXJPcHRpb25zOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiSW52YWxpZFBERkV4Y2VwdGlvbiIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLkludmFsaWRQREZFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJNaXNzaW5nUERGRXhjZXB0aW9uIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuTWlzc2luZ1BERkV4Y2VwdGlvbjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIk9QUyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLk9QUzsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIlBERkRhdGFSYW5nZVRyYW5zcG9ydCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9hcGkuUERGRGF0YVJhbmdlVHJhbnNwb3J0OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiUERGRGF0ZVN0cmluZyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9kaXNwbGF5X3V0aWxzLlBERkRhdGVTdHJpbmc7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJQREZXb3JrZXIiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfYXBpLlBERldvcmtlcjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIlBhc3N3b3JkUmVzcG9uc2VzIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuUGFzc3dvcmRSZXNwb25zZXM7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJQZXJtaXNzaW9uRmxhZyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLlBlcm1pc3Npb25GbGFnOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiUGl4ZWxzUGVySW5jaCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9kaXNwbGF5X3V0aWxzLlBpeGVsc1BlckluY2g7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJSZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb24iLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5SZW5kZXJpbmdDYW5jZWxsZWRFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJTVkdHcmFwaGljcyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9zdmcuU1ZHR3JhcGhpY3M7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJVbmV4cGVjdGVkUmVzcG9uc2VFeGNlcHRpb24iLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfdXRpbC5VbmV4cGVjdGVkUmVzcG9uc2VFeGNlcHRpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJVdGlsIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuVXRpbDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIlZlcmJvc2l0eUxldmVsIiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX3V0aWwuVmVyYm9zaXR5TGV2ZWw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJYZmFMYXllciIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF94ZmFfbGF5ZXIuWGZhTGF5ZXI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJidWlsZCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9hcGkuYnVpbGQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJjcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5OwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9KSk7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiY3JlYXRlVmFsaWRBYnNvbHV0ZVVybCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLmNyZWF0ZVZhbGlkQWJzb2x1dGVVcmw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJnZXREb2N1bWVudCIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9hcGkuZ2V0RG9jdW1lbnQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJnZXRGaWxlbmFtZUZyb21VcmwiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5nZXRGaWxlbmFtZUZyb21Vcmw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJnZXRQZGZGaWxlbmFtZUZyb21VcmwiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5nZXRQZGZGaWxlbmFtZUZyb21Vcmw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJnZXRYZmFQYWdlVmlld3BvcnQiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5nZXRYZmFQYWdlVmlld3BvcnQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJpc0RhdGFTY2hlbWUiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5pc0RhdGFTY2hlbWU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJpc1BkZkZpbGUiLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfZGlzcGxheV91dGlscy5pc1BkZkZpbGU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJsb2FkU2NyaXB0IiwgKHsKICAgICAgICAgICAgICAgIGVudW1lcmFibGU6IHRydWUsCiAgICAgICAgICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgICByZXR1cm4gX2Rpc3BsYXlfdXRpbHMubG9hZFNjcmlwdDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInJlbmRlclRleHRMYXllciIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF90ZXh0X2xheWVyLnJlbmRlclRleHRMYXllcjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInNldExheWVyRGltZW5zaW9ucyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF9kaXNwbGF5X3V0aWxzLnNldExheWVyRGltZW5zaW9uczsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInNoYWRvdyIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF91dGlsLnNoYWRvdzsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInVwZGF0ZVRleHRMYXllciIsICh7CiAgICAgICAgICAgICAgICBlbnVtZXJhYmxlOiB0cnVlLAogICAgICAgICAgICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIF90ZXh0X2xheWVyLnVwZGF0ZVRleHRMYXllcjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSkpOwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgInZlcnNpb24iLCAoewogICAgICAgICAgICAgICAgZW51bWVyYWJsZTogdHJ1ZSwKICAgICAgICAgICAgICAgIGdldDogZnVuY3Rpb24gKCkgewogICAgICAgICAgICAgICAgICAgIHJldHVybiBfYXBpLnZlcnNpb247CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgdmFyIF91dGlsID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKICAgICAgICAgICAgdmFyIF9hcGkgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDEzOCk7CiAgICAgICAgICAgIHZhciBfZGlzcGxheV91dGlscyA9IF9fd19wZGZqc19yZXF1aXJlX18oMTQyKTsKICAgICAgICAgICAgdmFyIF90ZXh0X2xheWVyID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjEpOwogICAgICAgICAgICB2YXIgX2Fubm90YXRpb25fZWRpdG9yX2xheWVyID0gX193X3BkZmpzX3JlcXVpcmVfXygxNjIpOwogICAgICAgICAgICB2YXIgX3Rvb2xzID0gX193X3BkZmpzX3JlcXVpcmVfXygxNDEpOwogICAgICAgICAgICB2YXIgX2Fubm90YXRpb25fbGF5ZXIgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE2Nyk7CiAgICAgICAgICAgIHZhciBfd29ya2VyX29wdGlvbnMgPSBfX3dfcGRmanNfcmVxdWlyZV9fKDE0OSk7CiAgICAgICAgICAgIHZhciBfc3ZnID0gX193X3BkZmpzX3JlcXVpcmVfXygxNzApOwogICAgICAgICAgICB2YXIgX3hmYV9sYXllciA9IF9fd19wZGZqc19yZXF1aXJlX18oMTY5KTsKICAgICAgICAgICAgY29uc3QgcGRmanNWZXJzaW9uID0gJzMuNS4xMjInOwogICAgICAgICAgICBjb25zdCBwZGZqc0J1aWxkID0gJzYyMjQ2NWRjMic7CiAgICAgICAgfSkoKTsKCiAgICAgICAgLyoqKioqKi8gCXJldHVybiBfX3dlYnBhY2tfZXhwb3J0c19fOwogICAgICAgIC8qKioqKiovIH0pKCkKICAgICA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lQ2h1bmtTaXplLAogICAgICAgIGxlbmd0aCwKICAgICAgICBkb2NCYXNlVXJsLAogICAgICAgIGVuYWJsZVhmYSwKICAgICAgICBldmFsdWF0b3JPcHRpb25zCiAgICAgIH0gPSBfcmVmOwogICAgICBjb25zdCBwZGZNYW5hZ2VyQXJncyA9IHsKICAgICAgICBzb3VyY2U6IG51bGwsCiAgICAgICAgZGlzYWJsZUF1dG9GZXRjaCwKICAgICAgICBkb2NCYXNlVXJsLAogICAgICAgIGRvY0lkLAogICAgICAgIGVuYWJsZVhmYSwKICAgICAgICBldmFsdWF0b3JPcHRpb25zLAogICAgICAgIGhhbmRsZXIsCiAgICAgICAgbGVuZ3RoLAogICAgICAgIHBhc3N3b3JkLAogICAgICAgIHJhbmdlQ2h1bmtTaXplCiAgICAgIH07CiAgICAgIGNvbnN0IHBkZk1hbmFnZXJDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICBsZXQgbmV3UGRmTWFuYWdlcjsKICAgICAgaWYgKGRhdGEpIHsKICAgICAgICB0cnkgewogICAgICAgICAgcGRmTWFuYWdlckFyZ3Muc291cmNlID0gZGF0YTsKICAgICAgICAgIG5ld1BkZk1hbmFnZXIgPSBuZXcgX3BkZl9tYW5hZ2VyLkxvY2FsUGRmTWFuYWdlcihwZGZNYW5hZ2VyQXJncyk7CiAgICAgICAgICBwZGZNYW5hZ2VyQ2FwYWJpbGl0eS5yZXNvbHZlKG5ld1BkZk1hbmFnZXIpOwogICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICBwZGZNYW5hZ2VyQ2FwYWJpbGl0eS5yZWplY3QoZXgpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gcGRmTWFuYWdlckNhcGFiaWxpdHkucHJvbWlzZTsKICAgICAgfQogICAgICBsZXQgcGRmU3RyZWFtLAogICAgICAgIGNhY2hlZENodW5rcyA9IFtdOwogICAgICB0cnkgewogICAgICA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B7CiAgICAgICAgICAgIHZhbHVlLAogICAgICAgICAgICBkb25lCiAgICAgICAgICB9ID0gX3JlZjI7CiAgICAgICAgICB0cnkgewogICAgICAgICAgICBlbnN1cmVOb3RUZXJtaW5hdGVkKCk7CiAgICAgICAgICAgIGlmIChkb25lKSB7CiAgICAgICAgICAgICAgaWYgKCFuZXdQZGZNYW5hZ2VyKSB7CiAgICAgICAgICAgICAgICBmbHVzaENodW5rcygpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjYW5jZWxYSFJzID0gbnVsbDsKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbG9hZGVkICs9IHZhbHVlLmJ5dGVMZW5ndGg7CiAgICAgICAgICAgIGlmICghZnVsbFJlcXVlc3QuaXNTdHJlYW1pbmdTdXBwb3J0ZWQpIHsKICAgICAgICAgICAgICBoYW5kbGVyLnNlbmQoIkRvY1Byb2dyZXNzIiwgewogICAgICAgICAgICAgICAgbG9hZGVkLAogICAgICAgICAgICAgICAgdG90YWw6IE1hdGgubWF4KGxvYWRlZCwgZnVsbFJlcXVlc3QuY29udGVudExlbmd0aCB8fCAwKQogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChuZXdQZGZNYW5hZ2VyKSB7CiAgICAgICAgICAgICAgbmV3UGRmTWFuYWdlci5zZW5kUHJvZ3Jlc3NpdmVEYXRhKHZhbHVlKTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjYWNoZWRDaHVua3MucHVzaCh2YWx1ZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZnVsbFJlcXVlc3QucmVhZCgpLnRoZW4ocmVhZENodW5rLCByZWplY3QpOwogICAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgICByZWplY3QoZSk7CiAgICAgICAgICB9CiAgICAgICAgfTsKICAgICAgICBmdWxsUmVxdWVzdC5yZWFkKCkudGhlbihyZWFkQ2h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ZmEpKSB7CiAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSB4ZmEubGVuZ3RoOyBpIDwgaWk7IGkgKz0gMikgewogICAgICAgICAgICBpZiAoeGZhW2ldID09PSAiZGF0YXNldHMiKSB7CiAgICAgICAgICAgICAgeGZhRGF0YXNldHNSZWYgPSB4ZmFbaSArIDFdOwogICAgICAgICAgICAgIGhhc1hmYURhdGFzZXRzRW50cnkgPSB0cnVlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoeGZhRGF0YXNldHNSZWYgPT09IG51bGwpIHsKICAgICAgICAgICAgeGZhRGF0YXNldHNSZWYgPSB4cmVmLmdldE5ld1RlbXBvcmFyeVJlZigpOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoeGZhKSB7CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlVuc3VwcG9ydGVkIFhGQSB0eXBlLiIpOwogICAgICAgIH0KICAgICAgICBsZXQgbmV3WHJlZkluZm8gPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgIGlmICh4cmVmLnRyYWlsZXIpIHsKICAgICAgICAgIGNvbnN0IGluZm9PYmogPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICAgICAgY29uc3QgeHJlZkluZm8gPSB4cmVmLnRyYWlsZXIuZ2V0KCJJbmZvIikgfHwgbnVsbDsKICAgICAgICAgIGlmICh4cmVmSW5mbyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgICAgICAgeHJlZkluZm8uZm9yRWFjaCgoa2V5LCB2YWx1ZSkgPT4gewogICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICBpbmZvT2JqW2tleV0gPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHZhbHVlKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQogICAgICAgICAgY29uc3QgbGFzdFhSZWZTdHJlYW1Qb3MgPSB4cmVmLmxhc3RYUmVmU3RyZWFtUG9zOwogICAgICAgICAgbmV3WHJlZkluZm8gPSB7CiAgICAgICAgICAgIHJvb3RSZWY6IHhyZWYudHJhaWxlci5nZXRSYXcoIlJvb3QiKSB8fCBudWxsLAogICAgICAgICAgICBlbmNyeXB0UmVmOiB4cmVmLnRyYWlsZXIuZ2V0UmF3KCJFbmNyeXB0IikgfHwgbnVsbCwKICAgICAgICAgICAgbmV3UmVmOiB4cmVmLmdldE5ld1RlbXBvcmFyeVJlZigpLAogICAgICAgICAgICBpbmZvUmVmOiB4cmVmLnRyYWlsZXIuZ2V0UmF3KCJJbmZvIikgfHwgbnVsbCwKICAgICAgICAgICAgaW5mbzogaW5mb09iaiwKICAgICAgICAgICAgZmlsZUlkczogeHJlZi50cmFpbGVyLmdldCgiSUQiKSB8fCBudWxsLAogICAgICAgICAgICBzdGFydFhSZWY6IGxhc3RYUmVmU3RyZWFtUG9zID09PSBudWxsID8gc3RhcnRYUmVmIDogbGFzdFhSZWZTdHJlYW1Qb3MsCiAgICAgICAgICAgIGZpbGVuYW1lCiAgICAgICAgICB9OwogICAgICAgIH0KICAgICAgICB0cnkgewogICAgICAgICAgcmV0dXJuICgwLCBfd3JpdGVyLmluY3JlbWVudGFsVXBkYXRlKSh7CiAgICAgICAgICAgIG9yaWdpbmFsRGF0YTogc3RyZWFtLmJ5dGVzLAogICAgICAgICAgICB4cmVmSW5mbzogbmV3WHJlZkluZm8sCiAgICAgICAgICAgIG5ld1JlZnMsCiAgICAgICAgICAgIHhyZWYsCiAgICAgICAgICAgIGhhc1hmYTogISF4ZmEsCiAgICAgICAgICAgIHhmYURhdGFzZXRzUmVmLAogICAgICAgICAgICBoYXNYZmFEYXRhc2V0c0VudHJ5LAogICAgICAgICAgICBuZWVkQXBwZWFyYW5jZXMsCiAgICAgICAgICAgIGFjcm9Gb3JtUmVmLAogICAgICAgICAgICBhY3JvRm9ybSwKICAgICAgICAgICAgeGZhRGF0YQogICAgICAgICAgfSk7CiAgICAgICAgfSBmaW5hbGx5IHsKICAgICAgICAgIHhyZWYucmVzZXROZXdUZW1wb3JhcnlSZWYoKTsKICAgICAgICB9CiAgICAgIH0pOwogICAgfSk7CiAgICBoYW5kbGVyLm9uKCJHZXRPcGVyYXRvckxpc3QiLCBmdW5jdGlvbiAoZGF0YSwgc2luaykgewogICAgICBjb25zdCBwYWdlSW5kZXggPSBkYXRhLnBhZ2VJbmRleDsKICAgICAgcGRmTWFuYWdlci5nZXRQYWdlKHBhZ2VJbmRleCkudGhlbihmdW5jdGlvbiAocGFnZSkgewogICAgICAgIGNvbnN0IHRhc2sgPSBuZXcgV29ya2VyVGFzayhgR2V0T3BlcmF0b3JMaXN0OiBwYWdlICR7cGFnZUluZGV4fWApOwogICAgICAgIHN0YXJ0V29ya2VyVGFzayh0YXNrKTsKICAgICAgICBjb25zdCBzdGFydCA9IHZlcmJvc2l0eSA+PSBfdXRpbC5WZXJib3NpdHlMZXZlbC5JTkZPUyA/IERhdGUubm93KCkgOiAwOwogICAgICAgIHBhZ2UuZ2V0T3BlcmF0b3JMaXN0KHsKICAgICAgICAgIGhhbmRsZXIsCiAgICAgICAgICBzaW5rLAogICAgICAgICAgdGFzaywKICAgICAgICAgIGludGVudDogZGF0YS5pbnRlbnQsCiAgICAgICAgICBjYWNoZUtleTogZGF0YS5jYWNoZUtleSwKICAgICAgICAgIGFubm90YXRpb25TdG9yYWdlOiBkYXRhLmFubm90YXRpb25TdG9yYWdlCiAgICAgICAgfSkudGhlbihmdW5jdGlvbiAob3BlcmF0b3JMaXN0SW5mbykgewogICAgICAgICAgZmluaXNoV29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgIGlmIChzdGFydCkgewogICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoYHBhZ2U9JHtwYWdlSW5kZXggKyAxfSAtIGdldE9wZXJhdG9yTGlzdDogdGltZT1gICsgYCR7RGF0ZS5ub3coKSAtIHN0YXJ0fW1zLCBsZW49JHtvcGVyYXRvckxpc3RJbmZvLmxlbmd0aH1gKTsKICAgICAgICAgIH0KICAgICAgICAgIHNpbmsuY2xvc2UoKTsKICAgICAgICB9LCBmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICBmaW5pc2hXb3JrZXJUYXNrKHRhc2spOwogICAgICAgICAgaWYgKHRhc2sudGVybWluYXRlZCkgewogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICB9CiAgICAgICAgICBzaW5rLmVycm9yKHJlYXNvbik7CiAgICAgICAgfSk7CiAgICAgIH0pOwogICAgfSk7CiAgICBoYW5kbGVyLm9uKCJHZXRUZXh0Q29udGVudCIsIGZ1bmN0aW9uIChkYXRhLCBzaW5rKSB7CiAgICAgIGNvbnN0IHBhZ2VJbmRleCA9IGRhdGEucGFnZUluZGV4OwogICAgICBwZGZNYW5hZ2VyLmdldFBhZ2UocGFnZUluZGV4KS50aGVuKGZ1bmN0aW9uIChwYWdlKSB7CiAgICAgICAgY29uc3QgdGFzayA9IG5ldyBXb3JrZXJUYXNrKCJHZXRUZXh0Q29udGVudDogcGFnZSAiICsgcGFnZUluZGV4KTsKICAgICAgICBzdGFydFdvcmtlclRhc2sodGFzayk7CiAgICAgICAgY29uc3Qgc3RhcnQgPSB2ZXJib3NpdHkgPj0gX3V0aWwuVmVyYm9zaXR5TGV2ZWwuSU5GT1MgPyBEYXRlLm5vdygpIDogMDsKICAgICAgICBwYWdlLmV4dHJhY3RUZXh0Q29udGVudCh7CiAgICAgICAgICBoYW5kbGVyLAogICAgICAgICAgdGFzaywKICAgICAgICAgIHNpbmssCiAgICAgICAgICBpbmNsdWRlTWFya2VkQ29udGVudDogZGF0YS5pbmNsdWRlTWFya2VkQ29udGVudCwKICAgICAgICAgIGNvbWJpbmVUZXh0SXRlbXM6IGRhdGEuY29tYmluZVRleHRJdGVtcwogICAgICAgIH0pLnRoZW4oZnVuY3Rpb24gKCkgewogICAgICAgICAgZmluaXNoV29ya2VyVGFzayh0YXNrKTsKICAgICAgICAgIGlmIChzdGFydCkgewogICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoYHBhZ2U9JHtwYWdlSW5kZXggKyAxfSAtIGdldFRleHRDb250ZW50OiB0aW1lPWAgKyBgJHtEYXRlLm5vdygpIC0gc3RhcnR9bXNgKTsKICAgICAgICAgIH0KICAgICAgICAgIHNpbmsuY2xvc2UoKTsKICAgICAgICB9LCBmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICBmaW5pc2hXb3JrZXJUYXNrKHRhc2spOwogICAgICAgICAgaWYgKHRhc2sudGVybWluYXRlZCkgewogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICB9CiAgICAgICAgICBzaW5rLmVycm9yKHJlYXNvbik7CiAgICAgICAgfSk7CiAgICAgIH0pOwogICAgfSk7CiAgICBoYW5kbGVyLm9uKCJHZXRTdHJ1Y3RUcmVlIiwgZnVuY3Rpb24gKGRhdGEpIHsKICAgICAgcmV0dXJuIHBkZk1hbmFnZXIuZ2V0UGFnZShkYXRhLnBhZ2VJbmRleCkudGhlbihmdW5jdGlvbiAocGFnZSkgewogICAgICAgIHJldHVybiBwZGZNYW5hZ2VyLmVuc3VyZShwYWdlLCAiZ2V0U3RydWN0VHJlZSIpOwogICAgICB9KTsKICAgIH0pOwogICAgaGFuZGxlci5vbigiRm9udEZhbGxiYWNrIiwgZnVuY3Rpb24gKGRhdGEpIHsKICAgICAgcmV0dXJuIHBkZk1hbmFnZXIuZm9udEZhbGxiYWNrKGRhdGEuaWQsIGhhbmRsZXIpOwogICAgfSk7CiAgICBoYW5kbGVyLm9uKCJDbGVhbnVwIiwgZnVuY3Rpb24gKGRhdGEpIHsKICAgICAgcmV0dXJuIHBkZk1hbmFnZXIuY2xlYW51cCh0cnVlKTsKICAgIH0pOwogICAgaGFuZGxlci5vbigiVGVybWluYXRlIiwgZnVuY3Rpb24gKGRhdGEpIHsKICAgICAgdGVybWluYXRlZCA9IHRyd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d1bWVudHMubGVuZ3RoID4gMiAmJiBhcmd1bWVudHNbMl0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1syXSA6IG51bGw7CiAgaWYgKCF1cmwpIHsKICAgIHJldHVybiBudWxsOwogIH0KICB0cnkgewogICAgaWYgKG9wdGlvbnMgJiYgdHlwZW9mIHVybCA9PT0gInN0cmluZyIpIHsKICAgICAgaWYgKG9wdGlvbnMuYWRkRGVmYXVsdFByb3RvY29sICYmIHVybC5zdGFydHNXaXRoKCJ3d3cuIikpIHsKICAgICAgICBjb25zdCBkb3RzID0gdXJsLm1hdGNoKC9cLi9nKTsKICAgICAgICBpZiAoZG90cyAmJiBkb3RzLmxlbmd0aCA+PSAyKSB7CiAgICAgICAgICB1cmwgPSBgaHR0cDovLyR7dXJsfWA7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChvcHRpb25zLnRyeUNvbnZlcnRFbmNvZGluZykgewogICAgICAgIHRyeSB7CiAgICAgICAgICB1cmwgPSBzdHJpbmdUb1VURjhTdHJpbmcodXJsKTsKICAgICAgICB9IGNhdGNoIChleCkge30KICAgICAgfQogICAgfQogICAgY29uc3QgYWJzb2x1dGVVcmwgPSBiYXNlVXJsID8gbmV3IFVSTCh1cmwsIGJhc2VVcmwpIDogbmV3IFVSTCh1cmwpOwogICAgaWYgKF9pc1ZhbGlkUHJvdG9jb2woYWJzb2x1dGVVcmwpKSB7CiAgICAgIHJldHVybiBhYnNvbHV0ZVVybDsKICAgIH0KICB9IGNhdGNoIChleCkge30KICByZXR1cm4gbnVsbDsKfQpmdW5jdGlvbiBzaGFkb3cob2JqLCBwcm9wLCB2YWx1ZSkgewogIGxldCBub25TZXJpYWxpemFibGUgPSBhcmd1bWVudHMubGVuZ3RoID4gMyAmJiBhcmd1bWVudHNbM10gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1szXSA6IGZhbHNlOwogIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShvYmosIHByb3AsIHsKICAgIH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MgPSAzICogeDEgLSAzICogeDA7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgYiA9IDYgKiB5MCAtIDEyICogeTEgKyA2ICogeTI7CiAgICAgICAgYSA9IC0zICogeTAgKyA5ICogeTEgLSA5ICogeTIgKyAzICogeTM7CiAgICAgICAgYyA9IDMgKiB5MSAtIDMgKiB5MDsKICAgICAgfQogICAgICBpZiAoTWF0aC5hYnMoYSkgPCAxZS0xMikgewogICAgICAgIGlmIChNYXRoLmFicyhiKSA8IDFlLTEyKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgdCA9IC1jIC8gYjsKICAgICAgICBpZiAoMCA8IHQgJiYgdCA8IDEpIHsKICAgICAgICAgIHR2YWx1ZXMucHVzaCh0KTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgYjJhYyA9IGIgKiBiIC0gNCAqIGMgKiBhOwogICAgICBzcXJ0YjJhYyA9IE1hdGguc3FydChiMmFjKTsKICAgICAgaWYgKGIyYWMgPCAwKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdDEgPSAoLWIgKyBzcXJ0YjJhYykgLyAoMiAqIGEpOwogICAgICBpZiAoMCA8IHQxICYmIHQxIDwgMSkgewogICAgICAgIHR2YWx1ZXMucHVzaCh0MSk7CiAgICAgIH0KICAgICAgdDIgPSAoLWIgLSBzcXJ0YjJhYykgLyAoMiAqIGEpOwogICAgICBpZiAoMCA8IHQyICYmIHQyIDwgMSkgewogICAgICAgIHR2YWx1ZXMucHVzaCh0Mik7CiAgICAgIH0KICAgIH0KICAgIGxldCBqID0gdHZhbHVlcy5sZW5ndGgsCiAgICAgIG10OwogICAgY29uc3QgamxlbiA9IGo7CiAgICB3aGlsZSAoai0tKSB7CiAgICAgIHQgPSB0dmFsdWVzW2pdOwogICAgICBtdCA9IDEgLSB0OwogICAgICBib3VuZHNbMF1bal0gPSBtdCAqIG10ICogbXQgKiB4MCArIDMgKiBtdC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NldChrZXksIHByb3BlcnR5KTsKICAgICAgICB9IGVsc2UgaWYgKCFtZXJnZVN1YkRpY3RzIHx8ICEodmFsdWUgaW5zdGFuY2VvZiBEaWN0KSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIHByb3BlcnR5LnB1c2godmFsdWUpOwogICAgICB9CiAgICB9CiAgICBmb3IgKGNvbnN0IFtuYW1lLCB2YWx1ZXNdIG9mIHByb3BlcnRpZXMpIHsKICAgICAgaWYgKHZhbHVlcy5sZW5ndGggPT09IDEgfHwgISh2YWx1ZXNbMF0gaW5zdGFuY2VvZiBEaWN0KSkgewogICAgICAgIG1lcmdlZERpY3QuX21hcFtuYW1lXSA9IHZhbHVlc1swXTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBzdWJEaWN0ID0gbmV3IERpY3QoeHJlZik7CiAgICAgIGZvciAoY29uc3QgZGljdCBvZiB2YWx1ZXMpIHsKICAgICAgICBmb3IgKGNvbnN0IFtrZXksIHZhbHVlXSBvZiBPYmplY3QuZW50cmllcyhkaWN0Ll9tYXApKSB7CiAgICAgICAgICBpZiAoc3ViRGljdC5fbWFwW2tleV0gPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICBzdWJEaWN0Ll9tYXBba2V5XSA9IHZhbHVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoc3ViRGljdC5zaXplID4gMCkgewogICAgICAgIG1lcmdlZERpY3QuX21hcFtuYW1lXSA9IHN1YkRpY3Q7CiAgICAgIH0KICAgIH0KICAgIHByb3BlcnRpZXMuY2xlYXIoKTsKICAgIHJldHVybiBtZXJnZWREaWN0LnNpemUgPiAwID8gbWVyZ2VkRGljdCA6IERpY3QuZW1wdHk7CiAgfQp9CmV4cG9ydHMuRGljdCA9IERpY3Q7CmNvbnN0IFJlZiA9IGZ1bmN0aW9uIFJlZkNsb3N1cmUoKSB7CiAgbGV0IHJlZkNhY2hlID0gT2JqZWN0Lm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ICAgICAgdGhpcy5vblByb2dyZXNzKHsKICAgICAgICAgICAgICBsb2FkZWQKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9CiAgICAgICAgICBjaHVua3MucHVzaCh2YWx1ZSk7CiAgICAgICAgICByYW5nZVJlYWRlci5yZWFkKCkudGhlbihyZWFkQ2h1bmssIHJlamVjdCk7CiAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgcmVqZWN0KGUpOwogICAgICAgIH0KICAgICAgfTsKICAgICAgcmFuZ2VSZWFkZXIucmVhZCgpLnRoZW4ocmVhZENodW5rLCByZWplY3QpOwogICAgfSkudGhlbihkYXRhID0+IHsKICAgICAgaWYgKHRoaXMuYWJvcnRlZCkgewogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICB0aGlzLm9uUmVjZWl2ZURhdGEoewogICAgICAgIGNodW5rOiBkYXRhLAogICAgICAgIGJlZ2luCiAgICAgIH0pOwogICAgfSk7CiAgfQogIHJlcXVlc3RBbGxDaHVua3MoKSB7CiAgICBsZXQgbm9GZXRjaCA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogZmFsc2U7CiAgICBpZiAoIW5vRmV0Y2gpIHsKICAgICAgY29uc3QgbWlzc2luZ0NodW5rcyA9IHRoaXMuc3RyZWFtLmdldE1pc3NpbmdDaHVua3MoKTsKICAgICAgdGhpcy5fcmVxdWVzdENodW5rcyhtaXNzaW5nQ2h1bmtzKTsKICAgIH0KICAgIHJldHVybiB0aGlzLl9sb2FkZWRTdHJlYW1DYXBhYmlsaXR5LnByb21pc2U7CiAgfQogIF9yZXF1ZXN0Q2h1bmtzKGNodW5rcykgewogICAgY29uc3QgcmVxdWVzdElkID0gdGhpcy5jdXJyUmVxdWVzdElkKys7CiAgICBjb25zdCBjaHVua3NOZWVkZWQgPSBuZXcgU2V0KCk7CiAgICB0aGlzLl9jaHVua3NOZWVkZWRCe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ZWQgPyBhcmd1bWVudHNbMF0gOiBbXTsKICAgIGNvbnN0IGNodW5rc1RvUmVxdWVzdCA9IFtdOwogICAgZm9yIChjb25zdCByYW5nZSBvZiByYW5nZXMpIHsKICAgICAgY29uc3QgYmVnaW5DaHVuayA9IHRoaXMuZ2V0QmVnaW5DaHVuayhyYW5nZS5iZWdpbik7CiAgICAgIGNvbnN0IGVuZENodW5rID0gdGhpcy5nZXRFbmRDaHVuayhyYW5nZS5lbmQpOwogICAgICBmb3IgKGxldCBjaHVuayA9IGJlZ2luQ2h1bms7IGNodW5rIDwgZW5kQ2h1bms7ICsrY2h1bmspIHsKICAgICAgICBpZiAoIWNodW5rc1RvUmVxdWVzdC5pbmNsdWRlcyhjaHVuaykpIHsKICAgICAgICAgIGNodW5rc1RvUmVxdWVzdC5wdXNoKGNodW5rKTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGNodW5rc1RvUmVxdWVzdC5zb3J0KGZ1bmN0aW9uIChhLCBiKSB7CiAgICAgIHJldHVybiBhIC0gYjsKICAgIH0pOwogICAgcmV0dXJuIHRoaXMuX3JlcXVlc3RDaHVua3MoY2h1bmtzVG9SZXF1ZXN0KTsKICB9CiAgZ3JvdXBDaHVua3MoY2h1bmtzKSB7CiAgICBjb25zdCBncm91cGVkQ2h1bmtzID0gW107CiAgICBsZXQgYmVnaW5DaHVuayA9IC0xOwogICAgbGV0IHByZXZDaHVuayA9IC0xOwogICAgZm9yIChsZXQgaSA9IDAsIGlpID0gY2h1bmtzLmxlbmd0aDsgaSA8IGlpOyArK2kpIHsKICAgICAgY29uc3QgY2h1bmsgPSBjaHVua3NbaV07CiAgICAgIGlmIChiZWdpbkNodW5rIDwgMCkgewogICAgICAgIGJlZ2luQ2h1bmsgPSBjaHVuazsKICAgICAgfQogICAgICBpZiAocHJldkNodW5rID49IDAgJiYgcHJldkNodW5rICsgMSAhPT0gY2h1bmspIHsKICAgICAgICBncm91cGVkQ2h1bmtzLnB1c2goewogICAgICAgICA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Bib3gubGVuZ3RoID09PSA0KSB7CiAgICAgIGJveCA9IF91dGlsLlV0aWwubm9ybWFsaXplUmVjdChib3gpOwogICAgICBpZiAoYm94WzJdIC0gYm94WzBdID4gMCAmJiBib3hbM10gLSBib3hbMV0gPiAwKSB7CiAgICAgICAgcmV0dXJuIGJveDsKICAgICAgfQogICAgICAoMCwgX3V0aWwud2FybikoYEVtcHR5LCBvciBpbnZhbGlkLCAvJHtuYW1lfSBlbnRyeS5gKTsKICAgIH0KICAgIHJldHVybiBudWxsOwogIH0KICBnZXQgbWVkaWFCb3goKSB7CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIm1lZGlhQm94IiwgdGhpcy5fZ2V0Qm91bmRpbmdCb3goIk1lZGlhQm94IikgfHwgTEVUVEVSX1NJWkVfTUVESUFCT1gpOwogIH0KICBnZXQgY3JvcEJveCgpIHsKICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAiY3JvcEJveCIsIHRoaXMuX2dldEJvdW5kaW5nQm94KCJDcm9wQm94IikgfHwgdGhpcy5tZWRpYUJveCk7CiAgfQogIGdldCB1c2VyVW5pdCgpIHsKICAgIGxldCBvYmogPSB0aGlzLnBhZ2VEaWN0LmdldCgiVXNlclVuaXQiKTsKICAgIGlmICh0eXBlb2Ygb2JqICE9PSAibnVtYmVyIiB8fCBvYmogPD0gMCkgewogICAgICBvYmogPSBERUZBVUxUX1VTRVJfVU5JVDsKICAgIH0KICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAidXNlclVuaXQiLCBvYmopOwogIH0KICBnZXQgdmlldygpIHsKICAgIGNvbnN0IHsKICAgICAgY3JvcEJveCwKICAgICAgbWVkaWFCb3gKICAgIH0gPSB0aGlzOwogICAgaWYgKGNyb3BCb3ggIT09IG1lZGlhQm94ICYmICEoMCwgX3V0aWwuaXNBcnJheUVxdWFsKShjcm9wQm94LCBtZWRpYUJveCkpIHsKICAgICAgY29uc3Q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Y29uc3QgbmV3UmVmc1Byb21pc2VzID0gW107CiAgICAgIGZvciAoY29uc3QgYW5ub3RhdGlvbiBvZiBhbm5vdGF0aW9ucykgewogICAgICAgIGlmICghYW5ub3RhdGlvbi5tdXN0QmVQcmludGVkKGFubm90YXRpb25TdG9yYWdlKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIG5ld1JlZnNQcm9taXNlcy5wdXNoKGFubm90YXRpb24uc2F2ZShwYXJ0aWFsRXZhbHVhdG9yLCB0YXNrLCBhbm5vdGF0aW9uU3RvcmFnZSkuY2F0Y2goZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJzYXZlIC0gaWdub3JpbmcgYW5ub3RhdGlvbiBkYXRhIGR1cmluZyAiICsgYCIke3Rhc2submFtZX0iIHRhc2s6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfSkpOwogICAgICB9CiAgICAgIHJldHVybiBQcm9taXNlLmFsbChuZXdSZWZzUHJvbWlzZXMpLnRoZW4oZnVuY3Rpb24gKG5ld1JlZnMpIHsKICAgICAgICByZXR1cm4gbmV3UmVmcy5maWx0ZXIobmV3UmVmID0+ICEhbmV3UmVmKTsKICAgICAgfSk7CiAgICB9KTsKICB9CiAgbG9hZFJlc291cmNlcyhrZXlzKSB7CiAgICBpZiAoIXRoaXMucmVzb3VyY2VzUHJvbWlzZSkgewogICAgICB0aGlzLnJlc291cmNlc1Byb21pc2UgPSB0aGlzLnBkZk1hbmFnZXIuZW5zdXJlKHRoaXMsICJyZXNvdXJjZXMiKTsKICAgIH0KICAgIHJldHVybiB0aGlzLnJlc291cmNlc1Byb21pc2UudGhlbigoKSA9PiB7CiAgICAgIGNvbnN0IG9iamVjdExvYWRlciA9IG5ldyBfb2JqZWN0X2xvYWRlci5PYmplY3RMb2FkZXIodGhpcy5yZXNvdXJjZXMsIGtleXMsIHRoaXMueHJlZik7CiAgIC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gIH0pOwogICAgICByZXR1cm4gcGFydGlhbEV2YWx1YXRvci5nZXRPcGVyYXRvckxpc3QoewogICAgICAgIHN0cmVhbTogY29udGVudFN0cmVhbSwKICAgICAgICB0YXNrLAogICAgICAgIHJlc291cmNlczogdGhpcy5yZXNvdXJjZXMsCiAgICAgICAgb3BlcmF0b3JMaXN0OiBvcExpc3QKICAgICAgfSkudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgcmV0dXJuIG9wTGlzdDsKICAgICAgfSk7CiAgICB9KTsKICAgIHJldHVybiBQcm9taXNlLmFsbChbcGFnZUxpc3RQcm9taXNlLCB0aGlzLl9wYXJzZWRBbm5vdGF0aW9ucywgbmV3QW5ub3RhdGlvbnNQcm9taXNlXSkudGhlbihmdW5jdGlvbiAoX3JlZjQpIHsKICAgICAgbGV0IFtwYWdlT3BMaXN0LCBhbm5vdGF0aW9ucywgbmV3QW5ub3RhdGlvbnNdID0gX3JlZjQ7CiAgICAgIGlmIChuZXdBbm5vdGF0aW9ucykgewogICAgICAgIGFubm90YXRpb25zID0gYW5ub3RhdGlvbnMuY29uY2F0KG5ld0Fubm90YXRpb25zKTsKICAgICAgfQogICAgICBpZiAoYW5ub3RhdGlvbnMubGVuZ3RoID09PSAwIHx8IGludGVudCAmIF91dGlsLlJlbmRlcmluZ0ludGVudEZsYWcuQU5OT1RBVElPTlNfRElTQUJMRSkgewogICAgICAgIHBhZ2VPcExpc3QuZmx1c2godHJ1ZSk7CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGxlbmd0aDogcGFnZU9wTGlzdC50b3RhbExlbmd0aAogICAgICAgIH07CiAgICAgIH0KICAgICAgY29uc3QgcmVuZGVyRm9ybXMgPSAhIShpbnRlbnQgJiBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLkFOTk9UQVRJT05TX0ZPUk1TKSwKICAgICAgICBpbnRlbnRBbnkgPSAhIShpbnRlbnQgJiBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLkFOWSksCiAgICAgICAgaW50ZW50RGlzcGxheSA9ICEhKGludGVudCAmIF91dGlsLlJlbmRlcmluZ0ludGVudEZsYWcuRElTUExBWSksCiAgICAgICAgaW50ZW50UHJpbnQgPSAhIShpbnRlbnQgJiBfdXRpbC5SZW5kZXJpbmdJbnRlbnRGbGFnLlBSSU5UKTsKICAgICAgY29uc3Qgb3BMaXN0UHJvbWlzZXMgPSBbXTsKICAgICAgZm9yIChjb25zdCBhbm5vdGF0aW9uIG9mIGFubm90YXRpb25zKSB7CiAgICAgICAgaWYgKGludGVudEFueSB8fCBpbnRlbnREaXNwbGF5ICYmIGFubm90YXRpb24ubXVzdEJlVmlld2VkKGFubm90YXRpb25TdG9yYWdlKSB8fCBpbnRlbnRQcmludCAmJiBhbm5vdGF0aW9uLm11c3RCZVByaW50ZWQoYW5ub3RhdGlvblN0b3JhZ2UpKSB7CiAgICAgICAgICBvcExpc3RQcm9taXNlcy5wdXNoKGFubm90YXRpb24uZ2V0T3BlcmF0b3JMaXN0KHBhcnRpYWxFdmFsdWF0b3IsIHRhc2ssIGludGVudCwgcmVuZGVyRm9ybXMsIGFubm90YXRpb25TdG9yYWdlKS5jYXRjaChmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiZ2V0T3BlcmF0b3JMaXN0IC0gaWdub3JpbmcgYW5ub3RhdGlvbiBkYXRhIGR1cmluZyAiICsgYCIke3Rhc2submFtZX0iIHRhc2s6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICByZXR1cm4gewogICAgICAgICAgICAgIG9wTGlzdDogbnVsbCwKICAgICAgICAgICAgICBzZXBhcmF0ZUZvcm06IGZhbHNlLAogICAgICAgICAgICAgIHNlcGFyYXRlQ2FudmFzOiBmYWxzZQogICAgICAgICAgICB9OwogICAgICAgICAgfSkpOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gUHJvbWlzZS5hbGwob3BMaXN0UHJvbWlzZXMpLnRoZW4oZnVuY3Rpb24gKG9wTGlzdHMpIHsKICAgICAgICBsZXQgZm9ybSA9IGZhbHNlLAogICAgICAgICAgY2FudmFzID0gZmFsc2U7CiAgICAgICAgZm9yIChjb25zdCB7CiAgICAgICAgICBvcExpc3QsCiAgICAgICAgICBzZXBhcmF0ZUZvcm0sCiAgICAgICAgICBzZXBhcmF0ZUNhbnZhcwogICAgICAgIH0gb2Ygb3BMaXN0cykgewogICAgICAgICAgcGFnZU9wTGlzdC5hZGRPcExpc3Qob3BMaXN0KTsKICAgICAgICAgIGlmIChzZXBhcmF0ZUZvcm0pIHsKICAgICAgICAgICAgZm9ybSA9IHNlcGFyYXRlRm9ybTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChzZXBhcmF0ZUNhbnZhcykgewogICAgICAgICAgICBjYW52YXMgPSBzZXBhcmF0ZUNhbnZhczsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcGFnZU9wTGlzdC5mbHVzaCh0cnVlLCB7CiAgICAgICAgICBmb3JtLAogICAgICAgICAgY2FudmFzCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGxlbmd0aDogcGFnZU9wTGlzdC50b3RhbExlbmd0aAogICAgICAgIH07CiAgICAgIH0pOwogICAgfSk7CiAgfQogIGV4dHJhY3RUZXh0Q29udGVudChfcmVmNSkgewogICAgbGV0IHsKICAgICAgaGFuZGxlciwKICAgICAgdGFzaywKICAgICAgaW5jbHVkZU1hcmtlZENvbnRlbnQsCiAgICAgIHNpbmssCiAgICAgIGNvbWJpbmVUZXh0SXRlbXMKICAgIH0gPSBfcmVmNTsKICAgIGNvbnN0IGNvbnRlbnRTdHJlYW1Qcm9taXNlID0gdGhpcy5nZXRDb250ZW50U3RyZWFtKCk7CiAgICBjb25zdCByZXNvdXJjZXNQcm9taXNlID0gdGhpcy5sb2FkUmVzb3VyY2VzKFsiRXh0R1N0YXRlIiwgIkZvbnQiLCAiUHJvcGVydGllcyIsICJYT2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ub3RhdGlvblJlZiwgdGhpcy5wZGZNYW5hZ2VyLCB0aGlzLl9sb2NhbElkRmFjdG9yeSwgZmFsc2UpLmNhdGNoKGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgX3BhcnNlZEFubm90YXRpb25zOiAiJHtyZWFzb259Ii5gKTsKICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgIH0pKTsKICAgICAgfQogICAgICByZXR1cm4gUHJvbWlzZS5hbGwoYW5ub3RhdGlvblByb21pc2VzKS50aGVuKGZ1bmN0aW9uIChhbm5vdGF0aW9ucykgewogICAgICAgIGlmIChhbm5vdGF0aW9ucy5sZW5ndGggPT09IDApIHsKICAgICAgICAgIHJldHVybiBhbm5vdGF0aW9uczsKICAgICAgICB9CiAgICAgICAgY29uc3Qgc29ydGVkQW5ub3RhdGlvbnMgPSBbXTsKICAgICAgICBsZXQgcG9wdXBBbm5vdGF0aW9uczsKICAgICAgICBmb3IgKGNvbnN0IGFubm90YXRpb24gb2YgYW5ub3RhdGlvbnMpIHsKICAgICAgICAgIGlmICghYW5ub3RhdGlvbikgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChhbm5vdGF0aW9uIGluc3RhbmNlb2YgX2Fubm90YXRpb24uUG9wdXBBbm5vdGF0aW9uKSB7CiAgICAgICAgICAgIGlmICghcG9wdXBBbm5vdGF0aW9ucykgewogICAgICAgICAgICAgIHBvcHVwQW5ub3RhdGlvbnMgPSBbXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBwb3B1cEFubm90YXRpb25zLnB1c2goYW5ub3RhdGlvbik7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgc29ydGVkQW5ub3RhdGlvbnMucHVzaChhbm5vdGF0aW9uKTsKICAgICAgICB9CiAgICAgICAgaWYgKHBvcHVwQW5ub3RhdGlvbnMpIHsKICAgICAgICAgIHNvcnRlZEFubm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mYTsKICAgICAgcmV0dXJuIGVudHJpZXM7CiAgICB9CiAgICBpZiAoIUFycmF5LmlzQXJyYXkoeGZhKSB8fCB4ZmEubGVuZ3RoID09PSAwKSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgZm9yIChsZXQgaSA9IDAsIGlpID0geGZhLmxlbmd0aDsgaSA8IGlpOyBpICs9IDIpIHsKICAgICAgbGV0IG5hbWU7CiAgICAgIGlmIChpID09PSAwKSB7CiAgICAgICAgbmFtZSA9ICJ4ZHA6eGRwIjsKICAgICAgfSBlbHNlIGlmIChpID09PSBpaSAtIDIpIHsKICAgICAgICBuYW1lID0gIi94ZHA6eGRwIjsKICAgICAgfSBlbHNlIHsKICAgICAgICBuYW1lID0geGZhW2ldOwogICAgICB9CiAgICAgIGlmICghZW50cmllcy5oYXNPd25Qcm9wZXJ0eShuYW1lKSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IGRhdGEgPSB0aGlzLnhyZWYuZmV0Y2hJZlJlZih4ZmFbaSArIDFdKTsKICAgICAgaWYgKCEoZGF0YSBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSB8fCBkYXRhLmlzRW1wdHkpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBlbnRyaWVzW25hbWVdID0gZGF0YTsKICAgIH0KICAgIHJldHVybiBlbnRyaWVzOwogIH0KICBnZXQgeGZhRGF0YXNldHMoKSB7CiAgICBjb25zdCBzdHJlYW1zID0gdGhpcy5feGZhU3RyZWFtczsKICAgIGlmICghc3RyZWFtcykgewogICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInhmYURhdGFzZXRzIiwgbnVsbCk7CiAgICB9CiAgICBmb3IgKGNvbnN0IGtleSBvZiBbImRhdGFzZXRzIiwgInhkcDp4ZHAiXSkgewogICAgICBjb25zdCBzdHJlYW0gPSBzdHJlYW1zW2tleV07CiAgICAgIGlmICghc3RyZWFtKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdHJ5IHsKICAgICAgICBjb25zdCBzdHIgPSAoMCwgX3V0aWwuc3RyaW5nVG9VVEY4U3RyaW5nKShzdHJlYW0uZ2V0U3RyaW5nKCkpOwogICAgICAgIGNvbnN0IGRhdGEgPSB7CiAgICAgICAgICBba2V5XTogc3RyCiAgICAgICAgfTsKICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInhmYURhdGFzZXRzIiwgbmV3IF9kYXRhc2V0X3JlYWRlci5EYXRhc2V0UmVhZGVyKGRhdGEpKTsKICAgICAgfSBjYXRjaCAoXykgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiWEZBIC0gSW52YWxpZCB1dGYtOCBzdHJpbmcuIik7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAieGZhRGF0YXNldHMiLCBudWxsKTsKICB9CiAgZ2V0IHhmYURhdGEoKSB7CiAgICBjb25zdCBzdHJlYW1zID0gdGhpcy5feGZhU3RyZWFtczsKICAgIGlmICghc3RyZWFtcykgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIGNvbnN0IGRhdGEgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgZm9yIChjb25zdCBba2V5LCBzdHJlYW1dIG9mIE9iamVjdC5lbnRyaWVzKHN0cmVhbXMpKSB7CiAgICAgIGlmICghc3RyZWFtKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdHJ5IHsKICAgICAgICBkYXRhW2tleV0gPSAoMCwgX3V0aWwuc3RyaW5nVG9VVEY4U3RyaW5nKShzdHJlYW0uZ2V0U3RyaW5nKCkpOwogICAgICB9IGNhdGNoIChfKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJYRkEgLSBJbnZhbGlkIHV0Zi04IHN0cmluZy4iKTsKICAgICAgICByZXR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nVsbCksIHRoaXMucGRmTWFuYWdlci5ldmFsdWF0b3JPcHRpb25zKTsKICAgIG9wdGlvbnMudXNlU3lzdGVtRm9udHMgPSBmYWxzZTsKICAgIGNvbnN0IHBhcnRpYWxFdmFsdWF0b3IgPSBuZXcgX2V2YWx1YXRvci5QYXJ0aWFsRXZhbHVhdG9yKHsKICAgICAgeHJlZjogdGhpcy54cmVmLAogICAgICBoYW5kbGVyLAogICAgICBwYWdlSW5kZXg6IC0xLAogICAgICBpZEZhY3Rvcnk6IHRoaXMuX2dsb2JhbElkRmFjdG9yeSwKICAgICAgZm9udENhY2hlOiB0aGlzLmNhdGFsb2cuZm9udENhY2hlLAogICAgICBidWlsdEluQ01hcENhY2hlOiB0aGlzLmNhdGFsb2cuYnVpbHRJbkNNYXBDYWNoZSwKICAgICAgc3RhbmRhcmRGb250RGF0YUNhY2hlOiB0aGlzLmNhdGFsb2cuc3RhbmRhcmRGb250RGF0YUNhY2hlLAogICAgICBvcHRpb25zCiAgICB9KTsKICAgIGNvbnN0IG9wZXJhdG9yTGlzdCA9IG5ldyBfb3BlcmF0b3JfbGlzdC5PcGVyYXRvckxpc3QoKTsKICAgIGNvbnN0IHBkZkZvbnRzID0gW107CiAgICBjb25zdCBpbml0aWFsU3RhdGUgPSB7CiAgICAgIGdldCBmb250KCkgewogICAgICAgIHJldHVybiBwZGZGb250cy5hdCgtMSk7CiAgICAgIH0sCiAgICAgIHNldCBmb250KGZvbnQpIHsKICAgICAgICBwZGZGb250cy5wdXNoKGZvbnQpOwogICAgICB9LAogICAgICBjbG9uZSgpIHsKICAgICAgICByZXR1cm4gdGhpczsKICAgICAgfQogICAgfTsKICAgIGNvbnN0IGZvbnRzID0gbmV3IE1hcCgpOwogICAgZm9udFJlcy5mb3JFYWNoKChmb250TmFtZSwgZm9udCkgPT4gewogICAgICBmb250cy5zZXQoZm9udE5hbWUsIGZvbnQpOwogICAgfSk7CiAgICBjb25zdCBwcm9taXNlcyA9IFtdOwogICAgZm9yICh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IH0pKTsKICAgIH0KICAgIGF3YWl0IFByb21pc2UuYWxsKHByb21pc2VzKTsKICAgIGNvbnN0IG1pc3NpbmdGb250cyA9IHRoaXMueGZhRmFjdG9yeS5zZXRGb250cyhwZGZGb250cyk7CiAgICBpZiAoIW1pc3NpbmdGb250cykgewogICAgICByZXR1cm47CiAgICB9CiAgICBvcHRpb25zLmlnbm9yZUVycm9ycyA9IHRydWU7CiAgICBwcm9taXNlcy5sZW5ndGggPSAwOwogICAgcGRmRm9udHMubGVuZ3RoID0gMDsKICAgIGNvbnN0IHJlYWxseU1pc3NpbmdGb250cyA9IG5ldyBTZXQoKTsKICAgIGZvciAoY29uc3QgbWlzc2luZyBvZiBtaXNzaW5nRm9udHMpIHsKICAgICAgaWYgKCEoMCwgX3hmYV9mb250cy5nZXRYZmFGb250TmFtZSkoYCR7bWlzc2luZ30tUmVndWxhcmApKSB7CiAgICAgICAgcmVhbGx5TWlzc2luZ0ZvbnRzLmFkZChtaXNzaW5nKTsKICAgICAgfQogICAgfQogICAgaWYgKHJlYWxseU1pc3NpbmdGb250cy5zaXplKSB7CiAgICAgIG1pc3NpbmdGb250cy5wdXNoKCJQZGZKUy1GYWxsYmFjayIpOwogICAgfQogICAgZm9yIChjb25zdCBtaXNzaW5nIG9mIG1pc3NpbmdGb250cykgewogICAgICBpZiAocmVhbGx5TWlzc2luZ0ZvbnRzLmhhcyhtaXNzaW5nKSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGZvciAoY29uc3QgZm9udEluZm8gb2YgW3sKICAgICAgICBuYW1lOiAiUmVndWxhciIsCiAgICAgICAgZm9udFdlaWdodDogNDAwLAogICAgICAgIGl0YWxpY0FuZ2xlOiAwCiAgICAgIH0sIHsKICAgICAgICBuYW1lOiAiQm9sZCIsCiAgICAgICAgZm9udFdlaWdodDogNzAwLAogICAgICAgIGl0YWxpY0FuZ2xlOiAwCiAgICAgIH0sIHsKICAgICAgICBuYW1lOiAiSXRhbGljIiwKICAg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gPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHZhbHVlKTsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJUcmFwcGVkIjoKICAgICAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgZG9jSW5mb1trZXldID0gdmFsdWU7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIGxldCBjdXN0b21WYWx1ZTsKICAgICAgICAgIHN3aXRjaCAodHlwZW9mIHZhbHVlKSB7CiAgICAgICAgICAgIGNhc2UgInN0cmluZyI6CiAgICAgICAgICAgICAgY3VzdG9tVmFsdWUgPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHZhbHVlKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAibnVtYmVyIjoKICAgICAgICAgICAgY2FzZSAiYm9vbGVhbiI6CiAgICAgICAgICAgICAgY3VzdG9tVmFsdWUgPSB2YWx1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgICBjdXN0b21WYWx1ZSA9IHZhbHVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChjdXN0b21WYWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgQmFkIHZhbHVlLCBmb3IgY3VzdG9tIGtleSAiJHtrZXl9IiwgaW4gSW5mbzogJHt2YWx1ZX0uYCk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogIC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oKICAgICAgICBsZXQgZmllbGRUeXBlID0gKDAsIF9jb3JlX3V0aWxzLmdldEluaGVyaXRhYmxlUHJvcGVydHkpKHsKICAgICAgICAgIGRpY3QsCiAgICAgICAgICBrZXk6ICJGVCIKICAgICAgICB9KTsKICAgICAgICBmaWVsZFR5cGUgPSBmaWVsZFR5cGUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lID8gZmllbGRUeXBlLm5hbWUgOiBudWxsOwogICAgICAgIHN3aXRjaCAoZmllbGRUeXBlKSB7CiAgICAgICAgICBjYXNlICJUeCI6CiAgICAgICAgICAgIHJldHVybiBuZXcgVGV4dFdpZGdldEFubm90YXRpb24ocGFyYW1ldGVycyk7CiAgICAgICAgICBjYXNlICJCdG4iOgogICAgICAgICAgICByZXR1cm4gbmV3IEJ1dHRvbldpZGdldEFubm90YXRpb24ocGFyYW1ldGVycyk7CiAgICAgICAgICBjYXNlICJDaCI6CiAgICAgICAgICAgIHJldHVybiBuZXcgQ2hvaWNlV2lkZ2V0QW5ub3RhdGlvbihwYXJhbWV0ZXJzKTsKICAgICAgICAgIGNhc2UgIlNpZyI6CiAgICAgICAgICAgIHJldHVybiBuZXcgU2lnbmF0dXJlV2lkZ2V0QW5ub3RhdGlvbihwYXJhbWV0ZXJzKTsKICAgICAgICB9CiAgICAgICAgKDAsIF91dGlsLndhcm4pKGBVbmltcGxlbWVudGVkIHdpZGdldCBmaWVsZCB0eXBlICIke2ZpZWxkVHlwZX0iLCBgICsgImZhbGxpbmcgYmFjayB0byBiYXNlIGZpZWxkIHR5cGUuIik7CiAgICAgICAgcmV0dXJuIG5ldyBXaWRnZXRBbm5vdGF0aW9uKHBhcmFtZXRlcnMpOwogICAgICBjYXNlICJQb3B1cCI6CiAgICAgICAgcmV0dXJuIG5ldyBQb3B1cEFubm90YXRpb24ocGFyYW1ldGVycyk7CiAgICAgIGNhc2UgIkZyZWVUZXh0IjoKICAgICAgICByZXR1cm4gbmV3IEZyZWVUZXh0QW5ub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hbWUuZ2V0KCJXaW5BbnNpRW5jb2RpbmciKSk7CiAgICAgICAgICAgIGNvbnN0IGJ1ZmZlciA9IFtdOwogICAgICAgICAgICBiYXNlRm9udFJlZiA9IHhyZWYuZ2V0TmV3VGVtcG9yYXJ5UmVmKCk7CiAgICAgICAgICAgICgwLCBfd3JpdGVyLndyaXRlT2JqZWN0KShiYXNlRm9udFJlZiwgYmFzZUZvbnQsIGJ1ZmZlciwgbnVsbCk7CiAgICAgICAgICAgIGRlcGVuZGVuY2llcy5wdXNoKHsKICAgICAgICAgICAgICByZWY6IGJhc2VGb250UmVmLAogICAgICAgICAgICAgIGRhdGE6IGJ1ZmZlci5qb2luKCIiKQogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICAgIHByb21pc2VzLnB1c2goRnJlZVRleHRBbm5vdGF0aW9uLmNyZWF0ZU5ld0Fubm90YXRpb24oeHJlZiwgYW5ub3RhdGlvbiwgZGVwZW5kZW5jaWVzLCB7CiAgICAgICAgICAgIGV2YWx1YXRvciwKICAgICAgICAgICAgdGFzaywKICAgICAgICAgICAgYmFzZUZvbnRSZWYKICAgICAgICAgIH0pKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgX3V0aWwuQW5ub3RhdGlvbkVkaXRvclR5cGUuSU5LOgogICAgICAgICAgcHJvbWlzZXMucHVzaChJbmtBbm5vdGF0aW9uLmNyZWF0ZU5ld0Fubm90YXRpb24oeHJlZiwgYW5ub3RhdGlvbiwgZGVwZW5kZW5jaWVzKSk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiB7CiAgICAgIGFubm90YXRpb25zOiBhd2FpdCBQcm9taXNlLmFsbChwcm9taXNlcyksCiAgICAgIGRlcGVuZGVuY2llcwogICAgfTsKICB9CiAgc3RhdGljIGFzeW5jIHByaW50TmV3QW5ub3RhdGlvbnMoZXZhbHVhdG9yLCB0YXNrLCBhbm5vdGF0aW9ucykgewogICAgaWYgKCFhbm5vdGF0aW9ucykgewogICA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hZFBvaW50cyIpOwogIGlmICghQXJyYXkuaXNBcnJheShxdWFkUG9pbnRzKSB8fCBxdWFkUG9pbnRzLmxlbmd0aCA9PT0gMCB8fCBxdWFkUG9pbnRzLmxlbmd0aCAlIDggPiAwKSB7CiAgICByZXR1cm4gbnVsbDsKICB9CiAgY29uc3QgcXVhZFBvaW50c0xpc3RzID0gW107CiAgZm9yIChsZXQgaSA9IDAsIGlpID0gcXVhZFBvaW50cy5sZW5ndGggLyA4OyBpIDwgaWk7IGkrKykgewogICAgbGV0IG1pblggPSBJbmZpbml0eSwKICAgICAgbWF4WCA9IC1JbmZpbml0eSwKICAgICAgbWluWSA9IEluZmluaXR5LAogICAgICBtYXhZID0gLUluZmluaXR5OwogICAgZm9yIChsZXQgaiA9IGkgKiA4LCBqaiA9IGkgKiA4ICsgODsgaiA8IGpqOyBqICs9IDIpIHsKICAgICAgY29uc3QgeCA9IHF1YWRQb2ludHNbal07CiAgICAgIGNvbnN0IHkgPSBxdWFkUG9pbnRzW2ogKyAxXTsKICAgICAgbWluWCA9IE1hdGgubWluKHgsIG1pblgpOwogICAgICBtYXhYID0gTWF0aC5tYXgoeCwgbWF4WCk7CiAgICAgIG1pblkgPSBNYXRoLm1pbih5LCBtaW5ZKTsKICAgICAgbWF4WSA9IE1hdGgubWF4KHksIG1heFkpOwogICAgfQogICAgaWYgKHJlY3QgIT09IG51bGwgJiYgKG1pblggPCByZWN0WzBdIHx8IG1heFggPiByZWN0WzJdIHx8IG1pblkgPCByZWN0WzFdIHx8IG1heFkgPiByZWN0WzNdKSkgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIHF1YWRQb2ludHNMaXN0cy5wdXNoKFt7CiAgICAgIHg6IG1pblgsCiAgICAgIHk6IG1heFkKICAgIH0sIHsKICAgICAgeDogbWF4WCwKICAgICAgeTogbWF4WQogICAgfSwgewogICAgICB4OiBtaW5YLAogICAgICB5OiBtaW5ZCiAgICB9LCB7CiAgICAgIHg6IG1heFgsCiAgICA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GEuaWQpOwogICAgaWYgKHN0b3JhZ2VFbnRyeSAmJiBzdG9yYWdlRW50cnkucHJpbnQgIT09IHVuZGVmaW5lZCkgewogICAgICByZXR1cm4gc3RvcmFnZUVudHJ5LnByaW50OwogICAgfQogICAgcmV0dXJuIHRoaXMucHJpbnRhYmxlOwogIH0KICBnZXQgdmlld2FibGUoKSB7CiAgICBpZiAodGhpcy5kYXRhLnF1YWRQb2ludHMgPT09IG51bGwpIHsKICAgICAgcmV0dXJuIGZhbHNlOwogICAgfQogICAgaWYgKHRoaXMuZmxhZ3MgPT09IDApIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICByZXR1cm4gdGhpcy5faXNWaWV3YWJsZSh0aGlzLmZsYWdzKTsKICB9CiAgZ2V0IHByaW50YWJsZSgpIHsKICAgIGlmICh0aGlzLmRhdGEucXVhZFBvaW50cyA9PT0gbnVsbCkgewogICAgICByZXR1cm4gZmFsc2U7CiAgICB9CiAgICBpZiAodGhpcy5mbGFncyA9PT0gMCkgewogICAgICByZXR1cm4gZmFsc2U7CiAgICB9CiAgICByZXR1cm4gdGhpcy5faXNQcmludGFibGUodGhpcy5mbGFncyk7CiAgfQogIF9wYXJzZVN0cmluZ0hlbHBlcihkYXRhKSB7CiAgICBjb25zdCBzdHIgPSB0eXBlb2YgZGF0YSA9PT0gInN0cmluZyIgPyAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKGRhdGEpIDogIiI7CiAgICBjb25zdCBkaXIgPSBzdHIgJiYgKDAsIF9iaWRpLmJpZGkpKHN0cikuZGlyID09PSAicnRsIiA/ICJydGwiIDogImx0ciI7CiAgICByZXR1cm4gewogICAgICBzdHIsCiAgICAgIGRpcgogICAgfTsKICB9CiAgc2V0RGVmYXVsdEFwcGVhcmFuY2UocGFyYW1zKSB7CiAgICBjb25zdCBkZWZhdWx0QXBwZWFyYW5jZSA9ICgwLCBfY29yZV91dGlscy5nZXRJbmhlcml0YWJsZVByb3BlcnR5KSh7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RhbmdsZS5sZW5ndGggPT09IDQpIHsKICAgICAgdGhpcy5yZWN0YW5nbGUgPSBfdXRpbC5VdGlsLm5vcm1hbGl6ZVJlY3QocmVjdGFuZ2xlKTsKICAgIH0gZWxzZSB7CiAgICAgIHRoaXMucmVjdGFuZ2xlID0gWzAsIDAsIDAsIDBdOwogICAgfQogIH0KICBzZXRDb2xvcihjb2xvcikgewogICAgdGhpcy5jb2xvciA9IGdldFJnYkNvbG9yKGNvbG9yKTsKICB9CiAgc2V0TGluZUVuZGluZ3MobGluZUVuZGluZ3MpIHsKICAgIHRoaXMubGluZUVuZGluZ3MgPSBbIk5vbmUiLCAiTm9uZSJdOwogICAgaWYgKEFycmF5LmlzQXJyYXkobGluZUVuZGluZ3MpICYmIGxpbmVFbmRpbmdzLmxlbmd0aCA9PT0gMikgewogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI7IGkrKykgewogICAgICAgIGNvbnN0IG9iaiA9IGxpbmVFbmRpbmdzW2ldOwogICAgICAgIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICBzd2l0Y2ggKG9iai5uYW1lKSB7CiAgICAgICAgICAgIGNhc2UgIk5vbmUiOgogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICBjYXNlICJTcXVhcmUiOgogICAgICAgICAgICBjYXNlICJDaXJjbGUiOgogICAgICAgICAgICBjYXNlICJEaWFtb25kIjoKICAgICAgICAgICAgY2FzZSAiT3BlbkFycm93IjoKICAgICAgICAgICAgY2FzZSAiQ2xvc2VkQXJyb3ciOgogICAgICAgICAgICBjYXNlICJCdXR0IjoKICAgICAgICAgICAgY2FzZSAiUk9wZW5BcnJvdyI6CiAgICAgICAgICAgIGNhc2UgIlJDbG9zZWRBcnJvdyI6CiAgICAgICAgICAgIGNhc2UgIlNsYXNoIjoKICAgICAgICAgICAgICB0aGlzLmxpbmVFbmRpbmdzW2ldID0gb2JqLm5hbWU7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgICgwLCBfdXRpbC53YXJuKShgSWdub3JpbmcgaW52YWxpZCBsaW5lRW5kaW5nOiAke29ian1gKTsKICAgICAgfQogICAgfQogIH0KICBzZXRSb3RhdGlvbihtaykgewogICAgdGhpcy5yb3RhdGlvbiA9IDA7CiAgICBpZiAobWsgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgIGxldCBhbmdsZSA9IG1rLmdldCgiUiIpIHx8IDA7CiAgICAgIGlmIChOdW1iZXIuaXNJbnRlZ2VyKGFuZ2xlKSAmJiBhbmdsZSAhPT0gMCkgewogICAgICAgIGFuZ2xlICU9IDM2MDsKICAgICAgICBpZiAoYW5nbGUgPCAwKSB7CiAgICAgICAgICBhbmdsZSArPSAzNjA7CiAgICAgICAgfQogICAgICAgIGlmIChhbmdsZSAlIDkwID09PSAwKSB7CiAgICAgICAgICB0aGlzLnJvdGF0aW9uID0gYW5nbGU7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgfQogIHNldEJvcmRlckFuZEJhY2tncm91bmRDb2xvcnMobWspIHsKICAgIGlmIChtayBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgdGhpcy5ib3JkZXJDb2xvciA9IGdldFJnYkNvbG9yKG1rLmdldEFycmF5KCJCQyIpLCBudWxsKTsKICAgICAgdGhpcy5iYWNrZ3JvdW5kQ29sb3IgPSBnZXRSZ2JDb2xvcihtay5nZXRBcnJheSgiQkciKSwgbnVsbCk7CiAgICB9IGVsc2UgewogICAgICB0aGlzLmJvcmRlckNvbG9yID0gdGhpcy5iYWNrZ3JvdW5kQ29sb3IgPSBudWxsOwogICAgfQogIH0KICBzZXRCb3JkZXJTdHlsZShib3JkZXJTdHlsZSkgewogICAgdGhpcy5ib3JkZXJTdHlsZSA9IG5ldyBBbm5vdGF0aW9uQm9yZGVyU3R5bGUoKTsKICAgIGlmICgh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bHVhdG9yLCB0YXNrLCBhbm5vdGF0aW9uU3RvcmFnZSkgewogICAgcmV0dXJuIG51bGw7CiAgfQogIGdldCBoYXNUZXh0Q29udGVudCgpIHsKICAgIHJldHVybiBmYWxzZTsKICB9CiAgYXN5bmMgZXh0cmFjdFRleHRDb250ZW50KGV2YWx1YXRvciwgdGFzaywgdmlld0JveCkgewogICAgaWYgKCF0aGlzLmFwcGVhcmFuY2UpIHsKICAgICAgcmV0dXJuOwogICAgfQogICAgY29uc3QgcmVzb3VyY2VzID0gYXdhaXQgdGhpcy5sb2FkUmVzb3VyY2VzKFsiRXh0R1N0YXRlIiwgIkZvbnQiLCAiUHJvcGVydGllcyIsICJYT2JqZWN0Il0sIHRoaXMuYXBwZWFyYW5jZSk7CiAgICBjb25zdCB0ZXh0ID0gW107CiAgICBjb25zdCBidWZmZXIgPSBbXTsKICAgIGNvbnN0IHNpbmsgPSB7CiAgICAgIGRlc2lyZWRTaXplOiBNYXRoLkluZmluaXR5LAogICAgICByZWFkeTogdHJ1ZSwKICAgICAgZW5xdWV1ZShjaHVuaywgc2l6ZSkgewogICAgICAgIGZvciAoY29uc3QgaXRlbSBvZiBjaHVuay5pdGVtcykgewogICAgICAgICAgYnVmZmVyLnB1c2goaXRlbS5zdHIpOwogICAgICAgICAgaWYgKGl0ZW0uaGFzRU9MKSB7CiAgICAgICAgICAgIHRleHQucHVzaChidWZmZXIuam9pbigiIikpOwogICAgICAgICAgICBidWZmZXIubGVuZ3RoID0gMDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH07CiAgICBhd2FpdCBldmFsdWF0b3IuZ2V0VGV4dENvbnRlbnQoewogICAgICBzdHJlYW06IHRoaXMuYXBwZWFyYW5jZSwKICAgICAgdGFzaywKICAgICAgcmVzb3VyY2VzLAogICAgICBpbmNsdWRlTWFya2VkQ29udGVudDogdHJ1ZSwKICAgICAgY29tYmluZVRleHRJdGVtczogdHJ1ZSwKICAgICAgc2luaywKICAgICAgdmlld0JveAogICAgfSk7CiAgICB0aGlzLnJlc2V0KCk7CiAgICBpZiAoYnVmZmVyLmxlbmd0aCkgewogICAgICB0ZXh0LnB1c2goYnVmZmVyLmpvaW4oIiIpKTsKICAgIH0KICAgIGlmICh0ZXh0Lmxlbmd0aCA+IDApIHsKICAgICAgdGhpcy5kYXRhLnRleHRDb250ZW50ID0gdGV4dDsKICAgIH0KICB9CiAgZ2V0RmllbGRPYmplY3QoKSB7CiAgICBpZiAodGhpcy5kYXRhLmtpZElkcykgewogICAgICByZXR1cm4gewogICAgICAgIGlkOiB0aGlzLmRhdGEuaWQsCiAgICAgICAgYWN0aW9uczogdGhpcy5kYXRhLmFjdGlvbnMsCiAgICAgICAgbmFtZTogdGhpcy5kYXRhLmZpZWxkTmFtZSwKICAgICAgICBzdHJva2VDb2xvcjogdGhpcy5kYXRhLmJvcmRlckNvbG9yLAogICAgICAgIGZpbGxDb2xvcjogdGhpcy5kYXRhLmJhY2tncm91bmRDb2xvciwKICAgICAgICB0eXBlOiAiIiwKICAgICAgICBraWRJZHM6IHRoaXMuZGF0YS5raWRJZHMsCiAgICAgICAgcGFnZTogdGhpcy5kYXRhLnBhZ2VJbmRleCwKICAgICAgICByb3RhdGlvbjogdGhpcy5yb3RhdGlvbgogICAgICB9OwogICAgfQogICAgcmV0dXJuIG51bGw7CiAgfQogIHJlc2V0KCkgewogICAgZm9yIChjb25zdCBzdHJlYW0gb2YgdGhpcy5fc3RyZWFtcykgewogICAgICBzdHJlYW0ucmVzZXQoKTsKICAgIH0KICB9CiAgX2NvbnN0cnVjdEZpZWxkTmFtZShkaWN0KSB7CiAgICBpZiAoIWRpY3QuaGFzKCJUIikgJiYgIWRpY3QuaGFzKCJQYXJlbnQiKSkgewogICAgICAoMCwgX3V0aWwud2FybikoIlVua25vd24gZmllbGQgbmFtZSwgZmFsbGluZyBiYWNrIHRvIGVtcHR5IGZpZWxkIG5hbWUuIik7CiAgICAgIHJldHVybiAiIjsKICAgIH0KICAgIGlmICghZ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FzaEFycmF5Lmxlbmd0aCA+IDApIHsKICAgICAgbGV0IGlzVmFsaWQgPSB0cnVlOwogICAgICBsZXQgYWxsWmVyb3MgPSB0cnVlOwogICAgICBmb3IgKGNvbnN0IGVsZW1lbnQgb2YgZGFzaEFycmF5KSB7CiAgICAgICAgY29uc3QgdmFsaWROdW1iZXIgPSArZWxlbWVudCA+PSAwOwogICAgICAgIGlmICghdmFsaWROdW1iZXIpIHsKICAgICAgICAgIGlzVmFsaWQgPSBmYWxzZTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0gZWxzZSBpZiAoZWxlbWVudCA+IDApIHsKICAgICAgICAgIGFsbFplcm9zID0gZmFsc2U7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChpc1ZhbGlkICYmICFhbGxaZXJvcykgewogICAgICAgIHRoaXMuZGFzaEFycmF5ID0gZGFzaEFycmF5OwogICAgICAgIGlmIChmb3JjZVN0eWxlKSB7CiAgICAgICAgICB0aGlzLnNldFN0eWxlKF9wcmltaXRpdmVzLk5hbWUuZ2V0KCJEIikpOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICB0aGlzLndpZHRoID0gMDsKICAgICAgfQogICAgfSBlbHNlIGlmIChkYXNoQXJyYXkpIHsKICAgICAgdGhpcy53aWR0aCA9IDA7CiAgICB9CiAgfQogIHNldEhvcml6b250YWxDb3JuZXJSYWRpdXMocmFkaXVzKSB7CiAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihyYWRpdXMpKSB7CiAgICAgIHRoaXMuaG9yaXpvbnRhbENvcm5lclJhZGl1cyA9IHJhZGl1czsKICAgIH0KICB9CiAgc2V0VmVydGljYWxDb3JuZXJSYWRpdXMocmFkaXVzKSB7CiAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihyYWRpdXMpKSB7CiAgICAgIHRoaXMudmVydGljYWxDb3JuZXJSYWRpdXMgPSByYWRpdXM7CiAgICB9CiAgfQp9CmV4cG9ydHMuQW5ub3RhdGlv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ID0gZm9udC5jaGFyc1RvR2x5cGhzKGVuY29kZWQpOwogICAgICAgICAgY29uc3QgcG9zaXRpb25zID0gZm9udC5nZXRDaGFyUG9zaXRpb25zKGVuY29kZWQpOwogICAgICAgICAgY2FjaGVkTGluZXMucHVzaCh7CiAgICAgICAgICAgIGxpbmU6IGVuY29kZWQsCiAgICAgICAgICAgIGdseXBocywKICAgICAgICAgICAgcG9zaXRpb25zCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgY29uc3QgaXNUb29CaWcgPSBmc2l6ZSA9PiB7CiAgICAgICAgICBsZXQgdG90YWxIZWlnaHQgPSAwOwogICAgICAgICAgZm9yIChjb25zdCBjYWNoZSBvZiBjYWNoZWRMaW5lcykgewogICAgICAgICAgICBjb25zdCBjaHVua3MgPSB0aGlzLl9zcGxpdExpbmUobnVsbCwgZm9udCwgZnNpemUsIHdpZHRoLCBjYWNoZSk7CiAgICAgICAgICAgIHRvdGFsSGVpZ2h0ICs9IGNodW5rcy5sZW5ndGggKiBmc2l6ZTsKICAgICAgICAgICAgaWYgKHRvdGFsSGVpZ2h0ID4gaGVpZ2h0KSB7CiAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9OwogICAgICAgIG51bWJlck9mTGluZXMgPSBNYXRoLm1heChudW1iZXJPZkxpbmVzLCBsaW5lQ291bnQpOwogICAgICAgIHdoaWxlICh0cnVlKSB7CiAgICAgICAgICBsaW5lSGVpZ2h0ID0gaGVpZ2h0IC8gbnVtYmVyT2ZMaW5lczsKICAgICAgICAgIGZvbnRTaXplID0gcm91bmRXaXRoVHdvRGlnaXRzKGxpbmVIZWlnaHQgLyBfdXRpbC5MSU5FX0ZBQ1RPUik7CiAgICAgICAgICBpZiAoaXNUb29CaWcoZm9udFNpemUpKSB7CiAgICAgICAgICAgIG51bWJlck9mTGluZXMrKzsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0KICAgICAgY29uc3QgewogICAgICAgIGZvbnROYW1lLAogICAgICAgIGZvbnRDb2xvcgogICAgICB9ID0gdGhpcy5kYXRhLmRlZmF1bHRBcHBlYXJhbmNlRGF0YTsKICAgICAgdGhpcy5fZGVmYXVsdEFwcGVhcmFuY2UgPSAoMCwgX2RlZmF1bHRfYXBwZWFyYW5jZS5jcmVhdGVEZWZhdWx0QXBwZWFyYW5jZSkoewogICAgICAgIGZvbnRTaXplLAogICAgICAgIGZvbnROYW1lLAogICAgICAgIGZvbnRDb2xvcgogICAgICB9KTsKICAgIH0KICAgIHJldHVybiBbdGhpcy5fZGVmYXVsdEFwcGVhcmFuY2UsIGZvbnRTaXplLCBoZWlnaHQgLyBudW1iZXJPZkxpbmVzXTsKICB9CiAgX3JlbmRlclRleHQodGV4dCwgZm9udCwgZm9udFNpemUsIHRvdGFsV2lkdGgsIGFsaWdubWVudCwgcHJldkluZm8sIGhQYWRkaW5nLCB2UGFkZGluZykgewogICAgbGV0IHNoaWZ0OwogICAgaWYgKGFsaWdubWVudCA9PT0gMSkgewogICAgICBjb25zdCB3aWR0aCA9IHRoaXMuX2dldFRleHRXaWR0aCh0ZXh0LCBmb250KSAqIGZvbnRTaXplOwogICAgICBzaGlmdCA9ICh0b3RhbFdpZHRoIC0gd2lkdGgpIC8gMjsKICAgIH0gZWxzZSBpZiAoYWxpZ25tZW50ID09PSAyKSB7CiAgICAgIGNvbnN0IHdpZHRoID0gdGhpcy5fZ2V0VGV4dFdpZHRoKHRleHQsIGZvbnQpICogZm9udFNpemU7CiAgICAgIHNoaWZ0ID0gdG90YWxXaWR0aCAtIHdpZHRoIC0gaFBhZGRpbmc7CiAgICB9IGVsc2UgewogICAgICBzaGlmdCA9IGhQYWRkaW5nOwogICAgfQogICAgY29uc3Qgc2hpZnRTdHIgPSAoMCwgX2NvcmVfdXRpbHMubnVtYmVyVG9TdH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ICAgY2h1bmtzLnB1c2gobGluZS5zdWJzdHJpbmcoc3RhcnRDaHVuaywgbGFzdFNwYWNlUG9zSW5TdHJpbmdFbmQpKTsKICAgICAgICAgICAgc3RhcnRDaHVuayA9IGxhc3RTcGFjZVBvc0luU3RyaW5nRW5kOwogICAgICAgICAgICBpID0gbGFzdFNwYWNlUG9zICsgMTsKICAgICAgICAgICAgbGFzdFNwYWNlUG9zSW5TdHJpbmdTdGFydCA9IC0xOwogICAgICAgICAgICBjdXJyZW50V2lkdGggPSAwOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY2h1bmtzLnB1c2gobGluZS5zdWJzdHJpbmcoc3RhcnRDaHVuaywgc3RhcnQpKTsKICAgICAgICAgICAgc3RhcnRDaHVuayA9IHN0YXJ0OwogICAgICAgICAgICBjdXJyZW50V2lkdGggPSBnbHlwaFdpZHRoOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjdXJyZW50V2lkdGggKz0gZ2x5cGhXaWR0aDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGlmIChzdGFydENodW5rIDwgbGluZS5sZW5ndGgpIHsKICAgICAgY2h1bmtzLnB1c2gobGluZS5zdWJzdHJpbmcoc3RhcnRDaHVuaywgbGluZS5sZW5ndGgpKTsKICAgIH0KICAgIHJldHVybiBjaHVua3M7CiAgfQogIGdldEZpZWxkT2JqZWN0KCkgewogICAgcmV0dXJuIHsKICAgICAgaWQ6IHRoaXMuZGF0YS5pZCwKICAgICAgdmFsdWU6IHRoaXMuZGF0YS5maWVsZFZhbHVlLAogICAgICBkZWZhdWx0VmFsdWU6IHRoaXMuZGF0YS5kZWZhdWx0RmllbGRWYWx1ZSB8fCAiIiwKICAgICAgbXVsdGlsaW5lOiB0aGlzLmRhdGEubXVsdGlMaW5lLAogICAgICBwYXNzd29yZDogdGhpcy5oYXNGaWVsZEZsYWcoX3V0aWwuQW5ub3RhdGlvbkZpZWxkRmxhZy5QQVNTV09SR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vckNvbG9yID8gZ2V0UGRmQ29sb3JBcnJheShpbnRlcmlvckNvbG9yKSA6IG51bGw7CiAgICAgIGNvbnN0IGZpbGxBbHBoYSA9IGZpbGxDb2xvciA/IHN0cm9rZUFscGhhIDogbnVsbDsKICAgICAgaWYgKHRoaXMuYm9yZGVyU3R5bGUud2lkdGggPT09IDAgJiYgIWZpbGxDb2xvcikgewogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICB0aGlzLl9zZXREZWZhdWx0QXBwZWFyYW5jZSh7CiAgICAgICAgeHJlZiwKICAgICAgICBleHRyYTogYCR7dGhpcy5ib3JkZXJTdHlsZS53aWR0aH0gd2AsCiAgICAgICAgc3Ryb2tlQ29sb3IsCiAgICAgICAgZmlsbENvbG9yLAogICAgICAgIHN0cm9rZUFscGhhLAogICAgICAgIGZpbGxBbHBoYSwKICAgICAgICBwb2ludHNDYWxsYmFjazogKGJ1ZmZlciwgcG9pbnRzKSA9PiB7CiAgICAgICAgICBjb25zdCB4ID0gcG9pbnRzWzJdLnggKyB0aGlzLmJvcmRlclN0eWxlLndpZHRoIC8gMjsKICAgICAgICAgIGNvbnN0IHkgPSBwb2ludHNbMl0ueSArIHRoaXMuYm9yZGVyU3R5bGUud2lkdGggLyAyOwogICAgICAgICAgY29uc3Qgd2lkdGggPSBwb2ludHNbM10ueCAtIHBvaW50c1syXS54IC0gdGhpcy5ib3JkZXJTdHlsZS53aWR0aDsKICAgICAgICAgIGNvbnN0IGhlaWdodCA9IHBvaW50c1sxXS55IC0gcG9pbnRzWzNdLnkgLSB0aGlzLmJvcmRlclN0eWxlLndpZHRoOwogICAgICAgICAgYnVmZmVyLnB1c2goYCR7eH0gJHt5fSAke3dpZHRofSAke2hlaWdodH0gcmVgKTsKICAgICAgICAgIGlmIChmaWxsQ29sb3IpIHsKICAgICAgICAgICAgYnVmZmVyLnB1c2goIkIiKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGJ1ZmZlci5wdXNoKCJTIik7CiA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c2V0RGVmYXVsdEFwcGVhcmFuY2UoewogICAgICAgIHhyZWYsCiAgICAgICAgZXh0cmE6IGAke3RoaXMuYm9yZGVyU3R5bGUud2lkdGh9IHdgLAogICAgICAgIHN0cm9rZUNvbG9yLAogICAgICAgIGZpbGxDb2xvciwKICAgICAgICBzdHJva2VBbHBoYSwKICAgICAgICBmaWxsQWxwaGEsCiAgICAgICAgcG9pbnRzQ2FsbGJhY2s6IChidWZmZXIsIHBvaW50cykgPT4gewogICAgICAgICAgY29uc3QgeDAgPSBwb2ludHNbMF0ueCArIHRoaXMuYm9yZGVyU3R5bGUud2lkdGggLyAyOwogICAgICAgICAgY29uc3QgeTAgPSBwb2ludHNbMF0ueSAtIHRoaXMuYm9yZGVyU3R5bGUud2lkdGggLyAyOwogICAgICAgICAgY29uc3QgeDEgPSBwb2ludHNbM10ueCAtIHRoaXMuYm9yZGVyU3R5bGUud2lkdGggLyAyOwogICAgICAgICAgY29uc3QgeTEgPSBwb2ludHNbM10ueSArIHRoaXMuYm9yZGVyU3R5bGUud2lkdGggLyAyOwogICAgICAgICAgY29uc3QgeE1pZCA9IHgwICsgKHgxIC0geDApIC8gMjsKICAgICAgICAgIGNvbnN0IHlNaWQgPSB5MCArICh5MSAtIHkwKSAvIDI7CiAgICAgICAgICBjb25zdCB4T2Zmc2V0ID0gKHgxIC0geDApIC8gMiAqIGNvbnRyb2xQb2ludHNEaXN0YW5jZTsKICAgICAgICAgIGNvbnN0IHlPZmZzZXQgPSAoeTEgLSB5MCkgLyAyICogY29udHJvbFBvaW50c0Rpc3RhbmNlOwogICAgICAgICAgYnVmZmVyLnB1c2goYCR7eE1pZH0gJHt5MX0gbWAsIGAke3hNaWQgKyB4T2Zmc2V0fSAke3kxfSAke3gxfSAke3lNaWQgKyB5T2Zmc2V0fSAke3gxfSAke3lNaWR9IGNgLCBgJHt4MX0gJHt5TWlkIC0geU9mZnNldH0gJHt4TWlkICsgeE9mZnNldH0gJHt5MH0gJHt4TWlkfSAke3kw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dCk7CiAgICAgIH0KICAgICAgaWYgKCFfdXRpbC5VdGlsLmludGVyc2VjdCh0aGlzLnJlY3RhbmdsZSwgYmJveCkpIHsKICAgICAgICB0aGlzLnJlY3RhbmdsZSA9IGJib3g7CiAgICAgIH0KICAgICAgdGhpcy5fc2V0RGVmYXVsdEFwcGVhcmFuY2UoewogICAgICAgIHhyZWYsCiAgICAgICAgZXh0cmE6IGAke2JvcmRlcldpZHRofSB3YCwKICAgICAgICBzdHJva2VDb2xvciwKICAgICAgICBzdHJva2VBbHBoYSwKICAgICAgICBwb2ludHNDYWxsYmFjazogKGJ1ZmZlciwgcG9pbnRzKSA9PiB7CiAgICAgICAgICBjb25zdCB2ZXJ0aWNlcyA9IHRoaXMuZGF0YS52ZXJ0aWNlczsKICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IHZlcnRpY2VzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgYnVmZmVyLnB1c2goYCR7dmVydGljZXNbaV0ueH0gJHt2ZXJ0aWNlc1tpXS55fSAke2kgPT09IDAgPyAibSIgOiAibCJ9YCk7CiAgICAgICAgICB9CiAgICAgICAgICBidWZmZXIucHVzaCgiUyIpOwogICAgICAgICAgcmV0dXJuIFtwb2ludHNbMF0ueCwgcG9pbnRzWzFdLngsIHBvaW50c1szXS55LCBwb2ludHNbMV0ueV07CiAgICAgICAgfQogICAgICB9KTsKICAgIH0KICB9Cn0KY2xhc3MgUG9seWdvbkFubm90YXRpb24gZXh0ZW5kcyBQb2x5bGluZUFubm90YXRpb24gewogIGNvbnN0cnVjdG9yKHBhcmFtcykgewogICAgc3VwZXIocGFyYW1zKTsKICAgIHRoaXMuZGF0YS5hbm5vdGF0aW9uVHlwZSA9IF91dGlsLkFubm90YXRpb25UeXBlLlBPTFlHT047CiAgfQp9CmNsYXNzIENhcmV0QW5ub3RhdGlvbiBleHRlbmRzIE1hcmt1cEFubm90YXRpb24gewogIGNvbnN0cnVjdG9yKHBhcm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vbnN0IHN0cm9rZUNvbG9yID0gdGhpcy5jb2xvciA/IGdldFBkZkNvbG9yQXJyYXkodGhpcy5jb2xvcikgOiBbMCwgMCwgMF07CiAgICAgIGNvbnN0IHN0cm9rZUFscGhhID0gZGljdC5nZXQoIkNBIik7CiAgICAgIGNvbnN0IGJvcmRlcldpZHRoID0gdGhpcy5ib3JkZXJTdHlsZS53aWR0aCB8fCAxLAogICAgICAgIGJvcmRlckFkanVzdCA9IDIgKiBib3JkZXJXaWR0aDsKICAgICAgY29uc3QgYmJveCA9IFtJbmZpbml0eSwgSW5maW5pdHksIC1JbmZpbml0eSwgLUluZmluaXR5XTsKICAgICAgZm9yIChjb25zdCBpbmtMaXN0cyBvZiB0aGlzLmRhdGEuaW5rTGlzdHMpIHsKICAgICAgICBmb3IgKGNvbnN0IHZlcnRleCBvZiBpbmtMaXN0cykgewogICAgICAgICAgYmJveFswXSA9IE1hdGgubWluKGJib3hbMF0sIHZlcnRleC54IC0gYm9yZGVyQWRqdXN0KTsKICAgICAgICAgIGJib3hbMV0gPSBNYXRoLm1pbihiYm94WzFdLCB2ZXJ0ZXgueSAtIGJvcmRlckFkanVzdCk7CiAgICAgICAgICBiYm94WzJdID0gTWF0aC5tYXgoYmJveFsyXSwgdmVydGV4LnggKyBib3JkZXJBZGp1c3QpOwogICAgICAgICAgYmJveFszXSA9IE1hdGgubWF4KGJib3hbM10sIHZlcnRleC55ICsgYm9yZGVyQWRqdXN0KTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCFfdXRpbC5VdGlsLmludGVyc2VjdCh0aGlzLnJlY3RhbmdsZSwgYmJveCkpIHsKICAgICAgICB0aGlzLnJlY3RhbmdsZSA9IGJib3g7CiAgICAgIH0KICAgICAgdGhpcy5fc2V0RGVmYXVsdEFwcGVhcmFuY2UoewogICAgICAgIHhyZWYsCiAgICAgICAgZXh0cmE6IGAke2JvcmRlcldpZHRofSB3YCwKICAgICAgICBzdHJva2VDb2xvciwKICAgICAgICBzdHJva2VBbHBoYSwKICAgICAgICBwb2ludHNDYWxsYmFjazogKGJ1ZmZlciwgcG9pbnRzKSA9PiB7CiAgICAgICAgICBmb3IgKGNvbnN0IGlua0xpc3Qgb2YgdGhpcy5kYXRhLmlua0xpc3RzKSB7CiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGlua0xpc3QubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgICAgICAgIGJ1ZmZlci5wdXNoKGAke2lua0xpc3RbaV0ueH0gJHtpbmtMaXN0W2ldLnl9ICR7aSA9PT0gMCA/ICJtIiA6ICJsIn1gKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBidWZmZXIucHVzaCgiUyIpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIFtwb2ludHNbMF0ueCwgcG9pbnRzWzFdLngsIHBvaW50c1szXS55LCBwb2ludHNbMV0ueV07CiAgICAgICAgfQogICAgICB9KTsKICAgIH0KICB9CiAgc3RhdGljIGNyZWF0ZU5ld0RpY3QoYW5ub3RhdGlvbiwgeHJlZiwgX3JlZjUpIHsKICAgIGxldCB7CiAgICAgIGFwUmVmLAogICAgICBhcAogICAgfSA9IF9yZWY1OwogICAgY29uc3QgewogICAgICBwYXRocywKICAgICAgcmVjdCwKICAgICAgcm90YXRpb24KICAgIH0gPSBhbm5vdGF0aW9uOwogICAgY29uc3QgaW5rID0gbmV3IF9wcmltaXRpdmVzLkRpY3QoeHJlZik7CiAgICBpbmsuc2V0KCJUeXBlIiwgX3ByaW1pdGl2ZXMuTmFtZS5nZXQoIkFubm90IikpOwogICAgaW5rLnNldCgiU3VidHlwZSIsIF9wcmltaXRpdmVzLk5hbWUuZ2V0KCJJbmsiKSk7CiAgICBpbmsuc2V0KCJDcmVhdGlvbkRhdGUiLCBgRDokeygwLCBfdXRpbC5nZXRNb2RpZmljYXRpb25EYXRlKSgpfWApOwogICAgaW5rLnNldCgiUmVjdCIsIHJlY3QpOwogICAgaW5rLnNldCgiSW5r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KICAgICAgICAgIHBvaW50c0NhbGxiYWNrOiAoYnVmZmVyLCBwb2ludHMpID0+IHsKICAgICAgICAgICAgYnVmZmVyLnB1c2goYCR7cG9pbnRzWzJdLnh9ICR7cG9pbnRzWzJdLnl9IG1gLCBgJHtwb2ludHNbM10ueH0gJHtwb2ludHNbM10ueX0gbGAsICJTIik7CiAgICAgICAgICAgIHJldHVybiBbcG9pbnRzWzBdLngsIHBvaW50c1sxXS54LCBwb2ludHNbM10ueSwgcG9pbnRzWzFdLnldOwogICAgICAgICAgfQogICAgICAgIH0pOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICB0aGlzLmRhdGEuaGFzUG9wdXAgPSBmYWxzZTsKICAgIH0KICB9Cn0KY2xhc3MgU3F1aWdnbHlBbm5vdGF0aW9uIGV4dGVuZHMgTWFya3VwQW5ub3RhdGlvbiB7CiAgY29uc3RydWN0b3IocGFyYW1zKSB7CiAgICBzdXBlcihwYXJhbXMpOwogICAgY29uc3QgewogICAgICBkaWN0LAogICAgICB4cmVmCiAgICB9ID0gcGFyYW1zOwogICAgdGhpcy5kYXRhLmFubm90YXRpb25UeXBlID0gX3V0aWwuQW5ub3RhdGlvblR5cGUuU1FVSUdHTFk7CiAgICBjb25zdCBxdWFkUG9pbnRzID0gdGhpcy5kYXRhLnF1YWRQb2ludHMgPSBnZXRRdWFkUG9pbnRzKGRpY3QsIG51bGwpOwogICAgaWYgKHF1YWRQb2ludHMpIHsKICAgICAgaWYgKCF0aGlzLmFwcGVhcmFuY2UpIHsKICAgICAgICBjb25zdCBzdHJva2VDb2xvciA9IHRoaXMuY29sb3IgPyBnZXRQZGZDb2xvckFycmF5KHRoaXMuY29sb3IpIDogWzAsIDAsIDBdOwogICAgICAgIGNvbnN0IHN0cm9rZUFscGhhID0gZGljdC5nZXQoIkNBIik7CiAgICAgICAgdGhpcy5fc2V0RGVmYXVsdEFwcGVhcmFuY2UoewogICAgICAgICAgeHJlZiwKICAgICAgICAgIGV4dHJhOiAiW10gMCBkIDEgdyIsCiAgICAgICAgICBzdHJva2VDb2xvciwKICAgICAgICAgIHN0cm9rZUFscGhhLAogICAgICAgICAgcG9pbnRzQ2FsbGJhY2s6IChidWZmZXIsIHBvaW50cykgPT4gewogICAgICAgICAgICBjb25zdCBkeSA9IChwb2ludHNbMF0ueSAtIHBvaW50c1syXS55KSAvIDY7CiAgICAgICAgICAgIGxldCBzaGlmdCA9IGR5OwogICAgICAgICAgICBsZXQgeCA9IHBvaW50c1syXS54OwogICAgICAgICAgICBjb25zdCB5ID0gcG9pbnRzWzJdLnk7CiAgICAgICAgICAgIGNvbnN0IHhFbmQgPSBwb2ludHNbM10ueDsKICAgICAgICAgICAgYnVmZmVyLnB1c2goYCR7eH0gJHt5ICsgc2hpZnR9IG1gKTsKICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgIHggKz0gMjsKICAgICAgICAgICAgICBzaGlmdCA9IHNoaWZ0ID09PSAwID8gZHkgOiAwOwogICAgICAgICAgICAgIGJ1ZmZlci5wdXNoKGAke3h9ICR7eSArIHNoaWZ0fSBsYCk7CiAgICAgICAgICAgIH0gd2hpbGUgKHggPCB4RW5kKTsKICAgICAgICAgICAgYnVmZmVyLnB1c2goIlMiKTsKICAgICAgICAgICAgcmV0dXJuIFtwb2ludHNbMl0ueCwgeEVuZCwgeSAtIDIgKiBkeSwgeSArIDIgKiBkeV07CiAgICAgICAgICB9CiAgICAgICAgfSk7CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIHRoaXMuZGF0YS5oYXNQb3B1cCA9IGZhbHNlOwogICAgfQogIH0KfQpjbGFzcyBTdHJpa2VPdXRBbm5vdGF0aW9uIGV4dGVuZHMgTWFya3VwQW5ub3RhdGlvbiB7CiAgY29uc3RydWN0b3IocGFyYW1zKSB7CiAgICBzdXBlcihwYXJhbXMpOwogICAgY29uc3QgewogICAgICBkaWN0LAogICAgICB4cmVmCiAgICB9ID0gcGFyYW1zOwogICAgdGhpcy5kYXRhLmFubm90YXRpb25Ue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gICB9OwogICAgdHJ5IHsKICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICBvcGVyYXRpb24uYXJncy5sZW5ndGggPSAwOwogICAgICAgIGlmICghdGhpcy5yZWFkKG9wZXJhdGlvbikpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBpZiAodGhpcy5zYXZlZFN0YXRlc0RlcHRoICE9PSAwKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgY29uc3QgewogICAgICAgICAgZm4sCiAgICAgICAgICBhcmdzCiAgICAgICAgfSA9IG9wZXJhdGlvbjsKICAgICAgICBzd2l0Y2ggKGZuIHwgMCkgewogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0Rm9udDoKICAgICAgICAgICAgY29uc3QgW2ZvbnROYW1lLCBmb250U2l6ZV0gPSBhcmdzOwogICAgICAgICAgICBpZiAoZm9udE5hbWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgcmVzdWx0LmZvbnROYW1lID0gZm9udE5hbWUubmFtZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodHlwZW9mIGZvbnRTaXplID09PSAibnVtYmVyIiAmJiBmb250U2l6ZSA+IDApIHsKICAgICAgICAgICAgICByZXN1bHQuZm9udFNpemUgPSBmb250U2l6ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZpbGxSR0JDb2xvcjoKICAgICAgICAgICAgX2NvbG9yc3BhY2UuQ29sb3JTcGFjZS5zaW5nbGV0b25zLnJnYi5nZXRSZ2JJdGVtKGFyZ3MsIDAsIHJlc3VsdC5mb250Q29sb3IsIDApOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEZpbGxHcmF5OgogICAgICAgICAgICBfY29sb3JzcGFjZS5Db2xvclNwYWNlLnNpbmdsZXR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Quc2V0KCJDSURUb0dJRE1hcCIsIF9wcmltaXRpdmVzLk5hbWUuZ2V0KCJJZGVudGl0eSIpKTsKICAgIGRlc2NlbmRhbnRGb250LnNldCgiRmlyc3RDaGFyIiwgdGhpcy5maXJzdENoYXIpOwogICAgZGVzY2VuZGFudEZvbnQuc2V0KCJMYXN0Q2hhciIsIHRoaXMubGFzdENoYXIpOwogICAgZGVzY2VuZGFudEZvbnQuc2V0KCJGb250RGVzY3JpcHRvciIsIHRoaXMuZm9udERlc2NyaXB0b3JSZWYpOwogICAgZGVzY2VuZGFudEZvbnQuc2V0KCJEVyIsIDEwMDApOwogICAgY29uc3Qgd2lkdGhzID0gW107CiAgICBjb25zdCBjaGFycyA9IFsuLi50aGlzLndpZHRocy5lbnRyaWVzKCldLnNvcnQoKTsKICAgIGxldCBjdXJyZW50Q2hhciA9IG51bGw7CiAgICBsZXQgY3VycmVudFdpZHRocyA9IG51bGw7CiAgICBmb3IgKGNvbnN0IFtjaGFyLCB3aWR0aF0gb2YgY2hhcnMpIHsKICAgICAgaWYgKCFjdXJyZW50Q2hhcikgewogICAgICAgIGN1cnJlbnRDaGFyID0gY2hhcjsKICAgICAgICBjdXJyZW50V2lkdGhzID0gW3dpZHRoXTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoY2hhciA9PT0gY3VycmVudENoYXIgKyBjdXJyZW50V2lkdGhzLmxlbmd0aCkgewogICAgICAgIGN1cnJlbnRXaWR0aHMucHVzaCh3aWR0aCk7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgd2lkdGhzLnB1c2goY3VycmVudENoYXIsIGN1cnJlbnRXaWR0aHMpOwogICAgICAgIGN1cnJlbnRDaGFyID0gY2hhcjsKICAgICAgICBjdXJyZW50V2lkdGhzID0gW3dpZHRoXTsKICAgICAgfQogICAgfQogICAgaWYgKGN1cnJlbnRDaGFyKSB7CiAgICAgIHdpZHRocy5wdXNoKGN1cnJlbnRDaGFyLCBjdXJyZW50V2lkdGh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AgICAgICB0aGlzLmxhc3RDaGFyID0gTWF0aC5tYXgoY29kZSwgdGhpcy5sYXN0Q2hhcik7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiB0aGlzLnJlc291cmNlczsKICB9CiAgY3JlYXRlQXBwZWFyYW5jZSh0ZXh0LCByZWN0LCByb3RhdGlvbiwgZm9udFNpemUsIGJnQ29sb3IsIHN0cm9rZUFscGhhKSB7CiAgICBjb25zdCBjdHggPSB0aGlzLl9jcmVhdGVDb250ZXh0KCk7CiAgICBjb25zdCBsaW5lcyA9IFtdOwogICAgbGV0IG1heFdpZHRoID0gLUluZmluaXR5OwogICAgZm9yIChjb25zdCBsaW5lIG9mIHRleHQuc3BsaXQoL1xyXG4/fFxuLykpIHsKICAgICAgbGluZXMucHVzaChsaW5lKTsKICAgICAgY29uc3QgbGluZVdpZHRoID0gY3R4Lm1lYXN1cmVUZXh0KGxpbmUpLndpZHRoOwogICAgICBtYXhXaWR0aCA9IE1hdGgubWF4KG1heFdpZHRoLCBsaW5lV2lkdGgpOwogICAgICBmb3IgKGNvbnN0IGNoYXIgb2YgbGluZS5zcGxpdCgiIikpIHsKICAgICAgICBjb25zdCBjb2RlID0gY2hhci5jaGFyQ29kZUF0KDApOwogICAgICAgIGxldCB3aWR0aCA9IHRoaXMud2lkdGhzLmdldChjb2RlKTsKICAgICAgICBpZiAod2lkdGggPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgY29uc3QgbWV0cmljcyA9IGN0eC5tZWFzdXJlVGV4dChjaGFyKTsKICAgICAgICAgIHdpZHRoID0gTWF0aC5jZWlsKG1ldHJpY3Mud2lkdGgpOwogICAgICAgICAgdGhpcy53aWR0aHMuc2V0KGNvZGUsIHdpZHRoKTsKICAgICAgICAgIHRoaXMuZmlyc3RDaGFyID0gTWF0aC5taW4oY29kZSwgdGhpcy5maXJzdENoYXIpOwogICAgICAgICAgdGhpcy5sYXN0Q2hhciA9IE1hdGgubWF4KGNvZGUsIHRoaXMubGFzdENoYXIpO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AgICBmb3IgKGxldCBpID0gMDsgaSA8IG51bUNvbXBvbmVudENvbG9yczsgaSsrKSB7CiAgICAgICAgYWxsQ29sb3JzW2ldID0gaTsKICAgICAgfQogICAgICBjb25zdCBjb2xvck1hcCA9IG5ldyBVaW50OENsYW1wZWRBcnJheShudW1Db21wb25lbnRDb2xvcnMgKiAzKTsKICAgICAgdGhpcy5nZXRSZ2JCdWZmZXIoYWxsQ29sb3JzLCAwLCBudW1Db21wb25lbnRDb2xvcnMsIGNvbG9yTWFwLCAwLCBicGMsIDApOwogICAgICBpZiAoIW5lZWRzUmVzaXppbmcpIHsKICAgICAgICBsZXQgZGVzdFBvcyA9IDA7CiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBjb3VudDsgKytpKSB7CiAgICAgICAgICBjb25zdCBrZXkgPSBjb21wc1tpXSAqIDM7CiAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBjb2xvck1hcFtrZXldOwogICAgICAgICAgZGVzdFtkZXN0UG9zKytdID0gY29sb3JNYXBba2V5ICsgMV07CiAgICAgICAgICBkZXN0W2Rlc3RQb3MrK10gPSBjb2xvck1hcFtrZXkgKyAyXTsKICAgICAgICAgIGRlc3RQb3MgKz0gYWxwaGEwMTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcmdiQnVmID0gbmV3IFVpbnQ4QXJyYXkoY291bnQgKiAzKTsKICAgICAgICBsZXQgcmdiUG9zID0gMDsKICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGNvdW50OyArK2kpIHsKICAgICAgICAgIGNvbnN0IGtleSA9IGNvbXBzW2ldICogMzsKICAgICAgICAgIHJnYkJ1ZltyZ2JQb3MrK10gPSBjb2xvck1hcFtrZXldOwogICAgICAgICAgcmdiQnVmW3JnYlBvcysrXSA9IGNvbG9yTWFwW2tleSArIDFdOwogICAgICAgICAgcmdiQnVmW3JnYlBvcysrXSA9IGNvbG9yTWFwW2tleSArIDJdOwogICAgICAgIH0K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AgICAgICAgICAgICAgY3MgPSByZXNvdXJjZXNDUzsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBVbnJlY29nbml6ZWQgQ29sb3JTcGFjZTogJHtjcy5uYW1lfWApOwogICAgICB9CiAgICB9CiAgICBpZiAoQXJyYXkuaXNBcnJheShjcykpIHsKICAgICAgY29uc3QgbW9kZSA9IHhyZWYuZmV0Y2hJZlJlZihjc1swXSkubmFtZTsKICAgICAgbGV0IHBhcmFtcywgbnVtQ29tcHMsIGJhc2VDUywgd2hpdGVQb2ludCwgYmxhY2tQb2ludCwgZ2FtbWE7CiAgICAgIHN3aXRjaCAobW9kZSkgewogICAgICAgIGNhc2UgIkciOgogICAgICAgIGNhc2UgIkRldmljZUdyYXkiOgogICAgICAgICAgcmV0dXJuIHRoaXMuc2luZ2xldG9ucy5ncmF5OwogICAgICAgIGNhc2UgIlJHQiI6CiAgICAgICAgY2FzZSAiRGV2aWNlUkdCIjoKICAgICAgICAgIHJldHVybiB0aGlzLnNpbmdsZXRvbnMucmdiOwogICAgICAgIGNhc2UgIkNNWUsiOgogICAgICAgIGNhc2UgIkRldmljZUNNWUsiOgogICAgICAgICAgcmV0dXJuIHRoaXMuc2luZ2xldG9ucy5jbXlrOwogICAgICAgIGNhc2UgIkNhbEdyYXkiOgogICAgICAgICAgcGFyYW1zID0geHJlZi5mZXRjaElmUmVmKGNzWzFdKTsKICAgICAgICAgIHdoaXRlUG9pbnQgPSBwYXJhbXMuZ2V0QXJyYXkoIldoaXRlUG9pbnQiKTsKICAgICAgICAgIGJsYWNrUG9pbnQgPSBwYXJhbXMuZ2V0QXJyYXkoIkJsYWNrUG9pbnQiKTsKICAgICAgICAgIGdhbW1hID0gcGFyYW1zLmdldCgiR2FtbWEiKTsKICAgICAgICAgIHJldHVybiBuZXcgQ2FsR3JheUNTKH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KTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChudW1Db21wcyA9PT0gMSkgewogICAgICAgICAgICByZXR1cm4gdGhpcy5zaW5nbGV0b25zLmdyYXk7CiAgICAgICAgICB9IGVsc2UgaWYgKG51bUNvbXBzID09PSAzKSB7CiAgICAgICAgICAgIHJldHVybiB0aGlzLnNpbmdsZXRvbnMucmdiOwogICAgICAgICAgfSBlbHNlIGlmIChudW1Db21wcyA9PT0gNCkgewogICAgICAgICAgICByZXR1cm4gdGhpcy5zaW5nbGV0b25zLmNteWs7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJQYXR0ZXJuIjoKICAgICAgICAgIGJhc2VDUyA9IGNzWzFdIHx8IG51bGw7CiAgICAgICAgICBpZiAoYmFzZUNTKSB7CiAgICAgICAgICAgIGJhc2VDUyA9IHRoaXMuX3BhcnNlKGJhc2VDUywgeHJlZiwgcmVzb3VyY2VzLCBwZGZGdW5jdGlvbkZhY3RvcnkpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG5ldyBQYXR0ZXJuQ1MoYmFzZUNTKTsKICAgICAgICBjYXNlICJJIjoKICAgICAgICBjYXNlICJJbmRleGVkIjoKICAgICAgICAgIGJhc2VDUyA9IHRoaXMuX3BhcnNlKGNzWzFdLCB4cmVmLCByZXNvdXJjZXMsIHBkZkZ1bmN0aW9uRmFjdG9yeSk7CiAgICAgICAgICBjb25zdCBoaVZhbCA9IHhyZWYuZmV0Y2hJZlJlZihjc1syXSkgKyAxOwogICAgICAgICAgY29uc3QgbG9va3VwID0geHJlZi5mZXRjaElmUmVmKGNzWzNdKTsKICAgICAgICAgIHJldHVybiBuZXcgSW5kZXhlZENTKGJhc2VDUywgaGlWYWwsIGxvb2t1cCk7CiAgICAgICAgY2FzZSAiU2VwYXJhdGlvbiI6CiAgICAgICAgY2FzZSAiRGV2aWNlTiI6CiAgICAgICAgICBjb25zdCBuYW1lID0geHJlZi5mZXRjaElmUmVmKGNzW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H0KICAgIGlmIChudW1Db21wcyAqIDIgIT09IGRlY29kZS5sZW5ndGgpIHsKICAgICAgKDAsIF91dGlsLndhcm4pKCJUaGUgZGVjb2RlIG1hcCBpcyBub3QgdGhlIGNvcnJlY3QgbGVuZ3RoIik7CiAgICAgIHJldHVybiB0cnVlOwogICAgfQogICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZGVjb2RlLmxlbmd0aDsgaSA8IGlpOyBpICs9IDIpIHsKICAgICAgaWYgKGRlY29kZVtpXSAhPT0gMCB8fCBkZWNvZGVbaSArIDFdICE9PSAxKSB7CiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gdHJ1ZTsKICB9CiAgc3RhdGljIGdldCBzaW5nbGV0b25zKCkgewogICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJzaW5nbGV0b25zIiwgewogICAgICBnZXQgZ3JheSgpIHsKICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgImdyYXkiLCBuZXcgRGV2aWNlR3JheUNTKCkpOwogICAgICB9LAogICAgICBnZXQgcmdiKCkgewogICAgICAgIHJldHVybiAoMCwgX3V0aWwuc2hhZG93KSh0aGlzLCAicmdiIiwgbmV3IERldmljZVJnYkNTKCkpOwogICAgICB9LAogICAgICBnZXQgY215aygpIHsKICAgICAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgImNteWsiLCBuZXcgRGV2aWNlQ215a0NTKCkpOwogICAgICB9CiAgICB9KTsKICB9Cn0KZXhwb3J0cy5Db2xvclNwYWNlID0gQ29sb3JTcGFjZTsKY2xhc3MgQWx0ZXJuYXRlQ1MgZXh0ZW5kcyBDb2xvclNwYWNlIHsKICBjb25zdHJ1Y3RvcihudW1Db21wcywgYmFzZSwgdGludEZuKSB7CiAgICBzdXBlcigiQWx0ZXJuYXRlIiwgbnVtQ29tcHMpOwogICAgdGhpcy5iYXNlID0gYmFzZTsK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GFzID0gZGVjb2RlKGFzLCBtYXhWYWwsIGNzLmFtaW4sIGNzLmFtYXgpOwogICAgICBicyA9IGRlY29kZShicywgbWF4VmFsLCBjcy5ibWluLCBjcy5ibWF4KTsKICAgIH0KICAgIGlmIChhcyA+IGNzLmFtYXgpIHsKICAgICAgYXMgPSBjcy5hbWF4OwogICAgfSBlbHNlIGlmIChhcyA8IGNzLmFtaW4pIHsKICAgICAgYXMgPSBjcy5hbWluOwogICAgfQogICAgaWYgKGJzID4gY3MuYm1heCkgewogICAgICBicyA9IGNzLmJtYXg7CiAgICB9IGVsc2UgaWYgKGJzIDwgY3MuYm1pbikgewogICAgICBicyA9IGNzLmJtaW47CiAgICB9CiAgICBjb25zdCBNID0gKExzICsgMTYpIC8gMTE2OwogICAgY29uc3QgTCA9IE0gKyBhcyAvIDUwMDsKICAgIGNvbnN0IE4gPSBNIC0gYnMgLyAyMDA7CiAgICBjb25zdCBYID0gY3MuWFcgKiBmbl9nKEwpOwogICAgY29uc3QgWSA9IGNzLllXICogZm5fZyhNKTsKICAgIGNvbnN0IFogPSBjcy5aVyAqIGZuX2coTik7CiAgICBsZXQgciwgZywgYjsKICAgIGlmIChjcy5aVyA8IDEpIHsKICAgICAgciA9IFggKiAzLjEzMzkgKyBZICogLTEuNjE3ICsgWiAqIC0wLjQ5MDY7CiAgICAgIGcgPSBYICogLTAuOTc4NSArIFkgKiAxLjkxNiArIFogKiAwLjAzMzM7CiAgICAgIGIgPSBYICogMC4wNzIgKyBZICogLTAuMjI5ICsgWiAqIDEuNDA1NzsKICAgIH0gZWxzZSB7CiAgICAgIHIgPSBYICogMy4yNDA2ICsgWSAqIC0xLjUzNzIgKyBaICogLTAuNDk4NjsKICAgICAgZyA9IFggKiAtMC45Njg5ICsgWSAqIDEuODc1OCArIFogKiAwLjA0MTU7CiAgICAgIGIgPSBYICogMC4wNTU3ICsgWSAqIC0wLjIwNCArIFogKiAxLjA1NzsKICAgIH0KICAgIGRlc3RbZGVzdE9mZnNldF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ICAgICgwLCBfdXRpbC53YXJuKShgVW5zdXBwb3J0ZWQgYmxlbmQgbW9kZSBBcnJheTogJHt2YWx1ZX1gKTsKICAgIHJldHVybiAic291cmNlLW92ZXIiOwogIH0KICBpZiAoISh2YWx1ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpKSB7CiAgICBpZiAocGFyc2luZ0FycmF5KSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgcmV0dXJuICJzb3VyY2Utb3ZlciI7CiAgfQogIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgY2FzZSAiTm9ybWFsIjoKICAgIGNhc2UgIkNvbXBhdGlibGUiOgogICAgICByZXR1cm4gInNvdXJjZS1vdmVyIjsKICAgIGNhc2UgIk11bHRpcGx5IjoKICAgICAgcmV0dXJuICJtdWx0aXBseSI7CiAgICBjYXNlICJTY3JlZW4iOgogICAgICByZXR1cm4gInNjcmVlbiI7CiAgICBjYXNlICJPdmVybGF5IjoKICAgICAgcmV0dXJuICJvdmVybGF5IjsKICAgIGNhc2UgIkRhcmtlbiI6CiAgICAgIHJldHVybiAiZGFya2VuIjsKICAgIGNhc2UgIkxpZ2h0ZW4iOgogICAgICByZXR1cm4gImxpZ2h0ZW4iOwogICAgY2FzZSAiQ29sb3JEb2RnZSI6CiAgICAgIHJldHVybiAiY29sb3ItZG9kZ2UiOwogICAgY2FzZSAiQ29sb3JCdXJuIjoKICAgICAgcmV0dXJuICJjb2xvci1idXJuIjsKICAgIGNhc2UgIkhhcmRMaWdodCI6CiAgICAgIHJldHVybiAiaGFyZC1saWdodCI7CiAgICBjYXNlICJTb2Z0TGlnaHQiOgogICAgICByZXR1cm4gInNvZnQtbGlnaHQiOwogICAgY2FzZSAiRGlmZmVyZW5jZSI6CiAgICAgIHJldHVybiAiZGlmZmVyZW5jZSI7CiAgICBjYXNlICJFeGNsdXNpb24iOgogICAgICByZXR1cm4gImV4Y2x1c2lvbiI7CiAgICBjYXNlICJIdWUiOgogICAgICBy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vKShgaGFzQmxlbmRNb2RlcyAtIGlnbm9yaW5nIEV4dEdTdGF0ZTogIiR7ZXh9Ii5gKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKCEoZ3JhcGhpY1N0YXRlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoZ3JhcGhpY1N0YXRlLm9iaklkKSB7CiAgICAgICAgICAgIHByb2Nlc3NlZC5wdXQoZ3JhcGhpY1N0YXRlLm9iaklkKTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IGJtID0gZ3JhcGhpY1N0YXRlLmdldCgiQk0iKTsKICAgICAgICAgIGlmIChibSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgaWYgKGJtLm5hbWUgIT09ICJOb3JtYWwiKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYm0gIT09IHVuZGVmaW5lZCAmJiBBcnJheS5pc0FycmF5KGJtKSkgewogICAgICAgICAgICBmb3IgKGNvbnN0IGVsZW1lbnQgb2YgYm0pIHsKICAgICAgICAgICAgICBpZiAoZWxlbWVudCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUgJiYgZWxlbWVudC5uYW1lICE9PSAiTm9ybWFsIikgewogICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIGNvbnN0IHhPYmplY3RzID0gbm9kZS5nZXQoIlhPYmplY3QiKTsKICAgICAgaWYgKCEoeE9iamVjdHMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGZvciAobGV0IHhPYmplY3Qgb2YgeE9iamVjdHMuZ2V0UmF3VmFsdWVzKCkpIHsKICAgICAgICBpZiAoeE9iamVjdCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgaWYgKHByb2Nlc3NlZC5oYXMoeE9iamVjdCkpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICB0cnkgewogICAgICAgICAgICB4T2JqZWN0ID0geHJlZi5mZXRjaCh4T2JqZWN0KTsKICAgICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICAgIHByb2Nlc3NlZC5wdXQoeE9iamVjdCk7CiAgICAgICAgICAgICgwLCBfdXRpbC5pbmZvKShgaGFzQmxlbmRNb2RlcyAtIGlnbm9yaW5nIFhPYmplY3Q6ICIke2V4fSIuYCk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoISh4T2JqZWN0IGluc3RhbmNlb2YgX2Jhc2Vfc3RyZWFtLkJhc2VTdHJlYW0pKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYgKHhPYmplY3QuZGljdC5vYmpJZCkgewogICAgICAgICAgcHJvY2Vzc2VkLnB1dCh4T2JqZWN0LmRpY3Qub2JqSWQpOwogICAgICAgIH0KICAgICAgICBjb25zdCB4UmVzb3VyY2VzID0geE9iamVjdC5kaWN0LmdldCgiUmVzb3VyY2VzIik7CiAgICAgICAgaWYgKCEoeFJlc291cmNlcyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYgKHhSZXNvdXJjZXMub2JqSWQgJiYgcHJvY2Vzc2VkLmhhcyh4UmVzb3VyY2VzLm9iaklkKSkgewogICAgICAgICAgY29udGludWU7Ci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mFsc2U7CiAgICAgICAgaWYgKGdyb3VwLmhhcygiQ1MiKSkgewogICAgICAgICAgY29uc3QgY3MgPSBncm91cC5nZXRSYXcoIkNTIik7CiAgICAgICAgICBjb25zdCBjYWNoZWRDb2xvclNwYWNlID0gX2NvbG9yc3BhY2UuQ29sb3JTcGFjZS5nZXRDYWNoZWQoY3MsIHRoaXMueHJlZiwgbG9jYWxDb2xvclNwYWNlQ2FjaGUpOwogICAgICAgICAgaWYgKGNhY2hlZENvbG9yU3BhY2UpIHsKICAgICAgICAgICAgY29sb3JTcGFjZSA9IGNhY2hlZENvbG9yU3BhY2U7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBjb2xvclNwYWNlID0gYXdhaXQgdGhpcy5wYXJzZUNvbG9yU3BhY2UoewogICAgICAgICAgICAgIGNzLAogICAgICAgICAgICAgIHJlc291cmNlcywKICAgICAgICAgICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKHNtYXNrICYmIHNtYXNrLmJhY2tkcm9wKSB7CiAgICAgICAgY29sb3JTcGFjZSA9IGNvbG9yU3BhY2UgfHwgX2NvbG9yc3BhY2UuQ29sb3JTcGFjZS5zaW5nbGV0b25zLnJnYjsKICAgICAgICBzbWFzay5iYWNrZHJvcCA9IGNvbG9yU3BhY2UuZ2V0UmdiKHNtYXNrLmJhY2tkcm9wLCAwKTsKICAgICAgfQogICAgICBvcGVyYXRvckxpc3QuYWRkT3AoX3V0aWwuT1BTLmJlZ2luR3JvdXAsIFtncm91cE9wdGlvbnNdKTsKICAgIH0KICAgIGNvbnN0IGFyZ3MgPSBncm91cCA/IFttYXRyaXgsIG51bGxdIDogW21hdHJpeCwgYmJveF07CiAgICBvcGVyYXRvckxpc3QuYWRkT3AoX3V0aWwuT1BTLnBhaW50Rm9ybVhPYmplY3RCZWdpbiwgYXJncyk7CiAgICByZXR1cm4gdGhpcy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KSB7CiAgICAgICAgICBsb2NhbEltYWdlQ2FjaGUuc2V0KGNhY2hlS2V5LCBpbWFnZVJlZiwgewogICAgICAgICAgICBmbjogX3V0aWwuT1BTLnBhaW50U29saWRDb2xvckltYWdlTWFzaywKICAgICAgICAgICAgYXJnczogW10sCiAgICAgICAgICAgIG9wdGlvbmFsQ29udGVudAogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBjb25zdCBvYmpJZCA9IGBtYXNrXyR7dGhpcy5pZEZhY3RvcnkuY3JlYXRlT2JqSWQoKX1gOwogICAgICBvcGVyYXRvckxpc3QuYWRkRGVwZW5kZW5jeShvYmpJZCk7CiAgICAgIHRoaXMuX3NlbmRJbWdEYXRhKG9iaklkLCBpbWdEYXRhKTsKICAgICAgYXJncyA9IFt7CiAgICAgICAgZGF0YTogb2JqSWQsCiAgICAgICAgd2lkdGg6IGltZ0RhdGEud2lkdGgsCiAgICAgICAgaGVpZ2h0OiBpbWdEYXRhLmhlaWdodCwKICAgICAgICBpbnRlcnBvbGF0ZTogaW1nRGF0YS5pbnRlcnBvbGF0ZSwKICAgICAgICBjb3VudDogMQogICAgICB9XTsKICAgICAgb3BlcmF0b3JMaXN0LmFkZEltYWdlT3BzKF91dGlsLk9QUy5wYWludEltYWdlTWFza1hPYmplY3QsIGFyZ3MsIG9wdGlvbmFsQ29udGVudCk7CiAgICAgIGlmIChjYWNoZUtleSkgewogICAgICAgIGxvY2FsSW1hZ2VDYWNoZS5zZXQoY2FjaGVLZXksIGltYWdlUmVmLCB7CiAgICAgICAgICBmbjogX3V0aWwuT1BTLnBhaW50SW1hZ2VNYXNrWE9iamVjdCwKICAgICAgICAgIGFyZ3MsCiAgICAgICAgICBvcHRpb25hbENvbnRlbnQKICAgICAgICB9KTsKICAgICAgfQogICAgICByZXR1cm47CiAgICB9CiAgICBjb25zdCBzb2Z0TWFzayA9IGRpY3QuZ2V0KCJTTSIsICJTTWFzayIpIHx8IGZhb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TCI6CiAgICAgICAgY2FzZSAiQ0EiOgogICAgICAgIGNhc2UgImNhIjoKICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIHZhbHVlXSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJGb250IjoKICAgICAgICAgIGlzU2ltcGxlR1N0YXRlID0gZmFsc2U7CiAgICAgICAgICBwcm9taXNlID0gcHJvbWlzZS50aGVuKCgpID0+IHsKICAgICAgICAgICAgcmV0dXJuIHRoaXMuaGFuZGxlU2V0Rm9udChyZXNvdXJjZXMsIG51bGwsIHZhbHVlWzBdLCBvcGVyYXRvckxpc3QsIHRhc2ssIHN0YXRlTWFuYWdlci5zdGF0ZSkudGhlbihmdW5jdGlvbiAobG9hZGVkTmFtZSkgewogICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGREZXBlbmRlbmN5KGxvYWRlZE5hbWUpOwogICAgICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIFtsb2FkZWROYW1lLCB2YWx1ZVsxXV1dKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkJNIjoKICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIG5vcm1hbGl6ZUJsZW5kTW9kZSh2YWx1ZSldKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIlNNYXNrIjoKICAgICAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKSh2YWx1ZSwgIk5vbmUiKSkgewogICAgICAgICAgICBnU3RhdGVPYmoucHVzaChba2V5LCBmYWxzZV0pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAgICAgICAgaXNTaW1wbGVHU3RhdGUgPSBmYWxzZTsKICAgICAgICAgICAgcHJvbWlzZSA9IHByb21pc2UudGhlbigoKSA9PiB7CiAgICAgICAgICAgICAgcmV0dXJuIHRoaXMuaGFuZGxlU01hc2sodmFsdWUsIHJlc291cmNlcywgb3BlcmF0b3JMaXN0LCB0YXNrLCBzdGF0ZU1hbmFnZXIsIGxvY2FsQ29sb3JTcGFjZUNhY2hlKTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIHRydWVdKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5zdXBwb3J0ZWQgU01hc2sgdHlwZSIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiVFIiOgogICAgICAgICAgY29uc3QgdHJhbnNmZXJNYXBzID0gdGhpcy5oYW5kbGVUcmFuc2ZlckZ1bmN0aW9uKHZhbHVlKTsKICAgICAgICAgIGdTdGF0ZU9iai5wdXNoKFtrZXksIHRyYW5zZmVyTWFwc10pOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiT1AiOgogICAgICAgIGNhc2UgIm9wIjoKICAgICAgICBjYXNlICJPUE0iOgogICAgICAgIGNhc2UgIkJHIjoKICAgICAgICBjYXNlICJCRzIiOgogICAgICAgIGNhc2UgIlVDUiI6CiAgICAgICAgY2FzZSAiVUNSMiI6CiAgICAgICAgY2FzZSAiVFIyIjoKICAgICAgICBjYXNlICJIVCI6CiAgICAgICAgY2FzZSAiU00iOgogICAgICAgIGNhc2UgIlNBIjoKICAgICAgICBjYXNlICJBSVMiOgogICAgICAgIGNhc2UgIlRLIjoKICAgICAgICAgICgwLCBfdXRpbC5pbmZvKSgiZ3JhcGhpYyBzdGF0ZSBvcGVyYXRvciAiICsga2V5KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoIlVua25vd24gZ3JhcGhpYyBzdGF0ZSBvcGVyYXRvciAiICs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CkgewogICAgICBpZiAoZm9udCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIGZvbnRSZWYgPSBmb250OwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBmb250UmVzID0gcmVzb3VyY2VzLmdldCgiRm9udCIpOwogICAgICBpZiAoZm9udFJlcykgewogICAgICAgIGZvbnRSZWYgPSBmb250UmVzLmdldFJhdyhmb250TmFtZSk7CiAgICAgIH0KICAgIH0KICAgIGlmICghZm9udFJlZikgewogICAgICBjb25zdCBwYXJ0aWFsTXNnID0gYEZvbnQgIiR7Zm9udE5hbWUgfHwgZm9udCAmJiBmb250LnRvU3RyaW5nKCl9IiBpcyBub3QgYXZhaWxhYmxlYDsKICAgICAgaWYgKCF0aGlzLm9wdGlvbnMuaWdub3JlRXJyb3JzICYmICF0aGlzLnBhcnNpbmdUeXBlM0ZvbnQpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYCR7cGFydGlhbE1zZ30uYCk7CiAgICAgICAgcmV0dXJuIGVycm9yRm9udCgpOwogICAgICB9CiAgICAgICgwLCBfdXRpbC53YXJuKShgJHtwYXJ0aWFsTXNnfSAtLSBhdHRlbXB0aW5nIHRvIGZhbGxiYWNrIHRvIGEgZGVmYXVsdCBmb250LmApOwogICAgICBpZiAoZmFsbGJhY2tGb250RGljdCkgewogICAgICAgIGZvbnRSZWYgPSBmYWxsYmFja0ZvbnREaWN0OwogICAgICB9IGVsc2UgewogICAgICAgIGZvbnRSZWYgPSBQYXJ0aWFsRXZhbHVhdG9yLmZhbGxiYWNrRm9udERpY3Q7CiAgICAgIH0KICAgIH0KICAgIGlmICh0aGlzLnBhcnNpbmdUeXBlM0ZvbnQgJiYgdGhpcy50eXBlM0ZvbnRSZWZzLmhhcyhmb250UmVmKSkgewogICAgICByZXR1cm4gZXJyb3JGb250KCk7CiAgICB9CiAgICBpZiAodGhpcy5mb250Q2FjaGUuaGFzKGZvbnRSZWYpKSB7CiAgICAgIHJldH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lwdG9yIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICBpZiAoIWRlc2NyaXB0b3IuZm9udEFsaWFzZXMpIHsKICAgICAgICBkZXNjcmlwdG9yLmZvbnRBbGlhc2VzID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgfQogICAgICBjb25zdCBmb250QWxpYXNlcyA9IGRlc2NyaXB0b3IuZm9udEFsaWFzZXM7CiAgICAgIGlmIChmb250QWxpYXNlc1toYXNoXSkgewogICAgICAgIGNvbnN0IGFsaWFzRm9udFJlZiA9IGZvbnRBbGlhc2VzW2hhc2hdLmFsaWFzUmVmOwogICAgICAgIGlmIChmb250UmVmSXNSZWYgJiYgYWxpYXNGb250UmVmICYmIHRoaXMuZm9udENhY2hlLmhhcyhhbGlhc0ZvbnRSZWYpKSB7CiAgICAgICAgICB0aGlzLmZvbnRDYWNoZS5wdXRBbGlhcyhmb250UmVmLCBhbGlhc0ZvbnRSZWYpOwogICAgICAgICAgcmV0dXJuIHRoaXMuZm9udENhY2hlLmdldChmb250UmVmKTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgZm9udEFsaWFzZXNbaGFzaF0gPSB7CiAgICAgICAgICBmb250SUQ6IHRoaXMuaWRGYWN0b3J5LmNyZWF0ZUZvbnRJZCgpCiAgICAgICAgfTsKICAgICAgfQogICAgICBpZiAoZm9udFJlZklzUmVmKSB7CiAgICAgICAgZm9udEFsaWFzZXNbaGFzaF0uYWxpYXNSZWYgPSBmb250UmVmOwogICAgICB9CiAgICAgIGZvbnRJRCA9IGZvbnRBbGlhc2VzW2hhc2hdLmZvbnRJRDsKICAgIH0KICAgIGlmIChmb250UmVmSXNSZWYpIHsKICAgICAgdGhpcy5mb250Q2FjaGUucHV0KGZvbnRSZWYsIGZvbnRDYXBhYmlsaXR5LnByb21pc2UpOwogICAgfSBlbHNlIHsKICAgICAgaWYgKCFmb250SUQpIHsKICAgICAgICBmb250SUQgPSB0aGlzLm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ChhcmdzWzFdLCB5KV07CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIF91dGlsLk9QUy5tb3ZlVG86CiAgICAgICAgY2FzZSBfdXRpbC5PUFMubGluZVRvOgogICAgICAgICAgbWluTWF4ID0gW2FyZ3NbMF0sIGFyZ3NbMF0sIGFyZ3NbMV0sIGFyZ3NbMV1dOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIG1pbk1heCA9IFtJbmZpbml0eSwgLUluZmluaXR5LCBJbmZpbml0eSwgLUluZmluaXR5XTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIG9wZXJhdG9yTGlzdC5hZGRPcChfdXRpbC5PUFMuY29uc3RydWN0UGF0aCwgW1tmbl0sIGFyZ3MsIG1pbk1heF0pOwogICAgICBpZiAocGFyc2luZ1RleHQpIHsKICAgICAgICBvcGVyYXRvckxpc3QuYWRkT3AoX3V0aWwuT1BTLnJlc3RvcmUsIG51bGwpOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBvcEFyZ3MgPSBvcGVyYXRvckxpc3QuYXJnc0FycmF5W2xhc3RJbmRleF07CiAgICAgIG9wQXJnc1swXS5wdXNoKGZuKTsKICAgICAgb3BBcmdzWzFdLnB1c2goLi4uYXJncyk7CiAgICAgIGNvbnN0IG1pbk1heCA9IG9wQXJnc1syXTsKICAgICAgc3dpdGNoIChmbikgewogICAgICAgIGNhc2UgX3V0aWwuT1BTLnJlY3RhbmdsZToKICAgICAgICAgIGNvbnN0IHggPSBhcmdzWzBdICsgYXJnc1syXTsKICAgICAgICAgIGNvbnN0IHkgPSBhcmdzWzFdICsgYXJnc1szXTsKICAgICAgICAgIG1pbk1heFswXSA9IE1hdGgubWluKG1pbk1heFswXSwgYXJnc1swXSwgeCk7CiAgICAgICAgICBtaW5NYXhbMV0gPSBNYXRoLm1heChtaW5NYXhbMV0sIGFyZ3NbMF0sIHgpOwogICAgICAgICAgbWluTWF4WzJdID0gTWF0aC5taW4obWluTWF4WzJdLCBhcmdzWzFdLCB5KTsKICAgICAgICAgIG1pbk1heFszXSA9IE1hdGgubWF4KG1pbk1heFszXSwgYXJnc1sxXSwgeSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIF91dGlsLk9QUy5tb3ZlVG86CiAgICAgICAgY2FzZSBfdXRpbC5PUFMubGluZVRvOgogICAgICAgICAgbWluTWF4WzBdID0gTWF0aC5taW4obWluTWF4WzBdLCBhcmdzWzBdKTsKICAgICAgICAgIG1pbk1heFsxXSA9IE1hdGgubWF4KG1pbk1heFsxXSwgYXJnc1swXSk7CiAgICAgICAgICBtaW5NYXhbMl0gPSBNYXRoLm1pbihtaW5NYXhbMl0sIGFyZ3NbMV0pOwogICAgICAgICAgbWluTWF4WzNdID0gTWF0aC5tYXgobWluTWF4WzNdLCBhcmdzWzFdKTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgfQogIHBhcnNlQ29sb3JTcGFjZShfcmVmNCkgewogICAgbGV0IHsKICAgICAgY3MsCiAgICAgIHJlc291cmNlcywKICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUKICAgIH0gPSBfcmVmNDsKICAgIHJldHVybiBfY29sb3JzcGFjZS5Db2xvclNwYWNlLnBhcnNlQXN5bmMoewogICAgICBjcywKICAgICAgeHJlZjogdGhpcy54cmVmLAogICAgICByZXNvdXJjZXMsCiAgICAgIHBkZkZ1bmN0aW9uRmFjdG9yeTogdGhpcy5fcGRmRnVuY3Rpb25GYWN0b3J5LAogICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgfSkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0KICAgICAgaWYgKHRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAoMCwgX3V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yYXRvci5uYW1lKTsKICAgICAgICBicmVhazsKICAgICAgZGVmYXVsdDoKICAgICAgICAoMCwgX3V0aWwud2FybikoYEludmFsaWQgb3BlcmF0b3IgJHtvcGVyYXRvci5uYW1lfSBpbiB2aXNpYmlsaXR5IGV4cHJlc3Npb25gKTsKICAgICAgICByZXR1cm47CiAgICB9CiAgICBmb3IgKGxldCBpID0gMTsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIGNvbnN0IHJhdyA9IGFycmF5W2ldOwogICAgICBjb25zdCBvYmplY3QgPSB0aGlzLnhyZWYuZmV0Y2hJZlJlZihyYXcpOwogICAgICBpZiAoQXJyYXkuaXNBcnJheShvYmplY3QpKSB7CiAgICAgICAgY29uc3QgbmVzdGVkUmVzdWx0ID0gW107CiAgICAgICAgY3VycmVudFJlc3VsdC5wdXNoKG5lc3RlZFJlc3VsdCk7CiAgICAgICAgdGhpcy5fcGFyc2VWaXNpYmlsaXR5RXhwcmVzc2lvbihvYmplY3QsIG5lc3RpbmdDb3VudGVyLCBuZXN0ZWRSZXN1bHQpOwogICAgICB9IGVsc2UgaWYgKHJhdyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIGN1cnJlbnRSZXN1bHQucHVzaChyYXcudG9TdHJpbmcoKSk7CiAgICAgIH0KICAgIH0KICB9CiAgYXN5bmMgcGFyc2VNYXJrZWRDb250ZW50UHJvcHMoY29udGVudFByb3BlcnRpZXMsIHJlc291cmNlcykgewogICAgbGV0IG9wdGlvbmFsQ29udGVudDsKICAgIGlmIChjb250ZW50UHJvcGVydGllcyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgY29uc3QgcHJvcGVydGllcyA9IHJlc291cmNlcy5nZXQoIlByb3BlcnRpZXMiKTsKICAgICAgb3B0aW9uYWxDb250ZW50ID0gcHJvcGVydGllcy5nZXQoY29udGVudFByb3BlcnRpZXMubmFtZSk7CiAgICB9IGVsc2UgaWYgKGNvbnRlbnRQcm9wZXJ0aWVzIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICBvcHRpb25hbENvbnRlbnQgPSBjb250ZW50UHJvcGVydGllczsKICAgIH0gZWxzZSB7CiAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiT3B0aW9uYWwgY29udGVudCBwcm9wZXJ0aWVzIG1hbGZvcm1lZC4iKTsKICAgIH0KICAgIGNvbnN0IG9wdGlvbmFsQ29udGVudFR5cGUgPSBvcHRpb25hbENvbnRlbnQuZ2V0KCJUeXBlIikubmFtZTsKICAgIGlmIChvcHRpb25hbENvbnRlbnRUeXBlID09PSAiT0NHIikgewogICAgICByZXR1cm4gewogICAgICAgIHR5cGU6IG9wdGlvbmFsQ29udGVudFR5cGUsCiAgICAgICAgaWQ6IG9wdGlvbmFsQ29udGVudC5vYmpJZAogICAgICB9OwogICAgfSBlbHNlIGlmIChvcHRpb25hbENvbnRlbnRUeXBlID09PSAiT0NNRCIpIHsKICAgICAgY29uc3QgZXhwcmVzc2lvbiA9IG9wdGlvbmFsQ29udGVudC5nZXQoIlZFIik7CiAgICAgIGlmIChBcnJheS5pc0FycmF5KGV4cHJlc3Npb24pKSB7CiAgICAgICAgY29uc3QgcmVzdWx0ID0gW107CiAgICAgICAgdGhpcy5fcGFyc2VWaXNpYmlsaXR5RXhwcmVzc2lvbihleHByZXNzaW9uLCAwLCByZXN1bHQpOwogICAgICAgIGlmIChyZXN1bHQubGVuZ3RoID4gMCkgewogICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgdHlwZTogIk9DTUQiLAogICAgICAgICAgICBleHByZXNzaW9uOiByZXN1bHQKICAgICAgICAgIH07CiAgICAgICAgfQogICAgICB9CiAgICAgIGNvbnN0IG9wdGlvbmFsQ29udGVudEdyb3VwcyA9IG9wdGlvbmFsQ29udGVudC5nZXQoIk9DR3MiKTsKICAgICAgaWYgKEFycmF5LmlzQXJyYXkob3B0aW9uYWxDb250ZW50R3JvdXBzKSB8fCBvcHRpb25hbENvbnRlbnRHcm91cHMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSB7CiAgICAgICAgY29uc3QgZ3JvdXBJZHMgPSBbXTsKICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShvcHRpb25hbENvbnRlbnRHcm91cHMpKSB7CiAgICAgICAgICBmb3IgKGNvbnN0IG9jZyBvZiBvcHRpb25hbENvbnRlbnRHcm91cHMpIHsKICAgICAgICAgICAgZ3JvdXBJZHMucHVzaChvY2cudG9TdHJpbmcoKSk7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGdyb3VwSWRzLnB1c2gob3B0aW9uYWxDb250ZW50R3JvdXBzLm9iaklkKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIHR5cGU6IG9wdGlvbmFsQ29udGVudFR5cGUsCiAgICAgICAgICBpZHM6IGdyb3VwSWRzLAogICAgICAgICAgcG9saWN5OiBvcHRpb25hbENvbnRlbnQuZ2V0KCJQIikgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lID8gb3B0aW9uYWxDb250ZW50LmdldCgiUCIpLm5hbWUgOiBudWxsLAogICAgICAgICAgZXhwcmVzc2lvbjogbnVsbAogICAgICAgIH07CiAgICAgIH0gZWxzZSBpZiAob3B0aW9uYWxDb250ZW50R3JvdXBzIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmKSB7CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIHR5cGU6IG9wdGlvbmFsQ29udGVudFR5cGUsCiAgICAgICAgICBpZDogb3B0aW9uYWxDb250ZW50R3JvdXBzLnRvU3RyaW5nKCkKICAgICAgICB9OwogICAgICB9CiAgICB9CiAgICByZXR1cm4gbnVsbDsKICB9CiAgZ2V0T3BlcmF0b3JMaXN0KF9yZWY2KSB7CiAgICBsZXQgewogICAgICBzdHJlYW0sCiAgICAgIHRhc2ssCiA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YWdlci5yZXNldCgpOwogICAgICBjb25zdCBvcGVyYXRpb24gPSB7fTsKICAgICAgbGV0IHN0b3AsIGksIGlpLCBjcywgbmFtZSwgaXNWYWxpZE5hbWU7CiAgICAgIHdoaWxlICghKHN0b3AgPSB0aW1lU2xvdE1hbmFnZXIuY2hlY2soKSkpIHsKICAgICAgICBvcGVyYXRpb24uYXJncyA9IG51bGw7CiAgICAgICAgaWYgKCFwcmVwcm9jZXNzb3IucmVhZChvcGVyYXRpb24pKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgbGV0IGFyZ3MgPSBvcGVyYXRpb24uYXJnczsKICAgICAgICBsZXQgZm4gPSBvcGVyYXRpb24uZm47CiAgICAgICAgc3dpdGNoIChmbiB8IDApIHsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnBhaW50WE9iamVjdDoKICAgICAgICAgICAgaXNWYWxpZE5hbWUgPSBhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZTsKICAgICAgICAgICAgbmFtZSA9IGFyZ3NbMF0ubmFtZTsKICAgICAgICAgICAgaWYgKGlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgY29uc3QgbG9jYWxJbWFnZSA9IGxvY2FsSW1hZ2VDYWNoZS5nZXRCeU5hbWUobmFtZSk7CiAgICAgICAgICAgICAgaWYgKGxvY2FsSW1hZ2UpIHsKICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRJbWFnZU9wcyhsb2NhbEltYWdlLmZuLCBsb2NhbEltYWdlLmFyZ3MsIGxvY2FsSW1hZ2Uub3B0aW9uYWxDb250ZW50KTsKICAgICAgICAgICAgICAgIGluY3JlbWVudENhY2hlZEltYWdlTWFza0NvdW50KGxvY2FsSW1hZ2UpOwogICAgICAgICAgICAgICAgYXJncyA9IG51bGw7CiAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbmV4dChuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZVhPYmplY3QsIHJlamVjdFhPYmplY3QpIHsKICAgICAgICAgICAgICBpZiAoIWlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlhPYmplY3QgbXVzdCBiZSByZWZlcnJlZCB0byBieSBuYW1lLiIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBsZXQgeG9iaiA9IHhvYmpzLmdldFJhdyhuYW1lKTsKICAgICAgICAgICAgICBpZiAoeG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICAgICAgY29uc3QgbG9jYWxJbWFnZSA9IGxvY2FsSW1hZ2VDYWNoZS5nZXRCeVJlZih4b2JqKTsKICAgICAgICAgICAgICAgIGlmIChsb2NhbEltYWdlKSB7CiAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRJbWFnZU9wcyhsb2NhbEltYWdlLmZuLCBsb2NhbEltYWdlLmFyZ3MsIGxvY2FsSW1hZ2Uub3B0aW9uYWxDb250ZW50KTsKICAgICAgICAgICAgICAgICAgaW5jcmVtZW50Q2FjaGVkSW1hZ2VNYXNrQ291bnQobG9jYWxJbWFnZSk7CiAgICAgICAgICAgICAgICAgIHJlc29sdmVYT2JqZWN0KCk7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbnN0IGdsb2JhbEltYWdlID0gc2VsZi5nbG9iYWxJbWFnZUNhY2hlLmdldERhdGEoeG9iaiwgc2VsZi5wYWdlSW5kZXgpOwogICAgICAgICAgICAgICAgaWYgKGdsb2JhbEltYWdlKSB7CiAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGREZXBlbmRlbmN5KGdsb2JhbEltYWdlLm9iaklkKTsKICAgICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZEltYWdlT3BzKGdsb2JhbEltYWdlLmZuLCBnbG9iYWxJbWFnZS5hcmdzLCBnbG9iYWxJbWFnZS5vcHRpb25hbENvbnRlbnQpOwogICAgICAgICAgICAgICAgICByZXNvbHZlWE9iamVjdCgpOwogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB4b2JqID0geHJlZi5mZXRjaCh4b2JqKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKCEoeG9iaiBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSkgewogICAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJYT2JqZWN0IHNob3VsZCBiZSBhIHN0cmVhbSIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb25zdCB0eXBlID0geG9iai5kaWN0LmdldCgiU3VidHlwZSIpOwogICAgICAgICAgICAgIGlmICghKHR5cGUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSkgewogICAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJYT2JqZWN0IHNob3VsZCBoYXZlIGEgTmFtZSBzdWJ0eXBlIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmICh0eXBlLm5hbWUgPT09ICJGb3JtIikgewogICAgICAgICAgICAgICAgc3RhdGVNYW5hZ2VyLnNhdmUoKTsKICAgICAgICAgICAgICAgIHNlbGYuYnVpbGRGb3JtWE9iamVjdChyZXNvdXJjZXMsIHhvYmosIG51bGwsIG9wZXJhdG9yTGlzdCwgdGFzaywgc3RhdGVNYW5hZ2VyLnN0YXRlLmNsb25lKCksIGxvY2FsQ29sb3JTcGFjZUNhY2hlKS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgICAgICAgICAgc3RhdGVNYW5hZ2VyLnJlc3RvcmUoKTsKICAgICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgIH0sIHJlamVjdFhPYmplY3QpOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZS5uYW1lID09PSAiSW1hZ2UiKSB7CiAgICAgICAgICAgICAgICBzZWxmLmJ1aWxkUGFpbnRJbWFnZVhPYmplY3QoewogICAgICAgICAgICAgICAgICByZXNvdXJjZXMsCiAgICAgICAgICAgICAgICAgIGltYWdlOiB4b2JqLAogICAgICAgICAgICAgICAgICBvcGVyYXRvckxpc3QsCiAgICAgICAgICAgICAgICAgIGNhY2hlS2V5OiBuYW1lLAogICAgICAgICAgICAgICAgICBsb2NhbEltYWdlQ2FjaGUsCiAgICAgICAgICAgICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgICAgICAgICAgICB9KS50aGVuKHJlc29sdmVYT2JqZWN0LCByZWplY3RYT2JqZWN0KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9IGVsc2UgaWYgKHR5cGUubmFtZSA9PT0gIlBTIikgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJJZ25vcmVkIFhPYmplY3Qgc3VidHlwZSBQUyIpOwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYFVuaGFuZGxlZCBYT2JqZWN0IHN1YnR5cGUgJHt0eXBlLm5hbWV9YCk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHJlc29sdmVYT2JqZWN0KCk7CiAgICAgICAgICAgIH0pLmNhdGNoKGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICBpZiAocmVhc29uIGluc3RhbmNlb2YgX3V0aWwuQWJvcnRFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHNlbGYub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0T3BlcmF0b3JMaXN0IC0gaWdub3JpbmcgWE9iamVjdDogIiR7cmVhc29ufSIuYCk7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHRocm93IHJlYXNvbjsKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zZXRGb250OgogICAgICAgICAgICB2YXIgZm9udFNpemUgPSBhcmdzWzFdOwogICAgICAgICAgICBuZXh0KHNlbGYuaGFuZGxlU2V0Rm9udChyZXNvdXJjZXMsIGFyZ3MsIG51bGwsIG9wZXJhdG9yTGlzdCwgdGFzaywgc3RhdGVNYW5hZ2VyLnN0YXRlLCBmYWxsYmFja0ZvbnREaWN0KS50aGVuKGZ1bmN0aW9uIChsb2FkZWROYW1lKSB7CiAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZERlcGVuZGVuY3kobG9hZGVkTmFtZSk7CiAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZE9wKF91dGlsLk9QUy5zZXRGb250LCBbbG9hZGVkTmFtZSwgZm9udFNpemVdKTsKICAgICAgICAgICAgfSkpOwogICAgICAgICAgICByZXR1cm47CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5iZWdpblRleHQ6CiAgICAgICAgICAgIHBhcnNpbmdUZXh0ID0gdHJ1ZTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5lbmRUZXh0OgogICAgICAgICAgICBwYXJzaW5nVGV4dCA9IGZhbHNlOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmVuZElubGluZUltYWdlOgogICAgICAgICAgICB2YXIgY2FjaGVLZXkgPSBhcmdzWzBdLmNhY2hlS2V5OwogICAgICAgICAgICBpZiAoY2FjaGVLZXkpIHsKICAgICAgICAgICAgICBjb25zdCBsb2NhbEltYWdlID0gbG9jYWxJbWFnZUNhY2hlLmdldEJ5TmFtZShjYWNoZUtleSk7CiAgICAgICAgICAgICAgaWYgKGxvY2FsSW1hZ2UpIHsKICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRJbWFnZU9wcyhsb2NhbEltYWdlLmZuLCBsb2NhbEltYWdlLmFyZ3MsIGxvY2FsSW1hZ2Uub3B0aW9uYWxDb250ZW50KTsKICAgICAgICAgICAgICAgIGluY3JlbWVudENhY2hlZEltYWdlTWFza0NvdW50KGxvY2FsSW1hZ2UpOwogICAgICAgICAgICAgICAgYXJncyA9IG51bGw7CiAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbmV4dChzZWxmLmJ1aWxkUGFpbnRJbWFnZVhPYmplY3QoewogICAgICAgICAgICAgIHJlc291cmNlcywKICAgICAgICAgICAgICBpbWFnZTogYXJnc1swXSwKICAgICAgICAgICAgICBpc0lubGluZTogdHJ1ZSwKICAgICAgICAgICAgICBvcGVyYXRvckxpc3QsCiAgICAgICAgICAgICAgY2FjaGVLZXksCiAgICAgICAgICAgICAgbG9jYWxJbWFnZUNhY2hlLAogICAgICAgICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2hvd1RleHQ6CiAgICAgICAgICAgIGlmICghc3RhdGVNYW5hZ2VyLnN0YXRlLmZvbnQpIHsKICAgICAgICAgICAgICBzZWxmLmVuc3VyZVN0YXRlRm9udChzdGF0ZU1hbmFnZXIuc3RhdGUpOwogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGFyZ3NbMF0gPSBzZWxmLmhhbmRsZVRleHQoYXJnc1swXSwgc3RhdGVNYW5hZ2VyLnN0YXRlKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zaG93U3BhY2VkVGV4dDoKICAgICAgICAgICAgaWYgKCFzdGF0ZU1hbmFnZXIuc3RhdGUuZm9udCkgewogICAgICAgICAgICAgIHNlbGYuZW5zdXJlU3RhdGVGb250KHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdmFyIGNvbWJpbmVkR2x5cGhzID0gW107CiAgICAgICAgICAgIHZhciBzdGF0ZSA9IHN0YXRlTWFuYWdlci5zdGF0ZTsKICAgICAgICAgICAgZm9yIChjb25zdCBhcnJJdGVtIG9mIGFyZ3NbMF0pIHsKICAgICAgICAgICAgICBpZiAodHlwZW9mIGFyckl0ZW0gPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICBjb21iaW5lZEdseXBocy5wdXNoKC4uLnNlbGYuaGFuZGxlVGV4dChhcnJJdGVtLCBzdGF0ZSkpOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIGFyckl0ZW0gPT09ICJudW1iZXIiKSB7CiAgICAgICAgICAgICAgICBjb21iaW5lZEdseXBocy5wdXNoKGFyckl0ZW0pOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBhcmdzWzBdID0gY29tYmluZWRHbHlwaHM7CiAgICAgICAgICAgIGZuID0gX3V0aWwuT1BTLnNob3dUZXh0OwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLm5leHRMaW5lU2hvd1RleHQ6CiAgICAgICAgICAgIGlmICghc3RhdGVNYW5hZ2VyLnN0YXRlLmZvbnQpIHsKICAgICAgICAgICAgICBzZWxmLmVuc3VyZVN0YXRlRm9udChzdGF0ZU1hbmFnZXIuc3RhdGUpOwogICAgICA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IGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0RmlsbENvbG9yU3BhY2U6CiAgICAgICAgICAgIHsKICAgICAgICAgICAgICBjb25zdCBjYWNoZWRDb2xvclNwYWNlID0gX2NvbG9yc3BhY2UuQ29sb3JTcGFjZS5nZXRDYWNoZWQoYXJnc1swXSwgeHJlZiwgbG9jYWxDb2xvclNwYWNlQ2FjaGUpOwogICAgICAgICAgICAgIGlmIChjYWNoZWRDb2xvclNwYWNlKSB7CiAgICAgICAgICAgICAgICBzdGF0ZU1hbmFnZXIuc3RhdGUuZmlsbENvbG9yU3BhY2UgPSBjYWNoZWRDb2xvclNwYWNlOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIG5leHQoc2VsZi5wYXJzZUNvbG9yU3BhY2UoewogICAgICAgICAgICAgICAgY3M6IGFyZ3NbMF0sCiAgICAgICAgICAgICAgICByZXNvdXJjZXMsCiAgICAgICAgICAgICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgICAgICAgICAgIH0pLnRoZW4oZnVuY3Rpb24gKGNvbG9yU3BhY2UpIHsKICAgICAgICAgICAgICAgIGlmIChjb2xvclNwYWNlKSB7CiAgICAgICAgICAgICAgICAgIHN0YXRlTWFuYWdlci5zdGF0ZS5maWxsQ29sb3JTcGFjZSA9IGNvbG9yU3BhY2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0U3Ryb2tlQ29sb3JTcGFjZToKICAgICAgICAgICAgewogICAgICAgICAgICAgIGNvbnN0IGNhY2hlZENvbG9yU3BhY2UgPSBfY29sb3JzcGFjZS5Db2xvclNwYWNlLmdldENhY2hlZChhcmdzWzBdLCB4cmVmLCBsb2NhbENvbG9yU3BhY2VDYWNoZSk7CiAgICAgICAgICAgICAgaWYgKGNhY2hlZENvbG9yU3BhY2UpIHsKICAgICAgICAgICAgICAgIHN0YXRlTWFuYWdlci5zdGF0ZS5zdHJva2VDb2xvclNwYWNlID0gY2FjaGVkQ29sb3JTcGFjZTsKICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBuZXh0KHNlbGYucGFyc2VDb2xvclNwYWNlKHsKICAgICAgICAgICAgICAgIGNzOiBhcmdzWzBdLAogICAgICAgICAgICAgICAgcmVzb3VyY2VzLAogICAgICAgICAgICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUKICAgICAgICAgICAgICB9KS50aGVuKGZ1bmN0aW9uIChjb2xvclNwYWNlKSB7CiAgICAgICAgICAgICAgICBpZiAoY29sb3JTcGFjZSkgewogICAgICAgICAgICAgICAgICBzdGF0ZU1hbmFnZXIuc3RhdGUuc3Ryb2tlQ29sb3JTcGFjZSA9IGNvbG9yU3BhY2U7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0RmlsbENvbG9yOgogICAgICAgICAgICBjcyA9IHN0YXRlTWFuYWdlci5zdGF0ZS5maWxsQ29sb3JTcGFjZTsKICAgICAgICAgICAgYXJncyA9IGNzLmdldFJnYihhcmdzLCAwKTsKICAgICAgICAgICAgZm4gPSBfdXRpbC5PUFMuc2V0RmlsbFJHQkNvbG9yOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFN0cm9rZUNvbG9yOgogICAgICAgICAgICBjcyA9IHN0YXRlTWFuYWdlci5zdGF0ZS5zdHJva2VDb2xvclNwYWNlOwogICAgICAgICAgICBhcmdzID0gY3MuZ2V0UmdiKGFyZ3MsIDApOwogICAgICAgICAgICBmbiA9IF91dGlsLk9QUy5zZXRTdHJva2VSR0JDb2xvcjsKICAgICA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ZpbGw6CiAgICAgICAgICAgIHZhciBzaGFkaW5nUmVzID0gcmVzb3VyY2VzLmdldCgiU2hhZGluZyIpOwogICAgICAgICAgICBpZiAoIXNoYWRpbmdSZXMpIHsKICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIk5vIHNoYWRpbmcgcmVzb3VyY2UgZm91bmQiKTsKICAgICAgICAgICAgfQogICAgICAgICAgICB2YXIgc2hhZGluZyA9IHNoYWRpbmdSZXMuZ2V0KGFyZ3NbMF0ubmFtZSk7CiAgICAgICAgICAgIGlmICghc2hhZGluZykgewogICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiTm8gc2hhZGluZyBvYmplY3QgZm91bmQiKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBwYXR0ZXJuSWQgPSBzZWxmLnBhcnNlU2hhZGluZyh7CiAgICAgICAgICAgICAgc2hhZGluZywKICAgICAgICAgICAgICByZXNvdXJjZXMsCiAgICAgICAgICAgICAgbG9jYWxDb2xvclNwYWNlQ2FjaGUsCiAgICAgICAgICAgICAgbG9jYWxTaGFkaW5nUGF0dGVybkNhY2hlCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBhcmdzID0gW3BhdHRlcm5JZF07CiAgICAgICAgICAgIGZuID0gX3V0aWwuT1BTLnNoYWRpbmdGaWxsOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEdTdGF0ZToKICAgICAgICAgICAgaXNWYWxpZE5hbWUgPSBhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZTsKICAgICAgICAgICAgbmFtZSA9IGFyZ3NbMF0ubmFtZTsKICAgICAgICAgICAgaWYgKGlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgY29uc3QgbG9jYWxHU3RhdGVPYmogPSBsb2NhbEdTdGF0ZUNhY2hlLmdldEJ5TmFtZShuYW1lKTsKICAgICAgICAgICAgICBpZiAobG9jYWxHU3RhdGVPYmopIHsKICAgICAgICAgICAgICAgIGlmIChsb2NhbEdTdGF0ZU9iai5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdC5hZGRPcChfdXRpbC5PUFMuc2V0R1N0YXRlLCBbbG9jYWxHU3RhdGVPYmpdKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGFyZ3MgPSBudWxsOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIG5leHQobmV3IFByb21pc2UoZnVuY3Rpb24gKHJlc29sdmVHU3RhdGUsIHJlamVjdEdTdGF0ZSkgewogICAgICAgICAgICAgIGlmICghaXNWYWxpZE5hbWUpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiR1N0YXRlIG11c3QgYmUgcmVmZXJyZWQgdG8gYnkgbmFtZS4iKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgZXh0R1N0YXRlID0gcmVzb3VyY2VzLmdldCgiRXh0R1N0YXRlIik7CiAgICAgICAgICAgICAgaWYgKCEoZXh0R1N0YXRlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiRXh0R1N0YXRlIHNob3VsZCBiZSBhIGRpY3Rpb25hcnkuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNvbnN0IGdTdGF0ZSA9IGV4dEdTdGF0ZS5nZXQobmFtZSk7CiAgICAgICAgICAgICAgaWYgKCEoZ1N0YXRlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiR1N0YXRlIHNob3VsZCBiZSBhIGRpY3Rpb25hcnkuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNlbGYuc2V0R1N0YXRlKHsKICAgICAgICAgICAgICAgIHJlc291cmNlcywKICAgICAgICAgICAgICAgIGdTdGF0ZSwKICAgICAgICAgICAgICAgIG9wZXJhdG9yTGlzdCwKICAgICAgICAgICAgICAgIGNhY2hlS2V5OiBuYW1lLAogICAgICAgICAgICAgICAgdGFzaywKICAgICAgICAgICAgICAgIHN0YXRlTWFuYWdlciwKICAgICAgICAgICAgICAgIGxvY2FsR1N0YXRlQ2FjaGUsCiAgICAgICAgICAgICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgICAgICAgICAgIH0pLnRoZW4ocmVzb2x2ZUdTdGF0ZSwgcmVqZWN0R1N0YXRlKTsKICAgICAgICAgICAgfSkuY2F0Y2goZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgICAgIGlmIChyZWFzb24gaW5zdGFuY2VvZiBfdXRpbC5BYm9ydEV4Y2VwdGlvbikgewogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAoc2VsZi5vcHRpb25zLmlnbm9yZUVycm9ycykgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBnZXRPcGVyYXRvckxpc3QgLSBpZ25vcmluZyBFeHRHU3RhdGU6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMubW92ZVRvOgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMubGluZVRvOgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY3VydmVUbzoKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmN1cnZlVG8yOgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuY3VydmVUbzM6CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5jbG9zZVBhdGg6CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5yZWN0YW5nbGU6CiAgICAgICAgICAgIHNlbGYuYnVpbGRQYXRoKG9wZXJhdG9yTGlzdCwgZm4sIGFyZ3MsIHBhcnNpbmdUZXh0KTsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tYXJrUG9pbnQ6CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tYXJrUG9pbnRQcm9wczoKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmJlZ2luQ29tcGF0OgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kQ29tcGF0OgogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLmJlZ2luTWFya2VkQ29udGVudFByb3BzOgogICAgICAgICAgICBpZiAoIShhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkpIHsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYEV4cGVjdGVkIG5hbWUgZm9yIGJlZ2luTWFya2VkQ29udGVudFByb3BzIGFyZzA9JHthcmdzWzBdfWApOwogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChhcmdzWzBdLm5hbWUgPT09ICJPQyIpIHsKICAgICAgICAgICAgICBuZXh0KHNlbGYucGFyc2VNYXJrZWRDb250ZW50UHJvcHMoYXJnc1sxXSwgcmVzb3VyY2VzKS50aGVuKGRhdGEgPT4gewogICAgICAgICAgICAgICAgb3BlcmF0b3JMaXN0LmFkZE9wKF91dGlsLk9QUy5iZWdpbk1hcmtlZENvbnRlbnRQcm9wcywgWyJPQyIsIGRhdGFdKTsKICAgICAgICAgICAgICB9KS5jYXRjaChyZWFzb24gPT4gewogICAgICAgICAgICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChzZWxmLm9wdGlvbnMuaWdub3JlRXJyb3JzKSB7CiAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0T3BlcmF0b3JMaXN0IC0gaWdub3JpbmcgYmVnaW5NYXJrZWRDb250ZW50UHJvcHM6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgICAgfSkpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBhcmdzID0gW2FyZ3NbMF0ubmFtZSwgYXJnc1sxXSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QgPyBhcmdzWzFdLmdldCgiTUNJRCIpIDogbnVsbF07CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuYmVnaW5NYXJrZWRDb250ZW50OgogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kTWFya2VkQ29udGVudDoKICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIGlmIChhcmdzICE9PSBudWxsKSB7CiAgICAgICAgICAgICAgZm9yIChpID0gMCwgaWkgPSBhcmdzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgICAgICAgIGlmIChhcmdzW2ldIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKGkgPCBpaSkgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJnZXRPcGVyYXRvckxpc3QgLSBpZ25vcmluZyBvcGVyYXRvcjogIiArIGZuKTsKICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBvcGVyYXRvckxpc3QuYWRkT3AoZm4sIGFyZ3MpOwogICAgICB9CiAgICAgIGlmIChzdG9wKSB7CiAgICAgICAgbmV4dChkZWZlcnJlZCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGNsb3NlUGVuZGluZ1Jlc3RvcmVPUFMoKTsKICAgICAgcmVzb2x2ZSgpOwogICAgfSkuY2F0Y2gocmVhc29uID0+IHsKICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGlmICh0aGlzLm9wdGlvbnMuaWdub3JlRXJyb3JzKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKGBnZXRPcGVyYXRvckxpc3QgLSBpZ25vcmluZyBlcnJvcnMgZHVyaW5nICIke3Rhc2submFtZX0iIGAgKyBgdGFzazogIiR7cmVhc29ufSIuYCk7CiAgICAgICAgY2xvc2VQZW5kaW5nUmVzdG9yZU9QUygpOwogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICB0aHJvdyByZWFzb247CiAgICB9KTsKICB9CiAgZ2V0VGV4dENvbnRlbnQoX3JlZjcpIHsKICAgIGxldCB7CiAgICAgIHN0cmVhbSwKICAgICAgdGFzaywKICAgICAgcmVzb3VyY2VzLAogICAgICBzdGF0ZU1hbmFnZXIgPSBudWxsLAogICAgICBjb21iaW5lVGV4dEl0ZW1zID0gZmFsc2UsCiAgICAgIGluY2x1ZGVNYXJrZWRDb250ZW50ID0gZmFsc2UsCiAgICAgIHNpbmssCiAgICAgIHNlZW5TdHlsZXMgPSBuZXcgU2V0KCksCiAgICAgIHZpZXdCb3gsCiAgICAgIG1hcmtlZENvbnRlbnREYXRhID0gbnVsbAogICAgfSA9IF9yZWY3OwogICAgcmVzb3VyY2VzID0gcmVzb3VyY2VzIHx8IF9wcmltaXRpdmVzLkRpY3QuZW1wdHk7CiAgICBzdGF0ZU1hbmFnZXIgPSBzdGF0ZU1hbmFnZXIgfHwgbmV3IFN0YXRlTWFuYWdlcihuZXcgVGV4dFN0YXRlKCkpOwogICAgaWYgKGluY2x1ZGVNYXJrZWRDb250ZW50KSB7CiAgICAgIG1hcmtlZENvbnRlbnREYXRhID0gbWFya2VkQ29udGVudERhdGEgfHwgewogICAgICAgIGxldmVsOiAwCiAgICAgIH07CiAgICB9CiAgICBjb25zdCB0ZXh0Q29udGVudCA9IHsKICAgICAgaXRlbXM6IFtdLAogICAgICBzdHlsZXM6IE9iamVjdC5jcmVhdGUobnVsbCkKICAgIH07CiAgICBjb25zdCB0ZXh0Q29udGVudEl0ZW0gPSB7CiAgICAgIGluaXRpYWxpemVkOiBmYWxzZSwKICAgICAgc3RyOiBbXSwKICAgICAgdG90YWxXaWR0aDogMCwKICAgICAgdG90YWxIZWlnaHQ6IDAsCiAgICAgIHdpZHRoOiAwLAogICAgICBoZWlnaHQ6IDAsCiAgICAgIHZlcnRpY2FsOiBmYWxzZSwKICAgICAgcHJldlRyYW5zZm9ybTogbnVsbCwKICAgICAgdGV4dEFkdmFuY2VTY2FsZTogMCwKICAgICAgc3BhY2VJbkZsb3dNaW46IDAsCiAgICAgIHNwYWNlSW5GbG93TWF4OiAwLAogICAgICB0cmFja2luZ1NwYWNlTWluOiBJbmZpbml0eSwKICAgICAgbmVnYXRpdmVTcGFjZU1heDogLUluZmluaXR5LAogICAgICBub3RBU3BhY2U6IC1JbmZpbml0eSwKICAgICAgdHJhbnNmb3JtOiBudWxsLAogICAgICBmb250TmFtZTogbnVsbCwKICAgICAgaGFzRU9MOiBmYWxzZQogICAgfTsKICAgIGNvbnN0IHR3b0xhc3RDaGFycyA9IFsiICIsICIgIl07CiAgICBsZXQgdHdvTGFzdENoYXJzUG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YgKHRleHRDb250ZW50SXRlbS5pbml0aWFsaXplZCkgewogICAgICAgIHJldHVybiB0ZXh0Q29udGVudEl0ZW07CiAgICAgIH0KICAgICAgY29uc3QgewogICAgICAgIGZvbnQsCiAgICAgICAgbG9hZGVkTmFtZQogICAgICB9ID0gdGV4dFN0YXRlOwogICAgICBpZiAoIXNlZW5TdHlsZXMuaGFzKGxvYWRlZE5hbWUpKSB7CiAgICAgICAgc2VlblN0eWxlcy5hZGQobG9hZGVkTmFtZSk7CiAgICAgICAgdGV4dENvbnRlbnQuc3R5bGVzW2xvYWRlZE5hbWVdID0gewogICAgICAgICAgZm9udEZhbWlseTogZm9udC5mYWxsYmFja05hbWUsCiAgICAgICAgICBhc2NlbnQ6IGZvbnQuYXNjZW50LAogICAgICAgICAgZGVzY2VudDogZm9udC5kZXNjZW50LAogICAgICAgICAgdmVydGljYWw6IGZvbnQudmVydGljYWwKICAgICAgICB9OwogICAgICB9CiAgICAgIHRleHRDb250ZW50SXRlbS5mb250TmFtZSA9IGxvYWRlZE5hbWU7CiAgICAgIGNvbnN0IHRybSA9IHRleHRDb250ZW50SXRlbS50cmFuc2Zvcm0gPSBnZXRDdXJyZW50VGV4dFRyYW5zZm9ybSgpOwogICAgICBpZiAoIWZvbnQudmVydGljYWwpIHsKICAgICAgICB0ZXh0Q29udGVudEl0ZW0ud2lkdGggPSB0ZXh0Q29udGVudEl0ZW0udG90YWxXaWR0aCA9IDA7CiAgICAgICAgdGV4dENvbnRlbnRJdGVtLmhlaWdodCA9IHRleHRDb250ZW50SXRlbS50b3RhbEhlaWdodCA9IE1hdGguaHlwb3QodHJtWzJdLCB0cm1bM10pOwogICAgICAgIHRleHRDb250ZW50SXRlbS52ZXJ0aWNhbCA9IGZhbHNlOwogICAgICB9IGVsc2UgewogICAgICAgIHRleHRDb250ZW50SXRlbS53aWR0aCA9IHRleHRDb250ZW50SXRlbS50b3RhbFdpZHRoID0gTWF0aC5oeXBvdCh0cm1bMF0sIHRybVsxXSk7C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WU7CiAgICAgICAgICB9CiAgICAgICAgICByZXNldExhc3RDaGFycygpOwogICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KICAgICAgICBpZiAoTWF0aC5hYnMoYWR2YW5jZVgpID4gdGV4dENvbnRlbnRJdGVtLndpZHRoKSB7CiAgICAgICAgICBhcHBlbmRFT0woKTsKICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgIH0KICAgICAgICBpZiAoYWR2YW5jZVkgPD0gdGV4dE9yaWVudGF0aW9uICogdGV4dENvbnRlbnRJdGVtLm5vdEFTcGFjZSkgewogICAgICAgICAgcmVzZXRMYXN0Q2hhcnMoKTsKICAgICAgICB9CiAgICAgICAgaWYgKGFkdmFuY2VZIDw9IHRleHRPcmllbnRhdGlvbiAqIHRleHRDb250ZW50SXRlbS50cmFja2luZ1NwYWNlTWluKSB7CiAgICAgICAgICB0ZXh0Q29udGVudEl0ZW0uaGVpZ2h0ICs9IGFkdmFuY2VZOwogICAgICAgIH0gZWxzZSBpZiAoIWFkZEZha2VTcGFjZXMoYWR2YW5jZVksIHRleHRDb250ZW50SXRlbS5wcmV2VHJhbnNmb3JtLCB0ZXh0T3JpZW50YXRpb24pKSB7CiAgICAgICAgICBpZiAodGV4dENvbnRlbnRJdGVtLnN0ci5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgcmVzZXRMYXN0Q2hhcnMoKTsKICAgICAgICAgICAgdGV4dENvbnRlbnQuaXRlbXMucHVzaCh7CiAgICAgICAgICAgICAgc3RyOiAiICIsCiAgICAgICAgICAgICAgZGlyOiAibHRyIiwKICAgICAgICAgICAgICB3aWR0aDogMCwKICAgICAgICAgICAgICBoZWlnaHQ6IE1hdGguYWJzKGFkdmFuY2VZKSwKICAgICAgICAgICAgICB0cmFuc2Zvcm06IHRleHRDb250ZW50SXRlbS5wcmV2VHJhbnNmb3JtLAogICAgICAgICAgICAgIGZvbnROYW1lOiB0ZXh0Q29udGVudEl0ZW0uZm9udE5hbWUsCiAgICAgICAgICAgICAgaGFzRU9MOiBmYWxzZQogICAgICAgICAgICB9KTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRleHRDb250ZW50SXRlbS5oZWlnaHQgKz0gYWR2YW5jZVk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGlmIChNYXRoLmFicyhhZHZhbmNlWCkgPiB0ZXh0Q29udGVudEl0ZW0ud2lkdGggKiBWRVJUSUNBTF9TSElGVF9SQVRJTykgewogICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgIH0KICAgICAgY29uc3QgYWR2YW5jZVggPSAocG9zWCAtIGxhc3RQb3NYKSAvIHRleHRDb250ZW50SXRlbS50ZXh0QWR2YW5jZVNjYWxlOwogICAgICBjb25zdCBhZHZhbmNlWSA9IHBvc1kgLSBsYXN0UG9zWTsKICAgICAgY29uc3QgdGV4dE9yaWVudGF0aW9uID0gTWF0aC5zaWduKHRleHRDb250ZW50SXRlbS53aWR0aCk7CiAgICAgIGlmIChhZHZhbmNlWCA8IHRleHRPcmllbnRhdGlvbiAqIHRleHRDb250ZW50SXRlbS5uZWdhdGl2ZVNwYWNlTWF4KSB7CiAgICAgICAgaWYgKE1hdGguYWJzKGFkdmFuY2VZKSA+IDAuNSAqIHRleHRDb250ZW50SXRlbS5oZWlnaHQpIHsKICAgICAgICAgIGFwcGVuZEVPTCgpOwogICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgfQogICAgICAgIHJlc2V0TGFzdENoYXJzKCk7CiAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfQogICAgICBpZiAoTWF0aC5hYnMoYWR2YW5jZVkpID4gdGV4dENvbnRlbnRJdGVtLmhlaWdodCkgewogICAgICAgIGFwcGVuZEVPTCgpOwogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9CiAgICAgIGlmIChhZHZhbmNlWCA8PSB0ZXh0T3JpZW50YXRpb24gKiB0ZXh0Q29udGVudEl0ZW0ubm90QVNwYWNlKSB7CiAgICAgICAgcmVzZXRMYXN0Q2hhcnMoKTsKICAgICAgfQogICAgICBpZiAoYWR2YW5jZVggPD0gdGV4dE9yaWVudGF0aW9uICogdGV4dENvbnRlbnRJdGVtLnRyYWNraW5nU3BhY2VNaW4pIHsKICAgICAgICB0ZXh0Q29udGVudEl0ZW0ud2lkdGggKz0gYWR2YW5jZVg7CiAgICAgIH0gZWxzZSBpZiAoIWFkZEZha2VTcGFjZXMoYWR2YW5jZVgsIHRleHRDb250ZW50SXRlbS5wcmV2VHJhbnNmb3JtLCB0ZXh0T3JpZW50YXRpb24pKSB7CiAgICAgICAgaWYgKHRleHRDb250ZW50SXRlbS5zdHIubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICByZXNldExhc3RDaGFycygpOwogICAgICAgICAgdGV4dENvbnRlbnQuaXRlbXMucHVzaCh7CiAgICAgICAgICAgIHN0cjogIiAiLAogICAgICAgICAgICBkaXI6ICJsdHIiLAogICAgICAgICAgICB3aWR0aDogTWF0aC5hYnMoYWR2YW5jZVgpLAogICAgICAgICAgICBoZWlnaHQ6IDAsCiAgICAgICAgICAgIHRyYW5zZm9ybTogdGV4dENvbnRlbnRJdGVtLnByZXZUcmFuc2Zvcm0sCiAgICAgICAgICAgIGZvbnROYW1lOiB0ZXh0Q29udGVudEl0ZW0uZm9udE5hbWUsCiAgICAgICAgICAgIGhhc0VPTDogZmFsc2UKICAgICAgICAgIH0pOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB0ZXh0Q29udGVudEl0ZW0ud2lkdGggKz0gYWR2YW5jZVg7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChNYXRoLmFicyhhZHZhbmNlWSkgPiB0ZXh0Q29udGVudEl0ZW0uaGVpZ2h0ICogVkVSVElDQUxfU0hJRlRfUkFUSU8pIHsKICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICB9CiAgICAgIHJldHVybiB0cnVlOwogICAgfQogICAgZnVuY3Rpb24gYnVpbGRUZXh0Q29udGVudEl0ZW0oX3JlZjgpIHsKICAgICAgbGV0IHsKICAgICAgICBjaGFycywKICAgICAgICBleHRyYVNwYWNpbmcKICAgICAgfSA9IF9yZWY4OwogICAgICBjb25zdCBmb250ID0gdGV4dFN0YXRlLmZvbnQ7CiAgICAgIGlmICghY2hhcnMpIHsKICAgICAgICBjb25zdCBjaGFyU3BhY2luZyA9IHRleHRTdGF0ZS5jaGFyU3BhY2luZyArIGV4dHJhU3BhY2luZzsKICAgICAgICBpZiAoY2hhclNwYWNpbmcpIHsKICAgICAgICAgIGlmICghZm9udC52ZXJ0aWNhbCkgewogICAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeChjaGFyU3BhY2luZyAqIHRleHRTdGF0ZS50ZXh0SFNjYWxlLCAwKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRleHRTdGF0ZS50cmFuc2xhdGVUZXh0TWF0cml4KDAsIC1jaGFyU3BhY2luZyk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBjb25zdCBnbHlwaHMgPSBmb250LmNoYXJzVG9HbHlwaHMoY2hhcnMpOwogICAgICBjb25zdCBzY2FsZSA9IHRleHRTdGF0ZS5mb250TWF0cml4WzBdICogdGV4dFN0YXRlLmZvbnRTaXplOwogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBnbHlwaHMubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgIGNvbnN0IGdseXBoID0gZ2x5cGhzW2ldOwogICAgICAgIGNvbnN0IHsKICAgICAgICAgIGNhdGVnb3J5CiAgICAgICAgfSA9IGdseXBoOwogICAgICAgIGlmIChjYXRlZ29yeS5pc0ludmlzaWJsZUZvcm1hdE1hcmspIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBsZXQgY2hhclNwYWNpbmcgPSB0ZXh0U3RhdGUuY2hhclNwYWNpbmcgKyAoaSArIDEgPT09IGlpID8gZXh0cmFTcGFjaW5nIDogMCk7CiAgICAgICAgbGV0IGdseXBoV2lkdGggPSBnbHlwaC53aWR0aDsKICAgICAgICBpZiAoZm9udC52ZXJ0aWNhbCkgewogICAgICAgICAgZ2x5cGhXaWR0aCA9IGdseXBoLnZtZXRyaWMgPyBnbHlwaC52bWV0cmljWzBdIDogLWdseXBoV2lkdGg7CiAgICAgICAgfQogICAgICAgIGxldCBzY2FsZWREaW0gPSBnbHlwaFdpZHRoICogc2NhbGU7CiAgICAgICAgaWYgKGNhdGVnb3J5LmlzV2hpdGVzcGFjZSkgewogICAgICAgICAgaWYgKCFmb250LnZlcnRpY2FsKSB7CiAgICAgICAgICAgIGNoYXJTcGFjaW5nICs9IHNjYWxlZERpbSArIHRleHRTdGF0ZS53b3JkU3BhY2luZzsKICAgICAgICAgICAgdGV4dFN0YXRlLnRyYW5zbGF0ZVRleHRNYXRyaXgoY2hhclNwYWNpbmcgKiB0ZXh0U3RhdGUudGV4dEhTY2FsZSwgMCk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBjaGFyU3BhY2luZyArPSAtc2NhbGVkRGltICsgdGV4dFN0YXRlLndvcmRTcGFjaW5nOwogICAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeCgwLCAtY2hhclNwYWNpbmcpOwogICAgICAgICAgfQogICAgICAgICAgc2F2ZUxhc3RDaGFyKCIgIik7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYgKCFjYXRlZ29yeS5pc1plcm9XaWR0aERpYWNyaXRpYyAmJiAhY29tcGFyZVdpdGhMYXN0UG9zaXRpb24oKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHRleHRDaHVuayA9IGVuc3VyZVRleHRDb250ZW50SXRlbSgpOwogICAgICAgIGlmIChjYXRlZ29yeS5pc1plcm9XaWR0aERpYWNyaXRpYykgewogICAgICAgICAgc2NhbGVkRGltID0gMDsKICAgICAgICB9CiAgICAgICAgaWYgKCFmb250LnZlcnRpY2FsKSB7CiAgICAgICAgICBzY2FsZWREaW0gKj0gdGV4dFN0YXRlLnRleHRIU2NhbGU7CiAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeChzY2FsZWREaW0sIDApOwogICAgICAgICAgdGV4dENodW5rLndpZHRoICs9IHNjYWxlZERpbTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgdGV4dFN0YXRlLnRyYW5zbGF0ZVRleHRNYXRyaXgoMCwgc2NhbGVkRGltKTsKICAgICAgICAgIHNjYWxlZERpbSA9IE1hdGguYWJzKHNjYWxlZERpbSk7CiAgICAgICAgICB0ZXh0Q2h1bmsuaGVpZ2h0ICs9IHNjYWxlZERpbTsKICAgICAgICB9CiAgICAgICAgaWYgKHNjYWxlZERpbSkgewogICAgICAgICAgdGV4dENodW5rLnByZXZUcmFuc2Zvcm0gPSBnZXRDdXJyZW50VGV4dFRyYW5zZm9ybSgpOwogICAgICAgIH0KICAgICAgICBjb25zdCBnbHlwaFVuaWNvZGUgPSBnbHlwaC5ub3JtYWxpemVkVW5pY29kZTsKICAgICAgICBpZiAoc2F2ZUxhc3RDaGFyKGdseXBoVW5pY29kZSkpIHsKICAgICAgICAgIHRleHRDaHVuay5zdHIucHVzaCgiICIpOwogICAgICAgIH0KICAgICAgICB0ZXh0Q2h1bmsuc3RyLnB1c2goZ2x5cGhVbmljb2RlKTsKICAgICAgICBpZiAoY2hhclNwYWNpbmcpIHsKICAgICAgICAgIGlmICghZm9udC52ZXJ0aWNhbCkgewogICAgICAgICAgICB0ZXh0U3RhdGUudHJhbnNsYXRlVGV4dE1hdHJpeChjaGFyU3BhY2luZyAqIHRleHRTdGF0ZS50ZXh0SFNjYWxlLCAwKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRleHRTdGF0ZS50cmFuc2xhdGVUZXh0TWF0cml4KDAsIC1jaGFyU3BhY2luZyk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBmdW5jdGlvbiBhcHBlbmRFT0woKSB7CiAgICAgIHJlc2V0TGFzdENoYXJzKCk7CiAgICAgIGlmICh0ZXh0Q29udGVudEl0ZW0uaW5pdGlhbGl6ZWQpIHsKICAgICAgICB0ZXh0Q29udGVudEl0ZW0uaGFzRU9MID0gdHJ1ZTsKICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICB9IGVsc2UgewogICAgICAgIHRleHRDb250ZW50Lml0ZW1zLnB1c2goewogICAgICAgICAgc3RyOiAiIiwKICAgICAgICAgIGRpcjogImx0ciIsCiAgICAgICAgICB3aWR0aDogMCwKICAgICAgICAgIGhlaWdodDogMCwKICAgICAgICAgIHRyYW5zZm9ybTogZ2V0Q3VycmVudFRleHRUcmFuc2Zvcm0oKSwKICAgICAgICAgIGZvbnROYW1lOiB0ZXh0U3RhdGUubG9hZGVkTmFtZSwKICAgICAgICAgIGhhc0VPTDogdHJ1ZQogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgICBmdW5jdGlvbiBhZGRGYWtlU3BhY2VzKHdpZHRoLCB0cmFuc2YsIHRleHRPcmllbnRhdGlvbikgewogICAgICBpZiAodGV4dE9yaWVudGF0aW9uICogdGV4dENvbnRlbnRJdGVtLnNwYWNlSW5GbG93TWluIDw9IHdpZHRoICYmIHdpZHRoIDw9IHRleHRPcmllbnRhdGlvbiAqIHRleHRDb250ZW50SXRlbS5zcGFjZUluRmxvd01heCkgewogICAgICAgIGlmICh0ZXh0Q29udGVudEl0ZW0uaW5pdGlhbGl6ZWQpIHsKICAgICAgICAgIHJlc2V0TGFzdENoYXJzKCk7CiAgICAgICAgICB0ZXh0Q29udGVudEl0ZW0uc3RyLnB1c2goIiAiKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICB9CiAgICAgIGNvbnN0IGZvbnROYW1lID0gdGV4dENvbnRlbnRJdGVtLmZvbnROYW1lOwogICAgICBsZXQgaGVpZ2h0ID0gMDsKICAgICAgaWYgKHRleHRDb250ZW50SXRlbS52ZXJ0aWNhbCkgewogICAgICAgIGhlaWdodCA9IHdpZHRoOwogICAgICAgIHdpZHRoID0gMDsKICAgICAgfQogICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICByZXNldExhc3RDaGFycygpOwogICAgICB0ZXh0Q29udGVudC5pdGVtcy5wdXNoKHsKICAgICAgICBzdHI6ICIgIiwKICAgICAgICBkaXI6ICJsdHIiLAogICAgICAgIHdpZHRoOiBNYXRoLmFicyh3aWR0aCksCiAgICAgICAgaGVpZ2h0OiBNYXRoLmFicyhoZWlnaHQpLAogICAgICAgIHRyYW5zZm9ybTogdHJhbnNmIHx8IGdldEN1cnJlbnRUZXh0VHJhbnNmb3JtKCksCiAgICAgICAgZm9udE5hbWUsCiAgICAgICAgaGFzRU9MOiBmYWxzZQogICAgICB9KTsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBmdW5jdGlvbiBmbHVzaFRleHRDb250ZW50SXRlbSgpIHsKICAgICAgaWYgKCF0ZXh0Q29udGVudEl0ZW0uaW5pdGlhbGl6ZWQgfHwgIXRleHRDb250ZW50SXRlbS5zdHIpIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgaWYgKCF0ZXh0Q29udGVudEl0ZW0udmVydGljYWwpIHsKICAgICAgICB0ZXh0Q29udGVudEl0ZW0udG90YWxXaWR0aCArPSB0ZXh0Q29udGVudEl0ZW0ud2lkdGggKiB0ZXh0Q29udGVudEl0ZW0udGV4dEFkdmFuY2VTY2FsZTsKICAgICAgfSBlbHNlIHsKICAgICAgICB0ZXh0Q29ud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ZSk7CiAgICAgICAgUHJvbWlzZS5hbGwoW3Byb21pc2UsIHNpbmsucmVhZHldKS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgIHRyeSB7CiAgICAgICAgICAgIHByb21pc2VCb2R5KHJlc29sdmUsIHJlamVjdCk7CiAgICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgICByZWplY3QoZXgpOwogICAgICAgICAgfQogICAgICAgIH0sIHJlamVjdCk7CiAgICAgIH07CiAgICAgIHRhc2suZW5zdXJlTm90VGVybWluYXRlZCgpOwogICAgICB0aW1lU2xvdE1hbmFnZXIucmVzZXQoKTsKICAgICAgY29uc3Qgb3BlcmF0aW9uID0ge307CiAgICAgIGxldCBzdG9wLAogICAgICAgIGFyZ3MgPSBbXTsKICAgICAgd2hpbGUgKCEoc3RvcCA9IHRpbWVTbG90TWFuYWdlci5jaGVjaygpKSkgewogICAgICAgIGFyZ3MubGVuZ3RoID0gMDsKICAgICAgICBvcGVyYXRpb24uYXJncyA9IGFyZ3M7CiAgICAgICAgaWYgKCFwcmVwcm9jZXNzb3IucmVhZChvcGVyYXRpb24pKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgdGV4dFN0YXRlID0gc3RhdGVNYW5hZ2VyLnN0YXRlOwogICAgICAgIGNvbnN0IGZuID0gb3BlcmF0aW9uLmZuOwogICAgICAgIGFyZ3MgPSBvcGVyYXRpb24uYXJnczsKICAgICAgICBzd2l0Y2ggKGZuIHwgMCkgewogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0Rm9udDoKICAgICAgICAgICAgdmFyIGZvbnROYW1lQXJnID0gYXJnc1swXS5uYW1lLAogICAgICAgICAgICAgIGZvbnRTaXplQXJnID0gYXJnc1sxXTsKICAgICAgICAgICAgaWYgKHRleHRTdGF0ZS5mb250ICYmIGZvbnROYW1lQXJnID09PSB0ZXh0U3RhdGUuZm9udE5hbWUgJiYgZm9udFNpemVBcmcgPT09IHRleHRTdGF0ZS5mb250U2l6ZSkgewogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgICAgICAgIHRleHRTdGF0ZS5mb250TmFtZSA9IGZvbnROYW1lQXJnOwogICAgICAgICAgICB0ZXh0U3RhdGUuZm9udFNpemUgPSBmb250U2l6ZUFyZzsKICAgICAgICAgICAgbmV4dChoYW5kbGVTZXRGb250KGZvbnROYW1lQXJnLCBudWxsKSk7CiAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFRleHRSaXNlOgogICAgICAgICAgICB0ZXh0U3RhdGUudGV4dFJpc2UgPSBhcmdzWzBdOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEhTY2FsZToKICAgICAgICAgICAgdGV4dFN0YXRlLnRleHRIU2NhbGUgPSBhcmdzWzBdIC8gMTAwOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldExlYWRpbmc6CiAgICAgICAgICAgIHRleHRTdGF0ZS5sZWFkaW5nID0gYXJnc1swXTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5tb3ZlVGV4dDoKICAgICAgICAgICAgdGV4dFN0YXRlLnRyYW5zbGF0ZVRleHRMaW5lTWF0cml4KGFyZ3NbMF0sIGFyZ3NbMV0pOwogICAgICAgICAgICB0ZXh0U3RhdGUudGV4dE1hdHJpeCA9IHRleHRTdGF0ZS50ZXh0TGluZU1hdHJpeC5zbGljZSgpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldExlYWRpbmdNb3ZlVGV4dDoKICAgICAgICAgICAgdGV4dFN0YXRlLmxlYWRpbmcgPSAtYXJnc1sxXTsKICAgICAgICAgICAgdGV4dFN0YXRlLnRyYW5zbGF0ZVRleHRMa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CA9IF91dGlsLklERU5USVRZX01BVFJJWC5zbGljZSgpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgX3V0aWwuT1BTLnNob3dTcGFjZWRUZXh0OgogICAgICAgICAgICBpZiAoIXN0YXRlTWFuYWdlci5zdGF0ZS5mb250KSB7CiAgICAgICAgICAgICAgc2VsZi5lbnN1cmVTdGF0ZUZvbnQoc3RhdGVNYW5hZ2VyLnN0YXRlKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBzcGFjZUZhY3RvciA9ICh0ZXh0U3RhdGUuZm9udC52ZXJ0aWNhbCA/IDEgOiAtMSkgKiB0ZXh0U3RhdGUuZm9udFNpemUgLyAxMDAwOwogICAgICAgICAgICBjb25zdCBlbGVtZW50cyA9IGFyZ3NbMF07CiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGVsZW1lbnRzLmxlbmd0aDsgaSA8IGlpIC0gMTsgaSsrKSB7CiAgICAgICAgICAgICAgY29uc3QgaXRlbSA9IGVsZW1lbnRzW2ldOwogICAgICAgICAgICAgIGlmICh0eXBlb2YgaXRlbSA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICAgIHNob3dTcGFjZWRUZXh0QnVmZmVyLnB1c2goaXRlbSk7CiAgICAgICAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgaXRlbSA9PT0gIm51bWJlciIgJiYgaXRlbSAhPT0gMCkgewogICAgICAgICAgICAgICAgY29uc3Qgc3RyID0gc2hvd1NwYWNlZFRleHRCdWZmZXIuam9pbigiIik7CiAgICAgICAgICAgICAgICBzaG93U3BhY2VkVGV4dEJ1ZmZlci5sZW5ndGggPSAwOwogICAgICAgICAgICAgICAgYnVpbGRUZXh0Q29udGVudEl0ZW0oewogICAgICAgICAgICAgICAgICBjaGFyczogc3RyLAogICAgICAgICAgICAgICAgICBleHRyYVNwYWNpbmc6IGl0ZW0gKiBzcGFjZUZhY3RvcgogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGl0ZW0gPSBlbGVtZW50cy5hdCgtMSk7CiAgICAgICAgICAgIGlmICh0eXBlb2YgaXRlbSA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICBzaG93U3BhY2VkVGV4dEJ1ZmZlci5wdXNoKGl0ZW0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChzaG93U3BhY2VkVGV4dEJ1ZmZlci5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3RyID0gc2hvd1NwYWNlZFRleHRCdWZmZXIuam9pbigiIik7CiAgICAgICAgICAgICAgc2hvd1NwYWNlZFRleHRCdWZmZXIubGVuZ3RoID0gMDsKICAgICAgICAgICAgICBidWlsZFRleHRDb250ZW50SXRlbSh7CiAgICAgICAgICAgICAgICBjaGFyczogc3RyLAogICAgICAgICAgICAgICAgZXh0cmFTcGFjaW5nOiAwCiAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5zaG93VGV4dDoKICAgICAgICAgICAgaWYgKCFzdGF0ZU1hbmFnZXIuc3RhdGUuZm9udCkgewogICAgICAgICAgICAgIHNlbGYuZW5zdXJlU3RhdGVGb250KHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnVpbGRUZXh0Q29udGVudEl0ZW0oewogICAgICAgICAgICAgIGNoYXJzOiBhcmdzWzBdLAogICAgICAgICAgICAgIGV4dHJhU3BhY2luZzogMAogICAgICAgICAgICB9KTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5uZXh0TGluZVNob3dUZXh0OgogICAgICAgICAgICBpZiAoIXN0YXRlTWFuYWdlci5zdGF0ZS5mb250KSB7CiAgICAgICAgICAgICAgc2VsZi5lbnN1cmVTdGF0ZUZvbnQoc3RhdGVNYW5hZ2VyLnN0YXRlKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICB0ZXh0U3RhdGUuY2FycmlhZ2VSZXR1cm4oKTsKICAgICAgICAgICAgYnVpbGRUZXh0Q29udGVudEl0ZW0oewogICAgICAgICAgICAgIGNoYXJzOiBhcmdzWzBdLAogICAgICAgICAgICAgIGV4dHJhU3BhY2luZzogMAogICAgICAgICAgICB9KTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIF91dGlsLk9QUy5uZXh0TGluZVNldFNwYWNpbmdTaG93VGV4dDoKICAgICAgICAgICAgaWYgKCFzdGF0ZU1hbmFnZXIuc3RhdGUuZm9udCkgewogICAgICAgICAgICAgIHNlbGYuZW5zdXJlU3RhdGVGb250KHN0YXRlTWFuYWdlci5zdGF0ZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGV4dFN0YXRlLndvcmRTcGFjaW5nID0gYXJnc1swXTsKICAgICAgICAgICAgdGV4dFN0YXRlLmNoYXJTcGFjaW5nID0gYXJnc1sxXTsKICAgICAgICAgICAgdGV4dFN0YXRlLmNhcnJpYWdlUmV0dXJuKCk7CiAgICAgICAgICAgIGJ1aWxkVGV4dENvbnRlbnRJdGVtKHsKICAgICAgICAgICAgICBjaGFyczogYXJnc1syXSwKICAgICAgICAgICAgICBleHRyYVNwYWNpbmc6IDAKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMucGFpbnRYT2JqZWN0OgogICAgICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICAgICAgICBpZiAoIXhvYmpzKSB7CiAgICAgICAgICAgICAgeG9ianMgPSByZXNvdXJjZXMuZ2V0KCJYT2JqZWN0IikgfHwgX3ByaW1pdGl2ZXMuRGljdC5lbXB0eTsKICAgICAgICAgICAgfQogICAgICAgICAgICB2YXIgaXNWYWxpZE5hbWUgPSBhcmdzWzBdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZTsKICAgICAgICAgICAgdmFyIG5hbWUgPSBhcmdzWzBdLm5hbWU7CiAgICAgICAgICAgIGlmIChpc1ZhbGlkTmFtZSAmJiBlbXB0eVhPYmplY3RDYWNoZS5nZXRCeU5hbWUobmFtZSkpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBuZXh0KG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlWE9iamVjdCwgcmVqZWN0WE9iamVjdCkgewogICAgICAgICAgICAgIGlmICghaXNWYWxpZE5hbWUpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiWE9iamVjdCBtdXN0IGJlIHJlZmVycmVkIHRvIGJ5IG5hbWUuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGxldCB4b2JqID0geG9ianMuZ2V0UmF3KG5hbWUpOwogICAgICAgICAgICAgIGlmICh4b2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmKSB7CiAgICAgICAgICAgICAgICBpZiAoZW1wdHlYT2JqZWN0Q2FjaGUuZ2V0QnlSZWYoeG9iaikpIHsKICAgICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgY29uc3QgZ2xvYmFsSW1hZ2UgPSBzZWxmLmdsb2JhbEltYWdlQ2FjaGUuZ2V0RGF0YSh4b2JqLCBzZWxmLnBhZ2VJbmRleCk7CiAgICAgICAgICAgICAgICBpZiAoZ2xvYmFsSW1hZ2UpIHsKICAgICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgeG9iaiA9IHhyZWYuZmV0Y2goeG9iaik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmICghKHhvYmogaW5zdGFuY2VvZiBfYmFzZV9zdHJlYW0uQmFzZVN0cmVhbSkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiWE9iamVjdCBzaG91bGQgYmUgYSBzdHJlYW0iKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgdHlwZSA9IHhvYmouZGljdC5nZXQoIlN1YnR5cGUiKTsKICAgICAgICAgICAgICBpZiAoISh0eXBlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkpIHsKICAgICAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiWE9iamVjdCBzaG91bGQgaGF2ZSBhIE5hbWUgc3VidHlwZSIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAodHlwZS5uYW1lICE9PSAiRm9ybSIpIHsKICAgICAgICAgICAgICAgIGVtcHR5WE9iamVjdENhY2hlLnNldChuYW1lLCB4b2JqLmRpY3Qub2JqSWQsIHRydWUpOwogICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgY3VycmVudFN0YXRlID0gc3RhdGVNYW5hZ2VyLnN0YXRlLmNsb25lKCk7CiAgICAgICAgICAgICAgY29uc3QgeE9ialN0YXRlTWFuYWdlciA9IG5ldyBTdGF0ZU1hbmFnZXIoY3VycmVudFN0YXRlKTsKICAgICAgICAgICAgICBjb25zdCBtYXRyaXggPSB4b2JqLmRpY3QuZ2V0QXJyYXkoIk1hdHJpeCIpOwogICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KG1hdHJpeCkgJiYgbWF0cml4Lmxlbmd0aCA9PT0gNikgewogICAgICAgICAgICAgICAgeE9ialN0YXRlTWFuYWdlci50cmFuc2Zvcm0obWF0cml4KTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgZW5xdWV1ZUNodW5rKCk7CiAgICAgICAgICAgICAgY29uc3Qgc2lua1dyYXBwZXIgPSB7CiAgICAgICAgICAgICAgICBlbnF1ZXVlSW52b2tlZDogZmFsc2UsCiAgICAgICAgICAgICAgICBlbnF1ZXVlKGNodW5rLCBzaXplKSB7CiAgICAgICAgICAgICAgICAgIHRoaXMuZW5xdWV1ZUludm9rZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgICBzaW5rLmVucXVldWUoY2h1bmssIHNpemUpOwogICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgIGdldCBkZXNpcmVkU2l6ZSgpIHsKICAgICAgICAgICAgICAgICAgcmV0dXJuIHNpbmsuZGVzaXJlZFNpemU7CiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgZ2V0IHJlYWR5KCkgewogICAgICAgICAgICAgICAgICByZXR1cm4gc2luay5yZWFkeTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgIHNlbGYuZ2V0VGV4dENvbnRlbnQoewogICAgICAgICAgICAgICAgc3RyZWFtOiB4b2JqLAogICAgICAgICAgICAgICAgdGFzaywKICAgICAgICAgICAgICAgIHJlc291cmNlczogeG9iai5kaWN0LmdldCgiUmVzb3VyY2VzIikgfHwgcmVzb3VyY2VzLAogICAgICAgICAgICAgICAgc3RhdGVNYW5hZ2VyOiB4T2JqU3RhdGVNYW5hZ2VyLAogICAgICAgICAgICAgICAgY29tYmluZVRleHRJdGVtcywKICAgICAgICAgICAgICAgIGluY2x1ZGVNYXJrZWRDb250ZW50LAogICAgICAgICAgICAgICAgc2luazogc2lua1dyYXBwZXIsCiAgICAgICAgICAgICAgICBzZWVuU3R5bGVzLAogICAgICAgICAgICAgICAgdmlld0JveCwKICAgICAgICAgICAgICAgIG1hcmtlZENvbnRlbnREYXRhCiAgICAgICAgICAgICAgfSkudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICAgICAgICBpZiAoIXNpbmtXcmFwcGVyLmVucXVldWVJbnZva2VkKSB7CiAgICAgICAgICAgICAgICAgIGVtcHR5WE9iamVjdENhY2hlLnNldChuYW1lLCB4b2JqLmRpY3Qub2JqSWQsIHRydWUpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgcmVzb2x2ZVhPYmplY3QoKTsKICAgICAgICAgICAgICB9LCByZWplY3RYT2JqZWN0KTsKICAgICAgICAgICAgfSkuY2F0Y2goZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgICAgIGlmIChyZWFzb24gaW5zdGFuY2VvZiBfdXRpbC5BYm9ydEV4Y2VwdGlvbikgewogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAoc2VsZi5vcHRpb25zLmlnbm9yZUVycm9ycykgewogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBnZXRUZXh0Q29udGVudCAtIGlnbm9yaW5nIFhPYmplY3Q6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuc2V0R1N0YXRlOgogICAgICAgICAgICBpc1ZhbGlkTmFtZSA9IGFyZ3NbMF0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lOwogICAgICAgICAgICBuYW1lID0gYXJnc1swXS5uYW1lOwogICAgICAgICAgICBpZiAoaXNWYWxpZE5hbWUgJiYgZW1wdHlHU3RhdGVDYWNoZS5nZXRCeU5hbWUobmFtZSkpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBuZXh0KG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlR1N0YXRlLCByZWplY3RHU3RhdGUpIHsKICAgICAgICAgICAgICBpZiAoIWlzVmFsaWROYW1lKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIkdTdGF0ZSBtdXN0IGJlIHJlZmVycmVkIHRvIGJ5IG5hbWUuIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNvbnN0IGV4dEdTdGF0ZSA9IHJlc291cmNlcy5nZXQoIkV4dEdTdGF0ZSIpOwogICAgICAgICAgICAgIGlmICghKGV4dEdTdGF0ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIkV4dEdTdGF0ZSBzaG91bGQgYmUgYSBkaWN0aW9uYXJ5LiIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb25zdCBnU3RhdGUgPSBleHRHU3RhdGUuZ2V0KG5hbWUpOwogICAgICAgICAgICAgIGlmICghKGdTdGF0ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIkdTdGF0ZSBzaG91bGQgYmUgYSBkaWN0aW9uYXJ5LiIpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb25zdCBnU3RhdGVGb250ID0gZ1N0YXRlLmdldCgiRm9udCIpOwogICAgICAgICAgICAgIGlmICghZ1N0YXRlRm9udCkgewogICAgICAgICAgICAgICAgZW1wdHlHU3RhdGVDYWNoZS5zZXQobmFtZSwgZ1N0YXRlLm9iaklkLCB0cnVlKTsKICAgICAgICAgICAgICAgIHJlc29sdmVHU3RhdGUoKTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICAgICAgICB0ZXh0U3RhdGUuZm9udE5hbWUgPSBudWxsOwogICAgICAgICAgICAgIHRleHRTdGF0ZS5mb250U2l6ZSA9IGdTdGF0ZUZvbnRbMV07CiAgICAgICAgICAgICAgaGFuZGxlU2V0Rm9udChudWxsLCBnU3RhdGVGb250WzBdKS50aGVuKHJlc29sdmVHU3RhdGUsIHJlamVjdEdTdGF0ZSk7CiAgICAgICAgICAgIH0pLmNhdGNoKGZ1bmN0aW9uIChyZWFzb24pIHsKICAgICAgICAgICAgICBpZiAocmVhc29uIGluc3RhbmNlb2YgX3V0aWwuQWJvcnRFeGNlcHRpb24pIHsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHNlbGYub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgZ2V0VGV4dENvbnRlbnQgLSBpZ25vcmluZyBFeHRHU3RhdGU6ICIke3JlYXNvbn0iLmApOwogICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aHJvdyByZWFzb247CiAgICAgICAgICAgIH0pKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuYmVnaW5NYXJrZWRDb250ZW50OgogICAgICAgICAgICBmbHVzaFRleHRDb250ZW50SXRlbSgpOwogICAgICAgICAgICBpZiAoaW5jbHVkZU1hcmtlZENvbnRlbnQpIHsKICAgICAgICAgICAgICBtYXJrZWRDb250ZW50RGF0YS5sZXZlbCsrOwogICAgICAgICAgICAgIHRleHRDb250ZW50Lml0ZW1zLnB1c2goewogICAgICAgICAgICAgICAgdHlwZTogImJlZ2luTWFya2VkQ29udGVudCIsCiAgICAgICAgICAgICAgICB0YWc6IGFyZ3NbMF0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lID8gYXJnc1swXS5uYW1lIDogbnVsbAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuYmVnaW5NYXJrZWRDb250ZW50UHJvcHM6CiAgICAgICAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgICAgICAgIGlmIChpbmNsdWRlTWFya2VkQ29udGVudCkgewogICAgICAgICAgICAgIG1hcmtlZENvbnRlbnREYXRhLmxldmVsKys7CiAgICAgICAgICAgICAgbGV0IG1jaWQgPSBudWxsOwogICAgICAgICAgICAgIGlmIChhcmdzWzFdIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICAgICAgbWNpZCA9IGFyZ3NbMV0uZ2V0KCJNQ0lEIik7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHRleHRDb250ZW50Lml0ZW1zLnB1c2goewogICAgICAgICAgICAgICAgdHlwZTogImJlZ2luTWFya2VkQ29udGVudFByb3BzIiwKICAgICAgICAgICAgICAgIGlkOiBOdW1iZXIuaXNJbnRlZ2VyKG1jaWQpID8gYCR7c2VsZi5pZEZhY3RvcnkuZ2V0UGFnZU9iaklkKCl9X21jaWQke21jaWR9YCA6IG51bGwsCiAgICAgICAgICAgICAgICB0YWc6IGFyZ3NbMF0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lID8gYXJnc1swXS5uYW1lIDogbnVsbAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBfdXRpbC5PUFMuZW5kTWFya2VkQ29udGVudDoKICAgICAgICAgICAgZmx1c2hUZXh0Q29udGVudEl0ZW0oKTsKICAgICAgICAgICAgaWYgKGluY2x1ZGVNYXJrZWRDb250ZW50KSB7CiAgICAgICAgICAgICAgaWYgKG1hcmtlZENvbnRlbnREYXRhLmxldmVsID09PSAwKSB7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgbWFya2VkQ29udGVudERhdGEubGV2ZWwtLTsKICAgICAgICAgICAgICB0ZXh0Q29udGVudC5pdGVtcy5wdXNoKHsKICAgICAgICAgICAgICAgIHR5cGU6ICJlbmRNYXJrZWRDb250ZW50IgogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBpZiAodGV4dENvbnRlbnQuaXRlbXMubGVuZ3RoID49IHNpbmsuZGVzaXJlZFNpemUpIHsKICAgICAgICAgIHN0b3AgPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChzdG9wKSB7CiAgICAgICAgbmV4dChkZWZlcnJlZCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgIGVucXVldWVDaHVuaygpOwogICAgICByZXNvbHZlKCk7CiAgICB9KS5jYXRjaChyZWFzb24gPT4gewogICAgICBpZiAocmVhc29uIGluc3RhbmNlb2YgX3V0aWwuQWJvcnRFeGNlcHRpb24pIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgaWYgKHRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYGdldFRleHRDb250ZW50IC0gaWdub3JpbmcgZXJyb3JzIGR1cmluZyAiJHt0YXNrLm5hbWV9IiBgICsgYHRhc2s6ICIke3JlYXNvbn0iLmApOwogICAgICAgIGZsdXNoVGV4dENvbnRlbnRJdGVtKCk7CiAgICAgICAgZW5xdWV1ZUNodW5rKCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIHRocm93IHJlYXNvbjsKICA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ICAgICAgICAgaW5kZXggPSBkYXRhOwogICAgICAgICAgICB9IGVsc2UgaWYgKGRhdGEgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgZGlmZmVyZW5jZXNbaW5kZXgrK10gPSBkYXRhLm5hbWU7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBJbnZhbGlkIGVudHJ5IGluICdEaWZmZXJlbmNlcycgYXJyYXk6ICR7ZGF0YX1gKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfSBlbHNlIGlmIChlbmNvZGluZyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICBiYXNlRW5jb2RpbmdOYW1lID0gZW5jb2RpbmcubmFtZTsKICAgICAgfSBlbHNlIHsKICAgICAgICBjb25zdCBtc2cgPSAiRW5jb2RpbmcgaXMgbm90IGEgTmFtZSBub3IgYSBEaWN0IjsKICAgICAgICBpZiAoIXRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihtc2cpOwogICAgICAgIH0KICAgICAgICAoMCwgX3V0aWwud2FybikobXNnKTsKICAgICAgfQogICAgICBpZiAoYmFzZUVuY29kaW5nTmFtZSAhPT0gIk1hY1JvbWFuRW5jb2RpbmciICYmIGJhc2VFbmNvZGluZ05hbWUgIT09ICJNYWNFeHBlcnRFbmNvZGluZyIgJiYgYmFzZUVuY29kaW5nTmFtZSAhPT0gIldpbkFuc2lFbmNvZGluZyIpIHsKICAgICAgICBiYXNlRW5jb2RpbmdOYW1lID0gbnVsbDsKICAgICAgfQogICAgfQogICAgaWYgKGJhc2VFbmNvZGluZ05hbWUpIHsKICAgICAgcHJvcGVydGllcy5kZWZhdWx0RW5jb2RpbmcgPSAoMCwgX2VuY29kaW5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PSBwYXJzZUludChnbHlwaE5hbWUuc3Vic3RyaW5nKDEpLCAxNik7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJnIjoKICAgICAgICAgIGlmIChnbHlwaE5hbWUubGVuZ3RoID09PSA1KSB7CiAgICAgICAgICAgIGNvZGUgPSBwYXJzZUludChnbHlwaE5hbWUuc3Vic3RyaW5nKDEpLCAxNik7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJDIjoKICAgICAgICBjYXNlICJjIjoKICAgICAgICAgIGlmIChnbHlwaE5hbWUubGVuZ3RoID49IDMgJiYgZ2x5cGhOYW1lLmxlbmd0aCA8PSA0KSB7CiAgICAgICAgICAgIGNvbnN0IGNvZGVTdHIgPSBnbHlwaE5hbWUuc3Vic3RyaW5nKDEpOwogICAgICAgICAgICBpZiAoZm9yY2VHbHlwaHMpIHsKICAgICAgICAgICAgICBjb2RlID0gcGFyc2VJbnQoY29kZVN0ciwgMTYpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvZGUgPSArY29kZVN0cjsKICAgICAgICAgICAgaWYgKE51bWJlci5pc05hTihjb2RlKSAmJiBOdW1iZXIuaXNJbnRlZ2VyKHBhcnNlSW50KGNvZGVTdHIsIDE2KSkpIHsKICAgICAgICAgICAgICByZXR1cm4gdGhpcy5fc2ltcGxlRm9udFRvVW5pY29kZShwcm9wZXJ0aWVzLCB0cnVlKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAidSI6CiAgICAgICAgICB1bmljb2RlID0gKDAsIF91bmljb2RlLmdldFVuaWNvZGVGb3JHbHlwaCkoZ2x5cGhOYW1lLCBnbHlwaHNVbmljb2RlTWFwKTsKICAgICAgICAgIGlmICh1bmljb2RlICE9PSAtMSkgewogICAgICAgICAgICBjb2RlID0gdW5pY29kZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICBzd2l0Y2ggKGdseXBoTmFtZSkgewogICAgICAgICAgICBjYXNlICJmX2giOgogICAgICAgICAgICBjYXNlICJmX3QiOgogICAgICAgICAgICBjYXNlICJUX2giOgogICAgICAgICAgICAgIHRvVW5pY29kZVtjaGFyY29kZV0gPSBnbHlwaE5hbWUucmVwbGFjZUFsbCgiXyIsICIiKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGlmIChjb2RlID4gMCAmJiBjb2RlIDw9IDB4MTBmZmZmICYmIE51bWJlci5pc0ludGVnZXIoY29kZSkpIHsKICAgICAgICBpZiAoYmFzZUVuY29kaW5nTmFtZSAmJiBjb2RlID09PSArY2hhcmNvZGUpIHsKICAgICAgICAgIGNvbnN0IGJhc2VFbmNvZGluZyA9ICgwLCBfZW5jb2RpbmdzLmdldEVuY29kaW5nKShiYXNlRW5jb2RpbmdOYW1lKTsKICAgICAgICAgIGlmIChiYXNlRW5jb2RpbmcgJiYgKGdseXBoTmFtZSA9IGJhc2VFbmNvZGluZ1tjaGFyY29kZV0pKSB7CiAgICAgICAgICAgIHRvVW5pY29kZVtjaGFyY29kZV0gPSBTdHJpbmcuZnJvbUNoYXJDb2RlKGdseXBoc1VuaWNvZGVNYXBbZ2x5cGhOYW1lXSk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICB0b1VuaWNvZGVbY2hhcmNvZGVdID0gU3RyaW5nLmZyb21Db2RlUG9pbnQoY29kZSk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiB0b1VuaWNvZGU7CiAgfQogIGFzeW5jIGJ1aWxkVG9Vbmljb2RlKHByb3BlcnRpZXMpIHsKICAgIHByb3BlcnRpZXMuaGFzSW5jbHVkZWRUb1VuaWNvZGVNYXAgPSAhIXByb3BlcnRpZXMudG9V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CwKICAgICAgICB1c2VDTWFwOiBudWxsCiAgICAgIH0pLnRoZW4oZnVuY3Rpb24gKGNtYXApIHsKICAgICAgICBpZiAoY21hcCBpbnN0YW5jZW9mIF9jbWFwLklkZW50aXR5Q01hcCkgewogICAgICAgICAgcmV0dXJuIG5ldyBfdG9fdW5pY29kZV9tYXAuSWRlbnRpdHlUb1VuaWNvZGVNYXAoMCwgMHhmZmZmKTsKICAgICAgICB9CiAgICAgICAgY29uc3QgbWFwID0gbmV3IEFycmF5KGNtYXAubGVuZ3RoKTsKICAgICAgICBjbWFwLmZvckVhY2goZnVuY3Rpb24gKGNoYXJDb2RlLCB0b2tlbikgewogICAgICAgICAgaWYgKHR5cGVvZiB0b2tlbiA9PT0gIm51bWJlciIpIHsKICAgICAgICAgICAgbWFwW2NoYXJDb2RlXSA9IFN0cmluZy5mcm9tQ29kZVBvaW50KHRva2VuKTsKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgfQogICAgICAgICAgY29uc3Qgc3RyID0gW107CiAgICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IHRva2VuLmxlbmd0aDsgayArPSAyKSB7CiAgICAgICAgICAgIGNvbnN0IHcxID0gdG9rZW4uY2hhckNvZGVBdChrKSA8PCA4IHwgdG9rZW4uY2hhckNvZGVBdChrICsgMSk7CiAgICAgICAgICAgIGlmICgodzEgJiAweGY4MDApICE9PSAweGQ4MDApIHsKICAgICAgICAgICAgICBzdHIucHVzaCh3MSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgayArPSAyOwogICAgICAgICAgICBjb25zdCB3MiA9IHRva2VuLmNoYXJDb2RlQXQoaykgPDwgOCB8IHRva2VuLmNoYXJDb2RlQXQoayArIDEpOwogICAgICAgICAgICBzdHIucHVzaCgoKHcxICYgMHgzZmYpIDw8IDEwKSArICh3MiAmIDB4M2ZmKSArIDB4MTAwMDApOwogICAgICAgICAgfQogICAgICAgICAgbWFwW2NoYXJDb2RlXSA9IFN0cmluZy5mcm9tQ29kZVBvaW50KC4uLnN0cik7CiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIG5ldyBfdG9fdW5pY29kZV9tYXAuVG9Vbmljb2RlTWFwKG1hcCk7CiAgICAgIH0sIHJlYXNvbiA9PiB7CiAgICAgICAgaWYgKHJlYXNvbiBpbnN0YW5jZW9mIF91dGlsLkFib3J0RXhjZXB0aW9uKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9CiAgICAgICAgaWYgKHRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgcmVhZFRvVW5pY29kZSAtIGlnbm9yaW5nIFRvVW5pY29kZSBkYXRhOiAiJHtyZWFzb259Ii5gKTsKICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgIH0KICAgICAgICB0aHJvdyByZWFzb247CiAgICAgIH0pOwogICAgfQogICAgcmV0dXJuIFByb21pc2UucmVzb2x2ZShudWxsKTsKICB9CiAgcmVhZENpZFRvR2lkTWFwKGdseXBoc0RhdGEsIHRvVW5pY29kZSkgewogICAgY29uc3QgcmVzdWx0ID0gW107CiAgICBmb3IgKGxldCBqID0gMCwgamogPSBnbHlwaHNEYXRhLmxlbmd0aDsgaiA8IGpqOyBqKyspIHsKICAgICAgY29uc3QgZ2x5cGhJRCA9IGdseXBoc0RhdGFbaisrXSA8PCA4IHwgZ2x5cGhzRGF0YVtqXTsKICAgICAgY29uc3QgY29kZSA9IGogPj4gMTsKICAgICAgaWYgKGdseXBoSUQgPT09IDAgJiYgIXRvVW5pY29kZS5oYXMoY29kZSkpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICByZXN1bHRbY29kZV0gPSBnbHlwaElEOwogICAgfQogICAgcmV0dXJuIHJlc3VsdDsKICB9CiAgZXh0cmFjdFdpZHRocyhkaWN0LCBkZXNjcmlwdG9yLCBwcm9wZXJ0aWVzKSB7CiAgICBjb25zdCB4cmVmID0gdGhpcy54cmVmOwogICAgbGV0IGdseXBoc1dpZHRocyA9IFtdOwogICAgbGV0IGRlZmF1bHRXaWR0aCA9IDA7CiAgICBjb25zdCBnbHlwaHNWTWV0cmljcyA9IFtdOwogICAgbGV0IGRlZmF1bHRWTWV0cmljczsKICAgIGxldCBpLCBpaSwgaiwgamosIHN0YXJ0LCBjb2RlLCB3aWR0aHM7CiAgICBpZiAocHJvcGVydGllcy5jb21wb3NpdGUpIHsKICAgICAgZGVmYXVsdFdpZHRoID0gZGljdC5oYXMoIkRXIikgPyBkaWN0LmdldCgiRFciKSA6IDEwMDA7CiAgICAgIHdpZHRocyA9IGRpY3QuZ2V0KCJXIik7CiAgICAgIGlmICh3aWR0aHMpIHsKICAgICAgICBmb3IgKGkgPSAwLCBpaSA9IHdpZHRocy5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgICBzdGFydCA9IHhyZWYuZmV0Y2hJZlJlZih3aWR0aHNbaSsrXSk7CiAgICAgICAgICBjb2RlID0geHJlZi5mZXRjaElmUmVmKHdpZHRoc1tpXSk7CiAgICAgICAgICBpZiAoQXJyYXkuaXNBcnJheShjb2RlKSkgewogICAgICAgICAgICBmb3IgKGogPSAwLCBqaiA9IGNvZGUubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgICAgICAgIGdseXBoc1dpZHRoc1tzdGFydCsrXSA9IHhyZWYuZmV0Y2hJZlJlZihjb2RlW2pdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY29uc3Qgd2lkdGggPSB4cmVmLmZldGNoSWZSZWYod2lkdGhzWysraV0pOwogICAgICAgICAgICBmb3IgKGogPSBzdGFydDsgaiA8PSBjb2RlOyBqKyspIHsKICAgICAgICAgICAgICBnbHlwaHNXaWR0aHNbal0gPSB3aWR0aDsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAocHJvcGVydGll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R5cGVvZiBlbnRyeSA9PT0gIm51bWJlciIgfHwgZW50cnkgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICAgICAgd2lkdGhzQnVmLnB1c2goZW50cnkudG9TdHJpbmcoKSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGhhc2gudXBkYXRlKHdpZHRoc0J1Zi5qb2luKCkpOwogICAgICB9CiAgICAgIGlmIChjb21wb3NpdGUpIHsKICAgICAgICBoYXNoLnVwZGF0ZSgiY29tcG9zaXRlRm9udCIpOwogICAgICAgIGNvbnN0IGNvbXBvc2l0ZVdpZHRocyA9IGRpY3QuZ2V0KCJXIikgfHwgYmFzZURpY3QuZ2V0KCJXIik7CiAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoY29tcG9zaXRlV2lkdGhzKSkgewogICAgICAgICAgY29uc3Qgd2lkdGhzQnVmID0gW107CiAgICAgICAgICBmb3IgKGNvbnN0IGVudHJ5IG9mIGNvbXBvc2l0ZVdpZHRocykgewogICAgICAgICAgICBpZiAodHlwZW9mIGVudHJ5ID09PSAibnVtYmVyIiB8fCBlbnRyeSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICAgIHdpZHRoc0J1Zi5wdXNoKGVudHJ5LnRvU3RyaW5nKCkpOwogICAgICAgICAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkoZW50cnkpKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3ViV2lkdGhzQnVmID0gW107CiAgICAgICAgICAgICAgZm9yIChjb25zdCBlbGVtZW50IG9mIGVudHJ5KSB7CiAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGVsZW1lbnQgPT09ICJudW1iZXIiIHx8IGVsZW1lbnQgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICAgICAgICAgICAgc3ViV2lkdGhzQnVmLnB1c2goZWxlbWVudC50b1N0cmluZygpKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgd2lkdGhzQnVmLnB1c2goYFske3N1YldpZHRoc0J1Zi5qb2luKCl9XWApOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBoYXNoLnVwZGF0ZSh3aWR0aHNCdWYuam9pbigpKTsKICAgICAgICB9CiAgICAgICAgY29uc3QgY2lkVG9HaWRNYXAgPSBkaWN0LmdldFJhdygiQ0lEVG9HSURNYXAiKSB8fCBiYXNlRGljdC5nZXRSYXcoIkNJRFRvR0lETWFwIik7CiAgICAgICAgaWYgKGNpZFRvR2lkTWFwIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkgewogICAgICAgICAgaGFzaC51cGRhdGUoY2lkVG9HaWRNYXAubmFtZSk7CiAgICAgICAgfSBlbHNlIGlmIChjaWRUb0dpZE1hcCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgaGFzaC51cGRhdGUoY2lkVG9HaWRNYXAudG9TdHJpbmcoKSk7CiAgICAgICAgfSBlbHNlIGlmIChjaWRUb0dpZE1hcCBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSB7CiAgICAgICAgICBoYXNoLnVwZGF0ZShjaWRUb0dpZE1hcC5wZWVrQnl0ZXMoKSk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gewogICAgICBkZXNjcmlwdG9yLAogICAgICBkaWN0LAogICAgICBiYXNlRGljdCwKICAgICAgY29tcG9zaXRlLAogICAgICB0eXBlOiB0eXBlLm5hbWUsCiAgICAgIGZpcnN0Q2hhciwKICAgICAgbGFzdENoYXIsCiAgICAgIHRvVW5pY29kZSwKICAgICAgaGFzaDogaGFzaCA/IGhhc2guaGV4ZGlnZXN0KCkgOiAiIgogICAgfTsKICB9CiAgYXN5bmMgdHJhbnNsYXRlRm9udChfcmVmOSkgewogICAgbGV0IHsKICAgICAgZGVzY3J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gICAgICBjb25zdCBmbGFncyA9ICh0aGlzLmlzU2VyaWZGb250KGZvbnROYW1lV29TdHlsZSkgPyBfZm9udHNfdXRpbHMuRm9udEZsYWdzLlNlcmlmIDogMCkgfCAobWV0cmljcy5tb25vc3BhY2UgPyBfZm9udHNfdXRpbHMuRm9udEZsYWdzLkZpeGVkUGl0Y2ggOiAwKSB8ICgoMCwgX3N0YW5kYXJkX2ZvbnRzLmdldFN5bWJvbHNGb250cykoKVtmb250TmFtZVdvU3R5bGVdID8gX2ZvbnRzX3V0aWxzLkZvbnRGbGFncy5TeW1ib2xpYyA6IF9mb250c191dGlscy5Gb250RmxhZ3MuTm9uc3ltYm9saWMpOwogICAgICAgIHByb3BlcnRpZXMgPSB7CiAgICAgICAgICB0eXBlLAogICAgICAgICAgbmFtZTogYmFzZUZvbnROYW1lLAogICAgICAgICAgbG9hZGVkTmFtZTogYmFzZURpY3QubG9hZGVkTmFtZSwKICAgICAgICAgIHdpZHRoczogbWV0cmljcy53aWR0aHMsCiAgICAgICAgICBkZWZhdWx0V2lkdGg6IG1ldHJpY3MuZGVmYXVsdFdpZHRoLAogICAgICAgICAgaXNTaW11bGF0ZWRGbGFnczogdHJ1ZSwKICAgICAgICAgIGZsYWdzLAogICAgICAgICAgZmlyc3RDaGFyLAogICAgICAgICAgbGFzdENoYXIsCiAgICAgICAgICB0b1VuaWNvZGUsCiAgICAgICAgICB4SGVpZ2h0OiAwLAogICAgICAgICAgY2FwSGVpZ2h0OiAwLAogICAgICAgICAgaXRhbGljQW5nbGU6IDAsCiAgICAgICAgICBpc1R5cGUzRm9udAogICAgICAgIH07CiAgICAgICAgY29uc3Qgd2lkdGhzID0gZGljdC5nZXQoIldpZHRocyIpOwogICAgICAgIGNvbnN0IHN0YW5kYXJkRm9udE5hbWUgPSAoMCwgX3N0YW5kYXJkX2ZvbnRzLmdldFN0YW5kYXJkRm9udE5hbWUpKGJhc2VGb250TmFtZSk7CiAgICAgICAgbGV0IGZpbGUgPSBudWxsOwogICAgICAgIGlmIChzdGFuZGFyZEZvbnROYW1lKSB7CiAgICAgICAgICBwcm9wZXJ0aWVzLmlzU3RhbmRhcmRGb250ID0gdHJ1ZTsKICAgICAgICAgIGZpbGUgPSBhd2FpdCB0aGlzLmZldGNoU3RhbmRhcmRGb250RGF0YShzdGFuZGFyZEZvbnROYW1lKTsKICAgICAgICAgIHByb3BlcnRpZXMuaXNJbnRlcm5hbEZvbnQgPSAhIWZpbGU7CiAgICAgICAgfQogICAgICAgIHJldHVybiB0aGlzLmV4dHJhY3REYXRhU3RydWN0dXJlcyhkaWN0LCBkaWN0LCBwcm9wZXJ0aWVzKS50aGVuKG5ld1Byb3BlcnRpZXMgPT4gewogICAgICAgICAgaWYgKHdpZHRocykgewogICAgICAgICAgICBjb25zdCBnbHlwaFdpZHRocyA9IFtdOwogICAgICAgICAgICBsZXQgaiA9IGZpcnN0Q2hhcjsKICAgICAgICAgICAgZm9yIChjb25zdCB3aWR0aCBvZiB3aWR0aHMpIHsKICAgICAgICAgICAgICBnbHlwaFdpZHRoc1tqKytdID0gdGhpcy54cmVmLmZldGNoSWZSZWYod2lkdGgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG5ld1Byb3BlcnRpZXMud2lkdGhzID0gZ2x5cGhXaWR0aHM7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBuZXdQcm9wZXJ0aWVzLndpZHRocyA9IHRoaXMuYnVpbGRDaGFyQ29kZVRvV2lkdGgobWV0cmljcy53aWR0aHMsIG5ld1Byb3BlcnRpZXMpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG5ldyBfZm9udHMuRm9udChiYXNlRm9udE5hbWUsIGZpbGUsIG5ld1Byb3BlcnRpZXMpOwogICAgICAgIH0pOwogICAgICB9CiAgICB9CiAgICBsZXQgZm9udE5hbWUgPSBkZXNjcmlwdG9yLmdldCgiRm9udE5hbWUiKTsKICAgIGxldCBiYXNlRm9udCA9IGRpY3QuZ2V0KCJCYXNlRm9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IGxlbmd0aDM7CiAgICB0cnkgewogICAgICBmb250RmlsZSA9IGRlc2NyaXB0b3IuZ2V0KCJGb250RmlsZSIsICJGb250RmlsZTIiLCAiRm9udEZpbGUzIik7CiAgICB9IGNhdGNoIChleCkgewogICAgICBpZiAoIXRoaXMub3B0aW9ucy5pZ25vcmVFcnJvcnMpIHsKICAgICAgICB0aHJvdyBleDsKICAgICAgfQogICAgICAoMCwgX3V0aWwud2FybikoYHRyYW5zbGF0ZUZvbnQgLSBmZXRjaGluZyAiJHtmb250TmFtZS5uYW1lfSIgZm9udCBmaWxlOiAiJHtleH0iLmApOwogICAgICBmb250RmlsZSA9IG5ldyBfc3RyZWFtLk51bGxTdHJlYW0oKTsKICAgIH0KICAgIGxldCBpc1N0YW5kYXJkRm9udCA9IGZhbHNlOwogICAgbGV0IGlzSW50ZXJuYWxGb250ID0gZmFsc2U7CiAgICBsZXQgZ2x5cGhTY2FsZUZhY3RvcnMgPSBudWxsOwogICAgaWYgKGZvbnRGaWxlKSB7CiAgICAgIGlmIChmb250RmlsZS5kaWN0KSB7CiAgICAgICAgY29uc3Qgc3VidHlwZUVudHJ5ID0gZm9udEZpbGUuZGljdC5nZXQoIlN1YnR5cGUiKTsKICAgICAgICBpZiAoc3VidHlwZUVudHJ5IGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkgewogICAgICAgICAgc3VidHlwZSA9IHN1YnR5cGVFbnRyeS5uYW1lOwogICAgICAgIH0KICAgICAgICBsZW5ndGgxID0gZm9udEZpbGUuZGljdC5nZXQoIkxlbmd0aDEiKTsKICAgICAgICBsZW5ndGgyID0gZm9udEZpbGUuZGljdC5nZXQoIkxlbmd0aDIiKTsKICAgICAgICBsZW5ndGgzID0gZm9udEZpbGUuZGljdC5nZXQoIkxlbmd0aDMiKTsKICAgICAgfQogICAgfSBlbHNlIGlmIChjc3NGb250SW5mbykgewogICAgICBjb25zdCBzdGFuZGFyZEZvbnROYW1lID0gKDAsIF94ZmFfZm9udHM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RlcGVuZGVuY2llczsKICAgIGxldCBsb2FkQ2hhclByb2NzUHJvbWlzZSA9IFByb21pc2UucmVzb2x2ZSgpOwogICAgY29uc3QgY2hhclByb2NzID0gdGhpcy5kaWN0LmdldCgiQ2hhclByb2NzIik7CiAgICBjb25zdCBmb250UmVzb3VyY2VzID0gdGhpcy5kaWN0LmdldCgiUmVzb3VyY2VzIikgfHwgcmVzb3VyY2VzOwogICAgY29uc3QgY2hhclByb2NPcGVyYXRvckxpc3QgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgY29uc3QgZm9udEJCb3ggPSBfdXRpbC5VdGlsLm5vcm1hbGl6ZVJlY3QodHJhbnNsYXRlZEZvbnQuYmJveCB8fCBbMCwgMCwgMCwgMF0pLAogICAgICB3aWR0aCA9IGZvbnRCQm94WzJdIC0gZm9udEJCb3hbMF0sCiAgICAgIGhlaWdodCA9IGZvbnRCQm94WzNdIC0gZm9udEJCb3hbMV07CiAgICBjb25zdCBmb250QkJveFNpemUgPSBNYXRoLmh5cG90KHdpZHRoLCBoZWlnaHQpOwogICAgZm9yIChjb25zdCBrZXkgb2YgY2hhclByb2NzLmdldEtleXMoKSkgewogICAgICBsb2FkQ2hhclByb2NzUHJvbWlzZSA9IGxvYWRDaGFyUHJvY3NQcm9taXNlLnRoZW4oKCkgPT4gewogICAgICAgIGNvbnN0IGdseXBoU3RyZWFtID0gY2hhclByb2NzLmdldChrZXkpOwogICAgICAgIGNvbnN0IG9wZXJhdG9yTGlzdCA9IG5ldyBfb3BlcmF0b3JfbGlzdC5PcGVyYXRvckxpc3QoKTsKICAgICAgICByZXR1cm4gdHlwZTNFdmFsdWF0b3IuZ2V0T3BlcmF0b3JMaXN0KHsKICAgICAgICAgIHN0cmVhbTogZ2x5cGhTdHJlYW0sCiAgICAgICAgICB0YXNrLAogICAgICAgICAgcmVzb3VyY2VzOiBmb250UmVzb3VyY2VzLAogICAgICAgICAgb3BlcmF0b3JMaXN0CiAgICAgICAgfSkudGhlbigoKS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nNoYWRpbmdGaWxsOgogICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldFJlbmRlcmluZ0ludGVudDoKICAgICAgICAgIG9wZXJhdG9yTGlzdC5mbkFycmF5LnNwbGljZShpLCAxKTsKICAgICAgICAgIG9wZXJhdG9yTGlzdC5hcmdzQXJyYXkuc3BsaWNlKGksIDEpOwogICAgICAgICAgaWktLTsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIGNhc2UgX3V0aWwuT1BTLnNldEdTdGF0ZToKICAgICAgICAgIGNvbnN0IFtnU3RhdGVPYmpdID0gb3BlcmF0b3JMaXN0LmFyZ3NBcnJheVtpXTsKICAgICAgICAgIGxldCBqID0gMCwKICAgICAgICAgICAgamogPSBnU3RhdGVPYmoubGVuZ3RoOwogICAgICAgICAgd2hpbGUgKGogPCBqaikgewogICAgICAgICAgICBjb25zdCBbZ1N0YXRlS2V5XSA9IGdTdGF0ZU9ialtqXTsKICAgICAgICAgICAgc3dpdGNoIChnU3RhdGVLZXkpIHsKICAgICAgICAgICAgICBjYXNlICJUUiI6CiAgICAgICAgICAgICAgY2FzZSAiVFIyIjoKICAgICAgICAgICAgICBjYXNlICJIVCI6CiAgICAgICAgICAgICAgY2FzZSAiQkciOgogICAgICAgICAgICAgIGNhc2UgIkJHMiI6CiAgICAgICAgICAgICAgY2FzZSAiVUNSIjoKICAgICAgICAgICAgICBjYXNlICJVQ1IyIjoKICAgICAgICAgICAgICAgIGdTdGF0ZU9iai5zcGxpY2UoaiwgMSk7CiAgICAgICAgICAgICAgICBqai0tOwogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaisrOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaSsrOwogICAgfQogIH0KfQpjbGFzcyBTdGF0ZU1hbmFnZXIgewogIGNvbnN0cnVjdG9yKCkgewogICAgbGV0IGluaXRpYWxTdGF0ZSA9IGFyZ3VtZW50cy5sZW5ndGgg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AgIH07CiAgICAgIHQuSiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldExpbmVDYXAsCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuaiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldExpbmVKb2luLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0Lk0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRNaXRlckxpbWl0LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmQgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXREYXNoLAogICAgICAgIG51bUFyZ3M6IDIsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnJpID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0UmVuZGVyaW5nSW50ZW50LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRGbGF0bmVzcywKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5ncyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldEdTdGF0ZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5xID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2F2ZSwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5RID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMucmVzdG9yZSwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5jbSA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnRyYW5zZm9ybSwKICAgICAgICBudW1BcmdzOiA2LAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5tID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMubW92ZVRvLAogICAgICAgIG51bUFyZ3M6IDIsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmwgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5saW5lVG8sCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuYyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmN1cnZlVG8sCiAgICAgICAgbnVtQXJnczogNiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQudiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmN1cnZlVG8yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5jdXJ2ZVRvMywKICAgICAgICBudW1BcmdzOiA0LAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5oID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuY2xvc2VQYXRoLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnJlID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMucmVjdGFuZ2xlLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zdHJva2UsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQucyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmNsb3NlU3Ryb2tlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmYgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5maWxsLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkYgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5maWxsLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyJmKiJdID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuZW9GaWxsLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkIgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5maWxsU3Ryb2tlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyJCKiJdID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuZW9GaWxsU3Ryb2tlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmIgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5jbG9zZUZpbGxTdHJva2UsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHRbImIqIl0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5jbG9zZUVPRmlsbFN0cm9rZSwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5uID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuZW5kUGF0aCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5XID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuY2xpcCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdFsiVyoiXSA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmVvQ2xpcCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5CVCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmJlZ2luVGV4dCwKICAgICAgICBudW1BcmdzOiAwLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5FVCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmVuZFRleHQsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVGMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRDaGFyU3BhY2luZywKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5UdyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFdvcmRTcGFjaW5nLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlR6ID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0SFNjYWxlLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlRMID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0TGVhZGluZywKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5UZiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldEZvbnQsCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVHIgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRUZXh0UmVuZGVyaW5nTW9kZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5UcyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFRleHRSaXNlLAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LlRkID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMubW92ZVRleHQsCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVEQgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRMZWFkaW5nTW92ZVRleHQsCiAgICAgICAgbnVtQXJnczogMiwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVG0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRUZXh0TWF0cml4LAogICAgICAgIG51bUFyZ3M6IDYsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyJUKiJdID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMubmV4dExpbmUsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuVGogPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zaG93VGV4dCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5USiA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNob3dTcGFjZWRUZXh0LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyInIl0gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5uZXh0TGluZVNob3dUZXh0LAogICAgICAgIG51bUFyZ3M6IDEsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0WyciJ10gPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5uZXh0TGluZVNldFNwYWNpbmdTaG93VGV4dCwKICAgICAgICBudW1BcmdzOiAzLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5kMCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldENoYXJXaWR0aCwKICAgICAgICBudW1BcmdzOiAyLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5kMSA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldENoYXJXaWR0aEFuZEJvdW5kcywKICAgICAgICBudW1BcmdzOiA2LAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5DUyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFN0cm9rZUNvbG9yU3BhY2UsCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuY3MgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRGaWxsQ29sb3JTcGFjZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5TQyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldFN0cm9rZUNvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiB0cnVlCiAgICAgIH07CiAgICAgIHQuU0NOID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0U3Ryb2tlQ29sb3JOLAogICAgICAgIG51bUFyZ3M6IDMzLAogICAgICAgIHZhcmlhYmxlQXJnczogdHJ1ZQogICAgICB9OwogICAgICB0LnNjID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0RmlsbENvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiB0cnVlCiAgICAgIH07CiAgICAgIHQuc2NuID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0RmlsbENvbG9yTiwKICAgICAgICBudW1BcmdzOiAzMywKICAgICAgICB2YXJpYWJsZUFyZ3M6IHRydWUKICAgICAgfTsKICAgICAgdC5HID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0U3Ryb2tlR3JheSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5nID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0RmlsbEdyYXksCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuUkcgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRTdHJva2VSR0JDb2xvciwKICAgICAgICBudW1BcmdzOiAzLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5yZyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnNldEZpbGxSR0JDb2xvciwKICAgICAgICBudW1BcmdzOiAzLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5LID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2V0U3Ryb2tlQ01ZS0NvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LmsgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5zZXRGaWxsQ01ZS0NvbG9yLAogICAgICAgIG51bUFyZ3M6IDQsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LnNoID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuc2hhZGluZ0ZpbGwsCiAgICAgICAgbnVtQXJnczogMSwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuQkkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5iZWdpbklubGluZUltYWdlLAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LklEID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuYmVnaW5JbWFnZURhdGEsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuRUkgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5lbmRJbmxpbmVJbWFnZSwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5EbyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLnBhaW50WE9iamVjdCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5NUCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLm1hcmtQb2ludCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5EUCA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLm1hcmtQb2ludFByb3BzLAogICAgICAgIG51bUFyZ3M6IDIsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkJNQyA9IHsKICAgICAgICBpZDogX3V0aWwuT1BTLmJlZ2luTWFya2VkQ29udGVudCwKICAgICAgICBudW1BcmdzOiAxLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5CREMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5iZWdpbk1hcmtlZENvbnRlbnRQcm9wcywKICAgICAgICBudW1BcmdzOiAyLAogICAgICAgIHZhcmlhYmxlQXJnczogZmFsc2UKICAgICAgfTsKICAgICAgdC5FTUMgPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5lbmRNYXJrZWRDb250ZW50LAogICAgICAgIG51bUFyZ3M6IDAsCiAgICAgICAgdmFyaWFibGVBcmdzOiBmYWxzZQogICAgICB9OwogICAgICB0LkJYID0gewogICAgICAgIGlkOiBfdXRpbC5PUFMuYmVnaW5Db21wYXQsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuRVggPSB7CiAgICAgICAgaWQ6IF91dGlsLk9QUy5lbmRDb21wYXQsCiAgICAgICAgbnVtQXJnczogMCwKICAgICAgICB2YXJpYWJsZUFyZ3M6IGZhbHNlCiAgICAgIH07CiAgICAgIHQuQk0gPSBudWxsOwogICAgICB0LkJEID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iAgcmVhZChvcGVyYXRpb24pIHsKICAgIGxldCBhcmdzID0gb3BlcmF0aW9uLmFyZ3M7CiAgICB3aGlsZSAodHJ1ZSkgewogICAgICBjb25zdCBvYmogPSB0aGlzLnBhcnNlci5nZXRPYmooKTsKICAgICAgaWYgKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkNtZCkgewogICAgICAgIGNvbnN0IGNtZCA9IG9iai5jbWQ7CiAgICAgICAgY29uc3Qgb3BTcGVjID0gRXZhbHVhdG9yUHJlcHJvY2Vzc29yLm9wTWFwW2NtZF07CiAgICAgICAgaWYgKCFvcFNwZWMpIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgVW5rbm93biBjb21tYW5kICIke2NtZH0iLmApOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IGZuID0gb3BTcGVjLmlkOwogICAgICAgIGNvbnN0IG51bUFyZ3MgPSBvcFNwZWMubnVtQXJnczsKICAgICAgICBsZXQgYXJnc0xlbmd0aCA9IGFyZ3MgIT09IG51bGwgPyBhcmdzLmxlbmd0aCA6IDA7CiAgICAgICAgaWYgKCF0aGlzLl9pc1BhdGhPcCkgewogICAgICAgICAgdGhpcy5fbnVtSW52YWxpZFBhdGhPUFMgPSAwOwogICAgICAgIH0KICAgICAgICB0aGlzLl9pc1BhdGhPcCA9IGZuID49IF91dGlsLk9QUy5tb3ZlVG8gJiYgZm4gPD0gX3V0aWwuT1BTLmVuZFBhdGg7CiAgICAgICAgaWYgKCFvcFNwZWMudmFyaWFibGVBcmdzKSB7CiAgICAgICAgICBpZiAoYXJnc0xlbmd0aCAhPT0gbnVtQXJncykgewogICAgICAgICAgICBjb25zdCBub25Qcm9jZXNzZWRBcmdzID0gdGhpcy5ub25Qcm9jZXNzZWRBcmdzOwogICAgICAgICAgICB3aGlsZSAoYXJnc0xlbmd0aCA+IG51bUFyZ3MpIHsKICAgICAgICAgICAgICBub25Qcm9jZXNzZWRBcmdzLnB1c2goYXJncy5zaGlmdCgpKTsKICAgICAgICAgICAgICBhcmdzTGVuZ3RoLS07CiAgICAgICAgICAgIH0KICAgICAgICAgICAgd2hpbGUgKGFyZ3NMZW5ndGggPCBudW1BcmdzICYmIG5vblByb2Nlc3NlZEFyZ3MubGVuZ3RoICE9PSAwKSB7CiAgICAgICAgICAgICAgaWYgKGFyZ3MgPT09IG51bGwpIHsKICAgICAgICAgICAgICAgIGFyZ3MgPSBbXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYXJncy51bnNoaWZ0KG5vblByb2Nlc3NlZEFyZ3MucG9wKCkpOwogICAgICAgICAgICAgIGFyZ3NMZW5ndGgrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKGFyZ3NMZW5ndGggPCBudW1BcmdzKSB7CiAgICAgICAgICAgIGNvbnN0IHBhcnRpYWxNc2cgPSBgY29tbWFuZCAke2NtZH06IGV4cGVjdGVkICR7bnVtQXJnc30gYXJncywgYCArIGBidXQgcmVjZWl2ZWQgJHthcmdzTGVuZ3RofSBhcmdzLmA7CiAgICAgICAgICAgIGlmICh0aGlzLl9pc1BhdGhPcCAmJiArK3RoaXMuX251bUludmFsaWRQYXRoT1BTID4gRXZhbHVhdG9yUHJlcHJvY2Vzc29yLk1BWF9JTlZBTElEX1BBVEhfT1BTKSB7CiAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBJbnZhbGlkICR7cGFydGlhbE1zZ31gKTsKICAgICAgICAgICAgfQogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYFNraXBwaW5nICR7cGFydGlhbE1zZ31gKTsKICAgICAgICAgICAgaWYgKGFyZ3MgIT09IG51bGwpIHsKICAgICAgICAgICAgICBhcmdzLmxlbmd0aCA9IDA7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIGlmIChhcmdzTGVuZ3RoID4gbnVtQXJncykgewogICAgICAgICAgKDAsIF91dGlsLmluZm8pKGBDb21tYW5kICR7Y21kfTogZXhwZWN0ZWQgWzAsICR7bnVtQXJnc31dIGFyZ3MsIGAgKyBgYnV0IHJlY2VpdmVkICR7YXJnc0xlbmd0aH0gYXJncy5gKTsKICAgICAgICB9CiAgICAgICAgdGhpcy5wcmVwcm9jZXNzQ29tbWFuZChmbiwgYXJncyk7CiAgICAgICAgb3BlcmF0aW9uLmZuID0gZm47CiAgICAgICAgb3BlcmF0aW9uLmFyZ3MgPSBhcmdzOwogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9CiAgICAgIGlmIChvYmogPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfQogICAgICBpZiAob2JqICE9PSBudWxsKSB7CiAgICAgICAgaWYgKGFyZ3MgPT09IG51bGwpIHsKICAgICAgICAgIGFyZ3MgPSBbXTsKICAgICAgICB9CiAgICAgICAgYXJncy5wdXNoKG9iaik7CiAgICAgICAgaWYgKGFyZ3MubGVuZ3RoID4gMzMpIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiVG9vIG1hbnkgYXJndW1lbnRzIik7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgfQogIHByZXByb2Nlc3NDb21tYW5kKGZuLCBhcmdzKSB7CiAgICBzd2l0Y2ggKGZuIHwgMCkgewogICAgICBjYXNlIF91dGlsLk9QUy5zYXZlOgogICAgICAgIHRoaXMuc3RhdGVNYW5hZ2VyLnNhdmUoKTsKICAgICAgICBicmVhazsKICAgICAgY2FzZSBfdXRpbC5PUFMucmVzdG9yZToKICAgICAgICB0aGlzLnN0YXRlTWFuYWdlci5yZXN0b3JlKCk7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgX3V0aWwuT1BTLnRyYW5zZm9ybToKICAgICAgICB0aGlzLnN0YXRlTWFuYWdlci50cmFuc2Zvcm0oYXJncyk7CiAgICAgICAg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gICAgIHRoaXMuYnVmZmVyID0gZGF0YTsKICAgICAgdGhpcy5wb3MgPSAwOwogICAgICB0aGlzLmVuZCA9IGRhdGEubGVuZ3RoOwogICAgICB0aGlzLnRtcEJ1ZiA9IG5ldyBVaW50OEFycmF5KE1BWF9FTkNPREVEX05VTV9TSVpFKTsKICAgIH0KICAgIHJlYWRCeXRlKCkgewogICAgICBpZiAodGhpcy5wb3MgPj0gdGhpcy5lbmQpIHsKICAgICAgICByZXR1cm4gLTE7CiAgICAgIH0KICAgICAgcmV0dXJuIHRoaXMuYnVmZmVyW3RoaXMucG9zKytdOwogICAgfQogICAgcmVhZE51bWJlcigpIHsKICAgICAgbGV0IG4gPSAwOwogICAgICBsZXQgbGFzdDsKICAgICAgZG8gewogICAgICAgIGNvbnN0IGIgPSB0aGlzLnJlYWRCeXRlKCk7CiAgICAgICAgaWYgKGIgPCAwKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoInVuZXhwZWN0ZWQgRU9GIGluIGJjbWFwIik7CiAgICAgICAgfQogICAgICAgIGxhc3QgPSAhKGIgJiAweDgwKTsKICAgICAgICBuID0gbiA8PCA3IHwgYiAmIDB4N2Y7CiAgICAgIH0gd2hpbGUgKCFsYXN0KTsKICAgICAgcmV0dXJuIG47CiAgICB9CiAgICByZWFkU2lnbmVkKCkgewogICAgICBjb25zdCBuID0gdGhpcy5yZWFkTnVtYmVyKCk7CiAgICAgIHJldHVybiBuICYgMSA/IH4obiA+Pj4gMSkgOiBuID4+PiAxOwogICAgfQogICAgcmVhZEhleChudW0sIHNpemUpIHsKICAgICAgbnVtLnNldCh0aGlzLmJ1ZmZlci5zdWJhcnJheSh0aGlzLnBvcywgdGhpcy5wb3MgKyBzaXplICsgMSkpOwogICAgICB0aGlzLnBvcyArPSBzaXplICsgMTsKICAgIH0KICAgIHJlYWRIZXhOdW1iZXIobnVtLCBzaXplKSB7CiAgICAgIGxldCBsYXN0OwogICAgICBjb25zdCBzdGFjayA9IHRoaXMudG1wQnVmOwogICAgICBsZXQgc3AgPSAwOwogICAgICBkbyB7CiAgICAgICAgY29uc3QgYiA9IHRoaXMucmVhZEJ5dGUoKTsKICAgICAgICBpZiAoYiA8IDApIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigidW5leHBlY3RlZCBFT0YgaW4gYmNtYXAiKTsKICAgICAgICB9CiAgICAgICAgbGFzdCA9ICEoYiAmIDB4ODApOwogICAgICAgIHN0YWNrW3NwKytdID0gYiAmIDB4N2Y7CiAgICAgIH0gd2hpbGUgKCFsYXN0KTsKICAgICAgbGV0IGkgPSBzaXplLAogICAgICAgIGJ1ZmZlciA9IDAsCiAgICAgICAgYnVmZmVyU2l6ZSA9IDA7CiAgICAgIHdoaWxlIChpID49IDApIHsKICAgICAgICB3aGlsZSAoYnVmZmVyU2l6ZSA8IDggJiYgc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgYnVmZmVyIHw9IHN0YWNrWy0tc3BdIDw8IGJ1ZmZlclNpemU7CiAgICAgICAgICBidWZmZXJTaXplICs9IDc7CiAgICAgICAgfQogICAgICAgIG51bVtpXSA9IGJ1ZmZlciAmIDI1NTsKICAgICAgICBpLS07CiAgICAgICAgYnVmZmVyID4+PSA4OwogICAgICAgIGJ1ZmZlclNpemUgLT0gODsKICAgICAgfQogICAgfQogICAgcmVhZEhleFNpZ25lZChudW0sIHNpemUpIHsKICAgICAgdGhpcy5yZWFkSGV4TnVtYmVyKG51bSwgc2l6ZSk7CiAgICAgIGNvbnN0IHNpZ24gPSBudW1bc2l6ZV0gJiAxID8gMjU1IDogMDsKICAgICAgbGV0IGMgPSAwOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8PSBzaXplOyBpKyspIHsKICAgICAgICBjID0gKGMgJiAxKSA8PCA4IHwgbnVtW2ldOwogICAgICAgIG51bVtpXSA9IGMgPj4gMSBeIHNpZ247CiAgICAgIH0KICAgIH0KICAgIHJlYWRTdHJpbmcoKSB7CiAgICAgIGNvbnN0IGxlbiA9IHRoaXMucmVhZE51bWJlcigpOwogICAgICBsZXQgcyA9ICIiOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IGxlbjsgaSsrKSB7CiAgICAgICAgcyArPSBTdHJpbmcuZnJvbUNoYXJDb2RlKHRoaXMucmVhZE51bWJlcigpKTsKICAgICAgfQogICAgICByZXR1cm4gczsKICAgIH0KICB9CiAgY2xhc3MgQmluYXJ5Q01hcFJlYWRlciB7CiAgICBhc3luYyBwcm9jZXNzKGRhdGEsIGNNYXAsIGV4dGVuZCkgewogICAgICBjb25zdCBzdHJlYW0gPSBuZXcgQmluYXJ5Q01hcFN0cmVhbShkYXRhKTsKICAgICAgY29uc3QgaGVhZGVyID0gc3RyZWFtLnJlYWRCeXRlKCk7CiAgICAgIGNNYXAudmVydGljYWwgPSAhIShoZWFkZXIgJiAxKTsKICAgICAgbGV0IHVzZUNNYXAgPSBudWxsOwogICAgICBjb25zdCBzdGFydCA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGNvbnN0IGVuZCA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGNvbnN0IGNoYXIgPSBuZXcgVWludDhBcnJheShNQVhfTlVNX1NJWkUpOwogICAgICBjb25zdCBjaGFyQ29kZSA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGNvbnN0IHRtcCA9IG5ldyBVaW50OEFycmF5KE1BWF9OVU1fU0laRSk7CiAgICAgIGxldCBjb2RlOwogICAgICBsZXQgYjsKICAgICAgd2hpbGUgKChiID0gc3RyZWFtLnJlYWRCeXRlKCkpID49IDApIHsKICAgICAgICBjb25zdCB0eXBlID0gYiA+PiA1OwogICAgICAgIGlmICh0eXBlID09PSA3KSB7CiAgICAgICAgICBzd2l0Y2ggKGIgJiAweDFmKSB7CiAgICAgICAgICAgIGNhc2UgMDoKICAgICAgICAgICAgICBzdHJlYW0ucmVhZFN0cmluZygpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgdXNlQ01hcCA9IHN0cmVhbS5yZWFkU3RyaW5nKCk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgY29uc3Qgc2VxdWVuY2UgPSAhIShiICYgMHgxMCk7CiAgICAgICAgY29uc3QgZGF0YVNpemUgPSBiICYgMTU7CiAgICAgICAgaWYgKGRhdGFTaXplICsgMSA+IE1BWF9OVU1fU0laRSkgewogICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCJCaW5hcnlDTWFwUmVhZGVyLnByb2Nlc3M6IEludmFsaWQgZGF0YVNpemUuIik7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHVjczJEYXRhU2l6ZSA9IDE7CiAgICAgICAgY29uc3Qgc3ViaXRlbXNDb3VudCA9IHN0cmVhbS5yZWFkTnVtYmVyKCk7CiAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4KHN0YXJ0LCBkYXRhU2l6ZSk7CiAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKGVuZCwgZGF0YVNpemUpOwogICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgZGF0YVNpemUpOwogICAgICAgICAgICBjTWFwLmFkZENvZGVzcGFjZVJhbmdlKGRhdGFTaXplICsgMSwgaGV4VG9JbnQoc3RhcnQsIGRhdGFTaXplKSwgaGV4VG9JbnQoZW5kLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8IHN1Yml0ZW1zQ291bnQ7IGkrKykgewogICAgICAgICAgICAgIGluY0hleChlbmQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcihzdGFydCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGFkZEhleChzdGFydCwgZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgYWRkSGV4KGVuZCwgc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBjTWFwLmFkZENvZGVzcGFjZVJhbmdlKGRhdGFTaXplICsgMSwgaGV4VG9JbnQoc3RhcnQsIGRhdGFTaXplKSwgaGV4VG9JbnQoZW5kLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAxOgogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChzdGFydCwgZGF0YVNpemUpOwogICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcihlbmQsIGRhdGFTaXplKTsKICAgICAgICAgICAgYWRkSGV4KGVuZCwgc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWROdW1iZXIoKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoc3RhcnQsIGVuZCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKGVuZCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGFkZEhleChlbmQsIHN0YXJ0LCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgc3RyZWFtLnJlYWROdW1iZXIoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMjoKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXgoY2hhciwgZGF0YVNpemUpOwogICAgICAgICAgICBjb2RlID0gc3RyZWFtLnJlYWROdW1iZXIoKTsKICAgICAgICAgICAgY01hcC5tYXBPbmUoaGV4VG9JbnQoY2hhciwgZGF0YVNpemUpLCBjb2RlKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoY2hhciwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGlmICghc2VxdWVuY2UpIHsKICAgICAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKHRtcCwgZGF0YVNpemUpOwogICAgICAgICAgICAgICAgYWRkSGV4KGNoYXIsIHRtcCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb2RlID0gc3RyZWFtLnJlYWRTaWduZWQoKSArIChjb2RlICsgMSk7CiAgICAgICAgICAgICAgY01hcC5tYXBPbmUoaGV4VG9JbnQoY2hhciwgZGF0YVNpemUpLCBjb2RlKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMzoKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXgoc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgIGFkZEhleChlbmQsIHN0YXJ0LCBkYXRhU2l6ZSk7CiAgICAgICAgICAgIGNvZGUgPSBzdHJlYW0ucmVhZE51bWJlcigpOwogICAgICAgICAgICBjTWFwLm1hcENpZFJhbmdlKGhleFRvSW50KHN0YXJ0LCBkYXRhU2l6ZSksIGhleFRvSW50KGVuZCwgZGF0YVNpemUpLCBjb2RlKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgaWYgKCFzZXF1ZW5jZSkgewogICAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoc3RhcnQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICAgIGFkZEhleChzdGFydCwgZW5kLCBkYXRhU2l6ZSk7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHN0YXJ0LnNldChlbmQpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcihlbmQsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGNvZGUgPSBzdHJlYW0ucmVhZE51bWJlcigpOwogICAgICAgICAgICAgIGNNYXAubWFwQ2lkUmFuZ2UoaGV4VG9JbnQoc3RhcnQsIGRhdGFTaXplKSwgaGV4VG9JbnQoZW5kLCBkYXRhU2l6ZSksIGNvZGUpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSA0OgogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChjaGFyLCB1Y3MyRGF0YVNpemUpOwogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChjaGFyQ29kZSwgZGF0YVNpemUpOwogICAgICAgICAgICBjTWFwLm1hcE9uZShoZXhUb0ludChjaGFyLCB1Y3MyRGF0YVNpemUpLCBoZXhUb1N0cihjaGFyQ29kZSwgZGF0YVNpemUpKTsKICAgICAgICAgICAgZm9yIChsZXQgaSA9IDE7IGkgPCBzdWJpdGVtc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBpbmNIZXgoY2hhciwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICBpZiAoIXNlcXVlbmNlKSB7CiAgICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleE51bWJlcih0bXAsIHVjczJEYXRhU2l6ZSk7CiAgICAgICAgICAgICAgICBhZGRIZXgoY2hhciwgdG1wLCB1Y3MyRGF0YVNpemUpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpbmNIZXgoY2hhckNvZGUsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleFNpZ25lZCh0bXAsIGRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoY2hhckNvZGUsIHRtcCwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGNNYXAubWFwT25lKGhleFRvSW50KGNoYXIsIHVjczJEYXRhU2l6ZSksIGhleFRvU3RyKGNoYXJDb2RlLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSA1OgogICAgICAgICAgICBzdHJlYW0ucmVhZEhleChzdGFydCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoZW5kLCB1Y3MyRGF0YVNpemUpOwogICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXgoY2hhckNvZGUsIGRhdGFTaXplKTsKICAgICAgICAgICAgY01hcC5tYXBCZlJhbmdlKGhleFRvSW50KHN0YXJ0LCB1Y3MyRGF0YVNpemUpLCBoZXhUb0ludChlbmQsIHVjczJEYXRhU2l6ZSksIGhleFRvU3RyKGNoYXJDb2RlLCBkYXRhU2l6ZSkpOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMTsgaSA8IHN1Yml0ZW1zQ291bnQ7IGkrKykgewogICAgICAgICAgICAgIGluY0hleChlbmQsIHVjczJEYXRhU2l6ZSk7CiAgICAgICAgICAgICAgaWYgKCFzZXF1ZW5jZSkgewogICAgICAgICAgICAgICAgc3RyZWFtLnJlYWRIZXhOdW1iZXIoc3RhcnQsIHVjczJEYXRhU2l6ZSk7CiAgICAgICAgICAgICAgICBhZGRIZXgoc3RhcnQsIGVuZCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgc3RhcnQuc2V0KGVuZCk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHN0cmVhbS5yZWFkSGV4TnVtYmVyKGVuZCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICBhZGRIZXgoZW5kLCBzdGFydCwgdWNzMkRhdGFTaXplKTsKICAgICAgICAgICAgICBzdHJlYW0ucmVhZEhleChjaGFyQ29kZSwgZGF0YVNpemUpOwogICAgICAgICAgICAgIGNNYXAubWFwQmZSYW5nZShoZXhUb0ludChzdGFydCwgdWNzMkRhdGFTaXplKSwgaGV4VG9JbnQoZW5kLCB1Y3MyRGF0YVNpemUpLCBoZXhUb1N0cihjaGFyQ29kZSwgZGF0YVNpemUpKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgQmluYXJ5Q01hcFJlYWRlci5wcm9jZXNzIC0gdW5rbm93biB0eXBlOiAke3R5cGV9YCk7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmICh1c2VDTWFwKSB7CiAgICAgICAgcmV0dXJuIGV4dGVuZCh1c2VDTWFwKTsKICAgICAgfQogICAgICByZXR1cm4gY01hcDsKICAgIH0KICB9CiAgcmV0dXJuIEJpbmFyeUNNYXBSZWFkZXI7Cn0oKTsKY29uc3QgQ01hcEZhY3RvcnkgPSBmdW5jdGlvbiBDTWFwRmFjdG9yeUNsb3N1cmUoKSB7CiAgZnVuY3Rpb24gc3RyVG9JbnQoc3RyKSB7CiAgICBsZXQgYSA9IDA7CiAgICBmb3IgKGxldCBpID0gMDsgaSA8IHN0ci5sZW5ndGg7IGkrKykgewogICAgICBhID0gYSA8PCA4IHwgc3RyLmNoYXJDb2RlQXQoaSk7CiAgICB9CiAgICByZXR1cm4gYSA+Pj4gMDsKICB9CiAgZnVuY3Rpb24gZXhwZWN0U3RyaW5nKG9iaikgewogICAgaWYgKHR5cGVvZiBvYmogIT09ICJzdHJpbmciKSB7CiAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiTWFsZm9ybWVkIENNYXA6IGV4cGVjdGVkIHN0cmluZy4iKTsKICAgIH0KICB9CiAgZnVuY3Rpb24gZXhwZWN0SW50KG9iaikgewogICAgaWYgKCFOdW1iZXIuaXNJbnRlZ2VyKG9iaikpIHsKICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJNYWxmb3JtZWQgQ01hcDogZXhwZWN0ZWQgaW50LiIpOwogICAgfQogIH0KICBmdW5jdGlvbiBwYXJzZUJmQ2hhcihjTWFwLCBsZXhlcikgewogICAgd2hpbGUgKHRydWUpIHsKICAgICAgbGV0IG9iaiA9IGxleGVyLmdldE9iaigpOwogICAgICBpZiAob2JqID09PSBfcHJpbWl0aXZlcy5FT0YpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoKDAsIF9wcmltaXRpdmVzLmlzQ21kKShvYmosICJlbmRiZmNoYXIiKSkgewogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBleHBlY3RTdHJpbmcob2JqKTsKICAgICAgY29uc3Qgc3JjID0gc3RyVG9JbnQob2JqKTsKICAgICAgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGV4cGVjdFN0cmluZyhvYmopOwogICAgICBjb25zdCBkc3QgPSBvYmo7CiAgICAgIGNNYXAubWFwT25lKHNyYywgZHN0KTsKICAgIH0KICB9CiAgZnVuY3Rpb24gcGFyc2VCZlJhbmdlKGNNYXAsIGxleGVyKSB7CiAgICB3aGlsZSAodHJ1ZSkgewogICAgICBsZXQgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGlmIChvYmogPT09IF9wcmltaXRpdmVzLkVPRikgew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vcigiSW52YWxpZCBiZiByYW5nZS4iKTsKICB9CiAgZnVuY3Rpb24gcGFyc2VDaWRDaGFyKGNNYXAsIGxleGVyKSB7CiAgICB3aGlsZSAodHJ1ZSkgewogICAgICBsZXQgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGlmIChvYmogPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNDbWQpKG9iaiwgImVuZGNpZGNoYXIiKSkgewogICAgICAgIHJldHVybjsKICAgICAgfQogICAgICBleHBlY3RTdHJpbmcob2JqKTsKICAgICAgY29uc3Qgc3JjID0gc3RyVG9JbnQob2JqKTsKICAgICAgb2JqID0gbGV4ZXIuZ2V0T2JqKCk7CiAgICAgIGV4cGVjdEludChvYmopOwogICAgICBjb25zdCBkc3QgPSBvYmo7CiAgICAgIGNNYXAubWFwT25lKHNyYywgZHN0KTsKICAgIH0KICB9CiAgZnVuY3Rpb24gcGFyc2VDaWRSYW5nZShjTWFwLCBsZXhlcikgewogICAgd2hpbGUgKHRydWUpIHsKICAgICAgbGV0IG9iaiA9IGxleGVyLmdldE9iaigpOwogICAgICBpZiAob2JqID09PSBfcHJpbWl0aXZlcy5FT0YpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoKDAsIF9wcmltaXRpdmVzLmlzQ21kKShvYmosICJlbmRjaWRyYW5nZSIpKSB7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGV4cGVjdFN0cmluZyhvYmopOwogICAgICBjb25zdCBsb3cgPSBzdHJUb0ludChvYmopOwogICAgICBvYmogPSBsZXhlci5nZXRPYmooKTsKICAgICAgZXhwZWN0U3RyaW5nKG9iaik7CiAgICAgIGNvbnN0IGhpZ2ggPSBzdHJUb0ludChvYmopOwogICAgICBvYmogPSBsZXhlci5nZXRPYmooKTsKICAgICAgZXhwZWN0SW50KG9iaik7CiAgICAgIGNv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GNvbnN0IG9iaiA9IGxleGVyLmdldE9iaigpOwogICAgaWYgKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgY01hcC5uYW1lID0gb2JqLm5hbWU7CiAgICB9CiAgfQogIGFzeW5jIGZ1bmN0aW9uIHBhcnNlQ01hcChjTWFwLCBsZXhlciwgZmV0Y2hCdWlsdEluQ01hcCwgdXNlQ01hcCkgewogICAgbGV0IHByZXZpb3VzLCBlbWJlZGRlZFVzZUNNYXA7CiAgICBvYmpMb29wOiB3aGlsZSAodHJ1ZSkgewogICAgICB0cnkgewogICAgICAgIGNvbnN0IG9iaiA9IGxleGVyLmdldE9iaigpOwogICAgICAgIGlmIChvYmogPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfSBlbHNlIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICBpZiAob2JqLm5hbWUgPT09ICJXTW9kZSIpIHsKICAgICAgICAgICAgcGFyc2VXTW9kZShjTWFwLCBsZXhlcik7CiAgICAgICAgICB9IGVsc2UgaWYgKG9iai5uYW1lID09PSAiQ01hcE5hbWUiKSB7CiAgICAgICAgICAgIHBhcnNlQ01hcE5hbWUoY01hcCwgbGV4ZXIpOwogICAgICAgICAgfQogICAgICAgICAgcHJldmlvdXMgPSBvYmo7CiAgICAgICAgfSBlbHNlIGlmIChvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5DbWQpIHsKICAgICAgICAgIHN3aXRjaCAob2JqLmNtZCkgewogICAgICAgICAgICBjYXNlICJlbmRjbWFwIjoKICAgICAgICAgICAgICBicmVhayBvYmpMb29wOwogICAgICAgICAgICBjYXNlICJ1c2VjbWFwIjoKICAgICAgICAgICAgICBpZiAocHJldmlvdXMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgICAgICBlbWJlZGRlZFVzZUNNYXAgPSBwcmV2aW91cy5uYW1lOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAiYmVnaW5jb2Rlc3BhY2VyYW5nZSI6CiAgICAgICAgICAgICAgcGFyc2VDb2Rlc3BhY2VSYW5nZShjTWFwLCBsZXhlcik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgImJlZ2luYmZjaGFyIjoKICAgICAgICAgICAgICBwYXJzZUJmQ2hhcihjTWFwLCBsZXhlcik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgImJlZ2luY2lkY2hhciI6CiAgICAgICAgICAgICAgcGFyc2VDaWRDaGFyKGNNYXAsIGxleGVyKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAiYmVnaW5iZnJhbmdlIjoKICAgICAgICAgICAgICBwYXJzZUJmUmFuZ2UoY01hcCwgbGV4ZXIpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlICJiZWdpbmNpZHJhbmdlIjoKICAgICAgICAgICAgICBwYXJzZUNpZFJhbmdlKGNNYXAsIGxleGVyKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuTWlzc2luZ0RhdGFFeGNlcHRpb24pIHsKICAgICAgICAgIHRocm93IGV4OwogICAgICAgIH0KICAgICAgICAoMCwgX3V0aWwud2FybikoIkludmFsaWQgY01hcCBkYXRhOiAiICsgZXgpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICB9CiAgICBpZiAoIXVzZUNNYXAgJiYgZW1iZWRkZWRVc2VDTWFwKSB7CiAgICAgIHVzZUNNYXAgPSBlbWJlZGRlZFVzZUNNYXA7CiAgICB9CiAgICBpZiAodXNlQ01hcCkgewogICA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LmJ1ZjEgIT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgICAgICBhcnJheS5wdXNoKHRoaXMuZ2V0T2JqKGNpcGhlclRyYW5zZm9ybSkpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHRoaXMuYnVmMSA9PT0gX3ByaW1pdGl2ZXMuRU9GKSB7CiAgICAgICAgICAgIGlmICh0aGlzLnJlY292ZXJ5TW9kZSkgewogICAgICAgICAgICAgIHJldHVybiBhcnJheTsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aHJvdyBuZXcgX2NvcmVfdXRpbHMuUGFyc2VyRU9GRXhjZXB0aW9uKCJFbmQgb2YgZmlsZSBpbnNpZGUgYXJyYXkuIik7CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLnNoaWZ0KCk7CiAgICAgICAgICByZXR1cm4gYXJyYXk7CiAgICAgICAgY2FzZSAiPDwiOgogICAgICAgICAgY29uc3QgZGljdCA9IG5ldyBfcHJpbWl0aXZlcy5EaWN0KHRoaXMueHJlZik7CiAgICAgICAgICB3aGlsZSAoISgwLCBfcHJpbWl0aXZlcy5pc0NtZCkodGhpcy5idWYxLCAiPj4iKSAmJiB0aGlzLmJ1ZjEgIT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgICAgICBpZiAoISh0aGlzLmJ1ZjEgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSkgewogICAgICAgICAgICAgICgwLCBfdXRpbC5pbmZvKSgiTWFsZm9ybWVkIGRpY3Rpb25hcnk6IGtleSBtdXN0IGJlIGEgbmFtZSBvYmplY3QiKTsKICAgICAgICAgICAgICB0aGlzLnNoaWZ0KCk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29uc3Qga2V5ID0gdGhpcy5idWYxLm5hbWU7CiAgICAgICAgICAgIHRoaXMuc2hpZnQoKTsKICAgICAgICAgICAgaWYgKHRoaXMuYnVmMSA9PT0gX3ByaW1pdGl2ZXMuRU9GKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZGljdC5zZXQoa2V5LCB0aGlzLmdldE9iaihjaXBoZXJUcmFuc2Zvcm0pKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh0aGlzLmJ1ZjEgPT09IF9wcmltaXRpdmVzLkVPRikgewogICAgICAgICAgICBpZiAodGhpcy5yZWNvdmVyeU1vZGUpIHsKICAgICAgICAgICAgICByZXR1cm4gZGljdDsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aHJvdyBuZXcgX2NvcmVfdXRpbHMuUGFyc2VyRU9GRXhjZXB0aW9uKCJFbmQgb2YgZmlsZSBpbnNpZGUgZGljdGlvbmFyeS4iKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNDbWQpKHRoaXMuYnVmMiwgInN0cmVhbSIpKSB7CiAgICAgICAgICAgIHJldHVybiB0aGlzLmFsbG93U3RyZWFtcyA/IHRoaXMubWFrZVN0cmVhbShkaWN0LCBjaXBoZXJUcmFuc2Zvcm0pIDogZGljdDsKICAgICAgICAgIH0KICAgICAgICAgIHRoaXMuc2hpZnQoKTsKICAgICAgICAgIHJldHVybiBkaWN0OwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICByZXR1cm4gYnVmMTsKICAgICAgfQogICAgfQogICAgaWYgKE51bWJlci5pc0ludGVnZXIoYnVmMSkpIHsKICAgICAgaWYgKE51bWJlci5pc0ludGVnZXIodGhpcy5idWYxKSAmJiAoMCwgX3ByaW1pdGl2ZXMuaXNDbWQpKHRoaXMuYnVmMiwgIlIiKSkgewogICAgICAgIGNvbnN0IHJlZiA9IF9wcmltaXRpdmVzLlJlZi5nZXQoYnVmMSwgdGhpcy5idWYxKTsKICAgICAgICB0aGlzLnNoaWZ0KCk7CiAgICAgICAgdGhpcy5zaGlmdCgpOwogICAgICAgIHJldHVybiByZWY7CiAgICAgIH0KICAgICAgc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yBpIDwgaWk7IGkrKykgewogICAgICAgICAgICBjaCA9IGZvbGxvd2luZ0J5dGVzW2ldOwogICAgICAgICAgICBpZiAoY2ggPT09IE5VTCAmJiBmb2xsb3dpbmdCeXRlc1tpICsgMV0gIT09IE5VTCkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChjaCAhPT0gTEYgJiYgY2ggIT09IENSICYmIChjaCA8IFNQQUNFIHx8IGNoID4gMHg3ZikpIHsKICAgICAgICAgICAgICBzdGF0ZSA9IDA7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzdGF0ZSAhPT0gMikgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChsZXhlci5rbm93bkNvbW1hbmRzKSB7CiAgICAgICAgICAgIGNvbnN0IG5leHRPYmogPSBsZXhlci5wZWVrT2JqKCk7CiAgICAgICAgICAgIGlmIChuZXh0T2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuQ21kICYmICFsZXhlci5rbm93bkNvbW1hbmRzW25leHRPYmouY21kXSkgewogICAgICAgICAgICAgIHN0YXRlID0gMDsKICAgICAgICAgICAgfQogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJmaW5kRGVmYXVsdElubGluZVN0cmVhbUVuZCAtIGBsZXhlci5rbm93bkNvbW1hbmRzYCBpcyB1bmRlZmluZWQuIik7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoc3RhdGUgPT09IDIpIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHN0YXRlID0gMDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGlmIChjaCA9PT0gLTEpIHsKICAgICAgKDAsIF91dGlsLndhcm4pKCJmaW5kRGVmYXVsdElubG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lYWs7CiAgICAgICAgY2FzZSAweGQ5OgogICAgICAgICAgZm91bmRFT0kgPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGMwOgogICAgICAgIGNhc2UgMHhjMToKICAgICAgICBjYXNlIDB4YzI6CiAgICAgICAgY2FzZSAweGMzOgogICAgICAgIGNhc2UgMHhjNToKICAgICAgICBjYXNlIDB4YzY6CiAgICAgICAgY2FzZSAweGM3OgogICAgICAgIGNhc2UgMHhjOToKICAgICAgICBjYXNlIDB4Y2E6CiAgICAgICAgY2FzZSAweGNiOgogICAgICAgIGNhc2UgMHhjZDoKICAgICAgICBjYXNlIDB4Y2U6CiAgICAgICAgY2FzZSAweGNmOgogICAgICAgIGNhc2UgMHhjNDoKICAgICAgICBjYXNlIDB4Y2M6CiAgICAgICAgY2FzZSAweGRhOgogICAgICAgIGNhc2UgMHhkYjoKICAgICAgICBjYXNlIDB4ZGM6CiAgICAgICAgY2FzZSAweGRkOgogICAgICAgIGNhc2UgMHhkZToKICAgICAgICBjYXNlIDB4ZGY6CiAgICAgICAgY2FzZSAweGUwOgogICAgICAgIGNhc2UgMHhlMToKICAgICAgICBjYXNlIDB4ZTI6CiAgICAgICAgY2FzZSAweGUzOgogICAgICAgIGNhc2UgMHhlNDoKICAgICAgICBjYXNlIDB4ZTU6CiAgICAgICAgY2FzZSAweGU2OgogICAgICAgIGNhc2UgMHhlNzoKICAgICAgICBjYXNlIDB4ZTg6CiAgICAgICAgY2FzZSAweGU5OgogICAgICAgIGNhc2UgMHhlYToKICAgICAgICBjYXNlIDB4ZWI6CiAgICAgICAgY2FzZSAweGVjOgogICAgICAgIGNhc2UgMHhlZDoKICAgICAgICBjYXNlIDB4ZWU6CiAgICAgICAgY2FzZSAweGVmOgogICAgICAgIGNhc2UgMHhmZToKICAgICAgICAgIG1hcmtlckxlbmd0aCA9IHN0cmVhbS5nZXRVaW50MTYoKTsKICAgICAgICAgIGlmIChtYXJrZXJMZW5ndGggPiAyKSB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wogICAgbGV0IHBvd2VyVmFsdWUgPSAwOwogICAgbGV0IHBvd2VyVmFsdWVTaWduID0gMTsKICAgIHdoaWxlICgoY2ggPSB0aGlzLm5leHRDaGFyKCkpID49IDApIHsKICAgICAgaWYgKGNoID49IDB4MzAgJiYgY2ggPD0gMHgzOSkgewogICAgICAgIGNvbnN0IGN1cnJlbnREaWdpdCA9IGNoIC0gMHgzMDsKICAgICAgICBpZiAoZU5vdGF0aW9uKSB7CiAgICAgICAgICBwb3dlclZhbHVlID0gcG93ZXJWYWx1ZSAqIDEwICsgY3VycmVudERpZ2l0OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBpZiAoZGl2aWRlQnkgIT09IDApIHsKICAgICAgICAgICAgZGl2aWRlQnkgKj0gMTA7CiAgICAgICAgICB9CiAgICAgICAgICBiYXNlVmFsdWUgPSBiYXNlVmFsdWUgKiAxMCArIGN1cnJlbnREaWdpdDsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoY2ggPT09IDB4MmUpIHsKICAgICAgICBpZiAoZGl2aWRlQnkgPT09IDApIHsKICAgICAgICAgIGRpdmlkZUJ5ID0gMTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGNoID09PSAweDJkKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJCYWRseSBmb3JtYXR0ZWQgbnVtYmVyOiBtaW51cyBzaWduIGluIHRoZSBtaWRkbGUiKTsKICAgICAgfSBlbHNlIGlmIChjaCA9PT0gMHg0NSB8fCBjaCA9PT0gMHg2NSkgewogICAgICAgIGNoID0gdGhpcy5wZWVrQ2hhcigpOwogICAgICAgIGlmIChjaCA9PT0gMHgyYiB8fCBjaCA9PT0gMHgyZCkgewogICAgICAgICAgcG93ZXJWYWx1ZVNpZ24gPSBjaCA9PT0gMHgyZCA/IC0xIDogMTsKICAgICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICB9IGVsc2UgaWYgKGNoIDwgMHgzMCB8fCBjaCA+IDB4MzkpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBlTm90YXRpb24gPSB0cnVlOwogICAgICB9IGVsc2UgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBpZiAoZGl2aWRlQnkgIT09IDApIHsKICAgICAgYmFzZVZhbHVlIC89IGRpdmlkZUJ5OwogICAgfQogICAgaWYgKGVOb3RhdGlvbikgewogICAgICBiYXNlVmFsdWUgKj0gMTAgKiogKHBvd2VyVmFsdWVTaWduICogcG93ZXJWYWx1ZSk7CiAgICB9CiAgICByZXR1cm4gc2lnbiAqIGJhc2VWYWx1ZTsKICB9CiAgZ2V0U3RyaW5nKCkgewogICAgbGV0IG51bVBhcmVuID0gMTsKICAgIGxldCBkb25lID0gZmFsc2U7CiAgICBjb25zdCBzdHJCdWYgPSB0aGlzLnN0ckJ1ZjsKICAgIHN0ckJ1Zi5sZW5ndGggPSAwOwogICAgbGV0IGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgd2hpbGUgKHRydWUpIHsKICAgICAgbGV0IGNoYXJCdWZmZXJlZCA9IGZhbHNlOwogICAgICBzd2l0Y2ggKGNoIHwgMCkgewogICAgICAgIGNhc2UgLTE6CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlVudGVybWluYXRlZCBzdHJpbmciKTsKICAgICAgICAgIGRvbmUgPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDI4OgogICAgICAgICAgKytudW1QYXJlbjsKICAgICAgICAgIHN0ckJ1Zi5wdXNoKCIoIik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4Mjk6CiAgICAgICAgICBpZiAoLS1udW1QYXJlbiA9PT0gMCkgewogICAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICAgIGRvbmUgPSB0cnVlOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RyQnVmLnB1c2goIikiKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHg1YzoKICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgc3dpdGNoIChjaCkgewogICAgICAgICAgICBjYXNlIC0xOgogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW50ZXJtaW5hdGVkIHN0cmluZyIpOwogICAgICAgICAgICAgIGRvbmUgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDB4NmU6CiAgICAgICAgICAgICAgc3RyQnVmLnB1c2goIlxuIik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHg3MjoKICAgICAgICAgICAgICBzdHJCdWYucHVzaCgiXHIiKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAweDc0OgogICAgICAgICAgICAgIHN0ckJ1Zi5wdXNoKCJcdCIpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDB4NjI6CiAgICAgICAgICAgICAgc3RyQnVmLnB1c2goIlxiIik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHg2NjoKICAgICAgICAgICAgICBzdHJCdWYucHVzaCgiXGYiKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAweDVjOgogICAgICAgICAgICBjYXNlIDB4Mjg6CiAgICAgICAgICAgIGNhc2UgMHgyOToKICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKGNoKSk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHgzMDoKICAgICAgICAgICAgY2FzZSAweDMxOgogICAgICAgICAgICBjYXNlIDB4MzI6CiAgICAgICAgICAgIGNhc2UgMHgzMzoKICAgICAgICAgICAgY2FzZSAweDM0OgogICAgICAgICAgICBjYXNlIDB4MzU6CiAgICAgICAgICAgIGNhc2UgMHgzNjoKICAgICAgICAgICAgY2FzZSAweDM3OgogICAgICAgICAgICAgIGxldCB4ID0gY2ggJiAweDBmOwogICAgICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgICAgIGNoYXJCdWZmZXJlZCA9IHRydWU7CiAgICAgICAgICAgICAgaWYgKGNoID49IDB4MzAgJiYgY2ggPD0gMHgzNykgewogICAgICAgICAgICAgICAgeCA9ICh4IDw8IDMpICsgKGNoICYgMHgwZik7CiAgICAgICAgICAgICAgICBjaCA9IHRoaXMubmV4dENoYXIoKTsKICAgICAgICAgICAgICAgIGlmIChjaCA+PSAweDMwICYmIGNoIDw9IDB4MzcpIHsKICAgICAgICAgICAgICAgICAgY2hhckJ1ZmZlcmVkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgIHggPSAoeCA8PCAzKSArIChjaCAmIDB4MGYpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKHgpKTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAweDBkOgogICAgICAgICAgICAgIGlmICh0aGlzLnBlZWtDaGFyKCkgPT09IDB4MGEpIHsKICAgICAgICAgICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMHgwYToKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICBzdHJCdWYucHVzaChTdHJpbmcuZnJvbUNoYXJDb2RlKGNoKSk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBkZWZhdWx0OgogICAgICAgICAgc3RyQnVmLnB1c2goU3RyaW5nLmZyb21DaGFyQ29kZShjaCkpOwogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKGRvbmUpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoIWNoYXJCdWZmZXJlZCkgewogICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gc3RyQnVmLmpvaW4oIiIpOwogIH0KICBnZXROYW1lKCkgewogICAgbGV0IGNoLCBwcmV2aW91c0NoOwogICAgY29uc3Qgc3RyQnVmID0gdGhpcy5zdHJCdWY7CiAgICBzdHJCdWYubGVuZ3RoID0gMDsKICAgIHdoaWxlICgoY2ggPSB0aGlzLm5leHRDaGFyKCkpID49IDAgJiYgIXNwZWNpYWxDaGFyc1tjaF0pIHsKICAgICAgaWYgKGNoID09PSAweDIzKSB7CiAgICAgICAgY2ggPSB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgaWYgKHNwZWNpYWxDaGFyc1tjaF0pIHsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiTGV4ZXJfZ2V0TmFtZTogIiArICJOVU1CRVIgU0lHTiAoIykgc2hvdWxkIGJlIGZvbGxvd2VkIGJ5IGEgaGV4YWRlY2ltYWwgbnVtYmVyLiIpOwogICAgICAgICAgc3RyQnVmLnB1c2goIiMiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBjb25zdCB4ID0gdG9IZXhEaWdpdChjaCk7CiAgICAgICAgaWYgKHggIT09IC0xKSB7CiAgICAgICAgICBwcmV2aW91c0NoID0gY2g7CiAgICAgICAgICBjaCA9IHRoaXMubmV4dENoYXIoKTsKICAgICAgICAgIGNvbnN0IHgyID0gdG9IZXhEaWdpdChjaCk7CiAgICAgICAgICBpZiAoeDIgPT09IC0xKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgTGV4ZXJfZ2V0TmFtZTogSWxsZWdhbCBkaWdpdCAoJHtTdHJpbmcuZnJvbUNoYXJDb2RlK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5uZXh0Q2hhcigpOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgc2Vjb25kRGlnaXQgPSB0b0hleERpZ2l0KGNoKTsKICAgICAgICAgIGlmIChzZWNvbmREaWdpdCA9PT0gLTEpIHsKICAgICAgICAgICAgdGhpcy5faGV4U3RyaW5nV2FybihjaCk7CiAgICAgICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHN0ckJ1Zi5wdXNoKFN0cmluZy5mcm9tQ2hhckNvZGUoZmlyc3REaWdpdCA8PCA0IHwgc2Vjb25kRGlnaXQpKTsKICAgICAgICB9CiAgICAgICAgaXNGaXJzdEhleCA9ICFpc0ZpcnN0SGV4OwogICAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gc3RyQnVmLmpvaW4oIiIpOwogIH0KICBnZXRPYmooKSB7CiAgICBsZXQgY29tbWVudCA9IGZhbHNlOwogICAgbGV0IGNoID0gdGhpcy5jdXJyZW50Q2hhcjsKICAgIHdoaWxlICh0cnVlKSB7CiAgICAgIGlmIChjaCA8IDApIHsKICAgICAgICByZXR1cm4gX3ByaW1pdGl2ZXMuRU9GOwogICAgICB9CiAgICAgIGlmIChjb21tZW50KSB7CiAgICAgICAgaWYgKGNoID09PSAweDBhIHx8IGNoID09PSAweDBkKSB7CiAgICAgICAgICBjb21tZW50ID0gZmFsc2U7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGNoID09PSAweDI1KSB7CiAgICAgICAgY29tbWVudCA9IHRydWU7CiAgICAgIH0gZWxzZSBpZiAoc3BlY2lhbENoYXJzW2NoXSAhPT0gMSkgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGNoID0gdGhpcy5uZXh0Q2hhcigpOwogICAgfQogICAgc3dpdGNoIChjaCB8IDApIHsKICAgICAgY2FzZSAweDMwOgogICAgICBjYXNlIDB4MzE6CiAgICAgIGNhc2UgMHgzMjoKICAgICAgY2FzZSAweDMzOgogICAgICBjYXNlIDB4MzQ6CiAgICAgIGNhc2UgMHgzNToKICAgICAgY2FzZSAweDM2OgogICAgICBjYXNlIDB4Mzc6CiAgICAgIGNhc2UgMHgzODoKICAgICAgY2FzZSAweDM5OgogICAgICBjYXNlIDB4MmI6CiAgICAgIGNhc2UgMHgyZDoKICAgICAgY2FzZSAweDJlOgogICAgICAgIHJldHVybiB0aGlzLmdldE51bWJlcigpOwogICAgICBjYXNlIDB4Mjg6CiAgICAgICAgcmV0dXJuIHRoaXMuZ2V0U3RyaW5nKCk7CiAgICAgIGNhc2UgMHgyZjoKICAgICAgICByZXR1cm4gdGhpcy5nZXROYW1lKCk7CiAgICAgIGNhc2UgMHg1YjoKICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgcmV0dXJuIF9wcmltaXRpdmVzLkNtZC5nZXQoIlsiKTsKICAgICAgY2FzZSAweDVkOgogICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICByZXR1cm4gX3ByaW1pdGl2ZXMuQ21kLmdldCgiXSIpOwogICAgICBjYXNlIDB4M2M6CiAgICAgICAgY2ggPSB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgaWYgKGNoID09PSAweDNjKSB7CiAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICByZXR1cm4gX3ByaW1pdGl2ZXMuQ21kLmdldCgiPDwiKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRoaXMuZ2V0SGV4U3RyaW5nKCk7CiAgICAgIGNhc2UgMHgzZToKICAgICAgICBjaCA9IHRoaXMubmV4dENoYXIoKTsKICAgICAgICBpZiAoY2ggPT09IDB4M2UpIHsKICAgICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICAgIHJldHVybiBfcHJpbWl0aXZlcy5DbWQuZ2V0KCI+PiI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mQgJiYga25vd25Db21tYW5kc1twb3NzaWJsZUNvbW1hbmRdID09PSB1bmRlZmluZWQpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoc3RyLmxlbmd0aCA9PT0gMTI4KSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBDb21tYW5kIHRva2VuIHRvbyBsb25nOiAke3N0ci5sZW5ndGh9YCk7CiAgICAgIH0KICAgICAgc3RyID0gcG9zc2libGVDb21tYW5kOwogICAgICBrbm93bkNvbW1hbmRGb3VuZCA9IGtub3duQ29tbWFuZHMgJiYga25vd25Db21tYW5kc1tzdHJdICE9PSB1bmRlZmluZWQ7CiAgICB9CiAgICBpZiAoc3RyID09PSAidHJ1ZSIpIHsKICAgICAgcmV0dXJuIHRydWU7CiAgICB9CiAgICBpZiAoc3RyID09PSAiZmFsc2UiKSB7CiAgICAgIHJldHVybiBmYWxzZTsKICAgIH0KICAgIGlmIChzdHIgPT09ICJudWxsIikgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIGlmIChzdHIgPT09ICJCSSIpIHsKICAgICAgdGhpcy5iZWdpbklubGluZUltYWdlUG9zID0gdGhpcy5zdHJlYW0ucG9zOwogICAgfQogICAgcmV0dXJuIF9wcmltaXRpdmVzLkNtZC5nZXQoc3RyKTsKICB9CiAgcGVla09iaigpIHsKICAgIGNvbnN0IHN0cmVhbVBvcyA9IHRoaXMuc3RyZWFtLnBvcywKICAgICAgY3VycmVudENoYXIgPSB0aGlzLmN1cnJlbnRDaGFyLAogICAgICBiZWdpbklubGluZUltYWdlUG9zID0gdGhpcy5iZWdpbklubGluZUltYWdlUG9zOwogICAgbGV0IG5leHRPYmo7CiAgICB0cnkgewogICAgICBuZXh0T2JqID0gdGhpcy5nZXRPYmooKTsKICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgIGlmIChleCBpbnN0YW5jZW9mIF9jb3JlX3V0aWxzLk1pc3NpbmdEYXRhRXhjZXB0a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1plcm9WYWx1ZSA/IG9iaiA+PSAwIDogb2JqID4gMCkpIHsKICAgICAgICByZXR1cm4gb2JqOwogICAgICB9CiAgICAgIHRocm93IG5ldyBFcnJvcihgVGhlICIke25hbWV9IiBwYXJhbWV0ZXIgaW4gdGhlIGxpbmVhcml6YXRpb24gYCArICJkaWN0aW9uYXJ5IGlzIGludmFsaWQuIik7CiAgICB9CiAgICBmdW5jdGlvbiBnZXRIaW50cyhsaW5EaWN0KSB7CiAgICAgIGNvbnN0IGhpbnRzID0gbGluRGljdC5nZXQoIkgiKTsKICAgICAgbGV0IGhpbnRzTGVuZ3RoOwogICAgICBpZiAoQXJyYXkuaXNBcnJheShoaW50cykgJiYgKChoaW50c0xlbmd0aCA9IGhpbnRzLmxlbmd0aCkgPT09IDIgfHwgaGludHNMZW5ndGggPT09IDQpKSB7CiAgICAgICAgZm9yIChsZXQgaW5kZXggPSAwOyBpbmRleCA8IGhpbnRzTGVuZ3RoOyBpbmRleCsrKSB7CiAgICAgICAgICBjb25zdCBoaW50ID0gaGludHNbaW5kZXhdOwogICAgICAgICAgaWYgKCEoTnVtYmVyLmlzSW50ZWdlcihoaW50KSAmJiBoaW50ID4gMCkpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBIaW50ICgke2luZGV4fSkgaW4gdGhlIGxpbmVhcml6YXRpb24gZGljdGlvbmFyeSBpcyBpbnZhbGlkLmApOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICByZXR1cm4gaGludHM7CiAgICAgIH0KICAgICAgdGhyb3cgbmV3IEVycm9yKCJIaW50IGFycmF5IGluIHRoZSBsaW5lYXJpemF0aW9uIGRpY3Rpb25hcnkgaXMgaW52YWxpZC4iKTsKICAgIH0KICAgIGNvbnN0IHBhcnNlciA9IG5ldyBQYXJzZXIoewogICAgICBsZXhlcjogbmV3IExleGVyKHN0cmVhbSksCiAgICAgIHhyZWY6IG51bGwKICAgIH0pOwogICAgY29uc3Qgb2JqMSA9IHBhcnNlci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NvbHVtbnMgPSB0aGlzLmNvbHVtbnM7CiAgICBsZXQgcmVmUG9zLCBibGFja1BpeGVscywgYml0cywgaTsKICAgIGlmICh0aGlzLm91dHB1dEJpdHMgPT09IDApIHsKICAgICAgaWYgKHRoaXMucm93c0RvbmUpIHsKICAgICAgICB0aGlzLmVvZiA9IHRydWU7CiAgICAgIH0KICAgICAgaWYgKHRoaXMuZW9mKSB7CiAgICAgICAgcmV0dXJuIC0xOwogICAgICB9CiAgICAgIHRoaXMuZXJyID0gZmFsc2U7CiAgICAgIGxldCBjb2RlMSwgY29kZTIsIGNvZGUzOwogICAgICBpZiAodGhpcy5uZXh0TGluZTJEKSB7CiAgICAgICAgZm9yIChpID0gMDsgY29kaW5nTGluZVtpXSA8IGNvbHVtbnM7ICsraSkgewogICAgICAgICAgcmVmTGluZVtpXSA9IGNvZGluZ0xpbmVbaV07CiAgICAgICAgfQogICAgICAgIHJlZkxpbmVbaSsrXSA9IGNvbHVtbnM7CiAgICAgICAgcmVmTGluZVtpXSA9IGNvbHVtbnM7CiAgICAgICAgY29kaW5nTGluZVswXSA9IDA7CiAgICAgICAgdGhpcy5jb2RpbmdQb3MgPSAwOwogICAgICAgIHJlZlBvcyA9IDA7CiAgICAgICAgYmxhY2tQaXhlbHMgPSAwOwogICAgICAgIHdoaWxlIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgIGNvZGUxID0gdGhpcy5fZ2V0VHdvRGltQ29kZSgpOwogICAgICAgICAgc3dpdGNoIChjb2RlMSkgewogICAgICAgICAgICBjYXNlIHR3b0RpbVBhc3M6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zICsgMV0sIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBpZiAocmVmTGluZVtyZWZQb3MgKyAxXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1Ib3JpejoKICAgICAgICAgICAgICBjb2RlMSA9IGNvZGUyID0gMDsKICAgICAgICAgICAgICBpZiAoYmxhY2tQaXhlbHMpIHsKICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgY29kZTEgKz0gY29kZTMgPSB0aGlzLl9nZXRCbGFja0NvZGUoKTsKICAgICAgICAgICAgICAgIH0gd2hpbGUgKGNvZGUzID49IDY0KTsKICAgICAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICAgICAgY29kZTIgKz0gY29kZTMgPSB0aGlzLl9nZXRXaGl0ZUNvZGUoKTsKICAgICAgICAgICAgICAgIH0gd2hpbGUgKGNvZGUzID49IDY0KTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICBjb2RlMSArPSBjb2RlMyA9IHRoaXMuX2dldFdoaXRlQ29kZSgpOwogICAgICAgICAgICAgICAgfSB3aGlsZSAoY29kZTMgPj0gNjQpOwogICAgICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgICAgICBjb2RlMiArPSBjb2RlMyA9IHRoaXMuX2dldEJsYWNrQ29kZSgpOwogICAgICAgICAgICAgICAgfSB3aGlsZSAoY29kZTMgPj0gNjQpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB0aGlzLl9hZGRQaXhlbHMoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gKyBjb2RlMSwgYmxhY2tQaXhlbHMpOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIHRoaXMuX2FkZFBpeGVscyhjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSArIGNvZGUyLCBibGFja1BpeGVscyBeIDEpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB3aGlsZSAocmVmTGluZVtyZWZQb3NdIDw9IGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdICYmIHJlZkxpbmVbcmVmUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0UjM6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zXSArIDMsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0UjI6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zXSArIDIsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0UjE6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKHJlZkxpbmVbcmVmUG9zXSArIDEsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0MDoKICAgICAgICAgICAgICB0aGlzLl9hZGRQaXhlbHMocmVmTGluZVtyZWZQb3NdLCBibGFja1BpeGVscyk7CiAgICAgICAgICAgICAgYmxhY2tQaXhlbHMgXj0gMTsKICAgICAgICAgICAgICBpZiAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICArK3JlZlBvczsKICAgICAgICAgICAgICAgIHdoaWxlIChyZWZMaW5lW3JlZlBvc10gPD0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gJiYgcmVmTGluZVtyZWZQb3NdIDwgY29sdW1ucykgewogICAgICAgICAgICAgICAgICByZWZQb3MgKz0gMjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgdHdvRGltVmVydEwzOgogICAgICAgICAgICAgIHRoaXMuX2FkZFBpeGVsc05lZyhyZWZMaW5lW3JlZlBvc10gLSAzLCBibGFja1BpeGVscyk7CiAgICAgICAgICAgICAgYmxhY2tQaXhlbHMgXj0gMTsKICAgICAgICAgICAgICBpZiAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICBpZiAocmVmUG9zID4gMCkgewogICAgICAgICAgICAgICAgICAtLXJlZlBvczsKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICsrcmVmUG9zOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgd2hpbGUgKHJlZkxpbmVbcmVmUG9zXSA8PSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSAmJiByZWZMaW5lW3JlZlBvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgICAgICAgIHJlZlBvcyArPSAyOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSB0d29EaW1WZXJ0TDI6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzTmVnKHJlZkxpbmVbcmVmUG9zXSAtIDIsIGJsYWNrUGl4ZWxzKTsKICAgICAgICAgICAgICBibGFja1BpeGVscyBePSAxOwogICAgICAgICAgICAgIGlmIChjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgIGlmIChyZWZQb3MgPiAwKSB7CiAgICAgICAgICAgICAgICAgIC0tcmVmUG9zOwogICAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgICAgKytyZWZQb3M7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB3aGlsZSAocmVmTGluZVtyZWZQb3NdIDw9IGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdICYmIHJlZkxpbmVbcmVmUG9zXSA8IGNvbHVtbnMpIHsKICAgICAgICAgICAgICAgICAgcmVmUG9zICs9IDI7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIHR3b0RpbVZlcnRMMToKICAgICAgICAgICAgICB0aGlzLl9hZGRQaXhlbHNOZWcocmVmTGluZVtyZWZQb3NdIC0gMSwgYmxhY2tQaXhlbHMpOwogICAgICAgICAgICAgIGJsYWNrUGl4ZWxzIF49IDE7CiAgICAgICAgICAgICAgaWYgKGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdIDwgY29sdW1ucykgewogICAgICAgICAgICAgICAgaWYgKHJlZlBvcyA+IDApIHsKICAgICAgICAgICAgICAgICAgLS1yZWZQb3M7CiAgICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICArK3JlZlBvczsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHdoaWxlIChyZWZMaW5lW3JlZlBvc10gPD0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gJiYgcmVmTGluZVtyZWZQb3NdIDwgY29sdW1ucykgewogICAgICAgICAgICAgICAgICByZWZQb3MgKz0gMjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgY2NpdHRFT0Y6CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKGNvbHVtbnMsIDApOwogICAgICAgICAgICAgIHRoaXMuZW9mID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoImJhZCAyZCBjb2RlIik7CiAgICAgICAgICAgICAgdGhpcy5fYWRkUGl4ZWxzKGNvbHVtbnMsIDApOwogICAgICAgICAgICAgIHRoaXMuZXJyID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29kaW5nTGluZVswXSA9IDA7CiAgICAgICAgdGhpcy5jb2RpbmdQb3MgPSAwOwogICAgICAgIGJsYWNrUGl4ZWxzID0gMDsKICAgICAgICB3aGlsZSAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICBjb2RlMSA9IDA7CiAgICAgICAgICBpZiAoYmxhY2tQaXhlbHMpIHsKICAgICAgICAgICAgZG8gewogICAgICAgICAgICAgIGNvZGUxICs9IGNvZGUzID0gdGhpcy5fZ2V0QmxhY2tDb2RlKCk7CiAgICAgICAgICAgIH0gd2hpbGUgKGNvZGUzID49IDY0KTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGRvIHsKICAgICAgICAgICAgICBjb2RlMSArPSBjb2RlMyA9IHRoaXMuX2dldFdoaXRlQ29kZSgpOwogICAgICAgICAgICB9IHdoaWxlIChjb2RlMyA+PSA2NCk7CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLl9hZGRQaXhlbHMoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gKyBjb2RlMSwgYmxhY2tQaXhlbHMpOwogICAgICAgICAgYmxhY2tQaXhlbHMgXj0gMTsKICAgICAgICB9CiAgICAgIH0KICAgICAgbGV0IGdvdEVPTCA9IGZhbHNlOwogICAgICBpZiAodGhpcy5ieXRlQWxpZ24pIHsKICAgICAgICB0aGlzLmlucHV0Qml0cyAmPSB+NzsKICAgICAgfQogICAgICBpZiAoIXRoaXMuZW9ibG9jayAmJiB0aGlzLnJvdyA9PT0gdGhpcy5yb3dzIC0gMSkgewogICAgICAgIHRoaXMucm93c0RvbmUgPSB0cnVlOwogICAgICB9IGVsc2UgewogICAgICAgIGNvZGUxID0gdGhpcy5fbG9va0JpdHMoMTIpOwogICAgICAgIGlmICh0aGlzLmVvbGluZSkgewogICAgICAgICAgd2hpbGUgKGNvZGUxICE9PSBjY2l0dEVPRiAmJiBjb2RlMSAhPT0gMSkgewogICAgICAgICAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgICAgICAgICBjb2RlMSA9IHRoaXMuX2xvb2tCaXRzKDEyKTsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgewogICAgICAgICAgd2hpbGUgKGNvZGUxID09PSAwKSB7CiAgICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICAgICAgICAgIGNvZGUxID0gdGhpcy5fbG9va0JpdHMoMTIpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoY29kZTEgPT09IDEpIHsKICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMTIpOwogICAgICAgICAgZ290RU9MID0gdHJ1ZTsKICAgICAgICB9IGVsc2UgaWYgKGNvZGUxID09PSBjY2l0dEVPRikgewogICAgICAgICAgdGhpcy5lb2YgPSB0cnVlOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoIXRoaXMuZW9mICYmIHRoaXMuZW5jb2RpbmcgPiAwICYmICF0aGlzLnJvd3NEb25lKSB7CiAgICAgICAgdGhpcy5uZXh0TGluZTJEID0gIXRoaXMuX2xvb2tCaXRzKDEpOwogICAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICAgIH0KICAgICAgaWYgKHRoaXMuZW9ibG9jayAmJiBnb3RFT0wgJiYgdGhpcy5ieXRlQWxpZ24pIHsKICAgICAgICBjb2RlMSA9IHRoaXMuX2xvb2tCaXRzKDEyKTsKICAgICAgICBpZiAoY29kZTEgPT09IDEpIHsKICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMTIpOwogICAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPiAwKSB7CiAgICAgICAgICAgIHRoaXMuX2xvb2tCaXRzKDEpOwogICAgICAgICAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPj0gMCkgewogICAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgNDsgKytpKSB7CiAgICAgICAgICAgICAgY29kZTEgPSB0aGlzLl9sb29rQml0cygxMik7CiAgICAgICAgICAgICAgaWYgKGNvZGUxICE9PSAxKSB7CiAgICAgICAgICAgICAgICAoMCwgX3V0aWwuaW5mbykoImJhZCBydGMgY29kZTogIiArIGNvZGUxKTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgdGhpcy5fZWF0Qml0cygxMik7CiAgICAgICAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPiAwKSB7CiAgICAgICAgICAgICAgICB0aGlzLl9sb29rQml0cygxKTsKICAgICAgICAgICAgICAgIHRoaXMuX2VhdEJpdHMoMSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLmVvZiA9IHRydWU7CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKHRoaXMuZXJyICYmIHRoaXMuZW9saW5lKSB7CiAgICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICAgIGNvZGUxID0gdGhpcy5fbG9va0JpdHMoMTMpOwogICAgICAgICAgaWYgKGNvZGUxID09PSBjY2l0dEVPRikgewogICAgICAgICAgICB0aGlzLmVvZiA9IHRydWU7CiAgICAgICAgICAgIHJldHVybiAtMTsKICAgICAgICAgIH0KICAgICAgICAgIGlmIChjb2RlMSA+PiAxID09PSAxKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgdGhpcy5fZWF0Qml0cygxKTsKICAgICAgICB9CiAgICAgICAgdGhpcy5fZWF0Qml0cygxMik7CiAgICAgICAgaWYgKHRoaXMuZW5jb2RpbmcgPiAwKSB7CiAgICAgICAgICB0aGlzLl9lYXRCaXRzKDEpOwogICAgICAgICAgdGhpcy5uZXh0TGluZTJEID0gIShjb2RlMSAmIDEpOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoY29kaW5nTGluZVswXSA+IDApIHsKICAgICAgICB0aGlzLm91dHB1dEJpdHMgPSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zID0gMF07CiAgICAgIH0gZWxzZSB7CiAgICAgICAgdGhpcy5vdXRwdXRCaXRzID0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1BvcyA9IDFdOwogICAgICB9CiAgICAgIHRoaXMucm93Kys7CiAgICB9CiAgICBsZXQgYzsKICAgIGlmICh0aGlzLm91dHB1dEJpdHMgPj0gOCkgewogICAgICBjID0gdGhpcy5jb2RpbmdQb3MgJiAxID8gMCA6IDB4ZmY7CiAgICAgIHRoaXMub3V0cHV0Qml0cyAtPSA4OwogICAgICBpZiAodGhpcy5vdXRwdXRCaXRzID09PSAwICYmIGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdIDwgY29sdW1ucykgewogICAgICAgIHRoaXMuY29kaW5nUG9zKys7CiAgICAgICAgdGhpcy5vdXRwdXRCaXRzID0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gLSBjb2RpbmdMaW5lW3RoaXMuY29kaW5nUG9zIC0gMV07CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGJpdHMgPSA4OwogICAgICBjID0gMDsKICAgICAgZG8gewogICAgICAgIGlmICh0eXBlb2YgdGhpcy5vdXRwdXRCaXRzICE9PSAibnVtYmVyIikgewogICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCdJbnZhbGlkIC9DQ0lUVEZheERlY29kZSBkYXRhLCAib3V0cHV0Qml0cyIgbXVzdCBiZSBhIG51bWJlci4nKTsKICAgICAgICB9CiAgICAgICAgaWYgKHRoaXMub3V0cHV0Qml0cyA+IGJpdHMpIHsKICAgICAgICAgIGMgPDw9IGJpdHM7CiAgICAgICAgICBpZiAoISh0aGlzLmNvZGluZ1BvcyAmIDEpKSB7CiAgICAgICAgICAgIGMgfD0gMHhmZiA+PiA4IC0gYml0czsKICAgICAgICAgIH0KICAgICAgICAgIHRoaXMub3V0cHV0Qml0cyAtPSBiaXRzOwogICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGMgPDw9IHRoaXMub3V0cHV0Qml0czsKICAgICAgICAgIGlmICghKHRoaXMuY29kaW5nUG9zICYgMSkpIHsKICAgICAgICAgICAgYyB8PSAweGZmID4+IDggLSB0aGlzLm91dHB1dEJpdHM7CiAgICAgICAgICB9CiAgICAgICAgICBiaXRzIC09IHRoaXMub3V0cHV0Qml0czsKICAgICAgICAgIHRoaXMub3V0cHV0Qml0cyA9IDA7CiAgICAgICAgICBpZiAoY29kaW5nTGluZVt0aGlzLmNvZGluZ1Bvc10gPCBjb2x1bW5zKSB7CiAgICAgICAgICAgIHRoaXMuY29kaW5nUG9zKys7CiAgICAgICAgICAgIHRoaXMub3V0cHV0Qml0cyA9IGNvZGluZ0xpbmVbdGhpcy5jb2RpbmdQb3NdIC0gY29kaW5nTGluZVt0aGlzLmNvZGluZ1BvcyAtIDFdOwogICAgICAgICAgfSBlbHNlIGlmIChiaXRzID4gMCkgewogICAgICAgICAgICBjIDw8PSBiaXRzOwogICAgICAgICAgICBiaXRzID0gMDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gd2hpbGUgKGJpdHMpOwogICAgfQogICAgaWYgKHRoaXMuYmxhY2spIHsKICAgICAgYyBePSAweGZmOwogICAgfQogICAgcmV0dXJuIGM7CiAgfQogIF9hZGRQaXhlbHMoYTEsIGJsYWNrUGl4ZWxzKSB7CiAgICBjb25zdCBjb2RpbmdMaW5lID0gdGhpcy5jb2RpbmdMaW5lOwogICAgbGV0IGNvZGluZ1BvcyA9IHRoaXMuY29kaW5nUG9zOwogICAgaWYgKGExID4gY29kaW5nTGluZVtjb2RpbmdQb3NdKSB7CiAgICAgIGlmIChhMSA+IHRoaXMuY29sdW1ucykgewogICAgICAgICgwLCBfdXR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V0dXJuIHBbMV07CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGNvbnN0IHJlc3VsdCA9IHRoaXMuX2ZpbmRUYWJsZUNvZGUoMSwgNywgdHdvRGltVGFibGUpOwogICAgICBpZiAocmVzdWx0WzBdICYmIHJlc3VsdFsyXSkgewogICAgICAgIHJldHVybiByZXN1bHRbMV07CiAgICAgIH0KICAgIH0KICAgICgwLCBfdXRpbC5pbmZvKSgiQmFkIHR3byBkaW0gY29kZSIpOwogICAgcmV0dXJuIGNjaXR0RU9GOwogIH0KICBfZ2V0V2hpdGVDb2RlKCkgewogICAgbGV0IGNvZGUgPSAwOwogICAgbGV0IHA7CiAgICBpZiAodGhpcy5lb2Jsb2NrKSB7CiAgICAgIGNvZGUgPSB0aGlzLl9sb29rQml0cygxMik7CiAgICAgIGlmIChjb2RlID09PSBjY2l0dEVPRikgewogICAgICAgIHJldHVybiAxOwogICAgICB9CiAgICAgIGlmIChjb2RlID4+IDUgPT09IDApIHsKICAgICAgICBwID0gd2hpdGVUYWJsZTFbY29kZV07CiAgICAgIH0gZWxzZSB7CiAgICAgICAgcCA9IHdoaXRlVGFibGUyW2NvZGUgPj4gM107CiAgICAgIH0KICAgICAgaWYgKHBbMF0gPiAwKSB7CiAgICAgICAgdGhpcy5fZWF0Qml0cyhwWzBdKTsKICAgICAgICByZXR1cm4gcFsxXTsKICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgbGV0IHJlc3VsdCA9IHRoaXMuX2ZpbmRUYWJsZUNvZGUoMSwgOSwgd2hpdGVUYWJsZTIpOwogICAgICBpZiAocmVzdWx0WzBdKSB7CiAgICAgICAgcmV0dXJuIHJlc3VsdFsxXTsKICAgICAgfQogICAgICByZXN1bHQgPSB0aGlzLl9maW5kVGFibGVDb2RlKDExLCAxMiwgd2hpdGVUYWJsZTEpOwogICAgICBpZiAocmVzdWx0WzBdKSB7CiAgICAgICAgcmV0dXJuIHJlc3VsdFsxXTsKICAgICAgfQogICAgfQogICAgKDAsIF91dGlsLmluZm8pKCJiYWQgd2hpdGUgY29kZSIpOwogICAgdGhpcy5fZWF0Qml0cygxKTsKICAgIHJldHVybiAxOwogIH0KICBfZ2V0QmxhY2tDb2RlKCkgewogICAgbGV0IGNvZGUsIHA7CiAgICBpZiAodGhpcy5lb2Jsb2NrKSB7CiAgICAgIGNvZGUgPSB0aGlzLl9sb29rQml0cygxMyk7CiAgICAgIGlmIChjb2RlID09PSBjY2l0dEVPRikgewogICAgICAgIHJldHVybiAxOwogICAgICB9CiAgICAgIGlmIChjb2RlID4+IDcgPT09IDApIHsKICAgICAgICBwID0gYmxhY2tUYWJsZTFbY29kZV07CiAgICAgIH0gZWxzZSBpZiAoY29kZSA+PiA5ID09PSAwICYmIGNvZGUgPj4gNyAhPT0gMCkgewogICAgICAgIHAgPSBibGFja1RhYmxlMlsoY29kZSA+PiAxKSAtIDY0XTsKICAgICAgfSBlbHNlIHsKICAgICAgICBwID0gYmxhY2tUYWJsZTNbY29kZSA+PiA3XTsKICAgICAgfQogICAgICBpZiAocFswXSA+IDApIHsKICAgICAgICB0aGlzLl9lYXRCaXRzKHBbMF0pOwogICAgICAgIHJldHVybiBwWzFdOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBsZXQgcmVzdWx0ID0gdGhpcy5fZmluZFRhYmxlQ29kZSgyLCA2LCBibGFja1RhYmxlMyk7CiAgICAgIGlmIChyZXN1bHRbMF0pIHsKICAgICAgICByZXR1cm4gcmVzdWx0WzFdOwogICAgICB9CiAgICAgIHJlc3VsdCA9IHRoaXMuX2ZpbmRUYWJsZUNvZGUoNywgMTIsIGJsYWNrVGFibGUyLCA2NCk7CiAgICAgIGlmIChyZXN1bHRbMF0pIHsKICAgICAgICByZXR1cm4gcmVzdWx0WzFdOwogICAgICB9CiAgICAgIHJlc3VsdCA9IHRoaXMuX2ZpbmRUYWJsZUNvZGUoMTAsIDEzLCBibGFja1RhYmxlMSk7CiAgICAgIGlmIChyZXN1bHRbMF0pIHsKICAgICA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BsZW5ndGhzW2ldOwogICAgICB9CiAgICB9CiAgICBjb25zdCBzaXplID0gMSA8PCBtYXhMZW47CiAgICBjb25zdCBjb2RlcyA9IG5ldyBJbnQzMkFycmF5KHNpemUpOwogICAgZm9yIChsZXQgbGVuID0gMSwgY29kZSA9IDAsIHNraXAgPSAyOyBsZW4gPD0gbWF4TGVuOyArK2xlbiwgY29kZSA8PD0gMSwgc2tpcCA8PD0gMSkgewogICAgICBmb3IgKGxldCB2YWwgPSAwOyB2YWwgPCBuOyArK3ZhbCkgewogICAgICAgIGlmIChsZW5ndGhzW3ZhbF0gPT09IGxlbikgewogICAgICAgICAgbGV0IGNvZGUyID0gMDsKICAgICAgICAgIGxldCB0ID0gY29kZTsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47ICsraSkgewogICAgICAgICAgICBjb2RlMiA9IGNvZGUyIDw8IDEgfCB0ICYgMTsKICAgICAgICAgICAgdCA+Pj0gMTsKICAgICAgICAgIH0KICAgICAgICAgIGZvciAoaSA9IGNvZGUyOyBpIDwgc2l6ZTsgaSArPSBza2lwKSB7CiAgICAgICAgICAgIGNvZGVzW2ldID0gbGVuIDw8IDE2IHwgdmFsOwogICAgICAgICAgfQogICAgICAgICAgKytjb2RlOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIFtjb2RlcywgbWF4TGVuXTsKICB9CiAgcmVhZEJsb2NrKCkgewogICAgbGV0IGJ1ZmZlciwgbGVuOwogICAgY29uc3Qgc3RyID0gdGhpcy5zdHI7CiAgICBsZXQgaGRyID0gdGhpcy5nZXRCaXRzKDMpOwogICAgaWYgKGhkciAmIDEpIHsKICAgICAgdGhpcy5lb2YgPSB0cnVlOwogICAgfQogICAgaGRyID4+PSAxOwogICAgaWYgKGhkciA9PT0gMCkgewogICAgICBsZXQgYjsKICAgICAgaWYgKChiID0gc3RyLmdldEJ5dGUoKSkgPT09IC0xKSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1h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W5ndGhzW2NvZGVMZW5Db2RlTWFwW2ldXSA9IHRoaXMuZ2V0Qml0cygzKTsKICAgICAgfQogICAgICBjb25zdCBjb2RlTGVuQ29kZVRhYiA9IHRoaXMuZ2VuZXJhdGVIdWZmbWFuVGFibGUoY29kZUxlbkNvZGVMZW5ndGhzKTsKICAgICAgbGVuID0gMDsKICAgICAgaSA9IDA7CiAgICAgIGNvbnN0IGNvZGVzID0gbnVtTGl0Q29kZXMgKyBudW1EaXN0Q29kZXM7CiAgICAgIGNvbnN0IGNvZGVMZW5ndGhzID0gbmV3IFVpbnQ4QXJyYXkoY29kZXMpOwogICAgICBsZXQgYml0c0xlbmd0aCwgYml0c09mZnNldCwgd2hhdDsKICAgICAgd2hpbGUgKGkgPCBjb2RlcykgewogICAgICAgIGNvbnN0IGNvZGUgPSB0aGlzLmdldENvZGUoY29kZUxlbkNvZGVUYWIpOwogICAgICAgIGlmIChjb2RlID09PSAxNikgewogICAgICAgICAgYml0c0xlbmd0aCA9IDI7CiAgICAgICAgICBiaXRzT2Zmc2V0ID0gMzsKICAgICAgICAgIHdoYXQgPSBsZW47CiAgICAgICAgfSBlbHNlIGlmIChjb2RlID09PSAxNykgewogICAgICAgICAgYml0c0xlbmd0aCA9IDM7CiAgICAgICAgICBiaXRzT2Zmc2V0ID0gMzsKICAgICAgICAgIHdoYXQgPSBsZW4gPSAwOwogICAgICAgIH0gZWxzZSBpZiAoY29kZSA9PT0gMTgpIHsKICAgICAgICAgIGJpdHNMZW5ndGggPSA3OwogICAgICAgICAgYml0c09mZnNldCA9IDExOwogICAgICAgICAgd2hhdCA9IGxlbiA9IDA7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGNvZGVMZW5ndGhzW2krK10gPSBsZW4gPSBjb2RlOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGxldCByZXBlYXRMZW5ndGggPSB0aGlzLmdldEJpdHMoYml0c0xlbmd0aCkgKyBiaXRzT2Zmc2V0OwogICAgIC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fSwgewogIHg6IDIsCiAgeTogLTIKfSwgewogIHg6IC0yLAogIHk6IC0xCn0sIHsKICB4OiAtMSwKICB5OiAtMQp9LCB7CiAgeDogMCwKICB5OiAtMQp9LCB7CiAgeDogMSwKICB5OiAtMQp9LCB7CiAgeDogMiwKICB5OiAtMQp9LCB7CiAgeDogLTMsCiAgeTogMAp9LCB7CiAgeDogLTIsCiAgeTogMAp9LCB7CiAgeDogLTEsCiAgeTogMAp9XSwgW3sKICB4OiAtMSwKICB5OiAtMgp9LCB7CiAgeDogMCwKICB5OiAtMgp9LCB7CiAgeDogMSwKICB5OiAtMgp9LCB7CiAgeDogLTIsCiAgeTogLTEKfSwgewogIHg6IC0xLAogIHk6IC0xCn0sIHsKICB4OiAwLAogIHk6IC0xCn0sIHsKICB4OiAxLAogIHk6IC0xCn0sIHsKICB4OiAtMiwKICB5OiAwCn0sIHsKICB4OiAtMSwKICB5OiAwCn1dLCBbewogIHg6IC0zLAogIHk6IC0xCn0sIHsKICB4OiAtMiwKICB5OiAtMQp9LCB7CiAgeDogLTEsCiAgeTogLTEKfSwgewogIHg6IDAsCiAgeTogLTEKfSwgewogIHg6IDEsCiAgeTogLTEKfSwgewogIHg6IC00LAogIHk6IDAKfSwgewogIHg6IC0zLAogIHk6IDAKfSwgewogIHg6IC0yLAogIHk6IDAKfSwgewogIHg6IC0xLAogIHk6IDAKfV1dOwpjb25zdCBSZWZpbmVtZW50VGVtcGxhdGVzID0gW3sKICBjb2Rpbmc6IFt7CiAgICB4OiAwLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAxLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAtMSwKICAgIHk6IDAKICB9XSwKICByZWZlcmVuY2U6IFt7CiAgICB4OiAwLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAxLAogICAgeTogLTEKICB9LCB7CiAgICB4OiAtMSwKICAgIHk6IDAKICB9LCB7CiAgICB4OiAwLAogICAgeTogMAogIH0sIHsKICAgIHg6IDEsCiAgICB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YOwogIGNvbnN0IHNiYl90b3AgPSAtbWluWTsKICBjb25zdCBzYmJfcmlnaHQgPSB3aWR0aCAtIG1heFg7CiAgY29uc3QgcHNldWRvUGl4ZWxDb250ZXh0ID0gUmV1c2VkQ29udGV4dHNbdGVtcGxhdGVJbmRleF07CiAgbGV0IHJvdyA9IG5ldyBVaW50OEFycmF5KHdpZHRoKTsKICBjb25zdCBiaXRtYXAgPSBbXTsKICBjb25zdCBkZWNvZGVyID0gZGVjb2RpbmdDb250ZXh0LmRlY29kZXI7CiAgY29uc3QgY29udGV4dHMgPSBkZWNvZGluZ0NvbnRleHQuY29udGV4dENhY2hlLmdldENvbnRleHRzKCJHQiIpOwogIGxldCBsdHAgPSAwLAogICAgaiwKICAgIGkwLAogICAgajAsCiAgICBjb250ZXh0TGFiZWwgPSAwLAogICAgYml0LAogICAgc2hpZnQ7CiAgZm9yIChsZXQgaSA9IDA7IGkgPCBoZWlnaHQ7IGkrKykgewogICAgaWYgKHByZWRpY3Rpb24pIHsKICAgICAgY29uc3Qgc2x0cCA9IGRlY29kZXIucmVhZEJpdChjb250ZXh0cywgcHNldWRvUGl4ZWxDb250ZXh0KTsKICAgICAgbHRwIF49IHNsdHA7CiAgICAgIGlmIChsdHApIHsKICAgICAgICBiaXRtYXAucHVzaChyb3cpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICB9CiAgICByb3cgPSBuZXcgVWludDhBcnJheShyb3cpOwogICAgYml0bWFwLnB1c2gocm93KTsKICAgIGZvciAoaiA9IDA7IGogPCB3aWR0aDsgaisrKSB7CiAgICAgIGlmICh1c2Vza2lwICYmIHNraXBbaV1bal0pIHsKICAgICAgICByb3dbal0gPSAwOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmIChqID49IHNiYl9sZWZ0ICYmIGogPCBzYmJfcmlnaHQgJiYgaSA+PSBzYmJfdG9wKSB7CiAgICAgICAgY29udGV4dExhYmVsID0gY29udGV4dExhYmVsIDw8IDEgJiByZXVzZU1hc2s7CiAgICAgICAgZm9yIChrID0gMDsgayA8IGNoYW5naW5nRW50cmllc0xlbmd0aDsgaysrKSB7CiAgICAgICAgICBpMCA9IGkgKyBjaGFuZ2luZ1RlbXBsYXRlWVtrXTsKICAgICAgICAgIGowID0gaiArIGNoYW5naW5nVGVtcGxhdGVYW2tdOwogICAgICAgICAgYml0ID0gYml0bWFwW2kwXVtqMF07CiAgICAgICAgICBpZiAoYml0KSB7CiAgICAgICAgICAgIGJpdCA9IGNoYW5naW5nVGVtcGxhdGVCaXRba107CiAgICAgICAgICAgIGNvbnRleHRMYWJlbCB8PSBiaXQ7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGNvbnRleHRMYWJlbCA9IDA7CiAgICAgICAgc2hpZnQgPSB0ZW1wbGF0ZUxlbmd0aCAtIDE7CiAgICAgICAgZm9yIChrID0gMDsgayA8IHRlbXBsYXRlTGVuZ3RoOyBrKyssIHNoaWZ0LS0pIHsKICAgICAgICAgIGowID0gaiArIHRlbXBsYXRlWFtrXTsKICAgICAgICAgIGlmIChqMCA+PSAwICYmIGowIDwgd2lkdGgpIHsKICAgICAgICAgICAgaTAgPSBpICsgdGVtcGxhdGVZW2tdOwogICAgICAgICAgICBpZiAoaTAgPj0gMCkgewogICAgICAgICAgICAgIGJpdCA9IGJpdG1hcFtpMF1bajBdOwogICAgICAgICAgICAgIGlmIChiaXQpIHsKICAgICAgICAgICAgICAgIGNvbnRleHRMYWJlbCB8PSBiaXQgPDwgc2hpZnQ7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIGNvbnN0IHBpeGVsID0gZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBjb250ZXh0TGFiZWwpOwogICAgICByb3dbal0gPSBwaXhlbDsKICAgIH0KICB9CiAgcmV0dXJuIGJpdG1hcDsKfQpmdW5jdGlvbiBkZWNvZGVSZWZp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aWcyRXJyb3IoInByZWRpY3Rpb24gaXMgbm90IHN1cHBvcnRlZCIpOwogICAgICB9CiAgICB9CiAgICBjb25zdCByb3cgPSBuZXcgVWludDhBcnJheSh3aWR0aCk7CiAgICBiaXRtYXAucHVzaChyb3cpOwogICAgZm9yIChsZXQgaiA9IDA7IGogPCB3aWR0aDsgaisrKSB7CiAgICAgIGxldCBpMCwgajA7CiAgICAgIGxldCBjb250ZXh0TGFiZWwgPSAwOwogICAgICBmb3IgKGsgPSAwOyBrIDwgY29kaW5nVGVtcGxhdGVMZW5ndGg7IGsrKykgewogICAgICAgIGkwID0gaSArIGNvZGluZ1RlbXBsYXRlWVtrXTsKICAgICAgICBqMCA9IGogKyBjb2RpbmdUZW1wbGF0ZVhba107CiAgICAgICAgaWYgKGkwIDwgMCB8fCBqMCA8IDAgfHwgajAgPj0gd2lkdGgpIHsKICAgICAgICAgIGNvbnRleHRMYWJlbCA8PD0gMTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY29udGV4dExhYmVsID0gY29udGV4dExhYmVsIDw8IDEgfCBiaXRtYXBbaTBdW2owXTsKICAgICAgICB9CiAgICAgIH0KICAgICAgZm9yIChrID0gMDsgayA8IHJlZmVyZW5jZVRlbXBsYXRlTGVuZ3RoOyBrKyspIHsKICAgICAgICBpMCA9IGkgKyByZWZlcmVuY2VUZW1wbGF0ZVlba10gLSBvZmZzZXRZOwogICAgICAgIGowID0gaiArIHJlZmVyZW5jZVRlbXBsYXRlWFtrXSAtIG9mZnNldFg7CiAgICAgICAgaWYgKGkwIDwgMCB8fCBpMCA+PSByZWZlcmVuY2VIZWlnaHQgfHwgajAgPCAwIHx8IGowID49IHJlZmVyZW5jZVdpZHRoKSB7CiAgICAgICAgICBjb250ZXh0TGFiZWwgPDw9IDE7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGNvbnRleHRMYWJlbCA9IGNvbnRleHRMYWJlbCA8PCAxIHwgcmVmZXJlbmNlQml0bWFwW2kwXVtqMF07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bWJvbHNEZWNvZGVkID0gc3ltYm9sV2lkdGhzLmxlbmd0aDsKICAgICAgaWYgKGZpcnN0U3ltYm9sID09PSBudW1iZXJPZlN5bWJvbHNEZWNvZGVkIC0gMSkgewogICAgICAgIG5ld1N5bWJvbHMucHVzaChjb2xsZWN0aXZlQml0bWFwKTsKICAgICAgfSBlbHNlIHsKICAgICAgICBsZXQgaSwKICAgICAgICAgIHksCiAgICAgICAgICB4TWluID0gMCwKICAgICAgICAgIHhNYXgsCiAgICAgICAgICBiaXRtYXBXaWR0aCwKICAgICAgICAgIHN5bWJvbEJpdG1hcDsKICAgICAgICBmb3IgKGkgPSBmaXJzdFN5bWJvbDsgaSA8IG51bWJlck9mU3ltYm9sc0RlY29kZWQ7IGkrKykgewogICAgICAgICAgYml0bWFwV2lkdGggPSBzeW1ib2xXaWR0aHNbaV07CiAgICAgICAgICB4TWF4ID0geE1pbiArIGJpdG1hcFdpZHRoOwogICAgICAgICAgc3ltYm9sQml0bWFwID0gW107CiAgICAgICAgICBmb3IgKHkgPSAwOyB5IDwgY3VycmVudEhlaWdodDsgeSsrKSB7CiAgICAgICAgICAgIHN5bWJvbEJpdG1hcC5wdXNoKGNvbGxlY3RpdmVCaXRtYXBbeV0uc3ViYXJyYXkoeE1pbiwgeE1heCkpOwogICAgICAgICAgfQogICAgICAgICAgbmV3U3ltYm9scy5wdXNoKHN5bWJvbEJpdG1hcCk7CiAgICAgICAgICB4TWluID0geE1heDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICB9CiAgY29uc3QgZXhwb3J0ZWRTeW1ib2xzID0gW10sCiAgICBmbGFncyA9IFtdOwogIGxldCBjdXJyZW50RmxhZyA9IGZhbHNlLAogICAgaSwKICAgIGlpOwogIGNvbnN0IHRvdGFsU3ltYm9sc0xlbmd0aCA9IHN5bWJvbHMubGVuZ3RoICsgbnVtYmVyT2ZOZXdTeW1ib2xzOwogIHdoaWxlIChmbGFncy5sZW5ndGggPCB0b3RhbFN5bWJvbHNMZW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WJvbFJvdyA9IHN5bWJvbEJpdG1hcFtzMl07CiAgICAgICAgICBjb25zdCBtYXhXaWR0aCA9IE1hdGgubWluKHdpZHRoIC0gb2Zmc2V0VCwgc3ltYm9sV2lkdGgpOwogICAgICAgICAgc3dpdGNoIChjb21iaW5hdGlvbk9wZXJhdG9yKSB7CiAgICAgICAgICAgIGNhc2UgMDoKICAgICAgICAgICAgICBmb3IgKHQyID0gMDsgdDIgPCBtYXhXaWR0aDsgdDIrKykgewogICAgICAgICAgICAgICAgcm93W29mZnNldFQgKyB0Ml0gfD0gc3ltYm9sUm93W3QyXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMjoKICAgICAgICAgICAgICBmb3IgKHQyID0gMDsgdDIgPCBtYXhXaWR0aDsgdDIrKykgewogICAgICAgICAgICAgICAgcm93W29mZnNldFQgKyB0Ml0gXj0gc3ltYm9sUm93W3QyXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgdGhyb3cgbmV3IEpiaWcyRXJyb3IoYG9wZXJhdG9yICR7Y29tYmluYXRpb25PcGVyYXRvcn0gaXMgbm90IHN1cHBvcnRlZGApOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjdXJyZW50UyArPSBzeW1ib2xIZWlnaHQgLSAxOwogICAgICB9IGVsc2UgewogICAgICAgIGZvciAodDIgPSAwOyB0MiA8IHN5bWJvbEhlaWdodDsgdDIrKykgewogICAgICAgICAgcm93ID0gYml0bWFwW29mZnNldFQgKyB0Ml07CiAgICAgICAgICBpZiAoIXJvdykgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHN5bWJvbFJvdyA9IHN5bWJvbEJpdG1hcFt0Ml07CiAgICAgICAgICBzd2l0Y2ggKGNvbWJpbmF0aW9uT3BlcmF0b3IpIHsKICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgIGZvciAoczIgPSAwOyBzMiA8IHN5bWJvbFdpZHRoOyBzMisrKSB7CiAgICAgICAgICAgICAgICByb3dbb2Zmc2V0UyArIHMyXSB8PSBzeW1ib2xSb3dbczJdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgIGZvciAoczIgPSAwOyBzMiA8IHN5bWJvbFdpZHRoOyBzMisrKSB7CiAgICAgICAgICAgICAgICByb3dbb2Zmc2V0UyArIHMyXSBePSBzeW1ib2xSb3dbczJdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICB0aHJvdyBuZXcgSmJpZzJFcnJvcihgb3BlcmF0b3IgJHtjb21iaW5hdGlvbk9wZXJhdG9yfSBpcyBub3Qgc3VwcG9ydGVkYCk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGN1cnJlbnRTICs9IHN5bWJvbFdpZHRoIC0gMTsKICAgICAgfQogICAgICBpKys7CiAgICAgIGNvbnN0IGRlbHRhUyA9IGh1ZmZtYW4gPyBodWZmbWFuVGFibGVzLnRhYmxlRGVsdGFTLmRlY29kZShodWZmbWFuSW5wdXQpIDogZGVjb2RlSW50ZWdlcihjb250ZXh0Q2FjaGUsICJJQURTIiwgZGVjb2Rlcik7CiAgICAgIGlmIChkZWx0YVMgPT09IG51bGwpIHsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBjdXJyZW50UyArPSBkZWx0YVMgKyBkc09mZnNldDsKICAgIH0gd2hpbGUgKHRydWUpOwogIH0KICByZXR1cm4gYml0bWFwOwp9CmZ1bmN0aW9uIGRlY29kZVBhdHRlcm5EaWN0aW9uYXJ5KG1tciwgcGF0dGVybldpZHRoLCBwYXR0ZXJuSGVpZ2h0LCBtYXhQYXR0ZXJuSW5kZXgsIHRlbXBsYXRlLCBkZWNvZGluZ0NvbnRleHQpIHsKICBjb25zdCBhdCA9IFtdOwogIGlmICghbW1yKSB7CiAgICBhdC5wdXNoKHsKICAgICAgeDogLXBhdHRlcm5XaWR0aCwKICAgICAgeTogMAogICAgfSk7CiAgICBpZiAodGVtcGxhdGUgPT09IDApIHsKICAgICAgYXQucHVzaCh7CiAgICAgICAgeDogLTMsCiAgICAgICAgeTogLTEKICAgICAgfSwgewogICAgICAgIHg6IDIsCiAgICAgICAgeTogLTIKICAgICAgfSwgewogICAgICAgIHg6IC0yLAogICAgICAgIHk6IC0yCiAgICAgIH0pOwogICAgfQogIH0KICBjb25zdCBjb2xsZWN0aXZlV2lkdGggPSAobWF4UGF0dGVybkluZGV4ICsgMSkgKiBwYXR0ZXJuV2lkdGg7CiAgY29uc3QgY29sbGVjdGl2ZUJpdG1hcCA9IGRlY29kZUJpdG1hcChtbXIsIGNvbGxlY3RpdmVXaWR0aCwgcGF0dGVybkhlaWdodCwgdGVtcGxhdGUsIGZhbHNlLCBudWxsLCBhdCwgZGVjb2RpbmdDb250ZXh0KTsKICBjb25zdCBwYXR0ZXJucyA9IFtdOwogIGZvciAobGV0IGkgPSAwOyBpIDw9IG1heFBhdHRlcm5JbmRleDsgaSsrKSB7CiAgICBjb25zdCBwYXR0ZXJuQml0bWFwID0gW107CiAgICBjb25zdCB4TWluID0gcGF0dGVybldpZHRoICogaTsKICAgIGNvbnN0IHhNYXggPSB4TWluICsgcGF0dGVybldpZHRoOwogICAgZm9yIChsZXQgeSA9IDA7IHkgPCBwYXR0ZXJuSGVpZ2h0OyB5KyspIHsKICAgICAgcGF0dGVybkJpdG1hcC5wdXNoKGNvbGxlY3RpdmVCaXRtYXBbeV0uc3ViYXJyYXkoeE1pbiwgeE1heCkpOwogICAgfQogICAgcGF0dGVybnMucHVzaChwYXR0ZXJuQml0bWFwKTsKICB9CiAgcmV0dXJuIHBhdHRlcm5zOwp9CmZ1bmN0aW9uIGRlY29kZUhhbGZ0b25lUmVnaW9uKG1tci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dbal07CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGxldCByZWdpb25YLCByZWdpb25ZOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBwYXR0ZXJuSGVpZ2h0OyBpKyspIHsKICAgICAgICAgIHJlZ2lvblkgPSB5ICsgaTsKICAgICAgICAgIGlmIChyZWdpb25ZIDwgMCB8fCByZWdpb25ZID49IHJlZ2lvbkhlaWdodCkgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIHJlZ2lvblJvdyA9IHJlZ2lvbkJpdG1hcFtyZWdpb25ZXTsKICAgICAgICAgIHBhdHRlcm5Sb3cgPSBwYXR0ZXJuQml0bWFwW2ldOwogICAgICAgICAgZm9yIChqID0gMDsgaiA8IHBhdHRlcm5XaWR0aDsgaisrKSB7CiAgICAgICAgICAgIHJlZ2lvblggPSB4ICsgajsKICAgICAgICAgICAgaWYgKHJlZ2lvblggPj0gMCAmJiByZWdpb25YIDwgcmVnaW9uV2lkdGgpIHsKICAgICAgICAgICAgICByZWdpb25Sb3dbcmVnaW9uWF0gfD0gcGF0dGVyblJvd1tqXTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfQogIH0KICByZXR1cm4gcmVnaW9uQml0bWFwOwp9CmZ1bmN0aW9uIHJlYWRTZWdtZW50SGVhZGVyKGRhdGEsIHN0YXJ0KSB7CiAgY29uc3Qgc2VnbWVudEhlYWRlciA9IHt9OwogIHNlZ21lbnRIZWFkZXIubnVtYmVyID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MzIpKGRhdGEsIHN0YXJ0KTsKICBjb25zdCBmbGFncyA9IGRhdGFbc3RhcnQgKyA0XTsKICBjb25zdCBzZWdtZW50VHlwZSA9IGZsYWdzICYgMHgzZjsKICBpZiAoIVNlZ21lbnRUeXBlc1tzZWdtZW50VHlwZV0pIHsKICAgIHRocm93IG5ldyBKYmlnMkVycm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Zmc2V0ID0gb2Zmc2V0MDsKICAgICAgICAgIGZvciAoaiA9IDA7IGogPCB3aWR0aDsgaisrKSB7CiAgICAgICAgICAgIGlmIChiaXRtYXBbaV1bal0pIHsKICAgICAgICAgICAgICBidWZmZXJbb2Zmc2V0XSB8PSBtYXNrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG1hc2sgPj49IDE7CiAgICAgICAgICAgIGlmICghbWFzaykgewogICAgICAgICAgICAgIG1hc2sgPSAxMjg7CiAgICAgICAgICAgICAgb2Zmc2V0Kys7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIG9mZnNldDAgKz0gcm93U2l6ZTsKICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgMjoKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgaGVpZ2h0OyBpKyspIHsKICAgICAgICAgIG1hc2sgPSBtYXNrMDsKICAgICAgICAgIG9mZnNldCA9IG9mZnNldDA7CiAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgd2lkdGg7IGorKykgewogICAgICAgICAgICBpZiAoYml0bWFwW2ldW2pdKSB7CiAgICAgICAgICAgICAgYnVmZmVyW29mZnNldF0gXj0gbWFzazsKICAgICAgICAgICAgfQogICAgICAgICAgICBtYXNrID4+PSAxOwogICAgICAgICAgICBpZiAoIW1hc2spIHsKICAgICAgICAgICAgICBtYXNrID0gMTI4OwogICAgICAgICAgICAgIG9mZnNldCsrOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBvZmZzZXQwICs9IHJvd1NpemU7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBkZWZhdWx0OgogICAgICAgIHRocm93IG5ldyBKYmlnMkVycm9yKGBvcGVyYXRvciAke2NvbWJpbmF0aW9uT3BlcmF0b3J9IGlzIG5vdCBzdXBwb3J0ZWRgKTsKICAgIH0KICB9CiAgb25JbW1lZGlhdGVHZW5lcmljUmVnaW9uKHJlZ2lvbiwgZGF0YS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IHFlSWN4OwogICAgICBpZiAoKGEgJiAweDgwMDApICE9PSAwKSB7CiAgICAgICAgdGhpcy5hID0gYTsKICAgICAgICByZXR1cm4gY3hfbXBzOwogICAgICB9CiAgICAgIGlmIChhIDwgcWVJY3gpIHsKICAgICAgICBkID0gMSBeIGN4X21wczsKICAgICAgICBpZiAocWVUYWJsZUljeC5zd2l0Y2hGbGFnID09PSAxKSB7CiAgICAgICAgICBjeF9tcHMgPSBkOwogICAgICAgIH0KICAgICAgICBjeF9pbmRleCA9IHFlVGFibGVJY3gubmxwczsKICAgICAgfSBlbHNlIHsKICAgICAgICBkID0gY3hfbXBzOwogICAgICAgIGN4X2luZGV4ID0gcWVUYWJsZUljeC5ubXBzOwogICAgICB9CiAgICB9CiAgICBkbyB7CiAgICAgIGlmICh0aGlzLmN0ID09PSAwKSB7CiAgICAgICAgdGhpcy5ieXRlSW4oKTsKICAgICAgfQogICAgICBhIDw8PSAxOwogICAgICB0aGlzLmNoaWdoID0gdGhpcy5jaGlnaCA8PCAxICYgMHhmZmZmIHwgdGhpcy5jbG93ID4+IDE1ICYgMTsKICAgICAgdGhpcy5jbG93ID0gdGhpcy5jbG93IDw8IDEgJiAweGZmZmY7CiAgICAgIHRoaXMuY3QtLTsKICAgIH0gd2hpbGUgKChhICYgMHg4MDAwKSA9PT0gMCk7CiAgICB0aGlzLmEgPSBhOwogICAgY29udGV4dHNbcG9zXSA9IGN4X2luZGV4IDw8IDEgfCBjeF9tcHM7CiAgICByZXR1cm4gZDsKICB9Cn0KZXhwb3J0cy5Bcml0aG1ldGljRGVjb2RlciA9IEFyaXRobWV0aWNEZWNvZGVyOwoKLyoqKi8gfSksCi8qIDE2MSAqLwovKioqLyAoKF9fdW51c2VkX3dlYnBhY2tfbW9kdWxlLCBleHBvcnRzLCBfX3dfcGRmanNfcmVxdWlyZV9fKSA9PiB7CgoidXNlIHN0cmljdCI7CgoKT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICJfX2VzTW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5ndGggPT09IDEpIHsKICAgICAgcmV0dXJuIHJlYWRCaXQoKSA9PT0gMSA/IDEgOiAtMTsKICAgIH0KICAgIGNvbnN0IG4gPSByZWNlaXZlKGxlbmd0aCk7CiAgICBpZiAobiA+PSAxIDw8IGxlbmd0aCAtIDEpIHsKICAgICAgcmV0dXJuIG47CiAgICB9CiAgICByZXR1cm4gbiArICgtMSA8PCBsZW5ndGgpICsgMTsKICB9CiAgZnVuY3Rpb24gZGVjb2RlQmFzZWxpbmUoY29tcG9uZW50LCBibG9ja09mZnNldCkgewogICAgY29uc3QgdCA9IGRlY29kZUh1ZmZtYW4oY29tcG9uZW50Lmh1ZmZtYW5UYWJsZURDKTsKICAgIGNvbnN0IGRpZmYgPSB0ID09PSAwID8gMCA6IHJlY2VpdmVBbmRFeHRlbmQodCk7CiAgICBjb21wb25lbnQuYmxvY2tEYXRhW2Jsb2NrT2Zmc2V0XSA9IGNvbXBvbmVudC5wcmVkICs9IGRpZmY7CiAgICBsZXQgayA9IDE7CiAgICB3aGlsZSAoayA8IDY0KSB7CiAgICAgIGNvbnN0IHJzID0gZGVjb2RlSHVmZm1hbihjb21wb25lbnQuaHVmZm1hblRhYmxlQUMpOwogICAgICBjb25zdCBzID0gcnMgJiAxNSwKICAgICAgICByID0gcnMgPj4gNDsKICAgICAgaWYgKHMgPT09IDApIHsKICAgICAgICBpZiAociA8IDE1KSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgayArPSAxNjsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBrICs9IHI7CiAgICAgIGNvbnN0IHogPSBkY3RaaWdaYWdba107CiAgICAgIGNvbXBvbmVudC5ibG9ja0RhdGFbYmxvY2tPZmZzZXQgKyB6XSA9IHJlY2VpdmVBbmRFeHRlbmQocyk7CiAgICAgIGsrKzsKICAgIH0KICB9CiAgZnVuY3Rpb24gZGVjb2RlRENGaXJzdChjb21wb25lbnQsIGJsb2NrT2Zmc2V0KSB7CiAgICBjb25zdCB0ID0gZGVjb2RlSHVmZm1hbihjb21wb25lbnQuaHVmZm1hblRhYmxlREMpOwogICAgY29uc3QgZGlmZiA9IHQgPT09IDAgPyAwIDogcmVjZWl2ZUFuZEV4dGVuZCh0KSA8PCBzdWNjZXNzaXZlOwogICAgY29tcG9uZW50LmJsb2NrRGF0YVtibG9ja09mZnNldF0gPSBjb21wb25lbnQucHJlZCArPSBkaWZmOwogIH0KICBmdW5jdGlvbiBkZWNvZGVEQ1N1Y2Nlc3NpdmUoY29tcG9uZW50LCBibG9ja09mZnNldCkgewogICAgY29tcG9uZW50LmJsb2NrRGF0YVtibG9ja09mZnNldF0gfD0gcmVhZEJpdCgpIDw8IHN1Y2Nlc3NpdmU7CiAgfQogIGxldCBlb2JydW4gPSAwOwogIGZ1bmN0aW9uIGRlY29kZUFDRmlyc3QoY29tcG9uZW50LCBibG9ja09mZnNldCkgewogICAgaWYgKGVvYnJ1biA+IDApIHsKICAgICAgZW9icnVuLS07CiAgICAgIHJldHVybjsKICAgIH0KICAgIGxldCBrID0gc3BlY3RyYWxTdGFydDsKICAgIGNvbnN0IGUgPSBzcGVjdHJhbEVuZDsKICAgIHdoaWxlIChrIDw9IGUpIHsKICAgICAgY29uc3QgcnMgPSBkZWNvZGVIdWZmbWFuKGNvbXBvbmVudC5odWZmbWFuVGFibGVBQyk7CiAgICAgIGNvbnN0IHMgPSBycyAmIDE1LAogICAgICAgIHIgPSBycyA+PiA0OwogICAgICBpZiAocyA9PT0gMCkgewogICAgICAgIGlmIChyIDwgMTUpIHsKICAgICAgICAgIGVvYnJ1biA9IHJlY2VpdmUocikgKyAoMSA8PCByKSAtIDE7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgayArPSAxNjsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBrICs9IHI7CiAgICAgIGNvbnN0IHogPSBkY3RaaWdaYWdba107CiAgICAgIGNvbXBvbmVudC5ibG9ja0RhdGFbYmxvY2tPZmZzZXQgK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AgIHRocm93IG5ldyBKcGVnRXJyb3IoImludmFsaWQgQUNuIGVuY29kaW5nIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc3VjY2Vzc2l2ZUFDTmV4dFZhbHVlID0gcmVjZWl2ZUFuZEV4dGVuZChzKTsKICAgICAgICAgICAgc3VjY2Vzc2l2ZUFDU3RhdGUgPSByID8gMiA6IDM7CiAgICAgICAgICB9CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICBjYXNlIDE6CiAgICAgICAgY2FzZSAyOgogICAgICAgICAgaWYgKGNvbXBvbmVudC5ibG9ja0RhdGFbb2Zmc2V0Wl0pIHsKICAgICAgICAgICAgY29tcG9uZW50LmJsb2NrRGF0YVtvZmZzZXRaXSArPSBzaWduICogKHJlYWRCaXQoKSA8PCBzdWNjZXNzaXZlKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHItLTsKICAgICAgICAgICAgaWYgKHIgPT09IDApIHsKICAgICAgICAgICAgICBzdWNjZXNzaXZlQUNTdGF0ZSA9IHN1Y2Nlc3NpdmVBQ1N0YXRlID09PSAyID8gMyA6IDA7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMzoKICAgICAgICAgIGlmIChjb21wb25lbnQuYmxvY2tEYXRhW29mZnNldFpdKSB7CiAgICAgICAgICAgIGNvbXBvbmVudC5ibG9ja0RhdGFbb2Zmc2V0Wl0gKz0gc2lnbiAqIChyZWFkQml0KCkgPDwgc3VjY2Vzc2l2ZSk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBjb21wb25lbnQuYmxvY2tEYXRhW29mZnNldFpdID0gc3VjY2Vzc2l2ZUFDTmV4dFZhbHVlIDw8IHN1Y2Nlc3NpdmU7CiAgICAgICAgICAgIHN1Y2Nlc3NpdmVBQ1N0YXRlID0gMDsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgNDoKICAgIC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N1RXhwZWN0ZWQ7CiAgICBpZiAobWN1VG9SZWFkID4gMCkgewogICAgICBmb3IgKGkgPSAwOyBpIDwgY29tcG9uZW50c0xlbmd0aDsgaSsrKSB7CiAgICAgICAgY29tcG9uZW50c1tpXS5wcmVkID0gMDsKICAgICAgfQogICAgICBlb2JydW4gPSAwOwogICAgICBpZiAoY29tcG9uZW50c0xlbmd0aCA9PT0gMSkgewogICAgICAgIGNvbXBvbmVudCA9IGNvbXBvbmVudHNbMF07CiAgICAgICAgZm9yIChuID0gMDsgbiA8IG1jdVRvUmVhZDsgbisrKSB7CiAgICAgICAgICBkZWNvZGVCbG9jayhjb21wb25lbnQsIGRlY29kZUZuLCBtY3UpOwogICAgICAgICAgbWN1Kys7CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGZvciAobiA9IDA7IG4gPCBtY3VUb1JlYWQ7IG4rKykgewogICAgICAgICAgZm9yIChpID0gMDsgaSA8IGNvbXBvbmVudHNMZW5ndGg7IGkrKykgewogICAgICAgICAgICBjb21wb25lbnQgPSBjb21wb25lbnRzW2ldOwogICAgICAgICAgICBoID0gY29tcG9uZW50Lmg7CiAgICAgICAgICAgIHYgPSBjb21wb25lbnQudjsKICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IHY7IGorKykgewogICAgICAgICAgICAgIGZvciAoayA9IDA7IGsgPCBoOyBrKyspIHsKICAgICAgICAgICAgICAgIGRlY29kZU1jdShjb21wb25lbnQsIGRlY29kZUZuLCBtY3UsIGosIGspOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgbWN1Kys7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBiaXRzQ291bnQgPSAwOwogICAgZmlsZU1hcmtlciA9IGZpbmROZXh0RmlsZU1hcmtlcihkYXRhLCBvZmZzZXQpOwogICAgaWYgKCFmaWxlTWFya2VyKSB7CiAgICAgIGJyZWFrOwogICAgfQogICAgaWYgKGZpbGVNYXJrZX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+IDEyOwogICAgdjUgPSB2NSAqIGRjdENvczEgLSB2NiAqIGRjdFNpbjEgKyAyMDQ4ID4+IDEyOwogICAgdjYgPSB0OwogICAgcDAgPSB2MCArIHY3OwogICAgcDcgPSB2MCAtIHY3OwogICAgcDEgPSB2MSArIHY2OwogICAgcDYgPSB2MSAtIHY2OwogICAgcDIgPSB2MiArIHY1OwogICAgcDUgPSB2MiAtIHY1OwogICAgcDMgPSB2MyArIHY0OwogICAgcDQgPSB2MyAtIHY0OwogICAgaWYgKHAwIDwgMTYpIHsKICAgICAgcDAgPSAwOwogICAgfSBlbHNlIGlmIChwMCA+PSA0MDgwKSB7CiAgICAgIHAwID0gMjU1OwogICAgfSBlbHNlIHsKICAgICAgcDAgPj49IDQ7CiAgICB9CiAgICBpZiAocDEgPCAxNikgewogICAgICBwMSA9IDA7CiAgICB9IGVsc2UgaWYgKHAxID49IDQwODApIHsKICAgICAgcDEgPSAyNTU7CiAgICB9IGVsc2UgewogICAgICBwMSA+Pj0gNDsKICAgIH0KICAgIGlmIChwMiA8IDE2KSB7CiAgICAgIHAyID0gMDsKICAgIH0gZWxzZSBpZiAocDIgPj0gNDA4MCkgewogICAgICBwMiA9IDI1NTsKICAgIH0gZWxzZSB7CiAgICAgIHAyID4+PSA0OwogICAgfQogICAgaWYgKHAzIDwgMTYpIHsKICAgICAgcDMgPSAwOwogICAgfSBlbHNlIGlmIChwMyA+PSA0MDgwKSB7CiAgICAgIHAzID0gMjU1OwogICAgfSBlbHNlIHsKICAgICAgcDMgPj49IDQ7CiAgICB9CiAgICBpZiAocDQgPCAxNikgewogICAgICBwNCA9IDA7CiAgICB9IGVsc2UgaWYgKHA0ID49IDQwODApIHsKICAgICAgcDQgPSAyNTU7CiAgICB9IGVsc2UgewogICAgICBwNCA+Pj0gNDsKICAgIH0KICAgIGlmIChwNSA8IDE2KSB7CiAgICAgIHA1ID0gMDsKICAgIH0gZWxzZSBpZiAocDUgPj0gNDA4MCkgewogICAgICBwNSA9IDI1N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Hg0NiAmJiBhcHBEYXRhWzRdID09PSAwKSB7CiAgICAgICAgICAgICAgamZpZiA9IHsKICAgICAgICAgICAgICAgIHZlcnNpb246IHsKICAgICAgICAgICAgICAgICAgbWFqb3I6IGFwcERhdGFbNV0sCiAgICAgICAgICAgICAgICAgIG1pbm9yOiBhcHBEYXRhWzZdCiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgZGVuc2l0eVVuaXRzOiBhcHBEYXRhWzddLAogICAgICAgICAgICAgICAgeERlbnNpdHk6IGFwcERhdGFbOF0gPDwgOCB8IGFwcERhdGFbOV0sCiAgICAgICAgICAgICAgICB5RGVuc2l0eTogYXBwRGF0YVsxMF0gPDwgOCB8IGFwcERhdGFbMTFdLAogICAgICAgICAgICAgICAgdGh1bWJXaWR0aDogYXBwRGF0YVsxMl0sCiAgICAgICAgICAgICAgICB0aHVtYkhlaWdodDogYXBwRGF0YVsxM10sCiAgICAgICAgICAgICAgICB0aHVtYkRhdGE6IGFwcERhdGEuc3ViYXJyYXkoMTQsIDE0ICsgMyAqIGFwcERhdGFbMTJdICogYXBwRGF0YVsxM10pCiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYgKGZpbGVNYXJrZXIgPT09IDB4ZmZlZSkgewogICAgICAgICAgICBpZiAoYXBwRGF0YVswXSA9PT0gMHg0MSAmJiBhcHBEYXRhWzFdID09PSAweDY0ICYmIGFwcERhdGFbMl0gPT09IDB4NmYgJiYgYXBwRGF0YVszXSA9PT0gMHg2MiAmJiBhcHBEYXRhWzRdID09PSAweDY1KSB7CiAgICAgICAgICAgICAgYWRvYmUgPSB7CiAgICAgICAgICAgICAgICB2ZXJzaW9uOiBhcHBEYXRhWzVdIDw8IDggfCBhcHBEYXRhWzZdLAogICAgICAgICAgICAgICAgZmxhZ3MwOiBhcHBEYXRhWzddIDw8IDggfCBhcHBEYXRhWzhdLAogICAgICAgICAgICAgICAgZmxhZ3MxOiBhcHBEYXRhWzldIDw8IDggfCBhcHBEYXRhWzEwXSwKICAgICAgICAgICAgICAgIHRyYW5zZm9ybUNvZGU6IGFwcERhdGFbMTFdCiAgICAgICAgICAgICAgfTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmZGI6CiAgICAgICAgICBjb25zdCBxdWFudGl6YXRpb25UYWJsZXNMZW5ndGggPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgY29uc3QgcXVhbnRpemF0aW9uVGFibGVzRW5kID0gcXVhbnRpemF0aW9uVGFibGVzTGVuZ3RoICsgb2Zmc2V0IC0gMjsKICAgICAgICAgIGxldCB6OwogICAgICAgICAgd2hpbGUgKG9mZnNldCA8IHF1YW50aXphdGlvblRhYmxlc0VuZCkgewogICAgICAgICAgICBjb25zdCBxdWFudGl6YXRpb25UYWJsZVNwZWMgPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgICAgY29uc3QgdGFibGVEYXRhID0gbmV3IFVpbnQxNkFycmF5KDY0KTsKICAgICAgICAgICAgaWYgKHF1YW50aXphdGlvblRhYmxlU3BlYyA+PiA0ID09PSAwKSB7CiAgICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IDY0OyBqKyspIHsKICAgICAgICAgICAgICAgIHogPSBkY3RaaWdaYWdbal07CiAgICAgICAgICAgICAgICB0YWJsZURhdGFbel0gPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gZWxzZSBpZiAocXVhbnRpemF0aW9uVGFibGVTcGVjID4+IDQgPT09IDEpIHsKICAgICAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgNjQ7IGorKykgewogICAgICAgICAgICAgICAgeiA9IGRjdFppZ1phZ1tqXTsKICAgICAgICAgICAgICAgIHRhYmxlRGF0YVt6XSA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICAgICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRocm93IG5ldyBKcGVnRXJyb3IoIkRRVCAtIGludmFsaWQgdGFibGUgc3BlYyIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHF1YW50aXphdGlvblRhYmxlc1txdWFudGl6YXRpb25UYWJsZVNwZWMgJiAxNV0gPSB0YWJsZURhdGE7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4ZmZjMDoKICAgICAgICBjYXNlIDB4ZmZjMToKICAgICAgICBjYXNlIDB4ZmZjMjoKICAgICAgICAgIGlmIChmcmFtZSkgewogICAgICAgICAgICB0aHJvdyBuZXcgSnBlZ0Vycm9yKCJPbmx5IHNpbmdsZSBmcmFtZSBKUEVHcyBzdXBwb3J0ZWQiKTsKICAgICAgICAgIH0KICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgZnJhbWUgPSB7fTsKICAgICAgICAgIGZyYW1lLmV4dGVuZGVkID0gZmlsZU1hcmtlciA9PT0gMHhmZmMxOwogICAgICAgICAgZnJhbWUucHJvZ3Jlc3NpdmUgPSBmaWxlTWFya2VyID09PSAweGZmYzI7CiAgICAgICAgICBmcmFtZS5wcmVjaXNpb24gPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgIGNvbnN0IHNvZlNjYW5MaW5lcyA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICBmcmFtZS5zY2FuTGluZXMgPSBkbmxTY2FuTGluZXMgfHwgc29mU2NhbkxpbmVzOwogICAgICAgICAgZnJhbWUuc2FtcGxlc1BlckxpbmUgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgZnJhbWUuY29tcG9uZW50cyA9IFtdOwogICAgICAgICAgZnJhbWUuY29tcG9uZW50SWRzID0ge307CiAgICAgICAgICBjb25zdCBjb21wb25lbnRzQ291bnQgPSBkYXRhW29mZnNldCsrXTsKICAgICAgICAgIGxldCBtYXhIID0gMCwKICAgICAgICAgICAgbWF4ViA9IDA7CiAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgY29tcG9uZW50c0NvdW50OyBpKyspIHsKICAgICAgICAgICAgY29uc3QgY29tcG9uZW50SWQgPSBkYXRhW29mZnNldF07CiAgICAgICAgICAgIGNvbnN0IGggPSBkYXRhW29mZnNldCArIDFdID4+IDQ7CiAgICAgICAgICAgIGNvbnN0IHYgPSBkYXRhW29mZnNldCArIDFdICYgMTU7CiAgICAgICAgICAgIGlmIChtYXhIIDwgaCkgewogICAgICAgICAgICAgIG1heEggPSBoOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChtYXhWIDwgdikgewogICAgICAgICAgICAgIG1heFYgPSB2OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IHFJZCA9IGRhdGFbb2Zmc2V0ICsgMl07CiAgICAgICAgICAgIGwgPSBmcmFtZS5jb21wb25lbnRzLnB1c2goewogICAgICAgICAgICAgIGgsCiAgICAgICAgICAgICAgdiwKICAgICAgICAgICAgICBxdWFudGl6YXRpb25JZDogcUlkLAogICAgICAgICAgICAgIHF1YW50aXphdGlvblRhYmxlOiBudWxsCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBmcmFtZS5jb21wb25lbnRJZHNbY29tcG9uZW50SWRdID0gbCAtIDE7CiAgICAgICAgICAgIG9mZnNldCArPSAzOwogICAgICAgICAgfQogICAgICAgICAgZnJhbWUubWF4SCA9IG1heEg7CiAgICAgICAgICBmcmFtZS5tYXhWID0gbWF4VjsKICAgICAgICAgIHByZXBhcmVDb21wb25lbnRzKGZyYW1lKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHhmZmM0OgogICAgICAgICAgY29uc3QgaHVmZm1hbkxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICBmb3IgKGkgPSAyOyBpIDwgaHVmZm1hbkxlbmd0aDspIHsKICAgICAgICAgICAgY29uc3QgaHVmZm1hblRhYmxlU3BlYyA9IGRhdGFbb2Zmc2V0KytdOwogICAgICAgICAgICBjb25zdCBjb2RlTGVuZ3RocyA9IG5ldyBVaW50OEFycmF5KDE2KTsKICAgICAgICAgICAgbGV0IGNvZGVMZW5ndGhTdW0gPSAwOwogICAgICAgICAgICBmb3IgKGogPSAwOyBqIDwgMTY7IGorKywgb2Zmc2V0KyspIHsKICAgICAgICAgICAgICBjb2RlTGVuZ3RoU3VtICs9IGNvZGVMZW5ndGhzW2pdID0gZGF0YVtvZmZzZXRdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGh1ZmZtYW5WYWx1ZXMgPSBuZXcgVWludDhBcnJheShjb2RlTGVuZ3RoU3VtKTsKICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IGNvZGVMZW5ndGhTdW07IGorKywgb2Zmc2V0KyspIHsKICAgICAgICAgICAgICBodWZmbWFuVmFsdWVzW2pdID0gZGF0YVtvZmZzZXRdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGkgKz0gMTcgKyBjb2RlTGVuZ3RoU3VtOwogICAgICAgICAgICAoaHVmZm1hblRhYmxlU3BlYyA+PiA0ID09PSAwID8gaHVmZm1hblRhYmxlc0RDIDogaHVmZm1hblRhYmxlc0FDKVtodWZmbWFuVGFibGVTcGVjICYgMTVdID0gYnVpbGRIdWZmbWFuVGFibGUoY29kZUxlbmd0aHMsIGh1ZmZtYW5WYWx1ZXMpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmZGQ6CiAgICAgICAgICBvZmZzZXQgKz0gMjsKICAgICAgICAgIHJlc2V0SW50ZXJ2YWwgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgb2Zmc2V0KTsKICAgICAgICAgIG9mZnNldCArPSAyOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweGZmZGE6CiAgICAgICAgICBjb25zdCBwYXJzZUROTE1hcmtlciA9ICsrbnVtU09TTWFya2VycyA9PT0gMSAmJiAhZG5sU2NhbkxpbmVzOwogICAgICAgICAgb2Zmc2V0ICs9IDI7CiAgICAgICAgICBjb25zdCBzZWxlY3RvcnNDb3VudCA9IGRhdGFbb2Zmc2V0KytdLAogICAgICAgICAgICBjb21wb25lbnRzID0gW107CiAgICAgICAgICBmb3IgKGkgPSAwOyBpIDwgc2VsZWN0b3JzQ291bnQ7IGkrKykgewogICAgICAgICAgICBjb25zdCBpbmRleCA9IGRhdGFbb2Zmc2V0KytdOwogICAgICAgICAgICBjb25zdCBjb21wb25lbnRJbmRleCA9IGZyYW1lLmNvbXBvbmVudElkc1tpbmRleF07CiAgICAgICAgICAgIGNvbnN0IGNvbXBvbmVudCA9IGZyYW1lLmNvbXBvbmVudHNbY29tcG9uZW50SW5kZXhdOwogICAgICAgICAgICBjb21wb25lbnQuaW5kZXggPSBpbmRleDsKICAgICAgICAgICAgY29uc3QgdGFibGVTcGVjID0gZGF0YVtvZmZzZXQrK107CiAgICAgICAgICAgIGNvbXBvbmVudC5odWZmbWFuVGFibGVEQyA9IGh1ZmZtYW5UYWJsZXNEQ1t0YWJsZVNwZWMgPj4gNF07CiAgICAgICAgICAgIGNvbXBvbmVudC5odWZmbWFuVGFibGVBQyA9IGh1ZmZtYW5UYWJsZXNBQ1t0YWJsZVNwZWMgJiAxNV07CiAgICAgICAgICAgIGNvbXBvbmVudHMucHVzaChjb21wb25lbnQpOwogICAgICAgICAgfQogICAgICAgICAgY29uc3Qgc3BlY3RyYWxTdGFydCA9IGRhdGFbb2Zmc2V0KytdLAogICAgICAgICAgICBzcGVjdHJhbEVuZCA9IGRhdGFbb2Zmc2V0KytdLAogICAgICAgICAgICBzdWNjZXNzaXZlQXBwcm94aW1hdGlvbiA9IGRhdGFbb2Zmc2V0KytdOwogICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgY29uc3QgcHJvY2Vzc2VkID0gZGVjb2RlU2NhbihkYXRhLCBvZmZzZXQsIGZyYW1lLCBjb21wb25lbnRzLCByZXNldEludGVydmFsLCBzcGVjdHJhbFN0YXJ0LCBzcGVjdHJhbEVuZCwgc3VjY2Vzc2l2ZUFwcHJveGltYXRpb24gPj4gNCwgc3VjY2Vzc2l2ZUFwcHJveGltYXRpb24gJiAxNSwgcGFyc2VETkxNYXJrZXIpOwogICAgICAgICAgICBvZmZzZXQgKz0gcHJvY2Vzc2VkOwogICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgaWYgKGV4IGluc3RhbmNlb2YgRE5MTWFya2VyRXJyb3IpIHsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYCR7ZXgubWVzc2FnZX0gLS0gYXR0ZW1wdGluZyB0byByZS1wYXJzZSB0aGUgSlBFRyBpbWFnZS5gKTsKICAgICAgICAgICAgICByZXR1cm4gdGhpcy5wYXJzZShkYXRhLCB7CiAgICAgICAgICAgICAgICBkbmxTY2FuTGluZXM6IGV4LnNjYW5MaW5lcwogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9IGVsc2UgaWYgKGV4IGluc3RhbmNlb2YgRU9JTWFya2VyRXJyb3IpIHsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYCR7ZXgubWVzc2FnZX0gLS0gaWdub3JpbmcgdGhlIHJlc3Qgb2YgdGhlIGltYWdlIGRhdGEuYCk7CiAgICAgICAgICAgICAgYnJlYWsgbWFya2VyTG9vcDsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aHJvdyBleDsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHhmZmRjOgogICAgICAgICAgb2Zmc2V0ICs9IDQ7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4ZmZmZjoKICAgICAgICAgIGlmIChkYXRhW29mZnNldF0gIT09IDB4ZmYpIHsKICAgICAgICAgICAgb2Zmc2V0LS07CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBkZWZhdWx0OgogICAgICAgICAgY29uc3QgbmV4dEZpbGVNYXJrZXIgPSBmaW5kTmV4dEZpbGVNYXJrZXIoZGF0YSwgb2Zmc2V0IC0gMiwgb2Zmc2V0IC0gMyk7CiAgICAgICAgICBpZiAobmV4dEZpbGVNYXJrZXIgJiYgbmV4dEZpbGVNYXJrZXIuaW52YWxpZCkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIkpwZWdJbWFnZS5wYXJzZSAtIHVuZXhwZWN0ZWQgZGF0YSwgY3VycmVudCBtYXJrZXIgaXM6ICIgKyBuZXh0RmlsZU1hcmtlci5pbnZhbGlkKTsKICAgICAgICAgICAgb2Zmc2V0ID0gbmV4dEZpbGVNYXJrZXIub2Zmc2V0OwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGlmICghbmV4dEZpbGVNYXJrZXIgfHwgb2Zmc2V0ID49IGRhdGEubGVuZ3RoIC0gMSkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIkpwZWdJbWFnZS5wYXJzZSAtIHJlYWNoZWQgdGhlIGVuZCBvZiB0aGUgaW1hZ2UgZGF0YSAiICsgIndpdGhvdXQgZmluZGluZyBhbiBFT0kgbWFya2VyICgweEZGRDkpLiIpOwogICAgICAgICAgICBicmVhayBtYXJrZXJMb29wOwogICAgICAgICAgfQogICAgICAgICAgdGhyb3cgbmV3IEpwZWdFcnJvcigiSnBlZ0ltYWdlLnBhcnNlIC0gdW5rbm93biBtYXJrZXI6ICIgKyBmaWxlTWFya2VyLnRvU3RyaW5nKDE2KSk7CiAgICAgIH0KICAgICAgZmlsZU1hcmtlciA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBvZmZzZXQpOwogICAgICBvZmZzZXQgKz0gMjsKICAgIH0KICAgIHRoaXMud2lkdGggPSBmcmFtZS5zYW1wbGVzUGVyTGluZTsKICAgIHRoaXMuaGVpZ2h0ID0gZnJhbWUuc2NhbkxpbmVzOwogICAgdGhpcy5qZmlmID0gamZpZjsKICAgIHRoaXMuYWRvYmUgPSBhZG9iZTsKICAgIHRoaXMuY29tcG9uZW50cyA9IFtdOwogICAgZm9yIChjb25zdCBjb21wb25lbnQgb2YgZnJhbWUuY29tcG9uZW50cykgewogICAgICBjb25zdCBxdWFudGl6YXRpb25UYWJsZSA9IHF1YW50aXphdGlvblRhYmxlc1tjb21wb25lbnQucXVhbnRpemF0aW9uSWRdOwogICAgICBpZiAocXVhbnRpemF0aW9uVGFibGUpIHsKICAgICAgICBjb21wb25lbnQucXVhbnRpemF0aW9uVGFibGUgPSBxdWFudGl6YXRpb25UYWJsZTsKICAgICAgfQogICAgICB0aGlzLmNvbXBvbmVudHMucHVzaCh7CiAgICAgICAgaW5kZXg6IGNvbXBvbmVudC5pbmRleCwKICAgICAgICBvdXRwdXQ6IGJ1aWxkQ29tcG9uZW50RGF0YShmcmFtZSwgY29tcG9uZW50KSwKICAgICAgICBzY2FsZVg6IGNvbXBvbmVudC5oIC8gZnJhbWUubWF4SCwKICAgICAgICBzY2FsZVk6IGNvbXBvbmVudC52IC8gZnJhbWUubWF4ViwKICAgICAgICBibG9ja3NQZXJMaW5lOiBjb21wb25lbnQuYmxvY2tzUGVyTGluZSwKICAgICAgICBibG9ja3NQZXJDb2x1bW46IGNvbXBvbmVudC5ibG9ja3NQZXJDb2x1bW4KICAgICAgfSk7CiAgICB9CiAgICB0aGlzLm51bUNvbXBvbmVudHMgPSB0aGlzLmNvbXBvbmVudHMubGVuZ3RoOwogIC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ZOwogICAgICBvZmZzZXQgPSBpOwogICAgICBvdXRwdXQgPSBjb21wb25lbnQub3V0cHV0OwogICAgICBibG9ja3NQZXJTY2FubGluZSA9IGNvbXBvbmVudC5ibG9ja3NQZXJMaW5lICsgMSA8PCAzOwogICAgICBpZiAoY29tcG9uZW50U2NhbGVYICE9PSBsYXN0Q29tcG9uZW50U2NhbGVYKSB7CiAgICAgICAgZm9yICh4ID0gMDsgeCA8IHdpZHRoOyB4KyspIHsKICAgICAgICAgIGogPSAwIHwgeCAqIGNvbXBvbmVudFNjYWxlWDsKICAgICAgICAgIHhTY2FsZUJsb2NrT2Zmc2V0W3hdID0gKGogJiBtYXNrM0xTQikgPDwgMyB8IGogJiA3OwogICAgICAgIH0KICAgICAgICBsYXN0Q29tcG9uZW50U2NhbGVYID0gY29tcG9uZW50U2NhbGVYOwogICAgICB9CiAgICAgIGZvciAoeSA9IDA7IHkgPCBoZWlnaHQ7IHkrKykgewogICAgICAgIGogPSAwIHwgeSAqIGNvbXBvbmVudFNjYWxlWTsKICAgICAgICBpbmRleCA9IGJsb2Nrc1BlclNjYW5saW5lICogKGogJiBtYXNrM0xTQikgfCAoaiAmIDcpIDw8IDM7CiAgICAgICAgZm9yICh4ID0gMDsgeCA8IHdpZHRoOyB4KyspIHsKICAgICAgICAgIGRhdGFbb2Zmc2V0XSA9IG91dHB1dFtpbmRleCArIHhTY2FsZUJsb2NrT2Zmc2V0W3hdXTsKICAgICAgICAgIG9mZnNldCArPSBudW1Db21wb25lbnRzOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgbGV0IHRyYW5zZm9ybSA9IHRoaXMuX2RlY29kZVRyYW5zZm9ybTsKICAgIGlmICghaXNTb3VyY2VQREYgJiYgbnVtQ29tcG9uZW50cyA9PT0gNCAmJiAhdHJhbnNmb3JtKSB7CiAgICAgIHRyYW5zZm9ybSA9IG5ldyBJbnQzMkFycmF5KFstMjU2LCAyNTUsIC0yNTYsIDI1NSwgLTI1NiwgMjU1LCAtMjU2LCAyNTVdKTsKICAgIH0KICAgIGlmICh0cmFuc2Zvcm0pIHsKICAgICAgZm9yIChpID0gMDsgaSA8IGRhdGFMZW5ndGg7KSB7CiAgICAgICAgZm9yIChqID0gMCwgayA9IDA7IGogPCBudW1Db21wb25lbnRzOyBqKyssIGkrKywgayArPSAyKSB7CiAgICAgICAgICBkYXRhW2ldID0gKGRhdGFbaV0gKiB0cmFuc2Zvcm1ba10gPj4gOCkgKyB0cmFuc2Zvcm1bayArIDFdOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIGRhdGE7CiAgfQogIGdldCBfaXNDb2xvckNvbnZlcnNpb25OZWVkZWQoKSB7CiAgICBpZiAodGhpcy5hZG9iZSkgewogICAgICByZXR1cm4gISF0aGlzLmFkb2JlLnRyYW5zZm9ybUNvZGU7CiAgICB9CiAgICBpZiAodGhpcy5udW1Db21wb25lbnRzID09PSAzKSB7CiAgICAgIGlmICh0aGlzLl9jb2xvclRyYW5zZm9ybSA9PT0gMCkgewogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfSBlbHNlIGlmICh0aGlzLmNvbXBvbmVudHNbMF0uaW5kZXggPT09IDB4NTIgJiYgdGhpcy5jb21wb25lbnRzWzFdLmluZGV4ID09PSAweDQ3ICYmIHRoaXMuY29tcG9uZW50c1syXS5pbmRleCA9PT0gMHg0MikgewogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfQogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGlmICh0aGlzLl9jb2xvclRyYW5zZm9ybSA9PT0gMSkgewogICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIHJldHVybiBmYWxzZTsKICB9CiAgX2NvbnZlcnRZY2NUb1JnYihkYXRhKSB7CiAgICBsZXQgWSwgQ2IsIENyOwogICAgZm9yIChsZXQgaSA9IDAsIGxlbmd0aCA9IGRhdGEubGVuZ3RoOyBpIDwgbGVuZ3RoOyBpICs9IDMpIHsKICAgICAgWSA9IGRh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0aGlzLmVvZikgewogICAgICByZXR1cm47CiAgICB9CiAgICBjb25zdCBqcHhJbWFnZSA9IG5ldyBfanB4LkpweEltYWdlKCk7CiAgICBqcHhJbWFnZS5wYXJzZSh0aGlzLmJ5dGVzKTsKICAgIGNvbnN0IHdpZHRoID0ganB4SW1hZ2Uud2lkdGg7CiAgICBjb25zdCBoZWlnaHQgPSBqcHhJbWFnZS5oZWlnaHQ7CiAgICBjb25zdCBjb21wb25lbnRzQ291bnQgPSBqcHhJbWFnZS5jb21wb25lbnRzQ291bnQ7CiAgICBjb25zdCB0aWxlQ291bnQgPSBqcHhJbWFnZS50aWxlcy5sZW5ndGg7CiAgICBpZiAodGlsZUNvdW50ID09PSAxKSB7CiAgICAgIHRoaXMuYnVmZmVyID0ganB4SW1hZ2UudGlsZXNbMF0uaXRlbXM7CiAgICB9IGVsc2UgewogICAgICBjb25zdCBkYXRhID0gbmV3IFVpbnQ4Q2xhbXBlZEFycmF5KHdpZHRoICogaGVpZ2h0ICogY29tcG9uZW50c0NvdW50KTsKICAgICAgZm9yIChsZXQgayA9IDA7IGsgPCB0aWxlQ291bnQ7IGsrKykgewogICAgICAgIGNvbnN0IHRpbGVDb21wb25lbnRzID0ganB4SW1hZ2UudGlsZXNba107CiAgICAgICAgY29uc3QgdGlsZVdpZHRoID0gdGlsZUNvbXBvbmVudHMud2lkdGg7CiAgICAgICAgY29uc3QgdGlsZUhlaWdodCA9IHRpbGVDb21wb25lbnRzLmhlaWdodDsKICAgICAgICBjb25zdCB0aWxlTGVmdCA9IHRpbGVDb21wb25lbnRzLmxlZnQ7CiAgICAgICAgY29uc3QgdGlsZVRvcCA9IHRpbGVDb21wb25lbnRzLnRvcDsKICAgICAgICBjb25zdCBzcmMgPSB0aWxlQ29tcG9uZW50cy5pdGVtczsKICAgICAgICBsZXQgc3JjUG9zaXRpb24gPSAwOwogICAgICAgIGxldCBkYXRhUG9zaXRpb24gPSAod2lkdGggKiB0aWxlVG9wICsgdGlsZUxlZnQpIC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AoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyA0KTsKICAgICAgICBwb3NpdGlvbiArPSA4OwogICAgICAgIGhlYWRlclNpemUgKz0gODsKICAgICAgfQogICAgICBpZiAobGJveCA9PT0gMCkgewogICAgICAgIGxib3ggPSBsZW5ndGggLSBwb3NpdGlvbiArIGhlYWRlclNpemU7CiAgICAgIH0KICAgICAgaWYgKGxib3ggPCBoZWFkZXJTaXplKSB7CiAgICAgICAgdGhyb3cgbmV3IEpweEVycm9yKCJJbnZhbGlkIGJveCBmaWVsZCBzaXplIik7CiAgICAgIH0KICAgICAgY29uc3QgZGF0YUxlbmd0aCA9IGxib3ggLSBoZWFkZXJTaXplOwogICAgICBsZXQganVtcERhdGFMZW5ndGggPSB0cnVlOwogICAgICBzd2l0Y2ggKHRib3gpIHsKICAgICAgICBjYXNlIDB4NmE3MDMyNjg6CiAgICAgICAgICBqdW1wRGF0YUxlbmd0aCA9IGZhbHNlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDYzNmY2YzcyOgogICAgICAgICAgY29uc3QgbWV0aG9kID0gZGF0YVtwb3NpdGlvbl07CiAgICAgICAgICBpZiAobWV0aG9kID09PSAxKSB7CiAgICAgICAgICAgIGNvbnN0IGNvbG9yc3BhY2UgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAzKTsKICAgICAgICAgICAgc3dpdGNoIChjb2xvcnNwYWNlKSB7CiAgICAgICAgICAgICAgY2FzZSAxNjoKICAgICAgICAgICAgICBjYXNlIDE3OgogICAgICAgICAgICAgIGNhc2UgMTg6CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJVbmtub3duIGNvbG9yc3BhY2UgIiArIGNvbG9yc3BhY2UpOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSBpZiAobWV0aG9kID09PSAyKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC5pbmZvKSgiSUNDIHByb2ZpbGUgbm90IHN1cHBvcnRlZCIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDZhNzAzMjYzOgogICAgICAgICAgdGhpcy5wYXJzZUNvZGVzdHJlYW0oZGF0YSwgcG9zaXRpb24sIHBvc2l0aW9uICsgZGF0YUxlbmd0aCk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4NmE1MDIwMjA6CiAgICAgICAgICBpZiAoKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MzIpKGRhdGEsIHBvc2l0aW9uKSAhPT0gMHgwZDBhODcwYSkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIkludmFsaWQgSlAyIHNpZ25hdHVyZSIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDZhNTAxYTFhOgogICAgICAgIGNhc2UgMHg2Njc0Nzk3MDoKICAgICAgICBjYXNlIDB4NzI3MjY1NzE6CiAgICAgICAgY2FzZSAweDcyNjU3MzIwOgogICAgICAgIGNhc2UgMHg2OTY4NjQ3MjoKICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICBjb25zdCBoZWFkZXJUeXBlID0gU3RyaW5nLmZyb21DaGFyQ29kZSh0Ym94ID4+IDI0ICYgMHhmZiwgdGJveCA+PiAxNiAmIDB4ZmYsIHRib3ggPj4gOCAmIDB4ZmYsIHRib3ggJiAweGZmKTsKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgVW5zdXBwb3J0ZWQgaGVhZGVyIHR5cGUgJHt0Ym94fSAoJHtoZWFkZXJUeXBlfSkuYCk7CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoanVtcERhdGFMZW5ndGgpIHsKICAgICA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ogICAgY29uc3QgY29udGV4dCA9IHt9OwogICAgbGV0IGRvTm90UmVjb3ZlciA9IGZhbHNlOwogICAgdHJ5IHsKICAgICAgbGV0IHBvc2l0aW9uID0gc3RhcnQ7CiAgICAgIHdoaWxlIChwb3NpdGlvbiArIDEgPCBlbmQpIHsKICAgICAgICBjb25zdCBjb2RlID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MTYpKGRhdGEsIHBvc2l0aW9uKTsKICAgICAgICBwb3NpdGlvbiArPSAyOwogICAgICAgIGxldCBsZW5ndGggPSAwLAogICAgICAgICAgaiwKICAgICAgICAgIHNxY2QsCiAgICAgICAgICBzcHFjZHMsCiAgICAgICAgICBzcHFjZFNpemUsCiAgICAgICAgICBzY2FsYXJFeHBvdW5kZWQsCiAgICAgICAgICB0aWxlOwogICAgICAgIHN3aXRjaCAoY29kZSkgewogICAgICAgICAgY2FzZSAweGZmNGY6CiAgICAgICAgICAgIGNvbnRleHQubWFpbkhlYWRlciA9IHRydWU7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmZDk6CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmNTE6CiAgICAgICAgICAgIGxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbik7CiAgICAgICAgICAgIGNvbnN0IHNpeiA9IHt9OwogICAgICAgICAgICBzaXouWHNpeiA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDQpOwogICAgICAgICAgICBzaXouWXNpeiA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDgpOwogICAgICAgICAgICBzaXouWE9zaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAxMik7CiAgICAgICAgICAgIHNpei5ZT3NpeiA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDE2KTsKICAgICAgICAgICAgc2l6LlhUc2l6ID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MzIpKGRhdGEsIHBvc2l0aW9uICsgMjApOwogICAgICAgICAgICBzaXouWVRzaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAyNCk7CiAgICAgICAgICAgIHNpei5YVE9zaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAyOCk7CiAgICAgICAgICAgIHNpei5ZVE9zaXogPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQzMikoZGF0YSwgcG9zaXRpb24gKyAzMik7CiAgICAgICAgICAgIGNvbnN0IGNvbXBvbmVudHNDb3VudCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbiArIDM2KTsKICAgICAgICAgICAgc2l6LkNzaXogPSBjb21wb25lbnRzQ291bnQ7CiAgICAgICAgICAgIGNvbnN0IGNvbXBvbmVudHMgPSBbXTsKICAgICAgICAgICAgaiA9IHBvc2l0aW9uICsgMzg7CiAgICAgICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgY29tcG9uZW50c0NvdW50OyBpKyspIHsKICAgICAgICAgICAgICBjb25zdCBjb21wb25lbnQgPSB7CiAgICAgICAgICAgICAgICBwcmVjaXNpb246IChkYXRhW2pdICYgMHg3ZikgKyAxLAogICAgICAgICAgICAgICAgaXNTaWduZWQ6ICEhKGRhdGFbal0gJiAweDgwKSwKICAgICAgICAgICAgICAgIFhSc2l6OiBkYXRhW2ogKyAxXSwKICAgICAgICAgICAgICAgIFlSc2l6OiBkYXRhW2ogKyAyXQogICAgICAgICAgICAgIH07CiAgICAgICAgICAgICAgaiArPSAzOwogICAgICAgICAgICAgIGNhbGN1bGF0ZUNvbXBvbmVudERpbWVuc2lvbnMoY29tcG9uZW50LCBzaXopOwogICAgICAgICAgICAgIGNvbXBvbmVudHMucHVzaChjb21wb25lbnQpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnRleHQuU0laID0gc2l6OwogICAgICAgICAgICBjb250ZXh0LmNvbXBvbmVudHMgPSBjb21wb25lbnRzOwogICAgICAgICAgICBjYWxjdWxhdGVUaWxlR3JpZHMoY29udGV4dCwgY29tcG9uZW50cyk7CiAgICAgICAgICAgIGNvbnRleHQuUUNDID0gW107CiAgICAgICAgICAgIGNvbnRleHQuQ09DID0gW107CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmNWM6CiAgICAgICAgICAgIGxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbik7CiAgICAgICAgICAgIGNvbnN0IHFjZCA9IHt9OwogICAgICAgICAgICBqID0gcG9zaXRpb24gKyAyOwogICAgICAgICAgICBzcWNkID0gZGF0YVtqKytdOwogICAgICAgICAgICBzd2l0Y2ggKHNxY2QgJiAweDFmKSB7CiAgICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gODsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgICBzcHFjZFNpemUgPSAxNjsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gMTY7CiAgICAgICAgICAgICAgICBzY2FsYXJFeHBvdW5kZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiSW52YWxpZCBTUWNkIHZhbHVlICIgKyBzcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2Qubm9RdWFudGl6YXRpb24gPSBzcHFjZFNpemUgPT09IDg7CiAgICAgICAgICAgIHFjZC5zY2FsYXJFeHBvdW5kZWQgPSBzY2FsYXJFeHBvdW5kZWQ7CiAgICAgICAgICAgIHFjZC5ndWFyZEJpdHMgPSBzcWNkID4+IDU7CiAgICAgICAgICAgIHNwcWNkcyA9IFtdOwogICAgICAgICAgICB3aGlsZSAoaiA8IGxlbmd0aCArIHBvc2l0aW9uKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3BxY2QgPSB7fTsKICAgICAgICAgICAgICBpZiAoc3BxY2RTaXplID09PSA4KSB7CiAgICAgICAgICAgICAgICBzcHFjZC5lcHNpbG9uID0gZGF0YVtqKytdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IDA7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHNwcWNkLmVwc2lsb24gPSBkYXRhW2pdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IChkYXRhW2pdICYgMHg3KSA8PCA4IHwgZGF0YVtqICsgMV07CiAgICAgICAgICAgICAgICBqICs9IDI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNwcWNkcy5wdXNoKHNwcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2QuU1BxY2RzID0gc3BxY2RzOwogICAgICAgICAgICBpZiAoY29udGV4dC5tYWluSGVhZGVyKSB7CiAgICAgICAgICAgICAgY29udGV4dC5RQ0QgPSBxY2Q7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZS5RQ0QgPSBxY2Q7CiAgICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZS5RQ0MgPSBbXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMHhmZjVkOgogICAgICAgICAgICBsZW5ndGggPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgcG9zaXRpb24pOwogICAgICAgICAgICBjb25zdCBxY2MgPSB7fTsKICAgICAgICAgICAgaiA9IHBvc2l0aW9uICsgMjsKICAgICAgICAgICAgbGV0IGNxY2M7CiAgICAgICAgICAgIGlmIChjb250ZXh0LlNJWi5Dc2l6IDwgMjU3KSB7CiAgICAgICAgICAgICAgY3FjYyA9IGRhdGFbaisrXTsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjcWNjID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MTYpKGRhdGEsIGopOwogICAgICAgICAgICAgIGogKz0gMjsKICAgICAgICAgICAgfQogICAgICAgICAgICBzcWNkID0gZGF0YVtqKytdOwogICAgICAgICAgICBzd2l0Y2ggKHNxY2QgJiAweDFmKSB7CiAgICAgICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gODsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgICBzcHFjZFNpemUgPSAxNjsKICAgICAgICAgICAgICAgIHNjYWxhckV4cG91bmRlZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgICAgc3BxY2RTaXplID0gMTY7CiAgICAgICAgICAgICAgICBzY2FsYXJFeHBvdW5kZWQgPSB0cnVlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcigiSW52YWxpZCBTUWNkIHZhbHVlICIgKyBzcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2Mubm9RdWFudGl6YXRpb24gPSBzcHFjZFNpemUgPT09IDg7CiAgICAgICAgICAgIHFjYy5zY2FsYXJFeHBvdW5kZWQgPSBzY2FsYXJFeHBvdW5kZWQ7CiAgICAgICAgICAgIHFjYy5ndWFyZEJpdHMgPSBzcWNkID4+IDU7CiAgICAgICAgICAgIHNwcWNkcyA9IFtdOwogICAgICAgICAgICB3aGlsZSAoaiA8IGxlbmd0aCArIHBvc2l0aW9uKSB7CiAgICAgICAgICAgICAgY29uc3Qgc3BxY2QgPSB7fTsKICAgICAgICAgICAgICBpZiAoc3BxY2RTaXplID09PSA4KSB7CiAgICAgICAgICAgICAgICBzcHFjZC5lcHNpbG9uID0gZGF0YVtqKytdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IDA7CiAgICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHNwcWNkLmVwc2lsb24gPSBkYXRhW2pdID4+IDM7CiAgICAgICAgICAgICAgICBzcHFjZC5tdSA9IChkYXRhW2pdICYgMHg3KSA8PCA4IHwgZGF0YVtqICsgMV07CiAgICAgICAgICAgICAgICBqICs9IDI7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNwcWNkcy5wdXNoKHNwcWNkKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxY2MuU1BxY2RzID0gc3BxY2RzOwogICAgICAgICAgICBpZiAoY29udGV4dC5tYWluSGVhZGVyKSB7CiAgICAgICAgICAgICAgY29udGV4dC5RQ0NbY3FjY10gPSBxY2M7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZS5RQ0NbY3FjY10gPSBxY2M7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDB4ZmY1MjoKICAgICAgICAgICAgbGVuZ3RoID0gKDAsIF9jb3JlX3V0aWxzLnJlYWRVaW50MTYpKGRhdGEsIHBvc2l0aW9uKTsKICAgICAgICAgICAgY29uc3QgY29kID0ge307CiAgICAgICAgICAgIGogPSBwb3NpdGlvbiArIDI7CiAgICAgICAgICAgIGNvbnN0IHNjb2QgPSBkYXRhW2orK107CiAgICAgICAgICAgIGNvZC5lbnRyb3B5Q29kZXJXaXRoQ3VzdG9tUHJlY2luY3RzID0gISEoc2NvZCAmIDEpOwogICAgICAgICAgICBjb2Quc29wTWFya2VyVXNlZCA9ICEhKHNjb2QgJiAyKTsKICAgICAgICAgICAgY29kLmVwaE1hcmtlclVzZWQgPSAhIShzY29kICYgNCk7CiAgICAgICAgICAgIGNvZC5wcm9ncmVzc2lvbk9yZGVyID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2QubGF5ZXJzQ291bnQgPSAoMCwgX2NvcmVfdXRpbHMucmVhZFVpbnQxNikoZGF0YSwgaik7CiAgICAgICAgICAgIGogKz0gMjsKICAgICAgICAgICAgY29kLm11bHRpcGxlQ29tcG9uZW50VHJhbnNmb3JtID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2QuZGVjb21wb3NpdGlvbkxldmVsc0NvdW50ID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2QueGNiID0gKGRhdGFbaisrXSAmIDB4ZikgKyAyOwogICAgICAgICAgICBjb2QueWNiID0gKGRhdGFbaisrXSAmIDB4ZikgKyAyOwogICAgICAgICAgICBjb25zdCBibG9ja1N0eWxlID0gZGF0YVtqKytdOwogICAgICAgICAgICBjb2Quc2VsZWN0aXZlQXJpdGhtZXRpY0NvZGluZ0J5cGFzcyA9ICEhKGJsb2NrU3R5bGUgJiAxKTsKICAgICAgICAgICAgY29kLnJlc2V0Q29udGV4dFByb2JhYmlsaXRpZXMgPSAhIShibG9ja1N0eWxlICYgMik7CiAgICAgICAgICAgIGNvZC50ZXJtaW5hdGlvbk9uRWFjaENvZGluZ1Bhc3MgPSAhIShibG9ja1N0eWxlICYgNCk7CiAgICAgICAgICAgIGNvZC52ZXJ0aWNhbGx5U3RyaXBlID0gISEoYmxvY2tTdHlsZSAmIDgpOwogICAgICAgICAgICBjb2QucHJlZGljdGFibGVUZXJtaW5hdGlvbiA9ICEhKGJsb2NrU3R5bGUgJiAxNik7CiAgICAgICAgICAgIGNvZC5zZWdtZW50YXRpb25TeW1ib2xVc2VkID0gISEoYmxvY2tTdHlsZSAmIDMyKTsKICAgICAgICAgICAgY29kLnJldmVyc2libGVUcmFuc2Zvcm1hdGlvbiA9IGRhdGFbaisrXTsKICAgICAgICAgICAgaWYgKGNvZC5lbnRyb3B5Q29kZXJXaXRoQ3VzdG9tUHJlY2luY3RzKSB7CiAgICAgICAgICAgICAgY29uc3QgcHJlY2luY3RzU2l6ZXMgPSBbXTsKICAgICAgICAgICAgICB3aGlsZSAoaiA8IGxlbmd0aCArIHBvc2l0aW9uKSB7CiAgICAgICAgICAgICAgICBjb25zdCBwcmVjaW5jdHNTaXplID0gZGF0YVtqKytdOwogICAgICAgICAgICAgICAgcHJlY2luY3RzU2l6ZXMucHVzaCh7CiAgICAgICAgICAgICAgICAgIFBQeDogcHJlY2luY3RzU2l6ZSAmIDB4ZiwKICAgICAgICAgICAgICAgICAgUFB5OiBwcmVjaW5jdHNTaXplID4+IDQKICAgICAgICAgICAgICAgIH0pOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBjb2QucHJlY2luY3RzU2l6ZXMgPSBwcmVjaW5jdHNTaXplczsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCB1bnN1cHBvcnRlZCA9IFtdOwogICAgICAgICAgICBpZiAoY29kLnNlbGVjdGl2ZUFyaXRobWV0aWNDb2RpbmdCeXBhc3MpIHsKICAgICAgICAgICAgICB1bnN1cHBvcnRlZC5wdXNoKCJzZWxlY3RpdmVBcml0aG1ldGljQ29kaW5nQnlwYXNzIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGNvZC50ZXJtaW5hdGlvbk9uRWFjaENvZGluZ1Bhc3MpIHsKICAgICAgICAgICAgICB1bnN1cHBvcnRlZC5wdXNoKCJ0ZXJtaW5hdGlvbk9uRWFjaENvZGluZ1Bhc3MiKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoY29kLnZlcnRpY2FsbHlTdHJpcGUpIHsKICAgICAgICAgICAgICB1bnN1cHBvcnRlZC5wdXNoKCJ2ZXJ0aWNhbGx5U3RyaXBlIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGNvZC5wcmVkaWN0YWJsZVRlcm1pbmF0aW9uKSB7CiAgICAgICAgICAgICAgdW5zdXBwb3J0ZWQucHVzaCgicHJlZGljdGFibGVUZXJtaW5hdGlvbiIpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICh1bnN1cHBvcnRlZC5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgICAgZG9Ob3RSZWNvdmVyID0gdHJ1ZTsKICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYEpQWDogVW5zdXBwb3J0ZWQgQ09EIG9wdGlvbnMgKCR7dW5zdXBwb3J0ZWQuam9pbigiLCAiKX0pLmApOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChjb250ZXh0Lm1haW5IZWFkZXIpIHsKICAgICAgICAgICAgICBjb250ZXh0LkNPRCA9IGNvZDsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICBjb250ZXh0LmN1cnJlbnRUaWxlLkNPRCA9IGNvZDsKICAgICAgICAgICAgICBjb250ZXh0LmN1cnJlbnRUaWxlLkNPQyA9IFtdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmOTA6CiAgICAgICAgICAgIGxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbik7CiAgICAgICAgICAgIHRpbGUgPSB7fTsKICAgICAgICAgICAgdGlsZS5pbmRleCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDE2KShkYXRhLCBwb3NpdGlvbiArIDIpOwogICAgICAgICAgICB0aWxlLmxlbmd0aCA9ICgwLCBfY29yZV91dGlscy5yZWFkVWludDMyKShkYXRhLCBwb3NpdGlvbiArIDQpOwogICAgICAgICAgICB0aWxlLmRhdGFFbmQgPSB0aWxlLmxlbmd0aCArIHBvc2l0aW9uIC0gMjsKICAgICAgICAgICAgdGlsZS5wYXJ0SW5kZXggPSBkYXRhW3Bvc2l0aW9uICsgOF07CiAgICAgICAgICAgIHRpbGUucGFydHNDb3VudCA9IGRhdGFbcG9zaXRpb24gKyA5XTsKICAgICAgICAgICAgY29udGV4dC5tYWluSGVhZGVyID0gZmFsc2U7CiAgICAgICAgICAgIGlmICh0aWxlLnBhcnRJbmRleCA9PT0gMCkgewogICAgICAgICAgICAgIHRpbGUuQ09EID0gY29udGV4dC5DT0Q7CiAgICAgICAgICAgICAgdGlsZS5DT0MgPSBjb250ZXh0LkNPQy5zbGljZSgwKTsKICAgICAgICAgICAgICB0aWxlLlFDRCA9IGNvbnRleHQuUUNEOwogICAgICAgICAgICAgIHRpbGUuUUNDID0gY29udGV4dC5RQ0Muc2xpY2UoMCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29udGV4dC5jdXJyZW50VGlsZSA9IHRpbGU7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAweGZmOTM6CiAgICAgICAgICAgIHRpbGUgPSBjb250ZXh0LmN1cnJlbnRUaWxlOwogICAgICAgICAgICBpZiAodGlsZS5wYXJ0SW5kZXggPT09IDApIHsKICAgICAgICAgICAgICBpbml0aWFsaXplVGlsZShjb250ZXh0LCB0aWxlLmluZGV4KTsKICAgICAgICAgICAgICBidWlsZFBhY2tldHMoY29udGV4dCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbGVuZ3RoID0gdGlsZS5kYXRhRW5kIC0gcG9zaXRpb247CiAgICAgICAgICAgIHBhcnNlVGlsZVBhY2tldHMoY29udGV4dCwgZGF0YSwgcG9zaXRpb24sIGxlbmd0aCk7CiAgICAgICAgICAgIG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KICAgICAgdGlsZS50eTAgPSBNYXRoLm1heChzaXouWVRPc2l6ICsgcSAqIHNpei5ZVHNpeiwgc2l6LllPc2l6KTsKICAgICAgdGlsZS50eDEgPSBNYXRoLm1pbihzaXouWFRPc2l6ICsgKHAgKyAxKSAqIHNpei5YVHNpeiwgc2l6LlhzaXopOwogICAgICB0aWxlLnR5MSA9IE1hdGgubWluKHNpei5ZVE9zaXogKyAocSArIDEpICogc2l6LllUc2l6LCBzaXouWXNpeik7CiAgICAgIHRpbGUud2lkdGggPSB0aWxlLnR4MSAtIHRpbGUudHgwOwogICAgICB0aWxlLmhlaWdodCA9IHRpbGUudHkxIC0gdGlsZS50eTA7CiAgICAgIHRpbGUuY29tcG9uZW50cyA9IFtdOwogICAgICB0aWxlcy5wdXNoKHRpbGUpOwogICAgfQogIH0KICBjb250ZXh0LnRpbGVzID0gdGlsZXM7CiAgY29uc3QgY29tcG9uZW50c0NvdW50ID0gc2l6LkNzaXo7CiAgZm9yIChsZXQgaSA9IDAsIGlpID0gY29tcG9uZW50c0NvdW50OyBpIDwgaWk7IGkrKykgewogICAgY29uc3QgY29tcG9uZW50ID0gY29tcG9uZW50c1tpXTsKICAgIGZvciAobGV0IGogPSAwLCBqaiA9IHRpbGVzLmxlbmd0aDsgaiA8IGpqOyBqKyspIHsKICAgICAgY29uc3QgdGlsZUNvbXBvbmVudCA9IHt9OwogICAgICB0aWxlID0gdGlsZXNbal07CiAgICAgIHRpbGVDb21wb25lbnQudGN4MCA9IE1hdGguY2VpbCh0aWxlLnR4MCAvIGNvbXBvbmVudC5YUnNpeik7CiAgICAgIHRpbGVDb21wb25lbnQudGN5MCA9IE1hdGguY2VpbCh0aWxlLnR5MCAvIGNvbXBvbmVudC5ZUnNpeik7CiAgICAgIHRpbGVDb21wb25lbnQudGN4MSA9IE1hdGguY2VpbCh0aWxlLnR4MSAvIGNvbXBvbmVudC5YUnNpeik7CiAgICAgIHRpbGVDb21wb25lbnQudGN5MSA9IE1hdGguY2VpbC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ICB0YnkxOiBjb2RlYmxvY2tIZWlnaHQgKiAoaiArIDEpCiAgICAgIH07CiAgICAgIGNvZGVibG9jay50YngwXyA9IE1hdGgubWF4KHN1YmJhbmQudGJ4MCwgY29kZWJsb2NrLnRieDApOwogICAgICBjb2RlYmxvY2sudGJ5MF8gPSBNYXRoLm1heChzdWJiYW5kLnRieTAsIGNvZGVibG9jay50YnkwKTsKICAgICAgY29kZWJsb2NrLnRieDFfID0gTWF0aC5taW4oc3ViYmFuZC50YngxLCBjb2RlYmxvY2sudGJ4MSk7CiAgICAgIGNvZGVibG9jay50YnkxXyA9IE1hdGgubWluKHN1YmJhbmQudGJ5MSwgY29kZWJsb2NrLnRieTEpOwogICAgICBjb25zdCBwaSA9IE1hdGguZmxvb3IoKGNvZGVibG9jay50YngwXyAtIHN1YmJhbmQudGJ4MCkgLyBwcmVjaW5jdFBhcmFtZXRlcnMucHJlY2luY3RXaWR0aEluU3ViYmFuZCk7CiAgICAgIGNvbnN0IHBqID0gTWF0aC5mbG9vcigoY29kZWJsb2NrLnRieTBfIC0gc3ViYmFuZC50YnkwKSAvIHByZWNpbmN0UGFyYW1ldGVycy5wcmVjaW5jdEhlaWdodEluU3ViYmFuZCk7CiAgICAgIHByZWNpbmN0TnVtYmVyID0gcGkgKyBwaiAqIHByZWNpbmN0UGFyYW1ldGVycy5udW1wcmVjaW5jdHN3aWRlOwogICAgICBjb2RlYmxvY2sucHJlY2luY3ROdW1iZXIgPSBwcmVjaW5jdE51bWJlcjsKICAgICAgY29kZWJsb2NrLnN1YmJhbmRUeXBlID0gc3ViYmFuZC50eXBlOwogICAgICBjb2RlYmxvY2suTGJsb2NrID0gMzsKICAgICAgaWYgKGNvZGVibG9jay50YngxXyA8PSBjb2RlYmxvY2sudGJ4MF8gfHwgY29kZWJsb2NrLnRieTFfIDw9IGNvZGVibG9jay50YnkwXykgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvZGVibG9ja3MucHVzaChjb2RlYmxvY2spOwogICAgICBsZXQgcHJlY2luY3QgPSBwcmVjaW5jdHNbcHJlY2luY3ROdW1iZXJdOwogICAgICBpZiAocHJlY2luY3QgIT09IHVuZGVmaW5lZCkgewogICAgICAgIGlmIChpIDwgcHJlY2luY3QuY2J4TWluKSB7CiAgICAgICAgICBwcmVjaW5jdC5jYnhNaW4gPSBpOwogICAgICAgIH0gZWxzZSBpZiAoaSA+IHByZWNpbmN0LmNieE1heCkgewogICAgICAgICAgcHJlY2luY3QuY2J4TWF4ID0gaTsKICAgICAgICB9CiAgICAgICAgaWYgKGogPCBwcmVjaW5jdC5jYnlNaW4pIHsKICAgICAgICAgIHByZWNpbmN0LmNieE1pbiA9IGo7CiAgICAgICAgfSBlbHNlIGlmIChqID4gcHJlY2luY3QuY2J5TWF4KSB7CiAgICAgICAgICBwcmVjaW5jdC5jYnlNYXggPSBqOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICBwcmVjaW5jdHNbcHJlY2luY3ROdW1iZXJdID0gcHJlY2luY3QgPSB7CiAgICAgICAgICBjYnhNaW46IGksCiAgICAgICAgICBjYnlNaW46IGosCiAgICAgICAgICBjYnhNYXg6IGksCiAgICAgICAgICBjYnlNYXg6IGoKICAgICAgICB9OwogICAgICB9CiAgICAgIGNvZGVibG9jay5wcmVjaW5jdCA9IHByZWNpbmN0OwogICAgfQogIH0KICBzdWJiYW5kLmNvZGVibG9ja1BhcmFtZXRlcnMgPSB7CiAgICBjb2RlYmxvY2tXaWR0aDogeGNiXywKICAgIGNvZGVibG9ja0hlaWdodDogeWNiXywKICAgIG51bWNvZGVibG9ja3dpZGU6IGNieDEgLSBjYngwICsgMSwKICAgIG51bWNvZGVibG9ja2hpZ2g6IGNieTEgLSBjYnkwICsgMQogIH07CiAgc3ViYmFuZC5jb2RlYmxvY2tzID0gY29kZWJsb2NrczsKICBzdWJiYW5kLnByZWNpbmN0cyA9IHByZWNpbmN0czsKfQpmdW5jdGlvbiBjcmVhdGVQYWNrZXQocm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F4RGVjb21wb3NpdGlvbkxldmVsc0NvdW50ID0gMDsKICBmb3IgKGxldCBxID0gMDsgcSA8IGNvbXBvbmVudHNDb3VudDsgcSsrKSB7CiAgICBtYXhEZWNvbXBvc2l0aW9uTGV2ZWxzQ291bnQgPSBNYXRoLm1heChtYXhEZWNvbXBvc2l0aW9uTGV2ZWxzQ291bnQsIHRpbGUuY29tcG9uZW50c1txXS5jb2RpbmdTdHlsZVBhcmFtZXRlcnMuZGVjb21wb3NpdGlvbkxldmVsc0NvdW50KTsKICB9CiAgbGV0IGwgPSAwLAogICAgciA9IDAsCiAgICBpID0gMCwKICAgIGsgPSAwOwogIHRoaXMubmV4dFBhY2tldCA9IGZ1bmN0aW9uIEpweEltYWdlX25leHRQYWNrZXQoKSB7CiAgICBmb3IgKDsgbCA8IGxheWVyc0NvdW50OyBsKyspIHsKICAgICAgZm9yICg7IHIgPD0gbWF4RGVjb21wb3NpdGlvbkxldmVsc0NvdW50OyByKyspIHsKICAgICAgICBmb3IgKDsgaSA8IGNvbXBvbmVudHNDb3VudDsgaSsrKSB7CiAgICAgICAgICBjb25zdCBjb21wb25lbnQgPSB0aWxlLmNvbXBvbmVudHNbaV07CiAgICAgICAgICBpZiAociA+IGNvbXBvbmVudC5jb2RpbmdTdHlsZVBhcmFtZXRlcnMuZGVjb21wb3NpdGlvbkxldmVsc0NvdW50KSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgY29uc3QgcmVzb2x1dGlvbiA9IGNvbXBvbmVudC5yZXNvbHV0aW9uc1tyXTsKICAgICAgICAgIGNvbnN0IG51bXByZWNpbmN0cyA9IHJlc29sdXRpb24ucHJlY2luY3RQYXJhbWV0ZXJzLm51bXByZWNpbmN0czsKICAgICAgICAgIGZvciAoOyBrIDwgbnVtcHJlY2luY3RzOykgewogICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgaywgbCk7CiAgICAgIC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IGxheWVyc0NvdW50OyBsKyspIHsKICAgICAgICBmb3IgKDsgaSA8IGNvbXBvbmVudHNDb3VudDsgaSsrKSB7CiAgICAgICAgICBjb25zdCBjb21wb25lbnQgPSB0aWxlLmNvbXBvbmVudHNbaV07CiAgICAgICAgICBpZiAociA+IGNvbXBvbmVudC5jb2RpbmdTdHlsZVBhcmFtZXRlcnMuZGVjb21wb3NpdGlvbkxldmVsc0NvdW50KSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgY29uc3QgcmVzb2x1dGlvbiA9IGNvbXBvbmVudC5yZXNvbHV0aW9uc1tyXTsKICAgICAgICAgIGNvbnN0IG51bXByZWNpbmN0cyA9IHJlc29sdXRpb24ucHJlY2luY3RQYXJhbWV0ZXJzLm51bXByZWNpbmN0czsKICAgICAgICAgIGZvciAoOyBrIDwgbnVtcHJlY2luY3RzOykgewogICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgaywgbCk7CiAgICAgICAgICAgIGsrKzsKICAgICAgICAgICAgcmV0dXJuIHBhY2tldDsKICAgICAgICAgIH0KICAgICAgICAgIGsgPSAwOwogICAgICAgIH0KICAgICAgICBpID0gMDsKICAgICAgfQogICAgICBsID0gMDsKICAgIH0KICAgIHRocm93IG5ldyBKcHhFcnJvcigiT3V0IG9mIHBhY2tldHMiKTsKICB9Owp9CmZ1bmN0aW9uIFJlc29sdXRpb25Qb3NpdGlvbkNvbXBvbmVudExheWVySXRlcmF0b3IoY29udGV4dCkgewogIGNvbnN0IHNpeiA9IGNvbnRleHQuU0laOwogIGNvbnN0IHRpbGVJbmRleCA9IGNvbnRleHQuY3VycmVudFRpbGUuaW5kZXg7CiAgY29uc3QgdGlsZSA9IGNvbnRleHQudGlsZXNbdGlsZUluZGV4XTsKICBjb25zdCBsYXllcnNDb3VudCA9IHRpbGUuY29kaW5nU3R5bGVEZWZhdWx0UGFyYW1ldGVycy5sYX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uZXh0UGFja2V0ID0gZnVuY3Rpb24gSnB4SW1hZ2VfbmV4dFBhY2tldCgpIHsKICAgIGZvciAoOyByIDw9IG1heERlY29tcG9zaXRpb25MZXZlbHNDb3VudDsgcisrKSB7CiAgICAgIGZvciAoOyBwIDwgbWF4TnVtUHJlY2luY3RzSW5MZXZlbFtyXTsgcCsrKSB7CiAgICAgICAgZm9yICg7IGMgPCBjb21wb25lbnRzQ291bnQ7IGMrKykgewogICAgICAgICAgY29uc3QgY29tcG9uZW50ID0gdGlsZS5jb21wb25lbnRzW2NdOwogICAgICAgICAgaWYgKHIgPiBjb21wb25lbnQuY29kaW5nU3R5bGVQYXJhbWV0ZXJzLmRlY29tcG9zaXRpb25MZXZlbHNDb3VudCkgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IHJlc29sdXRpb24gPSBjb21wb25lbnQucmVzb2x1dGlvbnNbcl07CiAgICAgICAgICBjb25zdCBudW1wcmVjaW5jdHMgPSByZXNvbHV0aW9uLnByZWNpbmN0UGFyYW1ldGVycy5udW1wcmVjaW5jdHM7CiAgICAgICAgICBpZiAocCA+PSBudW1wcmVjaW5jdHMpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBmb3IgKDsgbCA8IGxheWVyc0NvdW50OykgewogICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgcCwgbCk7CiAgICAgICAgICAgIGwrKzsKICAgICAgICAgICAgcmV0dXJuIHBhY2tldDsKICAgICAgICAgIH0KICAgICAgICAgIGwgPSAwOwogICAgICAgIH0KICAgICAgICBjID0gMDsKICAgICAgfQogICAgICBwID0gMDsKICAgIH0KICAgIHRocm93IG5ldyBKcHhFcnJvcigiT3V0IG9mIHBhY2tldHMiKTsKICB9Owp9CmZ1bmN0aW9uIFBvc2l0aW9uQ29tcG9uZW50UmVzb2x1dGlvbkxheWVySXRlcmF0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Jlc29sdXRpb24gPSBjb21wb25lbnQucmVzb2x1dGlvbnNbcl07CiAgICAgICAgICAgIGNvbnN0IHNpemVJbkltYWdlU2NhbGUgPSBwcmVjaW5jdHNTaXplcy5jb21wb25lbnRzW2NdLnJlc29sdXRpb25zW3JdOwogICAgICAgICAgICBjb25zdCBrID0gZ2V0UHJlY2luY3RJbmRleElmRXhpc3QocHgsIHB5LCBzaXplSW5JbWFnZVNjYWxlLCBwcmVjaW5jdHNJdGVyYXRpb25TaXplcywgcmVzb2x1dGlvbik7CiAgICAgICAgICAgIGlmIChrID09PSBudWxsKSB7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZm9yICg7IGwgPCBsYXllcnNDb3VudDspIHsKICAgICAgICAgICAgICBjb25zdCBwYWNrZXQgPSBjcmVhdGVQYWNrZXQocmVzb2x1dGlvbiwgaywgbCk7CiAgICAgICAgICAgICAgbCsrOwogICAgICAgICAgICAgIHJldHVybiBwYWNrZXQ7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgbCA9IDA7CiAgICAgICAgICB9CiAgICAgICAgICByID0gMDsKICAgICAgICB9CiAgICAgICAgYyA9IDA7CiAgICAgIH0KICAgICAgcHggPSAwOwogICAgfQogICAgdGhyb3cgbmV3IEpweEVycm9yKCJPdXQgb2YgcGFja2V0cyIpOwogIH07Cn0KZnVuY3Rpb24gQ29tcG9uZW50UG9zaXRpb25SZXNvbHV0aW9uTGF5ZXJJdGVyYXRvcihjb250ZXh0KSB7CiAgY29uc3Qgc2l6ID0gY29udGV4dC5TSVo7CiAgY29uc3QgdGlsZUluZGV4ID0gY29udGV4dC5jdXJyZW50VGlsZS5pbmRleDsKICBjb25zdCB0aWxlID0gY29udGV4dC50aWxlc1t0aWxlSW5kZXhdOwogIGNvbnN0IGxheWVyc0NvdW50ID0gdGlsZS5jb2RpbmdTdHlsZURlZmF1bHRQYXJhbWV0ZXJzLmxheWVyc0NvdW50OwogIGNvbnN0IGNv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Y3RzSXRlcmF0aW9uU2l6ZXMsIHJlc29sdXRpb24pOwogICAgICAgICAgICBpZiAoayA9PT0gbnVsbCkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZvciAoOyBsIDwgbGF5ZXJzQ291bnQ7KSB7CiAgICAgICAgICAgICAgY29uc3QgcGFja2V0ID0gY3JlYXRlUGFja2V0KHJlc29sdXRpb24sIGssIGwpOwogICAgICAgICAgICAgIGwrKzsKICAgICAgICAgICAgICByZXR1cm4gcGFja2V0OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGwgPSAwOwogICAgICAgICAgfQogICAgICAgICAgciA9IDA7CiAgICAgICAgfQogICAgICAgIHB4ID0gMDsKICAgICAgfQogICAgICBweSA9IDA7CiAgICB9CiAgICB0aHJvdyBuZXcgSnB4RXJyb3IoIk91dCBvZiBwYWNrZXRzIik7CiAgfTsKfQpmdW5jdGlvbiBnZXRQcmVjaW5jdEluZGV4SWZFeGlzdChweEluZGV4LCBweUluZGV4LCBzaXplSW5JbWFnZVNjYWxlLCBwcmVjaW5jdEl0ZXJhdGlvblNpemVzLCByZXNvbHV0aW9uKSB7CiAgY29uc3QgcG9zWCA9IHB4SW5kZXggKiBwcmVjaW5jdEl0ZXJhdGlvblNpemVzLm1pbldpZHRoOwogIGNvbnN0IHBvc1kgPSBweUluZGV4ICogcHJlY2luY3RJdGVyYXRpb25TaXplcy5taW5IZWlnaHQ7CiAgaWYgKHBvc1ggJSBzaXplSW5JbWFnZVNjYWxlLndpZHRoICE9PSAwIHx8IHBvc1kgJSBzaXplSW5JbWFnZVNjYWxlLmhlaWdodCAhPT0gMCkgewogICAgcmV0dXJuIG51bGw7CiAgfQogIGNvbnN0IHN0YXJ0UHJlY2luY3RSb3dJbmRleCA9IHBvc1kgLyBzaXplSW5JbWFnZVNjYWxlLndpZHRoICogcmVzb2x1dGlvbi5wcmVjaW5jdFBhcmFtZXRlcnMubnVtcHJlY2luY3Rzd2l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HRoID0gTWF0aC5taW4obWluV2lkdGgsIG1pbldpZHRoQ3VycmVudENvbXBvbmVudCk7CiAgICBtaW5IZWlnaHQgPSBNYXRoLm1pbihtaW5IZWlnaHQsIG1pbkhlaWdodEN1cnJlbnRDb21wb25lbnQpOwogICAgbWF4TnVtV2lkZSA9IE1hdGgubWF4KG1heE51bVdpZGUsIG1heE51bVdpZGVDdXJyZW50Q29tcG9uZW50KTsKICAgIG1heE51bUhpZ2ggPSBNYXRoLm1heChtYXhOdW1IaWdoLCBtYXhOdW1IaWdoQ3VycmVudENvbXBvbmVudCk7CiAgICBzaXplUGVyQ29tcG9uZW50W2NdID0gewogICAgICByZXNvbHV0aW9uczogc2l6ZVBlclJlc29sdXRpb24sCiAgICAgIG1pbldpZHRoOiBtaW5XaWR0aEN1cnJlbnRDb21wb25lbnQsCiAgICAgIG1pbkhlaWdodDogbWluSGVpZ2h0Q3VycmVudENvbXBvbmVudCwKICAgICAgbWF4TnVtV2lkZTogbWF4TnVtV2lkZUN1cnJlbnRDb21wb25lbnQsCiAgICAgIG1heE51bUhpZ2g6IG1heE51bUhpZ2hDdXJyZW50Q29tcG9uZW50CiAgICB9OwogIH0KICByZXR1cm4gewogICAgY29tcG9uZW50czogc2l6ZVBlckNvbXBvbmVudCwKICAgIG1pbldpZHRoLAogICAgbWluSGVpZ2h0LAogICAgbWF4TnVtV2lkZSwKICAgIG1heE51bUhpZ2gKICB9Owp9CmZ1bmN0aW9uIGJ1aWxkUGFja2V0cyhjb250ZXh0KSB7CiAgY29uc3Qgc2l6ID0gY29udGV4dC5TSVo7CiAgY29uc3QgdGlsZUluZGV4ID0gY29udGV4dC5jdXJyZW50VGlsZS5pbmRleDsKICBjb25zdCB0aWxlID0gY29udGV4dC50aWxlc1t0aWxlSW5kZXhdOwogIGNvbnN0IGNvbXBvbmVudHNDb3VudCA9IHNpei5Dc2l6OwogIGZvciAobGV0IGMgPSAwOyBjIDwgY29tcG9uZW50c0NvdW50OyBjKyspIHsKICAgI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lOwogICAgICAgICAgcHJlY2luY3QuemVyb0JpdFBsYW5lc1RyZWUgPSB6ZXJvQml0UGxhbmVzVHJlZTsKICAgICAgICAgIGZvciAobGV0IGwgPSAwOyBsIDwgbGF5ZXJOdW1iZXI7IGwrKykgewogICAgICAgICAgICBpZiAocmVhZEJpdHMoMSkgIT09IDApIHsKICAgICAgICAgICAgICB0aHJvdyBuZXcgSnB4RXJyb3IoIkludmFsaWQgdGFnIHRyZWUiKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoaW5jbHVzaW9uVHJlZS5yZXNldChjb2RlYmxvY2tDb2x1bW4sIGNvZGVibG9ja1JvdywgbGF5ZXJOdW1iZXIpKSB7CiAgICAgICAgICB3aGlsZSAodHJ1ZSkgewogICAgICAgICAgICBpZiAocmVhZEJpdHMoMSkpIHsKICAgICAgICAgICAgICB2YWx1ZVJlYWR5ID0gIWluY2x1c2lvblRyZWUubmV4dExldmVsKCk7CiAgICAgICAgICAgICAgaWYgKHZhbHVlUmVhZHkpIHsKICAgICAgICAgICAgICAgIGNvZGVibG9jay5pbmNsdWRlZCA9IHRydWU7CiAgICAgICAgICAgICAgICBjb2RlYmxvY2tJbmNsdWRlZCA9IGZpcnN0VGltZUluY2x1c2lvbiA9IHRydWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgaW5jbHVzaW9uVHJlZS5pbmNyZW1lbnRWYWx1ZShsYXllck51bWJlcik7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCFjb2RlYmxvY2tJbmNsdWRlZCkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmIChmaXJzdFRpbWVJbmNsdXNpb24pIHsKICAgICAgICB6ZXJvQml0UGxhbmVzVHJlZSA9IHByZWNpbmN0Lnplcm9CaXRQbGFuZXNUcmVlOwogICAgICAgIHplcm9CaXRQbGFuZXNUcmVlLnJlc2V0KGNvZGVibG9ja0NvbHVtbiwgY29kZWJsb2NrUm93KTsKICAgICAgICB3aGlsZSAodHJ1ZSkgewogICAgICAgICAgaWYgKHJlYWRCaXRzKDEpKSB7CiAgICAgICAgICAgIHZhbHVlUmVhZHkgPSAhemVyb0JpdFBsYW5lc1RyZWUubmV4dExldmVsKCk7CiAgICAgICAgICAgIGlmICh2YWx1ZVJlYWR5KSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHplcm9CaXRQbGFuZXNUcmVlLmluY3JlbWVudFZhbHVlKCk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGNvZGVibG9jay56ZXJvQml0UGxhbmVzID0gemVyb0JpdFBsYW5lc1RyZWUudmFsdWU7CiAgICAgIH0KICAgICAgY29uc3QgY29kaW5ncGFzc2VzID0gcmVhZENvZGluZ3Bhc3NlcygpOwogICAgICB3aGlsZSAocmVhZEJpdHMoMSkpIHsKICAgICAgICBjb2RlYmxvY2suTGJsb2NrKys7CiAgICAgIH0KICAgICAgY29uc3QgY29kaW5ncGFzc2VzTG9nMiA9ICgwLCBfY29yZV91dGlscy5sb2cyKShjb2RpbmdwYXNzZXMpOwogICAgICBjb25zdCBiaXRzID0gKGNvZGluZ3Bhc3NlcyA8IDEgPDwgY29kaW5ncGFzc2VzTG9nMiA/IGNvZGluZ3Bhc3Nlc0xvZzIgLSAxIDogY29kaW5ncGFzc2VzTG9nMikgKyBjb2RlYmxvY2suTGJsb2NrOwogICAgICBjb25zdCBjb2RlZERhdGFMZW5ndGggPSByZWFkQml0cyhiaXRzKTsKICAgICAgcXVldWUucHVzaCh7CiAgICAgICAgY29kZWJsb2NrLAogICAgICAgIGNvZGluZ3Bhc3NlcywKICAgICAgICBkYXRhTGVuZ3RoOiBjb2Rl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0aW9uU3ltYm9sVXNlZCkgewogICAgICAgICAgICBiaXRNb2RlbC5jaGVja1NlZ21lbnRhdGlvblN5bWJvbCgpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKHJlc2V0Q29udGV4dFByb2JhYmlsaXRpZXMpIHsKICAgICAgICBiaXRNb2RlbC5yZXNldCgpOwogICAgICB9CiAgICAgIGN1cnJlbnRDb2RpbmdwYXNzVHlwZSA9IChjdXJyZW50Q29kaW5ncGFzc1R5cGUgKyAxKSAlIDM7CiAgICB9CiAgICBsZXQgb2Zmc2V0ID0gY29kZWJsb2NrLnRieDBfIC0geDAgKyAoY29kZWJsb2NrLnRieTBfIC0geTApICogd2lkdGg7CiAgICBjb25zdCBzaWduID0gYml0TW9kZWwuY29lZmZpY2VudHNTaWduOwogICAgY29uc3QgbWFnbml0dWRlID0gYml0TW9kZWwuY29lZmZpY2VudHNNYWduaXR1ZGU7CiAgICBjb25zdCBiaXRzRGVjb2RlZCA9IGJpdE1vZGVsLmJpdHNEZWNvZGVkOwogICAgY29uc3QgbWFnbml0dWRlQ29ycmVjdGlvbiA9IHJldmVyc2libGUgPyAwIDogMC41OwogICAgbGV0IGssIG4sIG5iOwogICAgcG9zaXRpb24gPSAwOwogICAgY29uc3QgaW50ZXJsZWF2ZSA9IHN1YmJhbmQudHlwZSAhPT0gIkxMIjsKICAgIGZvciAoaiA9IDA7IGogPCBibG9ja0hlaWdodDsgaisrKSB7CiAgICAgIGNvbnN0IHJvdyA9IG9mZnNldCAvIHdpZHRoIHwgMDsKICAgICAgY29uc3QgbGV2ZWxPZmZzZXQgPSAyICogcm93ICogKGxldmVsV2lkdGggLSB3aWR0aCkgKyByaWdodCArIGJvdHRvbTsKICAgICAgZm9yIChrID0gMDsgayA8IGJsb2NrV2lkdGg7IGsrKykgewogICAgICAgIG4gPSBtYWduaXR1ZGVbcG9zaXRpb25dOwogICAgICAgIGlmIChuICE9PSAwKSB7CiAgICAgICAgIC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1zW2pdOwogICAgICAgICAgb3V0W3BvcysrXSA9IHkwICsgMS40MDIgKiB5MiA+PiBzaGlmdDsKICAgICAgICAgIG91dFtwb3MrK10gPSB5MCAtIDAuMzQ0MTMgKiB5MSAtIDAuNzE0MTQgKiB5MiA+PiBzaGlmdDsKICAgICAgICAgIG91dFtwb3MrK10gPSB5MCArIDEuNzcyICogeTEgPj4gc2hpZnQ7CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGZvciAoaiA9IDA7IGogPCBqajsgaisrLCBwb3MgKz0gYWxwaGEwMSkgewogICAgICAgICAgeTAgPSB5MGl0ZW1zW2pdICsgb2Zmc2V0OwogICAgICAgICAgeTEgPSB5MWl0ZW1zW2pdOwogICAgICAgICAgeTIgPSB5Mml0ZW1zW2pdOwogICAgICAgICAgY29uc3QgZyA9IHkwIC0gKHkyICsgeTEgPj4gMik7CiAgICAgICAgICBvdXRbcG9zKytdID0gZyArIHkyID4+IHNoaWZ0OwogICAgICAgICAgb3V0W3BvcysrXSA9IGcgPj4gc2hpZnQ7CiAgICAgICAgICBvdXRbcG9zKytdID0gZyArIHkxID4+IHNoaWZ0OwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoZm91ckNvbXBvbmVudHMpIHsKICAgICAgICBmb3IgKGogPSAwLCBwb3MgPSAzOyBqIDwgamo7IGorKywgcG9zICs9IDQpIHsKICAgICAgICAgIG91dFtwb3NdID0geTNpdGVtc1tqXSArIG9mZnNldCA+PiBzaGlmdDsKICAgICAgICB9CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGZvciAobGV0IGMgPSAwOyBjIDwgY29tcG9uZW50c0NvdW50OyBjKyspIHsKICAgICAgICBjb25zdCBpdGVtcyA9IHRyYW5zZm9ybWVkVGlsZXNbY10uaXRlbXM7CiAgICAgICAgc2hpZnQgPSBjb21wb25lbnRzW2NdLnByZWNpc2lvbiAtIDg7CiAgICAgICAgb2Zmc2V0ID0gKDEyOCA8PCBzaGlmdCkgKyA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iAxNCkgewogICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlID0gbmV3IFVpbnQzMkFycmF5KGNvZWZmaWNpZW50Q291bnQpOwogICAgICB9IGVsc2UgaWYgKG1iID4gNikgewogICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlID0gbmV3IFVpbnQxNkFycmF5KGNvZWZmaWNpZW50Q291bnQpOwogICAgICB9IGVsc2UgewogICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlID0gbmV3IFVpbnQ4QXJyYXkoY29lZmZpY2llbnRDb3VudCk7CiAgICAgIH0KICAgICAgdGhpcy5jb2VmZmljZW50c01hZ25pdHVkZSA9IGNvZWZmaWNlbnRzTWFnbml0dWRlOwogICAgICB0aGlzLnByb2Nlc3NpbmdGbGFncyA9IG5ldyBVaW50OEFycmF5KGNvZWZmaWNpZW50Q291bnQpOwogICAgICBjb25zdCBiaXRzRGVjb2RlZCA9IG5ldyBVaW50OEFycmF5KGNvZWZmaWNpZW50Q291bnQpOwogICAgICBpZiAoemVyb0JpdFBsYW5lcyAhPT0gMCkgewogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgY29lZmZpY2llbnRDb3VudDsgaSsrKSB7CiAgICAgICAgICBiaXRzRGVjb2RlZFtpXSA9IHplcm9CaXRQbGFuZXM7CiAgICAgICAgfQogICAgICB9CiAgICAgIHRoaXMuYml0c0RlY29kZWQgPSBiaXRzRGVjb2RlZDsKICAgICAgdGhpcy5yZXNldCgpOwogICAgfQogICAgc2V0RGVjb2RlcihkZWNvZGVyKSB7CiAgICAgIHRoaXMuZGVjb2RlciA9IGRlY29kZXI7CiAgICB9CiAgICByZXNldCgpIHsKICAgICAgdGhpcy5jb250ZXh0cyA9IG5ldyBJbnQ4QXJyYXkoMTkpOwogICAgICB0aGlzLmNvbnRleHRzWzBdID0gNCA8PCAxIHwgMDsKICAgICAgdGhpcy5jb250ZXh0c1tVTklGT1JNX0NPTlRFWFRdID0gNDYgPDwgMSB8IDA7CiAgICAgIHRoaXMuY29udGV4dHNbUlVOTEVOR1RIX0NPTlRFWFRdID0gMyA8PCAxIHwgMDsKICAgIH0KICAgIHNldE5laWdoYm9yc1NpZ25pZmljYW5jZShyb3csIGNvbHVtbiwgaW5kZXgpIHsKICAgICAgY29uc3QgbmVpZ2hib3JzU2lnbmlmaWNhbmNlID0gdGhpcy5uZWlnaGJvcnNTaWduaWZpY2FuY2U7CiAgICAgIGNvbnN0IHdpZHRoID0gdGhpcy53aWR0aCwKICAgICAgICBoZWlnaHQgPSB0aGlzLmhlaWdodDsKICAgICAgY29uc3QgbGVmdCA9IGNvbHVtbiA+IDA7CiAgICAgIGNvbnN0IHJpZ2h0ID0gY29sdW1uICsgMSA8IHdpZHRoOwogICAgICBsZXQgaTsKICAgICAgaWYgKHJvdyA+IDApIHsKICAgICAgICBpID0gaW5kZXggLSB3aWR0aDsKICAgICAgICBpZiAobGVmdCkgewogICAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2kgLSAxXSArPSAweDEwOwogICAgICAgIH0KICAgICAgICBpZiAocmlnaHQpIHsKICAgICAgICAgIG5laWdoYm9yc1NpZ25pZmljYW5jZVtpICsgMV0gKz0gMHgxMDsKICAgICAgICB9CiAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2ldICs9IDB4MDQ7CiAgICAgIH0KICAgICAgaWYgKHJvdyArIDEgPCBoZWlnaHQpIHsKICAgICAgICBpID0gaW5kZXggKyB3aWR0aDsKICAgICAgICBpZiAobGVmdCkgewogICAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2kgLSAxXSArPSAweDEwOwogICAgICAgIH0KICAgICAgICBpZiAocmlnaHQpIHsKICAgICAgICAgIG5laWdoYm9yc1NpZ25pZmljYW5jZVtpICsgMV0gKz0gMHgxMDsKICAgICAgICB9CiAgICAgICAgbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2ldICs9IDB4MDQ7CiAgICAgIH0KICAgICAgaWYgKGx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7CiAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCB3aWR0aDsgaisrKSB7CiAgICAgICAgICBsZXQgaW5kZXggPSBpMCAqIHdpZHRoICsgajsKICAgICAgICAgIGZvciAobGV0IGkxID0gMDsgaTEgPCA0OyBpMSsrLCBpbmRleCArPSB3aWR0aCkgewogICAgICAgICAgICBjb25zdCBpID0gaTAgKyBpMTsKICAgICAgICAgICAgaWYgKGkgPj0gaGVpZ2h0KSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcHJvY2Vzc2luZ0ZsYWdzW2luZGV4XSAmPSBwcm9jZXNzZWRJbnZlcnNlTWFzazsKICAgICAgICAgICAgaWYgKGNvZWZmaWNlbnRzTWFnbml0dWRlW2luZGV4XSB8fCAhbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2luZGV4XSkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGNvbnRleHRMYWJlbCA9IGxhYmVsc1tuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXhdXTsKICAgICAgICAgICAgY29uc3QgZGVjaXNpb24gPSBkZWNvZGVyLnJlYWRCaXQoY29udGV4dHMsIGNvbnRleHRMYWJlbCk7CiAgICAgICAgICAgIGlmIChkZWNpc2lvbikgewogICAgICAgICAgICAgIGNvbnN0IHNpZ24gPSB0aGlzLmRlY29kZVNpZ25CaXQoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICAgIGNvZWZmaWNlbnRzU2lnbltpbmRleF0gPSBzaWduOwogICAgICAgICAgICAgIGNvZWZmaWNlbnRzTWFnbml0dWRlW2luZGV4XSA9IDE7CiAgICAgICAgICAgICAgdGhpcy5zZXROZWlnaGJvcnNTaWduaWZpY2FuY2UoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICAgIHByb2Nlc3NpbmdGbGFnc1tpbmRleF0gfD0gZmlyc3RNYWduaXR1ZGVCaXRNYXNrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJpdHNEZWNvZGVkW2luZGV4XSsrOwogICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIHw9IHByb2Nlc3NlZE1hc2s7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBkZWNvZGVTaWduQml0KHJvdywgY29sdW1uLCBpbmRleCkgewogICAgICBjb25zdCB3aWR0aCA9IHRoaXMud2lkdGgsCiAgICAgICAgaGVpZ2h0ID0gdGhpcy5oZWlnaHQ7CiAgICAgIGNvbnN0IGNvZWZmaWNlbnRzTWFnbml0dWRlID0gdGhpcy5jb2VmZmljZW50c01hZ25pdHVkZTsKICAgICAgY29uc3QgY29lZmZpY2VudHNTaWduID0gdGhpcy5jb2VmZmljZW50c1NpZ247CiAgICAgIGxldCBjb250cmlidXRpb24sIHNpZ24wLCBzaWduMSwgc2lnbmlmaWNhbmNlMTsKICAgICAgbGV0IGNvbnRleHRMYWJlbCwgZGVjb2RlZDsKICAgICAgc2lnbmlmaWNhbmNlMSA9IGNvbHVtbiA+IDAgJiYgY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXggLSAxXSAhPT0gMDsKICAgICAgaWYgKGNvbHVtbiArIDEgPCB3aWR0aCAmJiBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleCArIDFdICE9PSAwKSB7CiAgICAgICAgc2lnbjEgPSBjb2VmZmljZW50c1NpZ25baW5kZXggKyAxXTsKICAgICAgICBpZiAoc2lnbmlmaWNhbmNlMSkgewogICAgICAgICAgc2lnbjAgPSBjb2VmZmljZW50c1NpZ25baW5kZXggLSAxXTsKICAgICAgICAgIGNvbnRyaWJ1dGlvbiA9IDEgLSBzaWduMSAtIHNpZ24wOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb250cmlidXRpb24gPSAxIC0gc2lnbjEgLSBzaWduMTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoc2lnbmlmaWNhbmNlMSkgewogICAgICAgIHNpZ24wID0gY29lZmZpY2VudHNTaWduW2luZGV4IC0gMV07CiAgICAgICAgY29udHJpYnV0aW9uID0gMSAtIHNpZ24wIC0gc2lnbjA7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29udHJpYnV0aW9uID0gMDsKICAgICAgfQogICAgICBjb25zdCBob3Jpem9udGFsQ29udHJpYnV0aW9uID0gMyAqIGNvbnRyaWJ1dGlvbjsKICAgICAgc2lnbmlmaWNhbmNlMSA9IHJvdyA+IDAgJiYgY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXggLSB3aWR0aF0gIT09IDA7CiAgICAgIGlmIChyb3cgKyAxIDwgaGVpZ2h0ICYmIGNvZWZmaWNlbnRzTWFnbml0dWRlW2luZGV4ICsgd2lkdGhdICE9PSAwKSB7CiAgICAgICAgc2lnbjEgPSBjb2VmZmljZW50c1NpZ25baW5kZXggKyB3aWR0aF07CiAgICAgICAgaWYgKHNpZ25pZmljYW5jZTEpIHsKICAgICAgICAgIHNpZ24wID0gY29lZmZpY2VudHNTaWduW2luZGV4IC0gd2lkdGhdOwogICAgICAgICAgY29udHJpYnV0aW9uID0gMSAtIHNpZ24xIC0gc2lnbjAgKyBob3Jpem9udGFsQ29udHJpYnV0aW9uOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb250cmlidXRpb24gPSAxIC0gc2lnbjEgLSBzaWduMSArIGhvcml6b250YWxDb250cmlidXRpb247CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKHNpZ25pZmljYW5jZTEpIHsKICAgICAgICBzaWduMCA9IGNvZWZmaWNlbnRzU2lnbltpbmRleCAtIHdpZHRoXTsKICAgICAgICBjb250cmlidXRpb24gPSAxIC0gc2lnbjAgLSBzaWduMCArIGhvcml6b250YWxDb250cmlidXRpb247CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29udHJpYnV0aW9uID0gaG9yaXpvbnRhbENvbnRyaWJ1dGlvbjsKICAgICAgfQogICAgICBpZiAoY29udHJpYnV0aW9uID49IDApIHsKICAgICAgICBjb250ZXh0TGFiZWwgPSA5ICsgY29udHJpYnV0aW9uOwogICAgICAgIGRlY29kZWQgPSB0aGlzLmRlY29kZXIucmVhZEJpdCh0aGlzLmNvbnRleHRzLCBjb250ZXh0TGFiZWwpOwogICAgICB9IGVsc2UgewogICAgICAgIGNvbnRleHRMYWJlbCA9IDkgLSBjb250cmlidXRpb247CiAgICAgICAgZGVjb2RlZCA9IHRoaXMuZGVjb2Rlci5yZWFkQml0KHRoaXMuY29udGV4dHMsIGNvbnRleHRMYWJlbCkgXiAxOwogICAgICB9CiAgICAgIHJldHVybiBkZWNvZGVkOwogICAgfQogICAgcnVuTWFnbml0dWRlUmVmaW5lbWVudFBhc3MoKSB7CiAgICAgIGNvbnN0IGRlY29kZXIgPSB0aGlzLmRlY29kZXI7CiAgICAgIGNvbnN0IHdpZHRoID0gdGhpcy53aWR0aCwKICAgICAgICBoZWlnaHQgPSB0aGlzLmhlaWdodDsKICAgICAgY29uc3QgY29lZmZpY2VudHNNYWduaXR1ZGUgPSB0aGlzLmNvZWZmaWNlbnRzTWFnbml0dWRlOwogICAgICBjb25zdCBuZWlnaGJvcnNTaWduaWZpY2FuY2UgPSB0aGlzLm5laWdoYm9yc1NpZ25pZmljYW5jZTsKICAgICAgY29uc3QgY29udGV4dHMgPSB0aGlzLmNvbnRleHRzOwogICAgICBjb25zdCBiaXRzRGVjb2RlZCA9IHRoaXMuYml0c0RlY29kZWQ7CiAgICAgIGNvbnN0IHByb2Nlc3NpbmdGbGFncyA9IHRoaXMucHJvY2Vzc2luZ0ZsYWdzOwogICAgICBjb25zdCBwcm9jZXNzZWRNYXNrID0gMTsKICAgICAgY29uc3QgZmlyc3RNYWduaXR1ZGVCaXRNYXNrID0gMjsKICAgICAgY29uc3QgbGVuZ3RoID0gd2lkdGggKiBoZWlnaHQ7CiAgICAgIGNvbnN0IHdpZHRoNCA9IHdpZHRoICogNDsKICAgICAgZm9yIChsZXQgaW5kZXgwID0gMCwgaW5kZXhOZXh0OyBpbmRleDAgPCBsZW5ndGg7IGluZGV4MCA9IGluZGV4TmV4dCkgewogICAgICAgIGluZGV4TmV4dCA9IE1hdGgubWluKGxlbmd0aCwgaW5kZXgwICsgd2lkdGg0KTsKICAgICAgICBmb3IgKGxldCBqID0gMDsgaiA8IHdpZHRoOyBqKyspIHsKICAgICAgICAgIGZvciAobGV0IGluZGV4ID0gaW5kZXgwICsgajsgaW5kZXggPCBpbmRleE5leHQ7IGluZGV4ICs9IHdpZHRoKSB7CiAgICAgICAgICAgIGlmICghY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXhdIHx8IChwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdICYgcHJvY2Vzc2VkTWFzaykgIT09IDApIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgY29udGV4dExhYmVsID0gMTY7CiAgICAgICAgICAgIGlmICgocHJvY2Vzc2luZ0ZsYWdzW2luZGV4XSAmIGZpcnN0TWFnbml0dWRlQml0TWFzaykgIT09IDApIHsKICAgICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIF49IGZpcnN0TWFnbml0dWRlQml0TWFzazsKICAgICAgICAgICAgICBjb25zdCBzaWduaWZpY2FuY2UgPSBuZWlnaGJvcnNTaWduaWZpY2FuY2VbaW5kZXhdICYgMTI3OwogICAgICAgICAgICAgIGNvbnRleHRMYWJlbCA9IHNpZ25pZmljYW5jZSA9PT0gMCA/IDE1IDogMTQ7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29uc3QgYml0ID0gZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBjb250ZXh0TGFiZWwpOwogICAgICAgICAgICBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleF0gPSBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleF0gPDwgMSB8IGJpdDsKICAgICAgICAgICAgYml0c0RlY29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gIGlmICghaGFzU2lnbmlmaWNhbnRDb2VmZmljZW50KSB7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXgwXSsrOwogICAgICAgICAgICAgIGJpdHNEZWNvZGVkW2luZGV4MCArIG9uZVJvd0Rvd25dKys7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXgwICsgdHdvUm93c0Rvd25dKys7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXgwICsgdGhyZWVSb3dzRG93bl0rKzsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpMSA9IGRlY29kZXIucmVhZEJpdChjb250ZXh0cywgVU5JRk9STV9DT05URVhUKSA8PCAxIHwgZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBVTklGT1JNX0NPTlRFWFQpOwogICAgICAgICAgICBpZiAoaTEgIT09IDApIHsKICAgICAgICAgICAgICBpID0gaTAgKyBpMTsKICAgICAgICAgICAgICBpbmRleCArPSBpMSAqIHdpZHRoOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHNpZ24gPSB0aGlzLmRlY29kZVNpZ25CaXQoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICBjb2VmZmljZW50c1NpZ25baW5kZXhdID0gc2lnbjsKICAgICAgICAgICAgY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXhdID0gMTsKICAgICAgICAgICAgdGhpcy5zZXROZWlnaGJvcnNTaWduaWZpY2FuY2UoaSwgaiwgaW5kZXgpOwogICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIHw9IGZpcnN0TWFnbml0dWRlQml0TWFzazsKICAgICAgICAgICAgaW5kZXggPSBpbmRleDA7CiAgICAgICAgICAgIGZvciAobGV0IGkyID0gaTA7IGkyIDw9IGk7IGkyKyssIGluZGV4ICs9IHdpZHRoKSB7CiAgICAgICAgICAgICAgYml0c0RlY29kZWRbaW5kZXhdKys7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaTErKzsKICAgICAgICAgIH0KICAgICAgICAgIGZvciAoaSA9IGkwICsgaTE7IGkgPCBpTmV4dDsgaSsrLCBpbmRleCArPSB3aWR0aCkgewogICAgICAgICAgICBpZiAoY29lZmZpY2VudHNNYWduaXR1ZGVbaW5kZXhdIHx8IChwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdICYgcHJvY2Vzc2VkTWFzaykgIT09IDApIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBjb250ZXh0TGFiZWwgPSBsYWJlbHNbbmVpZ2hib3JzU2lnbmlmaWNhbmNlW2luZGV4XV07CiAgICAgICAgICAgIGNvbnN0IGRlY2lzaW9uID0gZGVjb2Rlci5yZWFkQml0KGNvbnRleHRzLCBjb250ZXh0TGFiZWwpOwogICAgICAgICAgICBpZiAoZGVjaXNpb24gPT09IDEpIHsKICAgICAgICAgICAgICBzaWduID0gdGhpcy5kZWNvZGVTaWduQml0KGksIGosIGluZGV4KTsKICAgICAgICAgICAgICBjb2VmZmljZW50c1NpZ25baW5kZXhdID0gc2lnbjsKICAgICAgICAgICAgICBjb2VmZmljZW50c01hZ25pdHVkZVtpbmRleF0gPSAxOwogICAgICAgICAgICAgIHRoaXMuc2V0TmVpZ2hib3JzU2lnbmlmaWNhbmNlKGksIGosIGluZGV4KTsKICAgICAgICAgICAgICBwcm9jZXNzaW5nRmxhZ3NbaW5kZXhdIHw9IGZpcnN0TWFnbml0dWRlQml0TWFzazsKICAgICAgICAgICAgfQogICAgICAgICAgICBiaXRzRGVjb2RlZFtpbmRleF0rKzsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGNoZWNrU2VnbWVudGF0aW9uU3ltYm9sKCkgewogICAgICBjb25zdCBkZWNvZGVyID0gdGhpcy5kZWNvZGVyOwogICAgICBjb25zdCBjb250ZXh0cyA9IHRoaXMuY29udGV4dHM7CiAgICAgIGNvbnN0IH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gIH0gZWxzZSB7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIH0KICAgIGogPSBvZmZzZXQgLSAxOwogICAgY3VycmVudCA9IGdhbW1hICogeFtqIC0gMV07CiAgICBmb3IgKG4gPSBsZW4gKyAyOyBuLS07IGogKz0gMikgewogICAgICBuZXh0ID0gZ2FtbWEgKiB4W2ogKyAxXTsKICAgICAgeFtqXSAtPSBjdXJyZW50ICsgbmV4dDsKICAgICAgaWYgKG4tLSkgewogICAgICAgIGogKz0gMjsKICAgICAgICBjdXJyZW50ID0gZ2FtbWEgKiB4W2ogKyAxXTsKICAgICAgICB4W2pdIC09IGN1cnJlbnQgKyBuZXh0OwogICAgICB9IGVsc2UgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBqID0gb2Zmc2V0OwogICAgY3VycmVudCA9IGJldGEgKiB4W2ogLSAxXTsKICAgIGZvciAobiA9IGxlbiArIDE7IG4tLTsgaiArPSAyKSB7CiAgICAgIG5leHQgPSBiZXRhICogeFtqICsgMV07CiAgICAgIHhbal0gLT0gY3VycmVudCArIG5leHQ7CiAgICAgIGlmIChuLS0pIHsKICAgICAgICBqICs9IDI7CiAgICAgICAgY3VycmVudCA9IGJldGEgKiB4W2ogKyAxXTsKICAgICAgICB4W2pdIC09IGN1cnJlbnQgKyBuZXh0OwogICAgICB9IGVsc2UgewogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBpZiAobGVuICE9PSAwKSB7CiAgICAgIGogPSBvZmZzZXQgKyAxOwogICAgICBjdXJyZW50ID0gYWxwaGEgKiB4W2ogLSAxXTsKICAgICAgZm9yIChuID0gbGVuOyBuLS07IGogKz0gMikgewogICAgICAgIG5leHQgPSBhbHBoYSAqIHhbaiArIDFdOwogICAgICAgIHhbal0gLT0gY3VycmVudCArIG5leHQ7CiAgICAgICAgaWYgKG4tLSkgewogICAgICAgICAgaiArPSAyOwogICAgICAgICAgY3VycmVudCA9IGFscGhhICogeFtqICsgMV07CiA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BjdXJyZW50U2VxdWVuY2VbY3VycmVudFNlcXVlbmNlTGVuZ3RoKytdID0gY3VycmVudFNlcXVlbmNlWzBdOwogICAgICAgIH0KICAgICAgfSBlbHNlIGlmIChjb2RlID09PSAyNTYpIHsKICAgICAgICBjb2RlTGVuZ3RoID0gOTsKICAgICAgICBuZXh0Q29kZSA9IDI1ODsKICAgICAgICBjdXJyZW50U2VxdWVuY2VMZW5ndGggPSAwOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgewogICAgICAgIHRoaXMuZW9mID0gdHJ1ZTsKICAgICAgICBkZWxldGUgdGhpcy5sendTdGF0ZTsKICAgICAgICBicmVhazsKICAgICAgfQogICAgICBpZiAoaGFzUHJldikgewogICAgICAgIGRpY3Rpb25hcnlQcmV2Q29kZXNbbmV4dENvZGVdID0gcHJldkNvZGU7CiAgICAgICAgZGljdGlvbmFyeUxlbmd0aHNbbmV4dENvZGVdID0gZGljdGlvbmFyeUxlbmd0aHNbcHJldkNvZGVdICsgMTsKICAgICAgICBkaWN0aW9uYXJ5VmFsdWVzW25leHRDb2RlXSA9IGN1cnJlbnRTZXF1ZW5jZVswXTsKICAgICAgICBuZXh0Q29kZSsrOwogICAgICAgIGNvZGVMZW5ndGggPSBuZXh0Q29kZSArIGVhcmx5Q2hhbmdlICYgbmV4dENvZGUgKyBlYXJseUNoYW5nZSAtIDEgPyBjb2RlTGVuZ3RoIDogTWF0aC5taW4oTWF0aC5sb2cobmV4dENvZGUgKyBlYXJseUNoYW5nZSkgLyAwLjY5MzE0NzE4MDU1OTk0NTMgKyAxLCAxMikgfCAwOwogICAgICB9CiAgICAgIHByZXZDb2RlID0gY29kZTsKICAgICAgZGVjb2RlZExlbmd0aCArPSBjdXJyZW50U2VxdWVuY2VMZW5ndGg7CiAgICAgIGlmIChlc3RpbWF0ZWREZWNvZGVkU2l6ZSA8IGRlY29kZWRMZW5ndGgpIHsKICAgICAgICBkbyB7CiAgICAgICAgICBlc3RpbWF0ZWREZWN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sgPSAoMSA8PCBiaXRzKSAtIDE7CiAgICAgIGxldCBqID0gMCwKICAgICAgICBrID0gYnVmZmVyTGVuZ3RoOwogICAgICBjb25zdCBjb2x1bW5zID0gdGhpcy5jb2x1bW5zOwogICAgICBmb3IgKGkgPSAwOyBpIDwgY29sdW1uczsgKytpKSB7CiAgICAgICAgZm9yIChsZXQga2sgPSAwOyBrayA8IGNvbG9yczsgKytraykgewogICAgICAgICAgaWYgKGluYml0cyA8IGJpdHMpIHsKICAgICAgICAgICAgaW5idWYgPSBpbmJ1ZiA8PCA4IHwgcmF3Qnl0ZXNbaisrXSAmIDB4ZmY7CiAgICAgICAgICAgIGluYml0cyArPSA4OwogICAgICAgICAgfQogICAgICAgICAgY29tcEFycmF5W2trXSA9IGNvbXBBcnJheVtra10gKyAoaW5idWYgPj4gaW5iaXRzIC0gYml0cykgJiBiaXRNYXNrOwogICAgICAgICAgaW5iaXRzIC09IGJpdHM7CiAgICAgICAgICBvdXRidWYgPSBvdXRidWYgPDwgYml0cyB8IGNvbXBBcnJheVtra107CiAgICAgICAgICBvdXRiaXRzICs9IGJpdHM7CiAgICAgICAgICBpZiAob3V0Yml0cyA+PSA4KSB7CiAgICAgICAgICAgIGJ1ZmZlcltrKytdID0gb3V0YnVmID4+IG91dGJpdHMgLSA4ICYgMHhmZjsKICAgICAgICAgICAgb3V0Yml0cyAtPSA4OwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAob3V0Yml0cyA+IDApIHsKICAgICAgICBidWZmZXJbaysrXSA9IChvdXRidWYgPDwgOCAtIG91dGJpdHMpICsgKGluYnVmICYgKDEgPDwgOCAtIG91dGJpdHMpIC0gMSk7CiAgICAgIH0KICAgIH0KICAgIHRoaXMuYnVmZmVyTGVuZ3RoICs9IHJvd0J5dGVzOwogIH0KICByZWFkQmxvY2tQbmcoKSB7CiAgICBjb25zdCByb3dCeXRlcyA9IHRoaXMucm93Qnl0ZXM7CiAgICBjb25zdCBwaXhCeXRlc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c1tpXSAmIDB4ZmY7CiAgICAgICAgICBqKys7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBjYXNlIDI6CiAgICAgICAgZm9yIChpID0gMDsgaSA8IHJvd0J5dGVzOyArK2kpIHsKICAgICAgICAgIGJ1ZmZlcltqKytdID0gcHJldlJvd1tpXSArIHJhd0J5dGVzW2ldICYgMHhmZjsKICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgMzoKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgcGl4Qnl0ZXM7ICsraSkgewogICAgICAgICAgYnVmZmVyW2orK10gPSAocHJldlJvd1tpXSA+PiAxKSArIHJhd0J5dGVzW2ldOwogICAgICAgIH0KICAgICAgICBmb3IgKDsgaSA8IHJvd0J5dGVzOyArK2kpIHsKICAgICAgICAgIGJ1ZmZlcltqXSA9IChwcmV2Um93W2ldICsgYnVmZmVyW2ogLSBwaXhCeXRlc10gPj4gMSkgKyByYXdCeXRlc1tpXSAmIDB4ZmY7CiAgICAgICAgICBqKys7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBjYXNlIDQ6CiAgICAgICAgZm9yIChpID0gMDsgaSA8IHBpeEJ5dGVzOyArK2kpIHsKICAgICAgICAgIHVwID0gcHJldlJvd1tpXTsKICAgICAgICAgIGMgPSByYXdCeXRlc1tpXTsKICAgICAgICAgIGJ1ZmZlcltqKytdID0gdXAgKyBjOwogICAgICAgIH0KICAgICAgICBmb3IgKDsgaSA8IHJvd0J5dGVzOyArK2kpIHsKICAgICAgICAgIHVwID0gcHJldlJvd1tpXTsKICAgICAgICAgIGNvbnN0IHVwTGVmdCA9IHByZXZSb3dbaSAtIHBpeEJ5dGVzXTsKICAgICAgICAgIGNvbnN0IGxlZnQgPSBidWZmZXJbaiAtIHBpeEJ5dGVzXTsKICAgICAgICAgIGNvbnN0IHAgPSBsZWZ0ICsgdXAgLSB1cExlZnQ7CiAgICAgICAgICBsZXQgcGEgPSBwIC0gbGVmdDsKICAgICAgICAgIGlmIChwYSA8IDApIHsKICAgICAgICAgICAgcGEgPSAtcGE7CiAgICAgICAgICB9CiAgICAgICAgICBsZXQgcGIgPSBwIC0gdXA7CiAgICAgICAgICBpZiAocGIgPCAwKSB7CiAgICAgICAgICAgIHBiID0gLXBiOwogICAgICAgICAgfQogICAgICAgICAgbGV0IHBjID0gcCAtIHVwTGVmdDsKICAgICAgICAgIGlmIChwYyA8IDApIHsKICAgICAgICAgICAgcGMgPSAtcGM7CiAgICAgICAgICB9CiAgICAgICAgICBjID0gcmF3Qnl0ZXNbaV07CiAgICAgICAgICBpZiAocGEgPD0gcGIgJiYgcGEgPD0gcGMpIHsKICAgICAgICAgICAgYnVmZmVyW2orK10gPSBsZWZ0ICsgYzsKICAgICAgICAgIH0gZWxzZSBpZiAocGIgPD0gcGMpIHsKICAgICAgICAgICAgYnVmZmVyW2orK10gPSB1cCArIGM7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBidWZmZXJbaisrXSA9IHVwTGVmdCArIGM7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBkZWZhdWx0OgogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihgVW5zdXBwb3J0ZWQgcHJlZGljdG9yOiAke3ByZWRpY3Rvcn1gKTsKICAgIH0KICAgIHRoaXMuYnVmZmVyTGVuZ3RoICs9IHJvd0J5dGVzOwogIH0KfQpleHBvcnRzLlByZWRpY3RvclN0cmVhbSA9IFByZWRpY3RvclN0cmVhbTsKCi8qKiovIH0pLAovKiAxNjggKi8KLyoqKi8gKChfX3VudXNlZF93ZWJwYWNrX21vZHVsZSwgZXhwb3J0cywgX193X3BkZmpzX3JlcXVpcmVfXykgPT4gewoKInVzZSBzdHJpY3QiOwoKCk9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgdmFsdWU6IHRydWUKfSkpOwpleHBvcnRzLlJ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IHJhbmdlID0gcmFuZ2VzW2ldOwogICAgc3RhcnQgPSByYW5nZVswXTsKICAgIGVuZCA9IHJhbmdlWzFdOwogICAgc3RhcnRDb3VudCArPSBzdHJpbmcxNihzdGFydCk7CiAgICBlbmRDb3VudCArPSBzdHJpbmcxNihlbmQpOwogICAgY29kZXMgPSByYW5nZVsyXTsKICAgIGxldCBjb250aWd1b3VzID0gdHJ1ZTsKICAgIGZvciAoaiA9IDEsIGpqID0gY29kZXMubGVuZ3RoOyBqIDwgamo7ICsraikgewogICAgICBpZiAoY29kZXNbal0gIT09IGNvZGVzW2ogLSAxXSArIDEpIHsKICAgICAgICBjb250aWd1b3VzID0gZmFsc2U7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIH0KICAgIGlmICghY29udGlndW91cykgewogICAgICBjb25zdCBvZmZzZXQgPSAoc2VnQ291bnQgLSBpKSAqIDIgKyBiaWFzICogMjsKICAgICAgYmlhcyArPSBlbmQgLSBzdGFydCArIDE7CiAgICAgIGlkRGVsdGFzICs9IHN0cmluZzE2KDApOwogICAgICBpZFJhbmdlT2Zmc2V0cyArPSBzdHJpbmcxNihvZmZzZXQpOwogICAgICBmb3IgKGogPSAwLCBqaiA9IGNvZGVzLmxlbmd0aDsgaiA8IGpqOyArK2opIHsKICAgICAgICBnbHlwaHNJZHMgKz0gc3RyaW5nMTYoY29kZXNbal0pOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBzdGFydENvZGUgPSBjb2Rlc1swXTsKICAgICAgaWREZWx0YXMgKz0gc3RyaW5nMTYoc3RhcnRDb2RlIC0gc3RhcnQgJiAweGZmZmYpOwogICAgICBpZFJhbmdlT2Zmc2V0cyArPSBzdHJpbmcxNigwKTsKICAgIH0KICB9CiAgaWYgKHRyYWlsaW5nUmFuZ2VzQ291bnQgPiAwKSB7CiAgICBlbmRDb3VudCArPSAiXHhGRlx4RkYiOwogICAgc3RhcnRDb3VudCArPSAiXHhGRlx4RkYiOwogICAgaWREZW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R5cGUgPSAiZm9udC9vcGVudHlwZSI7CiAgICAgICAgICBjb25zdCBjZmYgPSBzdWJ0eXBlID09PSAiVHlwZTFDIiB8fCBzdWJ0eXBlID09PSAiQ0lERm9udFR5cGUwQyIgPyBuZXcgX2NmZl9mb250LkNGRkZvbnQoZmlsZSwgcHJvcGVydGllcykgOiBuZXcgX3R5cGUxX2ZvbnQuVHlwZTFGb250KG5hbWUsIGZpbGUsIHByb3BlcnRpZXMpOwogICAgICAgICAgYWRqdXN0V2lkdGhzKHByb3BlcnRpZXMpOwogICAgICAgICAgZGF0YSA9IHRoaXMuY29udmVydChuYW1lLCBjZmYsIHByb3BlcnRpZXMpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiT3BlblR5cGUiOgogICAgICAgIGNhc2UgIlRydWVUeXBlIjoKICAgICAgICBjYXNlICJDSURGb250VHlwZTIiOgogICAgICAgICAgdGhpcy5taW1ldHlwZSA9ICJmb250L29wZW50eXBlIjsKICAgICAgICAgIGRhdGEgPSB0aGlzLmNoZWNrQW5kUmVwYWlyKG5hbWUsIGZpbGUsIHByb3BlcnRpZXMpOwogICAgICAgICAgaWYgKHRoaXMuaXNPcGVuVHlwZSkgewogICAgICAgICAgICBhZGp1c3RXaWR0aHMocHJvcGVydGllcyk7CiAgICAgICAgICAgIHR5cGUgPSAiT3BlblR5cGUiOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihgRm9udCAke3R5cGV9IGlzIG5vdCBzdXBwb3J0ZWRgKTsKICAgICAgfQogICAgfSBjYXRjaCAoZSkgewogICAgICAoMCwgX3V0aWwud2FybikoZSk7CiAgICAgIHRoaXMuZmFsbGJhY2tUb1N5c3RlbUZvbnQocHJvcGVydGllcyk7CiAgICAgIHJldHVybjsKICAgIH0KICAgIGFtZW5kRmFsbGJhY2tUb1VuaWNvZGUocHJvcGVydG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WxlLCBudW1UYWJsZXMpIHsKICAgICAgY29uc3QgdGFibGVzID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgdGFibGVzWyJPUy8yIl0gPSBudWxsOwogICAgICB0YWJsZXMuY21hcCA9IG51bGw7CiAgICAgIHRhYmxlcy5oZWFkID0gbnVsbDsKICAgICAgdGFibGVzLmhoZWEgPSBudWxsOwogICAgICB0YWJsZXMuaG10eCA9IG51bGw7CiAgICAgIHRhYmxlcy5tYXhwID0gbnVsbDsKICAgICAgdGFibGVzLm5hbWUgPSBudWxsOwogICAgICB0YWJsZXMucG9zdCA9IG51bGw7CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbnVtVGFibGVzOyBpKyspIHsKICAgICAgICBjb25zdCB0YWJsZSA9IHJlYWRUYWJsZUVudHJ5KGZpbGUpOwogICAgICAgIGlmICghVkFMSURfVEFCTEVTLmluY2x1ZGVzKHRhYmxlLnRhZykpIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBpZiAodGFibGUubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgdGFibGVzW3RhYmxlLnRhZ10gPSB0YWJsZTsKICAgICAgfQogICAgICByZXR1cm4gdGFibGVzOwogICAgfQogICAgZnVuY3Rpb24gcmVhZFRhYmxlRW50cnkoZmlsZSkgewogICAgICBjb25zdCB0YWcgPSBmaWxlLmdldFN0cmluZyg0KTsKICAgICAgY29uc3QgY2hlY2tzdW0gPSBmaWxlLmdldEludDMyKCkgPj4+IDA7CiAgICAgIGNvbnN0IG9mZnNldCA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgY29uc3QgbGVuZ3RoID0gZmlsZS5nZXRJbnQzMigpID4+PiAwOwogICAgICBjb25zdCBwcmV2aW91c1Bvc2l0aW9uID0gZmlsZS5wb3M7CiAgICAgIGZpbGUucG9zID0gZmlsZS5zdGFydCB8fCAwOwogICAgIC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ICAgIGNvbnN0IG51bUZvbnRzID0gdHRjLmdldEludDMyKCkgPj4+IDA7CiAgICAgIGNvbnN0IG9mZnNldFRhYmxlID0gW107CiAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgbnVtRm9udHM7IGkrKykgewogICAgICAgIG9mZnNldFRhYmxlLnB1c2godHRjLmdldEludDMyKCkgPj4+IDApOwogICAgICB9CiAgICAgIGNvbnN0IGhlYWRlciA9IHsKICAgICAgICB0dGNUYWcsCiAgICAgICAgbWFqb3JWZXJzaW9uLAogICAgICAgIG1pbm9yVmVyc2lvbiwKICAgICAgICBudW1Gb250cywKICAgICAgICBvZmZzZXRUYWJsZQogICAgICB9OwogICAgICBzd2l0Y2ggKG1ham9yVmVyc2lvbikgewogICAgICAgIGNhc2UgMToKICAgICAgICAgIHJldHVybiBoZWFkZXI7CiAgICAgICAgY2FzZSAyOgogICAgICAgICAgaGVhZGVyLmRzaWdUYWcgPSB0dGMuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICAgIGhlYWRlci5kc2lnTGVuZ3RoID0gdHRjLmdldEludDMyKCkgPj4+IDA7CiAgICAgICAgICBoZWFkZXIuZHNpZ09mZnNldCA9IHR0Yy5nZXRJbnQzMigpID4+PiAwOwogICAgICAgICAgcmV0dXJuIGhlYWRlcjsKICAgICAgfQogICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYEludmFsaWQgVHJ1ZVR5cGUgQ29sbGVjdGlvbiBtYWpvclZlcnNpb246ICR7bWFqb3JWZXJzaW9ufS5gKTsKICAgIH0KICAgIGZ1bmN0aW9uIHJlYWRUcnVlVHlwZUNvbGxlY3Rpb25EYXRhKHR0YywgZm9udE5hbWUpIHsKICAgICAgY29uc3QgewogICAgICAgIG51bUZvbnRzLAogICAgICAgIG9mZnNldFRhYmxlCiAgICAgIH0gPSByZWFkVHJ1ZVR5cGVDb2xsZWN0aW9uSGVhZGVyKHR0Yyk7CiAgICAgIGNvbnN0IGZvbnROYW1lUGFydHMgPSBmb250TmFtZS5zcGxpdCgiKyIpOwogICAgICBsZXQgZmFsbGJhY2tEYXRhOwogICAgICBmb3IgKGxldCBpID0gMDsgaSA8IG51bUZvbnRzOyBpKyspIHsKICAgICAgICB0dGMucG9zID0gKHR0Yy5zdGFydCB8fCAwKSArIG9mZnNldFRhYmxlW2ldOwogICAgICAgIGNvbnN0IHBvdGVudGlhbEhlYWRlciA9IHJlYWRPcGVuVHlwZUhlYWRlcih0dGMpOwogICAgICAgIGNvbnN0IHBvdGVudGlhbFRhYmxlcyA9IHJlYWRUYWJsZXModHRjLCBwb3RlbnRpYWxIZWFkZXIubnVtVGFibGVzKTsKICAgICAgICBpZiAoIXBvdGVudGlhbFRhYmxlcy5uYW1lKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoJ1RydWVUeXBlIENvbGxlY3Rpb24gZm9udCBtdXN0IGNvbnRhaW4gYSAibmFtZSIgdGFibGUuJyk7CiAgICAgICAgfQogICAgICAgIGNvbnN0IFtuYW1lVGFibGVdID0gcmVhZE5hbWVUYWJsZShwb3RlbnRpYWxUYWJsZXMubmFtZSk7CiAgICAgICAgZm9yIChsZXQgaiA9IDAsIGpqID0gbmFtZVRhYmxlLmxlbmd0aDsgaiA8IGpqOyBqKyspIHsKICAgICAgICAgIGZvciAobGV0IGsgPSAwLCBrayA9IG5hbWVUYWJsZVtqXS5sZW5ndGg7IGsgPCBrazsgaysrKSB7CiAgICAgICAgICAgIGNvbnN0IG5hbWVFbnRyeSA9IG5hbWVUYWJsZVtqXVtrXSAmJiBuYW1lVGFibGVbal1ba10ucmVwbGFjZUFsbCgvXHMvZywgIiIpOwogICAgICAgICAgICBpZiAoIW5hbWVFbnRyeSkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChuYW1lRW50cnkgPT09IGZvbnROYW1lKSB7CiAgICAgICAgICAgICAgcmV0dXJuIHsKICAgICAgICAgICAgICAgIGhlYWRlcjogcG90ZW50aWFsSGVhZGVyLAogICAgICAgICAgICAgICAgdGFibGVzOiBwb3RlbnRpYWxUYWJsZXMKICAgICAgICAgICAgICB9OwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChmb250TmFtZVBhcnRzLmxlbmd0aCA8IDIpIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBmb3IgKGNvbnN0IHBhcnQgb2YgZm9udE5hbWVQYXJ0cykgewogICAgICAgICAgICAgIGlmIChuYW1lRW50cnkgPT09IHBhcnQpIHsKICAgICAgICAgICAgICAgIGZhbGxiYWNrRGF0YSA9IHsKICAgICAgICAgICAgICAgICAgbmFtZTogcGFydCwKICAgICAgICAgICAgICAgICAgaGVhZGVyOiBwb3RlbnRpYWxIZWFkZXIsCiAgICAgICAgICAgICAgICAgIHRhYmxlczogcG90ZW50aWFsVGFibGVzCiAgICAgICAgICAgICAgICB9OwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoZmFsbGJhY2tEYXRhKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKGBUcnVlVHlwZSBDb2xsZWN0aW9uIGRvZXMgbm90IGNvbnRhaW4gIiR7Zm9udE5hbWV9IiBmb250LCBgICsgYGZhbGxpbmcgYmFjayB0byAiJHtmYWxsYmFja0RhdGEubmFtZX0iIGZvbnQgaW5zdGVhZC5gKTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgaGVhZGVyOiBmYWxsYmFja0RhdGEuaGVhZGVyLAogICAgICAgICAgdGFibGVzOiBmYWxsYmFja0RhdGEudGFibGVzCiAgICAgICAgfTsKICAgICAgfQogICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYFRydWVUeXBlIENvbGxlY3Rpb24gZG9lcyBub3QgY29udGFpbiAiJHtmb250TmFtZX0iIGZvbnQuYCk7CiAgICB9CiAgICBmdW5jdGlvbiByZWFkQ21hcFRhYmxlKGNtYXAsIGZpbGUsIGlzU3ltYm9saWNGb250LCBoYXNFbmNvZGluZykgewogICAgICBpZiAoIWNtYXApIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoIk5vIGNtYXAgdGFibGUgYXZhaWxhYmxlLiIpOwogICAgICAgIHJldHVybiB7CiAgICAgICAgICBwbGF0Zm9ybUlkOiAtMSwKICAgICAgICAgIGVuY29kaW5nSWQ6IC0xLAogICAgICAgICAgbWFwcGluZ3M6IFtdLAogICAgICAgICAgaGFzU2hvcnRDbWFwOiBmYWxzZQogICAgICAgIH07CiAgICAgIH0KICAgICAgbGV0IHNlZ21lbnQ7CiAgICAgIGxldCBzdGFydCA9IChmaWxlLnN0YXJ0IHx8IDApICsgY21hcC5vZmZzZXQ7CiAgICAgIGZpbGUucG9zID0gc3RhcnQ7CiAgICAgIGZpbGUuc2tpcCgyKTsKICAgICAgY29uc3QgbnVtVGFibGVzID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgbGV0IHBvdGVudGlhbFRhYmxlOwogICAgICBsZXQgY2FuQnJlYWsgPSBmYWxzZTsKICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCBudW1UYWJsZXM7IGkrKykgewogICAgICAgIGNvbnN0IHBsYXRmb3JtSWQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIGNvbnN0IGVuY29kaW5nSWQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIGNvbnN0IG9mZnNldCA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICBsZXQgdXNlVGFibGUgPSBmYWxzZTsKICAgICAgICBpZiAocG90ZW50aWFsVGFibGUgJiYgcG90ZW50aWFsVGFibGUucGxhdGZvcm1JZCA9PT0gcGxhdGZvcm1JZCAmJiBwb3RlbnRpYWxUYWJsZS5lbmNvZGluZ0lkID09PSBlbmNvZGluZ0lkKSB7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaWYgKHBsYXRmb3JtSWQgPT09IDAgJiYgKGVuY29kaW5nSWQgPT09IDAgfHwgZW5jb2RpbmdJZCA9PT0gMSB8fCBlbmNvZGluZ0lkID09PSAzKSkgewogICAgICAgICAgdXNlVGFibGUgPSB0cnVlOwogICAgICAgIH0gZWxzZSBpZiAocGxhdGZvcm1JZCA9PT0gMSAmJiBlbmNvZGluZ0lkID09PSAwKSB7CiAgICAgICAgICB1c2VUYWJsZSA9IHRydWU7CiAgICAgICAgfSBlbHNlIGlmIChwbGF0Zm9ybUlkID09PSAzICYmIGVuY29kaW5nSWQgPT09IDEgJiYgKGhhc0VuY29kaW5nIHx8ICFwb3RlbnRpYWxUYWJsZSkpIHsKICAgICAgICAgIHVzZVRhYmxlID0gdHJ1ZTsKICAgICAgICAgIGlmICghaXNTeW1ib2xpY0ZvbnQpIHsKICAgICAgICAgICAgY2FuQnJlYWsgPSB0cnVlOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoaXNTeW1ib2xpY0ZvbnQgJiYgcGxhdGZvcm1JZCA9PT0gMyAmJiBlbmNvZGluZ0lkID09PSAwKSB7CiAgICAgICAgICB1c2VUYWJsZSA9IHRydWU7CiAgICAgICAgICBsZXQgY29ycmVjdGx5U29ydGVkID0gdHJ1ZTsKICAgICAgICAgIGlmIChpIDwgbnVtVGFibGVzIC0gMSkgewogICAgICAgICAgICBjb25zdCBuZXh0Qnl0ZXMgPSBmaWxlLnBlZWtCeXRlcygyKSwKICAgICAgICAgICAgICBuZXh0UGxhdGZvcm1JZCA9IGludDE2KG5leHRCeXRlc1swXSwgbmV4dEJ5dGVzWzFdKTsKICAgICAgICAgICAgaWYgKG5leHRQbGF0Zm9ybUlkIDwgcGxhdGZvcm1JZCkgewogICAgICAgICAgICAgIGNvcnJlY3RseVNvcnRlZCA9IGZhbHNlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoY29ycmVjdGx5U29ydGVkKSB7CiAgICAgICAgICAgIGNhbkJyZWFrID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHVzZVRhYmxlKSB7CiAgICAgICAgICBwb3RlbnRpYWxUYWJsZSA9IHsKICAgICAgICAgICAgcGxhdGZvcm1JZCwKICAgICAgICAgICAgZW5jb2RpbmdJZCwKICAgICAgICAgICAgb2Zmc2V0CiAgICAgICAgICB9OwogICAgICAgIH0KICAgICAgICBpZiAoY2FuQnJlYWspIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAocG90ZW50aWFsVGFibGUpIHsKICAgICAgICBmaWxlLnBvcyA9IHN0YXJ0ICsgcG90ZW50aWFsVGFibGUub2Zmc2V0OwogICAgICB9CiAgICAgIGlmICghcG90ZW50aWFsVGFibGUgfHwgZmlsZS5wZWVrQnl0ZSgpID09PSAtMSkgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiQ291bGQgbm90IGZpbmQgYSBwcmVmZXJyZWQgY21hcCB0YWJsZS4iKTsKICAgICAgICByZXR1cm4gewogICAgICAgICAgcGxhdGZvcm1JZDogLTEsCiAgICAgICAgICBlbmNvZGluZ0lkOiAtMSwKICAgICAgICAgIG1hcHBpbmdzOiBbXSwKICAgICAgICAgIGhhc1Nob3J0Q21hcDogZmFsc2UKICAgICAgICB9OwogICAgICB9CiAgICAgIGNvbnN0IGZvcm1hdCA9IGZpbGUuZ2V0VWludDE2KCk7CiAgICAgIGxldCBoYXNTaG9ydENtYXAgPSBmYWxzZTsKICAgICAgY29uc3QgbWFwcGluZ3MgPSBbXTsKICAgICAgbGV0IGosIGdseXBoSWQ7CiAgICAgIGlmIChmb3JtYXQgPT09IDApIHsKICAgICAgICBmaWxlLnNraXAoMiArIDIpOwogICAgICAgIGZvciAoaiA9IDA7IGogPCAyNTY7IGorKykgewogICAgICAgICAgY29uc3QgaW5kZXggPSBmaWxlLmdldEJ5dGUoKTsKICAgICAgICAgIGlmICghaW5kZXgpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBtYXBwaW5ncy5wdXNoKHsKICAgICAgICAgICAgY2hhckNvZGU6IGosCiAgICAgICAgICAgIGdseXBoSWQ6IGluZGV4CiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgaGFzU2hvcnRDbWFwID0gdHJ1ZTsKICAgICAgfSBlbHNlIGlmIChmb3JtYXQgPT09IDIpIHsKICAgICAgICBmaWxlLnNraXAoMiArIDIpOwogICAgICAgIGNvbnN0IHN1YkhlYWRlcktleXMgPSBbXTsKICAgICAgICBsZXQgbWF4U3ViSGVhZGVyS2V5ID0gMDsKICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IDI1NjsgaSsrKSB7CiAgICAgICAgICBjb25zdCBzdWJIZWFkZXJLZXkgPSBmaWxlLmdldFVpbnQxNigpID4+IDM7CiAgICAgICAgICBzdWJIZWFkZXJLZXlzLnB1c2goc3ViSGVhZGVyS2V5KTsKICAgICAgICAgIG1heFN1YkhlYWRlcktleSA9IE1hdGgubWF4KHN1YkhlYWRlcktleSwgbWF4U3ViSGVhZGVyS2V5KTsKICAgICAgICB9CiAgICAgICAgY29uc3Qgc3ViSGVhZGVycyA9IFtdOwogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDw9IG1heFN1YkhlYWRlcktleTsgaSsrKSB7CiAgICAgICAgICBzdWJIZWFkZXJzLnB1c2goewogICAgICAgICAgICBmaXJzdENvZGU6IGZpbGUuZ2V0VWludDE2KCksCiAgICAgICAgICAgIGVudHJ5Q291bnQ6IGZpbGUuZ2V0VWludDE2KCksCiAgICAgICAgICAgIGlkRGVsdGE6IHNpZ25lZEludDE2KGZpbGUuZ2V0Qnl0ZSgpLCBmaWxlLmdldEJ5dGUoKSksCiAgICAgICAgICAgIGlkUmFuZ2VQb3M6IGZpbGUucG9zICsgZmlsZS5nZXRVaW50MTYoKQogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgMjU2OyBpKyspIHsKICAgICAgICAgIGlmIChzdWJIZWFkZXJLZXlzW2ldID09PSAwKSB7CiAgICAgICAgICAgIGZpbGUucG9zID0gc3ViSGVhZGVyc1swXS5pZFJhbmdlUG9zICsgMiAqIGk7CiAgICAgICAgICAgIGdseXBoSWQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgICAgICBtYXBwaW5ncy5wdXNoKHsKICAgICAgICAgICAgICBjaGFyQ29kZTogaSwKICAgICAgICAgICAgICBnbHlwaElkCiAgICAgICAgICAgIH0pOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY29uc3QgcyA9IHN1YkhlYWRlcnNbc3ViSGVhZGVyS2V5c1tpXV07CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBzLmVudHJ5Q291bnQ7IGorKykgewogICAgICAgICAgICAgIGNvbnN0IGNoYXJDb2RlID0gKGkgPDwgOCkgKyBqICsgcy5maXJzdENvZGU7CiAgICAgICAgICAgICAgZmlsZS5wb3MgPSBzLmlkUmFuZ2VQb3MgKyAyICogajsKICAgICAgICAgICAgICBnbHlwaElkID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgICAgICAgICBpZiAoZ2x5cGhJZCAhPT0gMCkgewogICAgICAgICAgICAgICAgZ2x5cGhJZCA9IChnbHlwaElkICsgcy5pZERlbHRhKSAlIDY1NTM2OwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBtYXBwaW5ncy5wdXNoKHsKICAgICAgICAgICAgICAgIGNoYXJDb2RlLAogICAgICAgICAgICAgICAgZ2x5cGhJZAogICAgICAgICAgICAgIH0pOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYgKGZvcm1hdCA9PT0gNCkgewogICAgICAgIGZpbGUuc2tpcCgyICsgMik7CiAgICAgICAgY29uc3Qgc2VnQ291bnQgPSBmaWxlLmdldFVpbnQxNigpID4+IDE7CiAgICAgICAgZmlsZS5za2lwKDYpOwogICAgICAgIGNvbnN0IHNlZ21lbnRzID0gW107CiAgICAgICAgbGV0IHNlZ0luZGV4OwogICAgICAgIGZvciAoc2VnSW5kZXggPSAwOyBzZWdJbmRleCA8IHNlZ0NvdW50OyBzZWdJbmRleCsrKSB7CiAgICAgICAgICBzZWdtZW50cy5wdXNoKHsKICAgICAgICAgICAgZW5kOiBmaWxlLmdldFVpbnQxNigpCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgZmlsZS5za2lwKDIpOwogICAgICAgIGZvciAoc2VnSW5kZXggPSAwOyBzZWdJbmRleCA8IHNlZ0NvdW50OyBzZWdJbmRleCsrKSB7CiAgICAgICAgICBzZWdtZW50c1tzZWdJbmRleF0uc3RhcnQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIH0KICAgICAgICBmb3IgKHNlZ0luZGV4ID0gMDsgc2VnSW5kZXggPCBzZWdDb3VudDsgc2VnSW5kZXgrKykgewogICAgICAgICAgc2VnbWVudHNbc2VnSW5kZXhdLmRlbHRhID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgICB9CiAgICAgICAgbGV0IG9mZnNldHNDb3VudCA9IDAsCiAgICAgICAgICBvZmZzZXRJbmRleDsKICAgICAgICBmb3IgKHNlZ0luZGV4ID0gMDsgc2VnSW5kZXggPCBzZWdDb3VudDsgc2VnSW5kZXgrKykgewogICAgICAgICAgc2VnbWVudCA9IHNlZ21lbnRzW3NlZ0luZGV4XTsKICAgICAgICAgIGNvbnN0IHJhbmdlT2Zmc2V0ID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgICAgIGlmICghcmFuZ2VPZmZzZXQpIHsKICAgICAgICAgICAgc2VnbWVudC5vZmZzZXRJbmRleCA9IC0xOwogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIG9mZnNldEluZGV4ID0gKHJhbmdlT2Zmc2V0ID4+IDEpIC0gKHNlZ0NvdW50IC0gc2VnSW5kZXgpOwogICAgICAgICAgc2VnbWVudC5vZmZzZXRJbmRleCA9IG9mZnNldEluZGV4OwogICAgICAgICAgb2Zmc2V0c0NvdW50ID0gTWF0aC5tYXgob2Zmc2V0c0NvdW50LCBvZmZzZXRJbmRleCArIHNlZ21lbnQuZW5kIC0gc2VnbWVudC5zdGFydCArIDEpOwogICAgICAgIH0KICAgICAgICBjb25zdCBvZmZzZXRzID0gW107CiAgICAgICAgZm9yIChqID0gMDsgaiA8IG9mZnNldHNDb3VudDsgaisrKSB7CiAgICAgICAgICBvZmZzZXRzLnB1c2goZmlsZS5nZXRVaW50MTYoKSk7CiAgICAgICAgfQogICAgICAgIGZvciAoc2VnSW5kZXggPSAwOyBzZWdJbmRleCA8IHNlZ0NvdW50OyBzZWdJbmRleCsrKSB7CiAgICAgICAgICBzZWdtZW50ID0gc2VnbWVudHNbc2VnSW5kZXhdOwogICAgICAgICAgc3RhcnQgPSBzZWdtZW50LnN0YXJ0OwogICAgICAgICAgY29uc3QgZW5kID0gc2VnbWVudC5lbmQ7CiAgICAgICAgICBjb25zdCBkZWx0YSA9IHNlZ21lbnQuZGVsdGE7CiAgICAgICAgICBvZmZzZXRJbmRleCA9IHNlZ21lbnQub2Zmc2V0SW5kZXg7CiAgICAgICAgICBmb3IgKGogPSBzdGFydDsgaiA8PSBlbmQ7IGorKykgewogICAgICAgICAgICBpZiAoaiA9PT0gMHhmZmZmKSB7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZ2x5cGhJZCA9IG9mZnNldEluZGV4IDwgMCA/IGogOiBvZmZzZXRzW29mZnNldEluZGV4ICsgaiAtIHN0YXJ0XTsKICAgICAgICAgICAgZ2x5cGhJZCA9IGdseXBoSWQgKyBkZWx0YSAmIDB4ZmZmZjsKICAgICAgICAgICAgbWFwcGluZ3MucHVzaCh7CiAgICAgICAgICAgICAgY2hhckNvZGU6IGosCiAgICAgICAgICAgICAgZ2x5cGhJZAogICAgICAgICAgICB9KTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoZm9ybWF0ID09PSA2KSB7CiAgICAgICAgZmlsZS5za2lwKDIgKyAyKTsKICAgICAgICBjb25zdCBmaXJzdENvZGUgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIGNvbnN0IGVudHJ5Q291bnQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgIGZvciAoaiA9IDA7IGogPCBlbnRyeUNvdW50OyBqKyspIHsKICAgICAgICAgIGdseXBoSWQgPSBmaWxlLmdldFVpbnQxNigpOwogICAgICAgICAgY29uc3QgY2hhckNvZGUgPSBmaXJzdENvZGUgKyBqOwogICAgICAgICAgbWFwcGluZ3MucHVzaCh7CiAgICAgICAgICAgIGNoYXJDb2RlLAogICAgICAgICAgICBnbHlwaElkCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoZm9ybWF0ID09PSAxMikgewogICAgICAgIGZpbGUuc2tpcCgyICsgNCArIDQpOwogICAgICAgIGNvbnN0IG5Hcm91cHMgPSBmaWxlLmdldEludDMyKCkgPj4+IDA7CiAgICAgICAgZm9yIChqID0gMDsgaiA8IG5Hcm91cHM7IGorKykgewogICAgICAgICAgY29uc3Qgc3RhcnRDaGFyQ29kZSA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICAgIGNvbnN0IGVuZENoYXJDb2RlID0gZmlsZS5nZXRJbnQzMigpID4+PiAwOwogICAgICAgICAgbGV0IGdseXBoQ29kZSA9IGZpbGUuZ2V0SW50MzIoKSA+Pj4gMDsKICAgICAgICAgIGZvciAobGV0IGNoYXJDb2RlID0gc3RhcnRDaGFyQ29kZTsgY2hhckNvZGUgPD0gZW5kQ2hhckNvZGU7IGNoYXJDb2RlKyspIHsKICAgICAgICAgICAgbWFwcGluZ3MucHVzaCh7CiAgICAgICAgICAgICAgY2hhckNvZGUsCiAgICAgICAgICAgIC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IChtZXRyaWNzKSB7CiAgICAgICAgICBtZXRyaWNzLmRhdGEgPSBudWxsOwogICAgICAgIH0KICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgZmlsZS5wb3MgPSAoZmlsZS5zdGFydCB8fCAwKSArIGhlYWRlci5vZmZzZXQ7CiAgICAgIGZpbGUucG9zICs9IDQ7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGZpbGUucG9zICs9IDI7CiAgICAgIGNvbnN0IGNhcmV0T2Zmc2V0ID0gZmlsZS5nZXRVaW50MTYoKTsKICAgICAgZmlsZS5wb3MgKz0gODsKICAgICAgZmlsZS5wb3MgKz0gMjsKICAgICAgbGV0IG51bU9mTWV0cmljcyA9IGZpbGUuZ2V0VWludDE2KCk7CiAgICAgIGlmIChjYXJldE9mZnNldCAhPT0gMCkgewogICAgICAgIGNvbnN0IG1hY1N0eWxlID0gaW50MTYoaGVhZFRhYmxlLmRhdGFbNDRdLCBoZWFkVGFibGUuZGF0YVs0NV0pOwogICAgICAgIGlmICghKG1hY1N0eWxlICYgMikpIHsKICAgICAgICAgIGhlYWRlci5kYXRhWzIyXSA9IDA7CiAgICAgICAgICBoZWFkZXIuZGF0YVsyM10gPSAwOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAobnVtT2ZNZXRyaWNzID4gbnVtR2x5cGhzKSB7CiAgICAgICAgKDAsIF91dGlsLmluZm8pKGBUaGUgbnVtT2ZNZXRyaWNzICgke251bU9mTWV0cmljc30pIHNob3VsZCBub3QgYmUgYCArIGBncmVhdGVyIHRoYW4gdGhlIG51bUdseXBocyAoJHtudW1HbHlwaHN9KS5gKTsKICAgICAgICBudW1PZk1ldHJpY3MgPSBudW1HbHlwaHM7CiAgICAgICAgaGVhZGVyLmRhdGFbMzRdID0gKG51bU9mTWV0cmljcyAmIDB4ZmYwMCkgPj4gODsKICAgICAgICBoZWFkZXIuZGF0YVszNV0gPSBudW1PZk1ldHJpY3MgJiAweDAwZmY7CiAgICAgIH0KICAgICAgY29uc3QgbnVtT2ZTaWRlYmVhcmluZ3MgPSBudW1HbHlwaHMgLSBudW1PZk1ldHJpY3M7CiAgICAgIGNvbnN0IG51bU1pc3NpbmcgPSBudW1PZlNpZGViZWFyaW5ncyAtIChtZXRyaWNzLmxlbmd0aCAtIG51bU9mTWV0cmljcyAqIDQgPj4gMSk7CiAgICAgIGlmIChudW1NaXNzaW5nID4gMCkgewogICAgICAgIGNvbnN0IGVudHJpZXMgPSBuZXcgVWludDhBcnJheShtZXRyaWNzLmxlbmd0aCArIG51bU1pc3NpbmcgKiAyKTsKICAgICAgICBlbnRyaWVzLnNldChtZXRyaWNzLmRhdGEpOwogICAgICAgIGlmIChkdXBGaXJzdEVudHJ5KSB7CiAgICAgICAgICBlbnRyaWVzW21ldHJpY3MubGVuZ3RoXSA9IG1ldHJpY3MuZGF0YVsyXTsKICAgICAgICAgIGVudHJpZXNbbWV0cmljcy5sZW5ndGggKyAxXSA9IG1ldHJpY3MuZGF0YVszXTsKICAgICAgICB9CiAgICAgICAgbWV0cmljcy5kYXRhID0gZW50cmllczsKICAgICAgfQogICAgfQogICAgZnVuY3Rpb24gc2FuaXRpemVHbHlwaChzb3VyY2UsIHNvdXJjZVN0YXJ0LCBzb3VyY2VFbmQsIGRlc3QsIGRlc3RTdGFydCwgaGludHNWYWxpZCkgewogICAgICBjb25zdCBnbHlwaFByb2ZpbGUgPSB7CiAgICAgICAgbGVuZ3RoOiAwLAogICAgICAgIHNpemVPZkluc3RydWN0aW9uczogMAogICAgICB9OwogICAgICBpZiAoc291cmNlRW5kIC0gc291cmNlU3RhcnQgPD0gMTIpIHsKICAgICAgICByZXR1c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gIGZvciAoaSA9IDA7IGkgPCBmbGFnc0NvdW50OyBpKyspIHsKICAgICAgICBjb25zdCBmbGFnID0gZ2x5ZltqKytdOwogICAgICAgIGlmIChmbGFnICYgMHhjMCkgewogICAgICAgICAgZ2x5ZltqIC0gMV0gPSBmbGFnICYgMHgzZjsKICAgICAgICB9CiAgICAgICAgbGV0IHhMZW5ndGggPSAyOwogICAgICAgIGlmIChmbGFnICYgMikgewogICAgICAgICAgeExlbmd0aCA9IDE7CiAgICAgICAgfSBlbHNlIGlmIChmbGFnICYgMTYpIHsKICAgICAgICAgIHhMZW5ndGggPSAwOwogICAgICAgIH0KICAgICAgICBsZXQgeUxlbmd0aCA9IDI7CiAgICAgICAgaWYgKGZsYWcgJiA0KSB7CiAgICAgICAgICB5TGVuZ3RoID0gMTsKICAgICAgICB9IGVsc2UgaWYgKGZsYWcgJiAzMikgewogICAgICAgICAgeUxlbmd0aCA9IDA7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHh5TGVuZ3RoID0geExlbmd0aCArIHlMZW5ndGg7CiAgICAgICAgY29vcmRpbmF0ZXNMZW5ndGggKz0geHlMZW5ndGg7CiAgICAgICAgaWYgKGZsYWcgJiA4KSB7CiAgICAgICAgICBjb25zdCByZXBlYXQgPSBnbHlmW2orK107CiAgICAgICAgICBpICs9IHJlcGVhdDsKICAgICAgICAgIGNvb3JkaW5hdGVzTGVuZ3RoICs9IHJlcGVhdCAqIHh5TGVuZ3RoOwogICAgICAgIH0KICAgICAgfQogICAgICBpZiAoY29vcmRpbmF0ZXNMZW5ndGggPT09IDApIHsKICAgICAgICByZXR1cm4gZ2x5cGhQcm9maWxlOwogICAgICB9CiAgICAgIGxldCBnbHlwaERhdGFMZW5ndGggPSBqICsgY29vcmRpbmF0ZXNMZW5ndGg7CiAgICAgIGlmIChnbHlwaERhdGFMZW5ndGggPiBnbHlmLmxlbmd0aCkgewogICAgICAgIHJldHVybiBnbHlwaFByb2ZpbGU7CiAgICAgIH0KICAgICAgaWY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25zdCBsb2NhRW50cmllcyA9IFtdOwogICAgICBmb3IgKGkgPSAwLCBqID0gMDsgaSA8IG51bUdseXBocyArIDE7IGkrKywgaiArPSBpdGVtU2l6ZSkgewogICAgICAgIGxldCBvZmZzZXQgPSBpdGVtRGVjb2RlKGxvY2FEYXRhLCBqKTsKICAgICAgICBpZiAob2Zmc2V0ID4gb2xkR2x5ZkRhdGFMZW5ndGgpIHsKICAgICAgICAgIG9mZnNldCA9IG9sZEdseWZEYXRhTGVuZ3RoOwogICAgICAgIH0KICAgICAgICBsb2NhRW50cmllcy5wdXNoKHsKICAgICAgICAgIGluZGV4OiBpLAogICAgICAgICAgb2Zmc2V0LAogICAgICAgICAgZW5kT2Zmc2V0OiAwCiAgICAgICAgfSk7CiAgICAgIH0KICAgICAgbG9jYUVudHJpZXMuc29ydCgoYSwgYikgPT4gewogICAgICAgIHJldHVybiBhLm9mZnNldCAtIGIub2Zmc2V0OwogICAgICB9KTsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bUdseXBoczsgaSsrKSB7CiAgICAgICAgbG9jYUVudHJpZXNbaV0uZW5kT2Zmc2V0ID0gbG9jYUVudHJpZXNbaSArIDFdLm9mZnNldDsKICAgICAgfQogICAgICBsb2NhRW50cmllcy5zb3J0KChhLCBiKSA9PiB7CiAgICAgICAgcmV0dXJuIGEuaW5kZXggLSBiLmluZGV4OwogICAgICB9KTsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bUdseXBoczsgaSsrKSB7CiAgICAgICAgY29uc3QgewogICAgICAgICAgb2Zmc2V0LAogICAgICAgICAgZW5kT2Zmc2V0CiAgICAgICAgfSA9IGxvY2FFbnRyaWVzW2ldOwogICAgICAgIGlmIChvZmZzZXQgIT09IDAgfHwgZW5kT2Zmc2V0ICE9PSAwKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgY29uc3QgbmV4dE9mZnNldCA9IGxvY2FFbnRyaWVzW2kgKyAxXS5vZmZzZXQ7CiAgICAgICA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ndGggLSBpdGVtU2l6ZSwgd3JpdGVPZmZzZXQgKyBmaXJzdEVudHJ5TGVuZ3RoKTsKICAgICAgfSBlbHNlIHsKICAgICAgICBnbHlmLmRhdGEgPSBuZXdHbHlmRGF0YS5zdWJhcnJheSgwLCB3cml0ZU9mZnNldCk7CiAgICAgIH0KICAgICAgcmV0dXJuIHsKICAgICAgICBtaXNzaW5nR2x5cGhzLAogICAgICAgIG1heFNpemVPZkluc3RydWN0aW9ucwogICAgICB9OwogICAgfQogICAgZnVuY3Rpb24gcmVhZFBvc3RTY3JpcHRUYWJsZShwb3N0LCBwcm9wZXJ0aWVzT2JqLCBtYXhwTnVtR2x5cGhzKSB7CiAgICAgIGNvbnN0IHN0YXJ0ID0gKGZvbnQuc3RhcnQgfHwgMCkgKyBwb3N0Lm9mZnNldDsKICAgICAgZm9udC5wb3MgPSBzdGFydDsKICAgICAgY29uc3QgbGVuZ3RoID0gcG9zdC5sZW5ndGgsCiAgICAgICAgZW5kID0gc3RhcnQgKyBsZW5ndGg7CiAgICAgIGNvbnN0IHZlcnNpb24gPSBmb250LmdldEludDMyKCk7CiAgICAgIGZvbnQuc2tpcCgyOCk7CiAgICAgIGxldCBnbHlwaE5hbWVzOwogICAgICBsZXQgdmFsaWQgPSB0cnVlOwogICAgICBsZXQgaTsKICAgICAgc3dpdGNoICh2ZXJzaW9uKSB7CiAgICAgICAgY2FzZSAweDAwMDEwMDAwOgogICAgICAgICAgZ2x5cGhOYW1lcyA9IF9mb250c191dGlscy5NYWNTdGFuZGFyZEdseXBoT3JkZXJpbmc7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4MDAwMjAwMDA6CiAgICAgICAgICBjb25zdCBudW1HbHlwaHMgPSBmb250LmdldFVpbnQxNigpOwogICAgICAgICAgaWYgKG51bUdseXBocyAhPT0gbWF4cE51bUdseXBocykgewogICAgICAgICAgICB2YWxpZCA9IGZhbHNlOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IGdseXBoTmFtZUluZGV4ZXMgPSBbXTsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPCBudW1HbHlwaHM7ICsraSkgewogICAgICAgICAgICBjb25zdCBpbmRleCA9IGZvbnQuZ2V0VWludDE2KCk7CiAgICAgICAgICAgIGlmIChpbmRleCA+PSAzMjc2OCkgewogICAgICAgICAgICAgIHZhbGlkID0gZmFsc2U7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZ2x5cGhOYW1lSW5kZXhlcy5wdXNoKGluZGV4KTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICghdmFsaWQpIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCBjdXN0b21OYW1lcyA9IFtdLAogICAgICAgICAgICBzdHJCdWYgPSBbXTsKICAgICAgICAgIHdoaWxlIChmb250LnBvcyA8IGVuZCkgewogICAgICAgICAgICBjb25zdCBzdHJpbmdMZW5ndGggPSBmb250LmdldEJ5dGUoKTsKICAgICAgICAgICAgc3RyQnVmLmxlbmd0aCA9IHN0cmluZ0xlbmd0aDsKICAgICAgICAgICAgZm9yIChpID0gMDsgaSA8IHN0cmluZ0xlbmd0aDsgKytpKSB7CiAgICAgICAgICAgICAgc3RyQnVmW2ldID0gU3RyaW5nLmZyb21DaGFyQ29kZShmb250LmdldEJ5dGUoKSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY3VzdG9tTmFtZXMucHVzaChzdHJCdWYuam9pbigiIikpOwogICAgICAgICAgfQogICAgICAgICAgZ2x5cGhOYW1lcyA9IFtdOwogICAgICAgICAgZm9yIChpID0gMDsgaSA8IG51bUdseXBoczsgKytpKSB7CiAgICAgICAgICAgIGNvbnN0IGogPSBnbHlwaE5hbWVJbmRleGVzW2ldOwogICAgICAgICAgICBpZiAoaiA8IDI1OCkgewogICAgICAgICAgICAgIGdseXBoTmFtZXMucHVzaChfZm9udHNfdXRpbHMuTWFjU3RhbmRhcmRHbHlwaE9yZGVyaW5nW2pdKTsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBnbHlwaE5hbWVzLnB1c2goY3VzdG9tTmFtZXNbaiAtIDI1OF0pOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDAwMDMwMDAwOgogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVW5rbm93bi91bnN1cHBvcnRlZCBwb3N0IHRhYmxlIHZlcnNpb24gIiArIHZlcnNpb24pOwogICAgICAgICAgdmFsaWQgPSBmYWxzZTsKICAgICAgICAgIGlmIChwcm9wZXJ0aWVzT2JqLmRlZmF1bHRFbmNvZGluZykgewogICAgICAgICAgICBnbHlwaE5hbWVzID0gcHJvcGVydGllc09iai5kZWZhdWx0RW5jb2Rpbmc7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgICBwcm9wZXJ0aWVzT2JqLmdseXBoTmFtZXMgPSBnbHlwaE5hbWVzOwogICAgICByZXR1cm4gdmFsaWQ7CiAgICB9CiAgICBmdW5jdGlvbiByZWFkTmFtZVRhYmxlKG5hbWVUYWJsZSkgewogICAgICBjb25zdCBzdGFydCA9IChmb250LnN0YXJ0IHx8IDApICsgbmFtZVRhYmxlLm9mZnNldDsKICAgICAgZm9udC5wb3MgPSBzdGFydDsKICAgICAgY29uc3QgbmFtZXMgPSBbW10sIFtdXSwKICAgICAgICByZWNvcmRzID0gW107CiAgICAgIGNvbnN0IGxlbmd0aCA9IG5hbWVUYWJsZS5sZW5ndGgsCiAgICAgICAgZW5kID0gc3RhcnQgKyBsZW5ndGg7CiAgICAgIGNvbnN0IGZvcm1hdCA9IGZvbnQuZ2V0VWludDE2KCk7CiAgICAgIGNvbnN0IEZPUk1BVF8wX0hFQURFUl9MRU5HVEggPSA2OwogICAgICBpZiAoZm9ybWF0ICE9PSAwIHx8IGxlbmd0aCA8IEZPUk1BVF8wX0hFQURFUl9MRU5HVEgpIHsKICAgICAgICByZXR1cm4gW25hbWVzLCByZWNvcmRzXTsKICAgICAgfQogICAgICBjb25zdCBudW1SZWNvcmRzID0gZm9udC5nZXRVaW50MTYoKTsKICAgICAgY29uc3Qgc3RyaW5nc1N0YXJ0ID0gZm9udC5nZXRVaW50MTYoKTsKICAgICAgY29uc3QgTkFNRV9SRUNPUkRfTEVOR1RIID0gMTI7CiAgICAgIGxldCBpLCBpaTsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bVJlY29yZHMgJiYgZm9udC5wb3MgKyBOQU1FX1JFQ09SRF9MRU5HVEggPD0gZW5kOyBpKyspIHsKICAgICAgICBjb25zdCByID0gewogICAgICAgICAgcGxhdGZvcm06IGZvbnQuZ2V0VWludDE2KCksCiAgICAgICAgICBlbmNvZGluZzogZm9udC5nZXRVaW50MTYoKSwKICAgICAgICAgIGxhbmd1YWdlOiBmb250LmdldFVpbnQxNigpLAogICAgICAgICAgbmFtZTogZm9udC5nZXRVaW50MTYoKSwKICAgICAgICAgIGxlbmd0aDogZm9udC5nZXRVaW50MTYoKSwKICAgICAgICAgIG9mZnNldDogZm9udC5nZXRVaW50MTYoKQogICAgICAgIH07CiAgICAgICAgaWYgKGlzTWFjTmFtZVJlY29yZChyKSB8fCBpc1dpbk5hbWVSZWNvcmQocikpIHsKICAgICAgICAgIHJlY29yZHMucHVzaChyKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgZm9yIChpID0gMCwgaWkgPSByZWNvcmRzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb25zdCByZWNvcmQgPSByZWNvcmRzW2ldOwogICAgICAgIGlmIChyZWNvcmQubGVuZ3RoIDw9IDApIHsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBjb25zdCBwb3MgPSBzdGFydCArIHN0cmluZ3NTdGFydCArIHJlY29yZC5v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CiAgICAgICAgICAgIGkgKz0gbjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBuOyBqKyspIHsKICAgICAgICAgICAgICBzdGFjay5wdXNoKGRhdGFbaSsrXSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgaWYgKG9wID09PSAweDQxKSB7CiAgICAgICAgICBuID0gZGF0YVtpKytdOwogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgaSArPSBuICogMjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBuOyBqKyspIHsKICAgICAgICAgICAgICBiID0gZGF0YVtpKytdOwogICAgICAgICAgICAgIHN0YWNrLnB1c2goYiA8PCA4IHwgZGF0YVtpKytdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoKG9wICYgMHhmOCkgPT09IDB4YjApIHsKICAgICAgICAgIG4gPSBvcCAtIDB4YjAgKyAxOwogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgaSArPSBuOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IG47IGorKykgewogICAgICAgICAgICAgIHN0YWNrLnB1c2goZGF0YVtpKytdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoKG9wICYgMHhmOCkgPT09IDB4YjgpIHsKICAgICAgICAgIG4gPSBvcCAtIDB4YjggKyAxOwogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgaSArPSBuICogMjsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBuOyBqKyspIHsKICAgICAgICAgICAgICBiID0gZGF0YVtpKytdOwogICAgICAgICAgICAgIHN0YWNrLnB1c2goYiA8PCA4IHwgZGF0YVtpKytdKTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MmIgJiYgIXRvb0NvbXBsZXhUb0ZvbGxvd0Z1bmN0aW9ucykgewogICAgICAgICAgaWYgKCFpbkZERUYgJiYgIWluRUxTRSkgewogICAgICAgICAgICBmdW5jSWQgPSBzdGFjay5hdCgtMSk7CiAgICAgICAgICAgIGlmIChpc05hTihmdW5jSWQpKSB7CiAgICAgICAgICAgICAgKDAsIF91dGlsLmluZm8pKCJUVDogQ0FMTCBlbXB0eSBzdGFjayAob3IgaW52YWxpZCBlbnRyeSkuIik7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdHRDb250ZXh0LmZ1bmN0aW9uc1VzZWRbZnVuY0lkXSA9IHRydWU7CiAgICAgICAgICAgICAgaWYgKGZ1bmNJZCBpbiB0dENvbnRleHQuZnVuY3Rpb25zU3RhY2tEZWx0YXMpIHsKICAgICAgICAgICAgICAgIGNvbnN0IG5ld1N0YWNrTGVuZ3RoID0gc3RhY2subGVuZ3RoICsgdHRDb250ZXh0LmZ1bmN0aW9uc1N0YWNrRGVsdGFzW2Z1bmNJZF07CiAgICAgICAgICAgICAgICBpZiAobmV3U3RhY2tMZW5ndGggPCAwKSB7CiAgICAgICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiVFQ6IENBTEwgaW52YWxpZCBmdW5jdGlvbnMgc3RhY2sgZGVsdGEuIik7CiAgICAgICAgICAgICAgICAgIHR0Q29udGV4dC5oaW50c1ZhbGlkID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0YWNrLmxlbmd0aCA9IG5ld1N0YWNrTGVuZ3RoOwogICAgICAgICAgICAgIH0gZWxzZSBpZiAoZnVuY0lkIGluIHR0Q29udGV4dC5mdW5jdGlvbnNEZWZpbmVkICYmICFmdW5jdGlvbnNDYWxsZWQuaW5jbHVkZXMoZnVuY0lkKSkgewogICAgICAgICAgICAgICAgY2FsbHN0YWNrLnB1c2goewogICAgICAgICAgICAgICAgICBkYXRhLAogICAgICAgICAgICAgICAgICBpLAogICAgICAgICAgICAgICAgICBzdGFja1RvcDogc3RhY2subGVuZ3RoIC0gMQogICAgICAgICAgICAgICAgfSk7CiAgICAgICAgICAgICAgICBmdW5jdGlvbnNDYWxsZWQucHVzaChmdW5jSWQpOwogICAgICAgICAgICAgICAgcGMgPSB0dENvbnRleHQuZnVuY3Rpb25zRGVmaW5lZFtmdW5jSWRdOwogICAgICAgICAgICAgICAgaWYgKCFwYykgewogICAgICAgICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlRUOiBDQUxMIG5vbi1leGlzdGVudCBmdW5jdGlvbiIpOwogICAgICAgICAgICAgICAgICB0dENvbnRleHQuaGludHNWYWxpZCA9IGZhbHNlOwogICAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBkYXRhID0gcGMuZGF0YTsKICAgICAgICAgICAgICAgIGkgPSBwYy5pOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MmMgJiYgIXRvb0NvbXBsZXhUb0ZvbGxvd0Z1bmN0aW9ucykgewogICAgICAgICAgaWYgKGluRkRFRiB8fCBpbkVMU0UpIHsKICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogbmVzdGVkIEZERUZzIG5vdCBhbGxvd2VkIik7CiAgICAgICAgICAgIHRvb0NvbXBsZXhUb0ZvbGxvd0Z1bmN0aW9ucyA9IHRydWU7CiAgICAgICAgICB9CiAgICAgICAgICBpbkZERUYgPSB0cnVlOwogICAgICAgICAgbGFzdERlZmYgPSBpOwogICAgICAgICAgZnVuY0lkID0gc3RhY2sucG9wKCk7CiAgICAgICAgICB0dENvbnRleHQuZnVuY3Rpb25zRGVmaW5lZFtmdW5jSWRdID0gewogICAgICAgICAgICBkYXRhLAogICAgICAgICAgICBpCiAgICAgICAgICB9OwogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MmQpIHsKICAgICAgICAgIGlmIChpbkZERUYpIHsKICAgICAgICAgICAgaW5GREVGID0gZmFsc2U7CiAgICAgICAgICAgIGxhc3RFbmRmID0gaTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHBjID0gY2FsbHN0YWNrLnBvcCgpOwogICAgICAgICAgICBpZiAoIXBjKSB7CiAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogRU5ERiBiYWQgc3RhY2siKTsKICAgICAgICAgICAgICB0dENvbnRleHQuaGludHNWYWxpZCA9IGZhbHNlOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBmdW5jSWQgPSBmdW5jdGlvbnNDYWxsZWQucG9wKCk7CiAgICAgICAgICAgIGRhdGEgPSBwYy5kYXRhOwogICAgICAgICAgICBpID0gcGMuaTsKICAgICAgICAgICAgdHRDb250ZXh0LmZ1bmN0aW9uc1N0YWNrRGVsdGFzW2Z1bmNJZF0gPSBzdGFjay5sZW5ndGggLSBwYy5zdGFja1RvcDsKICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgaWYgKG9wID09PSAweDg5KSB7CiAgICAgICAgICBpZiAoaW5GREVGIHx8IGluRUxTRSkgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoIlRUOiBuZXN0ZWQgSURFRnMgbm90IGFsbG93ZWQiKTsKICAgICAgICAgICAgdG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zID0gdHJ1ZTsKICAgICAgICAgIH0KICAgICAgICAgIGluRkRFRiA9IHRydWU7CiAgICAgICAgICBsYXN0RGVmZiA9IGk7CiAgICAgICAgfSBlbHNlIGlmIChvcCA9PT0gMHg1OCkgewogICAgICAgICAgKytpZkxldmVsOwogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MWIpIHsKICAgICAgICAgIGluRUxTRSA9IGlmTGV2ZWw7CiAgICAgICAgfSBlbHNlIGlmIChvcCA9PT0gMHg1OSkgewogICAgICAgICAgaWYgKGluRUxTRSA9PT0gaWZMZXZlbCkgewogICAgICAgICAgICBpbkVMU0UgPSAwOwogICAgICAgICAgfQogICAgICAgICAgLS1pZkxldmVsOwogICAgICAgIH0gZWxzZSBpZiAob3AgPT09IDB4MWMpIHsKICAgICAgICAgIGlmICghaW5GREVGICYmICFpbkVMU0UpIHsKICAgICAgICAgICAgY29uc3Qgb2Zmc2V0ID0gc3RhY2suYXQoLTEpOwogICAgICAgICAgICBpZiAob2Zmc2V0ID4gMCkgewogICAgICAgICAgICAgIGkgKz0gb2Zmc2V0IC0gMTsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoIWluRkRFRiAmJiAhaW5FTFNFKSB7CiAgICAgICAgICBsZXQgc3RhY2tEZWx0YSA9IDA7CiAgICAgICAgICBpZiAob3AgPD0gMHg4ZSkgewogICAgICAgICAgICBzdGFja0RlbHRhID0gVFRPcHNTdGFja0RlbHRhc1tvcF07CiAgICAgICAgICB9IGVsc2UgaWYgKG9wID49IDB4YzAgJiYgb3AgPD0gMHhkZikgewogICAgICAgICAgICBzdGFja0RlbHRhID0gLTE7CiAgICAgICAgICB9IGVsc2UgaWYgKG9wID49IDB4ZTApIHsKICAgICAgICAgICAgc3RhY2tEZWx0YSA9IC0yOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG9wID49IDB4NzEgJiYgb3AgPD0gMHg3NSkgewogICAgICAgICAgICBuID0gc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGlmICghaXNOYU4obikpIHsKICAgICAgICAgICAgICBzdGFja0RlbHRhID0gLW4gKiAyOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3RhY2tEZWx0YSA8IDAgJiYgc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICBzdGFjay5wb3AoKTsKICAgICAgICAgICAgc3RhY2tEZWx0YSsrOwogICAgICAgICAgfQogICAgICAgICAgd2hpbGUgKHN0YWNrRGVsdGEgPiAwKSB7CiAgICAgICAgICAgIHN0YWNrLnB1c2goTmFOKTsKICAgICAgICAgICAgc3RhY2tEZWx0YS0tOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgICB0dENvbnRleHQudG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zID0gdG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zOwogICAgICBjb25zdCBjb250ZW50ID0gW2RhdGFdOwogICAgICBpZiAoaSA+IGRhdGEubGVuZ3RoKSB7CiAgICAgICAgY29udGVudC5wdXNoKG5ldyBVaW50OEFycmF5KGkgLSBkYXRhLmxlbmd0aCkpOwogICAgICB9CiAgICAgIGlmIChsYXN0RGVmZiA+IGxhc3RFbmRmKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogY29tcGxlbWVudGluZyBhIG1pc3NpbmcgZnVuY3Rpb24gdGFpbCIpOwogICAgICAgIGNvbnRlbnQucHVzaChuZXcgVWludDhBcnJheShbMHgyMiwgMHgyZF0pKTsKICAgICAgfQogICAgICBmb2xkVFRUYWJsZSh0YWJsZSwgY29udGVudCk7CiAgICB9CiAgICBmdW5jdGlvbiBjaGVja0ludmFsaWRGdW5jdGlvbnModHRDb250ZXh0LCBtYXhGdW5jdGlvbkRlZnMpIHsKICAgICAgaWYgKHR0Q29udGV4dC50b29Db21wbGV4VG9Gb2xsb3dGdW5jdGlvbnMpIHsKICAgICAgICByZXR1cm47CiAgICAgIH0KICAgICAgaWYgKHR0Q29udGV4dC5mdW5jdGlvbnNEZWZpbmVkLmxlbmd0aCA+IG1heEZ1bmN0aW9uRGVmcykgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiVFQ6IG1vcmUgZnVuY3Rpb25zIGRlZmluZWQgdGhhbiBleHBlY3RlZCIpOwogICAgICAgIHR0Q29udGV4dC5oaW50c1ZhbGlkID0gZmFsc2U7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGZvciAobGV0IGogPSAwLCBqaiA9IHR0Q29udGV4dC5mdW5jdGlvbnNVc2VkLmxlbmd0aDsgaiA8IGpqOyBqKyspIHsKICAgICAgICBpZiAoaiA+IG1heEZ1bmN0aW9uRGVmcykgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogaW52YWxpZCBmdW5jdGlvbiBpZDogIiArIGopOwogICAgICAgICAgdHRDb250ZXh0LmhpbnRzVmFsaWQgPSBmYWxzZTsKICAgICAgICAgIHJldHVybjsKICAgICAgICB9CiAgICAgICAgaWYgKHR0Q29udGV4dC5mdW5jdGlvbnNVc2VkW2pdICYmICF0dENvbnRleHQuZnVuY3Rpb25zRGVmaW5lZFtqXSkgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJUVDogdW5kZWZpbmVkIGZ1bmN0aW9uOiAiICsgaik7CiAgICAgICAgICB0dENvbnRleHQuaGludHNWYWxpZCA9IGZhbHNlOwogICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgZnVuY3Rpb24gZm9sZFRUVGFibGUodGFibGUsIGNvbnRlbnQpIHsKICAgICAgaWYgKGNvbnRlbnQubGVuZ3RoID4gMSkgewogICAgICAgIGxldCBuZXdMZW5ndGggPSAwOwogICAgICAgIGxldCBqLCBqajsKICAgICAgICBmb3IgKGogPSAwLCBqaiA9IGNvbnRlbnQubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgICAgbmV3TGVuZ3RoICs9IGNvbnRlbnRbal0ubGVuZ3RoOwogICAgICAgIH0KICAgICAgICBuZXdMZW5ndGggPSBuZXdMZW5ndGggKyAzICYgfjM7CiAgICAgICAgY29uc3QgcmVzdWx0ID0gbmV3IFVpbnQ4QXJyYXkobmV3TGVuZ3RoKTsKICAgICAgICBsZXQgcG9zID0gMDsKICAgICAgICBmb3IgKGogPSAwLCBqaiA9IGNvbnRlbnQubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgICAgcmVzdWx0LnNldChjb250ZW50W2pdLCBwb3MpOwogICAgICAgICAgcG9zICs9IGNvbnRlbnRbal0ubGVuZ3RoOwogICAgICAgIH0KICAgICAgICB0YWJsZS5kYXRhID0gcmVzdWx0OwogICAgICAgIHRhYmxlLmxlbmd0aCA9IG5ld0xlbmd0aDsKICAgICAgfQogICAgfQogICAgZnVuY3Rpb24gc2FuaXRpemVUVFByb2dyYW1zKGZwZ20sIHByZXAsIGN2dCwgbWF4RnVuY3Rpb25EZWZzKSB7CiAgICAgIGNvbnN0IHR0Q29udGV4dCA9IHsKICAgICAgICBmdW5jdGlvbnNEZWZpbmVkOiBbXSwKICAgICAgICBmdW5jdGlvbnNVc2VkOiBbXSwKICAgICAgICBmdW5jdGlvbnNTdGFja0RlbHRhczogW10sCiAgICAgICAgdG9vQ29tcGxleFRvRm9sbG93RnVuY3Rpb25zOiBmYWxzZSwKICAgICAgICBoaW50c1ZhbGlkOiB0cnVlCiAgICAgIH07CiAgICAgIGlmIChmcGdtKSB7CiAgICAgICAgc2FuaXRpemVUVFByb2dyYW0oZnBnbSwgdHRDb250ZXh0KTsKICAgICAgfQogICAgICBpZiAocHJlcCkgewogICAgICAgIHNhbml0aXplVFRQcm9ncmFtKHByZXAsIHR0Q29udGV4dCk7CiAgICAgIH0KICAgICAgaWYgKGZwZ20pIHsKICAgICAgICBjaGVja0ludmFsaWRGdW5jdGlvbnModHRDb250ZXh0LCBtYXhGdW5jdGlvbkRlZnMpOwogICAgICB9CiAgICAgIGlmIChjdnQgJiYgY3Z0Lmxlbmd0aCAmIDEpIHsKICAgICAgICBjb25zdCBjdnREYXRhID0gbmV3IFVpbnQ4QXJyYXkoY3Z0Lmxlbmd0aCArIDEpOwogICAgICAgIGN2dERhdGEuc2V0KGN2dC5kYXRhKTsKICAgICAgICBj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jIpIHsKICAgICAgZm9udC5wb3MgKz0gODsKICAgICAgY29uc3QgbWF4Wm9uZXMgPSBmb250LmdldFVpbnQxNigpOwogICAgICBpZiAobWF4Wm9uZXMgPiAyKSB7CiAgICAgICAgdGFibGVzLm1heHAuZGF0YVsxNF0gPSAwOwogICAgICAgIHRhYmxlcy5tYXhwLmRhdGFbMTVdID0gMjsKICAgICAgfQogICAgICBmb250LnBvcyArPSA0OwogICAgICBtYXhGdW5jdGlvbkRlZnMgPSBmb250LmdldFVpbnQxNigpOwogICAgICBmb250LnBvcyArPSA0OwogICAgICBtYXhTaXplT2ZJbnN0cnVjdGlvbnMgPSBmb250LmdldFVpbnQxNigpOwogICAgfQogICAgdGFibGVzLm1heHAuZGF0YVs0XSA9IG51bUdseXBoc091dCA+PiA4OwogICAgdGFibGVzLm1heHAuZGF0YVs1XSA9IG51bUdseXBoc091dCAmIDI1NTsKICAgIGNvbnN0IGhpbnRzVmFsaWQgPSBzYW5pdGl6ZVRUUHJvZ3JhbXModGFibGVzLmZwZ20sIHRhYmxlcy5wcmVwLCB0YWJsZXNbImN2dCAiXSwgbWF4RnVuY3Rpb25EZWZzKTsKICAgIGlmICghaGludHNWYWxpZCkgewogICAgICBkZWxldGUgdGFibGVzLmZwZ207CiAgICAgIGRlbGV0ZSB0YWJsZXMucHJlcDsKICAgICAgZGVsZXRlIHRhYmxlc1siY3Z0ICJdOwogICAgfQogICAgc2FuaXRpemVNZXRyaWNzKGZvbnQsIHRhYmxlcy5oaGVhLCB0YWJsZXMuaG10eCwgdGFibGVzLmhlYWQsIG51bUdseXBoc091dCwgZHVwRmlyc3RFbnRyeSk7CiAgICBpZiAoIXRhYmxlcy5oZWFkKSB7CiAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcignUmVxdWlyZWQgImhlYWQiIHRhYmxlIGlzIG5vdCBmb3VuZCcpOwogICAgfQogICAgc2FuaXRpemVIZWFkKHRhYmxlcy5oZWFkLCBudW1HbHlwaHMsI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Z2x5cGhOYW1lLCBnbHlwaHNVbmljb2RlTWFwKTsKICAgICAgICAgIGxldCB1bmljb2RlT3JDaGFyQ29kZTsKICAgICAgICAgIGlmIChjbWFwUGxhdGZvcm1JZCA9PT0gMyAmJiBjbWFwRW5jb2RpbmdJZCA9PT0gMSkgewogICAgICAgICAgICB1bmljb2RlT3JDaGFyQ29kZSA9IGdseXBoc1VuaWNvZGVNYXBbc3RhbmRhcmRHbHlwaE5hbWVdOwogICAgICAgICAgfSBlbHNlIGlmIChjbWFwUGxhdGZvcm1JZCA9PT0gMSAmJiBjbWFwRW5jb2RpbmdJZCA9PT0gMCkgewogICAgICAgICAgICB1bmljb2RlT3JDaGFyQ29kZSA9IF9lbmNvZGluZ3MuTWFjUm9tYW5FbmNvZGluZy5pbmRleE9mKHN0YW5kYXJkR2x5cGhOYW1lKTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh1bmljb2RlT3JDaGFyQ29kZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgICAgIGlmICghcHJvcGVydGllcy5nbHlwaE5hbWVzICYmIHByb3BlcnRpZXMuaGFzSW5jbHVkZWRUb1VuaWNvZGVNYXAgJiYgISh0aGlzLnRvVW5pY29kZSBpbnN0YW5jZW9mIF90b191bmljb2RlX21hcC5JZGVudGl0eVRvVW5pY29kZU1hcCkpIHsKICAgICAgICAgICAgICBjb25zdCB1bmljb2RlID0gdGhpcy50b1VuaWNvZGUuZ2V0KGNoYXJDb2RlKTsKICAgICAgICAgICAgICBpZiAodW5pY29kZSkgewogICAgICAgICAgICAgICAgdW5pY29kZU9yQ2hhckNvZGUgPSB1bmljb2RlLmNvZGVQb2ludEF0KDApOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodW5pY29kZU9yQ2hhckNvZGUgPT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBmb3IgK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SA8IDI1NjsgKytpKSB7CiAgICAgICAgICBpZiAoIWZvcmNlUG9zdFRhYmxlICYmIGNoYXJDb2RlVG9HbHlwaElkW2ldICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCBnbHlwaE5hbWUgPSB0aGlzLmRpZmZlcmVuY2VzW2ldIHx8IGJhc2VFbmNvZGluZ1tpXTsKICAgICAgICAgIGlmICghZ2x5cGhOYW1lKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgY29uc3QgZ2x5cGhJZCA9IHByb3BlcnRpZXMuZ2x5cGhOYW1lcy5pbmRleE9mKGdseXBoTmFtZSk7CiAgICAgICAgICBpZiAoZ2x5cGhJZCA+IDAgJiYgaGFzR2x5cGgoZ2x5cGhJZCkpIHsKICAgICAgICAgICAgY2hhckNvZGVUb0dseXBoSWRbaV0gPSBnbHlwaElkOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfQogICAgaWYgKGNoYXJDb2RlVG9HbHlwaElkLmxlbmd0aCA9PT0gMCkgewogICAgICBjaGFyQ29kZVRvR2x5cGhJZFswXSA9IDA7CiAgICB9CiAgICBsZXQgZ2x5cGhaZXJvSWQgPSBudW1HbHlwaHNPdXQgLSAxOwogICAgaWYgKCFkdXBGaXJzdEVudHJ5KSB7CiAgICAgIGdseXBoWmVyb0lkID0gMDsKICAgIH0KICAgIGlmICghcHJvcGVydGllcy5jc3NGb250SW5mbykgewogICAgICBjb25zdCBuZXdNYXBwaW5nID0gYWRqdXN0TWFwcGluZyhjaGFyQ29kZVRvR2x5cGhJZCwgaGFzR2x5cGgsIGdseXBoWmVyb0lkLCB0aGlzLnRvVW5pY29kZSk7CiAgICAgIHRoaXMudG9Gb250Q2hhciA9IG5ld01hcHBpbmcudG9Gb250Q2hhcjsKICAgICAgdGFibGVzLmNtYXAgPSB7CiAgICAgICAgdGFnOiAiY21hcCIs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WYgKCF0YWJsZXMubmFtZSkgewogICAgICB0YWJsZXMubmFtZSA9IHsKICAgICAgICB0YWc6ICJuYW1lIiwKICAgICAgICBkYXRhOiBjcmVhdGVOYW1lVGFibGUodGhpcy5uYW1lKQogICAgICB9OwogICAgfSBlbHNlIHsKICAgICAgY29uc3QgW25hbWVQcm90b3R5cGUsIG5hbWVSZWNvcmRzXSA9IHJlYWROYW1lVGFibGUodGFibGVzLm5hbWUpOwogICAgICB0YWJsZXMubmFtZS5kYXRhID0gY3JlYXRlTmFtZVRhYmxlKG5hbWUsIG5hbWVQcm90b3R5cGUpOwogICAgICB0aGlzLnBzTmFtZSA9IG5hbWVQcm90b3R5cGVbMF1bNl0gfHwgbnVsbDsKICAgICAgaWYgKCFwcm9wZXJ0aWVzLmNvbXBvc2l0ZSkgewogICAgICAgIGFkanVzdFRydWVUeXBlVG9Vbmljb2RlKHByb3BlcnRpZXMsIHRoaXMuaXNTeW1ib2xpY0ZvbnQsIG5hbWVSZWNvcmRzKTsKICAgICAgfQogICAgfQogICAgY29uc3QgYnVpbGRlciA9IG5ldyBfb3BlbnR5cGVfZmlsZV9idWlsZGVyLk9wZW5UeXBlRmlsZUJ1aWxkZXIoaGVhZGVyLnZlcnNpb24pOwogICAgZm9yIChjb25zdCB0YWJsZVRhZyBpbiB0YWJsZXMpIHsKICAgICAgYnVpbGRlci5hZGRUYWJsZSh0YWJsZVRhZywgdGFibGVzW3RhYmxlVGFnXS5kYXRhKTsKICAgIH0KICAgIHJldHVybiBidWlsZGVyLnRvQXJyYXkoKTsKICB9CiAgY29udmVydChmb250TmFtZSwgZm9udCwgcHJvcGVydGllcykgewogICAgcHJvcGVydGllcy5maXhlZFBpdGNoID0gZmFsc2U7CiAgICBpZiAocHJvcGVydGllcy5idWlsdEluRW5jb2RpbmcpIHsKICAgICAgYWRqdXN0VHlwZTFUb1VuaWNvZGUocHJvcGVydGllcywgcHJvcGVydGllcy5idWlsdEluRW5jb2RpbmcpOwogICAgfQogICAgbG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vZGVzID0gW107CiAgICAgICAgICB9CiAgICAgICAgICBjaGFyQ29kZXMucHVzaChjaGFyQ29kZSB8IDApOwogICAgICAgIH0KICAgICAgfQogICAgICByZXR1cm4gY2hhckNvZGVzOwogICAgfQogICAgZnVuY3Rpb24gY3JlYXRlQ2hhckNvZGUoY2hhckNvZGVUb0dseXBoSWQsIGdseXBoSWQpIHsKICAgICAgZm9yIChjb25zdCBjaGFyQ29kZSBpbiBjaGFyQ29kZVRvR2x5cGhJZCkgewogICAgICAgIGlmIChnbHlwaElkID09PSBjaGFyQ29kZVRvR2x5cGhJZFtjaGFyQ29kZV0pIHsKICAgICAgICAgIHJldHVybiBjaGFyQ29kZSB8IDA7CiAgICAgICAgfQogICAgICB9CiAgICAgIG5ld01hcHBpbmcuY2hhckNvZGVUb0dseXBoSWRbbmV3TWFwcGluZy5uZXh0QXZhaWxhYmxlRm9udENoYXJDb2RlXSA9IGdseXBoSWQ7CiAgICAgIHJldHVybiBuZXdNYXBwaW5nLm5leHRBdmFpbGFibGVGb250Q2hhckNvZGUrKzsKICAgIH0KICAgIGNvbnN0IHNlYWNzID0gZm9udC5zZWFjczsKICAgIGlmIChuZXdNYXBwaW5nICYmIF9mb250c191dGlscy5TRUFDX0FOQUxZU0lTX0VOQUJMRUQgJiYgc2VhY3MgJiYgc2VhY3MubGVuZ3RoKSB7CiAgICAgIGNvbnN0IG1hdHJpeCA9IHByb3BlcnRpZXMuZm9udE1hdHJpeCB8fCBfdXRpbC5GT05UX0lERU5USVRZX01BVFJJWDsKICAgICAgY29uc3QgY2hhcnNldCA9IGZvbnQuZ2V0Q2hhcnNldCgpOwogICAgICBjb25zdCBzZWFjTWFwID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgICAgZm9yIChsZXQgZ2x5cGhJZCBpbiBzZWFjcykgewogICAgICAgIGdseXBoSWQgfD0gMDsKICAgICAgICBjb25zdCBzZWFjID0gc2VhY3NbZ2x5cGhJZF07CiAgICAgICAgY29uc3QgYmFzZ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bnRDaGFyQ29kZSA9PT0gIm51bWJlciIpIHsKICAgICAgaWYgKGZvbnRDaGFyQ29kZSA8PSAweDEwZmZmZikgewogICAgICAgIGZvbnRDaGFyID0gU3RyaW5nLmZyb21Db2RlUG9pbnQoZm9udENoYXJDb2RlKTsKICAgICAgfSBlbHNlIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYGNoYXJUb0dseXBoIC0gaW52YWxpZCBmb250Q2hhckNvZGU6ICR7Zm9udENoYXJDb2RlfWApOwogICAgICB9CiAgICB9CiAgICBnbHlwaCA9IG5ldyBHbHlwaChjaGFyY29kZSwgZm9udENoYXIsIHVuaWNvZGUsIGFjY2VudCwgd2lkdGgsIHZtZXRyaWMsIG9wZXJhdG9yTGlzdElkLCBpc1NwYWNlLCBpc0luRm9udCk7CiAgICByZXR1cm4gdGhpcy5fZ2x5cGhDYWNoZVtjaGFyY29kZV0gPSBnbHlwaDsKICB9CiAgY2hhcnNUb0dseXBocyhjaGFycykgewogICAgbGV0IGdseXBocyA9IHRoaXMuX2NoYXJzQ2FjaGVbY2hhcnNdOwogICAgaWYgKGdseXBocykgewogICAgICByZXR1cm4gZ2x5cGhzOwogICAgfQogICAgZ2x5cGhzID0gW107CiAgICBpZiAodGhpcy5jTWFwKSB7CiAgICAgIGNvbnN0IGMgPSBPYmplY3QuY3JlYXRlKG51bGwpLAogICAgICAgIGlpID0gY2hhcnMubGVuZ3RoOwogICAgICBsZXQgaSA9IDA7CiAgICAgIHdoaWxlIChpIDwgaWkpIHsKICAgICAgICB0aGlzLmNNYXAucmVhZENoYXJDb2RlKGNoYXJzLCBpLCBjKTsKICAgICAgICBjb25zdCB7CiAgICAgICAgICBjaGFyY29kZSwKICAgICAgICAgIGxlbmd0aAogICAgICAgIH0gPSBjOwogICAgICAgIGkgKz0gbGVuZ3RoOwogICAgICAgIGNvbnN0IGdseXBoID0gdGhpcy5fY2hhclRvR2x5cGgoY2hhcmNvZGUsIGxlbmd0aCA9PT0gMSAmJiBjaGFyc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sdWVzKHRoaXMuX2dseXBoQ2FjaGUpOwogIH0KICBlbmNvZGVTdHJpbmcoc3RyKSB7CiAgICBjb25zdCBidWZmZXJzID0gW107CiAgICBjb25zdCBjdXJyZW50QnVmID0gW107CiAgICBjb25zdCBoYXNDdXJyZW50QnVmRXJyb3JzID0gKCkgPT4gYnVmZmVycy5sZW5ndGggJSAyID09PSAxOwogICAgY29uc3QgZ2V0Q2hhckNvZGUgPSB0aGlzLnRvVW5pY29kZSBpbnN0YW5jZW9mIF90b191bmljb2RlX21hcC5JZGVudGl0eVRvVW5pY29kZU1hcCA/IHVuaWNvZGUgPT4gdGhpcy50b1VuaWNvZGUuY2hhckNvZGVPZih1bmljb2RlKSA6IHVuaWNvZGUgPT4gdGhpcy50b1VuaWNvZGUuY2hhckNvZGVPZihTdHJpbmcuZnJvbUNvZGVQb2ludCh1bmljb2RlKSk7CiAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBzdHIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICBjb25zdCB1bmljb2RlID0gc3RyLmNvZGVQb2ludEF0KGkpOwogICAgICBpZiAodW5pY29kZSA+IDB4ZDdmZiAmJiAodW5pY29kZSA8IDB4ZTAwMCB8fCB1bmljb2RlID4gMHhmZmZkKSkgewogICAgICAgIGkrKzsKICAgICAgfQogICAgICBpZiAodGhpcy50b1VuaWNvZGUpIHsKICAgICAgICBjb25zdCBjaGFyQ29kZSA9IGdldENoYXJDb2RlKHVuaWNvZGUpOwogICAgICAgIGlmIChjaGFyQ29kZSAhPT0gLTEpIHsKICAgICAgICAgIGlmIChoYXNDdXJyZW50QnVmRXJyb3JzKCkpIHsKICAgICAgICAgICAgYnVmZmVycy5wdXNoKGN1cnJlbnRCdWYuam9pbigiIikpOwogICAgICAgICAgICBjdXJyZW50QnVmLmxlbmd0aCA9IDA7CiAgICAgICAgICB9CiAgICAgICAgICBjb25zdCBjaGFyQ29kZUxlbmd0aCA9IHRoaXMuY01hcCA/IHRoaXMuY01h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AgICAgIHdoaWxlIChwb3MgPCBsZW5ndGgpIHsKICAgICAgICBjb25zdCBiID0gZGljdFtwb3MrK107CiAgICAgICAgY29uc3QgYjEgPSBiID4+IDQ7CiAgICAgICAgY29uc3QgYjIgPSBiICYgMTU7CiAgICAgICAgaWYgKGIxID09PSBlb2YpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBzdHIgKz0gbG9va3VwW2IxXTsKICAgICAgICBpZiAoYjIgPT09IGVvZikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIHN0ciArPSBsb29rdXBbYjJdOwogICAgICB9CiAgICAgIHJldHVybiBwYXJzZUZsb2F0KHN0cik7CiAgICB9CiAgICBsZXQgb3BlcmFuZHMgPSBbXTsKICAgIGNvbnN0IGVudHJpZXMgPSBbXTsKICAgIHBvcyA9IDA7CiAgICBjb25zdCBlbmQgPSBkaWN0Lmxlbmd0aDsKICAgIHdoaWxlIChwb3MgPCBlbmQpIHsKICAgICAgbGV0IGIgPSBkaWN0W3Bvc107CiAgICAgIGlmIChiIDw9IDIxKSB7CiAgICAgICAgaWYgKGIgPT09IDEyKSB7CiAgICAgICAgICBiID0gYiA8PCA4IHwgZGljdFsrK3Bvc107CiAgICAgICAgfQogICAgICAgIGVudHJpZXMucHVzaChbYiwgb3BlcmFuZHNdKTsKICAgICAgICBvcGVyYW5kcyA9IFtdOwogICAgICAgICsrcG9zOwogICAgICB9IGVsc2UgewogICAgICAgIG9wZXJhbmRzLnB1c2gocGFyc2VPcGVyYW5kKCkpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gZW50cmllczsKICB9CiAgcGFyc2VJbmRleChwb3MpIHsKICAgIGNvbnN0IGNmZkluZGV4ID0gbmV3IENGRkluZGV4KCk7CiAgICBjb25zdCBieXRlcyA9IHRoaXMuYnl0ZXM7CiAgICBjb25zdCBjb3VudCA9IGJ5dGVzW3BvcysrXSA8PCA4IHwgYnl0ZXNbcG9zKytdOwogICAgY29uc3Qgb2Zmc2V0cyA9IFtdOwogICAgbGV0IGVuZCA9IHBvczsKICAgIGxldCBpLCBpaTsKICAgIGlmIChjb3VudCAhPT0gMCkgewogICAgICBjb25zdCBvZmZzZXRTaXplID0gYnl0ZXNbcG9zKytdOwogICAgICBjb25zdCBzdGFydFBvcyA9IHBvcyArIChjb3VudCArIDEpICogb2Zmc2V0U2l6ZSAtIDE7CiAgICAgIGZvciAoaSA9IDAsIGlpID0gY291bnQgKyAxOyBpIDwgaWk7ICsraSkgewogICAgICAgIGxldCBvZmZzZXQgPSAwOwogICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgb2Zmc2V0U2l6ZTsgKytqKSB7CiAgICAgICAgICBvZmZzZXQgPDw9IDg7CiAgICAgICAgICBvZmZzZXQgKz0gYnl0ZXNbcG9zKytdOwogICAgICAgIH0KICAgICAgICBvZmZzZXRzLnB1c2goc3RhcnRQb3MgKyBvZmZzZXQpOwogICAgICB9CiAgICAgIGVuZCA9IG9mZnNldHNbY291bnRdOwogICAgfQogICAgZm9yIChpID0gMCwgaWkgPSBvZmZzZXRzLmxlbmd0aCAtIDE7IGkgPCBpaTsgKytpKSB7CiAgICAgIGNvbnN0IG9mZnNldFN0YXJ0ID0gb2Zmc2V0c1tpXTsKICAgICAgY29uc3Qgb2Zmc2V0RW5kID0gb2Zmc2V0c1tpICsgMV07CiAgICAgIGNmZkluZGV4LmFkZChieXRlcy5zdWJhcnJheShvZmZzZXRTdGFydCwgb2Zmc2V0RW5kKSk7CiAgICB9CiAgICByZXR1cm4gewogICAgICBvYmo6IGNmZkluZGV4LAogICAgICBlbmRQb3M6IGVuZAogICAgfTsKICB9CiAgcGFyc2VOYW1lSW5kZXgoaW5kZXgpIHsKICAgIGNvbnN0IG5hbWVzID0gW107CiAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBpbmRleC5jb3VudDsgaSA8IGlpOyArK2kpIHsKICAgICAgY29uc3QgbmFtZSA9IGluZGV4LmdldChpKTsKICAgICAgbmFt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AgICAgIGlmICh2YWx1ZSA9PT0gMTIpIHsKICAgICAgICBjb25zdCBxID0gZGF0YVtqKytdOwogICAgICAgIGlmIChxID09PSAwKSB7CiAgICAgICAgICBkYXRhW2ogLSAyXSA9IDEzOTsKICAgICAgICAgIGRhdGFbaiAtIDFdID0gMjI7CiAgICAgICAgICBzdGFja1NpemUgPSAwOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZCA9IENoYXJzdHJpbmdWYWxpZGF0aW9uRGF0YTEyW3FdOwogICAgICAgIH0KICAgICAgfSBlbHNlIGlmICh2YWx1ZSA9PT0gMjgpIHsKICAgICAgICBzdGFja1tzdGFja1NpemVdID0gKGRhdGFbal0gPDwgMjQgfCBkYXRhW2ogKyAxXSA8PCAxNikgPj4gMTY7CiAgICAgICAgaiArPSAyOwogICAgICAgIHN0YWNrU2l6ZSsrOwogICAgICB9IGVsc2UgaWYgKHZhbHVlID09PSAxNCkgewogICAgICAgIGlmIChzdGFja1NpemUgPj0gNCkgewogICAgICAgICAgc3RhY2tTaXplIC09IDQ7CiAgICAgICAgICBpZiAodGhpcy5zZWFjQW5hbHlzaXNFbmFibGVkKSB7CiAgICAgICAgICAgIHN0YXRlLnNlYWMgPSBzdGFjay5zbGljZShzdGFja1NpemUsIHN0YWNrU2l6ZSArIDQpOwogICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHZhbGlkYXRpb25Db21tYW5kID0gQ2hhcnN0cmluZ1ZhbGlkYXRpb25EYXRhW3ZhbHVlXTsKICAgICAgfSBlbHNlIGlmICh2YWx1ZSA+PSAzMiAmJiB2YWx1ZSA8PSAyNDYpIHsKICAgICAgICBzdGFja1tzdGFja1NpemVdID0gdmFsdWUgLSAxMzk7CiAgICAgICAgc3RhY2tTaXplKys7CiAgICAgIH0gZWxzZSBpZiAodmFsdWUgPj0gMjQ3ICYmIHZhbHVlIDw9IDI1NCkgewogICA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CwgX3V0aWwud2FybikoIk1pc3Npbmcgc3VicnNJbmRleCBmb3IgIiArIHZhbGlkYXRpb25Db21tYW5kLmlkKTsKICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgICAgbGV0IGJpYXMgPSAzMjc2ODsKICAgICAgICBpZiAoc3VicnNJbmRleC5jb3VudCA8IDEyNDApIHsKICAgICAgICAgIGJpYXMgPSAxMDc7CiAgICAgICAgfSBlbHNlIGlmIChzdWJyc0luZGV4LmNvdW50IDwgMzM5MDApIHsKICAgICAgICAgIGJpYXMgPSAxMTMxOwogICAgICAgIH0KICAgICAgICBjb25zdCBzdWJyTnVtYmVyID0gc3RhY2tbLS1zdGFja1NpemVdICsgYmlhczsKICAgICAgICBpZiAoc3Vick51bWJlciA8IDAgfHwgc3Vick51bWJlciA+PSBzdWJyc0luZGV4LmNvdW50IHx8IGlzTmFOKHN1YnJOdW1iZXIpKSB7CiAgICAgICAgICB2YWxpZGF0aW9uQ29tbWFuZCA9IENoYXJzdHJpbmdWYWxpZGF0aW9uRGF0YVt2YWx1ZV07CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIk91dCBvZiBib3VuZHMgc3VickluZGV4IGZvciAiICsgdmFsaWRhdGlvbkNvbW1hbmQuaWQpOwogICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgICBzdGF0ZS5zdGFja1NpemUgPSBzdGFja1NpemU7CiAgICAgICAgc3RhdGUuY2FsbERlcHRoKys7CiAgICAgICAgY29uc3QgdmFsaWQgPSB0aGlzLnBhcnNlQ2hhclN0cmluZyhzdGF0ZSwgc3VicnNJbmRleC5nZXQoc3Vick51bWJlciksIGxvY2FsU3VickluZGV4LCBnbG9iYWxTdWJySW5kZXgpOwogICAgICAgIGlmICghdmFsaWQpIHsKICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgICAgc3RhdGUuY2FsbERlcHRoLS07CiAgICAgICAgc3RhY2tTaXplID0gc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MyA6IDIzOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoIm1pbiIgaW4gdmFsaWRhdGlvbkNvbW1hbmQpIHsKICAgICAgICAgIGlmICghc3RhdGUudW5kZWZTdGFjayAmJiBzdGFja1NpemUgPCB2YWxpZGF0aW9uQ29tbWFuZC5taW4pIHsKICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJOb3QgZW5vdWdoIHBhcmFtZXRlcnMgZm9yICIgKyB2YWxpZGF0aW9uQ29tbWFuZC5pZCArICI7IGFjdHVhbDogIiArIHN0YWNrU2l6ZSArICIsIGV4cGVjdGVkOiAiICsgdmFsaWRhdGlvbkNvbW1hbmQubWluKTsKICAgICAgICAgICAgaWYgKHN0YWNrU2l6ZSA9PT0gMCkgewogICAgICAgICAgICAgIGRhdGFbaiAtIDFdID0gMTQ7CiAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc3RhdGUuZmlyc3RTdGFja0NsZWFyaW5nICYmIHZhbGlkYXRpb25Db21tYW5kLnN0YWNrQ2xlYXJpbmcpIHsKICAgICAgICAgIHN0YXRlLmZpcnN0U3RhY2tDbGVhcmluZyA9IGZhbHNlOwogICAgICAgICAgc3RhY2tTaXplIC09IHZhbGlkYXRpb25Db21tYW5kLm1pbjsKICAgICAgICAgIGlmIChzdGFja1NpemUgPj0gMiAmJiB2YWxpZGF0aW9uQ29tbWFuZC5zdGVtKSB7CiAgICAgICAgICAgIHN0YWNrU2l6ZSAlPSAyOwogICAgICAgICAgfSBlbHNlIGlmIChzdGFja1NpemUgPiAxKSB7CiAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiRm91bmQgdG9vIG1hbnkgcGFyYW1ldGVycyBmb3Igc3RhY2stY2xlYXJpbmcgY29tbWFuZCIpOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHN0Y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dHJpbmdzLAogICAgICBsb2NhbFN1YnJJbmRleCwKICAgICAgZ2xvYmFsU3VickluZGV4LAogICAgICBmZFNlbGVjdCwKICAgICAgZmRBcnJheSwKICAgICAgcHJpdmF0ZURpY3QKICAgIH0gPSBfcmVmOwogICAgY29uc3Qgc2VhY3MgPSBbXTsKICAgIGNvbnN0IHdpZHRocyA9IFtdOwogICAgY29uc3QgY291bnQgPSBjaGFyU3RyaW5ncy5jb3VudDsKICAgIGZvciAobGV0IGkgPSAwOyBpIDwgY291bnQ7IGkrKykgewogICAgICBjb25zdCBjaGFyc3RyaW5nID0gY2hhclN0cmluZ3MuZ2V0KGkpOwogICAgICBjb25zdCBzdGF0ZSA9IHsKICAgICAgICBjYWxsRGVwdGg6IDAsCiAgICAgICAgc3RhY2tTaXplOiAwLAogICAgICAgIHN0YWNrOiBbXSwKICAgICAgICB1bmRlZlN0YWNrOiB0cnVlLAogICAgICAgIGhpbnRzOiAwLAogICAgICAgIGZpcnN0U3RhY2tDbGVhcmluZzogdHJ1ZSwKICAgICAgICBzZWFjOiBudWxsLAogICAgICAgIHdpZHRoOiBudWxsLAogICAgICAgIGhhc1ZTdGVtczogZmFsc2UKICAgICAgfTsKICAgICAgbGV0IHZhbGlkID0gdHJ1ZTsKICAgICAgbGV0IGxvY2FsU3ViclRvVXNlID0gbnVsbDsKICAgICAgbGV0IHByaXZhdGVEaWN0VG9Vc2UgPSBwcml2YXRlRGljdDsKICAgICAgaWYgKGZkU2VsZWN0ICYmIGZkQXJyYXkubGVuZ3RoKSB7CiAgICAgICAgY29uc3QgZmRJbmRleCA9IGZkU2VsZWN0LmdldEZESW5kZXgoaSk7CiAgICAgICAgaWYgKGZkSW5kZXggPT09IC0xKSB7CiAgICAgICAgICAoMCwgX3V0aWwud2FybikoIkdseXBoIGluZGV4IGlzIG5vdCBpbiBmZCBzZWxlY3QuIik7CiAgICAgICAgICB2YWxpZCA9IGZhbHNlOwogICAgICAgIH0KICAgICAgICBpZiAoZmRJbmRle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SAxOgogICAgICAgIHdoaWxlIChjaGFyc2V0Lmxlbmd0aCA8PSBsZW5ndGgpIHsKICAgICAgICAgIGlkID0gYnl0ZXNbcG9zKytdIDw8IDggfCBieXRlc1twb3MrK107CiAgICAgICAgICBjb3VudCA9IGJ5dGVzW3BvcysrXTsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPD0gY291bnQ7IGkrKykgewogICAgICAgICAgICBjaGFyc2V0LnB1c2goY2lkID8gaWQrKyA6IHN0cmluZ3MuZ2V0KGlkKyspKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgMjoKICAgICAgICB3aGlsZSAoY2hhcnNldC5sZW5ndGggPD0gbGVuZ3RoKSB7CiAgICAgICAgICBpZCA9IGJ5dGVzW3BvcysrXSA8PCA4IHwgYnl0ZXNbcG9zKytdOwogICAgICAgICAgY291bnQgPSBieXRlc1twb3MrK10gPDwgOCB8IGJ5dGVzW3BvcysrXTsKICAgICAgICAgIGZvciAoaSA9IDA7IGkgPD0gY291bnQ7IGkrKykgewogICAgICAgICAgICBjaGFyc2V0LnB1c2goY2lkID8gaWQrKyA6IHN0cmluZ3MuZ2V0KGlkKyspKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGRlZmF1bHQ6CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJVbmtub3duIGNoYXJzZXQgZm9ybWF0Iik7CiAgICB9CiAgICBjb25zdCBlbmQgPSBwb3M7CiAgICBjb25zdCByYXcgPSBieXRlcy5zdWJhcnJheShzdGFydCwgZW5kKTsKICAgIHJldHVybiBuZXcgQ0ZGQ2hhcnNldChmYWxzZSwgZm9ybWF0LCBjaGFyc2V0LCByYXcpOwogIH0KICBwYXJzZUVuY29kaW5nKHBvcywgcHJvcGVydGllcywgc3RyaW5ncywgY2hhcnNldCkgewogICAgY29uc3QgZW5jb2RpbmcgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgY29uc3QgYnl0ZXMgPSB0aGlzLmJ5dGVzOwogICAgbGV0IHByZWRlZmluZWQgPSBmYWxzZTsKICAgIGxldCBmb3JtYXQsIGksIGlpOwogICAgbGV0IHJhdyA9IG51bGw7CiAgICBmdW5jdGlvbiByZWFkU3VwcGxlbWVudCgpIHsKICAgICAgY29uc3Qgc3VwcGxlbWVudHNDb3VudCA9IGJ5dGVzW3BvcysrXTsKICAgICAgZm9yIChpID0gMDsgaSA8IHN1cHBsZW1lbnRzQ291bnQ7IGkrKykgewogICAgICAgIGNvbnN0IGNvZGUgPSBieXRlc1twb3MrK107CiAgICAgICAgY29uc3Qgc2lkID0gKGJ5dGVzW3BvcysrXSA8PCA4KSArIChieXRlc1twb3MrK10gJiAweGZmKTsKICAgICAgICBlbmNvZGluZ1tjb2RlXSA9IGNoYXJzZXQuaW5kZXhPZihzdHJpbmdzLmdldChzaWQpKTsKICAgICAgfQogICAgfQogICAgaWYgKHBvcyA9PT0gMCB8fCBwb3MgPT09IDEpIHsKICAgICAgcHJlZGVmaW5lZCA9IHRydWU7CiAgICAgIGZvcm1hdCA9IHBvczsKICAgICAgY29uc3QgYmFzZUVuY29kaW5nID0gcG9zID8gX2VuY29kaW5ncy5FeHBlcnRFbmNvZGluZyA6IF9lbmNvZGluZ3MuU3RhbmRhcmRFbmNvZGluZzsKICAgICAgZm9yIChpID0gMCwgaWkgPSBjaGFyc2V0Lmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb25zdCBpbmRleCA9IGJhc2VFbmNvZGluZy5pbmRleE9mKGNoYXJzZXRbaV0pOwogICAgICAgIGlmIChpbmRleCAhPT0gLTEpIHsKICAgICAgICAgIGVuY29kaW5nW2luZGV4XSA9IGk7CiAgICAgICAgfQogICAgICB9CiAgICB9IGVsc2UgewogICAgICBjb25zdCBkYXRhU3RhcnQgPSBwb3M7CiAgICAgIGZvcm1hdCA9IGJ5dGVzW3BvcysrXTsKICAgICAgc3dpdGNoIChmb3JtYXQgJiAweDdmKSB7CiAgICAgICAgY2FzZSAwOgogICAgICAgICAgY29uc3QgZ2x5cGhzQ291bnQgPSBieXRlc1twb3MrK107CiAgICAgICAgICBmb3IgKGkgPSAxOyBpIDw9IGdseXBoc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgZW5jb2RpbmdbYnl0ZXNbcG9zKytdXSA9IGk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDE6CiAgICAgICAgICBjb25zdCByYW5nZXNDb3VudCA9IGJ5dGVzW3BvcysrXTsKICAgICAgICAgIGxldCBnaWQgPSAxOwogICAgICAgICAgZm9yIChpID0gMDsgaSA8IHJhbmdlc0NvdW50OyBpKyspIHsKICAgICAgICAgICAgY29uc3Qgc3RhcnQgPSBieXRlc1twb3MrK107CiAgICAgICAgICAgIGNvbnN0IGxlZnQgPSBieXRlc1twb3MrK107CiAgICAgICAgICAgIGZvciAobGV0IGogPSBzdGFydDsgaiA8PSBzdGFydCArIGxlZnQ7IGorKykgewogICAgICAgICAgICAgIGVuY29kaW5nW2pdID0gZ2lkKys7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYFVua25vd24gZW5jb2RpbmcgZm9ybWF0OiAke2Zvcm1hdH0gaW4gQ0ZGYCk7CiAgICAgIH0KICAgICAgY29uc3QgZGF0YUVuZCA9IHBvczsKICAgICAgaWYgKGZvcm1hdCAmIDB4ODApIHsKICAgICAgICBieXRlc1tkYXRhU3RhcnRdICY9IDB4N2Y7CiAgICAgICAgcmVhZFN1cHBsZW1lbnQoKTsKICAgICAgfQogICAgICByYXcgPSBieXRlcy5zdWJhcnJheShkYXRhU3RhcnQsIGRhdGFFbmQpOwogICAgfQogICAgZm9ybWF0ICY9IDB4N2Y7CiAgICByZXR1cm4gbmV3IEN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25hbWVdXTsKICB9CiAgc3RhdGljIGNyZWF0ZVRhYmxlcyhsYXlvdXQpIHsKICAgIGNvbnN0IHRhYmxlcyA9IHsKICAgICAga2V5VG9OYW1lTWFwOiB7fSwKICAgICAgbmFtZVRvS2V5TWFwOiB7fSwKICAgICAgZGVmYXVsdHM6IHt9LAogICAgICB0eXBlczoge30sCiAgICAgIG9wY29kZXM6IHt9LAogICAgICBvcmRlcjogW10KICAgIH07CiAgICBmb3IgKGNvbnN0IGVudHJ5IG9mIGxheW91dCkgewogICAgICBjb25zdCBrZXkgPSBBcnJheS5pc0FycmF5KGVudHJ5WzBdKSA/IChlbnRyeVswXVswXSA8PCA4KSArIGVudHJ5WzBdWzFdIDogZW50cnlbMF07CiAgICAgIHRhYmxlcy5rZXlUb05hbWVNYXBba2V5XSA9IGVudHJ5WzFdOwogICAgICB0YWJsZXMubmFtZVRvS2V5TWFwW2VudHJ5WzFdXSA9IGtleTsKICAgICAgdGFibGVzLnR5cGVzW2tleV0gPSBlbnRyeVsyXTsKICAgICAgdGFibGVzLmRlZmF1bHRzW2tleV0gPSBlbnRyeVszXTsKICAgICAgdGFibGVzLm9wY29kZXNba2V5XSA9IEFycmF5LmlzQXJyYXkoZW50cnlbMF0pID8gZW50cnlbMF0gOiBbZW50cnlbMF1dOwogICAgICB0YWJsZXMub3JkZXIucHVzaChrZXkpOwogICAgfQogICAgcmV0dXJuIHRhYmxlczsKICB9Cn0KY29uc3QgQ0ZGVG9wRGljdExheW91dCA9IFtbWzEyLCAzMF0sICJST1MiLCBbInNpZCIsICJzaWQiLCAibnVtIl0sIG51bGxdLCBbWzEyLCAyMF0sICJTeW50aGV0aWNCYXNlIiwgIm51bSIsIG51bGxdLCBbMCwgInZlcnNpb24iLCAic2lkIiwgbnVsbF0sIFsxLCAiTm90aWNlIiwgInNpZCIsIG51bGxdLCBbWzEyLCAwXSwgIkNvcHlyaWdodCIsICJzaWQiLCBudWxsXSwgWzIsICJGdWxsTmFtZSIsICJzaWQiL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6ZWROYW1lKSk7CiAgICB9CiAgICByZXR1cm4gdGhpcy5jb21waWxlSW5kZXgobmFtZUluZGV4KTsKICB9CiAgY29tcGlsZVRvcERpY3RzKGRpY3RzLCBsZW5ndGgsIHJlbW92ZUNpZEtleXMpIHsKICAgIGNvbnN0IGZvbnREaWN0VHJhY2tlcnMgPSBbXTsKICAgIGxldCBmZEFycmF5SW5kZXggPSBuZXcgQ0ZGSW5kZXgoKTsKICAgIGZvciAoY29uc3QgZm9udERpY3Qgb2YgZGljdHMpIHsKICAgICAgaWYgKHJlbW92ZUNpZEtleXMpIHsKICAgICAgICBmb250RGljdC5yZW1vdmVCeU5hbWUoIkNJREZvbnRWZXJzaW9uIik7CiAgICAgICAgZm9udERpY3QucmVtb3ZlQnlOYW1lKCJDSURGb250UmV2aXNpb24iKTsKICAgICAgICBmb250RGljdC5yZW1vdmVCeU5hbWUoIkNJREZvbnRUeXBlIik7CiAgICAgICAgZm9udERpY3QucmVtb3ZlQnlOYW1lKCJDSURDb3VudCIpOwogICAgICAgIGZvbnREaWN0LnJlbW92ZUJ5TmFtZSgiVUlEQmFzZSIpOwogICAgICB9CiAgICAgIGNvbnN0IGZvbnREaWN0VHJhY2tlciA9IG5ldyBDRkZPZmZzZXRUcmFja2VyKCk7CiAgICAgIGNvbnN0IGZvbnREaWN0RGF0YSA9IHRoaXMuY29tcGlsZURpY3QoZm9udERpY3QsIGZvbnREaWN0VHJhY2tlcik7CiAgICAgIGZvbnREaWN0VHJhY2tlcnMucHVzaChmb250RGljdFRyYWNrZXIpOwogICAgICBmZEFycmF5SW5kZXguYWRkKGZvbnREaWN0RGF0YSk7CiAgICAgIGZvbnREaWN0VHJhY2tlci5vZmZzZXQobGVuZ3RoKTsKICAgIH0KICAgIGZkQXJyYXlJbmRleCA9IHRoaXMuY29tcGlsZUluZGV4KGZkQXJyYXlJbmRleCwgZm9udERpY3RUcmFja2Vycyk7CiAgICByZXR1cm4gewogICAgICB0cmFja2VyczogZm9udERpY3RUcm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IHByaXZhdGVEaWN0Lmhhc05hbWUoIlN1YnJzIikpIHsKICAgICAgICBjb25zdCBzdWJycyA9IHRoaXMuY29tcGlsZUluZGV4KHByaXZhdGVEaWN0LnN1YnJzSW5kZXgpOwogICAgICAgIHByaXZhdGVEaWN0VHJhY2tlci5zZXRFbnRyeUxvY2F0aW9uKCJTdWJycyIsIFtwcml2YXRlRGljdERhdGEubGVuZ3RoXSwgb3V0cHV0KTsKICAgICAgICBvdXRwdXQuYWRkKHN1YnJzKTsKICAgICAgfQogICAgfQogIH0KICBjb21waWxlRGljdChkaWN0LCBvZmZzZXRUcmFja2VyKSB7CiAgICBjb25zdCBvdXQgPSBbXTsKICAgIGZvciAoY29uc3Qga2V5IG9mIGRpY3Qub3JkZXIpIHsKICAgICAgaWYgKCEoa2V5IGluIGRpY3QudmFsdWVzKSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGxldCB2YWx1ZXMgPSBkaWN0LnZhbHVlc1trZXldOwogICAgICBsZXQgdHlwZXMgPSBkaWN0LnR5cGVzW2tleV07CiAgICAgIGlmICghQXJyYXkuaXNBcnJheSh0eXBlcykpIHsKICAgICAgICB0eXBlcyA9IFt0eXBlc107CiAgICAgIH0KICAgICAgaWYgKCFBcnJheS5pc0FycmF5KHZhbHVlcykpIHsKICAgICAgICB2YWx1ZXMgPSBbdmFsdWVzXTsKICAgICAgfQogICAgICBpZiAodmFsdWVzLmxlbmd0aCA9PT0gMCkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGZvciAobGV0IGogPSAwLCBqaiA9IHR5cGVzLmxlbmd0aDsgaiA8IGpqOyArK2opIHsKICAgICAgICBjb25zdCB0eXBlID0gdHlwZXNbal07CiAgICAgICAgY29uc3QgdmFsdWUgPSB2YWx1ZXNbal07CiAgICAgICAgc3dpdGNoICh0eXBlKSB7CiAgICAgICAgICBjYXNlICJudW0iOgogICAgICAgICAgY2FzZSAic2lkIjoKICAgICAgICAgICAgb3V0LnB1c2goLi4udGhpcy5lbmNvZGVOdW1iZXIodmFsdWUpKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICJvZmZzZXQiOgogICAgICAgICAgICBjb25zdCBuYW1lID0gZGljdC5rZXlUb05hbWVNYXBba2V5XTsKICAgICAgICAgICAgaWYgKCFvZmZzZXRUcmFja2VyLmlzVHJhY2tpbmcobmFtZSkpIHsKICAgICAgICAgICAgICBvZmZzZXRUcmFja2VyLnRyYWNrKG5hbWUsIG91dC5sZW5ndGgpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG91dC5wdXNoKDB4MWQsIDAsIDAsIDAsIDApOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgImFycmF5IjoKICAgICAgICAgIGNhc2UgImRlbHRhIjoKICAgICAgICAgICAgb3V0LnB1c2goLi4udGhpcy5lbmNvZGVOdW1iZXIodmFsdWUpKTsKICAgICAgICAgICAgZm9yIChsZXQgayA9IDEsIGtrID0gdmFsdWVzLmxlbmd0aDsgayA8IGtrOyArK2spIHsKICAgICAgICAgICAgICBvdXQucHVzaCguLi50aGlzLmVuY29kZU51bWJlcih2YWx1ZXNba10pKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcihgVW5rbm93biBkYXRhIHR5cGUgb2YgJHt0eXBlfWApOwogICAgICAgIH0KICAgICAgfQogICAgICBvdXQucHVzaCguLi5kaWN0Lm9wY29kZXNba2V5XSk7CiAgICB9CiAgICByZXR1cm4gb3V0OwogIH0KICBjb21waWxlU3RyaW5nSW5kZXgoc3RyaW5ncykgewogICAgY29uc3Qgc3RyaW5nSW5kZXggPSBuZXcgQ0ZGSW5kZXgoKTsKICAgIGZvciAoY29uc3Qgc3RyaW5nIG9mIHN0cmluZ3MpIHsKICAgICAgc3RyaW5nSW5kZXguYWRkKCgwLCBfdXRpbC5zdHJpbmdUb0J5dGVzKShzdHJpbmcpKTsKICAgIH0KICAgIHJldHVybiB0aGlzLmNvbXBpbGVJbmRleChzdHJpbmdJbmRleCk7CiAgfQogIGNvbXBpbGVHbG9iYWxTdWJySW5kZXgoKSB7CiAgICBjb25zdCBnbG9iYWxTdWJySW5kZXggPSB0aGlzLmNmZi5nbG9iYWxTdWJySW5kZXg7CiAgICB0aGlzLm91dC53cml0ZUJ5dGVBcnJheSh0aGlzLmNvbXBpbGVJbmRleChnbG9iYWxTdWJySW5kZXgpKTsKICB9CiAgY29tcGlsZUNoYXJTdHJpbmdzKGNoYXJTdHJpbmdzKSB7CiAgICBjb25zdCBjaGFyU3RyaW5nc0luZGV4ID0gbmV3IENGRkluZGV4KCk7CiAgICBmb3IgKGxldCBpID0gMDsgaSA8IGNoYXJTdHJpbmdzLmNvdW50OyBpKyspIHsKICAgICAgY29uc3QgZ2x5cGggPSBjaGFyU3RyaW5ncy5nZXQoaSk7CiAgICAgIGlmIChnbHlwaC5sZW5ndGggPT09IDApIHsKICAgICAgICBjaGFyU3RyaW5nc0luZGV4LmFkZChuZXcgVWludDhBcnJheShbMHg4YiwgMHgwZV0pKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjaGFyU3RyaW5nc0luZGV4LmFkZChnbHlwaCk7CiAgICB9CiAgICByZXR1cm4gdGhpcy5jb21waWxlSW5kZXgoY2hhclN0cmluZ3NJbmRleCk7CiAgfQogIGNvbXBpbGVDaGFyc2V0KGNoYXJzZXQsIG51bUdseXBocywgc3RyaW5ncywgaXNDSURGb250KSB7CiAgICBsZXQgb3V0OwogICAgY29uc3QgbnVtR2x5cGhzTGVzc05vdERlZiA9IG51bUdseXBocyAtIDE7CiAgICBpZiAoaXNDSURGb250KSB7CiAgICAgIG91dCA9IG5ldyBVaW50OEFycmF5KFsyLCAwLCAwLCBudW1HbHlwaHNMZXNzTm90RGVmID4+IDggJiAweGZmLCBudW1HbHlwaHNMZXNzTm90RGVmICYgMHhmZl0pOwogICAgfSBlbHNlIHsKICAgICAgY29uc3QgbGVuZ3RoID0gMSArIG51bUdseXBoc0xlc3NOb3REZWYgKiAyOwogICAgICBvdXQgPSBuZXcgVWludDhBcnJheShsZW5ndGgpOwogICAgICBvdXRbMF0gPSAwOwogICAgICBsZXQgY2hhcnNldEluZGV4ID0gMDsKICAgICAgY29uc3QgbnVtQ2hhcnNldHMgPSBjaGFyc2V0LmNoYXJzZXQubGVuZ3RoOwogICAgICBsZXQgd2FybmVkID0gZmFsc2U7CiAgICAgIGZvciAobGV0IGkgPSAxOyBpIDwgb3V0Lmxlbmd0aDsgaSArPSAyKSB7CiAgICAgICAgbGV0IHNpZCA9IDA7CiAgICAgICAgaWYgKGNoYXJzZXRJbmRleCA8IG51bUNoYXJzZXRzKSB7CiAgICAgICAgICBjb25zdCBuYW1lID0gY2hhcnNldC5jaGFyc2V0W2NoYXJzZXRJbmRleCsrXTsKICAgICAgICAgIHNpZCA9IHN0cmluZ3MuZ2V0U0lEKG5hbWUpOwogICAgICAgICAgaWYgKHNpZCA9PT0gLTEpIHsKICAgICAgICAgICAgc2lkID0gMDsKICAgICAgICAgICAgaWYgKCF3YXJuZWQpIHsKICAgICAgICAgICAgICB3YXJuZWQgPSB0cnVlOwogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgQ291bGRuJ3QgZmluZCAke25hbWV9IGluIENGRiBzdHJpbmdzYCk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgb3V0W2ldID0gc2lkID4+IDggJiAweGZmOwogICAgICAgIG91dFtpICsgMV0gPSBzaWQgJiAweGZmOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gdGhpcy5jb21waWxlVHlwZWRBcnJheShvdXQpOwogIH0KICBjb21waWxlRW5jb2RpbmcoZW5jb2RpbmcpIHsKICAgIHJldHVybiB0aGlzLmNvbXBpbGVUeXBlZEFycmF5KGVuY29kaW5nLnJhdyk7CiAgfQogIGNvbXB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ZmOwogICAgICAgIHJhbmdlc1syXSA9IG51bVJhbmdlcyAmIDB4ZmY7CiAgICAgICAgcmFuZ2VzLnB1c2goaSA+PiA4ICYgMHhmZiwgaSAmIDB4ZmYpOwogICAgICAgIG91dCA9IG5ldyBVaW50OEFycmF5KHJhbmdlcyk7CiAgICAgICAgYnJlYWs7CiAgICB9CiAgICByZXR1cm4gdGhpcy5jb21waWxlVHlwZWRBcnJheShvdXQpOwogIH0KICBjb21waWxlVHlwZWRBcnJheShkYXRhKSB7CiAgICBjb25zdCBvdXQgPSBbXTsKICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGRhdGEubGVuZ3RoOyBpIDwgaWk7ICsraSkgewogICAgICBvdXRbaV0gPSBkYXRhW2ldOwogICAgfQogICAgcmV0dXJuIG91dDsKICB9CiAgY29tcGlsZUluZGV4KGluZGV4KSB7CiAgICBsZXQgdHJhY2tlcnMgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IFtdOwogICAgY29uc3Qgb2JqZWN0cyA9IGluZGV4Lm9iamVjdHM7CiAgICBjb25zdCBjb3VudCA9IG9iamVjdHMubGVuZ3RoOwogICAgaWYgKGNvdW50ID09PSAwKSB7CiAgICAgIHJldHVybiBbMCwgMF07CiAgICB9CiAgICBjb25zdCBkYXRhID0gW2NvdW50ID4+IDggJiAweGZmLCBjb3VudCAmIDB4ZmZdOwogICAgbGV0IGxhc3RPZmZzZXQgPSAxLAogICAgICBpOwogICAgZm9yIChpID0gMDsgaSA8IGNvdW50OyArK2kpIHsKICAgICAgbGFzdE9mZnNldCArPSBvYmplY3RzW2ldLmxlbmd0aDsKICAgIH0KICAgIGxldCBvZmZzZXRTaXplOwogICAgaWYgKGxhc3RPZmZzZXQgPCAweDEwMCkgewogICAgICBvZmZzZXRTaXplID0gMTsKICAgIH0gZWxzZSBpZiAobGFzdE9mZnNldCA8IDB4MTAwMD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ICAiYXRpbGRlIiwKICAweDAwZTMsCiAgImF0bW9ub3NwYWNlIiwKICAweGZmMjAsCiAgImF0c21hbGwiLAogIDB4ZmU2YiwKICAiYXR1cm5lZCIsCiAgMHgwMjUwLAogICJhdWJlbmdhbGkiLAogIDB4MDk5NCwKICAiYXVib3BvbW9mbyIsCiAgMHgzMTIwLAogICJhdWRldmEiLAogIDB4MDkxNCwKICAiYXVndWphcmF0aSIsCiAgMHgwYTk0LAogICJhdWd1cm11a2hpIiwKICAweDBhMTQsCiAgImF1bGVuZ3RobWFya2JlbmdhbGkiLAogIDB4MDlkNywKICAiYXVtYXRyYWd1cm11a2hpIiwKICAweDBhNGMsCiAgImF1dm93ZWxzaWduYmVuZ2FsaSIsCiAgMHgwOWNjLAogICJhdXZvd2Vsc2lnbmRldmEiLAogIDB4MDk0YywKICAiYXV2b3dlbHNpZ25ndWphcmF0aSIsCiAgMHgwYWNjLAogICJhdmFncmFoYWRldmEiLAogIDB4MDkzZCwKICAiYXliYXJtZW5pYW4iLAogIDB4MDU2MSwKICAiYXlpbiIsCiAgMHgwNWUyLAogICJheWluYWx0b25laGVicmV3IiwKICAweGZiMjAsCiAgImF5aW5oZWJyZXciLAogIDB4MDVlMiwKICAiYiIsCiAgMHgwMDYyLAogICJiYWJlbmdhbGkiLAogIDB4MDlhYywKICAiYmFja3NsYXNoIiwKICAweDAwNWMsCiAgImJhY2tzbGFzaG1vbm9zcGFjZSIsCiAgMHhmZjNjLAogICJiYWRldmEiLAogIDB4MDkyYywKICAiYmFndWphcmF0aSIsCiAgMHgwYWFjLAogICJiYWd1cm11a2hpIiwKICAweDBhMmMsCiAgImJhaGlyYWdhbmEiLAogIDB4MzA3MCwKICAiYmFodHRoYWkiLAogIDB4MGUzZiwKICAiYmFrYXRha2FuYSIsCiAgMHgzMGQwLAogICJiYXIiLAogIDB4MDA3YywKICAiYmFybW9ub3NwYWNlIiwKICAweGZmNWMsCiAgImJib3BvbW9mbyIsCiAgMHgzMTA1LAogICJi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zcGFjZSIsCiAgMHhmZjNiLAogICJicmFja2V0bGVmdHRwIiwKICAweGY4ZWUsCiAgImJyYWNrZXRyaWdodCIsCiAgMHgwMDVkLAogICJicmFja2V0cmlnaHRidCIsCiAgMHhmOGZiLAogICJicmFja2V0cmlnaHRleCIsCiAgMHhmOGZhLAogICJicmFja2V0cmlnaHRtb25vc3BhY2UiLAogIDB4ZmYzZCwKICAiYnJhY2tldHJpZ2h0dHAiLAogIDB4ZjhmOSwKICAiYnJldmUiLAogIDB4MDJkOCwKICAiYnJldmViZWxvd2NtYiIsCiAgMHgwMzJlLAogICJicmV2ZWNtYiIsCiAgMHgwMzA2LAogICJicmV2ZWludmVydGVkYmVsb3djbWIiLAogIDB4MDMyZiwKICAiYnJldmVpbnZlcnRlZGNtYiIsCiAgMHgwMzExLAogICJicmV2ZWludmVydGVkZG91YmxlY21iIiwKICAweDAzNjEsCiAgImJyaWRnZWJlbG93Y21iIiwKICAweDAzMmEsCiAgImJyaWRnZWludmVydGVkYmVsb3djbWIiLAogIDB4MDMzYSwKICAiYnJva2VuYmFyIiwKICAweDAwYTYsCiAgImJzdHJva2UiLAogIDB4MDE4MCwKICAiYnN1cGVyaW9yIiwKICAweGY2ZWEsCiAgImJ0b3BiYXIiLAogIDB4MDE4MywKICAiYnVoaXJhZ2FuYSIsCiAgMHgzMDc2LAogICJidWthdGFrYW5hIiwKICAweDMwZDYsCiAgImJ1bGxldCIsCiAgMHgyMDIyLAogICJidWxsZXRpbnZlcnNlIiwKICAweDI1ZDgsCiAgImJ1bGxldG9wZXJhdG9yIiwKICAweDIyMTksCiAgImJ1bGxzZXllIiwKICAweDI1Y2UsCiAgImMiLAogIDB4MDA2MywKICAiY2Fhcm1lbmlhbiIsCiAgMHgwNTZlLAogICJjYWJlbmdhbGkiLAogIDB4MDk5YSwKICAiY2FjdXRlIiwKICAweDAxMDcsCiAgImNhZGV2YSIsCiAgMHgwOTFhLAogICJjYWd1amFyYXRpIiwKICAweDBhOWEsCiAgImN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TEsCiAgImNvbG9uc21hbGwiLAogIDB4ZmU1NSwKICAiY29sb250cmlhbmd1bGFyaGFsZm1vZCIsCiAgMHgwMmQxLAogICJjb2xvbnRyaWFuZ3VsYXJtb2QiLAogIDB4MDJkMCwKICAiY29tbWEiLAogIDB4MDAyYywKICAiY29tbWFhYm92ZWNtYiIsCiAgMHgwMzEzLAogICJjb21tYWFib3ZlcmlnaHRjbWIiLAogIDB4MDMxNSwKICAiY29tbWFhY2NlbnQiLAogIDB4ZjZjMywKICAiY29tbWFhcmFiaWMiLAogIDB4MDYwYywKICAiY29tbWFhcm1lbmlhbiIsCiAgMHgwNTVkLAogICJjb21tYWluZmVyaW9yIiwKICAweGY2ZTEsCiAgImNvbW1hbW9ub3NwYWNlIiwKICAweGZmMGMsCiAgImNvbW1hcmV2ZXJzZWRhYm92ZWNtYiIsCiAgMHgwMzE0LAogICJjb21tYXJldmVyc2VkbW9kIiwKICAweDAyYmQsCiAgImNvbW1hc21hbGwiLAogIDB4ZmU1MCwKICAiY29tbWFzdXBlcmlvciIsCiAgMHhmNmUyLAogICJjb21tYXR1cm5lZGFib3ZlY21iIiwKICAweDAzMTIsCiAgImNvbW1hdHVybmVkbW9kIiwKICAweDAyYmIsCiAgImNvbXBhc3MiLAogIDB4MjYzYywKICAiY29uZ3J1ZW50IiwKICAweDIyNDUsCiAgImNvbnRvdXJpbnRlZ3JhbCIsCiAgMHgyMjJlLAogICJjb250cm9sIiwKICAweDIzMDMsCiAgImNvbnRyb2xBQ0siLAogIDB4MDAwNiwKICAiY29udHJvbEJFTCIsCiAgMHgwMDA3LAogICJjb250cm9sQlMiLAogIDB4MDAwOCwKICAiY29udHJvbENBTiIsCiAgMHgwMDE4LAogICJjb250cm9sQ1IiLAogIDB4MDAwZCwKICAiY29udHJvbERDMSIsCiAgMHgwMDExLAogICJjb250cm9sREMyIiwKICAweDAwMTIsCiAgImNvbnRyb2xEQzMiLAogIDB4MDAxMywKICAiY29udHJvbERDNCIsCiAgMHgwMDE0LAogICJjb250cm9sREVMIiwKICAweDAwN2YsCiAgImNvbnRyb2xETEUiLAogIDB4MDAxMCwKICAiY29udHJvbEVNIiwKICAweDAwMTksCiAgImNvbnRyb2xFTlEiLAogIDB4MDAwNSwKICAiY29udHJvbEVPVCIsCiAgMHgwMDA0LAogICJjb250cm9sRVNDIiwKICAweDAwMWIsCiAgImNvbnRyb2xFVEIiLAogIDB4MDAxNywKICAiY29udHJvbEVUWCIsCiAgMHgwMDAzLAogICJjb250cm9sRkYiLAogIDB4MDAwYywKICAiY29udHJvbEZTIiwKICAweDAwMWMsCiAgImNvbnRyb2xHUyIsCiAgMHgwMDFkLAogICJjb250cm9sSFQiLAogIDB4MDAwOSwKICAiY29udHJvbExGIiwKICAweDAwMGEsCiAgImNvbnRyb2xOQUsiLAogIDB4MDAxNSwKICAiY29udHJvbE5VTEwiLAogIDB4MDAwMCwKICAiY29udHJvbFJTIiwKICAweDAwMWUsCiAgImNvbnRyb2xTSSIsCiAgMHgwMDBmLAogICJjb250cm9sU08iLAogIDB4MDAwZSwKICAiY29udHJvbFNPVCIsCiAgMHgwMDAyLAogICJjb250cm9sU1RYIiwKICAweDAwMDEsCiAgImNvbnRyb2xTVUIiLAogIDB4MDAxYSwKICAiY29udHJvbFNZTiIsCiAgMHgwMDE2LAogICJjb250cm9sVVMiLAogIDB4MDAxZiwKICAiY29udHJvbFZUIiwKICAweDAwMGIsCiAgImNvcHlyaWdodCIsCiAgMHgwMGE5LAogICJjb3B5cmlnaHRzYW5zIiwKICAweGY4ZTksCiAgImNvcHlyaWdodHNlcmlmIiwKICAweGY2ZDksCiAgImNvcm5lcmJyYWNrZXRsZWZ0IiwKICAweDMwMGMsCiAgImNvcm5lcmJyYWNrZXRsZWZ0aGFsZndpZHRoIiwKICAweGZmNjIsCiAgImNvcm5lcmJyYWNrZXRsZWZ0dmVydGljYWwiLAogIDB4ZmU0MSwKICAiY29ybmVyYnJhY2tldHJpZ2h0IiwKICAweDMwMGQsCiAgImNvcm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aSIsCiAgMHgwZTJiLAogICJob2hpcmFnYW5hIiwKICAweDMwN2IsCiAgImhva2F0YWthbmEiLAogIDB4MzBkYiwKICAiaG9rYXRha2FuYWhhbGZ3aWR0aCIsCiAgMHhmZjhlLAogICJob2xhbSIsCiAgMHgwNWI5LAogICJob2xhbTE5IiwKICAweDA1YjksCiAgImhvbGFtMjYiLAogIDB4MDViOSwKICAiaG9sYW0zMiIsCiAgMHgwNWI5LAogICJob2xhbWhlYnJldyIsCiAgMHgwNWI5LAogICJob2xhbW5hcnJvd2hlYnJldyIsCiAgMHgwNWI5LAogICJob2xhbXF1YXJ0ZXJoZWJyZXciLAogIDB4MDViOSwKICAiaG9sYW13aWRlaGVicmV3IiwKICAweDA1YjksCiAgImhvbm9raHVrdGhhaSIsCiAgMHgwZTJlLAogICJob29rYWJvdmVjb21iIiwKICAweDAzMDksCiAgImhvb2tjbWIiLAogIDB4MDMwOSwKICAiaG9va3BhbGF0YWxpemVkYmVsb3djbWIiLAogIDB4MDMyMSwKICAiaG9va3JldHJvZmxleGJlbG93Y21iIiwKICAweDAzMjIsCiAgImhvb25zcXVhcmUiLAogIDB4MzM0MiwKICAiaG9yaWNvcHRpYyIsCiAgMHgwM2U5LAogICJob3Jpem9udGFsYmFyIiwKICAweDIwMTUsCiAgImhvcm5jbWIiLAogIDB4MDMxYiwKICAiaG90c3ByaW5ncyIsCiAgMHgyNjY4LAogICJob3VzZSIsCiAgMHgyMzAyLAogICJocGFyZW4iLAogIDB4MjRhMywKICAiaHN1cGVyaW9yIiwKICAweDAyYjAsCiAgImh0dXJuZWQiLAogIDB4MDI2NSwKICAiaHVoaXJhZ2FuYSIsCiAgMHgzMDc1LAogICJodWlpdG9zcXVhcmUiLAogIDB4MzMzMywKICAiaHVrYXRha2FuYSIsCiAgMHgzMGQ1LAogICJodWthdGFrYW5haGFsZndpZHRoIiwKICAweGZmOGMsCiAgImh1bmdhcnVtbGF1dCIsCiAgMHgwMmRkLAogICJodW5nYXJ1bWxhd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ZWFuIiwKICAweDMxNjMsCiAgImlsZGUiLAogIDB4MDJkYywKICAiaWx1eWhlYnJldyIsCiAgMHgwNWFjLAogICJpbWFjcm9uIiwKICAweDAxMmIsCiAgImltYWNyb25jeXJpbGxpYyIsCiAgMHgwNGUzLAogICJpbWFnZW9yYXBwcm94aW1hdGVseWVxdWFsIiwKICAweDIyNTMsCiAgImltYXRyYWd1cm11a2hpIiwKICAweDBhM2YsCiAgImltb25vc3BhY2UiLAogIDB4ZmY0OSwKICAiaW5jcmVtZW50IiwKICAweDIyMDYsCiAgImluZmluaXR5IiwKICAweDIyMWUsCiAgImluaWFybWVuaWFuIiwKICAweDA1NmIsCiAgImludGVncmFsIiwKICAweDIyMmIsCiAgImludGVncmFsYm90dG9tIiwKICAweDIzMjEsCiAgImludGVncmFsYnQiLAogIDB4MjMyMSwKICAiaW50ZWdyYWxleCIsCiAgMHhmOGY1LAogICJpbnRlZ3JhbHRvcCIsCiAgMHgyMzIwLAogICJpbnRlZ3JhbHRwIiwKICAweDIzMjAsCiAgImludGVyc2VjdGlvbiIsCiAgMHgyMjI5LAogICJpbnRpc3F1YXJlIiwKICAweDMzMDUsCiAgImludmJ1bGxldCIsCiAgMHgyNWQ4LAogICJpbnZjaXJjbGUiLAogIDB4MjVkOSwKICAiaW52c21pbGVmYWNlIiwKICAweDI2M2IsCiAgImlvY3lyaWxsaWMiLAogIDB4MDQ1MSwKICAiaW9nb25layIsCiAgMHgwMTJmLAogICJpb3RhIiwKICAweDAzYjksCiAgImlvdGFkaWVyZXNpcyIsCiAgMHgwM2NhLAogICJpb3RhZGllcmVzaXN0b25vcyIsCiAgMHgwMzkwLAogICJpb3RhbGF0aW4iLAogIDB4MDI2OSwKICAiaW90YXRvbm9zIiwKICAweDAzYWYsCiAgImlwYXJlbiIsCiAgMHgyNGE0LAogICJpcmlndXJtdWtoaSIsCiAgMHgwYTcyLAogICJpc21hbGxoaXJhZ2FuYSIsCiAgMHgzMDQzLAogICJpc21hbGxrYXRha2F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ljIiwKICAweGZlOWUsCiAgImplZW1pbml0aWFsYXJhYmljIiwKICAweGZlOWYsCiAgImplZW1tZWRpYWxhcmFiaWMiLAogIDB4ZmVhMCwKICAiamVoYXJhYmljIiwKICAweDA2OTgsCiAgImplaGZpbmFsYXJhYmljIiwKICAweGZiOGIsCiAgImpoYWJlbmdhbGkiLAogIDB4MDk5ZCwKICAiamhhZGV2YSIsCiAgMHgwOTFkLAogICJqaGFndWphcmF0aSIsCiAgMHgwYTlkLAogICJqaGFndXJtdWtoaSIsCiAgMHgwYTFkLAogICJqaGVoYXJtZW5pYW4iLAogIDB4MDU3YiwKICAiamlzIiwKICAweDMwMDQsCiAgImptb25vc3BhY2UiLAogIDB4ZmY0YSwKICAianBhcmVuIiwKICAweDI0YTUsCiAgImpzdXBlcmlvciIsCiAgMHgwMmIyLAogICJrIiwKICAweDAwNmIsCiAgImthYmFzaGtpcmN5cmlsbGljIiwKICAweDA0YTEsCiAgImthYmVuZ2FsaSIsCiAgMHgwOTk1LAogICJrYWN1dGUiLAogIDB4MWUzMSwKICAia2FjeXJpbGxpYyIsCiAgMHgwNDNhLAogICJrYWRlc2NlbmRlcmN5cmlsbGljIiwKICAweDA0OWIsCiAgImthZGV2YSIsCiAgMHgwOTE1LAogICJrYWYiLAogIDB4MDVkYiwKICAia2FmYXJhYmljIiwKICAweDA2NDMsCiAgImthZmRhZ2VzaCIsCiAgMHhmYjNiLAogICJrYWZkYWdlc2hoZWJyZXciLAogIDB4ZmIzYiwKICAia2FmZmluYWxhcmFiaWMiLAogIDB4ZmVkYSwKICAia2FmaGVicmV3IiwKICAweDA1ZGIsCiAgImthZmluaXRpYWxhcmFiaWMiLAogIDB4ZmVkYiwKICAia2FmbWVkaWFsYXJhYmljIiwKICAweGZlZGMsCiAgImthZnJhZmVoZWJyZXciLAogIDB4ZmI0ZCwKICAia2FndWphcmF0aSIsCiAgMHgwYTk1LAogICJrYWd1cm11a2hpIiwKICAweDBhMTUsCiAgImthaGlyYWdhbmEi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wNTg0LAogICJrZWhpcmFnYW5hIiwKICAweDMwNTEsCiAgImtla2F0YWthbmEiLAogIDB4MzBiMSwKICAia2VrYXRha2FuYWhhbGZ3aWR0aCIsCiAgMHhmZjc5LAogICJrZW5hcm1lbmlhbiIsCiAgMHgwNTZmLAogICJrZXNtYWxsa2F0YWthbmEiLAogIDB4MzBmNiwKICAia2dyZWVubGFuZGljIiwKICAweDAxMzgsCiAgImtoYWJlbmdhbGkiLAogIDB4MDk5NiwKICAia2hhY3lyaWxsaWMiLAogIDB4MDQ0NSwKICAia2hhZGV2YSIsCiAgMHgwOTE2LAogICJraGFndWphcmF0aSIsCiAgMHgwYTk2LAogICJraGFndXJtdWtoaSIsCiAgMHgwYTE2LAogICJraGFoYXJhYmljIiwKICAweDA2MmUsCiAgImtoYWhmaW5hbGFyYWJpYyIsCiAgMHhmZWE2LAogICJraGFoaW5pdGlhbGFyYWJpYyIsCiAgMHhmZWE3LAogICJraGFobWVkaWFsYXJhYmljIiwKICAweGZlYTgsCiAgImtoZWljb3B0aWMiLAogIDB4MDNlNywKICAia2hoYWRldmEiLAogIDB4MDk1OSwKICAia2hoYWd1cm11a2hpIiwKICAweDBhNTksCiAgImtoaWV1a2hhY2lyY2xla29yZWFuIiwKICAweDMyNzgsCiAgImtoaWV1a2hhcGFyZW5rb3JlYW4iLAogIDB4MzIxOCwKICAia2hpZXVraGNpcmNsZWtvcmVhbiIsCiAgMHgzMjZhLAogICJraGlldWtoa29yZWFuIiwKICAweDMxNGIsCiAgImtoaWV1a2hwYXJlbmtvcmVhbiIsCiAgMHgzMjBhLAogICJraG9raGFpdGhhaSIsCiAgMHgwZTAyLAogICJraG9raG9udGhhaSIsCiAgMHgwZTA1LAogICJraG9raHVhdHRoYWkiLAogIDB4MGUwMywKICAia2hva2h3YWl0aGFpIiwKICAweDBlMDQsCiAgImtob211dHRoYWkiLAogIDB4MGU1YiwKICAia2hvb2siLAogIDB4MDE5OSwKICAia2hvcmFraGFuZ3RoYWkiLAogIDB4MGUwNiwKICAia2h6c3F1YXJlIiwKICAweDMzOTEsCiAgImtpaGlyYWdhbmEiLAogIDB4MzA0ZCwKICAia2lrYXRha2FuYSIsCiAgMHgzMGFkLAogICJraWthdGFrYW5haGFsZndpZHRoIiwKICAweGZmNzcsCiAgImtpcm9ndXJhbXVzcXVhcmUiLAogIDB4MzMxNSwKICAia2lyb21lZXRvcnVzcXVhcmUiLAogIDB4MzMxNiwKICAia2lyb3NxdWFyZSIsCiAgMHgzMzE0LAogICJraXllb2thY2lyY2xla29yZWFuIiwKICAweDMyNmUsCiAgImtpeWVva2FwYXJlbmtvcmVhbiIsCiAgMHgzMjBlLAogICJraXllb2tjaXJjbGVrb3JlYW4iLAogIDB4MzI2MCwKICAia2l5ZW9ra29yZWFuIiwKICAweDMxMzEsCiAgImtpeWVva3BhcmVua29yZWFuIiwKICAweDMyMDAsCiAgImtpeWVva3Npb3Nrb3JlYW4iLAogIDB4MzEzMywKICAia2plY3lyaWxsaWMiLAogIDB4MDQ1YywKICAia2xpbmViZWxvdyIsCiAgMHgxZTM1LAogICJrbHNxdWFyZSIsCiAgMHgzMzk4LAogICJrbWN1YmVkc3F1YXJlIiwKICAweDMzYTYsCiAgImttb25vc3BhY2UiLAogIDB4ZmY0YiwKICAia21zcXVhcmVkc3F1YXJlIiwKICAweDMzYTIsCiAgImtvaGlyYWdhbmEiLAogIDB4MzA1MywKICAia29obXNxdWFyZSIsCiAgMHgzM2MwLAogICJrb2thaXRoYWkiLAogIDB4MGUwMSwKICAia29rYXRha2FuYSIsCiAgMHgzMGIzLAogICJrb2thdGFrYW5haGFsZndpZHRoIiwKICAweGZmN2EsCiAgImtvb3Bvc3F1YXJlIiwKICAweDMzMWUsCiAgImtvcHBhY3lyaWxsaWMiLAogIDB4MDQ4MSwKICAia29yZWFuc3RhbmRhcmRzeW1ib2wiLAogIDB4MzI3ZiwKICAia29yb25pc2NtYiIsCiAgMHgwMzQzLAogICJrcGFyZW4iLAogIDB4MjRhNiwKICA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VjY2VlZHMiLAogIDB4MjI4MSwKICAibm90c3VwZXJzZXQiLAogIDB4MjI4NSwKICAibm93YXJtZW5pYW4iLAogIDB4MDU3NiwKICAibnBhcmVuIiwKICAweDI0YTksCiAgIm5zc3F1YXJlIiwKICAweDMzYjEsCiAgIm5zdXBlcmlvciIsCiAgMHgyMDdmLAogICJudGlsZGUiLAogIDB4MDBmMSwKICAibnUiLAogIDB4MDNiZCwKICAibnVoaXJhZ2FuYSIsCiAgMHgzMDZjLAogICJudWthdGFrYW5hIiwKICAweDMwY2MsCiAgIm51a2F0YWthbmFoYWxmd2lkdGgiLAogIDB4ZmY4NywKICAibnVrdGFiZW5nYWxpIiwKICAweDA5YmMsCiAgIm51a3RhZGV2YSIsCiAgMHgwOTNjLAogICJudWt0YWd1amFyYXRpIiwKICAweDBhYmMsCiAgIm51a3RhZ3VybXVraGkiLAogIDB4MGEzYywKICAibnVtYmVyc2lnbiIsCiAgMHgwMDIzLAogICJudW1iZXJzaWdubW9ub3NwYWNlIiwKICAweGZmMDMsCiAgIm51bWJlcnNpZ25zbWFsbCIsCiAgMHhmZTVmLAogICJudW1lcmFsc2lnbmdyZWVrIiwKICAweDAzNzQsCiAgIm51bWVyYWxzaWdubG93ZXJncmVlayIsCiAgMHgwMzc1LAogICJudW1lcm8iLAogIDB4MjExNiwKICAibnVuIiwKICAweDA1ZTAsCiAgIm51bmRhZ2VzaCIsCiAgMHhmYjQwLAogICJudW5kYWdlc2hoZWJyZXciLAogIDB4ZmI0MCwKICAibnVuaGVicmV3IiwKICAweDA1ZTAsCiAgIm52c3F1YXJlIiwKICAweDMzYjUsCiAgIm53c3F1YXJlIiwKICAweDMzYmIsCiAgIm55YWJlbmdhbGkiLAogIDB4MDk5ZSwKICAibnlhZGV2YSIsCiAgMHgwOTFlLAogICJueWFndWphcmF0aSIsCiAgMHgwYTllLAogICJueWFndXJtdWtoaSIsCiAgMHgwYTFlLAogICJvIiwKICAweDAwNmYsCiAgIm9hY3V0ZSIsCiA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CiAgMHhmZTM1LAogICJwYXJlbnJpZ2h0IiwKICAweDAwMjksCiAgInBhcmVucmlnaHRhbHRvbmVhcmFiaWMiLAogIDB4ZmQzZiwKICAicGFyZW5yaWdodGJ0IiwKICAweGY4ZjgsCiAgInBhcmVucmlnaHRleCIsCiAgMHhmOGY3LAogICJwYXJlbnJpZ2h0aW5mZXJpb3IiLAogIDB4MjA4ZSwKICAicGFyZW5yaWdodG1vbm9zcGFjZSIsCiAgMHhmZjA5LAogICJwYXJlbnJpZ2h0c21hbGwiLAogIDB4ZmU1YSwKICAicGFyZW5yaWdodHN1cGVyaW9yIiwKICAweDIwN2UsCiAgInBhcmVucmlnaHR0cCIsCiAgMHhmOGY2LAogICJwYXJlbnJpZ2h0dmVydGljYWwiLAogIDB4ZmUzNiwKICAicGFydGlhbGRpZmYiLAogIDB4MjIwMiwKICAicGFzZXFoZWJyZXciLAogIDB4MDVjMCwKICAicGFzaHRhaGVicmV3IiwKICAweDA1OTksCiAgInBhc3F1YXJlIiwKICAweDMzYTksCiAgInBhdGFoIiwKICAweDA1YjcsCiAgInBhdGFoMTEiLAogIDB4MDViNywKICAicGF0YWgxZCIsCiAgMHgwNWI3LAogICJwYXRhaDJhIiwKICAweDA1YjcsCiAgInBhdGFoaGVicmV3IiwKICAweDA1YjcsCiAgInBhdGFobmFycm93aGVicmV3IiwKICAweDA1YjcsCiAgInBhdGFocXVhcnRlcmhlYnJldyIsCiAgMHgwNWI3LAogICJwYXRhaHdpZGVoZWJyZXciLAogIDB4MDViNywKICAicGF6ZXJoZWJyZXciLAogIDB4MDVhMSwKICAicGJvcG9tb2ZvIiwKICAweDMxMDYsCiAgInBjaXJjbGUiLAogIDB4MjRkZiwKICAicGRvdGFjY2VudCIsCiAgMHgxZTU3LAogICJwZSIsCiAgMHgwNWU0LAogICJwZWN5cmlsbGljIiwKICAweDA0M2YsCiAgInBlZGFnZXNoIiwKICAweGZiNDQsCiAgInBlZGFnZXNoaGVicmV3IiwKICAweGZiNDQs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YmVuZ2FsaSIsCiAgMHgwOWFiLAogICJwaGFkZXZhIiwKICAweDA5MmIsCiAgInBoYWd1amFyYXRpIiwKICAweDBhYWIsCiAgInBoYWd1cm11a2hpIiwKICAweDBhMmIsCiAgInBoaSIsCiAgMHgwM2M2LAogICJwaGkxIiwKICAweDAzZDUsCiAgInBoaWV1cGhhY2lyY2xla29yZWFuIiwKICAweDMyN2EsCiAgInBoaWV1cGhhcGFyZW5rb3JlYW4iLAogIDB4MzIxYSwKICAicGhpZXVwaGNpcmNsZWtvcmVhbiIsCiAgMHgzMjZjLAogICJwaGlldXBoa29yZWFuIiwKICAweDMxNGQsCiAgInBoaWV1cGhwYXJlbmtvcmVhbiIsCiAgMHgzMjBjLAogICJwaGlsYXRpbiIsCiAgMHgwMjc4LAogICJwaGludGh1dGhhaSIsCiAgMHgwZTNhLAogICJwaGlzeW1ib2xncmVlayIsCiAgMHgwM2Q1LAogICJwaG9vayIsCiAgMHgwMWE1LAogICJwaG9waGFudGhhaSIsCiAgMHgwZTFlLAogICJwaG9waHVuZ3RoYWkiLAogIDB4MGUxYywKICAicGhvc2FtcGhhb3RoYWkiLAogIDB4MGUyMCwKICAicGkiLAogIDB4MDNjMCwKICAicGlldXBhY2lyY2xla29yZWFuIiwKICAweDMyNzMsCiAgInBpZXVwYXBhcmVua29yZWFuIiwKICAweDMyMTMsCiAgInBpZXVwY2lldWNrb3JlYW4iLAogIDB4MzE3NiwKICAicGlldXBjaXJjbGVrb3JlYW4iLAogIDB4MzI2NSwKICAicGlldXBraXllb2trb3JlYW4iLAogIDB4MzE3MiwKICAicGlldXBrb3JlYW4iLAogIDB4MzE0MiwKICAicGlldXBwYXJlbmtvcmVhbiIsCiAgMHgzMjA1LAogICJwaWV1cHNpb3NraXllb2trb3JlYW4iLAogIDB4MzE3NCwKICAicGlldXBzaW9za29yZWFuIiwKICAweDMxNDQsCiAgInBpZXVwc2lvc3Rpa2V1dGtvcmVhbiIsCiAgMHgzMTc1LAogICJwaWV1cH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sCiAgMHgyMjBmLAogICJwcm9qZWN0aXZlIiwKICAweDIzMDUsCiAgInByb2xvbmdlZGthbmEiLAogIDB4MzBmYywKICAicHJvcGVsbG9yIiwKICAweDIzMTgsCiAgInByb3BlcnN1YnNldCIsCiAgMHgyMjgyLAogICJwcm9wZXJzdXBlcnNldCIsCiAgMHgyMjgzLAogICJwcm9wb3J0aW9uIiwKICAweDIyMzcsCiAgInByb3BvcnRpb25hbCIsCiAgMHgyMjFkLAogICJwc2kiLAogIDB4MDNjOCwKICAicHNpY3lyaWxsaWMiLAogIDB4MDQ3MSwKICAicHNpbGlwbmV1bWF0YWN5cmlsbGljY21iIiwKICAweDA0ODYsCiAgInBzc3F1YXJlIiwKICAweDMzYjAsCiAgInB1aGlyYWdhbmEiLAogIDB4MzA3NywKICAicHVrYXRha2FuYSIsCiAgMHgzMGQ3LAogICJwdnNxdWFyZSIsCiAgMHgzM2I0LAogICJwd3NxdWFyZSIsCiAgMHgzM2JhLAogICJxIiwKICAweDAwNzEsCiAgInFhZGV2YSIsCiAgMHgwOTU4LAogICJxYWRtYWhlYnJldyIsCiAgMHgwNWE4LAogICJxYWZhcmFiaWMiLAogIDB4MDY0MiwKICAicWFmZmluYWxhcmFiaWMiLAogIDB4ZmVkNiwKICAicWFmaW5pdGlhbGFyYWJpYyIsCiAgMHhmZWQ3LAogICJxYWZtZWRpYWxhcmFiaWMiLAogIDB4ZmVkOCwKICAicWFtYXRzIiwKICAweDA1YjgsCiAgInFhbWF0czEwIiwKICAweDA1YjgsCiAgInFhbWF0czFhIiwKICAweDA1YjgsCiAgInFhbWF0czFjIiwKICAweDA1YjgsCiAgInFhbWF0czI3IiwKICAweDA1YjgsCiAgInFhbWF0czI5IiwKICAweDA1YjgsCiAgInFhbWF0czMzIiwKICAweDA1YjgsCiAgInFhbWF0c2RlIiwKICAweDA1YjgsCiAgInFhbWF0c2hlYnJldyIsCiAgMHgwNWI4LAogICJxYW1hdHNuYXJyb3doZWJyZXciLAogIDB4MDViOCwKICAicWFtYXRzcWF0YW5oZWJyZXciLAogIDB4MDViOCwKICAicWFtYXRzcWF0YW5uYXJyb3doZWJyZXciLAogIDB4MDViOCwKICAicWFtYXRzcWF0YW5xdWFydGVyaGVicmV3IiwKICAweDA1YjgsCiAgInFhbWF0c3FhdGFud2lkZWhlYnJldyIsCiAgMHgwNWI4LAogICJxYW1hdHNxdWFydGVyaGVicmV3IiwKICAweDA1YjgsCiAgInFhbWF0c3dpZGVoZWJyZXciLAogIDB4MDViOCwKICAicWFybmV5cGFyYWhlYnJldyIsCiAgMHgwNTlmLAogICJxYm9wb21vZm8iLAogIDB4MzExMSwKICAicWNpcmNsZSIsCiAgMHgyNGUwLAogICJxaG9vayIsCiAgMHgwMmEwLAogICJxbW9ub3NwYWNlIiwKICAweGZmNTEsCiAgInFvZiIsCiAgMHgwNWU3LAogICJxb2ZkYWdlc2giLAogIDB4ZmI0NywKICAicW9mZGFnZXNoaGVicmV3IiwKICAweGZiNDcsCiAgInFvZmhlYnJldyIsCiAgMHgwNWU3LAogICJxcGFyZW4iLAogIDB4MjRhYywKICAicXVhcnRlcm5vdGUiLAogIDB4MjY2OSwKICAicXVidXRzIiwKICAweDA1YmIsCiAgInF1YnV0czE4IiwKICAweDA1YmIsCiAgInF1YnV0czI1IiwKICAweDA1YmIsCiAgInF1YnV0czMxIiwKICAweDA1YmIsCiAgInF1YnV0c2hlYnJldyIsCiAgMHgwNWJiLAogICJxdWJ1dHNuYXJyb3doZWJyZXciLAogIDB4MDViYiwKICAicXVidXRzcXVhcnRlcmhlYnJldyIsCiAgMHgwNWJiLAogICJxdWJ1dHN3aWRlaGVicmV3IiwKICAweDA1YmIsCiAgInF1ZXN0aW9uIiwKICAweDAwM2YsCiAgInF1ZXN0aW9uYXJhYmljIiwKICAweDA2MWYsCiAgInF1ZXN0aW9uYXJtZW5pYW4iLAogIDB4MDU1ZSwKICAicXVlc3Rpb25kb3duIiwKICAweDAwYmYsCiAgInF1ZXN0aW9uZG93bnNtY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ZWJyZXciLAogIDB4MDViZiwKICAicmFndWphcmF0aSIsCiAgMHgwYWIwLAogICJyYWd1cm11a2hpIiwKICAweDBhMzAsCiAgInJhaGlyYWdhbmEiLAogIDB4MzA4OSwKICAicmFrYXRha2FuYSIsCiAgMHgzMGU5LAogICJyYWthdGFrYW5haGFsZndpZHRoIiwKICAweGZmOTcsCiAgInJhbG93ZXJkaWFnb25hbGJlbmdhbGkiLAogIDB4MDlmMSwKICAicmFtaWRkbGVkaWFnb25hbGJlbmdhbGkiLAogIDB4MDlmMCwKICAicmFtc2hvcm4iLAogIDB4MDI2NCwKICAicmF0aW8iLAogIDB4MjIzNiwKICAicmJvcG9tb2ZvIiwKICAweDMxMTYsCiAgInJjYXJvbiIsCiAgMHgwMTU5LAogICJyY2VkaWxsYSIsCiAgMHgwMTU3LAogICJyY2lyY2xlIiwKICAweDI0ZTEsCiAgInJjb21tYWFjY2VudCIsCiAgMHgwMTU3LAogICJyZGJsZ3JhdmUiLAogIDB4MDIxMSwKICAicmRvdGFjY2VudCIsCiAgMHgxZTU5LAogICJyZG90YmVsb3ciLAogIDB4MWU1YiwKICAicmRvdGJlbG93bWFjcm9uIiwKICAweDFlNWQsCiAgInJlZmVyZW5jZW1hcmsiLAogIDB4MjAzYiwKICAicmVmbGV4c3Vic2V0IiwKICAweDIyODYsCiAgInJlZmxleHN1cGVyc2V0IiwKICAweDIyODcsCiAgInJlZ2lzdGVyZWQiLAogIDB4MDBhZSwKICAicmVnaXN0ZXJzYW5zIiwKICAweGY4ZTgsCiAgInJlZ2lzdGVyc2VyaWYiLAogIDB4ZjZkYSwKICAicmVoYXJhYmljIiwKICAweDA2MzEsCiAgInJlaGFybWVuaWFuIiwKICAweDA1ODAsCiAgInJlaGZpbmFsYXJhYmljIiwKICAweGZlYWUsCiAgInJlaGlyYWdhbmEiLAogIDB4MzA4YywKICAicmVrYXRha2FuYSIsCiAgMHgzMGVjLAogICJyZWthdGFrYW5haGFsZndpZHRoIiwKICAweGZmOWEs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W5hcmFiaWMiLAogIDB4MDYzMywKICAic2VlbmZpbmFsYXJhYmljIiwKICAweGZlYjIsCiAgInNlZW5pbml0aWFsYXJhYmljIiwKICAweGZlYjMsCiAgInNlZW5tZWRpYWxhcmFiaWMiLAogIDB4ZmViNCwKICAic2Vnb2wiLAogIDB4MDViNiwKICAic2Vnb2wxMyIsCiAgMHgwNWI2LAogICJzZWdvbDFmIiwKICAweDA1YjYsCiAgInNlZ29sMmMiLAogIDB4MDViNiwKICAic2Vnb2xoZWJyZXciLAogIDB4MDViNiwKICAic2Vnb2xuYXJyb3doZWJyZXciLAogIDB4MDViNiwKICAic2Vnb2xxdWFydGVyaGVicmV3IiwKICAweDA1YjYsCiAgInNlZ29sdGFoZWJyZXciLAogIDB4MDU5MiwKICAic2Vnb2x3aWRlaGVicmV3IiwKICAweDA1YjYsCiAgInNlaGFybWVuaWFuIiwKICAweDA1N2QsCiAgInNlaGlyYWdhbmEiLAogIDB4MzA1YiwKICAic2VrYXRha2FuYSIsCiAgMHgzMGJiLAogICJzZWthdGFrYW5haGFsZndpZHRoIiwKICAweGZmN2UsCiAgInNlbWljb2xvbiIsCiAgMHgwMDNiLAogICJzZW1pY29sb25hcmFiaWMiLAogIDB4MDYxYiwKICAic2VtaWNvbG9ubW9ub3NwYWNlIiwKICAweGZmMWIsCiAgInNlbWljb2xvbnNtYWxsIiwKICAweGZlNTQsCiAgInNlbWl2b2ljZWRtYXJra2FuYSIsCiAgMHgzMDljLAogICJzZW1pdm9pY2VkbWFya2thbmFoYWxmd2lkdGgiLAogIDB4ZmY5ZiwKICAic2VudGlzcXVhcmUiLAogIDB4MzMyMiwKICAic2VudG9zcXVhcmUiLAogIDB4MzMyMywKICAic2V2ZW4iLAogIDB4MDAzNywKICAic2V2ZW5hcmFiaWMiLAogIDB4MDY2NywKICAic2V2ZW5iZW5nYWxpIiwKICAweDA5ZWQsCiAgInNldmVuY2lyY2xlIiwKICAweDI0NjYsCiAgInNldmVuY2lyY2xlaW52ZXJ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hcmFiaWMiLAogIDB4ZmM2MiwKICAic2hhZGRha2FzcmF0YW5hcmFiaWMiLAogIDB4ZmM1ZiwKICAic2hhZGUiLAogIDB4MjU5MiwKICAic2hhZGVkYXJrIiwKICAweDI1OTMsCiAgInNoYWRlbGlnaHQiLAogIDB4MjU5MSwKICAic2hhZGVtZWRpdW0iLAogIDB4MjU5MiwKICAic2hhZGV2YSIsCiAgMHgwOTM2LAogICJzaGFndWphcmF0aSIsCiAgMHgwYWI2LAogICJzaGFndXJtdWtoaSIsCiAgMHgwYTM2LAogICJzaGFsc2hlbGV0aGVicmV3IiwKICAweDA1OTMsCiAgInNoYm9wb21vZm8iLAogIDB4MzExNSwKICAic2hjaGFjeXJpbGxpYyIsCiAgMHgwNDQ5LAogICJzaGVlbmFyYWJpYyIsCiAgMHgwNjM0LAogICJzaGVlbmZpbmFsYXJhYmljIiwKICAweGZlYjYsCiAgInNoZWVuaW5pdGlhbGFyYWJpYyIsCiAgMHhmZWI3LAogICJzaGVlbm1lZGlhbGFyYWJpYyIsCiAgMHhmZWI4LAogICJzaGVpY29wdGljIiwKICAweDAzZTMsCiAgInNoZXFlbCIsCiAgMHgyMGFhLAogICJzaGVxZWxoZWJyZXciLAogIDB4MjBhYSwKICAic2hldmEiLAogIDB4MDViMCwKICAic2hldmExMTUiLAogIDB4MDViMCwKICAic2hldmExNSIsCiAgMHgwNWIwLAogICJzaGV2YTIyIiwKICAweDA1YjAsCiAgInNoZXZhMmUiLAogIDB4MDViMCwKICAic2hldmFoZWJyZXciLAogIDB4MDViMCwKICAic2hldmFuYXJyb3doZWJyZXciLAogIDB4MDViMCwKICAic2hldmFxdWFydGVyaGVicmV3IiwKICAweDA1YjAsCiAgInNoZXZhd2lkZWhlYnJldyIsCiAgMHgwNWIwLAogICJzaGhhY3lyaWxsaWMiLAogIDB4MDRiYiwKICAic2hpbWFjb3B0aWMiLAogIDB4MDNlZCwKICAic2hpbiIsCiAgMHgwNWU5LAogICJzaGluZGFnZXNoIiwK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yZiwKICAic2xhc2htb25vc3BhY2UiLAogIDB4ZmYwZiwKICAic2xvbmciLAogIDB4MDE3ZiwKICAic2xvbmdkb3RhY2NlbnQiLAogIDB4MWU5YiwKICAic21pbGVmYWNlIiwKICAweDI2M2EsCiAgInNtb25vc3BhY2UiLAogIDB4ZmY1MywKICAic29mcGFzdXFoZWJyZXciLAogIDB4MDVjMywKICAic29mdGh5cGhlbiIsCiAgMHgwMGFkLAogICJzb2Z0c2lnbmN5cmlsbGljIiwKICAweDA0NGMsCiAgInNvaGlyYWdhbmEiLAogIDB4MzA1ZCwKICAic29rYXRha2FuYSIsCiAgMHgzMGJkLAogICJzb2thdGFrYW5haGFsZndpZHRoIiwKICAweGZmN2YsCiAgInNvbGlkdXNsb25nb3ZlcmxheWNtYiIsCiAgMHgwMzM4LAogICJzb2xpZHVzc2hvcnRvdmVybGF5Y21iIiwKICAweDAzMzcsCiAgInNvcnVzaXRoYWkiLAogIDB4MGUyOSwKICAic29zYWxhdGhhaSIsCiAgMHgwZTI4LAogICJzb3NvdGhhaSIsCiAgMHgwZTBiLAogICJzb3N1YXRoYWkiLAogIDB4MGUyYSwKICAic3BhY2UiLAogIDB4MDAyMCwKICAic3BhY2VoYWNrYXJhYmljIiwKICAweDAwMjAsCiAgInNwYWRlIiwKICAweDI2NjAsCiAgInNwYWRlc3VpdGJsYWNrIiwKICAweDI2NjAsCiAgInNwYWRlc3VpdHdoaXRlIiwKICAweDI2NjQsCiAgInNwYXJlbiIsCiAgMHgyNGFlLAogICJzcXVhcmViZWxvd2NtYiIsCiAgMHgwMzNiLAogICJzcXVhcmVjYyIsCiAgMHgzM2M0LAogICJzcXVhcmVjbSIsCiAgMHgzMzlkLAogICJzcXVhcmVkaWFnb25hbGNyb3NzaGF0Y2hmaWxsIiwKICAweDI1YTksCiAgInNxdWFyZWhvcml6b250YWxmaWxsIiwKICAweDI1YTQsCiAgInNxdWFyZWtnIiwKICAweDMzOGYsCiAgInNxdWFyZWttIiwKICAweDMzOW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ZWVucGVyaW9kIiwKICAweDI0OTQsCiAgInRob25hbmdtb250aG90aGFpIiwKICAweDBlMTEsCiAgInRob29rIiwKICAweDAxYWQsCiAgInRob3BodXRoYW90aGFpIiwKICAweDBlMTIsCiAgInRob3JuIiwKICAweDAwZmUsCiAgInRob3RoYWhhbnRoYWkiLAogIDB4MGUxNywKICAidGhvdGhhbnRoYWkiLAogIDB4MGUxMCwKICAidGhvdGhvbmd0aGFpIiwKICAweDBlMTgsCiAgInRob3RodW5ndGhhaSIsCiAgMHgwZTE2LAogICJ0aG91c2FuZGN5cmlsbGljIiwKICAweDA0ODIsCiAgInRob3VzYW5kc3NlcGFyYXRvcmFyYWJpYyIsCiAgMHgwNjZjLAogICJ0aG91c2FuZHNzZXBhcmF0b3JwZXJzaWFuIiwKICAweDA2NmMsCiAgInRocmVlIiwKICAweDAwMzMsCiAgInRocmVlYXJhYmljIiwKICAweDA2NjMsCiAgInRocmVlYmVuZ2FsaSIsCiAgMHgwOWU5LAogICJ0aHJlZWNpcmNsZSIsCiAgMHgyNDYyLAogICJ0aHJlZWNpcmNsZWludmVyc2VzYW5zc2VyaWYiLAogIDB4Mjc4YywKICAidGhyZWVkZXZhIiwKICAweDA5NjksCiAgInRocmVlZWlnaHRocyIsCiAgMHgyMTVjLAogICJ0aHJlZWd1amFyYXRpIiwKICAweDBhZTksCiAgInRocmVlZ3VybXVraGkiLAogIDB4MGE2OSwKICAidGhyZWVoYWNrYXJhYmljIiwKICAweDA2NjMsCiAgInRocmVlaGFuZ3pob3UiLAogIDB4MzAyMywKICAidGhyZWVpZGVvZ3JhcGhpY3BhcmVuIiwKICAweDMyMjIsCiAgInRocmVlaW5mZXJpb3IiLAogIDB4MjA4MywKICAidGhyZWVtb25vc3BhY2UiLAogIDB4ZmYxMywKICAidGhyZWVudW1lcmF0b3JiZW5nYWxpIiwKICAweDA5ZjYsCiAgInRocmVlb2xkc3R5bGUiLAogIDB4ZjczMywKICAidGhyZWVwYXJlbiIsCiAgMHgy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Z2N5cmlsbGljIiwKICAweDA0NmIsCiAgInl1c2JpZ2lvdGlmaWVkY3lyaWxsaWMiLAogIDB4MDQ2ZCwKICAieXVzbGl0dGxlY3lyaWxsaWMiLAogIDB4MDQ2NywKICAieXVzbGl0dGxlaW90aWZpZWRjeXJpbGxpYyIsCiAgMHgwNDY5LAogICJ5dXNtYWxsaGlyYWdhbmEiLAogIDB4MzA4NSwKICAieXVzbWFsbGthdGFrYW5hIiwKICAweDMwZTUsCiAgInl1c21hbGxrYXRha2FuYWhhbGZ3aWR0aCIsCiAgMHhmZjZkLAogICJ5dXlla29yZWFuIiwKICAweDMxOGIsCiAgInl1eWVva29yZWFuIiwKICAweDMxOGEsCiAgInl5YWJlbmdhbGkiLAogIDB4MDlkZiwKICAieXlhZGV2YSIsCiAgMHgwOTVmLAogICJ6IiwKICAweDAwN2EsCiAgInphYXJtZW5pYW4iLAogIDB4MDU2NiwKICAiemFjdXRlIiwKICAweDAxN2EsCiAgInphZGV2YSIsCiAgMHgwOTViLAogICJ6YWd1cm11a2hpIiwKICAweDBhNWIsCiAgInphaGFyYWJpYyIsCiAgMHgwNjM4LAogICJ6YWhmaW5hbGFyYWJpYyIsCiAgMHhmZWM2LAogICJ6YWhpbml0aWFsYXJhYmljIiwKICAweGZlYzcsCiAgInphaGlyYWdhbmEiLAogIDB4MzA1NiwKICAiemFobWVkaWFsYXJhYmljIiwKICAweGZlYzgsCiAgInphaW5hcmFiaWMiLAogIDB4MDYzMiwKICAiemFpbmZpbmFsYXJhYmljIiwKICAweGZlYjAsCiAgInpha2F0YWthbmEiLAogIDB4MzBiNiwKICAiemFxZWZnYWRvbGhlYnJldyIsCiAgMHgwNTk1LAogICJ6YXFlZnFhdGFuaGVicmV3IiwKICAweDA1OTQsCiAgInphcnFhaGVicmV3IiwKICAweDA1OTgsCiAgInpheWluIiwKICAweDA1ZDYsCiAgInpheWluZGFnZXNoIiwKICAweGZiMzYsCiAgInpheWluZGFnZXNoaGVicmV3IiwKICAweGZ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B4MjcwMSwKICAiYTIiLAogIDB4MjcwMiwKICAiYTIwMiIsCiAgMHgyNzAzLAogICJhMyIsCiAgMHgyNzA0LAogICJhNCIsCiAgMHgyNjBlLAogICJhNSIsCiAgMHgyNzA2LAogICJhMTE5IiwKICAweDI3MDcsCiAgImExMTgiLAogIDB4MjcwOCwKICAiYTExNyIsCiAgMHgyNzA5LAogICJhMTEiLAogIDB4MjYxYiwKICAiYTEyIiwKICAweDI2MWUsCiAgImExMyIsCiAgMHgyNzBjLAogICJhMTQiLAogIDB4MjcwZCwKICAiYTE1IiwKICAweDI3MGUsCiAgImExNiIsCiAgMHgyNzBmLAogICJhMTA1IiwKICAweDI3MTAsCiAgImExNyIsCiAgMHgyNzExLAogICJhMTgiLAogIDB4MjcxMiwKICAiYTE5IiwKICAweDI3MTMsCiAgImEyMCIsCiAgMHgyNzE0LAogICJhMjEiLAogIDB4MjcxNSwKICAiYTIyIiwKICAweDI3MTYsCiAgImEyMyIsCiAgMHgyNzE3LAogICJhMjQiLAogIDB4MjcxOCwKICAiYTI1IiwKICAweDI3MTksCiAgImEyNiIsCiAgMHgyNzFhLAogICJhMjciLAogIDB4MjcxYiwKICAiYTI4IiwKICAweDI3MWMsCiAgImE2IiwKICAweDI3MWQsCiAgImE3IiwKICAweDI3MWUsCiAgImE4IiwKICAweDI3MWYsCiAgImE5IiwKICAweDI3MjAsCiAgImExMCIsCiAgMHgyNzIxLAogICJhMjkiLAogIDB4MjcyMiwKICAiYTMwIiwKICAweDI3MjMsCiAgImEzMSIsCiAgMHgyNzI0LAogICJhMzIiLAogIDB4MjcyNSwKICAiYTMzIiwKICAweDI3MjYsCiAgImEzNCIsCiAgMHgyNzI3LAogICJhMzUiLAogIDB4MjYwNSwKICAiYTM2IiwKICAweDI3MjksCiAgImEzNyIsCiAgMHgyNzJhLAogICJhMzgiLAogIDB4MjcyYiwKICAiYTM5IiwKICAweDI3MmMsCiAgImE0MCIsCiAgMHgyNzJkLAogICJhNDEiLAogIDB4Mj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CiAgImE5NyIsCiAgMHgyNzViLAogICJhOTgiLAogIDB4Mjc1YywKICAiYTk5IiwKICAweDI3NWQsCiAgImExMDAiLAogIDB4Mjc1ZSwKICAiYTEwMSIsCiAgMHgyNzYxLAogICJhMTAyIiwKICAweDI3NjIsCiAgImExMDMiLAogIDB4Mjc2MywKICAiYTEwNCIsCiAgMHgyNzY0LAogICJhMTA2IiwKICAweDI3NjUsCiAgImExMDciLAogIDB4Mjc2NiwKICAiYTEwOCIsCiAgMHgyNzY3LAogICJhMTEyIiwKICAweDI2NjMsCiAgImExMTEiLAogIDB4MjY2NiwKICAiYTExMCIsCiAgMHgyNjY1LAogICJhMTA5IiwKICAweDI2NjAsCiAgImExMjAiLAogIDB4MjQ2MCwKICAiYTEyMSIsCiAgMHgyNDYxLAogICJhMTIyIiwKICAweDI0NjIsCiAgImExMjMiLAogIDB4MjQ2MywKICAiYTEyNCIsCiAgMHgyNDY0LAogICJhMTI1IiwKICAweDI0NjUsCiAgImExMjYiLAogIDB4MjQ2NiwKICAiYTEyNyIsCiAgMHgyNDY3LAogICJhMTI4IiwKICAweDI0NjgsCiAgImExMjkiLAogIDB4MjQ2OSwKICAiYTEzMCIsCiAgMHgyNzc2LAogICJhMTMxIiwKICAweDI3NzcsCiAgImExMzIiLAogIDB4Mjc3OCwKICAiYTEzMyIsCiAgMHgyNzc5LAogICJhMTM0IiwKICAweDI3N2EsCiAgImExMzUiLAogIDB4Mjc3YiwKICAiYTEzNiIsCiAgMHgyNzdjLAogICJhMTM3IiwKICAweDI3N2QsCiAgImExMzgiLAogIDB4Mjc3ZSwKICAiYTEzOSIsCiAgMHgyNzdmLAogICJhMTQwIiwKICAweDI3ODAsCiAgImExNDEiLAogIDB4Mjc4MSwKICAiYTE0MiIsCiAgMHgyNzgyLAogICJhMTQzIiwKICAweDI3ODMsCiAgImExNDQiLAogIDB4Mjc4NCwKICAiYTE0NSIsCiAgMHgyNzg1LAogICJhMTQ2IiwKICAweDI3ODYsCiAgImExNDciLAogIDB4Mjc4NywKICAiYTE0OCIsCiAgMHgyNzg4LAogICJhMTQ5IiwKICAweDI3ODksCiAgImExNTAiLAogIDB4Mjc4YSwKICAiYTE1MSIsCiAgMHgyNzhiLAogICJhMTUyIiwKICAweDI3OGMsCiAgImExNTMiLAogIDB4Mjc4ZCwKICAiYTE1NCIsCiAgMHgyNzhlLAogICJhMTU1IiwKICAweDI3OGYsCiAgImExNTYiLAogIDB4Mjc5MCwKICAiYTE1NyIsCiAgMHgyNzkxLAogICJhMTU4IiwKICAweDI3OTIsCiAgImExNTkiLAogIDB4Mjc5MywKICAiYTE2MCIsCiAgMHgyNzk0LAogICJhMTYxIiwKICAweDIxOTIsCiAgImExNjMiLAogIDB4MjE5NCwKICAiYTE2NCIsCiAgMHgyMTk1LAogICJhMTk2IiwKICAweDI3OTgsCiAgImExNjUiLAogIDB4Mjc5OSwKICAiYTE5MiIsCiAgMHgyNzlhLAogICJhMTY2IiwKICAweDI3OWIsCiAgImExNjciLAogIDB4Mjc5YywKICAiYTE2OCIsCiAgMHgyNzlkLAogICJhMTY5IiwKICAweDI3OWUsCiAgImExNzAiLAogIDB4Mjc5ZiwKICAiYTE3MSIsCiAgMHgyN2EwLAogICJhMTcyIiwKICAweDI3YTEsCiAgImExNzMiLAogIDB4MjdhMiwKICAiYTE2MiIsCiAgMHgyN2EzLAogICJhMTc0IiwKICAweDI3YTQsCiAgImExNzUiLAogIDB4MjdhNSwKICAiYTE3NiIsCiAgMHgyN2E2LAogICJhMTc3IiwKICAweDI3YTcsCiAgImExNzgiLAogIDB4MjdhOCwKICAiYTE3OSIsCiAgMHgyN2E5LAogICJhMTkzIiwKICAweDI3YWEsCiAgImExODAiLAogIDB4MjdhYiwKICAiYTE5OSIsCiAgMHgyN2FjLAogICJhMTgxIiwKICAweDI3YWQsCiAgImEyMDAiLAogIDB4MjdhZSwKICAiYTE4MiIsCiAgMHgyN2FmLAogICJhMjAxIiwKICAweDI3YjEsCiAgImExODMiLAogIDB4Mjdi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Glsc19qc19fV0VCUEFDS19JTVBPUlRFRF9NT0RVTEVfMF9fLmdldEFycmF5TG9va3VwVGFibGVGYWN0b3J5KShmdW5jdGlvbiAoKSB7CiByZXR1cm4gWwogICJcdTAwQTgiLAogICJcdTAwMjBcdTAzMDgiLAogICJcdTAwQUYiLAogICJcdTAwMjBcdTAzMDQiLAogICJcdTAwQjQiLAogICJcdTAwMjBcdTAzMDEiLAogICJcdTAwQjUiLAogICJcdTAzQkMiLAogICJcdTAwQjgiLAogICJcdTAwMjBcdTAzMjciLAogICJcdTAxMzIiLAogICJcdTAwNDlcdTAwNEEiLAogICJcdTAxMzMiLAogICJcdTAwNjlcdTAwNkEiLAogICJcdTAxM0YiLAogICJcdTAwNENcdTAwQjciLAogICJcdTAxNDAiLAogICJcdTAwNkNcdTAwQjciLAogICJcdTAxNDkiLAogICJcdTAyQkNcdTAwNkUiLAogICJcdTAxN0YiLAogICJcdTAwNzMiLAogICJcdTAxQzQiLAogICJcdTAwNDRcdTAxN0QiLAogICJcdTAxQzUiLAogICJcdTAwNDRcdTAxN0UiLAogICJcdTAxQzYiLAogICJcdTAwNjRcdTAxN0UiLAogICJcdTAxQzciLAogICJcdTAwNENcdTAwNEEiLAogICJcdTAxQzgiLAogICJcdTAwNENcdTAwNkEiLAogICJcdTAxQzkiLAogICJcdTAwNkNcdTAwNkEiLAogICJcdTAxQ0EiLAogICJcdTAwNEVcdTAwNEEiLAogICJcdTAxQ0IiLAogICJcdTAwNEVcdTAwNkEiLAogICJcdTAxQ0MiLAogICJcdTAwNkVcdTAwNkEiLAogICJcdTAxRjEiLAogICJcdTAwNDRcdTAwNUEiLAogICJcdTAxRjIiLAogICJcdTAwNDRcdTAwN0EiLAogICJcdTAxRjMiLAogICJcdTAwNjRcdTAwN0EiLAogICJcdTAyRDgiLAogICJcdTAwMjBcdTAzMDYiLAogICJcdTAyRDkiLAogICJcdTAwMjBcdTAzMDciLAogICJcdTAyREEiLAogICJcdTAwMjBcdTAzMEEiLAogICJcdTAyREIiLAogICJcdTAwMjBcdTAzMjgiLAogICJcdTAyREMiLAogICJcdTAwMjBcdTAzMDMiLAogICJcdTAyREQiLAogICJcdTAwMjBcdTAzMEIiLAogICJcdTAzN0EiLAogICJcdTAwMjBcdTAzNDUiLAogICJcdTAzODQiLAogICJcdTAwMjBcdTAzMDEiLAogICJcdTAzRDAiLAogICJcdTAzQjIiLAogICJcdTAzRDEiLAogICJcdTAzQjgiLAogICJcdTAzRDIiLAogICJcdTAzQTUiLAogICJcdTAzRDUiLAogICJcdTAzQzYiLAogICJcdTAzRDYiLAogICJcdTAzQzAiLAogICJcdTAzRjAiLAogICJcdTAzQkEiLAogICJcdTAzRjEiLAogICJcdTAzQzEiLAogICJcdTAzRjIiLAogICJcdTAzQzIiLAogICJcdTAzRjQiLAogICJcdTAzOTgiLAogICJcdTAzRjUiLAogICJcdTAzQjUiLAogICJcdTAzRjkiLAogICJcdTAzQTMiLAogICJcdTA1ODciLAogICJcdTA1NjVcdTA1ODIiLAogICJcdTA2NzUiLAogICJcdTA2MjdcdTA2NzQiLAogICJcdTA2NzYiLAogICJcdTA2NDhcdTA2NzQiLAogICJcdTA2NzciLAogICJcdTA2QzdcdTA2NzQiLAogICJcdTA2NzgiLAogICJcdTA2NEFcdTA2NzQiLAogICJcdTBFMzMiLAogICJcdTBFNERcdTBFMzIiLAogICJcdTBFQjMiLAogICJcdTBFQ0RcdTBFQjIiLAogICJcdTBFREMiLAogICJcdTBFQUJcdTBFOTkiLAogICJcdTBFREQiLAogICJcdTBFQUJcdTBFQTEiLAogICJcdTBGNzciLAogICJcdTBGQjJcdTBGODEiLAogICJcdTBGNzkiLAogICJcdTBGQjNcdTBGODEiLAogICJcdTFFOUEiLAogICJcdTAwNjFcdTAyQkUiLAogICJcdTFGQkQiLAogICJcdTAwMjBcdTAzMTMiLAogICJcdTFGQkYiLAogICJcdTAwMjBcdTAzMTMiLAogICJcdTFGQzAiLAogICJcdTAwMjBcdTAzNDIiLAogICJcdTFGRkUiLAogICJcdTAwMjBcdTAzMTQiLAogICJcdTIwMDIiLAogICJcdTAwMjAiLAogICJcdTIwMDMiLAogICJcdTAwMjAiLAogICJcdTIwMDQiLAogICJcdTAwMjAiLAogICJcdTIwMDUiLAogICJcdTAwMjAiLAogICJcdTIwMDYiLAogICJcdTAwMjAiLAogICJcdTIwMDgiLAogICJcdTAwMjAiLAogICJcdTIwMDkiLAogICJcdTAwMjAiLAogICJcdTIwMEEiLAogICJcdTAwMjAiLAogICJcdTIwMTciLAogICJcdTAwMjBcdTAzMzMiLAogICJcdTIwMjQiLAogICJcdTAwMkUiLAogICJcdTIwMjUiLAogICJcdTAwMkVcdTAwMkUiLAogICJcdTIwMjYiLAogICJcdTAwMkVcdTAwMkVcdTAwMkUiLAogICJcdTIwMzMiLAogICJcdTIwMzJcdTIwMzIiLAogICJcdTIwMzQiLAogICJcdTIwMzJcdTIwMzJcdTIwMzIiLAogICJcdTIwMzYiLAogICJcdTIwMzVcdTIwMzUiLAogICJcdTIwMzciLAogICJcdTIwMzVcdTIwMzVcdTIwMzUiLAogICJcdTIwM0MiLAogICJcdTAwMjFcdTAwMjEiLAogICJcdTIwM0UiLAogICJcdTAwMjBcdTAzMDUiLAogICJcdTIwNDciLAogICJcdTAwM0ZcdTAwM0YiLAogICJcdTIwNDgiLAogICJcdTAwM0ZcdTAwMjEiLAogICJcdTIwNDkiLAogICJcdTAwMjFcdTAwM0YiLAogICJcdTIwNTciLAogICJcdTIwMzJcdTIwMzJcdTIwMzJcdTIwMzIiLAogICJcdTIwNUYiLAogICJcdTAwMjAiLAogICJcdTIwQTgiLAogICJcdTAwNTJcdTAwNzMiLAogICJcdTIxMDAiLAogICJcdTAwNjFcdTAwMkZcdTAwNjMiLAogICJcdTIxMDEiLAogICJcdTAwNjFcdTAwMkZcdTAwNzMiLAogICJcdTIxMDMiLAogICJcdTAwQjBcdTAwNDMiLAogICJcdTIxMDUiLAogICJcdTAwNjNcdTAwMkZcdTAwNkYiLAogICJcdTIxMDYiLAogICJcdTAwNjNcdTAwMkZcdTAwNzUiLAogICJcdTIxMDciLAogICJcdTAxOTAiLAogICJcdTIxMDkiLAogICJcdTAwQjBcdTAwNDYiLAogICJcdTIxMTYiLAogICJcdTAwNEVcdTAwNkYiLAogICJcdTIxMjEiLAogICJcdTAwNTRcdTAwNDVcdTAwNEMiLAogICJcdTIxMzUiLAogICJcdTA1RDAiLAogICJcdTIxMzYiLAogICJcdTA1RDEiLAogICJcdTIxMzciLAogICJcdTA1RDIiLAogICJcdTIxMzgiLAogICJcdTA1RDMiLAogICJcdTIxM0IiLAogICJcdTAwNDZcdTAwNDFcdTAwNTgiLAogICJcdTIxNjAiLAogICJcdTAwNDkiLAogICJcdTIxNjEiLAogICJcdTAwNDlcdTAwNDkiLAogICJcdTIxNjIiLAogICJcdTAwNDlcdTAwNDlcdTAwNDkiLAogICJcdTIxNjMiLAogICJcdTAwNDlcdTAwNTYiLAogICJcdTIxNjQiLAogICJcdTAwNTYiLAogICJcdTIxNjUiLAogICJcdTAwNTZcdTAwNDkiLAogICJcdTIxNjYiLAogICJcdTAwNTZcdTAwNDlcdTAwNDkiLAogICJcdTIxNjciLAogICJcdTAwNTZcdTAwNDlcdTAwNDlcdTAwNDkiLAogICJcdTIxNjgiLAogICJcdTAwNDlcdTAwNTgiLAogICJcdTIxNjkiLAogICJcdTAwNTgiLAogICJcdTIxNkEiLAogICJcdTAwNThcdTAwNDkiLAogICJcdTIxNkIiLAogICJcdTAwNThcdTAwNDlcdTAwNDkiLAogICJcdTIxNkMiLAogICJcdTAwNEMiLAogICJcdTIxNkQiLAogICJcdTAwNDMiLAogICJcdTIxNkUiLAogICJcdTAwNDQiLAogICJcdTIxNkYiLAogICJcdTAwNEQiLAogICJcdTIxNzAiLAogICJcdTAwNjkiLAogICJcdTIxNzEiLAogICJcdTAwNjlcdTAwNjkiLAogICJcdTIxNzIiLAogICJcdTAwNjlcdTAwNjlcdTAwNjkiLAogICJcdTIxNzMiLAogICJcdTAwNjlcdTAwNzYiLAogICJcdTIxNzQiLAogICJcdTAwNzYiLAogICJcdTIxNzUiLAogICJcdTAwNzZcdTAwNjkiLAogICJcdTIxNzYiLAogICJcdTAwNzZcdTAwNjlcdTAwNjkiLAogICJcdTIxNzciLAogICJcdTAwNzZcdTAwNjlcdTAwNjlcdTAwNjkiLAogICJcdTIxNzgiLAogICJcdTAwNjlcdTAwNzgiLAogICJcdTIxNzkiLAogICJcdTAwNzgiLAogICJcdTIxN0EiLAogICJcdTAwNzhcdTAwNjkiLAogICJcdTIxN0IiLAogICJcdTAwNzhcdTAwNjlcdTAwNjkiLAogICJcdTIxN0MiLAogICJcdTAwNkMiLAogICJcdTIxN0QiLAogICJcdTAwNjMiLAogICJcdTIxN0UiLAogICJcdTAwNjQiLAogICJcdTIxN0YiLAogICJcdTAwNkQiLAogICJcdTIyMkMiLAogICJcdTIyMkJcdTIyMkIiLAogICJcdTIyMkQiLAogICJcdTIyMkJcdTIyMkJcdTIyMkIiLAogICJcdTIyMkYiLAogICJcdTIyMkVcdTIyMkUiLAogICJcdTIyMzAiLAogICJcdTIyMkVcdTIyMkVcdTIyMkUiLAogICJcdTI0NzQiLAogICJcdTAwMjhcdTAwMzFcdTAwMjkiLAogICJcdTI0NzUiLAogICJcdTAwMjhcdTAwMzJcdTAwMjkiLAogICJcdTI0NzYiLAogICJcdTAwMjhcdTAwMzNcdTAwMjkiLAogICJcdTI0NzciLAogICJcdTAwMjhcdTAwMzRcdTAwMjkiLAogICJcdTI0NzgiLAogICJcdTAwMjhcdTAwMzVcdTAwMjkiLAogICJcdTI0NzkiLAogICJcdTAwMjhcdTAwMzZcdTAwMjkiLAogICJcdTI0N0EiLAogICJcdTAwMjhcdTAwMzdcdTAwMjkiLAogICJcdTI0N0IiLAogICJcdTAwMjhcdTAwMzhcdTAwMjkiLAogICJcdTI0N0MiLAogICJcdTAwMjhcdTAwMzlcdTAwMjkiLAogICJcdTI0N0QiLAogICJcdTAwMjhcdTAwMzFcdTAwMzBc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UMiLAogICJcdTAwMjhcdTAwNzFcdTAwMjkiLAogICJcdTI0QUQiLAogICJcdTAwMjhcdTAwNzJcdTAwMjkiLAogICJcdTI0QUUiLAogICJcdTAwMjhcdTAwNzNcdTAwMjkiLAogICJcdTI0QUYiLAogICJcdTAwMjhcdTAwNzRcdTAwMjkiLAogICJcdTI0QjAiLAogICJcdTAwMjhcdTAwNzVcdTAwMjkiLAogICJcdTI0QjEiLAogICJcdTAwMjhcdTAwNzZcdTAwMjkiLAogICJcdTI0QjIiLAogICJcdTAwMjhcdTAwNzdcdTAwMjkiLAogICJcdTI0QjMiLAogICJcdTAwMjhcdTAwNzhcdTAwMjkiLAogICJcdTI0QjQiLAogICJcdTAwMjhcdTAwNzlcdTAwMjkiLAogICJcdTI0QjUiLAogICJcdTAwMjhcdTAwN0FcdTAwMjkiLAogICJcdTJBMEMiLAogICJcdTIyMkJcdTIyMkJcdTIyMkJcdTIyMkIiLAogICJcdTJBNzQiLAogICJcdTAwM0FcdTAwM0FcdTAwM0QiLAogICJcdTJBNzUiLAogICJcdTAwM0RcdTAwM0QiLAogICJcdTJBNzYiLAogICJcdTAwM0RcdTAwM0RcdTAwM0QiLAogICJcdTJFOUYiLAogICJcdTZCQ0QiLAogICJcdTJFRjMiLAogICJcdTlGOUYiLAogICJcdTJGMDAiLAogICJcdTRFMDAiLAogICJcdTJGMDEiLAogICJcdTRFMjgiLAogICJcdTJGMDIiLAogICJcdTRFMzYiLAogICJcdTJGMDMiLAogICJcdTRFM0YiLAogICJcdTJGMDQiLAogICJcdTRFNTkiLAogICJcdTJGMDUiLAogICJcdTRFODUiLAogICJcdTJGMDYiLAogICJcdTRFOEMiLAogICJcdTJGMDciLAogICJcdTRFQTAiLAogICJcdTJGMDgiLAogICJcdTRFQkEiLAogICJcdTJGMDkiLAogICJcdTUxM0YiLAogICJcdTJGMEEiLAogICJcdTUxNjUiLAogICJcdTJGMEIiLAogICJcdTUxNkIiLAogICJcdTJGMEMiLAogICJcdTUxODIiLAogICJcdTJGMEQiLAogICJcdTUxOTYiLAogICJcdTJGMEUiLAogICJcdTUxQUIiLAogICJcdTJGMEYiLAogICJcdTUxRTAiLAogICJcdTJGMTAiLAogICJcdTUxRjUiLAogICJcdTJGMTEiLAogICJcdTUyMDAiLAogICJcdTJGMTIiLAogICJcdTUyOUIiLAogICJcdTJGMTMiLAogICJcdTUyRjkiLAogICJcdTJGMTQiLAogICJcdTUzMTUiLAogICJcdTJGMTUiLAogICJcdTUzMUEiLAogICJcdTJGMTYiLAogICJcdTUzMzgiLAogICJcdTJGMTciLAogICJcdTUzNDEiLAogICJcdTJGMTgiLAogICJcdTUzNUMiLAogICJcdTJGMTkiLAogICJcdTUzNjkiLAogICJcdTJGMUEiLAogICJcdTUzODIiLAogICJcdTJGMUIiLAogICJcdTUzQjYiLAogICJcdTJGMUMiLAogICJcdTUzQzgiLAogICJcdTJGMUQiLAogICJcdTUzRTMiLAogICJcdTJGMUUiLAogICJcdTU2RDciLAogICJcdTJGMUYiLAogICJcdTU3MUYiLAogICJcdTJGMjAiLAogICJcdTU4RUIiLAogICJcdTJGMjEiLAogICJcdTU5MDIiLAogICJcdTJGMjIiLAogICJcdTU5MEEiLAogICJcdTJGMjMiLAogICJcdTU5MTUiLAogICJcdTJGMjQiLAogICJcdTU5MjciLAogICJcdTJGMjUiLAogICJcdTU5NzMiLAogICJcdTJGMjYiLAogICJcdTVCNTAiLAogICJcdTJGMjciLAogICJcdTVCODAiLAogICJcdTJGMjgiLAogICJcdTVCRjgiLAogICJcdTJGMjkiLAogICJcdTVDMEYiLAogICJcdTJGMkEiLAogICJcdTVDMjIiLAogICJcdTJGMkIiLAogICJcdTVDMzgiLAogICJcdTJGMkMiLAogICJcdTVDNkUiLAogICJcdTJGMkQiLAogICJcdTVDNzEiLAogICJcdTJGMkUiLAogICJcdTVEREIiLAogICJcdTJGMkYiLAogICJcdTVERTUiLAogICJcdTJGMzAiLAogICJcdTVERjEiLAogICJcdTJGMzEiLAogICJcdTVERkUiLAogICJcdTJGMzIiLAogICJcdTVFNzIiLAogICJcdTJGMzMiLAogICJcdTVFN0EiLAogICJcdTJGMzQiLAogICJcdTVFN0YiLAogICJcdTJGMzUiLAogICJcdTVFRjQiLAogICJcdTJGMzYiLAogICJcdTVFRkUiLAogICJcdTJGMzciLAogICJcdTVGMEIiLAogICJcdTJGMzgiLAogICJcdTVGMTMiLAogICJcdTJGMzkiLAogICJcdTVGNTAiLAogICJcdTJGM0EiLAogICJcdTVGNjEiLAogICJcdTJGM0IiLAogICJcdTVGNzMiLAogICJcdTJGM0MiLAogICJcdTVGQzMiLAogICJcdTJGM0QiLAogICJcdTYyMDgiLAogICJcdTJGM0UiLAogICJcdTYyMzYiLAogICJcdTJGM0YiLAogICJcdTYyNEIiLAogICJcdTJGNDAiLAogICJcdTY1MkYiLAogICJcdTJGNDEiLAogICJcdTY1MzQiLAogICJcdTJGNDIiLAogICJcdTY1ODciLAogICJcdTJGNDMiLAogICJcdTY1OTciLAogICJcdTJGNDQiLAogICJcdTY1QTQiLAogICJcdTJGNDUiLAogICJcdTY1QjkiLAogICJcdTJGNDYiLAogICJcdTY1RTAiLAogICJcdTJGNDciLAogICJcdTY1RTUiLAogICJcdTJGNDgiLAogICJcdTY2RjAiLAogICJcdTJGNDkiLAogICJcdTY3MDgiLAogICJcdTJGNEEiLAogICJcdTY3MjgiLAogICJcdTJGNEIiLAogICJcdTZCMjAiLAogICJcdTJGNEMiLAogICJcdTZCNjIiLAogICJcdTJGNEQiLAogICJcdTZCNzkiLAogICJcdTJGNEUiLAogICJcdTZCQjMiLAogICJcdTJGNEYiLAogICJcdTZCQ0IiLAogICJcdTJGNTAiLAogICJcdTZCRDQiLAogICJcdTJGNTEiLAogICJcdTZCREIiLAogICJcdTJGNTIiLAogICJcdTZDMEYiLAogICJcdTJGNTMiLAogICJcdTZDMTQiLAogICJcdTJGNTQiLAogICJcdTZDMzQiLAogICJcdTJGNTUiLAogICJcdTcwNkIiLAogICJcdTJGNTYiLAogICJcdTcyMkEiLAogICJcdTJGNTciLAogICJcdTcyMzYiLAogICJcdTJGNTgiLAogICJcdTcyM0IiLAogICJcdTJGNTkiLAogICJcdTcyM0YiLAogICJcdTJGNUEiLAogICJcdTcyNDciLAogICJcdTJGNUIiLAogICJcdTcyNTkiLAogICJcdTJGNUMiLAogICJcdTcyNUIiLAogICJcdTJGNUQiLAogICJcdTcyQUMiLAogICJcdTJGNUUiLAogICJcdTczODQiLAogICJcdTJGNUYiLAogICJcdTczODkiLAogICJcdTJGNjAiLAogICJcdTc0REMiLAogICJcdTJGNjEiLAogICJcdTc0RTYiLAogICJcdTJGNjIiLAogICJcdTc1MTgiLAogICJcdTJGNjMiLAogICJcdTc1MUYiLAogICJcdTJGNjQiLAogICJcdTc1MjgiLAogICJcdTJGNjUiLAogICJcdTc1MzAiLAogICJcdTJGNjYiLAogICJcdTc1OEIiLAogICJcdTJGNjciLAogICJcdTc1OTIiLAogICJcdTJGNjgiLAogICJcdTc2NzYiLAogICJcdTJGNjkiLAogICJcdTc2N0QiLAogICJcdTJGNkEiLAogICJcdTc2QUUiLAogICJcdTJGNkIiLAogICJcdTc2QkYiLAogICJcdTJGNkMiLAogICJcdTc2RUUiLAogICJcdTJGNkQiLAogICJcdTc3REIiLAogICJcdTJGNkUiLAogICJcdTc3RTIiLAogICJcdTJGNkYiLAogICJcdTc3RjMiLAogICJcdTJGNzAiLAogICJcdTc5M0EiLAogICJcdTJGNzEiLAogICJcdTc5QjgiLAogICJcdTJGNzIiLAogICJcdTc5QkUiLAogICJcdTJGNzMiLAogICJcdTdBNzQiLAogICJcdTJGNzQiLAogICJcdTdBQ0IiLAogICJcdTJGNzUiLAogICJcdTdBRjkiLAogICJcdTJGNzYiLAogICJcdTdDNzMiLAogICJcdTJGNzciLAogICJcdTdDRjgiLAogICJcdTJGNzgiLAogICJcdTdGMzYiLAogICJcdTJGNzkiLAogICJcdTdGNTEiLAogICJcdTJGN0EiLAogICJcdTdGOEEiLAogICJcdTJGN0IiLAogICJcdTdGQkQiLAogICJcdTJGN0MiLAogICJcdTgwMDEiLAogICJcdTJGN0QiLAogICJcdTgwMEMiLAogICJcdTJGN0UiLAogICJcdTgwMTIiLAogICJcdTJGN0YiLAogICJcdTgwMzMiLAogICJcdTJGODAiLAogICJcdTgwN0YiLAogICJcdTJGODEiLAogICJcdTgwODkiLAogICJcdTJGODIiLAogICJcdTgxRTMiLAogICJcdTJGODMiLAogICJcdTgxRUEiLAogICJcdTJGODQiLAogICJcdTgxRjMiLAogICJcdTJGODUiLAogICJcdTgxRkMiLAogICJcdTJGODYiLAogICJcdTgyMEMiLAogICJcdTJGODciLAogICJcdTgyMUIiLAogICJcdTJGODgiLAogICJcdTgyMUYiLAogICJcdTJGODkiLAogICJcdTgyNkUiLAogICJcdTJGOEEiLAogICJcdTgyNzIiLAogICJcdTJGOEIiLAogICJcdTgyNzgiLAogICJcdTJGOEMiLAogICJcdTg2NEQiLAogICJcdTJGOEQiLAogICJcdTg2NkIiLAogICJcdTJGOEUiLAogICJcdTg4NDAiLAogICJcdTJGOEYiLAogICJcdTg4NEMiLAogICJcdTJGOTAiLAogICJcdTg4NjMiLAogICJcdTJGOTEiLAogICJcdTg5N0UiLAogICJcdTJGOTIiLAogICJcdTg5OEIiLAogICJcdTJGOTMiLAogICJcdTg5RDIiLAogICJcdTJGOTQiLAogICJcdThBMDAiLAogICJcdTJGOTUiLAogICJcdThDMzciLAogICJcdTJGOTYiLAogICJcdThDNDYiLAogICJcdTJGOTciLAogICJcdThDNTUiLAogICJcdTJGOTgiLAogICJcdThDNzgiLAogICJcdTJGOTkiLAogICJcdThDOUQiLAogICJcdTJGOUEiLAogICJcdThENjQiLAogICJcdTJGOUIiLAogICJcdThENzAiLAogICJcdTJGOUMiLAogICJcdThEQjMiLAogICJcdTJGOUQiLAogICJcdThFQUIiLAogICJcdTJGOUUiLAogICJcdThFQ0EiLAogICJcdTJGOUYiLAogICJcdThGOUIiLAogICJcdTJGQTAiLAogICJcdThGQjAiLAogICJcdTJGQTEiLAogICJcdThGQjUiLAogICJcdTJGQTIiLAogICJcdTkwOTEiLAogICJcdTJGQTMiLAogICJcdTkxNDkiLAogICJcdTJGQTQiLAogICJcdTkxQzYiLAogICJcdTJGQTUiLAogICJcdTkxQ0MiLAogICJcdTJGQTYiLAogICJcdTkxRDEiLAogICJcdTJGQTciLAogICJcdTk1NzciLAogICJcdTJGQTgiLAogICJcdTk1ODAiLAogICJcdTJGQTkiLAogICJcdTk2MUMiLAogICJcdTJGQUEiLAogICJcdTk2QjYiLAogICJcdTJGQUIiLAogICJcdTk2QjkiLAogICJcdTJGQUMiLAogICJcdTk2RTgiLAogICJcdTJGQUQiLAogICJcdTk3NTEiLAogICJcdTJGQUUiLAogICJcdTk3NUUiLAogICJcdTJGQUYiLAogICJcdTk3NjIiLAogICJcdTJGQjAiLAogICJcdTk3NjkiLAogICJcdTJGQjEiLAogICJcdTk3Q0IiLAogICJcdTJGQjIiLAogICJcdTk3RUQiLAogICJcdTJGQjMiLAogICJcdTk3RjMiLAogICJcdTJGQjQiLAogICJcdTk4MDEiLAogICJcdTJGQjUiLAogICJcdTk4QTgiLAogICJcdTJGQjYiLAogICJcdTk4REIiLAogICJcdTJGQjciLAogICJcdTk4REYiLAogICJcdTJGQjgiLAogICJcdTk5OTYiLAogICJcdTJGQjkiLAogICJcdTk5OTkiLAogICJcdTJGQkEiLAogICJcdTk5QUMiLAogICJcdTJGQkIiLAogICJcdTlBQTgiLAogICJcdTJGQkMiLAogICJcdTlBRDgiLAogICJcdTJGQkQiLAogICJcdTlBREYiLAogICJcdTJGQkUiLAogICJcdTlCMjUiLAogICJcdTJGQkYiLAogICJcdTlCMkYiLAogICJcdTJGQzAiLAogICJcdTlCMzIiLAogICJcdTJGQzEiLAogICJcdTlCM0MiLAogICJcdTJGQzIiLAogICJcdTlCNUEiLAogICJcdTJGQzMiLAogICJcdTlDRTUiLAogICJcdTJGQzQiLAogICJcdTlFNzUiLAogICJcdTJGQzUiLAogICJcdTlFN0YiLAogICJcdTJGQzYiLAogICJcdTlFQTUiLAogICJcdTJGQzciLAogICJcdTlFQkIiLAogICJcdTJGQzgiLAogICJcdTlFQzMiLAogICJcdTJGQzkiLAogICJcdTlFQ0QiLAogICJcdTJGQ0EiLAogICJcdTlFRDEiLAogICJcdTJGQ0IiLAogICJcdTlFRjkiLAogICJcdTJGQ0MiLAogICJcdTlFRkQiLAogICJcdTJGQ0QiLAogICJcdTlGMEUiLAogICJcdTJGQ0UiLAogICJcdTlGMTMiLAogICJcdTJGQ0YiLAogICJcdTlGMjAiLAogICJcdTJGRDAiLAogICJcdTlGM0IiLAogICJcdTJGRDEiLAogICJcdTlGNEEiLAogICJcdTJGRDIiLAogICJcdTlGNTIiLAogICJcdTJGRDMiLAogICJcdTlGOEQiLAogICJcdTJGRDQiLAogICJcdTlGOUMiLAogICJcdTJGRDUiLAogICJcdTlGQTAiLAogICJcdTMwMzYiLAogICJcdTMwMTIiLAogICJcdTMwMzgiLAogICJcdTUzNDEiLAogICJcdTMwMzkiLAogICJcdTUzNDQiLAogICJcdTMwM0EiLAogICJcdTUzNDUiLAogICJcdTMwOUIiLAogICJcdTAwMjBcdTMwOTkiLAogICJcdTMwOUMiLAogICJcdTAwMjBcdTMwOUEiLAogICJcdTMxMzEiLAogICJcdTExMDAiLAogICJcdTMxMzIiLAogICJcdTExMDEiLAogICJcdTMxMzMiLAogICJcdTExQUEiLAogICJcdTMxMzQiLAogICJcdTExMDIiLAogICJcdTMxMzUiLAogICJcdTExQUMiLAogICJcdTMxMzYiLAogICJcdTExQUQiLAogICJcdTMxMzciLAogICJcdTExMDMiLAogICJcdTMxMzgiLAogICJcdTExMDQiLAogICJcdTMxMzkiLAogICJcdTExMDUiLAogICJcdTMxM0EiLAogICJcdTExQjAiLAogICJcdTMxM0IiLAogICJcdTExQjEiLAogICJcdTMxM0MiLAogICJcdTExQjIiLAogICJcdTMxM0QiLAogICJcdTExQjMiLAogICJcdTMxM0UiLAogICJcdTExQjQiLAogICJcdTMxM0YiLAogICJcdTExQjUiLAogICJcdTMxNDAiLAogICJcdTExMUEiLAogICJcdTMxNDEiLAogICJcdTExMDYiLAogICJcdTMxNDIiLAogICJcdTExMDciLAogICJcdTMxNDMiLAogICJcdTExMDgiLAogICJcdTMxNDQiLAogICJcdTExMjEiLAogICJcdTMxNDUiLAogICJcdTExMDkiLAogICJcdTMxNDYiLAogICJcdTExMEEiLAogICJcdTMxNDciLAogICJcdTExMEIiLAogICJcdTMxNDgiLAogICJcdTExMEMiLAogICJcdTMxNDkiLAogICJcdTExMEQiLAogICJcdTMxNEEiLAogICJcdTExMEUiLAogICJcdTMxNEIiLAogICJcdTExMEYiLAogICJcdTMxNEMiLAogICJcdTExMTAiLAogICJcdTMxNEQiLAogICJcdTExMTEiLAogICJcdTMxNEUiLAogICJcdTExMTIiLAogICJcdTMxNEYiLAogICJcdTExNjEiLAogICJcdTMxNTAiLAogICJcdTExNjIiLAogICJcdTMxNTEiLAogICJcdTExNjMiLAogICJcdTMxNTIiLAogICJcdTExNjQiLAogICJcdTMxNTMiLAogICJcdTExNjUiLAogICJcdTMxNTQiLAogICJcdTExNjYiLAogICJcdTMxNTUiLAogICJcdTExNjciLAogICJcdTMxNTYiLAogICJcdTExNjgiLAogICJcdTMxNTciLAogICJcdTExNjkiLAogICJcdTMxNTgiLAogICJcdTExNkEiLAogICJcdTMxNTkiLAogICJcdTExNkIiLAogICJcdTMxNUEiLAogICJcdTExNkMiLAogICJcdTMxNUIiLAogICJcdTExNkQiLAogICJcdTMxNUMiLAogICJcdTExNkUiLAogICJcdTMxNUQiLAogICJcdTExNkYiLAogICJcdTMxNUUiLAogICJcdTExNzAiLAogICJcdTMxNUYiLAogICJcdTExNzEiLAogICJcdTMxNjAiLAogICJcdTExNzIiLAogICJcdTMxNjEiLAogICJcdTExNzMiLAogICJcdTMxNjIiLAogICJcdTExNzQiLAogICJcdTMxNjMiLAogICJcdTExNzUiLAogICJcdTMxNjQiLAogICJcdTExNjAiLAogICJcdTMxNjUiLAogICJcdTExMTQiLAogICJcdTMxNjYiLAogICJcdTExMTUiLAogICJcdTMxNjciLAogICJcdTExQzciLAogICJcdTMxNjgiLAogICJcdTExQzgiLAogICJcdTMxNjkiLAogICJcdTExQ0MiLAogICJcdTMxNkEiLAogICJcdTExQ0UiLAogICJcdTMxNkIiLAogICJcdTExRDMiLAogICJcdTMxNkMiLAogICJcdTExRDciLAogICJcdTMxNkQiLAogICJcdTExRDkiLAogICJcdTMxNkUiLAogICJcdTExMUMiLAogICJcdTMxNkYiLAogICJcdTExREQiLAogICJcdTMxNzAiLAogICJcdTExREYiLAogICJcdTMxNzEiLAogICJcdTExMUQiLAogICJcdTMxNzIiLAogICJcdTExMUUiLAogICJcdTMxNzMiLAogICJcdTExMjAiLAogICJcdTMxNzQiLAogICJcdTExMjIiLAogICJcdTMxNzUiLAogICJcdTExMjMiLAogICJcdTMxNzYiLAogICJcdTExMjciLAogICJcdTMxNzciLAogICJcdTExMjkiLAogICJcdTMxNzgiLAogICJcdTExMkIiLAogICJcdTMxNzkiLAogICJcdTExMkMiLAogICJcdTMxN0EiLAogICJcdTExMkQiLAogICJcdTMxN0IiLAogICJcdTExMkUiLAogICJcdTMxN0MiLAogICJcdTExMkYiLAogICJcdTMxN0QiLAogICJcdTExMzIiLAogICJcdTMxN0UiLAogICJcdTExMzYiLAogICJcdTMxN0YiLAogICJcdTExNDAiLAogICJcdTMxODAiLAogICJcdTExNDciLAogICJcdTMxODEiLAogICJcdTExNEMiLAogICJcdTMxODIiLAogICJcdTExRjEiLAogICJcdTMxODMiLAogICJcdTExRjIiLAogICJcdTMxODQiLAogICJcdTExNTciLAogICJcdTMxODUiLAogICJcdTExNTgiLAogICJcdTMxODYiLAogICJcdTExNTkiLAogICJcdTMxODciLAogICJcdTExODQiLAogICJcdTMxODgiLAogICJcdTExODUiLAogICJcdTMxODkiLAogICJcdTExODgiLAogICJcdTMxOEEiLAogICJcdTExOTEiLAogICJcdTMxOEIiLAogICJcdTExOTIiLAogICJcdTMxOEMiLAogICJcdTExOTQiLAogICJcdTMxOEQiLAogICJcdTExOUUiLAogICJcdTMxOEUiLAogICJcdTExQTEiLAogICJcdTMyMDAiLAogICJcdTAwMjhcdTExMDBcdTAwMjkiLAogICJcdTMyMDEiLAogICJcdTAwMjhcdTExMDJcdTAwMjkiLAogICJcdTMyMDIiLAogICJcdTAwMjhcdTExMDNcdTAwMjkiLAogICJcdTMyMDMiLAogICJcdTAwMjhcdTExMDVcdTAwMjkiLAogICJcdTMyMDQiLAogICJcdTAwMjhcdTExMDZcdTAwMjkiLAogICJcdTMyMDUiLAogICJcdTAwMjhcdTExMDdcdTAwMjkiLAogICJcdTMyMDYiLAogICJcdTAwMjhcdTExMDlcdTAwMjkiLAogICJcdTMyMDciLAogICJcdTAwMjhcdTExMEJcdTAwMjkiLAogICJcdTMyMDgiLAogICJcdTAwMjhcdTExMENcdTAwMjkiLAogICJcdTMyMDkiLAogICJcdTAwMjhcdTExMEVcdTAwMjkiLAogICJcdTMyMEEiLAogICJcdTAwMjhcdTExMEZcdTAwMjkiLAogICJcdTMyMEIiLAogICJcdTAwMjhcdTExMTBcdTAwMjkiLAogICJcdTMyMEMiLAogICJcdTAwMjhcdTExMTFcdTAwMjkiLAogICJcdTMyMEQiLAogICJcdTAwMjhcdTExMTJcdTAwMjkiLAogICJcdTMyMEUiLAogICJcdTAwMjhcdTExMDBcdTExNjFcdTAwMjkiLAogICJcdTMyMEYiLAogICJcdTAwMjhcdTExMDJcdTExNjFcdTAwMjkiLAogICJcdTMyMTAiLAogICJcdTAwMjhcdTExMDNcdTExNjFcdTAwMjkiLAogICJcdTMyMTEiLAogICJcdTAwMjhcdTExMDVcdTExNjFcdTAwMjkiLAogICJcdTMyMTIiLAogICJcdTAwMjhcdTExMDZcdTExNjFcdTAwMjkiLAogICJcdTMyMTMiLAogICJcdTAwMjhcdTExMDdcdTExNjFcdTAwMjkiLAogICJcdTMyMTQiLAogICJcdTAwMjhcdTExMDlcdTExNjFcdTAwMjkiLAogICJcdTMyMTUiLAogICJcdTAwMjhcdTExMEJcdTExNjFcdTAwMjkiLAogICJcdTMyMTYiLAogICJcdTAwMjhcdTExMENcdTExNjFcdTAwMjkiLAogICJcdTMyMTciLAogICJcdTAwMjhcdTExMEVcdTExNjFcdTAwMjkiLAogICJcdTMyMTgiLAogICJcdTAwMjhcdTExMEZcdTExNjFcdTAwMjkiLAogICJcdTMyMTkiLAogICJcdTAwMjhcdTExMTBcdTExNjFcdTAwMjkiLAogICJcdTMyMUEiLAogICJcdTAwMjhcdTExMTFcdTExNjFcdTAwMjkiLAogICJcdTMyMUIiLAogICJcdTAwMjhcdTExMTJcdTExNjFcdTAwMjkiLAogICJcdTMyMUMiLAogICJcdTAwMjhcdTExMENcdTExNkVcdTAwMjkiLAogICJcdTMyMUQiLAogICJcdTAwMjhcdTExMEJcdTExNjlcdTExMENcdTExNjVcdTExQUJcdTAwMjkiLAogICJcdTMyMUUiLAogICJcdTAwMjhcdTExMEJcdTExNjlcdTExMTJcdTExNkVcdTAwMjkiLAogICJcdTMyMjAiLAogICJcdTAwMjhcdTRFMDBcdTAwMjkiLAogICJcdTMyMjEiLAogICJcdTAwMjhcdTRFOENcdTAwMjkiLAogICJcdTMyMjIiLAogICJcdTAwMjhcdTRFMDlcdTAwMjkiLAogICJcdTMyMjMiLAogICJcdTAwMjhcdTU2REJcdTAwMjkiLAogICJcdTMyMjQiLAogICJcdTAwMjhcdTRFOTRcdTAwMjkiLAogICJcdTMyMjUiLAogICJcdTAwMjhcdTUxNkRcdTAwMjkiLAogICJcdTMyMjYiLAogICJcdTAwMjhcdTRFMDNcdTAwMjkiLAogICJcdTMyMjciLAogICJcdTAwMjhcdTUxNkJcdTAwMjkiLAogICJcdTMyMjgiLAogICJcdTAwMjhcdTRFNURcdTAwMjkiLAogICJcdTMyMjkiLAogICJcdTAwMjhcdTUzNDFcdTAwMjkiLAogICJcdTMyMkEiLAogICJcdTAwMjhcdTY3MDhcdTAwMjkiLAogICJc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wMjhcdTgxRUFcdTAwMjkiLAogICJcdTMyNDMiLAogICJcdTAwMjhcdTgxRjNcdTAwMjkiLAogICJcdTMyQzAiLAogICJcdTAwMzFcdTY3MDgiLAogICJcdTMyQzEiLAogICJcdTAwMzJcdTY3MDgiLAogICJcdTMyQzIiLAogICJcdTAwMzNcdTY3MDgiLAogICJcdTMyQzMiLAogICJcdTAwMzRcdTY3MDgiLAogICJcdTMyQzQiLAogICJcdTAwMzVcdTY3MDgiLAogICJcdTMyQzUiLAogICJcdTAwMzZcdTY3MDgiLAogICJcdTMyQzYiLAogICJcdTAwMzdcdTY3MDgiLAogICJcdTMyQzciLAogICJcdTAwMzhcdTY3MDgiLAogICJcdTMyQzgiLAogICJcdTAwMzlcdTY3MDgiLAogICJcdTMyQzkiLAogICJcdTAwMzFcdTAwMzBcdTY3MDgiLAogICJcdTMyQ0EiLAogICJcdTAwMzFcdTAwMzFcdTY3MDgiLAogICJcdTMyQ0IiLAogICJcdTAwMzFcdTAwMzJcdTY3MDgiLAogICJcdTMzNTgiLAogICJcdTAwMzBcdTcwQjkiLAogICJcdTMzNTkiLAogICJcdTAwMzFcdTcwQjkiLAogICJcdTMzNUEiLAogICJcdTAwMzJcdTcwQjkiLAogICJcdTMzNUIiLAogICJcdTAwMzNcdTcwQjkiLAogICJcdTMzNUMiLAogICJcdTAwMzRcdTcwQjkiLAogICJcdTMzNUQiLAogICJcdTAwMzVcdTcwQjkiLAogICJcdTMzNUUiLAogICJcdTAwMzZcdTcwQjkiLAogICJcdTMzNUYiLAogICJcdTAwMzdcdTcwQjkiLAogICJcdTMzNjAiLAogICJcdTAwMzhcdTcwQjkiLAogICJcdTMzNjEiLAogICJcdTAwMzlcdTcwQjkiLAogICJcdTMzNjIiLAogICJcdTAwMzFcdTAwMzBcdTcwQjkiLAogICJcdTMzNjMiLAogICJcdTAwMzFcdTAwMzFcdTcwQjkiLAogICJcdTMzNjQiLAogICJcdTAwMzFcdTAwMzJcdTcwQjkiLAogICJcdTMz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ZCMDYiLAogICJcdTAwNzNcdTAwNzQiLAogICJcdUZCMTMiLAogICJcdTA1NzRcdTA1NzYiLAogICJcdUZCMTQiLAogICJcdTA1NzRcdTA1NjUiLAogICJcdUZCMTUiLAogICJcdTA1NzRcdTA1NkIiLAogICJcdUZCMTYiLAogICJcdTA1N0VcdTA1NzYiLAogICJcdUZCMTciLAogICJcdTA1NzRcdTA1NkQiLAogICJcdUZCNEYiLAogICJcdTA1RDBcdTA1REMiLAogICJcdUZCNTAiLAogICJcdTA2NzEiLAogICJcdUZCNTEiLAogICJcdTA2NzEiLAogICJcdUZCNTIiLAogICJcdTA2N0IiLAogICJcdUZCNTMiLAogICJcdTA2N0IiLAogICJcdUZCNTQiLAogICJcdTA2N0IiLAogICJcdUZCNTUiLAogICJcdTA2N0IiLAogICJcdUZCNTYiLAogICJcdTA2N0UiLAogICJcdUZCNTciLAogICJcdTA2N0UiLAogICJcdUZCNTgiLAogICJcdTA2N0UiLAogICJcdUZCNTkiLAogICJcdTA2N0UiLAogICJcdUZCNUEiLAogICJcdTA2ODAiLAogICJcdUZCNUIiLAogICJcdTA2ODAiLAogICJcdUZCNUMiLAogICJcdTA2ODAiLAogICJcdUZCNUQiLAogICJcdTA2ODAiLAogICJcdUZCNUUiLAogICJcdTA2N0EiLAogICJcdUZCNUYiLAogICJcdTA2N0EiLAogICJcdUZCNjAiLAogICJcdTA2N0EiLAogICJcdUZCNjEiLAogICJcdTA2N0EiLAogICJcdUZCNjIiLAogICJcdTA2N0YiLAogICJcdUZCNjMiLAogICJcdTA2N0YiLAogICJcdUZCNjQiLAogICJcdTA2N0YiLAogICJcdUZCNjUiLAogICJcdTA2N0YiLAogICJcdUZCNjYiLAogICJcdTA2NzkiLAogICJcdUZCNjciLAogICJcdTA2NzkiLAogICJcdUZCNjgiLAogICJcdTA2NzkiLAogICJcdUZCNjkiLAogICJcdTA2NzkiLAogICJcdUZCNkEiLAogICJcdTA2QTQiLAogICJcdUZCNkIiLAogICJcdTA2QTQiLAogICJcdUZCNkMiLAogICJcdTA2QTQiLAogICJcdUZCNkQiLAogICJcdTA2QTQiLAogICJcdUZCNkUiLAogICJcdTA2QTYiLAogICJcdUZCNkYiLAogICJcdTA2QTYiLAogICJcdUZCNzAiLAogICJcdTA2QTYiLAogICJcdUZCNzEiLAogICJcdTA2QTYiLAogICJcdUZCNzIiLAogICJcdTA2ODQiLAogICJcdUZCNzMiLAogICJcdTA2ODQiLAogICJcdUZCNzQiLAogICJcdTA2ODQiLAogICJcdUZCNzUiLAogICJcdTA2ODQiLAogICJcdUZCNzYiLAogICJcdTA2ODMiLAogICJcdUZCNzciLAogICJcdTA2ODMiLAogICJcdUZCNzgiLAogICJcdTA2ODMiLAogICJcdUZCNzkiLAogICJcdTA2ODMiLAogICJcdUZCN0EiLAogICJcdTA2ODYiLAogICJcdUZCN0IiLAogICJcdTA2ODYiLAogICJcdUZCN0MiLAogICJcdTA2ODYiLAogICJcdUZCN0QiLAogICJcdTA2ODYiLAogICJcdUZCN0UiLAogICJcdTA2ODciLAogICJcdUZCN0YiLAogICJcdTA2ODciLAogICJcdUZCODAiLAogICJcdTA2ODciLAogICJcdUZCODEiLAogICJcdTA2ODciLAogICJcdUZCODIiLAogICJcdTA2OEQiLAogICJcdUZCODMiLAogICJcdTA2OEQiLAogICJcdUZCODQiLAogICJcdTA2OEMiLAogICJcdUZCODUiLAogICJcdTA2OEMiLAogICJcdUZCODYiLAogICJcdTA2OEUiLAogICJcdUZCODciLAogICJcdTA2OEUiLAogICJcdUZCODgiLAogICJcdTA2ODgiLAogICJcdUZCODkiLAogICJcdTA2ODgiLAogICJcdUZCOEEiLAogICJcdTA2OTgiLAogICJcdUZCOEIiLAogICJcdTA2OTgiLAogICJcdUZCOEMiLAogICJcdTA2OTEiLAogICJcdUZCOEQiLAogICJcdTA2OTEiLAogICJcdUZCOEUiLAogICJcdTA2QTkiLAogICJcdUZCOEYiLAogICJcdTA2QTkiLAogICJcdUZCOTAiLAogICJcdTA2QTkiLAogICJcdUZCOTEiLAogICJcdTA2QTkiLAogICJcdUZCOTIiLAogICJcdTA2QUYiLAogICJcdUZCOTMiLAogICJcdTA2QUYiLAogICJcdUZCOTQiLAogICJcdTA2QUYiLAogICJcdUZCOTUiLAogICJcdTA2QUYiLAogICJcdUZCOTYiLAogICJcdTA2QjMiLAogICJcdUZCOTciLAogICJcdTA2QjMiLAogICJcdUZCOTgiLAogICJcdTA2QjMiLAogICJcdUZCOTkiLAogICJcdTA2QjMiLAogICJcdUZCOUEiLAogICJcdTA2QjEiLAogICJcdUZCOUIiLAogICJcdTA2QjEiLAogICJcdUZCOUMiLAogICJcdTA2QjEiLAogICJcdUZCOUQiLAogICJcdTA2QjEiLAogICJcdUZCOUUiLAogICJcdTA2QkEiLAogICJcdUZCOUYiLAogICJcdTA2QkEiLAogICJcdUZCQTAiLAogICJcdTA2QkIiLAogICJcdUZCQTEiLAogICJcdTA2QkIiLAogICJcdUZCQTIiLAogICJcdTA2QkIiLAogICJcdUZCQTMiLAogICJcdTA2QkIiLAogICJcdUZCQTQiLAogICJcdTA2QzAiLAogICJcdUZCQTUiLAogICJcdTA2QzAiLAogICJcdUZCQTYiLAogICJcdTA2QzEiLAogICJcdUZCQTciLAogICJcdTA2QzEiLAogICJcdUZCQTgiLAogICJcdTA2QzEiLAogICJcdUZCQTkiLAogICJcdTA2QzEiLAogICJcdUZCQUEiLAogICJcdTA2QkUiLAogICJcdUZCQUIiLAogICJcdTA2QkUiLAogICJcdUZCQUMiLAogICJcdTA2QkUiLAogICJcdUZCQUQiLAogICJcdTA2QkUiLAogICJcdUZCQUUiLAogICJcdTA2RDIiLAogICJcdUZCQUYiLAogICJcdTA2RDIiLAogICJcdUZCQjAiLAogICJcdTA2RDMiLAogICJcdUZCQjEiLAogICJcdTA2RDMiLAogICJcdUZCRDMiLAogICJcdTA2QUQiLAogICJcdUZCRDQiLAogICJcdTA2QUQiLAogICJcdUZCRDUiLAogICJcdTA2QUQiLAogICJcdUZCRDYiLAogICJcdTA2QUQiLAogICJcdUZCRDciLAogICJcdTA2QzciLAogICJcdUZCRDgiLAogICJcdTA2QzciLAogICJcdUZCRDkiLAogICJcdTA2QzYiLAogICJcdUZCREEiLAogICJcdTA2QzYiLAogICJcdUZCREIiLAogICJcdTA2QzgiLAogICJcdUZCREMiLAogICJcdTA2QzgiLAogICJcdUZCREQiLAogICJcdTA2NzciLAogICJcdUZCREUiLAogICJcdTA2Q0IiLAogICJcdUZCREYiLAogICJcdTA2Q0IiLAogICJcdUZCRTAiLAogICJcdTA2QzUiLAogICJcdUZCRTEiLAogICJcdTA2QzUiLAogICJcdUZCRTIiLAogICJcdTA2QzkiLAogICJcdUZCRTMiLAogICJcdTA2QzkiLAogICJcdUZCRTQiLAogICJcdTA2RDAiLAogICJcdUZCRTUiLAogICJcdTA2RDAiLAogICJcdUZCRTYiLAogICJcdTA2RDAiLAogICJcdUZCRTciLAogICJcdTA2RDAiLAogICJcdUZCRTgiLAogICJcdTA2NDkiLAogICJcdUZCRTkiLAogICJcdTA2NDkiLAogICJcdUZCRUEiLAogICJcdTA2MjZcdTA2MjciLAogICJcdUZCRUIiLAogICJcdTA2MjZcdTA2MjciLAogICJcdUZCRUMiLAogICJcdTA2MjZcdTA2RDUiLAogICJcdUZCRUQiLAogICJcdTA2MjZcdTA2RDUiLAogICJcdUZCRUUiLAogICJcdTA2MjZcdTA2NDgiLAogICJcdUZCRUYiLAogICJcdTA2MjZcdTA2NDgiLAogICJcdUZCRjAiLAogICJcdTA2MjZcdTA2QzciLAogICJcdUZCRjEiLAogICJcdTA2MjZcdTA2QzciLAogICJcdUZCRjIiLAogICJcdTA2MjZcdTA2QzYiLAogICJcdUZCRjMiLAogICJcdTA2MjZcdTA2QzYiLAogICJcdUZCRjQiLAogICJcdTA2MjZcdTA2QzgiLAogICJcdUZCRjUiLAogICJcdTA2MjZcdTA2QzgiLAogICJcdUZCRjYiLAogICJcdTA2MjZcdTA2RDAiLAogICJcdUZCRjciLAogICJcdTA2MjZcdTA2RDAiLAogICJcdUZCRjgiLAogICJcdTA2MjZcdTA2RDAiLAogICJcdUZCRjkiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZCRkEiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZCRkIiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZCRkMiLAogICJcdTA2Q0MiLAogICJcdUZCRkQiLAogICJcdTA2Q0MiLAogICJcdUZCRkUiLAogICJcdTA2Q0MiLAogICJcdUZCRkYiLAogICJcdTA2Q0MiLAogICJcdUZDMDAiLAogICJcdTA2MjZcdTA2MkMiLAogICJcdUZDMDEiLAogICJcdTA2MjZcdTA2MkQiLAogICJcdUZDMDIiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDMDMiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZDMDQiLAogICJcdTA2MjZcdTA2NEEiLAogICJcdUZDMDUiLAogICJcdTA2MjhcdTA2MkMiLAogICJcdUZDMDYiLAogICJcdTA2MjhcdTA2MkQiLAogICJcdUZDMDciLAogICJcdTA2MjhcdTA2MkUiLAogICJcdUZDMDgiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDMDkiLAogICJcdTA2MjhcdTA2NDkiLAogICJcdUZDMEEiLAogICJcdTA2MjhcdTA2NEEiLAogICJcdUZDMEIiLAogICJcdTA2MkFcdTA2MkMiLAogICJcdUZDMEMiLAogICJcdTA2MkFcdTA2MkQiLAogICJcdUZDMEQiLAogICJcdTA2MkFcdTA2MkUiLAogICJcdUZDMEUiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDMEYiLAogICJcdTA2MkFcdTA2NDkiLAogICJcdUZDMTAiLAogICJcdTA2MkFcdTA2NEEiLAogICJcdUZDMTEiLAogICJcdTA2MkJcdTA2MkMiLAogICJcdUZDMTIiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDMTMiLAogICJcdTA2MkJcdTA2NDkiLAogICJcdUZDMTQiLAogICJcdTA2MkJcdTA2NEEiLAogICJcdUZDMTUiLAogICJcdTA2MkNcdTA2MkQiLAogICJcdUZDMTYiLAogICJcdTA2MkNcdTA2NDUiLAogICJcdUZDMTciLAogICJcdTA2MkRcdTA2MkMiLAogICJcdUZDMTgiLAogICJcdTA2MkRcdTA2NDUiLAogICJcdUZDMTkiLAogICJcdTA2MkVcdTA2MkMiLAogICJcdUZDMUEiLAogICJcdTA2MkVcdTA2MkQiLAogICJcdUZDMUIiLAogICJcdTA2MkVcdTA2NDUiLAogICJcdUZDMUMiLAogICJcdTA2MzNcdTA2MkMiLAogICJcdUZDMUQiLAogICJcdTA2MzNcdTA2MkQiLAogICJcdUZDMUUiLAogICJcdTA2MzNcdTA2MkUiLAogICJcdUZDMUYiLAogICJcdTA2MzNcdTA2NDUiLAogICJcdUZDMjAiLAogICJcdTA2MzVcdTA2MkQiLAogICJcdUZDMjEiLAogICJcdTA2MzVcdTA2NDUiLAogICJcdUZDMjIiLAogICJcdTA2MzZcdTA2MkMiLAogICJcdUZDMjMiLAogICJcdTA2MzZcdTA2MkQiLAogICJcdUZDMjQiLAogICJcdTA2MzZcdTA2MkUiLAogICJcdUZDMjUiLAogICJcdTA2MzZcdTA2NDUiLAogICJcdUZDMjYiLAogICJcdTA2MzdcdTA2MkQiLAogICJcdUZDMjciLAogICJcdTA2MzdcdTA2NDUiLAogICJcdUZDMjgiLAogICJcdTA2MzhcdTA2NDUiLAogICJcdUZDMjkiLAogICJcdTA2MzlcdTA2MkMiLAogICJcdUZDMkEiLAogICJcdTA2MzlcdTA2NDUiLAogICJcdUZDMkIiLAogICJcdTA2M0FcdTA2MkMiLAogICJcdUZDMkMiLAogICJcdTA2M0FcdTA2NDUiLAogICJcdUZDMkQiLAogICJcdTA2NDFcdTA2MkMiLAogICJcdUZDMkUiLAogICJcdTA2NDFcdTA2MkQiLAogICJcdUZDMkYiLAogICJcdTA2NDFcdTA2MkUiLAogICJcdUZDMzAiLAogICJcdTA2NDFcdTA2NDUiLAogICJcdUZDMzEiLAogICJcdTA2NDFcdTA2NDkiLAogICJcdUZDMzIiLAogICJcdTA2NDFcdTA2NEEiLAogICJcdUZDMzMiLAogICJcdTA2NDJcdTA2MkQiLAogICJcdUZDMzQiLAogICJcdTA2NDJcdTA2NDUiLAogICJcdUZDMzUiLAogICJcdTA2NDJcdTA2NDkiLAogICJcdUZDMzYiLAogICJcdTA2NDJcdTA2NEEiLAogICJcdUZDMzciLAogICJcdTA2NDNcdTA2MjciLAogICJcdUZDMzgiLAogICJcdTA2NDNcdTA2MkMiLAogICJcdUZDMzkiLAogICJcdTA2NDNcdTA2MkQiLAogICJcdUZDM0EiLAogICJcdTA2NDNcdTA2MkUiLAogICJcdUZDM0IiLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDM0MiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDM0QiLAogICJcdTA2NDNcdTA2NDkiLAogICJcdUZDM0UiLAogICJcdTA2NDNcdTA2NEEiLAogICJcdUZDM0YiLAogICJcdTA2NDRcdTA2MkMiLAogICJcdUZDNDAiLAogICJcdTA2NDRcdTA2MkQiLAogICJcdUZDNDEiLAogICJcdTA2NDRcdTA2MkUiLAogICJcdUZDNDIiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDNDMiLAogICJcdTA2NDRcdTA2NDkiLAogICJcdUZDNDQiLAogICJcdTA2NDRcdTA2NEEiLAogICJcdUZDNDUiLAogICJcdTA2NDVcdTA2MkMiLAogICJcdUZDNDYiLAogICJcdTA2NDVcdTA2MkQiLAogICJcdUZDNDciLAogICJcdTA2NDVcdTA2MkUiLAogICJcdUZDNDgiLAogICJcdTA2NDVcdTA2NDUiLAogICJcdUZDNDkiLAogICJcdTA2NDVcdTA2NDkiLAogICJcdUZDNEEiLAogICJcdTA2NDVcdTA2NEEiLAogICJcdUZDNEIiLAogICJcdTA2NDZcdTA2MkMiLAogICJcdUZDNEMiLAogICJcdTA2NDZcdTA2MkQiLAogICJcdUZDNEQiLAogICJcdTA2NDZcdTA2MkUiLAogICJcdUZDNEUiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDNEYiLAogICJcdTA2NDZcdTA2NDkiLAogICJcdUZDNTAiLAogICJcdTA2NDZcdTA2NEEiLAogICJcdUZDNTEiLAogICJcdTA2NDdcdTA2MkMiLAogICJcdUZDNTIiLAogICJcdTA2NDdcdTA2NDUiLAogICJcdUZDNTMiLAogICJcdTA2NDdcdTA2NDkiLAogICJcdUZDNTQiLAogICJcdTA2NDdcdTA2NEEiLAogICJcdUZDNTUiLAogICJcdTA2NEFcdTA2MkMiLAogICJcdUZDNTYiLAogICJcdTA2NEFcdTA2MkQiLAogICJcdUZDNTciLAogICJcdTA2NEFcdTA2MkUiLAogICJcdUZDNTgiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDNTkiLAogICJcdTA2NEFcdTA2NDkiLAogICJcdUZDNUEiLAogICJcdTA2NEFcdTA2NEEiLAogICJcdUZDNUIiLAogICJcdTA2MzBcdTA2NzAiLAogICJcdUZDNUMiLAogICJcdTA2MzFcdTA2NzAiLAogICJcdUZDNUQiLAogICJcdTA2NDlcdTA2NzAiLAogICJcdUZDNUUiLAogICJcdTAwMjBcdTA2NENcdTA2NTEiLAogICJcdUZDNUYiLAogICJcdTAwMjBcdTA2NERcdTA2NTEiLAogICJcdUZDNjAiLAogICJcdTAwMjBcdTA2NEVcdTA2NTEiLAogICJcdUZDNjEiLAogICJcdTAwMjBcdTA2NEZcdTA2NTEiLAogICJcdUZDNjIiLAogICJcdTAwMjBcdTA2NTBcdTA2NTEiLAogICJcdUZDNjMiLAogICJcdTAwMjBcdTA2NTFcdTA2NzAiLAogICJcdUZDNjQiLAogICJcdTA2MjZcdTA2MzEiLAogICJcdUZDNjUiLAogICJcdTA2MjZcdTA2MzIiLAogICJcdUZDNjYiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDNjciLAogICJcdTA2MjZcdTA2NDYiLAogICJcdUZDNjgiLAogICJcdTA2MjZcdTA2NDkiLAogICJcdUZDNjkiLAogICJcdTA2MjZcdTA2NEEiLAogICJcdUZDNkEiLAogICJcdTA2MjhcdTA2MzEiLAogICJcdUZDNkIiLAogICJcdTA2MjhcdTA2MzIiLAogICJcdUZDNkMiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDNkQiLAogICJcdTA2MjhcdTA2NDYiLAogICJcdUZDNkUiLAogICJcdTA2MjhcdTA2NDkiLAogICJcdUZDNkYiLAogICJcdTA2MjhcdTA2NEEiLAogICJcdUZDNzAiLAogICJcdTA2MkFcdTA2MzEiLAogICJcdUZDNzEiLAogICJcdTA2MkFcdTA2MzIiLAogICJcdUZDNzIiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDNzMiLAogICJcdTA2MkFcdTA2NDYiLAogICJcdUZDNzQiLAogICJcdTA2MkFcdTA2NDkiLAogICJcdUZDNzUiLAogICJcdTA2MkFcdTA2NEEiLAogICJcdUZDNzYiLAogICJcdTA2MkJcdTA2MzEiLAogICJcdUZDNzciLAogICJcdTA2MkJcdTA2MzIiLAogICJcdUZDNzgiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDNzkiLAogICJcdTA2MkJcdTA2NDYiLAogICJcdUZDN0EiLAogICJcdTA2MkJcdTA2NDkiLAogICJcdUZDN0IiLAogICJcdTA2MkJcdTA2NEEiLAogICJcdUZDN0MiLAogICJcdTA2NDFcdTA2NDkiLAogICJcdUZDN0QiLAogICJcdTA2NDFcdTA2NEEiLAogICJcdUZDN0UiLAogICJcdTA2NDJcdTA2NDkiLAogICJcdUZDN0YiLAogICJcdTA2NDJcdTA2NEEiLAogICJcdUZDODAiLAogICJcdTA2NDNcdTA2MjciLAogICJcdUZDODEiLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDODIiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDODMiLAogICJcdTA2NDNcdTA2NDkiLAogICJcdUZDODQiLAogICJcdTA2NDNcdTA2NEEiLAogICJcdUZDODUiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDODYiLAogICJcdTA2NDRcdTA2NDkiLAogICJcdUZDODciLAogICJcdTA2NDRcdTA2NEEiLAogICJcdUZDODgiLAogICJcdTA2NDVcdTA2MjciLAogICJcdUZDODkiLAogICJcdTA2NDVcdTA2NDUiLAogICJcdUZDOEEiLAogICJcdTA2NDZcdTA2MzEiLAogICJcdUZDOEIiLAogICJcdTA2NDZcdTA2MzIiLAogICJcdUZDOEMiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDOEQiLAogICJcdTA2NDZcdTA2NDYiLAogICJcdUZDOEUiLAogICJcdTA2NDZcdTA2NDkiLAogICJcdUZDOEYiLAogICJcdTA2NDZcdTA2NEEiLAogICJcdUZDOTAiLAogICJcdTA2NDlcdTA2NzAiLAogICJcdUZDOTEiLAogICJcdTA2NEFcdTA2MzEiLAogICJcdUZDOTIiLAogICJcdTA2NEFcdTA2MzIiLAogICJcdUZDOTMiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDOTQiLAogICJcdTA2NEFcdTA2NDYiLAogICJcdUZDOTUiLAogICJcdTA2NEFcdTA2NDkiLAogICJcdUZDOTYiLAogICJcdTA2NEFcdTA2NEEiLAogICJcdUZDOTciLAogICJcdTA2MjZcdTA2MkMiLAogICJcdUZDOTgiLAogICJcdTA2MjZcdTA2MkQiLAogICJcdUZDOTkiLAogICJcdTA2MjZcdTA2MkUiLAogICJcdUZDOUEiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDOUIiLAogICJcdTA2MjZcdTA2NDciLAogICJcdUZDOUMiLAogICJcdTA2MjhcdTA2MkMiLAogICJcdUZDOUQiLAogICJcdTA2MjhcdTA2MkQiLAogICJcdUZDOUUiLAogICJcdTA2MjhcdTA2MkUiLAogICJcdUZDOUYiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDQTAiLAogICJcdTA2MjhcdTA2NDciLAogICJcdUZDQTEiLAogICJcdTA2MkFcdTA2MkMiLAogICJcdUZDQTIiLAogICJcdTA2MkFcdTA2MkQiLAogICJcdUZDQTMiLAogICJcdTA2MkFcdTA2MkUiLAogICJcdUZDQTQiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDQTUiLAogICJcdTA2MkFcdTA2NDciLAogICJcdUZDQTYiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDQTciLAogICJcdTA2MkNcdTA2MkQiLAogICJcdUZDQTgiLAogICJcdTA2MkNcdTA2NDUiLAogICJcdUZDQTkiLAogICJcdTA2MkRcdTA2MkMiLAogICJcdUZDQUEiLAogICJcdTA2MkRcdTA2NDUiLAogICJcdUZDQUIiLAogICJcdTA2MkVcdTA2MkMiLAogICJcdUZDQUMiLAogICJcdTA2MkVcdTA2NDUiLAogICJcdUZDQUQiLAogICJcdTA2MzNcdTA2MkMiLAogICJcdUZDQUUiLAogICJcdTA2MzNcdTA2MkQiLAogICJcdUZDQUYiLAogICJcdTA2MzNcdTA2MkUiLAogICJcdUZDQjAiLAogICJcdTA2MzNcdTA2NDUiLAogICJcdUZDQjEiLAogICJcdTA2MzVcdTA2MkQiLAogICJcdUZDQjIiLAogICJcdTA2MzVcdTA2MkUiLAogICJcdUZDQjMiLAogICJcdTA2MzVcdTA2NDUiLAogICJcdUZDQjQiLAogICJcdTA2MzZcdTA2MkMiLAogICJcdUZDQjUiLAogICJcdTA2MzZcdTA2MkQiLAogICJcdUZDQjYiLAogICJcdTA2MzZcdTA2MkUiLAogICJcdUZDQjciLAogICJcdTA2MzZcdTA2NDUiLAogICJcdUZDQjgiLAogICJcdTA2MzdcdTA2MkQiLAogICJcdUZDQjkiLAogICJcdTA2MzhcdTA2NDUiLAogICJcdUZDQkEiLAogICJcdTA2MzlcdTA2MkMiLAogICJcdUZDQkIiLAogICJcdTA2MzlcdTA2NDUiLAogICJcdUZDQkMiLAogICJcdTA2M0FcdTA2MkMiLAogICJcdUZDQkQiLAogICJcdTA2M0FcdTA2NDUiLAogICJcdUZDQkUiLAogICJcdTA2NDFcdTA2MkMiLAogICJcdUZDQkYiLAogICJcdTA2NDFcdTA2MkQiLAogICJcdUZDQzAiLAogICJcdTA2NDFcdTA2MkUiLAogICJcdUZDQzEiLAogICJcdTA2NDFcdTA2NDUiLAogICJcdUZDQzIiLAogICJcdTA2NDJcdTA2MkQiLAogICJcdUZDQzMiLAogICJcdTA2NDJcdTA2NDUiLAogICJcdUZDQzQiLAogICJcdTA2NDNcdTA2MkMiLAogICJcdUZDQzUiLAogICJcdTA2NDNcdTA2MkQiLAogICJcdUZDQzYiLAogICJcdTA2NDNcdTA2MkUiLAogICJcdUZDQzciLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDQzgiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDQzkiLAogICJcdTA2NDRcdTA2MkMiLAogICJcdUZDQ0EiLAogICJcdTA2NDRcdTA2MkQiLAogICJcdUZDQ0IiLAogICJcdTA2NDRcdTA2MkUiLAogICJcdUZDQ0MiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDQ0QiLAogICJcdTA2NDRcdTA2NDciLAogICJcdUZDQ0UiLAogICJcdTA2NDVcdTA2MkMiLAogICJcdUZDQ0YiLAogICJcdTA2NDVcdTA2MkQiLAogICJcdUZDRDAiLAogICJcdTA2NDVcdTA2MkUiLAogICJcdUZDRDEiLAogICJcdTA2NDVcdTA2NDUiLAogICJcdUZDRDIiLAogICJcdTA2NDZcdTA2MkMiLAogICJcdUZDRDMiLAogICJcdTA2NDZcdTA2MkQiLAogICJcdUZDRDQiLAogICJcdTA2NDZcdTA2MkUiLAogICJcdUZDRDUiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDRDYiLAogICJcdTA2NDZcdTA2NDciLAogICJcdUZDRDciLAogICJcdTA2NDdcdTA2MkMiLAogICJcdUZDRDgiLAogICJcdTA2NDdcdTA2NDUiLAogICJcdUZDRDkiLAogICJcdTA2NDdcdTA2NzAiLAogICJcdUZDREEiLAogICJcdTA2NEFcdTA2MkMiLAogICJcdUZDREIiLAogICJcdTA2NEFcdTA2MkQiLAogICJcdUZDREMiLAogICJcdTA2NEFcdTA2MkUiLAogICJcdUZDREQiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDREUiLAogICJcdTA2NEFcdTA2NDciLAogICJcdUZDREYiLAogICJcdTA2MjZcdTA2NDUiLAogICJcdUZDRTAiLAogICJcdTA2MjZcdTA2NDciLAogICJcdUZDRTEiLAogICJcdTA2MjhcdTA2NDUiLAogICJcdUZDRTIiLAogICJcdTA2MjhcdTA2NDciLAogICJcdUZDRTMiLAogICJcdTA2MkFcdTA2NDUiLAogICJcdUZDRTQiLAogICJcdTA2MkFcdTA2NDciLAogICJcdUZDRTUiLAogICJcdTA2MkJcdTA2NDUiLAogICJcdUZDRTYiLAogICJcdTA2MkJcdTA2NDciLAogICJcdUZDRTciLAogICJcdTA2MzNcdTA2NDUiLAogICJcdUZDRTgiLAogICJcdTA2MzNcdTA2NDciLAogICJcdUZDRTkiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZDRUEiLAogICJcdTA2MzRcdTA2NDciLAogICJcdUZDRUIiLAogICJcdTA2NDNcdTA2NDQiLAogICJcdUZDRUMiLAogICJcdTA2NDNcdTA2NDUiLAogICJcdUZDRUQiLAogICJcdTA2NDRcdTA2NDUiLAogICJcdUZDRUUiLAogICJcdTA2NDZcdTA2NDUiLAogICJcdUZDRUYiLAogICJcdTA2NDZcdTA2NDciLAogICJcdUZDRjAiLAogICJcdTA2NEFcdTA2NDUiLAogICJcdUZDRjEiLAogICJcdTA2NEFcdTA2NDciLAogICJcdUZDRjIiLAogICJcdTA2NDBcdTA2NEVcdTA2NTEiLAogICJcdUZDRjMiLAogICJcdTA2NDBcdTA2NEZcdTA2NTEiLAogICJcdUZDRjQiLAogICJcdTA2NDBcdTA2NTBcdTA2NTEiLAogICJcdUZDRjUiLAogICJcdTA2MzdcdTA2NDkiLAogICJcdUZDRjYiLAogICJcdTA2MzdcdTA2NEEiLAogICJcdUZDRjciLAogICJcdTA2MzlcdTA2NDkiLAogICJcdUZDRjgiLAogICJcdTA2MzlcdTA2NEEiLAogICJcdUZDRjkiLAogICJcdTA2M0FcdTA2NDkiLAogICJcdUZDRkEiLAogICJcdTA2M0FcdTA2NEEiLAogICJcdUZDRkIiLAogICJcdTA2MzNcdTA2NDkiLAogICJcdUZDRkMiLAogICJcdTA2MzNcdTA2NEEiLAogICJcdUZDRkQiLAogICJcdTA2MzRcdTA2NDkiLAogICJcdUZDRkUiLAogICJcdTA2MzRcdTA2NEEiLAogICJcdUZDRkYiLAogICJcdTA2MkRcdTA2NDkiLAogICJcdUZEMDAiLAogICJcdTA2MkRcdTA2NEEiLAogICJcdUZEMDEiLAogICJcdTA2MkNcdTA2NDkiLAogICJcdUZEMDIiLAogICJcdTA2MkNcdTA2NEEiLAogICJcdUZEMDMiLAogICJcdTA2MkVcdTA2NDkiLAogICJcdUZEMDQiLAogICJcdTA2MkVcdTA2NEEiLAogICJcdUZEMDUiLAogICJcdTA2MzVcdTA2NDkiLAogICJcdUZEMDYiLAogICJcdTA2MzVcdTA2NEEiLAogICJcdUZEMDciLAogICJcdTA2MzZcdTA2NDkiLAogICJcdUZEMDgiLAogICJcdTA2MzZcdTA2NEEiLAogICJcdUZEMDkiLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMEEiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMEIiLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEMEMiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZEMEQiLAogICJcdTA2MzRcdTA2MzEiLAogICJcdUZEMEUiLAogICJcdTA2MzNcdTA2MzEiLAogICJcdUZEMEYiLAogICJcdTA2MzVcdTA2MzEiLAogICJcdUZEMTAiLAogICJcdTA2MzZcdTA2MzEiLAogICJcdUZEMTEiLAogICJcdTA2MzdcdTA2NDkiLAogICJcdUZEMTIiLAogICJcdTA2MzdcdTA2NEEiLAogICJcdUZEMTMiLAogICJcdTA2MzlcdTA2NDkiLAogICJcdUZEMTQiLAogICJcdTA2MzlcdTA2NEEiLAogICJcdUZEMTUiLAogICJcdTA2M0FcdTA2NDkiLAogICJcdUZEMTYiLAogICJcdTA2M0FcdTA2NEEiLAogICJcdUZEMTciLAogICJcdTA2MzNcdTA2NDkiLAogICJcdUZEMTgiLAogICJcdTA2MzNcdTA2NEEiLAogICJcdUZEMTkiLAogICJcdTA2MzRcdTA2NDkiLAogICJcdUZEMUEiLAogICJcdTA2MzRcdTA2NEEiLAogICJcdUZEMUIiLAogICJcdTA2MkRcdTA2NDkiLAogICJcdUZEMUMiLAogICJcdTA2MkRcdTA2NEEiLAogICJcdUZEMUQiLAogICJcdTA2MkNcdTA2NDkiLAogICJcdUZEMUUiLAogICJcdTA2MkNcdTA2NEEiLAogICJcdUZEMUYiLAogICJcdTA2MkVcdTA2NDkiLAogICJcdUZEMjAiLAogICJcdTA2MkVcdTA2NEEiLAogICJcdUZEMjEiLAogICJcdTA2MzVcdTA2NDkiLAogICJcdUZEMjIiLAogICJcdTA2MzVcdTA2NEEiLAogICJcdUZEMjMiLAogICJcdTA2MzZcdTA2NDkiLAogICJcdUZEMjQiLAogICJcdTA2MzZcdTA2NEEiLAogICJcdUZEMjUiLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMjYiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMjciLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEMjgiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZEMjkiLAogICJcdTA2MzRcdTA2MzEiLAogICJcdUZEMkEiLAogICJcdTA2MzNcdTA2MzEiLAogICJcdUZEMkIiLAogICJcdTA2MzVcdTA2MzEiLAogICJcdUZEMkMiLAogICJcdTA2MzZcdTA2MzEiLAogICJcdUZEMkQiLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMkUiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMkYiLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEMzAiLAogICJcdTA2MzRcdTA2NDUiLAogICJcdUZEMzEiLAogICJcdTA2MzNcdTA2NDciLAogICJcdUZEMzIiLAogICJcdTA2MzRcdTA2NDciLAogICJcdUZEMzMiLAogICJcdTA2MzdcdTA2NDUiLAogICJcdUZEMzQiLAogICJcdTA2MzNcdTA2MkMiLAogICJcdUZEMzUiLAogICJcdTA2MzNcdTA2MkQiLAogICJcdUZEMzYiLAogICJcdTA2MzNcdTA2MkUiLAogICJcdUZEMzciLAogICJcdTA2MzRcdTA2MkMiLAogICJcdUZEMzgiLAogICJcdTA2MzRcdTA2MkQiLAogICJcdUZEMzkiLAogICJcdTA2MzRcdTA2MkUiLAogICJcdUZEM0EiLAogICJcdTA2MzdcdTA2NDUiLAogICJcdUZEM0IiLAogICJcdTA2MzhcdTA2NDUiLAogICJcdUZEM0MiLAogICJcdTA2MjdcdTA2NEIiLAogICJcdUZEM0QiLAogICJcdTA2MjdcdTA2NEIiLAogICJcdUZENTAiLAogICJcdTA2MkFcdTA2MkNcdTA2NDUiLAogICJcdUZENTEiLAogICJcdTA2MkFcdTA2MkRcdTA2MkMiLAogICJcdUZENTIiLAogICJcdTA2MkFcdTA2MkRcdTA2MkMiLAogICJcdUZENTMiLAogICJcdTA2MkFcdTA2MkRcdTA2NDUiLAogICJcdUZENTQiLAogICJcdTA2MkFcdTA2MkVcdTA2NDUiLAogICJcdUZENTUiLAogICJcdTA2MkFcdTA2NDVcdTA2MkMiLAogICJcdUZENTYiLAogICJcdTA2MkFcdTA2NDVcdTA2MkQiLAogICJcdUZENTciLAogICJcdTA2MkFcdTA2NDVcdTA2MkUiLAogICJcdUZENTgiLAogICJcdTA2MkNcdTA2NDVcdTA2MkQiLAogICJcdUZENTkiLAogICJcdTA2MkNcdTA2NDVcdTA2MkQiLAogICJcdUZENUEiLAogICJcdTA2MkRcdTA2NDVcdTA2NEEiLAogICJcdUZENUIiLAogICJcdTA2MkRcdTA2NDVcdTA2NDkiLAogICJcdUZENUMiLAogICJcdTA2MzNcdTA2MkRcdTA2MkMiLAogICJcdUZENUQiLAogICJcdTA2MzNcdTA2MkNcdTA2MkQiLAogICJcdUZENUUiLAogICJcdTA2MzNcdTA2MkNcdTA2NDkiLAogICJcdUZENUYiLAogICJcdTA2MzNcdTA2NDVcdTA2MkQiLAogICJcdUZENjAiLAogICJcdTA2MzNcdTA2NDVcdTA2MkQiLAogICJcdUZENjEiLAogICJcdTA2MzNcdTA2NDVcdTA2MkMiLAogICJcdUZENjIiLAogICJcdTA2MzNcdTA2NDVcdTA2NDUiLAogICJcdUZENjMiLAogICJcdTA2MzNcdTA2NDVcdTA2NDUiLAogICJcdUZENjQiLAogICJcdTA2MzVcdTA2MkRcdTA2MkQiLAogICJcdUZENjUiLAogICJcdTA2MzVcdTA2MkRcdTA2MkQiLAogICJcdUZENjYiLAogICJcdTA2MzVcdTA2NDVcdTA2NDUiLAogICJcdUZENjciLAogICJcdTA2MzRcdTA2MkRcdTA2NDUiLAogICJcdUZENjgiLAogICJcdTA2MzRcdTA2MkRcdTA2NDUiLAogICJcdUZENjkiLAogICJcdTA2MzRcdTA2MkNcdTA2NEEiLAogICJcdUZENkEiLAogICJcdTA2MzRcdTA2NDVcdTA2MkUiLAogICJcdUZENkIiLAogICJcdTA2MzRcdTA2NDVcdTA2MkUiLAogICJcdUZENkMiLAogICJcdTA2MzRcdTA2NDVcdTA2NDUiLAogICJcdUZENkQiLAogICJcdTA2MzRcdTA2NDVcdTA2NDUiLAogICJcdUZENkUiLAogICJcdTA2MzZcdTA2MkRcdTA2NDkiLAogICJcdUZENkYiLAogICJcdTA2MzZcdTA2MkVcdTA2NDUiLAogICJcdUZENzAiLAogICJcdTA2MzZcdTA2MkVcdTA2NDUiLAogICJcdUZENzEiLAogICJcdTA2MzdcdTA2NDVcdTA2MkQiLAogICJcdUZENzIiLAogICJcdTA2MzdcdTA2NDVcdTA2MkQiLAogICJcdUZENzMiLAogICJcdTA2MzdcdTA2NDVcdTA2NDUiLAogICJcdUZENzQiLAogICJcdTA2MzdcdTA2NDVcdTA2NEEiLAogICJcdUZENzUiLAogICJcdTA2MzlcdTA2MkNcdTA2NDUiLAogICJcdUZENzYiLAogICJcdTA2MzlcdTA2NDVcdTA2NDUiLAogICJcdUZENzciLAogICJcdTA2MzlcdTA2NDVcdTA2NDUiLAogICJcdUZENzgiLAogICJcdTA2MzlcdTA2NDVcdTA2NDkiLAogICJcdUZENzkiLAogICJcdTA2M0FcdTA2NDVcdTA2NDUiLAogICJcdUZEN0EiLAogICJcdTA2M0FcdTA2NDVcdTA2NEEiLAogICJcdUZEN0IiLAogICJcdTA2M0FcdTA2NDVcdTA2NDkiLAogICJcdUZEN0MiLAogICJcdTA2NDFcdTA2MkVcdTA2NDUiLAogICJcdUZEN0QiLAogICJcdTA2NDFcdTA2MkVcdTA2NDUiLAogICJcdUZEN0UiLAogICJcdTA2NDJcdTA2NDVcdTA2MkQiLAogICJcdUZEN0YiLAogICJcdTA2NDJcdTA2NDVcdTA2NDUiLAogICJcdUZEODAiLAogICJcdTA2NDRcdTA2MkRcdTA2NDUiLAogICJcdUZEODEiLAogICJcdTA2NDRcdTA2MkRcdTA2NEEiLAogICJcdUZEODIiLAogICJcdTA2NDRcdTA2MkRcdTA2NDkiLAogICJcdUZEODMiLAogICJcdTA2NDRcdTA2MkNcdTA2MkMiLAogICJcdUZEODQiLAogICJcdTA2NDRcdTA2MkNcdTA2MkMiLAogICJcdUZEODUiLAogICJcdTA2NDRcdTA2MkVcdTA2NDUiLAogICJcdUZEODYiLAogICJcdTA2NDRcdTA2MkVcdTA2NDUiLAogICJcdUZEODciLAogICJcdTA2NDRcdTA2NDVcdTA2MkQiLAogICJcdUZEODgiLAogICJcdTA2NDRcdTA2NDVcdTA2MkQiLAogICJcdUZEODkiLAogICJcdTA2NDVcdTA2MkRcdTA2MkMiLAogICJcdUZEOEEiLAogICJcdTA2NDVcdTA2MkRcdTA2NDUiLAogICJcdUZEOEIiLAogICJcdTA2NDVcdTA2MkRcdTA2NEEiLAogICJcdUZEOEMiLAogICJ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ogICJcdUZEQkQiLAogICJcdTA2NDZcdTA2MkNcdTA2MkQiLAogICJcdUZEQkUiLAogICJcdTA2MkNcdTA2MkRcdTA2NEEiLAogICJcdUZEQkYiLAogICJcdTA2MkRcdTA2MkNcdTA2NEEiLAogICJcdUZEQzAiLAogICJcdTA2NDVcdTA2MkNcdTA2NEEiLAogICJcdUZEQzEiLAogICJcdTA2NDFcdTA2NDVcdTA2NEEiLAogICJcdUZEQzIiLAogICJcdTA2MjhcdTA2MkRcdTA2NEEiLAogICJcdUZEQzMiLAogICJcdTA2NDNcdTA2NDVcdTA2NDUiLAogICJcdUZEQzQiLAogICJcdTA2MzlcdTA2MkNcdTA2NDUiLAogICJcdUZEQzUiLAogICJcdTA2MzVcdTA2NDVcdTA2NDUiLAogICJcdUZEQzYiLAogICJcdTA2MzNcdTA2MkVcdTA2NEEiLAogICJcdUZEQzciLAogICJcdTA2NDZcdTA2MkNcdTA2NEEiLAogICJcdUZFNDkiLAogICJcdTIwM0UiLAogICJcdUZFNEEiLAogICJcdTIwM0UiLAogICJcdUZFNEIiLAogICJcdTIwM0UiLAogICJcdUZFNEMiLAogICJcdTIwM0UiLAogICJcdUZFNEQiLAogICJcdTAwNUYiLAogICJcdUZFNEUiLAogICJcdTAwNUYiLAogICJcdUZFNEYiLAogICJcdTAwNUYiLAogICJcdUZFODAiLAogICJcdTA2MjEiLAogICJcdUZFODEiLAogICJcdTA2MjIiLAogICJcdUZFODIiLAogICJcdTA2MjIiLAogICJcdUZFODMiLAogICJcdTA2MjMiLAogICJcdUZFODQiLAogICJcdTA2MjMiLAogICJcdUZFODUiLAogICJcdTA2MjQiLAogICJcdUZFODYiLAogICJcdTA2MjQiLAogICJcdUZFODciLAogICJcdTA2MjUiLAogICJcdUZFODgiLAogICJcdTA2MjUiLAogICJcdUZFODkiLAogICJcdTA2MjYiLAogICJcdUZFOEEiLAogICJcdTA2MjYiLAogICJcdUZFOEIiLAogICJcdTA2MjYiLAogICJcdUZFOEMiLAogICJcdTA2MjYiLAogICJcdUZFOEQiLAogICJcdTA2MjciLAogICJcdUZFOEUiLAogICJcdTA2MjciLAogICJcdUZFOEYiLAogICJcdTA2MjgiLAogICJcdUZFOTAiLAogICJcdTA2MjgiLAogICJcdUZFOTEiLAogICJcdTA2MjgiLAogICJcdUZFOTIiLAogICJcdTA2MjgiLAogICJcdUZFOTMiLAogICJcdTA2MjkiLAogICJcdUZFOTQiLAogICJcdTA2MjkiLAogICJcdUZFOTUiLAogICJcdTA2MkEiLAogICJcdUZFOTYiLAogICJcdTA2MkEiLAogICJcdUZFOTciLAogICJcdTA2MkEiLAogICJcdUZFOTgiLAogICJcdTA2MkEiLAogICJcdUZFOTkiLAogICJcdTA2MkIiLAogICJcdUZFOUEiLAogICJcdTA2MkIiLAogICJcdUZFOUIiLAogICJcdTA2MkIiLAogICJcdUZFOUMiLAogICJcdTA2MkIiLAogICJcdUZFOUQiLAogICJcdTA2MkMiLAogICJcdUZFOUUiLAogICJcdTA2MkMiLAogICJcdUZFOUYiLAogICJcdTA2MkMiLAogICJcdUZFQTAiLAogICJcdTA2MkMiLAogICJcdUZFQTEiLAogICJcdTA2MkQiLAogICJcdUZFQTIiLAogICJcdTA2MkQiLAogICJcdUZFQTMiLAogICJcdTA2MkQiLAogICJcdUZFQTQiLAogICJcdTA2MkQiLAogICJcdUZFQTUiLAogICJcdTA2MkUiLAogICJcdUZFQTYiLAogICJcdTA2MkUiLAogICJcdUZFQTciLAogICJcdTA2MkUiLAogICJcdUZFQTgiLAogICJcdTA2MkUiLAogICJcdUZFQTkiLAogICJcdTA2MkYiLAogICJcdUZFQUEiLAogICJcdTA2MkYiLAogICJcdUZFQUIiLAogICJcdTA2MzAiLAogICJcdUZFQUMiLAogICJcdTA2MzAiLAogICJcdUZFQUQiLAogICJcdTA2MzEiLAogICJcdUZFQUUiLAogICJcdTA2MzEiLAogICJcdUZFQUYiLAogICJcdTA2MzIiLAogICJcdUZFQjAiLAogICJcdTA2MzIiLAogICJcdUZFQjEiLAogICJcdTA2MzMiLAogICJcdUZFQjIiLAogICJcdTA2MzMiLAogICJcdUZFQjMiLAogICJcdTA2MzMiLAogICJcdUZFQjQiLAogICJcdTA2MzMiLAogICJcdUZFQjUiLAogICJcdTA2MzQiLAogICJcdUZFQjYiLAogICJcdTA2MzQiLAogICJcdUZFQjciLAogICJcdTA2MzQiLAogICJcdUZFQjgiLAogICJcdTA2MzQiLAogICJcdUZFQjkiLAogICJcdTA2MzUiLAogICJcdUZFQkEiLAogICJcdTA2MzUiLAogICJcdUZFQkIiLAogICJcdTA2MzUiLAogICJcdUZFQkMiLAogICJcdTA2MzUiLAogICJcdUZFQkQiLAogICJcdTA2MzYiLAogICJcdUZFQkUiLAogICJcdTA2MzYiLAogICJcdUZFQkYiLAogICJcdTA2MzYiLAogICJcdUZFQzAiLAogICJcdTA2MzYiLAogICJcdUZFQzEiLAogICJcdTA2MzciLAogICJcdUZFQzIiLAogICJcdTA2MzciLAogICJcdUZFQzMiLAogICJcdTA2MzciLAogICJcdUZFQzQiLAogICJcdTA2MzciLAogICJcdUZFQzUiLAogICJcdTA2MzgiLAogICJcdUZFQzYiLAogICJcdTA2MzgiLAogICJcdUZFQzciLAogICJcdTA2MzgiLAogICJcdUZFQzgiLAogICJcdTA2MzgiLAogICJcdUZFQzkiLAogICJcdTA2MzkiLAogICJcdUZFQ0EiLAogICJcdTA2MzkiLAogICJcdUZFQ0IiLAogICJcdTA2MzkiLAogICJcdUZFQ0MiLAogICJcdTA2MzkiLAogICJcdUZFQ0QiLAogICJcdTA2M0EiLAogICJcdUZFQ0UiLAogICJcdTA2M0EiLAogICJcdUZFQ0YiLAogICJcdTA2M0EiLAogICJcdUZFRDAiLAogICJcdTA2M0EiLAogICJcdUZFRDEiLAogICJcdTA2NDEiLAogICJcdUZFRDIiLAogICJcdTA2NDEiLAogICJcdUZFRDMiLAogICJcdTA2NDEiLAogICJcdUZFRDQiLAogICJcdTA2NDEiLAogICJcdUZFRDUiLAogICJcdTA2NDIiLAogICJcdUZFRDYiLAogICJcdTA2NDIiLAogICJcdUZFRDciLAogICJcdTA2NDIiLAogICJcdUZFRDgiLAogICJcdTA2NDIiLAogICJcdUZFRDkiLAogICJcdTA2NDMiLAogICJcdUZFREEiLAogICJcdTA2NDMiLAogICJcdUZFREIiLAogICJcdTA2NDMiLAogICJcdUZFREMiLAogICJcdTA2NDMiLAogICJcdUZFREQiLAogICJcdTA2NDQiLAogICJcdUZFREUiLAogICJcdTA2NDQiLAogICJcdUZFREYiLAogICJcdTA2NDQiLAogICJcdUZFRTAiLAogICJcdTA2NDQiLAogICJcdUZFRTEiLAogICJcdTA2NDUiLAogICJcdUZFRTIiLAogICJcdTA2NDUiLAogICJcdUZFRTMiLAogICJcdTA2NDUiLAogICJcdUZFRTQiLAogICJcdTA2NDUiLAogICJcdUZFRTUiLAogICJcdTA2NDYiLAogICJcdUZFRTYiLAogICJcdTA2NDYiLAogICJcdUZFRTciLAogICJcdTA2NDYiLAogICJcdUZFRTgiLAogICJcdTA2NDYiLAogICJcdUZFRTkiLAogICJcdTA2NDciLAogICJcdUZFRUEiLAogICJcdTA2NDciLAogICJcdUZFRUIiLAogICJcdTA2NDciLAogICJcdUZFRUMiLAogICJcdTA2NDciLAogICJcdUZFRUQiLAogICJcdTA2NDgiLAogICJcdUZFRUUiLAogICJcdTA2NDgiLAogICJcdUZFRUYiLAogICJcdTA2NDkiLAogICJcdUZFRjAiLAogICJcdTA2NDkiLAogICJcdUZFRjEiLAogICJcdTA2NEEiLAogICJcdUZFRjIiLAogICJcdTA2NEEiLAogICJcdUZFRjMiLAogICJcdTA2NEEiLAogICJcdUZFRjQiLAogICJcdTA2NEEiLAogICJcdUZFRjUiLAogICJcdTA2NDRcdTA2MjIiLAogICJcdUZFRjYiLAogICJcdTA2NDRcdTA2MjIiLAogICJcdUZFRjciLAogICJcdTA2NDRcdTA2MjMiLAogICJcdUZFRjgiLAogICJcdTA2NDRcdTA2MjMiLAogICJcdUZFRjkiLAogICJcdTA2NDR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AgIGlmIChnaWQgIT09IHVuZGVmaW5lZCkgewogICAgICAgICAgICBpbnZDaWRUb0dpZE1hcFtnaWRdID0gaTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KICAgICAgY2hhckNvZGVUb0dseXBoSWQgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICBsZXQgY2hhckNvZGU7CiAgICAgIGlmIChjZmYuaXNDSURGb250KSB7CiAgICAgICAgZm9yIChnbHlwaElkID0gMDsgZ2x5cGhJZCA8IGNoYXJzZXRzLmxlbmd0aDsgZ2x5cGhJZCsrKSB7CiAgICAgICAgICBjb25zdCBjaWQgPSBjaGFyc2V0c1tnbHlwaElkXTsKICAgICAgICAgIGNoYXJDb2RlID0gY01hcC5jaGFyQ29kZU9mKGNpZCk7CiAgICAgICAgICBpZiAoaW52Q2lkVG9HaWRNYXAgJiYgaW52Q2lkVG9HaWRNYXBbY2hhckNvZGVdICE9PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgY2hhckNvZGUgPSBpbnZDaWRUb0dpZE1hcFtjaGFyQ29kZV07CiAgICAgICAgICB9CiAgICAgICAgICBjaGFyQ29kZVRvR2x5cGhJZFtjaGFyQ29kZV0gPSBnbHlwaElkOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICBmb3IgKGdseXBoSWQgPSAwOyBnbHlwaElkIDwgY2ZmLmNoYXJTdHJpbmdzLmNvdW50OyBnbHlwaElkKyspIHsKICAgICAgICAgIGNoYXJDb2RlID0gY01hcC5jaGFyQ29kZU9mKGdseXBoSWQpOwogICAgICAgICAgY2hhckNvZGVUb0dseXBoSWRbY2hhckNvZGVdID0gZ2x5cGhJZDsKICAgICAgICB9CiAgICAgIH0KICAgICAgcmV0dXJuIGNoYXJDb2RlVG9HbHlwaElkOwogICAgfQogICAgbGV0IGVuY29kaW5nID0gY2ZmLmVuY29kaW5nID8gY2ZmLmVuY29kaW5nLmVuY29kaW5nIDogbnVsbDsKICAgIGlmIChwcm9w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H0KICAgIHAgKz0gMjsKICAgIGZvciAoaSA9IDA7IGkgPCBzZWdDb3VudDsgaSsrLCBwICs9IDIpIHsKICAgICAgcmFuZ2VzW2ldLnN0YXJ0ID0gZ2V0VWludDE2KGRhdGEsIHApOwogICAgfQogICAgZm9yIChpID0gMDsgaSA8IHNlZ0NvdW50OyBpKyssIHAgKz0gMikgewogICAgICByYW5nZXNbaV0uaWREZWx0YSA9IGdldFVpbnQxNihkYXRhLCBwKTsKICAgIH0KICAgIGZvciAoaSA9IDA7IGkgPCBzZWdDb3VudDsgaSsrLCBwICs9IDIpIHsKICAgICAgbGV0IGlkT2Zmc2V0ID0gZ2V0VWludDE2KGRhdGEsIHApOwogICAgICBpZiAoaWRPZmZzZXQgPT09IDApIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICByYW5nZXNbaV0uaWRzID0gW107CiAgICAgIGZvciAobGV0IGogPSAwLCBqaiA9IHJhbmdlc1tpXS5lbmQgLSByYW5nZXNbaV0uc3RhcnQgKyAxOyBqIDwgamo7IGorKykgewogICAgICAgIHJhbmdlc1tpXS5pZHNbal0gPSBnZXRVaW50MTYoZGF0YSwgcCArIGlkT2Zmc2V0KTsKICAgICAgICBpZE9mZnNldCArPSAyOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gcmFuZ2VzOwogIH0gZWxzZSBpZiAoZm9ybWF0ID09PSAxMikgewogICAgY29uc3QgZ3JvdXBzID0gZ2V0VWludDMyKGRhdGEsIHN0YXJ0ICsgb2Zmc2V0ICsgMTIpOwogICAgcCA9IHN0YXJ0ICsgb2Zmc2V0ICsgMTY7CiAgICByYW5nZXMgPSBbXTsKICAgIGZvciAoaSA9IDA7IGkgPCBncm91cHM7IGkrKykgewogICAgICBzdGFydCA9IGdldFVpbnQzMihkYXRhLCBwKTsKICAgICAgcmFuZ2VzLnB1c2goewogICAgICAgIHN0YXJ0LAogICAgICAgIGVuZDogZ2V0VWludDMyKGRhdGEsIHAgKyA0KSwKICAgICAgICBp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gICAgICAgICBhcmcyID0gZ2V0SW50MTYoY29kZSwgaSArIDIpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBhcmcxID0gZ2V0VWludDE2KGNvZGUsIGkpOwogICAgICAgICAgYXJnMiA9IGdldFVpbnQxNihjb2RlLCBpICsgMik7CiAgICAgICAgfQogICAgICAgIGkgKz0gNDsKICAgICAgfSBlbHNlIHsKICAgICAgICBpZiAoZmxhZ3MgJiAweDAyKSB7CiAgICAgICAgICBhcmcxID0gZ2V0SW50OChjb2RlLCBpKyspOwogICAgICAgICAgYXJnMiA9IGdldEludDgoY29kZSwgaSsrKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgYXJnMSA9IGNvZGVbaSsrXTsKICAgICAgICAgIGFyZzIgPSBjb2RlW2krK107CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChmbGFncyAmIDB4MDIpIHsKICAgICAgICB4ID0gYXJnMTsKICAgICAgICB5ID0gYXJnMjsKICAgICAgfSBlbHNlIHsKICAgICAgICB4ID0gMDsKICAgICAgICB5ID0gMDsKICAgICAgfQogICAgICBsZXQgc2NhbGVYID0gMSwKICAgICAgICBzY2FsZVkgPSAxLAogICAgICAgIHNjYWxlMDEgPSAwLAogICAgICAgIHNjYWxlMTAgPSAwOwogICAgICBpZiAoZmxhZ3MgJiAweDA4KSB7CiAgICAgICAgc2NhbGVYID0gc2NhbGVZID0gZ2V0RmxvYXQyMTQoY29kZSwgaSk7CiAgICAgICAgaSArPSAyOwogICAgICB9IGVsc2UgaWYgKGZsYWdzICYgMHg0MCkgewogICAgICAgIHNjYWxlWCA9IGdldEZsb2F0MjE0KGNvZGUsIGkpOwogICAgICAgIHNjYWxlWSA9IGdldEZsb2F0MjE0KGNvZGUsIGkgKyAyKTsKICAgICAgICBpICs9IDQ7CiAgICAgIH0gZWxzZSBpZiAoZmxhZ3MgJiAweDgwKSB7CiAgICAgICAgc2NhbGVYID0gZ2V0RmxvYXQyMTQoY29kZSwgaSk7CiAgICAgICAgc2NhbGUwMSA9IGdldEZsb2F0MjE0KGNvZGUsIGkgKyAyKTsKICAgICAgICBzY2FsZTEwID0gZ2V0RmxvYXQyMTQoY29kZSwgaSArIDQpOwogICAgICAgIHNjYWxlWSA9IGdldEZsb2F0MjE0KGNvZGUsIGkgKyA2KTsKICAgICAgICBpICs9IDg7CiAgICAgIH0KICAgICAgY29uc3Qgc3ViZ2x5cGggPSBmb250LmdseXBoc1tnbHlwaEluZGV4XTsKICAgICAgaWYgKHN1YmdseXBoKSB7CiAgICAgICAgY21kcy5wdXNoKHsKICAgICAgICAgIGNtZDogInNhdmUiCiAgICAgICAgfSwgewogICAgICAgICAgY21kOiAidHJhbnNmb3JtIiwKICAgICAgICAgIGFyZ3M6IFtzY2FsZVgsIHNjYWxlMDEsIHNjYWxlMTAsIHNjYWxlWSwgeCwgeV0KICAgICAgICB9KTsKICAgICAgICBpZiAoIShmbGFncyAmIDB4MDIpKSB7fQogICAgICAgIGNvbXBpbGVHbHlmKHN1YmdseXBoLCBjbWRzLCBmb250KTsKICAgICAgICBjbWRzLnB1c2goewogICAgICAgICAgY21kOiAicmVzdG9yZSIKICAgICAgICB9KTsKICAgICAgfQogICAgfSB3aGlsZSAoZmxhZ3MgJiAweDIwKTsKICB9IGVsc2UgewogICAgY29uc3QgZW5kUHRzT2ZDb250b3VycyA9IFtdOwogICAgbGV0IGosIGpqOwogICAgZm9yIChqID0gMDsgaiA8IG51bWJlck9mQ29udG91cnM7IGorKykgewogICAgICBlbmRQdHNPZkNvbnRvdXJzLnB1c2goZ2V0VWludDE2KGNvZGUsIGkpKTsKICAgICAgaSArPSAyOwogICAgfQogICAgY29uc3QgaW5zdHJ1Y3Rpb25MZW5ndGggPSBnZXRVaW50MTYoY29kZSwgaSk7CiAgICBpICs9IDIgKyBpbnN0cnVjdGlvbkxlbmd0aDsKICAgIGNvbnN0IG51bWJlck9mUG9pbnRzID0gZW5kUHRzT2ZDb250b3Vycy5hdCgtMSkgKyAxOwogICAgY29uc3QgcG9pbnRzID0gW107CiAgICB3aGlsZSAocG9pbnRzLmxlbmd0aCA8IG51bWJlck9mUG9pbnRzKSB7CiAgICAgIGZsYWdzID0gY29kZVtpKytdOwogICAgICBsZXQgcmVwZWF0ID0gMTsKICAgICAgaWYgKGZsYWdzICYgMHgwOCkgewogICAgICAgIHJlcGVhdCArPSBjb2RlW2krK107CiAgICAgIH0KICAgICAgd2hpbGUgKHJlcGVhdC0tID4gMCkgewogICAgICAgIHBvaW50cy5wdXNoKHsKICAgICAgICAgIGZsYWdzCiAgICAgICAgfSk7CiAgICAgIH0KICAgIH0KICAgIGZvciAoaiA9IDA7IGogPCBudW1iZXJPZlBvaW50czsgaisrKSB7CiAgICAgIHN3aXRjaCAocG9pbnRzW2pdLmZsYWdzICYgMHgxMikgewogICAgICAgIGNhc2UgMHgwMDoKICAgICAgICAgIHggKz0gZ2V0SW50MTYoY29kZSwgaSk7CiAgICAgICAgICBpICs9IDI7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDB4MDI6CiAgICAgICAgICB4IC09IGNvZGVbaSsrXTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHgxMjoKICAgICAgICAgIHggKz0gY29kZVtpKytdOwogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgcG9pbnRzW2pdLnggPSB4OwogICAgfQogICAgZm9yIChqID0gMDsgaiA8IG51bWJlck9mUG9pbnRzOyBqKyspIHsKICAgICAgc3dpdGNoIChwb2ludHNbal0uZmxhZ3MgJiAweDI0KSB7CiAgICAgICAgY2FzZSAweDAwOgogICAgICAgICAgeSArPSBnZXRJbnQxNihjb2RlLCBpKTsKICAgICAgICAgIGkgKz0gMjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMHgwNDoKICAgICAgICAgIHkgLT0gY29kZVtpKytdOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAweDI0OgogICAgICAgICAgeSArPSBjb2RlW2krK107CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgICBwb2ludHNbal0ueSA9IHk7CiAgICB9CiAgICBsZXQgc3RhcnRQb2ludCA9IDA7CiAgICBmb3IgKGkgPSAwOyBpIDwgbnVtYmVyT2ZDb250b3VyczsgaSsrKSB7CiAgICAgIGNvbnN0IGVuZFBvaW50ID0gZW5kUHRzT2ZDb250b3Vyc1tpXTsKICAgICAgY29uc3QgY29udG91ciA9IHBvaW50cy5zbGljZShzdGFydFBvaW50LCBlbmRQb2ludCArIDEpOwogICAgICBpZiAoY29udG91clswXS5mbGFncyAmIDEpIHsKICAgICAgICBjb250b3VyLnB1c2goY29udG91clswXSk7CiAgICAgIH0gZWxzZSBpZiAoY29udG91ci5hdCgtMSkuZmxhZ3MgJiAxKSB7CiAgICAgICAgY29udG91ci51bnNoaWZ0KGNvbnRvdXIuYXQoLTEpKTsKICAgICAgfSBlbHNlIHsKICAgICAgICBjb25zdCBwID0gewogICAgICAgICAgZmxhZ3M6IDEsCiAgICAgICAgICB4OiAoY29udG91clswXS54ICsgY29udG91ci5hdCgtMSkueCkgLyAyLAogICAgICAgICAgeTogKGNvbnRvdXJbMF0ueSArIGNvbnRvdXIuYXQoLTEpLnkpIC8gMgogICAgICAgIH07CiAgICAgICAgY29udG91ci51bnNoaWZ0KHApOwogICAgICAgIGNvbnRvdXIucHVzaChwKTsKICAgICAgfQogICAgICBtb3ZlVG8oY29udG91clswXS54LCBjb250b3VyWzBdLnkpOwogICAgICBmb3IgKGogPSAxLCBqaiA9IGNvbnRvdXIubGVuZ3RoOyBqIDwgamo7IGorKykgewogICAgICAgIGlmIChjb250b3VyW2pdLmZsYWdzICYgMSkgewogICAgICAgICAgbGluZVRvKGNvbnRvdXJbal0ueCwgY29udG91cltqXS55KTsKICAgICAgICB9IGVsc2UgaWYgKGNvbnRvdXJbaiArIDFdLmZsYWdzICYgMSkgewogICAgICAgICAgcXVhZHJhdGljQ3VydmVUbyhjb250b3VyW2pdLngsIGNvbnRvdXJbal0ueSwgY29udG91cltqICsgMV0ueCwgY29udG91cltqICsgMV0ueSk7CiAgICAgICAgICBqKys7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHF1YWRyYXRpY0N1cnZlVG8oY29udG91cltqXS54LCBjb250b3VyW2pdLnksIChjb250b3VyW2pdLnggKyBjb250b3VyW2ogKyAxXS54KSAvIDIsIChjb250b3VyW2pdLnkgKyBjb250b3VyW2ogKyAxXS55KSAvIDIpOwogICAgICAgIH0KICAgICAgfQogICAgICBzdGFydFBvaW50ID0gZW5kUG9pbnQgKyAxOwogICAgfQogIH0KfQpmdW5jdGlvbiBjb21waWxlQ2hhclN0cmluZyhjaGFyU3RyaW5nQ29kZSwgY21kcywgZm9udCwgZ2x5cGhJZCkgewogIGZ1bmN0aW9uIG1vdmVUbyh4LCB5KSB7CiAgICBjbWRzLnB1c2goewogICAgICBjbWQ6ICJtb3ZlVG8iLAogICAgICBhcmdzOiBbeCwgeV0KICAgIH0pOwogIH0KICBmdW5jdGlvbiBsaW5lVG8oeCwgeSkgewogICAgY21kcy5wdXNoKHsKICAgICAgY21kOiAibGluZVRvIiwKICAgICAgYXJnczogW3gsIHldCiAgICB9KTsKICB9CiAgZnVuY3Rpb24gYmV6aWVyQ3VydmVUbyh4MSwgeTEsIHgyLCB5MiwgeCwgeSkgewogICAgY21kcy5wdXNoKHsKICAgICAgY21kOiAiYmV6aWVyQ3VydmVUbyIsCiAgICAgIGFyZ3M6IFt4MSwgeTEsIHgyLCB5MiwgeCwgeV0KICAgIH0pOwogIH0KICBjb25zdCBzdGFjayA9IFtdOwogIGxldCB4ID0gMCwKICAgIHkgPSAwOwogIGxldCBzdGVtcyA9IDA7CiAgZnVuY3Rpb24gcGFyc2UoY29kZSkgewogICAgbGV0IGkgPSAwOwogICAgd2hpbGUgKGkgPCBjb2RlLmxlbmd0aCkgewogICAgICBsZXQgc3RhY2tDbGVhbiA9IGZhbHNlOwogICAgICBsZXQgdiA9IGNvZGVbaSsrXTsKICAgICAgbGV0IHhhLCB4YiwgeWEsIHliLCB5MSwgeTIsIHkzLCBuLCBzdWJyQ29kZTsKICAgICAgc3dpdGNoICh2KSB7CiAgICAgICAgY2FzZSAxOgogICAgICAgICAgc3RlbXMgKz0gc3RhY2subGVuZ3RoID4+IDE7CiAgICAgICAgICBzdGFja0NsZWFuID0gdHJ1ZTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMzoKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDQ6CiAgICAgICAgICB5ICs9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbW92ZVRvKHgsIHkpOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDU6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgbGluZVRvKHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSA2OgogICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgeCArPSBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBsaW5lVG8oeCwgeSk7CiAgICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICB5ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIGxpbmVUbyh4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgNzoKICAgICAgICAgIHdoaWxlIChzdGFjay5sZW5ndGggPiAwKSB7CiAgICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgbGluZVRvKHgsIHkpOwogICAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgeCArPSBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBsaW5lVG8oeCwgeSk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDg6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAxMDoKICAgICAgICAgIG4gPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN1YnJDb2RlID0gbnVsbDsKICAgICAgICAgIGlmIChmb250LmlzQ0ZGQ0lERm9udCkgewogICAgICAgICAgICBjb25zdCBmZEluZGV4ID0gZm9udC5mZFNlbGVjdC5nZXRGREluZGV4KGdseXBoSWQpOwogICAgICAgICAgICBpZiAoZmRJbmRleCA+PSAwICYmIGZkSW5kZXggPCBmb250LmZkQXJyYXkubGVuZ3RoKSB7CiAgICAgICAgICAgICAgY29uc3QgZm9udERpY3QgPSBmb250LmZkQXJyYXlbZmRJbmRleF07CiAgICAgICAgICAgICAgbGV0IHN1YnJzOwogICAgICAgICAgICAgIGlmIChmb250RGljdC5wcml2YXRlRGljdCAmJiBmb250RGljdC5wcml2YXRlRGljdC5zdWJyc0luZGV4KSB7CiAgICAgICAgICAgICAgICBzdWJycyA9IGZvbnREaWN0LnByaXZhdGVEaWN0LnN1YnJzSW5kZXgub2JqZWN0czsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgaWYgKHN1YnJzKSB7CiAgICAgICAgICAgICAgICBuICs9IGdldFN1YnJvdXRpbmVCaWFzKHN1YnJzKTsKICAgICAgICAgICAgICAgIHN1YnJDb2RlID0gc3VicnNbbl07CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKSgiSW52YWxpZCBmZCBpbmRleCBmb3IgZ2x5cGggaW5kZXguIik7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHN1YnJDb2RlID0gZm9udC5zdWJyc1tuICsgZm9udC5zdWJyc0JpYXNdOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHN1YnJDb2RlKSB7CiAgICAgICAgICAgIHBhcnNlKHN1YnJDb2RlKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMTE6CiAgICAgICAgICByZXR1cm47CiAgICAgICAgY2FzZSAxMjoKICAgICAgICAgIHYgPSBjb2RlW2krK107CiAgICAgICAgICBzd2l0Y2ggKHYpIHsKICAgICAgICAgICAgY2FzZSAzNDoKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHkxID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5LCB4YiwgeTEsIHgsIHkxKTsKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeTEsIHhiLCB5LCB4LCB5KTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAzNToKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5ID0geWIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgICAgIHhhID0geCArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeWEgPSB5ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB4ID0geGIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeWEsIHhiLCB5YiwgeCwgeSk7CiAgICAgICAgICAgICAgc3RhY2sucG9wKCk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMzY6CiAgICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5MSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHkyID0geTEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeTEsIHhiLCB5MiwgeCwgeTIpOwogICAgICAgICAgICAgIHhhID0geCArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeTMgPSB5MiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5MiwgeGIsIHkzLCB4LCB5KTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAzNzoKICAgICAgICAgICAgICBjb25zdCB4MCA9IHgsCiAgICAgICAgICAgICAgICB5MCA9IHk7CiAgICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB5YSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHliID0geWEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeSA9IHliICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgICAgeCA9IHhiOwogICAgICAgICAgICAgIHkgPSB5YjsKICAgICAgICAgICAgICBpZiAoTWF0aC5hYnMoeCAtIHgwKSA+IE1hdGguYWJzKHkgLSB5MCkpIHsKICAgICAgICAgICAgICAgIHggKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgeSArPSBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYHVua25vd24gb3BlcmF0b3I6IDEyICR7dn1gKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMTQ6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoID49IDQpIHsKICAgICAgICAgICAgY29uc3QgYWNoYXIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgICAgY29uc3QgYmNoYXIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgICAgeSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgICB4ID0gc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGNtZHMucHVzaCh7CiAgICAgICAgICAgICAgY21kOiAic2F2ZSIKICAgICAgICAgICAgfSwgewogICAgICAgICAgICAgIGNtZDogInRyYW5zbGF0ZSIsCiAgICAgICAgICAgICAgYXJnczogW3gsIHldCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBsZXQgY21hcCA9IGxvb2t1cENtYXAoZm9udC5jbWFwLCBTdHJpbmcuZnJvbUNoYXJDb2RlKGZvbnQuZ2x5cGhOYW1lTWFwW19lbmNvZGluZ3MuU3RhbmRhcmRFbmNvZGluZ1thY2hhcl1dKSk7CiAgICAgICAgICAgIGNvbXBpbGVDaGFyU3RyaW5nKGZvbnQuZ2x5cGhzW2NtYXAuZ2x5cGhJZF0sIGNtZHMsIGZvbnQsIGNtYXAuZ2x5cGhJZCk7CiAgICAgICAgICAgIGNtZHMucHVzaCh7CiAgICAgICAgICAgICAgY21kOiAicmVzdG9yZSIKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGNtYXAgPSBsb29rdXBDbWFwKGZvbnQuY21hcCwgU3RyaW5nLmZyb21DaGFyQ29kZShmb250LmdseXBoTmFtZU1hcFtfZW5jb2RpbmdzLlN0YW5kYXJkRW5jb2RpbmdbYmNoYXJdXSkpOwogICAgICAgICAgICBjb21waWxlQ2hhclN0cmluZyhmb250LmdseXBoc1tjbWFwLmdseXBoSWRdLCBjbWRzLCBmb250LCBjbWFwLmdseXBoSWQpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuOwogICAgICAgIGNhc2UgMTg6CiAgICAgICAgICBzdGVtcyArPSBzdGFjay5sZW5ndGggPj4gMTsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAxOToKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgaSArPSBzdGVtcyArIDcgPj4gMzsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAyMDoKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgaSArPSBzdGVtcyArIDcgPj4gMzsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAyMToKICAgICAgICAgIHkgKz0gc3RhY2sucG9wKCk7CiAgICAgICAgICB4ICs9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbW92ZVRvKHgsIHkpOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDIyOgogICAgICAgICAgeCArPSBzdGFjay5wb3AoKTsKICAgICAgICAgIG1vdmVUbyh4LCB5KTsKICAgICAgICAgIHN0YWNrQ2xlYW4gPSB0cnVlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAyMzoKICAgICAgICAgIHN0ZW1zICs9IHN0YWNrLmxlbmd0aCA+PiAxOwogICAgICAgICAgc3RhY2tDbGVhbiA9IHRydWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDI0OgogICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDIpIHsKICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWEgPSB5ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeGIgPSB4YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHliID0geWEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB4ID0geGIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5ID0geWIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIHggKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgIGxpbmVUbyh4LCB5KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjU6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gNikgewogICAgICAgICAgICB4ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgKz0gc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgbGluZVRvKHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHliID0geWEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjY6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoICUgMikgewogICAgICAgICAgICB4ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHg7CiAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiOwogICAgICAgICAgICB5ID0geWIgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjc6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoICUgMikgewogICAgICAgICAgICB5ICs9IHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICB9CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YSA9IHk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeSA9IHliOwogICAgICAgICAgICBiZXppZXJDdXJ2ZVRvKHhhLCB5YSwgeGIsIHliLCB4LCB5KTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjg6CiAgICAgICAgICBzdGFjay5wdXNoKChjb2RlW2ldIDw8IDI0IHwgY29kZVtpICsgMV0gPDwgMTYpID4+IDE2KTsKICAgICAgICAgIGkgKz0gMjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjk6CiAgICAgICAgICBuID0gc3RhY2sucG9wKCkgKyBmb250LmdzdWJyc0JpYXM7CiAgICAgICAgICBzdWJyQ29kZSA9IGZvbnQuZ3N1YnJzW25dOwogICAgICAgICAgaWYgKHN1YnJDb2RlKSB7CiAgICAgICAgICAgIHBhcnNlKHN1YnJDb2RlKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMzA6CiAgICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkgewogICAgICAgICAgICB4YSA9IHg7CiAgICAgICAgICAgIHlhID0geSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeSA9IHliICsgKHN0YWNrLmxlbmd0aCA9PT0gMSA/IHN0YWNrLnNoaWZ0KCkgOiAwKTsKICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeWEsIHhiLCB5YiwgeCwgeSk7CiAgICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPT09IDApIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICB4YSA9IHggKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YSA9IHk7CiAgICAgICAgICAgIHhiID0geGEgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB5YiA9IHlhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeSA9IHliICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeCA9IHhiICsgKHN0YWNrLmxlbmd0aCA9PT0gMSA/IHN0YWNrLnNoaWZ0KCkgOiAwKTsKICAgICAgICAgICAgYmV6aWVyQ3VydmVUbyh4YSwgeWEsIHhiLCB5YiwgeCwgeSk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDMxOgogICAgICAgICAgd2hpbGUgKHN0YWNrLmxlbmd0aCA+IDApIHsKICAgICAgICAgICAgeGEgPSB4ICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWEgPSB5OwogICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgPSB5YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHggPSB4YiArIChzdGFjay5sZW5ndGggPT09IDEgPyBzdGFjay5zaGlmdCgpIDogMCk7CiAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgeGEgPSB4OwogICAgICAgICAgICB5YSA9IHkgKyBzdGFjay5zaGlmdCgpOwogICAgICAgICAgICB4YiA9IHhhICsgc3RhY2suc2hpZnQoKTsKICAgICAgICAgICAgeWIgPSB5YSArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHggPSB4YiArIHN0YWNrLnNoaWZ0KCk7CiAgICAgICAgICAgIHkgPSB5YiArIChzdGFjay5sZW5ndGggPT09IDEgPyBzdGFjay5zaGlmdCgpIDogMCk7CiAgICAgICAgICAgIGJlemllckN1cnZlVG8oeGEsIHlhLCB4YiwgeWIsIHgsIHkpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIGlmICh2IDwgMzIpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGB1bmtub3duIG9wZXJhdG9yOiAke3Z9YCk7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAodiA8IDI0NykgewogICAgICAgICAgICBzdGFjay5wdXNoKHYgLSAxMzkpOwogICAgICAgICAgfSBlbHNlIGlmICh2IDwgMjUxKSB7CiAgICAgICAgICAgIHN0YWNrLnB1c2goKHYgLSAyNDcpICogMjU2ICsgY29kZVtpKytdICsgMTA4KTsKICAgICAgICAgIH0gZWxzZSBpZiAodiA8IDI1NSkgewogICAgICAgICAgICBzdGFjay5wdXNoKC0odiAtIDI1MSkgKiAyNTYgLSBjb2RlW2krK10gLSAxMDgpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhY2sucHVzaCgoY29kZVtpXSA8PCAyNCB8IGNvZGVbaSArIDFdIDw8IDE2IHwgY29kZVtpICsgMl0gPDwgOCB8IGNvZGVbaSArIDNdKSAvIDY1NTM2KTsKICAgICAgICAgICAgaSArPSA0OwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgaWYgKHN0YWNrQ2xlYW4pIHsKICAgICAgICBzdGFjay5sZW5ndGggPSAwOwogICAgICB9CiAgICB9CiAgfQogIHBhcnNlKGNoYXJTdHJpbmdDb2RlKTsKfQpjb25zdCBOT09QID0gW107CmNsYXNzIENvbXBpbGVkRm9udCB7CiAgY29uc3RydWN0b3IoZm9udE1hdHJpeCkgewogICAgaWYgKHRoaXMuY29uc3RydWN0b3IgPT09IENvbXBpbGVkRm9udCkgewogICAgICAoMCwgX3V0aWwudW5yZWFjaGFibGUpKCJDYW5ub3QgaW5pdGlhbGl6ZSBDb21waWxlZEZvbnQuIik7CiAgICB9CiAgICB0aGlzLmZvbnRNYXRyaXggPSBmb250TWF0cml4OwogICAgdGhpcy5jb21waWxlZEdseXBocyA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICB0aGlzLmNvbXBpbGVkQ2hhckNvZGVUb0dseXBoSWQgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogIH0KICBnZXRQYXRoSnModW5pY29kZSkgewogICAgY29uc3QgewogICAgICBjaGFyQ29kZSwKICAgICAgZ2x5cGhJZAogICAgfSA9IGxvb2t1cENtYXAodGhpcy5jbWFwLCB1bmljb2RlKTsKICAgIGxldCBmbiA9IHRoaXMuY29tcGlsZWRHbHlwaHNbZ2x5cGhJZF07CiAgICBpZiAoIWZuKSB7CiAgICAgIHRyeSB7CiAgICAgICAgZm4gPSB0aGlzLmNvbXBpbGVHbHlwaCh0aGlzLmdseXBoc1tnbHlwaElkXSwgZ2x5cGhJZCk7CiAgICAgICAgdGhpcy5jb21waWxlZEdseXBoc1tnbHlwaElkXSA9IGZuOwogICAgICB9IGNhdGNoIChleCkgewogICAgICAgIHRoaXMuY29tcGlsZWRHbHlwaHNbZ2x5cGhJZF0gPSBOT09QOwogICAgICAgIGlmICh0aGlzLmNvbXBpbGVkQ2hhckNvZGVUb0dseXBoSWRbY2hhckNvZGVdID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgIHRoaXMuY29tcGlsZWRDaGFyQ29kZVRvR2x5cGhJZFtjaGFyQ29kZV0gPSBnbHlwaElkOwogICAgICAgIH0KICAgICAgICB0aHJvdyBleDsKICAgICAgfQogICAgfQogICAgaWYgKHRoaXMuY29tcGlsZWRDaGFyQ29kZVRvR2x5cGhJZFtjaGFyQ29kZV0gPT09IHVuZGVmaW5lZCkgewogICAgICB0aGlzLmNvbXBpbGVkQ2hhckNvZGVUb0dseXBoSWRbY2hhckNvZGVdID0gZ2x5cGhJZDsKICAgIH0KICAgIHJldHVybiBmbjsKICB9CiAgY29tcGlsZUdseXBoKGNvZGUsIGdseXBoSWQpIHsKICAgIGlmICghY29kZSB8fCBjb2RlLmxlbmd0aCA9PT0gMCB8fCBjb2RlWzBdID09PSAxNCkgewogICAgICByZXR1cm4gTk9PUDsKICAgIH0KICAgIGxldCBmb250TWF0cml4ID0gdGhpcy5mb250TWF0cml4OwogICAgaWYgKHRoaXMuaXNDRkZDSURGb250KSB7CiAgICAgIGNvbnN0IGZkSW5kZXggPSB0aGlzLmZkU2VsZWN0LmdldEZESW5kZXgoZ2x5cGhJZCk7CiAgICAgIGlmIChmZEluZGV4ID49IDAgJiYgZmRJbmRleCA8IHRoaXMuZmRBcnJheS5sZW5ndGgpIHsKICAgICAgICBjb25zdCBmb250RGljdCA9IHRoaXMuZmRBcnJheVtmZEluZGV4XTsKICAgICAgICBmb250TWF0cml4ID0gZm9udERpY3QuZ2V0QnlOYW1lKCJGb250TWF0cml4IikgfHwgX3V0aWwuRk9OVF9JREVOVElUWV9NQVRSSVg7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJJbnZhbGlkIGZkIGluZGV4IGZvciBnbHlwaCBpbmRleC4iKTsKICAgICAgfQogICAgfQogICAgY29uc3QgY21kcyA9IFt7CiAgICAgIGNtZDogInNhdmUiCiAgICB9LCB7CiAgICAgIGNtZDogInRyYW5zZm9ybSIsCiAgICAgIGFyZ3M6IGZvbnRNYXRyaXguc2xpY2UoKQogICAgfSwgewogICAgICBjbWQ6ICJzY2FsZSIsCiAgICAgIGFyZ3M6IFsic2l6ZSIsICItc2l6ZSJdCiAgICB9XTsKICAgIHRoaXM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y2xhbSA9IDMzMzsKICAgIHQucXVvdGVkYmwgPSA0NzQ7CiAgICB0Lm51bWJlcnNpZ24gPSA1NTY7CiAgICB0LmRvbGxhciA9IDU1NjsKICAgIHQucGVyY2VudCA9IDg4OTsKICAgIHQuYW1wZXJzYW5kID0gNzIyOwogICAgdC5xdW90ZXJpZ2h0ID0gMjc4OwogICAgdC5wYXJlbmxlZnQgPSAzMzM7CiAgICB0LnBhcmVucmlnaHQgPSAzMzM7CiAgICB0LmFzdGVyaXNrID0gMzg5OwogICAgdC5wbHVzID0gNTg0OwogICAgdC5jb21tYSA9IDI3ODsKICAgIHQuaHlwaGVuID0gMzMzOwogICAgdC5wZXJpb2QgPSAyNzg7CiAgICB0LnNsYXNoID0gMjc4OwogICAgdC56ZXJvID0gNTU2OwogICAgdC5vbmUgPSA1NTY7CiAgICB0LnR3byA9IDU1NjsKICAgIHQudGhyZWUgPSA1NTY7CiAgICB0LmZvdXIgPSA1NTY7CiAgICB0LmZpdmUgPSA1NTY7CiAgICB0LnNpeCA9IDU1NjsKICAgIHQuc2V2ZW4gPSA1NTY7CiAgICB0LmVpZ2h0ID0gNTU2OwogICAgdC5uaW5lID0gNTU2OwogICAgdC5jb2xvbiA9IDMzMzsKICAgIHQuc2VtaWNvbG9uID0gMzMzOwogICAgdC5sZXNzID0gNTg0OwogICAgdC5lcXVhbCA9IDU4NDsKICAgIHQuZ3JlYXRlciA9IDU4NDsKICAgIHQucXVlc3Rpb24gPSA2MTE7CiAgICB0LmF0ID0gOTc1OwogICAgdC5BID0gNzIyOwogICAgdC5CID0gNzIyOwogICAgdC5DID0gNzIyOwogICAgdC5EID0gNzIyOwogICAgdC5FID0gNjY3OwogICAgdC5GID0gNjExOwogICAgdC5HID0gNzc4OwogICAgdC5IID0gNzIyOwogICAgdC5JID0gMjc4OwogICAgdC5KID0gNTU2OwogICAgdC5LID0gNzIyOwogICAgdC5MID0gNjExOwogICAgdC5NID0gODMzOwogICAgdC5OID0gNzIyOwogICAgdC5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ODsKICAgIHQuUiA9IDcyMjsKICAgIHQuUyA9IDY2NzsKICAgIHQuVCA9IDYxMTsKICAgIHQuVSA9IDcyMjsKICAgIHQuViA9IDY2NzsKICAgIHQuVyA9IDk0NDsKICAgIHQuWCA9IDY2NzsKICAgIHQuWSA9IDY2NzsKICAgIHQuWiA9IDYxMTsKICAgIHQuYnJhY2tldGxlZnQgPSAzMzM7CiAgICB0LmJhY2tzbGFzaCA9IDI3ODsKICAgIHQuYnJhY2tldHJpZ2h0ID0gMzMzOwogICAgdC5hc2NpaWNpcmN1bSA9IDU4NDsKICAgIHQudW5kZXJzY29yZSA9IDU1NjsKICAgIHQucXVvdGVsZWZ0ID0gMjc4OwogICAgdC5hID0gNTU2OwogICAgdC5iID0gNjExOwogICAgdC5jID0gNTU2OwogICAgdC5kID0gNjExOwogICAgdC5lID0gNTU2OwogICAgdC5mID0gMzMzOwogICAgdC5nID0gNjExOwogICAgdC5oID0gNjExOwogICAgdC5pID0gMjc4OwogICAgdC5qID0gMjc4OwogICAgdC5rID0gNTU2OwogICAgdC5sID0gMjc4OwogICAgdC5tID0gODg5OwogICAgdC5uID0gNjExOwogICAgdC5vID0gNjExOwogICAgdC5wID0gNjExOwogICAgdC5xID0gNjExOwogICAgdC5yID0gMzg5OwogICAgdC5zID0gNTU2OwogICAgdC50ID0gMzMzOwogICAgdC51ID0gNjExOwogICAgdC52ID0gNTU2OwogICAgdC53ID0gNzc4OwogICAgdC54ID0gNTU2OwogICAgdC55ID0gNTU2OwogICAgdC56ID0gNTAwOwogICAgdC5icmFjZWxlZnQgPSAzODk7CiAgICB0LmJhciA9IDI4MDsKICAgIHQuYnJhY2VyaWdodCA9IDM4OTsKICAgIHQuYXNjaWl0aWxkZSA9IDU4NDsKICAgIHQuZXhjbGFtZG93biA9IDMzMzsKICAgIHQuY2VudCA9IDU1NjsKICAgIHQuc3RlcmxpbmcgPSA1NTY7CiAgICB0LmZyYWN0aW9uID0gMTY3OwogICAgdC55ZW4gPSA1NTY7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wMDsKICAgIHQuVCA9IDU1NjsKICAgIHQuVSA9IDcyMjsKICAgIHQuViA9IDYxMTsKICAgIHQuVyA9IDgzMzsKICAgIHQuWCA9IDYxMTsKICAgIHQuWSA9IDU1NjsKICAgIHQuWiA9IDU1NjsKICAgIHQuYnJhY2tldGxlZnQgPSAzODk7CiAgICB0LmJhY2tzbGFzaCA9IDI3ODsKICAgIHQuYnJhY2tldHJpZ2h0ID0gMzg5OwogICAgdC5hc2NpaWNpcmN1bSA9IDQyMjsKICAgIHQudW5kZXJzY29yZSA9IDUwMDsKICAgIHQucXVvdGVsZWZ0ID0gMzMzOwogICAgdC5hID0gNTAwOwogICAgdC5iID0gNTAwOwogICAgdC5jID0gNDQ0OwogICAgdC5kID0gNTAwOwogICAgdC5lID0gNDQ0OwogICAgdC5mID0gMjc4OwogICAgdC5nID0gNTAwOwogICAgdC5oID0gNTAwOwogICAgdC5pID0gMjc4OwogICAgdC5qID0gMjc4OwogICAgdC5rID0gNDQ0OwogICAgdC5sID0gMjc4OwogICAgdC5tID0gNzIyOwogICAgdC5uID0gNTAwOwogICAgdC5vID0gNTAwOwogICAgdC5wID0gNTAwOwogICAgdC5xID0gNTAwOwogICAgdC5yID0gMzg5OwogICAgdC5zID0gMzg5OwogICAgdC50ID0gMjc4OwogICAgdC51ID0gNTAwOwogICAgdC52ID0gNDQ0OwogICAgdC53ID0gNjY3OwogICAgdC54ID0gNDQ0OwogICAgdC55ID0gNDQ0OwogICAgdC56ID0gMzg5OwogICAgdC5icmFjZWxlZnQgPSA0MDA7CiAgICB0LmJhciA9IDI3NTsKICAgIHQuYnJhY2VyaWdodCA9IDQwMDsKICAgIHQuYXNjaWl0aWxkZSA9IDU0MTsKICAgIHQuZXhjbGFtZG93biA9IDM4OTsKICAgIHQuY2VudCA9IDUwMDsKICAgIHQuc3RlcmxpbmcgPSA1MDA7CiAgICB0LmZyYWN0aW9uID0gMTY3OwogICAgdC55ZW4gPSA1MDA7CiAgICB0LmZsb3JpbiA9I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LmE5NSA9IDMzNDsKICAgIHQuYTk2ID0gMzM0OwogICAgdC5hMTAxID0gNzMyOwogICAgdC5hMTAyID0gNTQ0OwogICAgdC5hMTAzID0gNTQ0OwogICAgdC5hMTA0ID0gOTEwOwogICAgdC5hMTA2ID0gNjY3OwogICAgdC5hMTA3ID0gNzYwOwogICAgdC5hMTA4ID0gNzYwOwogICAgdC5hMTEyID0gNzc2OwogICAgdC5hMTExID0gNTk1OwogICAgdC5hMTEwID0gNjk0OwogICAgdC5hMTA5ID0gNjI2OwogICAgdC5hMTIwID0gNzg4OwogICAgdC5hMTIxID0gNzg4OwogICAgdC5hMTIyID0gNzg4OwogICAgdC5hMTIzID0gNzg4OwogICAgdC5hMTI0ID0gNzg4OwogICAgdC5hMTI1ID0gNzg4OwogICAgdC5hMTI2ID0gNzg4OwogICAgdC5hMTI3ID0gNzg4OwogICAgdC5hMTI4ID0gNzg4OwogICAgdC5hMTI5ID0gNzg4OwogICAgdC5hMTMwID0gNzg4OwogICAgdC5hMTMxID0gNzg4OwogICAgdC5hMTMyID0gNzg4OwogICAgdC5hMTMzID0gNzg4OwogICAgdC5hMTM0ID0gNzg4OwogICAgdC5hMTM1ID0gNzg4OwogICAgdC5hMTM2ID0gNzg4OwogICAgdC5hMTM3ID0gNzg4OwogICAgdC5hMTM4ID0gNzg4OwogICAgdC5hMTM5ID0gNzg4OwogICAgdC5hMTQwID0gNzg4OwogICAgdC5hMTQxID0gNzg4OwogICAgdC5hMTQyID0gNzg4OwogICAgdC5hMTQzID0gNzg4OwogICAgdC5hMTQ0ID0gNzg4OwogICAgdC5hMTQ1ID0gNzg4OwogICAgdC5hMTQ2ID0gNzg4OwogICAgdC5hMTQ3ID0gNzg4OwogICAgdC5hMTQ4ID0gNzg4OwogICAgdC5hMTQ5ID0gNzg4OwogICAgdC5hMTUwID0gNzg4OwogICAgdC5hMTUxID0gNzg4OwogICAgdC5hMTUyID0gNzg4OwogICAgdC5hMTUzID0gNzg4OwogICAgdC5hMTU0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mQ29udG91cnNJbmRleCsrOwogICAgICAgIGNvbnRvdXJzLnB1c2gobmV3IENvbnRvdXIoewogICAgICAgICAgZmxhZ3M6IHBvaW50RmxhZ3MsCiAgICAgICAgICB4Q29vcmRpbmF0ZXMsCiAgICAgICAgICB5Q29vcmRpbmF0ZXMKICAgICAgICB9KSk7CiAgICAgICAgeUNvb3JkaW5hdGVzID0gW107CiAgICAgICAgcG9pbnRGbGFncyA9IFtdOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gbmV3IFNpbXBsZUdseXBoKHsKICAgICAgY29udG91cnMsCiAgICAgIGluc3RydWN0aW9ucwogICAgfSk7CiAgfQogIGdldFNpemUoKSB7CiAgICBsZXQgc2l6ZSA9IHRoaXMuY29udG91cnMubGVuZ3RoICogMiArIDIgKyB0aGlzLmluc3RydWN0aW9ucy5sZW5ndGg7CiAgICBsZXQgbGFzdFggPSAwOwogICAgbGV0IGxhc3RZID0gMDsKICAgIGZvciAoY29uc3QgY29udG91ciBvZiB0aGlzLmNvbnRvdXJzKSB7CiAgICAgIHNpemUgKz0gY29udG91ci5mbGFncy5sZW5ndGg7CiAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGNvbnRvdXIueENvb3JkaW5hdGVzLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICBjb25zdCB4ID0gY29udG91ci54Q29vcmRpbmF0ZXNbaV07CiAgICAgICAgY29uc3QgeSA9IGNvbnRvdXIueUNvb3JkaW5hdGVzW2ldOwogICAgICAgIGxldCBhYnMgPSBNYXRoLmFicyh4IC0gbGFzdFgpOwogICAgICAgIGlmIChhYnMgPiAyNTUpIHsKICAgICAgICAgIHNpemUgKz0gMjsKICAgICAgICB9IGVsc2UgaWYgKGFicyA+IDApIHsKICAgICAgICAgIHNpemUgKz0gMTsKICAgICAgICB9CiAgICAgICAgbGFzdFggPSB4OwogICAgICAgIGFicyA9IE1hdGguYWJzKHkgLSBsYXN0WSk7CiAgICAgICAgaWYgKGFicyA+IDI1NSkgewogICAgICAgICAgc2l6ZSArPSAyOwogICAgICAgIH0gZWxzZSBpZiAoYWJzID4gMCkgewogICAgICAgICAgc2l6ZSArPSAxOwogICAgICAgIH0KICAgICAgICBsYXN0WSA9IHk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBzaXplOwogIH0KICB3cml0ZShwb3MsIGJ1ZikgewogICAgY29uc3Qgc3BvcyA9IHBvczsKICAgIGNvbnN0IHhDb29yZGluYXRlcyA9IFtdOwogICAgY29uc3QgeUNvb3JkaW5hdGVzID0gW107CiAgICBjb25zdCBmbGFncyA9IFtdOwogICAgbGV0IGxhc3RYID0gMDsKICAgIGxldCBsYXN0WSA9IDA7CiAgICBmb3IgKGNvbnN0IGNvbnRvdXIgb2YgdGhpcy5jb250b3VycykgewogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBjb250b3VyLnhDb29yZGluYXRlcy5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgbGV0IGZsYWcgPSBjb250b3VyLmZsYWdzW2ldOwogICAgICAgIGNvbnN0IHggPSBjb250b3VyLnhDb29yZGluYXRlc1tpXTsKICAgICAgICBsZXQgZGVsdGEgPSB4IC0gbGFzdFg7CiAgICAgICAgaWYgKGRlbHRhID09PSAwKSB7CiAgICAgICAgICBmbGFnIHw9IFhfSVNfU0FNRV9PUl9QT1NJVElWRV9YX1NIT1JUX1ZFQ1RPUjsKICAgICAgICAgIHhDb29yZGluYXRlcy5wdXNoKDApOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb25zdCBhYnMgPSBNYXRoLmFicyhkZWx0YSk7CiAgICAgICAgICBpZiAoYWJzIDw9IDI1NSkgewogICAgICAgICAgICBmbGFnIHw9IGRlbHRhID49IDAgPyBYX1NIT1JUX1ZFQ1RPUiB8IFhfSVNfU0FNRV9PUl9QT1NJVElWRV9YX1NIT1JUX1ZFQ1RPUiA6IFhfU0hPUlRfVkVDVE9SOwogICAgICAgICAgICB4Q29vcmRpbmF0ZXMucHVzaChhYnMpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgeENvb3JkaW5hdGVzLnB1c2goZGVsdGEpOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBsYXN0WCA9IHg7CiAgICAgICAgY29uc3QgeSA9IGNvbnRvdXIueUNvb3JkaW5hdGVzW2ldOwogICAgICAgIGRlbHRhID0geSAtIGxhc3RZOwogICAgICAgIGlmIChkZWx0YSA9PT0gMCkgewogICAgICAgICAgZmxhZyB8PSBZX0lTX1NBTUVfT1JfUE9TSVRJVkVfWV9TSE9SVF9WRUNUT1I7CiAgICAgICAgICB5Q29vcmRpbmF0ZXMucHVzaCgwKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY29uc3QgYWJzID0gTWF0aC5hYnMoZGVsdGEpOwogICAgICAgICAgaWYgKGFicyA8PSAyNTUpIHsKICAgICAgICAgICAgZmxhZyB8PSBkZWx0YSA+PSAwID8gWV9TSE9SVF9WRUNUT1IgfCBZX0lTX1NBTUVfT1JfUE9TSVRJVkVfWV9TSE9SVF9WRUNUT1IgOiBZX1NIT1JUX1ZFQ1RPUjsKICAgICAgICAgICAgeUNvb3JkaW5hdGVzLnB1c2goYWJzKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHlDb29yZGluYXRlcy5wdXNoKGRlbHRhKTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgbGFzdFkgPSB5OwogICAgICAgIGZsYWdzLnB1c2goZmxhZyk7CiAgICAgIH0KICAgICAgYnVmLnNldFVpbnQxNihwb3MsIHhDb29yZGluYXRlcy5sZW5ndGggLSAxKTsKICAgICAgcG9zICs9IDI7CiAgICB9CiAgICBidWYuc2V0VWludDE2KHBvcywgdGhpcy5pbnN0cnVjdGlvbnMubGVuZ3RoKTsKICAgIHBvcyArPSAyOwogICAgaWYgKHRoaXMuaW5zdHJ1Y3Rpb25zLmxlbmd0aCkgewogICAgICBuZXcgVWludDhBcnJheShidW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zICs9IDQ7CiAgICBpZiAodGhpcy5mbGFncyAmIEFSR18xX0FORF8yX0FSRV9XT1JEUykgewogICAgICBpZiAodGhpcy5mbGFncyAmIEFSR1NfQVJFX1hZX1ZBTFVFUykgewogICAgICAgIGJ1Zi5zZXRJbnQxNihwb3MsIHRoaXMuYXJndW1lbnQxKTsKICAgICAgICBidWYuc2V0SW50MTYocG9zICsgMiwgdGhpcy5hcmd1bWVudDIpOwogICAgICB9IGVsc2UgewogICAgICAgIGJ1Zi5zZXRVaW50MTYocG9zLCB0aGlzLmFyZ3VtZW50MSk7CiAgICAgICAgYnVmLnNldFVpbnQxNihwb3MgKyAyLCB0aGlzLmFyZ3VtZW50Mik7CiAgICAgIH0KICAgICAgcG9zICs9IDQ7CiAgICB9IGVsc2UgewogICAgICBidWYuc2V0VWludDgocG9zLCB0aGlzLmFyZ3VtZW50MSk7CiAgICAgIGJ1Zi5zZXRVaW50OChwb3MgKyAxLCB0aGlzLmFyZ3VtZW50Mik7CiAgICAgIHBvcyArPSAyOwogICAgfQogICAgaWYgKHRoaXMuZmxhZ3MgJiBXRV9IQVZFX0lOU1RSVUNUSU9OUykgewogICAgICBidWYuc2V0VWludDE2KHBvcywgdGhpcy5pbnN0cnVjdGlvbnMubGVuZ3RoKTsKICAgICAgcG9zICs9IDI7CiAgICAgIGlmICh0aGlzLmluc3RydWN0aW9ucy5sZW5ndGgpIHsKICAgICAgICBuZXcgVWludDhBcnJheShidWYuYnVmZmVyLCAwLCBidWYuYnVmZmVyLmJ5dGVMZW5ndGgpLnNldCh0aGlzLmluc3RydWN0aW9ucywgcG9zKTsKICAgICAgICBwb3MgKz0gdGhpcy5pbnN0cnVjdGlvbnMubGVuZ3RoOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gcG9zIC0gc3BvczsKICB9CiAgc2NhbGUoeCwgZmFjdG9yKSB7fQp9CgovKioqLyB9KSwKLyogMTgyICovCi8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9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0ID0gW107CiAgICB0aGlzLnN0YWNrID0gW107CiAgfQogIGNvbnZlcnQoZW5jb2RlZCwgc3VicnMsIHNlYWNBbmFseXNpc0VuYWJsZWQpIHsKICAgIGNvbnN0IGNvdW50ID0gZW5jb2RlZC5sZW5ndGg7CiAgICBsZXQgZXJyb3IgPSBmYWxzZTsKICAgIGxldCB3eCwgc2J4LCBzdWJyTnVtYmVyOwogICAgZm9yIChsZXQgaSA9IDA7IGkgPCBjb3VudDsgaSsrKSB7CiAgICAgIGxldCB2YWx1ZSA9IGVuY29kZWRbaV07CiAgICAgIGlmICh2YWx1ZSA8IDMyKSB7CiAgICAgICAgaWYgKHZhbHVlID09PSAxMikgewogICAgICAgICAgdmFsdWUgPSAodmFsdWUgPDwgOCkgKyBlbmNvZGVkWysraV07CiAgICAgICAgfQogICAgICAgIHN3aXRjaCAodmFsdWUpIHsKICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgaWYgKCFISU5USU5HX0VOQUJMRUQpIHsKICAgICAgICAgICAgICB0aGlzLnN0YWNrID0gW107CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDIsIENPTU1BTkRfTUFQLmhzdGVtKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDM6CiAgICAgICAgICAgIGlmICghSElOVElOR19FTkFCTEVEKSB7CiAgICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgyLCBDT01NQU5EX01BUC52c3RlbSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSA0OgogICAgICAgICAgICBpZiAodGhpcy5mbGV4aW5nKSB7CiAgICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgMSkgewogICAgICAgICAgICAgICAgZXJyb3IgPSB0cnVlOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNvbnN0IGR5ID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgICB0aGlzLnN0YWNrLnB1c2goMCwgZHkpOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgxLCBDT01NQU5EX01BUC52bW92ZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDU6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgyLCBDT01NQU5EX01BUC5ybGluZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDY6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgxLCBDT01NQU5EX01BUC5obGluZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDc6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgxLCBDT01NQU5EX01BUC52bGluZXRvKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDg6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg2LCBDT01NQU5EX01BUC5ycmN1cnZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgOToKICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMTA6CiAgICAgICAgICAgIGlmICh0aGlzLnN0YWNrLmxlbmd0aCA8IDEpIHsKICAgICAgICAgICAgICBlcnJvciA9IHRydWU7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc3Vick51bWJlciA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGlmICghc3VicnNbc3Vick51bWJlcl0pIHsKICAgICAgICAgICAgICBlcnJvciA9IHRydWU7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmNvbnZlcnQoc3VicnNbc3Vick51bWJlcl0sIHN1YnJzLCBzZWFjQW5hbHlzaXNFbmFibGVkKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDExOgogICAgICAgICAgICByZXR1cm4gZXJyb3I7CiAgICAgICAgICBjYXNlIDEzOgogICAgICAgICAgICBpZiAodGhpcy5zdGFjay5sZW5ndGggPCAyKSB7CiAgICAgICAgICAgICAgZXJyb3IgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHd4ID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgc2J4ID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgdGhpcy5sc2IgPSBzYng7CiAgICAgICAgICAgIHRoaXMud2lkdGggPSB3eDsKICAgICAgICAgICAgdGhpcy5zdGFjay5wdXNoKHd4LCBzYngpOwogICAgICAgICAgICBlcnJvciA9IHRoaXMuZXhlY3V0ZUNvbW1hbmQoMiwgQ09NTUFORF9NQVAuaG1vdmV0byk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAxNDoKICAgICAgICAgICAgdGhpcy5vdXRwdXQucHVzaChDT01NQU5EX01BUC5lbmRjaGFyWzBdKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlIDIxOgogICAgICAgICAgICBpZiAodGhpcy5mbGV4aW5nKSB7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDIsIENPTU1BTkRfTUFQLnJtb3ZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMjI6CiAgICAgICAgICAgIGlmICh0aGlzLmZsZXhpbmcpIHsKICAgICAgICAgICAgICB0aGlzLnN0YWNrLnB1c2goMCk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDEsIENPTU1BTkRfTUFQLmhtb3ZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMzA6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg0LCBDT01NQU5EX01BUC52aGN1cnZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMzE6CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg0LCBDT01NQU5EX01BUC5odmN1cnZldG8pOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgMDoKICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgMToKICAgICAgICAgICAgaWYgKCFISU5USU5HX0VOQUJMRUQpIHsKICAgICAgICAgICAgICB0aGlzLnN0YWNrID0gW107CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDIsIENPTU1BTkRfTUFQLnZzdGVtKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICgxMiA8PCA4KSArIDI6CiAgICAgICAgICAgIGlmICghSElOVElOR19FTkFCTEVEKSB7CiAgICAgICAgICAgICAgdGhpcy5zdGFjayA9IFtdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCgyLCBDT01NQU5EX01BUC5oc3RlbSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAoMTIgPDwgOCkgKyA2OgogICAgICAgICAgICBpZiAoc2VhY0FuYWx5c2lzRW5hYmxlZCkgewogICAgICAgICAgICAgIGNvbnN0IGFzYiA9IHRoaXMuc3RhY2suYXQoLTUpOwogICAgICAgICAgICAgIHRoaXMuc2VhYyA9IHRoaXMuc3RhY2suc3BsaWNlKC00LCA0KTsKICAgICAgICAgICAgICB0aGlzLnNlYWNbMF0gKz0gdGhpcy5sc2IgLSBhc2I7CiAgICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDAsIENPTU1BTkRfTUFQLmVuZGNoYXIpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIGVycm9yID0gdGhpcy5leGVjdXRlQ29tbWFuZCg0LCBDT01NQU5EX01BUC5lbmRjaGFyKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgNzoKICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgNCkgewogICAgICAgICAgICAgIGVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnN0YWNrLnBvcCgpOwogICAgICAgICAgICB3eCA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGNvbnN0IHNieSA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIHNieCA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIHRoaXMubHNiID0gc2J4OwogICAgICAgICAgICB0aGlzLndpZHRoID0gd3g7CiAgICAgICAgICAgIHRoaXMuc3RhY2sucHVzaCh3eCwgc2J4LCBzYnkpOwogICAgICAgICAgICBlcnJvciA9IHRoaXMuZXhlY3V0ZUNvbW1hbmQoMywgQ09NTUFORF9NQVAucm1vdmV0byk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAoMTIgPDwgOCkgKyAxMjoKICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICAgIGVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb25zdCBudW0yID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgY29uc3QgbnVtMSA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIHRoaXMuc3RhY2sucHVzaChudW0xIC8gbnVtMik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAoMTIgPDwgOCkgKyAxNjoKICAgICAgICAgICAgaWYgKHRoaXMuc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICAgIGVycm9yID0gdHJ1ZTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBzdWJyTnVtYmVyID0gdGhpcy5zdGFjay5wb3AoKTsKICAgICAgICAgICAgY29uc3QgbnVtQXJncyA9IHRoaXMuc3RhY2sucG9wKCk7CiAgICAgICAgICAgIGlmIChzdWJyTnVtYmVyID09PSAwICYmIG51bUFyZ3MgPT09IDMpIHsKICAgICAgICAgICAgICBjb25zdCBmbGV4QXJncyA9IHRoaXMuc3RhY2suc3BsaWNlKC0xNywgMTcpOwogICAgICAgICAgICAgIHRoaXMuc3RhY2sucHVzaChmbGV4QXJnc1syXSArIGZsZXhBcmdzWzBdLCBmbGV4QXJnc1szXSArIGZsZXhBcmdzWzFdLCBmbGV4QXJnc1s0XSwgZmxleEFyZ3NbNV0sIGZsZXhBcmdzWzZdLCBmbGV4QXJnc1s3XSwgZmxleEFyZ3NbOF0sIGZsZXhBcmdzWzldLCBmbGV4QXJnc1sxMF0sIGZsZXhBcmdzWzExXSwgZmxleEFyZ3NbMTJdLCBmbGV4QXJnc1sxM10sIGZsZXhBcmdzWzE0XSk7CiAgICAgICAgICAgICAgZXJyb3IgPSB0aGlzLmV4ZWN1dGVDb21tYW5kKDEzLCBDT01NQU5EX01BUC5mbGV4LCB0cnVlKTsKICAgICAgICAgICAgICB0aGlzLmZsZXhpbmcgPSBmYWxzZTsKICAgICAgICAgICAgICB0aGlzLnN0YWNrLnB1c2goZmxleEFyZ3NbMTVdLCBmbGV4QXJnc1sxNl0pOwogICAgICAgICAgICB9IGVsc2UgaWYgKHN1YnJOdW1iZXIgPT09IDEgJiYgbnVtQXJncyA9PT0gMCkgewogICAgICAgICAgICAgIHRoaXMuZmxleGluZyA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICgxMiA8PCA4KSArIDE3OgogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgKDEyIDw8IDgpICsgMzM6CiAgICAgICAgICAgIHRoaXMuc3RhY2sgPSBbXTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoJ1Vua25vd24gdHlwZSAxIGNoYXJzdHJpbmcgY29tbWFuZCBvZiAiJyArIHZhbHVlICsgJyInKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmIChlcnJvcikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9IGVsc2UgaWYgKHZhbHVlIDw9IDI0NikgewogICAgICAgIHZhbHVlIC09IDEzOTsKICAgICAgfSBlbHNlIGlmICh2YWx1ZSA8PSAyNTApIHsKICAgICAgICB2YWx1ZSA9ICh2YWx1ZSAtIDI0NykgKiAyNTYgKyBlbmNvZGVkWysraV0gKyAxMDg7CiAgICAgIH0gZWxzZSBpZiAodmFsdWUgPD0gMjU0KSB7CiAgICAgICAgdmFsdWUgPSAtKCh2YWx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AodG9rZW4gPT09IG51bGwgfHwgdG9rZW4gPT09ICJdIiB8fCB0b2tlbiA9PT0gIn0iKSB7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgYXJyYXkucHVzaChwYXJzZUZsb2F0KHRva2VuIHx8IDApKTsKICAgIH0KICAgIHJldHVybiBhcnJheTsKICB9CiAgcmVhZE51bWJlcigpIHsKICAgIGNvbnN0IHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgcmV0dXJuIHBhcnNlRmxvYXQodG9rZW4gfHwgMCk7CiAgfQogIHJlYWRJbnQoKSB7CiAgICBjb25zdCB0b2tlbiA9IHRoaXMuZ2V0VG9rZW4oKTsKICAgIHJldHVybiBwYXJzZUludCh0b2tlbiB8fCAwLCAxMCkgfCAwOwogIH0KICByZWFkQm9vbGVhbigpIHsKICAgIGNvbnN0IHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgcmV0dXJuIHRva2VuID09PSAidHJ1ZSIgPyAxIDogMDsKICB9CiAgbmV4dENoYXIoKSB7CiAgICByZXR1cm4gdGhpcy5jdXJyZW50Q2hhciA9IHRoaXMuc3RyZWFtLmdldEJ5dGUoKTsKICB9CiAgcHJldkNoYXIoKSB7CiAgICB0aGlzLnN0cmVhbS5za2lwKC0yKTsKICAgIHJldHVybiB0aGlzLmN1cnJlbnRDaGFyID0gdGhpcy5zdHJlYW0uZ2V0Qnl0ZSgpOwogIH0KICBnZXRUb2tlbigpIHsKICAgIGxldCBjb21tZW50ID0gZmFsc2U7CiAgICBsZXQgY2ggPSB0aGlzLmN1cnJlbnRDaGFyOwogICAgd2hpbGUgKHRydWUpIHsKICAgICAgaWYgKGNoID09PSAtMSkgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAgIGlmIChjb21tZW50KSB7CiAgICAgICAgaWYgKGNoID09PSAweDBhIHx8IGNoID09PSAweDBkKSB7CiAgICAgICAgICBjb21tZW50ID0gZmFsc2U7CiAgICAgICAgfQogICAgICB9IGV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AgICAgcHJvcGVydGllczogewogICAgICAgIHByaXZhdGVEYXRhCiAgICAgIH0KICAgIH07CiAgICBsZXQgdG9rZW4sIGxlbmd0aCwgZGF0YSwgbGVuSVY7CiAgICB3aGlsZSAoKHRva2VuID0gdGhpcy5nZXRUb2tlbigpKSAhPT0gbnVsbCkgewogICAgICBpZiAodG9rZW4gIT09ICIvIikgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgICBzd2l0Y2ggKHRva2VuKSB7CiAgICAgICAgY2FzZSAiQ2hhclN0cmluZ3MiOgogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgd2hpbGUgKHRydWUpIHsKICAgICAgICAgICAgdG9rZW4gPSB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgIGlmICh0b2tlbiA9PT0gbnVsbCB8fCB0b2tlbiA9PT0gImVuZCIpIHsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAodG9rZW4gIT09ICIvIikgewogICAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvbnN0IGdseXBoID0gdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBsZW5ndGggPSB0aGlzLnJlYWRJbnQoKTsKICAgICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBkYXRhID0gbGVuZ3RoID4gMCA/IHN0cmVhbS5nZXRCeXRlcyhsZW5ndGgpIDogbmV3IFVpbnQ4QXJyYXkoMCk7CiAgICAgICAgICAgIGxlbklWID0gcHJvZ3JhbS5wcm9wZXJ0aWVzLnByaXZhdGVEYXRhLmxlbklWOwogICAgICAgICAgICBjb25zdCBlbmNvZGVkID0gdGhpcy5yZWFkQ2hhclN0cmluZ3MoZGF0YSwgbGVuSVYpOwogICAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICAgIHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBpZiAodG9rZW4gPT09ICJub2FjY2VzcyIpIHsKICAgICAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgIH0gZWxzZSBpZiAodG9rZW4gPT09ICIvIikgewogICAgICAgICAgICAgIHRoaXMucHJldkNoYXIoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjaGFyc3RyaW5ncy5wdXNoKHsKICAgICAgICAgICAgICBnbHlwaCwKICAgICAgICAgICAgICBlbmNvZGVkCiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiU3VicnMiOgogICAgICAgICAgdGhpcy5yZWFkSW50KCk7CiAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICB3aGlsZSAodGhpcy5nZXRUb2tlbigpID09PSAiZHVwIikgewogICAgICAgICAgICBjb25zdCBpbmRleCA9IHRoaXMucmVhZEludCgpOwogICAgICAgICAgICBsZW5ndGggPSB0aGlzLnJlYWRJbnQoKTsKICAgICAgICAgICAgdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBkYXRhID0gbGVuZ3RoID4gMCA/IHN0cmVhbS5nZXRCeXRlcyhsZW5ndGgpIDogbmV3IFVpbnQ4QXJyYXkoMCk7CiAgICAgICAgICAgIGxlbklWID0gcHJvZ3JhbS5wcm9wZXJ0aWVzLnByaXZhdGVEYXRhLmxlbklWOwogICAgICAgICAgICBjb25zdCBlbmNvZGVkID0gdGhpcy5yZWFkQ2hhclN0cmluZ3MoZGF0YSwgbGVuSVYpOwogICAgICAgICAgICB0aGlzLm5leHRDaGFyKCk7CiAgICAgICAgICAgIHRva2VuID0gdGhpcy5nZXRUb2tlbigpOwogICAgICAgICAgICBpZiAodG9rZW4gPT09ICJub2FjY2VzcyIpIHsKICAgICAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc3VicnNbaW5kZXhdID0gZW5jb2RlZDsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkJsdWVWYWx1ZXMiOgogICAgICAgIGNhc2UgIk90aGVyQmx1ZXMiOgogICAgICAgIGNhc2UgIkZhbWlseUJsdWVzIjoKICAgICAgICBjYXNlICJGYW1pbHlPdGhlckJsdWVzIjoKICAgICAgICAgIGNvbnN0IGJsdWVBcnJheSA9IHRoaXMucmVhZE51bWJlckFycmF5KCk7CiAgICAgICAgICBpZiAoYmx1ZUFycmF5Lmxlbmd0aCA+IDAgJiYgYmx1ZUFycmF5Lmxlbmd0aCAlIDIgPT09IDAgJiYgSElOVElOR19FTkFCTEVEKSB7CiAgICAgICAgICAgIHByb2dyYW0ucHJvcGVydGllcy5wcml2YXRlRGF0YVt0b2tlbl0gPSBibHVlQXJyYXk7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJTdGVtU25hcEgiOgogICAgICAgIGNhc2UgIlN0ZW1TbmFwViI6CiAgICAgICAgICBwcm9ncmFtLnByb3BlcnRpZXMucHJpdmF0ZURhdGFbdG9rZW5dID0gdGhpcy5yZWFkTnVtYmVyQXJyYXkoKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIlN0ZEhXIjoKICAgICAgICBjYXNlICJTdGRWVyI6CiAgICAgICAgICBwcm9ncmFtLnByb3BlcnRpZXMucHJpdmF0ZURhdGFbdG9rZW5dID0gdGhpcy5yZWFkTnVtYmVyQXJyYXkoKVswXTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkJsdWVTaGlmdCI6CiAgICAgICAgY2FzZSAibGVuSVYiOgogICAgICAgIGNhc2UgIkJsdWVGdXp6IjoKICAgICAgICBjYXNlICJCbHVlU2NhbGUiOgogICAgICAgIGNhc2UgIkxhbmd1YWdlR3JvdXAiOgogICAgICAgICAgcHJvZ3JhbS5wcm9wZXJ0aWVzLnByaXZhdGVEYXRhW3Rva2VuXSA9IHRoaXMucmVhZE51bWJlcigpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiRXhwYW5zaW9uRmFjdG9yIjoKICAgICAgICAgIHByb2dyYW0ucHJvcGVydGllcy5wcml2YXRlRGF0YVt0b2tlbl0gPSB0aGlzLnJlYWROdW1iZXIoKSB8fCAwLjA2OwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiRm9yY2VCb2xkIjoKICAgICAgICAgIHByb2dyYW0ucHJvcGVydGllcy5wcml2YXRlRGF0YVt0b2tlbl0gPSB0aGlzLnJlYWRCb29sZWFuKCk7CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgfQogICAgZm9yIChjb25zdCB7CiAgICAgIGVuY29kZWQsCiAgICAgIGdseXBoCiAgICB9IG9mIGNoYXJzdHJpbmdzKSB7CiAgICAgIGNvbnN0IGNoYXJTdHJpbmcgPSBuZXcgVHlwZTFDaGFyU3RyaW5nKCk7CiAgICAgIGNvbnN0IGVycm9yID0gY2hhclN0cmluZy5jb252ZXJ0KGVuY29kZWQsIHN1YnJzLCB0aGlzLnNlYWNBbmFseXNpc0VuYWJsZWQpOwogICAgICBsZXQgb3V0cHV0ID0gY2hhclN0cmluZy5vdXRwdXQ7CiAgICAgIGlmIChlcnJvcikgewogICAgICAgIG91dHB1dCA9IFsxNF07CiAgICAgIH0KICAgICAgY29uc3QgY2hhclN0cmluZ09iamVjdCA9IHsKICAgICAgICBnbHlwaE5hbWU6IGdseXBoLAogICAgICAgIGNoYXJzdHJpbmc6IG91dHB1dCwKICAgICAgICB3aWR0aDogY2hhclN0cmluZy53aWR0aCwKICAgICAgICBsc2I6IGNoYXJTdHJpbmcubHNiLAogICAgICAgIHNlYWM6IGNoYXJTdHJpbmcuc2VhYwogICAgICB9OwogICAgICBpZiAoZ2x5cGggPT09ICIubm90ZGVmIikgewogICAgICAgIHByb2dyYW0uY2hhcnN0cmluZ3MudW5zaGlmdChjaGFyU3RyaW5nT2JqZWN0KTsKICAgICAgfSBlbHNlIHsKICAgICAgICBwcm9ncmFtLmNoYXJzdHJpbmdzLnB1c2goY2hhclN0cmluZ09iamVjdCk7CiAgICAgIH0KICAgICAgaWYgKHByb3BlcnRpZXMuYnVpbHRJbkVuY29kaW5nKSB7CiAgICAgICAgY29uc3QgaW5kZXggPSBwcm9wZXJ0aWVzLmJ1aWx0SW5FbmNvZGluZy5pbmRleE9mKGdseXBoKTsKICAgICAgICBpZiAoaW5kZXggPiAtMSAmJiBwcm9wZXJ0aWVzLndpZHRoc1tpbmRleF0gPT09IHVuZGVmaW5lZCAmJiBpbmRleCA+PSBwcm9wZXJ0aWVzLmZpcnN0Q2hhciAmJiBpbmRleCA8PSBwcm9wZXJ0aWVzLmxhc3RDaGFyKSB7CiAgICAgICAgICBwcm9wZXJ0aWVzLndpZHRoc1tpbmRleF0gPSBjaGFyU3RyaW5nLndpZHRoOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgcmV0dXJuIHByb2dyYW07CiAgfQogIGV4dHJhY3RGb250SGVhZGVyKHByb3BlcnRpZXMpIHsKICAgIGxldCB0b2tlbjsKICAgIHdoaWxlICgodG9rZW4gPSB0aGlzLmdldFRva2VuKCkpICE9PSBudWxsKSB7CiAgICAgIGlmICh0b2tlbiAhPT0gIi8iKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgdG9rZW4gPSB0aGlzLmdldFRva2VuKCk7CiAgICAgIHN3aXRjaCAodG9rZW4pIHsKICAgICAgICBjYXNlICJGb250TWF0cml4IjoKICAgICAgICAgIGNvbnN0IG1hdHJpeCA9IHRoaXMucmVhZE51bWJlckFycmF5KCk7CiAgICAgICAgICBwcm9wZXJ0aWVzLmZvbnRNYXRyaXggPSBtYXRyaXg7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJFbmNvZGluZyI6CiAgICAgICAgICBjb25zdCBlbmNvZGluZ0FyZyA9IHRoaXMuZ2V0VG9rZW4oKTsKICAgICAgICAgIGxldCBlbmNvZGluZzsKICAgICAgICAgIGlmICghL15cZCskLy50ZXN0KGVuY29kaW5nQXJnKSkgewogICAgICAgICAgICBlbmNvZGluZyA9ICgwLCBfZW5jb2RpbmdzLmdldEVuY29kaW5nKShlbmNvZGluZ0FyZyk7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBlbmNvZGluZyA9IFtdOwogICAgICAgICAgICBjb25zdCBzaXplID0gcGFyc2VJbnQoZW5jb2RpbmdBcmcsIDEwKSB8IDA7CiAgICAgICAgICAgIHRoaXMuZ2V0VG9rZW4oKTsKICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBzaXplOyBqKyspIHsKICAgICAgICAgICAgICB0b2tlbiA9IHRoaXMuZ2V0VG9rZW4oKTsKICAgICAgICAgICAgICB3aGlsZSAodG9rZW4gIT09ICJkdXAiICYmIHRva2VuICE9PSAiZGVmIikgewogICAgICAgICAgICAgICAgdG9rZW4gPSB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgICAgICBpZiAodG9rZW4gPT09IG51bGwpIHsKICAgICAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBpZiAodG9rZW4gPT09ICJkZWYiKSB7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgaW5kZXggPSB0aGlzLnJlYWRJbnQoKTsKICAgICAgICAgICAgICB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgICAgY29uc3QgZ2x5cGggPSB0aGlzLmdldFRva2VuKCk7CiAgICAgICAgICAgICAgZW5jb2RpbmdbaW5kZXhdID0gZ2x5cGg7CiAgICAgICAgICAgICAgdGhpcy5nZXRUb2tlbig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lYWs7CiAgICB9CiAgICBpZiAocGF0Y2hNZXNoKSB7CiAgICAgIHRoaXMuX3VwZGF0ZUJvdW5kcygpOwogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSB0aGlzLmZpZ3VyZXMubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgIHRoaXMuX2J1aWxkRmlndXJlRnJvbVBhdGNoKGkpOwogICAgICB9CiAgICB9CiAgICB0aGlzLl91cGRhdGVCb3VuZHMoKTsKICAgIHRoaXMuX3BhY2tEYXRhKCk7CiAgfQogIF9kZWNvZGVUeXBlNFNoYWRpbmcocmVhZGVyKSB7CiAgICBjb25zdCBjb29yZHMgPSB0aGlzLmNvb3JkczsKICAgIGNvbnN0IGNvbG9ycyA9IHRoaXMuY29sb3JzOwogICAgY29uc3Qgb3BlcmF0b3JzID0gW107CiAgICBjb25zdCBwcyA9IFtdOwogICAgbGV0IHZlcnRpY2VzTGVmdCA9IDA7CiAgICB3aGlsZSAocmVhZGVyLmhhc0RhdGEpIHsKICAgICAgY29uc3QgZiA9IHJlYWRlci5yZWFkRmxhZygpOwogICAgICBjb25zdCBjb29yZCA9IHJlYWRlci5yZWFkQ29vcmRpbmF0ZSgpOwogICAgICBjb25zdCBjb2xvciA9IHJlYWRlci5yZWFkQ29tcG9uZW50cygpOwogICAgICBpZiAodmVydGljZXNMZWZ0ID09PSAwKSB7CiAgICAgICAgaWYgKCEoMCA8PSBmICYmIGYgPD0gMikpIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiVW5rbm93biB0eXBlNCBmbGFnIik7CiAgICAgICAgfQogICAgICAgIHN3aXRjaCAoZikgewogICAgICAgICAgY2FzZSAwOgogICAgICAgICAgICB2ZXJ0aWNlc0xlZnQgPSAzOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgcHMucHVzaChwcy5hdCgtMiksIHBzLmF0KC0xKSk7CiAgICAgICAgICAgIHZlc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kczogbmV3IEludDMyQXJyYXkocHMpLAogICAgICBjb2xvcnM6IG5ldyBJbnQzMkFycmF5KHBzKSwKICAgICAgdmVydGljZXNQZXJSb3cKICAgIH0pOwogIH0KICBfZGVjb2RlVHlwZTZTaGFkaW5nKHJlYWRlcikgewogICAgY29uc3QgY29vcmRzID0gdGhpcy5jb29yZHM7CiAgICBjb25zdCBjb2xvcnMgPSB0aGlzLmNvbG9yczsKICAgIGNvbnN0IHBzID0gbmV3IEludDMyQXJyYXkoMTYpOwogICAgY29uc3QgY3MgPSBuZXcgSW50MzJBcnJheSg0KTsKICAgIHdoaWxlIChyZWFkZXIuaGFzRGF0YSkgewogICAgICBjb25zdCBmID0gcmVhZGVyLnJlYWRGbGFnKCk7CiAgICAgIGlmICghKDAgPD0gZiAmJiBmIDw9IDMpKSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJVbmtub3duIHR5cGU2IGZsYWciKTsKICAgICAgfQogICAgICBjb25zdCBwaSA9IGNvb3Jkcy5sZW5ndGg7CiAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGYgIT09IDAgPyA4IDogMTI7IGkgPCBpaTsgaSsrKSB7CiAgICAgICAgY29vcmRzLnB1c2gocmVhZGVyLnJlYWRDb29yZGluYXRlKCkpOwogICAgICB9CiAgICAgIGNvbnN0IGNpID0gY29sb3JzLmxlbmd0aDsKICAgICAgZm9yIChsZXQgaSA9IDAsIGlpID0gZiAhPT0gMCA/IDIgOiA0OyBpIDwgaWk7IGkrKykgewogICAgICAgIGNvbG9ycy5wdXNoKHJlYWRlci5yZWFkQ29tcG9uZW50cygpKTsKICAgICAgfQogICAgICBsZXQgdG1wMSwgdG1wMiwgdG1wMywgdG1wNDsKICAgICAgc3dpdGNoIChmKSB7CiAgICAgICAgY2FzZSAwOgogICAgICAgICAgcHNbMTJdID0gcGkgKyAzOwogICAgICAgICAgcHNbMTNdID0gcGkgKyA0OwogICAgICAgICAgcHNbMTRdID0gcGkgKyA1OwogICAgICAgICAgcHNbMTVdID0gcGkgKyA2OwogICAgICAgICAgcHNbOF0gPSBwaSArIDI7CiAgICAgICAgICBwc1sxMV0gPSBwaSArIDc7CiAgICAgICAgICBwc1s0XSA9IHBpICsgMTsKICAgICAgICAgIHBzWzddID0gcGkgKyA4OwogICAgICAgICAgcHNbMF0gPSBwaTsKICAgICAgICAgIHBzWzFdID0gcGkgKyAxMTsKICAgICAgICAgIHBzWzJdID0gcGkgKyAxMDsKICAgICAgICAgIHBzWzNdID0gcGkgKyA5OwogICAgICAgICAgY3NbMl0gPSBjaSArIDE7CiAgICAgICAgICBjc1szXSA9IGNpICsgMjsKICAgICAgICAgIGNzWzBdID0gY2k7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMzsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMToKICAgICAgICAgIHRtcDEgPSBwc1sxMl07CiAgICAgICAgICB0bXAyID0gcHNbMTNdOwogICAgICAgICAgdG1wMyA9IHBzWzE0XTsKICAgICAgICAgIHRtcDQgPSBwc1sxNV07CiAgICAgICAgICBwc1sxMl0gPSB0bXA0OwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSB0bXAzOwogICAgICAgICAgcHNbMTFdID0gcGkgKyAzOwogICAgICAgICAgcHNbNF0gPSB0bXAyOwogICAgICAgICAgcHNbN10gPSBwaSArIDQ7CiAgICAgICAgICBwc1swXSA9IHRtcDE7CiAgICAgICAgICBwc1sxXSA9IHBpICsgNzsKICAgICAgICAgIHBzWzJdID0gcGkgKyA2OwogICAgICAgICAgcHNbM10gPSBwaSArIDU7CiAgICAgICAgICB0bXAxID0gY3NbMl07CiAgICAgICAgICB0bXAyID0gY3NbM107CiAgICAgICAgICBjc1syXSA9IHRtcDI7CiAgICAgICAgICBjc1szXSA9IGNpOwogICAgICAgICAgY3NbMF0gPSB0bXAxOwogICAgICAgICAgY3NbMV0gPSBjaSArIDE7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDI6CiAgICAgICAgICB0bXAxID0gcHNbMTVdOwogICAgICAgICAgdG1wMiA9IHBzWzExXTsKICAgICAgICAgIHBzWzEyXSA9IHBzWzNdOwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSBwc1s3XTsKICAgICAgICAgIHBzWzExXSA9IHBpICsgMzsKICAgICAgICAgIHBzWzRdID0gdG1wMjsKICAgICAgICAgIHBzWzddID0gcGkgKyA0OwogICAgICAgICAgcHNbMF0gPSB0bXAxOwogICAgICAgICAgcHNbMV0gPSBwaSArIDc7CiAgICAgICAgICBwc1syXSA9IHBpICsgNjsKICAgICAgICAgIHBzWzNdID0gcGkgKyA1OwogICAgICAgICAgdG1wMSA9IGNzWzNdOwogICAgICAgICAgY3NbMl0gPSBjc1sxXTsKICAgICAgICAgIGNzWzNdID0gY2k7CiAgICAgICAgICBjc1swXSA9IHRtcDE7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMzoKICAgICAgICAgIHBzWzEyXSA9IHBzWzBdOwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSBwc1sxXTsKICAgICAgICAgIHBzWzExXSA9IHBpICsgMzsKICAgICAgICAgIHBzWzRdID0gcHNbMl07CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gcHNbM107CiAgICAgICAgICBwc1sxXSA9IHBpICsgNzsKICAgICAgICAgIHBzWzJdID0gcGkgKyA2OwogICAgICAgIC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srKSB7CiAgICAgICAgY29sb3JzLnB1c2gocmVhZGVyLnJlYWRDb21wb25lbnRzKCkpOwogICAgICB9CiAgICAgIGxldCB0bXAxLCB0bXAyLCB0bXAzLCB0bXA0OwogICAgICBzd2l0Y2ggKGYpIHsKICAgICAgICBjYXNlIDA6CiAgICAgICAgICBwc1sxMl0gPSBwaSArIDM7CiAgICAgICAgICBwc1sxM10gPSBwaSArIDQ7CiAgICAgICAgICBwc1sxNF0gPSBwaSArIDU7CiAgICAgICAgICBwc1sxNV0gPSBwaSArIDY7CiAgICAgICAgICBwc1s4XSA9IHBpICsgMjsKICAgICAgICAgIHBzWzldID0gcGkgKyAxMzsKICAgICAgICAgIHBzWzEwXSA9IHBpICsgMTQ7CiAgICAgICAgICBwc1sxMV0gPSBwaSArIDc7CiAgICAgICAgICBwc1s0XSA9IHBpICsgMTsKICAgICAgICAgIHBzWzVdID0gcGkgKyAxMjsKICAgICAgICAgIHBzWzZdID0gcGkgKyAxNTsKICAgICAgICAgIHBzWzddID0gcGkgKyA4OwogICAgICAgICAgcHNbMF0gPSBwaTsKICAgICAgICAgIHBzWzFdID0gcGkgKyAxMTsKICAgICAgICAgIHBzWzJdID0gcGkgKyAxMDsKICAgICAgICAgIHBzWzNdID0gcGkgKyA5OwogICAgICAgICAgY3NbMl0gPSBjaSArIDE7CiAgICAgICAgICBjc1szXSA9IGNpICsgMjsKICAgICAgICAgIGNzWzBdID0gY2k7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMzsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMToKICAgICAgICAgIHRtcDEgPSBwc1sxMl07CiAgICAgICAgICB0bXAyID0gcHNbMTNdOwogICAgICAgICAgdG1wMyA9IHBzWzE0XTsKICAgICAgICAgIHRtcDQgPSBwc1sxNV07CiAgICAgICAgICBwc1sxMl0gPSB0bXA0OwogICAgICAgICAgcHNbMTNdID0gcGkgKyAwOwogICAgICAgICAgcHNbMTRdID0gcGkgKyAxOwogICAgICAgICAgcHNbMTVdID0gcGkgKyAyOwogICAgICAgICAgcHNbOF0gPSB0bXAzOwogICAgICAgICAgcHNbOV0gPSBwaSArIDk7CiAgICAgICAgICBwc1sxMF0gPSBwaSArIDEwOwogICAgICAgICAgcHNbMTFdID0gcGkgKyAzOwogICAgICAgICAgcHNbNF0gPSB0bXAyOwogICAgICAgICAgcHNbNV0gPSBwaSArIDg7CiAgICAgICAgICBwc1s2XSA9IHBpICsgMTE7CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gdG1wMTsKICAgICAgICAgIHBzWzFdID0gcGkgKyA3OwogICAgICAgICAgcHNbMl0gPSBwaSArIDY7CiAgICAgICAgICBwc1szXSA9IHBpICsgNTsKICAgICAgICAgIHRtcDEgPSBjc1syXTsKICAgICAgICAgIHRtcDIgPSBjc1szXTsKICAgICAgICAgIGNzWzJdID0gdG1wMjsKICAgICAgICAgIGNzWzNdID0gY2k7CiAgICAgICAgICBjc1swXSA9IHRtcDE7CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMjoKICAgICAgICAgIHRtcDEgPSBwc1sxNV07CiAgICAgICAgICB0bXAyID0gcHNbMTFdOwogICAgICAgICAgcHNbMTJdID0gcHNbM107CiAgICAgICAgICBwc1sxM10gPSBwaSArIDA7CiAgICAgICAgICBwc1sxNF0gPSBwaSArIDE7CiAgICAgICAgICBwc1sxNV0gPSBwaSArIDI7CiAgICAgICAgICBwc1s4XSA9IHBzWzddOwogICAgICAgICAgcHNbOV0gPSBwaSArIDk7CiAgICAgICAgICBwc1sxMF0gPSBwaSArIDEwOwogICAgICAgICAgcHNbMTFdID0gcGkgKyAzOwogICAgICAgICAgcHNbNF0gPSB0bXAyOwogICAgICAgICAgcHNbNV0gPSBwaSArIDg7CiAgICAgICAgICBwc1s2XSA9IHBpICsgMTE7CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gdG1wMTsKICAgICAgICAgIHBzWzFdID0gcGkgKyA3OwogICAgICAgICAgcHNbMl0gPSBwaSArIDY7CiAgICAgICAgICBwc1szXSA9IHBpICsgNTsKICAgICAgICAgIHRtcDEgPSBjc1szXTsKICAgICAgICAgIGNzWzJdID0gY3NbMV07CiAgICAgICAgICBjc1szXSA9IGNpOwogICAgICAgICAgY3NbMF0gPSB0bXAxOwogICAgICAgICAgY3NbMV0gPSBjaSArIDE7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDM6CiAgICAgICAgICBwc1sxMl0gPSBwc1swXTsKICAgICAgICAgIHBzWzEzXSA9IHBpICsgMDsKICAgICAgICAgIHBzWzE0XSA9IHBpICsgMTsKICAgICAgICAgIHBzWzE1XSA9IHBpICsgMjsKICAgICAgICAgIHBzWzhdID0gcHNbMV07CiAgICAgICAgICBwc1s5XSA9IHBpICsgOTsKICAgICAgICAgIHBzWzEwXSA9IHBpICsgMTA7CiAgICAgICAgICBwc1sxMV0gPSBwaSArIDM7CiAgICAgICAgICBwc1s0XSA9IHBzWzJdOwogICAgICAgICAgcHNbNV0gPSBwaSArIDg7CiAgICAgICAgICBwc1s2XSA9IHBpICsgMTE7CiAgICAgICAgICBwc1s3XSA9IHBpICsgNDsKICAgICAgICAgIHBzWzBdID0gcHNbM107CiAgICAgICAgICBwc1sxXSA9IHBpICsgNzsKICAgICAgICAgIHBzWzJdID0gcGkgKyA2OwogICAgICAgICAgcHNbM10gPSBwaSArIDU7CiAgICAgICAgICBjc1syXSA9IGNzWzBdOwogICAgICAgICAgY3NbM10gPSBjaTsKICAgICAgICAgIGNzWzBdID0gY3NbMV07CiAgICAgICAgICBjc1sxXSA9IGNpICsgMTsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIHRoaXMuZmlndXJlcy5wdXNoKHsKICAgICAgICB0eXBlOiAicGF0Y2giLAogICAgICAgIGNvb3JkczogbmV3IEludDMyQXJyYXkocHMpLAogICAgICAgIG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nVmID0gMDsKICAgIGNvbnN0IHNhbXBsZU11bCA9IDEuMCAvICgyLjAgKiogYnBzIC0gMSk7CiAgICBjb25zdCBzdHJCeXRlcyA9IHN0cmVhbS5nZXRCeXRlcygobGVuZ3RoICogYnBzICsgNykgLyA4KTsKICAgIGxldCBzdHJJZHggPSAwOwogICAgZm9yIChpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7CiAgICAgIHdoaWxlIChjb2RlU2l6ZSA8IGJwcykgewogICAgICAgIGNvZGVCdWYgPDw9IDg7CiAgICAgICAgY29kZUJ1ZiB8PSBzdHJCeXRlc1tzdHJJZHgrK107CiAgICAgICAgY29kZVNpemUgKz0gODsKICAgICAgfQogICAgICBjb2RlU2l6ZSAtPSBicHM7CiAgICAgIGFycmF5W2ldID0gKGNvZGVCdWYgPj4gY29kZVNpemUpICogc2FtcGxlTXVsOwogICAgICBjb2RlQnVmICY9ICgxIDw8IGNvZGVTaXplKSAtIDE7CiAgICB9CiAgICByZXR1cm4gYXJyYXk7CiAgfQogIHN0YXRpYyBwYXJzZShfcmVmMikgewogICAgbGV0IHsKICAgICAgeHJlZiwKICAgICAgaXNFdmFsU3VwcG9ydGVkLAogICAgICBmbgogICAgfSA9IF9yZWYyOwogICAgY29uc3QgZGljdCA9IGZuLmRpY3QgfHwgZm47CiAgICBjb25zdCB0eXBlTnVtID0gZGljdC5nZXQoIkZ1bmN0aW9uVHlwZSIpOwogICAgc3dpdGNoICh0eXBlTnVtKSB7CiAgICAgIGNhc2UgMDoKICAgICAgICByZXR1cm4gdGhpcy5jb25zdHJ1Y3RTYW1wbGVkKHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICBmbiwKICAgICAgICAgIGRpY3QKICAgICAgICB9KTsKICAgICAgY2FzZSAxOgogICAgICAgIGJyZWFrOwogICAgICBjYXNlIDI6CiAgICAgICAgcmV0dXJuIHRoaXMuY29uc3RydWN0SW50ZXJwb2xhdGVkKHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICBkaWN0CiAgICAgICAgfSk7CiAgICAgIGNhc2UgMzoKICAgICAgICByZXR1cm4gdGhpcy5jb25zdHJ1Y3RTdGljaGVkKHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICBkaWN0CiAgICAgICAgfSk7CiAgICAgIGNhc2UgNDoKICAgICAgICByZXR1cm4gdGhpcy5jb25zdHJ1Y3RQb3N0U2NyaXB0KHsKICAgICAgICAgIHhyZWYsCiAgICAgICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgICAgICBmbiwKICAgICAgICAgIGRpY3QKICAgICAgICB9KTsKICAgIH0KICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiVW5rbm93biB0eXBlIG9mIGZ1bmN0aW9uIik7CiAgfQogIHN0YXRpYyBwYXJzZUFycmF5KF9yZWYzKSB7CiAgICBsZXQgewogICAgICB4cmVmLAogICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgIGZuT2JqCiAgICB9ID0gX3JlZjM7CiAgICBpZiAoIUFycmF5LmlzQXJyYXkoZm5PYmopKSB7CiAgICAgIHJldHVybiB0aGlzLnBhcnNlKHsKICAgICAgICB4cmVmLAogICAgICAgIGlzRXZhbFN1cHBvcnRlZCwKICAgICAgICBmbjogZm5PYmoKICAgICAgfSk7CiAgICB9CiAgICBjb25zdCBmbkFycmF5ID0gW107CiAgICBmb3IgKGNvbnN0IGZuIG9mIGZuT2JqKSB7CiAgICAgIGZuQXJyYXkucHVzaCh0aGlzLnBhcnNlKHsKICAgICAgICB4cmVmLAogICAgICAgIGlzRXZhbFN1cHBvcnRlZCwKICAgICAgICBmbjogeHJlZi5mZXRjaElmUmVmKGZuKQogICAgICB9KSk7CiAgICB9CiAgICByZXR1cm4gZnVuY3Rpb24gKHNyYywgc3JjT2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dCBuMCA9IGUwICsgMSAtIGU7CiAgICAgICAgY29uc3QgbjEgPSBlIC0gZTA7CiAgICAgICAgY29uc3Qgb2Zmc2V0MCA9IGUwICogazsKICAgICAgICBjb25zdCBvZmZzZXQxID0gb2Zmc2V0MCArIGs7CiAgICAgICAgZm9yIChqID0gMDsgaiA8IGN1YmVWZXJ0aWNlczsgaisrKSB7CiAgICAgICAgICBpZiAoaiAmIHBvcykgewogICAgICAgICAgICBjdWJlTltqXSAqPSBuMTsKICAgICAgICAgICAgY3ViZVZlcnRleFtqXSArPSBvZmZzZXQxOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgY3ViZU5bal0gKj0gbjA7CiAgICAgICAgICAgIGN1YmVWZXJ0ZXhbal0gKz0gb2Zmc2V0MDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgayAqPSBzaXplX2k7CiAgICAgICAgcG9zIDw8PSAxOwogICAgICB9CiAgICAgIGZvciAoaiA9IDA7IGogPCBvdXRwdXRTaXplOyArK2opIHsKICAgICAgICBsZXQgcmogPSAwOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBjdWJlVmVydGljZXM7IGkrKykgewogICAgICAgICAgcmogKz0gc2FtcGxlc1tjdWJlVmVydGV4W2ldICsgal0gKiBjdWJlTltpXTsKICAgICAgICB9CiAgICAgICAgcmogPSBpbnRlcnBvbGF0ZShyaiwgMCwgMSwgZGVjb2RlW2pdWzBdLCBkZWNvZGVbal1bMV0pOwogICAgICAgIGRlc3RbZGVzdE9mZnNldCArIGpdID0gTWF0aC5taW4oTWF0aC5tYXgocmosIHJhbmdlW2pdWzBdKSwgcmFuZ2Vbal1bMV0pOwogICAgICB9CiAgICB9OwogIH0KICBzdGF0aWMgY29uc3RydWN0SW50ZXJwb2xhdGVkKF9yZWY1KSB7CiAgICBsZXQgewogICAgICB4cmVmLAogICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgIGRpY3QKICAgIH0gPSBfcmVmNTsKICAgIGNv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IDEpIHsKICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJCYWQgZG9tYWluIGZvciBzdGljaGVkIGZ1bmN0aW9uIik7CiAgICB9CiAgICBjb25zdCBmbnMgPSBbXTsKICAgIGZvciAoY29uc3QgZm4gb2YgZGljdC5nZXQoIkZ1bmN0aW9ucyIpKSB7CiAgICAgIGZucy5wdXNoKHRoaXMucGFyc2UoewogICAgICAgIHhyZWYsCiAgICAgICAgaXNFdmFsU3VwcG9ydGVkLAogICAgICAgIGZuOiB4cmVmLmZldGNoSWZSZWYoZm4pCiAgICAgIH0pKTsKICAgIH0KICAgIGNvbnN0IGJvdW5kcyA9IHRvTnVtYmVyQXJyYXkoZGljdC5nZXRBcnJheSgiQm91bmRzIikpOwogICAgY29uc3QgZW5jb2RlID0gdG9OdW1iZXJBcnJheShkaWN0LmdldEFycmF5KCJFbmNvZGUiKSk7CiAgICBjb25zdCB0bXBCdWYgPSBuZXcgRmxvYXQzMkFycmF5KDEpOwogICAgcmV0dXJuIGZ1bmN0aW9uIGNvbnN0cnVjdFN0aWNoZWRGbihzcmMsIHNyY09mZnNldCwgZGVzdCwgZGVzdE9mZnNldCkgewogICAgICBjb25zdCBjbGlwID0gZnVuY3Rpb24gY29uc3RydWN0U3RpY2hlZEZyb21JUkNsaXAodiwgbWluLCBtYXgpIHsKICAgICAgICBpZiAodiA+IG1heCkgewogICAgICAgICAgdiA9IG1heDsKICAgICAgICB9IGVsc2UgaWYgKHYgPCBtaW4pIHsKICAgICAgICAgIHYgPSBtaW47CiAgICAgICAgfQogICAgICAgIHJldHVybiB2OwogICAgICB9OwogICAgICBjb25zdCB2ID0gY2xpcChzcmNbc3JjT2Zmc2V0XSwgZG9tYWluWzBdLCBkb21haW5bMV0pOwogICAgICBjb25zdCBsZW5ndGggPSBib3VuZHMubGVuZ3RoOwogICAgICBsZXQgaTsKICAgICAgZm9yIChpID0gMDsgaSA8IGxlbmd0aDsgKytpKSB7CiAgICAgICAgaWYgKHYgPCBib3VuZHNbaV0pIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfQogICAgICBsZXQgZG1pbiA9IGRvbWFpblswXTsKICAgICAgaWYgKGkgPiAwKSB7CiAgICAgICAgZG1pbiA9IGJvdW5kc1tpIC0gMV07CiAgICAgIH0KICAgICAgbGV0IGRtYXggPSBkb21haW5bMV07CiAgICAgIGlmIChpIDwgYm91bmRzLmxlbmd0aCkgewogICAgICAgIGRtYXggPSBib3VuZHNbaV07CiAgICAgIH0KICAgICAgY29uc3Qgcm1pbiA9IGVuY29kZVsyICogaV07CiAgICAgIGNvbnN0IHJtYXggPSBlbmNvZGVbMiAqIGkgKyAxXTsKICAgICAgdG1wQnVmWzBdID0gZG1pbiA9PT0gZG1heCA/IHJtaW4gOiBybWluICsgKHYgLSBkbWluKSAqIChybWF4IC0gcm1pbikgLyAoZG1heCAtIGRtaW4pOwogICAgICBmbnNbaV0odG1wQnVmLCAwLCBkZXN0LCBkZXN0T2Zmc2V0KTsKICAgIH07CiAgfQogIHN0YXRpYyBjb25zdHJ1Y3RQb3N0U2NyaXB0KF9yZWY3KSB7CiAgICBsZXQgewogICAgICB4cmVmLAogICAgICBpc0V2YWxTdXBwb3J0ZWQsCiAgICAgIGZuLAogICAgICBkaWN0CiAgICB9ID0gX3JlZjc7CiAgICBjb25zdCBkb21haW4gPSB0b051bWJlckFycmF5KGRpY3QuZ2V0QXJyYXkoIkRvbWFpbiIpKTsKICAgIGNvbnN0IHJhbmdlID0gdG9OdW1iZXJBcnJheShkaWN0LmdldEFycmF5KCJSYW5nZSIpKTsKICAgIGlmICghZG9tYWluKSB7CiAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiTm8gZG9tYWluLiIpOwogICAgfQogICAgaWYgKCFyYW5nZSkgewogICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIk5vIHJhbmdlLiIpOwogICAgfQogICAgY29uc3QgbGV4ZXIgPS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AgICBsZXQgaSwgdmFsdWU7CiAgICAgIGxldCBrZXkgPSAiIjsKICAgICAgY29uc3QgaW5wdXQgPSB0bXBCdWY7CiAgICAgIGZvciAoaSA9IDA7IGkgPCBudW1JbnB1dHM7IGkrKykgewogICAgICAgIHZhbHVlID0gc3JjW3NyY09mZnNldCArIGldOwogICAgICAgIGlucHV0W2ldID0gdmFsdWU7CiAgICAgICAga2V5ICs9IHZhbHVlICsgIl8iOwogICAgICB9CiAgICAgIGNvbnN0IGNhY2hlZFZhbHVlID0gY2FjaGVba2V5XTsKICAgICAgaWYgKGNhY2hlZFZhbHVlICE9PSB1bmRlZmluZWQpIHsKICAgICAgICBkZXN0LnNldChjYWNoZWRWYWx1ZSwgZGVzdE9mZnNldCk7CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGNvbnN0IG91dHB1dCA9IG5ldyBGbG9hdDMyQXJyYXkobnVtT3V0cHV0cyk7CiAgICAgIGNvbnN0IHN0YWNrID0gZXZhbHVhdG9yLmV4ZWN1dGUoaW5wdXQpOwogICAgICBjb25zdCBzdGFja0luZGV4ID0gc3RhY2subGVuZ3RoIC0gbnVtT3V0cHV0czsKICAgICAgZm9yIChpID0gMDsgaSA8IG51bU91dHB1dHM7IGkrKykgewogICAgICAgIHZhbHVlID0gc3RhY2tbc3RhY2tJbmRleCArIGldOwogICAgICAgIGxldCBib3VuZCA9IHJhbmdlW2kgKiAyXTsKICAgICAgICBpZiAodmFsdWUgPCBib3VuZCkgewogICAgICAgICAgdmFsdWUgPSBib3VuZDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgYm91bmQgPSByYW5nZVtpICogMiArIDFdOwogICAgICAgICAgaWYgKHZhbHVlID4gYm91bmQpIHsKICAgICAgICAgICAgdmFsdWUgPSBib3VuZDsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgb3V0cHV0W2ldID0gdmFsdWU7CiAgICAgIH0KICAgICAgaWYgKGNhY2hlX2F2YWlsYWJsZSA+IDApIH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obGV0IGkgPSBjLCBqID0gcjsgaSA8IGo7IGkrKywgai0tKSB7CiAgICAgIGNvbnN0IHQgPSBzdGFja1tpXTsKICAgICAgc3RhY2tbaV0gPSBzdGFja1tqXTsKICAgICAgc3RhY2tbal0gPSB0OwogICAgfQogIH0KfQpjbGFzcyBQb3N0U2NyaXB0RXZhbHVhdG9yIHsKICBjb25zdHJ1Y3RvcihvcGVyYXRvcnMpIHsKICAgIHRoaXMub3BlcmF0b3JzID0gb3BlcmF0b3JzOwogIH0KICBleGVjdXRlKGluaXRpYWxTdGFjaykgewogICAgY29uc3Qgc3RhY2sgPSBuZXcgUG9zdFNjcmlwdFN0YWNrKGluaXRpYWxTdGFjayk7CiAgICBsZXQgY291bnRlciA9IDA7CiAgICBjb25zdCBvcGVyYXRvcnMgPSB0aGlzLm9wZXJhdG9yczsKICAgIGNvbnN0IGxlbmd0aCA9IG9wZXJhdG9ycy5sZW5ndGg7CiAgICBsZXQgb3BlcmF0b3IsIGEsIGI7CiAgICB3aGlsZSAoY291bnRlciA8IGxlbmd0aCkgewogICAgICBvcGVyYXRvciA9IG9wZXJhdG9yc1tjb3VudGVyKytdOwogICAgICBpZiAodHlwZW9mIG9wZXJhdG9yID09PSAibnVtYmVyIikgewogICAgICAgIHN0YWNrLnB1c2gob3BlcmF0b3IpOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIHN3aXRjaCAob3BlcmF0b3IpIHsKICAgICAgICBjYXNlICJqeiI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBpZiAoIWEpIHsKICAgICAgICAgICAgY291bnRlciA9IGI7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJqIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGNvdW50ZXIgPSBhOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiYWJzIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goTWF0aC5hYnMoYSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiYWRkIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSArIGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiYW5kIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGlmICh0eXBlb2YgYSA9PT0gImJvb2xlYW4iICYmIHR5cGVvZiBiID09PSAiYm9vbGVhbiIpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhICYmIGIpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhICYgYik7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJhdGFuIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBNYXRoLmF0YW4yKGEsIGIpIC8gTWF0aC5QSSAqIDE4MDsKICAgICAgICAgIGlmIChhIDwgMCkgewogICAgICAgICAgICBhICs9IDM2MDsKICAgICAgICAgIH0KICAgICAgICAgIHN0YWNrLnB1c2goYSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJiaXRzaGlmdCI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBpZiAoYSA+IDApIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhIDw8IGIpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhID4+IGIpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiY2VpbGluZyI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGguY2VpbChhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJjb3B5IjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLmNvcHkoYSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJjb3MiOgogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChNYXRoLmNvcyhhICUgMzYwIC8gMTgwICogTWF0aC5QSSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiY3ZpIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKSB8IDA7CiAgICAgICAgICBzdGFjay5wdXNoKGEpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiY3ZyIjoKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImRpdiI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgLyBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImR1cCI6CiAgICAgICAgICBzdGFjay5jb3B5KDEpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZXEiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhID09PSBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImV4Y2giOgogICAgICAgICAgc3RhY2sucm9sbCgyLCAxKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImV4cCI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgKiogYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJmYWxzZSI6CiAgICAgICAgICBzdGFjay5wdXNoKGZhbHNlKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImZsb29yIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goTWF0aC5mbG9vcihhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJnZSI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgPj0gYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJndCI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgPiBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImlkaXYiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhIC8gYiB8IDApOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiaW5kZXgiOgogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2suaW5kZXgoYSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJsZSI6CiAgICAgICAgICBiID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGEgPD0gYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJsbiI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGgubG9nKGEpKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImxvZyI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGgubG9nKGEpIC8gTWF0aC5MTjEwKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImx0IjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSA8IGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibW9kIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSAlIGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibXVsIjoKICAgICAgICAgIGIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYSAqIGIpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibmUiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhICE9PSBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIm5lZyI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKC1hKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIm5vdCI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBpZiAodHlwZW9mIGEgPT09ICJib29sZWFuIikgewogICAgICAgICAgICBzdGFjay5wdXNoKCFhKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHN0YWNrLnB1c2gofmEpOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAib3IiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgaWYgKHR5cGVvZiBhID09PSAiYm9vbGVhbiIgJiYgdHlwZW9mIGIgPT09ICJib29sZWFuIikgewogICAgICAgICAgICBzdGFjay5wdXNoKGEgfHwgYik7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBzdGFjay5wdXNoKGEgfCBiKTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInBvcCI6CiAgICAgICAgICBzdGFjay5wb3AoKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJvbGwiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucm9sbChhLCBiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJvdW5kIjoKICAgICAgICAgIGEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goTWF0aC5yb3VuZChhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJzaW4iOgogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChNYXRoLnNpbihhICUgMzYwIC8gMTgwICogTWF0aC5QSSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAic3FydCI6CiAgICAgICAgICBhID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKE1hdGguc3FydChhKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJzdWIiOgogICAgICAgICAgYiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgYSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChhIC0gYik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJ0cnVlI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yYXRpb24pIHsKICAgIHRoaXMucGFydHMucHVzaCgiKCIpOwogICAgb3BlcmF0aW9uLmFyZzEudmlzaXQodGhpcyk7CiAgICB0aGlzLnBhcnRzLnB1c2goIiAiLCBvcGVyYXRpb24ub3AsICIgIik7CiAgICBvcGVyYXRpb24uYXJnMi52aXNpdCh0aGlzKTsKICAgIHRoaXMucGFydHMucHVzaCgiKSIpOwogIH0KICB2aXNpdFZhcmlhYmxlRGVmaW5pdGlvbihkZWZpbml0aW9uKSB7CiAgICB0aGlzLnBhcnRzLnB1c2goInZhciAiKTsKICAgIGRlZmluaXRpb24udmFyaWFibGUudmlzaXQodGhpcyk7CiAgICB0aGlzLnBhcnRzLnB1c2goIiA9ICIpOwogICAgZGVmaW5pdGlvbi5hcmcudmlzaXQodGhpcyk7CiAgICB0aGlzLnBhcnRzLnB1c2goIjsiKTsKICB9CiAgdmlzaXRNaW4obWF4KSB7CiAgICB0aGlzLnBhcnRzLnB1c2goIk1hdGgubWluKCIpOwogICAgbWF4LmFyZy52aXNpdCh0aGlzKTsKICAgIHRoaXMucGFydHMucHVzaCgiLCAiLCBtYXgubWF4LCAiKSIpOwogIH0KICB0b1N0cmluZygpIHsKICAgIHJldHVybiB0aGlzLnBhcnRzLmpvaW4oIiIpOwogIH0KfQpmdW5jdGlvbiBidWlsZEFkZE9wZXJhdGlvbihudW0xLCBudW0yKSB7CiAgaWYgKG51bTIudHlwZSA9PT0gImxpdGVyYWwiICYmIG51bTIubnVtYmVyID09PSAwKSB7CiAgICByZXR1cm4gbnVtMTsKICB9CiAgaWYgKG51bTEudHlwZSA9PT0gImxpdGVyYWwiICYmIG51bTEubnVtYmVyID09PSAwKSB7CiAgICByZXR1cm4gbnVtMjsKICB9CiAgaWYgKG51bTIudHlwZSA9PT0gImxpdGVyYWwiICYmIG51bTEudHlwZSA9PT0gImxpdGVyYWwiKSB7CiAgICByZXR1cm4gbmV3IEFzdExpdGVyYWwobnVtMS5udW1iZXIgKyBudW0yLm51bWJlc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gYnVpbGRTdWJPcGVyYXRpb24obnVtMSwgbnVtMikgewogIGlmIChudW0yLnR5cGUgPT09ICJsaXRlcmFsIikgewogICAgaWYgKG51bTIubnVtYmVyID09PSAwKSB7CiAgICAgIHJldHVybiBudW0xOwogICAgfSBlbHNlIGlmIChudW0xLnR5cGUgPT09ICJsaXRlcmFsIikgewogICAgICByZXR1cm4gbmV3IEFzdExpdGVyYWwobnVtMS5udW1iZXIgLSBudW0yLm51bWJlcik7CiAgICB9CiAgfQogIGlmIChudW0yLnR5cGUgPT09ICJiaW5hcnkiICYmIG51bTIub3AgPT09ICItIiAmJiBudW0xLnR5cGUgPT09ICJsaXRlcmFsIiAmJiBudW0xLm51bWJlciA9PT0gMSAmJiBudW0yLmFyZzEudHlwZSA9PT0gImxpdGVyYWwiICYmIG51bTIuYXJnMS5udW1iZXIgPT09IDEpIHsKICAgIHJldHVybiBudW0yLmFyZzI7CiAgfQogIHJldHVybiBuZXcgQXN0QmluYXJ5T3BlcmF0aW9uKCItIiwgbnVtMSwgbnVtMiwgbnVtMS5taW4gLSBudW0yLm1heCwgbnVtMS5tYXggLSBudW0yLm1pbik7Cn0KZnVuY3Rpb24gYnVpbGRNaW5PcGVyYXRpb24obnVtMSwgbWF4KSB7CiAgaWYgKG51bTEubWluID49IG1heCkgewogICAgcmV0dXJuIG5ldyBBc3RMaXRlcmFsKG1heCk7CiAgfSBlbHNlIGlmIChudW0xLm1heCA8PSBtYXgpIHsKICAgIHJldHVybiBudW0xOwogIH0KICByZXR1cm4gbmV3IEFzdE1pbihudW0xLCBtYXgpOwp9CmNsYXNzIFBvc3RTY3JpcHRDb21waWxlciB7CiAgY29tcGlsZShjb2RlLCBkb21haW4sIHJhbmdlKSB7CiAgICBjb25zdCBzdGFjayA9IFtdOwogICAgY29uc3QgaW5zdHJ1Y3Rpb25zID0gW107CiAgICBjb25zdCBpbnB1dFNpemUgPSBkb21haW4ubGVuZ3RoID4+IDEsCiAgICAgIG91dHB1dFNpemUgPSByYW5nZS5sZW5ndGggPj4gMTsKICAgIGxldCBsYXN0UmVnaXN0ZXIgPSAwOwogICAgbGV0IG4sIGo7CiAgICBsZXQgbnVtMSwgbnVtMiwgYXN0MSwgYXN0MiwgdG1wVmFyLCBpdGVtOwogICAgZm9yIChsZXQgaSA9IDA7IGkgPCBpbnB1dFNpemU7IGkrKykgewogICAgICBzdGFjay5wdXNoKG5ldyBBc3RBcmd1bWVudChpLCBkb21haW5baSAqIDJdLCBkb21haW5baSAqIDIgKyAxXSkpOwogICAgfQogICAgZm9yIChsZXQgaSA9IDAsIGlpID0gY29kZS5sZW5ndGg7IGkgPCBpaTsgaSsrKSB7CiAgICAgIGl0ZW0gPSBjb2RlW2ldOwogICAgICBpZiAodHlwZW9mIGl0ZW0gPT09ICJudW1iZXIiKSB7CiAgICAgICAgc3RhY2sucHVzaChuZXcgQXN0TGl0ZXJhbChpdGVtKSk7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgc3dpdGNoIChpdGVtKSB7CiAgICAgICAgY2FzZSAiYWRkIjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAyKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbnVtMiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgc3RhY2sucHVzaChidWlsZEFkZE9wZXJhdGlvbihudW0xLCBudW0yKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJjdnIiOgogICAgICAgICAgaWYgKHN0YWNrLmxlbmd0aCA8IDEpIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJtdWwiOgogICAgICAgICAgaWYgKHN0YWNrLmxlbmd0aCA8IDIpIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBudW0yID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBudW0xID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBzdGFjay5wdXNoKGJ1aWxkTXVsT3BlcmF0aW9uKG51bTEsIG51bTIpKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInN1YiI6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgIH0KICAgICAgICAgIG51bTIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIG51bTEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYnVpbGRTdWJPcGVyYXRpb24obnVtMSwgbnVtMikpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZXhjaCI6CiAgICAgICAgICBpZiAoc3RhY2subGVuZ3RoIDwgMikgewogICAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICAgIH0KICAgICAgICAgIGFzdDEgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGFzdDIgPSBzdGFjay5wb3AoKTsKICAgICAgICAgIHN0YWNrLnB1c2goYXN0MSwgYXN0Mik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJwb3AiOgogICAgICAgICAgaWYgKHN0YWNrLmxlbmd0aCA8IDEpIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBzdGFjay5wb3AoKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImluZGV4IjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAxKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgaWYgKG51bTEudHlwZSAhPT0gImxpdGVyYWwiKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbiA9IG51bTEubnVtYmVyOwogICAgICAgICAgaWYgKG4gPCAwIHx8ICFOdW1iZXIuaXNJbnRlZ2VyKG4pIHx8IHN0YWNrLmxlbmd0aCA8IG4pIHsKICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBhc3QxID0gc3RhY2tbc3RhY2subGVuZ3RoIC0gbiAtIDFdOwogICAgICAgICAgaWYgKGFzdDEudHlwZSA9PT0gImxpdGVyYWwiIHx8IGFzdDEudHlwZSA9PT0gInZhciIpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhc3QxKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICB0bXBWYXIgPSBuZXcgQXN0VmFyaWFibGUobGFzdFJlZ2lzdGVyKyssIGFzdDEubWluLCBhc3QxLm1heCk7CiAgICAgICAgICBzdGFja1tzdGFjay5sZW5ndGggLSBuIC0gMV0gPSB0bXBWYXI7CiAgICAgICAgICBzdGFjay5wdXNoKHRtcFZhcik7CiAgICAgICAgICBpbnN0cnVjdGlvbnMucHVzaChuZXcgQXN0VmFyaWFibGVEZWZpbml0aW9uKHRtcFZhciwgYXN0MSkpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZHVwIjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAxKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaWYgKHR5cGVvZiBjb2RlW2kgKyAxXSA9PT0gIm51bWJlciIgJiYgY29kZVtpICsgMl0gPT09ICJndCIgJiYgY29kZVtpICsgM10gPT09IGkgKyA3ICYmIGNvZGVbaSArIDRdID09PSAianoiICYmIGNvZGVbaSArIDVdID09PSAicG9wIiAmJiBjb2RlW2kgKyA2XSA9PT0gY29kZVtpICsgMV0pIHsKICAgICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgICBzdGFjay5wdXNoKGJ1aWxkTWluT3BlcmF0aW9uKG51bTEsIGNvZGVbaSArIDFdKSk7CiAgICAgICAgICAgIGkgKz0gNjsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICBhc3QxID0gc3RhY2suYXQoLTEpOwogICAgICAgICAgaWYgKGFzdDEudHlwZSA9PT0gImxpdGVyYWwiIHx8IGFzdDEudHlwZSA9PT0gInZhciIpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChhc3QxKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgICB0bXBWYXIgPSBuZXcgQXN0VmFyaWFibGUobGFzdFJlZ2lzdGVyKyssIGFzdDEubWluLCBhc3QxLm1heCk7CiAgICAgICAgICBzdGFja1tzdGFjay5sZW5ndGggLSAxXSA9IHRtcFZhcjsKICAgICAgICAgIHN0YWNrLnB1c2godG1wVmFyKTsKICAgICAgICAgIGluc3RydWN0aW9ucy5wdXNoKG5ldyBBc3RWYXJpYWJsZURlZmluaXRpb24odG1wVmFyLCBhc3QxKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJyb2xsIjoKICAgICAgICAgIGlmIChzdGFjay5sZW5ndGggPCAyKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgbnVtMiA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgbnVtMSA9IHN0YWNrLnBvcCgpOwogICAgICAgICAgaWYgKG51bTIudHlwZSAhPT0gImxpdGVyYWwiIHx8IG51bTEudHlwZSAhPT0gImxpdGVyYWwiKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaiA9IG51bTIubnVtYmVyOwogICAgICAgICAgbiA9IG51bTEubnVtYmVyOwogICAgICAgICAgaWYgKG4gPD0gMCB8fCAhTnVtYmVyLmlzSW50ZWdlcihuKSB8fCAhTnVtYmVyLmlzSW50ZWdlcihqKSB8fCBzdGFjay5sZW5ndGggPCBuKSB7CiAgICAgICAgICAgIHJld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KICAgIGxldCBjb21tZW50ID0gZmFsc2U7CiAgICBsZXQgY2ggPSB0aGlzLmN1cnJlbnRDaGFyOwogICAgd2hpbGUgKHRydWUpIHsKICAgICAgaWYgKGNoIDwgMCkgewogICAgICAgIHJldHVybiBfcHJpbWl0aXZlcy5FT0Y7CiAgICAgIH0KICAgICAgaWYgKGNvbW1lbnQpIHsKICAgICAgICBpZiAoY2ggPT09IDB4MGEgfHwgY2ggPT09IDB4MGQpIHsKICAgICAgICAgIGNvbW1lbnQgPSBmYWxzZTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAoY2ggPT09IDB4MjUpIHsKICAgICAgICBjb21tZW50ID0gdHJ1ZTsKICAgICAgfSBlbHNlIGlmICghKDAsIF9jb3JlX3V0aWxzLmlzV2hpdGVTcGFjZSkoY2gpKSB7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgICAgY2ggPSB0aGlzLm5leHRDaGFyKCk7CiAgICB9CiAgICBzd2l0Y2ggKGNoIHwgMCkgewogICAgICBjYXNlIDB4MzA6CiAgICAgIGNhc2UgMHgzMToKICAgICAgY2FzZSAweDMyOgogICAgICBjYXNlIDB4MzM6CiAgICAgIGNhc2UgMHgzNDoKICAgICAgY2FzZSAweDM1OgogICAgICBjYXNlIDB4MzY6CiAgICAgIGNhc2UgMHgzNzoKICAgICAgY2FzZSAweDM4OgogICAgICBjYXNlIDB4Mzk6CiAgICAgIGNhc2UgMHgyYjoKICAgICAgY2FzZSAweDJkOgogICAgICBjYXNlIDB4MmU6CiAgICAgICAgcmV0dXJuIG5ldyBQb3N0U2NyaXB0VG9rZW4oUG9zdFNjcmlwdFRva2VuVHlwZXMuTlVNQkVSLCB0aGlzLmdldE51bWJlcigpKTsKICAgICAgY2FzZSAweDdiOgogICAgICAgIHRoaXMubmV4dENoYXIoKTsKICAgICAgICByZXR1cm4gUG9zdFNjcmlwdFRva2VuLkxCUkFDRTsKICAgICAgY2FzZSAweDdkOgogICAgICAgIHRoaXMubmV4dEN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Ik5TTSIsICJOU00iLCAiTlNNIiwgIk5TTSIsICJOU00iLCAiTlNNIiwgIkFOIiwgIkFOIiwgIkFOIiwgIkFOIiwgIkFOIiwgIkFOIiwgIkFOIiwgIkFOIiwgIkFOIiwgIkFOIiwgIkVUIiwgIkFOIiwgIkFOIiwgIkFMIiwgIkFMIiwgIkFMIiwgIk5TTSIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJBTCIsICJOU00iLCAiTlNNIiwgIk5TTSIsICJOU00iLCAiTlNNIiwgIk5TTSIsICJOU00iLCAiQU4iLCAiT04iLCAiTlNNIiwgIk5TTSIsICJOU00iLCAiTlNNIiwgIk5TTSIsICJOU00iLCAi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iICYmICh0eXBlc1tpIC0gMV0gPT09ICJFTiIgfHwgdHlwZXNbaSAtIDFdID09PSAiQU4iKSAmJiB0eXBlc1tpICsgMV0gPT09IHR5cGVzW2kgLSAxXSkgewogICAgICB0eXBlc1tpXSA9IHR5cGVzW2kgLSAxXTsKICAgIH0KICB9CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICBpZiAodHlwZXNbaV0gPT09ICJFTiIpIHsKICAgICAgZm9yIChsZXQgaiA9IGkgLSAxOyBqID49IDA7IC0taikgewogICAgICAgIGlmICh0eXBlc1tqXSAhPT0gIkVUIikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIHR5cGVzW2pdID0gIkVOIjsKICAgICAgfQogICAgICBmb3IgKGxldCBqID0gaSArIDE7IGogPCBzdHJMZW5ndGg7ICsraikgewogICAgICAgIGlmICh0eXBlc1tqXSAhPT0gIkVUIikgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIHR5cGVzW2pdID0gIkVOIjsKICAgICAgfQogICAgfQogIH0KICBmb3IgKGkgPSAwOyBpIDwgc3RyTGVuZ3RoOyArK2kpIHsKICAgIHQgPSB0eXBlc1tpXTsKICAgIGlmICh0ID09PSAiV1MiIHx8IHQgPT09ICJFUyIgfHwgdCA9PT0gIkVUIiB8fCB0ID09PSAiQ1MiKSB7CiAgICAgIHR5cGVzW2ldID0gIk9OIjsKICAgIH0KICB9CiAgbGFzdFR5cGUgPSBzb3I7CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICB0ID0gdHlwZXNbaV07CiAgICBpZiAodCA9PT0gIkVOIikgewogICAgICB0eXBlc1tpXSA9IGxhc3RUeXBlID09PSAiTCIgPyAiTCIgOiAiRU4iOwogICAgfSBlbHNlIGlmICh0ID09PSAiUiIgfHwgdCA9PT0gIkwiKSB7CiAgICAgIGxhc3RUeXBlID0gdDsKICAgIH0KICB9CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICBpZiAodHlwZXNbaV0gPT09ICJPTiIpIHsKICAgICAgY29uc3QgZW5kID0gZmluZFVuZXF1YWwodHlwZXMsIGkgKyAxLCAiT04iKTsKICAgICAgbGV0IGJlZm9yZSA9IHNvcjsKICAgICAgaWYgKGkgPiAwKSB7CiAgICAgICAgYmVmb3JlID0gdHlwZXNbaSAtIDFdOwogICAgICB9CiAgICAgIGxldCBhZnRlciA9IGVvcjsKICAgICAgaWYgKGVuZCArIDEgPCBzdHJMZW5ndGgpIHsKICAgICAgICBhZnRlciA9IHR5cGVzW2VuZCArIDFdOwogICAgICB9CiAgICAgIGlmIChiZWZvcmUgIT09ICJMIikgewogICAgICAgIGJlZm9yZSA9ICJSIjsKICAgICAgfQogICAgICBpZiAoYWZ0ZXIgIT09ICJMIikgewogICAgICAgIGFmdGVyID0gIlIiOwogICAgICB9CiAgICAgIGlmIChiZWZvcmUgPT09IGFmdGVyKSB7CiAgICAgICAgc2V0VmFsdWVzKHR5cGVzLCBpLCBlbmQsIGJlZm9yZSk7CiAgICAgIH0KICAgICAgaSA9IGVuZCAtIDE7CiAgICB9CiAgfQogIGZvciAoaSA9IDA7IGkgPCBzdHJMZW5ndGg7ICsraSkgewogICAgaWYgKHR5cGVzW2ldID09PSAiT04iKSB7CiAgICAgIHR5cGVzW2ldID0gZTsKICAgIH0KICB9CiAgZm9yIChpID0gMDsgaSA8IHN0ckxlbmd0aDsgKytpKSB7CiAgICB0ID0gdHlwZXNbaV07CiAgICBpZiAoaXNFdmVuKGxldmVsc1tpXSkpIHsKICAgICAgaWYgKHQgPT09ICJSIikgewogICAgICAgIGxldmVsc1tpXSArPSAxOwogICAgICB9IGVsc2UgaWYgKHQgPT09ICJBTiIgfHwgdCA9PT0gIkVOIikgewogICAgICAgIGxldmVsc1tpXSArPSAyOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBpZiAodCA9PT0gIkwiIHx8IHQgPT09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RhdGEgPSBudWxsOwogICAgaW1nRGF0YS5iaXRtYXAgPSBiaXRtYXA7CiAgICBpbWdEYXRhLndpZHRoID0gbmV3V2lkdGg7CiAgICBpbWdEYXRhLmhlaWdodCA9IG5ld0hlaWdodDsKICAgIHJldHVybiBpbWdEYXRhOwogIH0KICBfZW5jb2RlQk1QKCkgewogICAgY29uc3QgewogICAgICB3aWR0aCwKICAgICAgaGVpZ2h0LAogICAgICBraW5kCiAgICB9ID0gdGhpcy5faW1nRGF0YTsKICAgIGxldCBkYXRhID0gdGhpcy5faW1nRGF0YS5kYXRhOwogICAgbGV0IGJpdFBlclBpeGVsOwogICAgbGV0IGNvbG9yVGFibGUgPSBuZXcgVWludDhBcnJheSgwKTsKICAgIGxldCBtYXNrVGFibGUgPSBjb2xvclRhYmxlOwogICAgbGV0IGNvbXByZXNzaW9uID0gMDsKICAgIHN3aXRjaCAoa2luZCkgewogICAgICBjYXNlIF91dGlsLkltYWdlS2luZC5HUkFZU0NBTEVfMUJQUDoKICAgICAgICB7CiAgICAgICAgICBiaXRQZXJQaXhlbCA9IDE7CiAgICAgICAgICBjb2xvclRhYmxlID0gbmV3IFVpbnQ4QXJyYXkodGhpcy5faXNNYXNrID8gWzI1NSwgMjU1LCAyNTUsIDI1NSwgMCwgMCwgMCwgMF0gOiBbMCwgMCwgMCwgMCwgMjU1LCAyNTUsIDI1NSwgMjU1XSk7CiAgICAgICAgICBjb25zdCByb3dMZW4gPSB3aWR0aCArIDcgPj4gMzsKICAgICAgICAgIGNvbnN0IHJvd1NpemUgPSByb3dMZW4gKyAzICYgLTQ7CiAgICAgICAgICBpZiAocm93TGVuICE9PSByb3dTaXplKSB7CiAgICAgICAgICAgIGNvbnN0IG5ld0RhdGEgPSBuZXcgVWludDhBcnJheShyb3dTaXplICogaGVpZ2h0KTsKICAgICAgICAgICAgbGV0IGsgPSAwOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBoZWlnaHQgKiByb3dMZW47IGkgPCBpaTsgaSArPSByb3dMZW4sIGsgKz0gcm93U2l6ZSkgewogICAgICAgICAgICAgIG5ld0RhdGEuc2V0KGRhdGEuc3ViYXJyYXkoaSwgaSArIHJvd0xlbiksIGspOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGRhdGEgPSBuZXdEYXRhOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICBjYXNlIF91dGlsLkltYWdlS2luZC5SR0JfMjRCUFA6CiAgICAgICAgewogICAgICAgICAgYml0UGVyUGl4ZWwgPSAyNDsKICAgICAgICAgIGlmICh3aWR0aCAmIDMpIHsKICAgICAgICAgICAgY29uc3Qgcm93TGVuID0gMyAqIHdpZHRoOwogICAgICAgICAgICBjb25zdCByb3dTaXplID0gcm93TGVuICsgMyAmIC00OwogICAgICAgICAgICBjb25zdCBleHRyYUxlbiA9IHJvd1NpemUgLSByb3dMZW47CiAgICAgICAgICAgIGNvbnN0IG5ld0RhdGEgPSBuZXcgVWludDhBcnJheShyb3dTaXplICogaGVpZ2h0KTsKICAgICAgICAgICAgbGV0IGsgPSAwOwogICAgICAgICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBoZWlnaHQgKiByb3dMZW47IGkgPCBpaTsgaSArPSByb3dMZW4pIHsKICAgICAgICAgICAgICBjb25zdCByb3cgPSBkYXRhLnN1YmFycmF5KGksIGkgKyByb3dMZW4pOwogICAgICAgICAgICAgIGZvciAobGV0IGogPSAwOyBqIDwgcm93TGVuOyBqICs9IDMpIHsKICAgICAgICAgICAgICAgIG5ld0RhdGFbaysrXSA9IHJvd1tqICsgMl07CiAgICAgICAgICAgICAgICBuZXdEYXRhW2srK10gPSByb3dbaiArIDFdOwogICAgICAgICAgICAgICAgbmV3RGF0YVtrKytdID0gcm93W2pdOwogICAgICAgICAgICAgIH0KICAgICAgICAgICAgICBrICs9IGV4dHJhTGVuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGRhdGEgPSBuZXdEYXRhOwogICAgICAgIC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BdOwogICAgaWYgKGN1cnJlbnRYICsgaW1nLndpZHRoID4gTUFYX1dJRFRIKSB7CiAgICAgIG1heFggPSBNYXRoLm1heChtYXhYLCBjdXJyZW50WCk7CiAgICAgIGN1cnJlbnRZICs9IG1heExpbmVIZWlnaHQgKyAyICogSU1BR0VfUEFERElORzsKICAgICAgY3VycmVudFggPSAwOwogICAgICBtYXhMaW5lSGVpZ2h0ID0gMDsKICAgIH0KICAgIG1hcC5wdXNoKHsKICAgICAgdHJhbnNmb3JtLAogICAgICB4OiBjdXJyZW50WCwKICAgICAgeTogY3VycmVudFksCiAgICAgIHc6IGltZy53aWR0aCwKICAgICAgaDogaW1nLmhlaWdodAogICAgfSk7CiAgICBjdXJyZW50WCArPSBpbWcud2lkdGggKyAyICogSU1BR0VfUEFERElORzsKICAgIG1heExpbmVIZWlnaHQgPSBNYXRoLm1heChtYXhMaW5lSGVpZ2h0LCBpbWcuaGVpZ2h0KTsKICB9CiAgY29uc3QgaW1nV2lkdGggPSBNYXRoLm1heChtYXhYLCBjdXJyZW50WCkgKyBJTUFHRV9QQURESU5HOwogIGNvbnN0IGltZ0hlaWdodCA9IGN1cnJlbnRZICsgbWF4TGluZUhlaWdodCArIElNQUdFX1BBRERJTkc7CiAgY29uc3QgaW1nRGF0YSA9IG5ldyBVaW50OEFycmF5KGltZ1dpZHRoICogaW1nSGVpZ2h0ICogNCk7CiAgY29uc3QgaW1nUm93U2l6ZSA9IGltZ1dpZHRoIDw8IDI7CiAgZm9yIChsZXQgcSA9IDA7IHEgPCBjb3VudDsgcSsrKSB7CiAgICBjb25zdCBkYXRhID0gYXJnc0FycmF5W2lGaXJzdFBJSVhPICsgKHEgPDwgMildWzBdLmRhdGE7CiAgICBjb25zdCByb3dTaXplID0gbWFwW3FdLncgPDwgMjsKICAgIGxldCBkYXRhT2Zmc2V0ID0gMDsKICAgIGxldCBvZmZzZXQgPSBtYXBbcV0ueCArIG1hcFtxXS55ICogaW1nV2lkdGggPDwgMjsKICAgIG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BpaTsKICAgICAgcmV0dXJuOwogICAgfQogICAgY29uc3QgY29udGV4dCA9IHRoaXMuY29udGV4dDsKICAgIHdoaWxlIChpIDwgaWkpIHsKICAgICAgaWYgKG1hdGNoKSB7CiAgICAgICAgY29uc3QgaXRlcmF0ZSA9ICgwLCBtYXRjaC5pdGVyYXRlRm4pKGNvbnRleHQsIGkpOwogICAgICAgIGlmIChpdGVyYXRlKSB7CiAgICAgICAgICBpKys7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgaSA9ICgwLCBtYXRjaC5wcm9jZXNzRm4pKGNvbnRleHQsIGkgKyAxKTsKICAgICAgICBpaSA9IGZuQXJyYXkubGVuZ3RoOwogICAgICAgIG1hdGNoID0gbnVsbDsKICAgICAgICBzdGF0ZSA9IG51bGw7CiAgICAgICAgaWYgKGkgPj0gaWkpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfQogICAgICBzdGF0ZSA9IChzdGF0ZSB8fCBJbml0aWFsU3RhdGUpW2ZuQXJyYXlbaV1dOwogICAgICBpZiAoIXN0YXRlIHx8IEFycmF5LmlzQXJyYXkoc3RhdGUpKSB7CiAgICAgICAgaSsrOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnRleHQuaUN1cnIgPSBpOwogICAgICBpKys7CiAgICAgIGlmIChzdGF0ZS5jaGVja0ZuICYmICEoMCwgc3RhdGUuY2hlY2tGbikoY29udGV4dCkpIHsKICAgICAgICBzdGF0ZSA9IG51bGw7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgbWF0Y2ggPSBzdGF0ZTsKICAgICAgc3RhdGUgPSBudWxsOwogICAgfQogICAgdGhpcy5zdGF0ZSA9IHN0YXRlOwogICAgdGhpcy5tYXRjaCA9IG1hdGNoOwogICAgdGhpcy5sYXN0UHJvY2Vzc2VkID0gaTsKICB9CiAgZmx1c2goKSB7CiAgICB3aGlsZSAodGhpcy5tYXRjaCkgewogICAg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lzLm1hdHRlID0gZGljdC5nZXQoIk1hdHRlIikgfHwgZmFsc2U7CiAgICBsZXQgYml0c1BlckNvbXBvbmVudCA9IGltYWdlLmJpdHNQZXJDb21wb25lbnQ7CiAgICBpZiAoIWJpdHNQZXJDb21wb25lbnQpIHsKICAgICAgYml0c1BlckNvbXBvbmVudCA9IGRpY3QuZ2V0KCJCUEMiLCAiQml0c1BlckNvbXBvbmVudCIpOwogICAgICBpZiAoIWJpdHNQZXJDb21wb25lbnQpIHsKICAgICAgICBpZiAodGhpcy5pbWFnZU1hc2spIHsKICAgICAgICAgIGJpdHNQZXJDb21wb25lbnQgPSAxOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoYEJpdHMgcGVyIGNvbXBvbmVudCBtaXNzaW5nIGluIGltYWdlOiAke3RoaXMuaW1hZ2VNYXNrfWApOwogICAgICAgIH0KICAgICAgfQogICAgfQogICAgdGhpcy5icGMgPSBiaXRzUGVyQ29tcG9uZW50OwogICAgaWYgKCF0aGlzLmltYWdlTWFzaykgewogICAgICBsZXQgY29sb3JTcGFjZSA9IGRpY3QuZ2V0UmF3KCJDUyIpIHx8IGRpY3QuZ2V0UmF3KCJDb2xvclNwYWNlIik7CiAgICAgIGlmICghY29sb3JTcGFjZSkgewogICAgICAgICgwLCBfdXRpbC5pbmZvKSgiSlBYIGltYWdlcyAod2hpY2ggZG8gbm90IHJlcXVpcmUgY29sb3Igc3BhY2VzKSIpOwogICAgICAgIHN3aXRjaCAoaW1hZ2UubnVtQ29tcHMpIHsKICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgY29sb3JTcGFjZSA9IF9wcmltaXRpdmVzLk5hbWUuZ2V0KCJEZXZpY2VHcmF5Iik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAzOgogICAgICAgICAgICBjb2xvclNwYWNlID0gX3ByaW1pdGl2ZXMuTmFtZS5nZXQoIkRldmljZVJHQiIpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2UgNDoKICAgICAgICAgICAgY29sb3JTcGFjZSA9IF9wcmltaXRpdmVzLk5hbWUuZ2V0KCJEZXZpY2VDTVlLIik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBKUFggaW1hZ2VzIHdpdGggJHtpbWFnZS5udW1Db21wc30gY29sb3IgY29tcG9uZW50cyBub3Qgc3VwcG9ydGVkLmApOwogICAgICAgIH0KICAgICAgfQogICAgICB0aGlzLmNvbG9yU3BhY2UgPSBfY29sb3JzcGFjZS5Db2xvclNwYWNlLnBhcnNlKHsKICAgICAgICBjczogY29sb3JTcGFjZSwKICAgICAgICB4cmVmLAogICAgICAgIHJlc291cmNlczogaXNJbmxpbmUgPyByZXMgOiBudWxsLAogICAgICAgIHBkZkZ1bmN0aW9uRmFjdG9yeSwKICAgICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgICB9KTsKICAgICAgdGhpcy5udW1Db21wcyA9IHRoaXMuY29sb3JTcGFjZS5udW1Db21wczsKICAgIH0KICAgIHRoaXMuZGVjb2RlID0gZGljdC5nZXRBcnJheSgiRCIsICJEZWNvZGUiKTsKICAgIHRoaXMubmVlZHNEZWNvZGUgPSBmYWxzZTsKICAgIGlmICh0aGlzLmRlY29kZSAmJiAodGhpcy5jb2xvclNwYWNlICYmICF0aGlzLmNvbG9yU3BhY2UuaXNEZWZhdWx0RGVjb2RlKHRoaXMuZGVjb2RlLCBiaXRzUGVyQ29tcG9uZW50KSB8fCBpc01hc2sgJiYgIV9jb2xvcnNwYWNlLkNvbG9yU3BhY2UuaXNEZWZhdWx0RGVjb2RlKHRoaXMuZGVjb2RlLCAxKSkpIHsKICAgICAgdGhpcy5uZWVkc0RlY29kZSA9IHRydWU7CiAgICAgIGNvbnN0IG1heCA9ICgxIDw8IGJpdHNQZXJDb21wb25lbnQpIC0g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ICgwLCBfdXRpbC53YXJuKSgiSWdub3JpbmcgL01hc2sgaW4gaW1hZ2Ugd2l0aG91dCAvSW1hZ2VNYXNrLiIpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICB0aGlzLm1hc2sgPSBuZXcgUERGSW1hZ2UoewogICAgICAgICAgICB4cmVmLAogICAgICAgICAgICByZXMsCiAgICAgICAgICAgIGltYWdlOiBtYXNrLAogICAgICAgICAgICBpc0lubGluZSwKICAgICAgICAgICAgaXNNYXNrOiB0cnVlLAogICAgICAgICAgICBwZGZGdW5jdGlvbkZhY3RvcnksCiAgICAgICAgICAgIGxvY2FsQ29sb3JTcGFjZUNhY2hlCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgdGhpcy5tYXNrID0gbWFzazsKICAgICAgfQogICAgfQogIH0KICBzdGF0aWMgYXN5bmMgYnVpbGRJbWFnZShfcmVmMikgewogICAgbGV0IHsKICAgICAgeHJlZiwKICAgICAgcmVzLAogICAgICBpbWFnZSwKICAgICAgaXNJbmxpbmUgPSBmYWxzZSwKICAgICAgcGRmRnVuY3Rpb25GYWN0b3J5LAogICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgfSA9IF9yZWYyOwogICAgY29uc3QgaW1hZ2VEYXRhID0gaW1hZ2U7CiAgICBsZXQgc21hc2tEYXRhID0gbnVsbDsKICAgIGxldCBtYXNrRGF0YSA9IG51bGw7CiAgICBjb25zdCBzbWFzayA9IGltYWdlLmRpY3QuZ2V0KCJTTWFzayIpOwogICAgY29uc3QgbWFzayA9IGltYWdlLmRpY3QuZ2V0KCJNYXNrIik7CiAgICBpZiAoc21hc2spIHsKICAgICAgaWYgKHNtYXNrIGluc3RhbmNlb2YgX2Jhc2Vfc3RyZWFtLkJhc2VTdHJlYW0pIHsKICAgICAgICBzbWFza0RhdGEgPSBzbWFzazsKICAgICAgfSBlbHNlIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoIlVuc3VwcG9ydGVkIC9TTWFzayBmb3JtYXQuIik7CiAgICAgIH0KICAgIH0gZWxzZSBpZiAobWFzaykgewogICAgICBpZiAobWFzayBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtIHx8IEFycmF5LmlzQXJyYXkobWFzaykpIHsKICAgICAgICBtYXNrRGF0YSA9IG1hc2s7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKCJVbnN1cHBvcnRlZCAvTWFzayBmb3JtYXQuIik7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBuZXcgUERGSW1hZ2UoewogICAgICB4cmVmLAogICAgICByZXMsCiAgICAgIGltYWdlOiBpbWFnZURhdGEsCiAgICAgIGlzSW5saW5lLAogICAgICBzbWFzazogc21hc2tEYXRhLAogICAgICBtYXNrOiBtYXNrRGF0YSwKICAgICAgcGRmRnVuY3Rpb25GYWN0b3J5LAogICAgICBsb2NhbENvbG9yU3BhY2VDYWNoZQogICAgfSk7CiAgfQogIHN0YXRpYyBjcmVhdGVSYXdNYXNrKF9yZWYzKSB7CiAgICBsZXQgewogICAgICBpbWdBcnJheSwKICAgICAgd2lkdGgsCiAgICAgIGhlaWdodCwKICAgICAgaW1hZ2VJc0Zyb21EZWNvZGVTdHJlYW0sCiAgICAgIGludmVyc2VEZWNvZGUsCiAgICAgIGludGVycG9sYXRlCiAgICB9ID0gX3JlZjM7CiAgICBjb25zdCBjb21wdXRlZExlbmd0aCA9ICh3aWR0aCArIDcgPj4gMykgKiBoZWlnaHQ7CiAgICBjb25zdCBhY3R1YWxMZW5ndGggPSBpbWdBcnJheS5ieXRlTGVuZ3RoOwogICAgY29uc3QgaGF2ZUZ1bGxEYXRhID0gY29tcHV0ZWRMZW5ndGggPT09IGFjdHVhbExlbmd0aDsKICAgIGxldCBkYXRhLCBpOwogICAgaWYgKGltYWdlSXNGcm9tRGVjb2RlU3RyZWFtICYmICghaW52ZXJzZURlY29kZSB8fCBoYXZlRnVs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XRhLmRhdGEsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0LAogICAgICAgIG5vbkJsYWNrQ29sb3I6IDAsCiAgICAgICAgaW52ZXJzZURlY29kZQogICAgICB9KTsKICAgICAgY3R4LnB1dEltYWdlRGF0YShpbWdEYXRhLCAwLCAwKTsKICAgICAgY29uc3QgYml0bWFwID0gY2FudmFzLnRyYW5zZmVyVG9JbWFnZUJpdG1hcCgpOwogICAgICByZXR1cm4gewogICAgICAgIGRhdGE6IG51bGwsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0LAogICAgICAgIGludGVycG9sYXRlLAogICAgICAgIGJpdG1hcAogICAgICB9OwogICAgfQogICAgcmV0dXJuIHRoaXMuY3JlYXRlUmF3TWFzayh7CiAgICAgIGltZ0FycmF5LAogICAgICB3aWR0aCwKICAgICAgaGVpZ2h0LAogICAgICBpbnZlcnNlRGVjb2RlLAogICAgICBpbWFnZUlzRnJvbURlY29kZVN0cmVhbSwKICAgICAgaW50ZXJwb2xhdGUKICAgIH0pOwogIH0KICBnZXQgZHJhd1dpZHRoKCkgewogICAgcmV0dXJuIE1hdGgubWF4KHRoaXMud2lkdGgsIHRoaXMuc21hc2sgJiYgdGhpcy5zbWFzay53aWR0aCB8fCAwLCB0aGlzLm1hc2sgJiYgdGhpcy5tYXNrLndpZHRoIHx8IDApOwogIH0KICBnZXQgZHJhd0hlaWdodCgpIHsKICAgIHJldHVybiBNYXRoLm1heCh0aGlzLmhlaWdodCwgdGhpcy5zbWFzayAmJiB0aGlzLnNtYXNrLmhlaWdodCB8fCAwLCB0aGlzLm1hc2sgJiYgdGhpcy5tYXNrLmhlaWdodCB8fCAwKTsKICB9CiAgZGVjb2RlQnVmZmVyKGJ1ZmZlcikgewogICAgY29uc3QgYnBjID0gdGhpcy5icGM7CiAgICBjb25zdCBudW1Db21wcyA9IHRoaXMubnVtQ29tcHM7CiAgICBjb25zdCBkZWNvZGVBZGRlbmRzID0gdGhpcy5kZWNvZGVBZGRlbmRzOwogICAgY29uc3QgZGVjb2RlQ29lZmZpY2llbnRzID0gdGhpcy5kZWNvZGVDb2VmZmljaWVudHM7CiAgICBjb25zdCBtYXggPSAoMSA8PCBicGMpIC0gMTsKICAgIGxldCBpLCBpaTsKICAgIGlmIChicGMgPT09IDEpIHsKICAgICAgZm9yIChpID0gMCwgaWkgPSBidWZmZXIubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgIGJ1ZmZlcltpXSA9ICshYnVmZmVyW2ldOwogICAgICB9CiAgICAgIHJldHVybjsKICAgIH0KICAgIGxldCBpbmRleCA9IDA7CiAgICBmb3IgKGkgPSAwLCBpaSA9IHRoaXMud2lkdGggKiB0aGlzLmhlaWdodDsgaSA8IGlpOyBpKyspIHsKICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBudW1Db21wczsgaisrKSB7CiAgICAgICAgYnVmZmVyW2luZGV4XSA9IGRlY29kZUFuZENsYW1wKGJ1ZmZlcltpbmRleF0sIGRlY29kZUFkZGVuZHNbal0sIGRlY29kZUNvZWZmaWNpZW50c1tqXSwgbWF4KTsKICAgICAgICBpbmRleCsrOwogICAgICB9CiAgICB9CiAgfQogIGdldENvbXBvbmVudHMoYnVmZmVyKSB7CiAgICBjb25zdCBicGMgPSB0aGlzLmJwYzsKICAgIGlmIChicGMgPT09IDgpIHsKICAgICAgcmV0dXJuIGJ1ZmZlcjsKICAgIH0KICAgIGNvbnN0IHdpZHRoID0gdGhpcy53aWR0aDsKICAgIGNvbnN0IGhlaWdodCA9IHRoaXMuaGVpZ2h0OwogICAgY29uc3QgbnVtQ29tcHMgPSB0aGlzLm51bUNvbXBzOwogICAgY29uc3QgbGVuZ3RoID0gd2lkdGggKiBoZWlnaHQgKiBudW1Db21wczsKICAgIGxldCBidWZmZXJQb3MgPSAwOwogICAgbGV0IG91dHB1dDsKICAgIGlmIChicGMgPD0gOCkgewogICAgICBvdXRwdXQgPSBuZXcgVWludDhBcnJheShsZW5ndGgpOwogICAgfSBlbHNlIGlmIChicGMgPD0gMTYpIHsKICAgICAgb3V0cHV0ID0gbmV3IFVpbnQxNkFycmF5KGxlbmd0aCk7CiAgICB9IGVsc2UgewogICAgICBvdXRwdXQgPSBuZXcgVWludDMyQXJyYXkobGVuZ3RoKTsKICAgIH0KICAgIGNvbnN0IHJvd0NvbXBzID0gd2lkdGggKiBudW1Db21wczsKICAgIGNvbnN0IG1heCA9ICgxIDw8IGJwYykgLSAxOwogICAgbGV0IGkgPSAwLAogICAgICBpaSwKICAgICAgYnVmOwogICAgaWYgKGJwYyA9PT0gMSkgewogICAgICBsZXQgbWFzaywgbG9vcDFFbmQsIGxvb3AyRW5kOwogICAgICBmb3IgKGxldCBqID0gMDsgaiA8IGhlaWdodDsgaisrKSB7CiAgICAgICAgbG9vcDFFbmQgPSBpICsgKHJvd0NvbXBzICYgfjcpOwogICAgICAgIGxvb3AyRW5kID0gaSArIHJvd0NvbXBzOwogICAgICAgIHdoaWxlIChpIDwgbG9vcDFFbmQpIHsKICAgICAgICAgIGJ1ZiA9IGJ1ZmZlcltidWZmZXJQb3MrK107CiAgICAgICAgICBvdXRwdXRbaV0gPSBidWYgPj4gNyAmIDE7CiAgICAgICAgICBvdXRwdXRbaSArIDFdID0gYnVmID4+IDYgJiAxOwogICAgICAgICAgb3V0cHV0W2kgKyAyXSA9IGJ1ZiA+PiA1ICYgMTsKICAgICAgICAgIG91dHB1dFtpICsgM10gPSBidWYgPj4gNCAmIDE7CiAgICAgICAgICBvdXRwdXRbaSArIDRdID0gYnVmID4+IDMgJiAxOwogICAgICAgICAgb3V0cHV0W2kgKyA1XSA9IGJ1ZiA+PiAyICYgMTsKICAgICAgICAgIG91dHB1dFtpICsgNl0gPSBidWYgPj4gMSAmIDE7CiAgICAgICAgICBvdXRwdXRbaSArIDddID0gYnVmICYgMTsKICAgICAgICAgIGkgKz0gODsKICAgICAgICB9CiAgICAgICAgaWYgKGkgPCBsb29wMkVuZCkgewogICAgICAgICAgYnVmID0gYnVmZmVyW2J1ZmZlclBvcysrXTsKICAgICAgICAgIG1hc2sgPSAxMjg7CiAgICAgICAgICB3aGlsZSAoaSA8IGxvb3AyRW5kKSB7CiAgICAgICAgICAgIG91dHB1dFtpKytdID0gKyEhKGJ1ZiAmIG1hc2spOwogICAgICAgICAgICBtYXNrID4+PSAxOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgbGV0IGJpdHMgPSAwOwogICAgICBidWYgPSAwOwogICAgICBmb3IgKGkgPSAwLCBpaSA9IGxlbmd0aDsgaSA8IGlpOyArK2kpIHsKICAgICAgICBpZiAoaSAlIHJvd0NvbXBzID09PSAwKSB7CiAgICAgICAgICBidWYgPSAwOwogICAgICAgICAgYml0cyA9IDA7CiAgICAgICAgfQogICAgICAgIHdoaWxlIChiaXRzIDwgYnBjKSB7CiAgICAgICAgICBidWYgPSBidWYgPDwgOCB8IGJ1ZmZlcltidWZmZXJQb3MrK107CiAgICAgICAgICBiaXRzICs9IDg7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHJlbWFpbmluZ0JpdHMgPSBiaXRzIC0gYnBjOwogICAgICAgIGxldCB2YWx1ZSA9IGJ1ZiA+PiByZW1haW5pbmdCaXRzOwogICAgICAgIGlmICh2YWx1ZSA8IDApIHsKICAgICAgICAgIHZhbHVlID0gMDsKICAgICAgICB9IGVsc2UgaWYgKHZhbHVlID4gbWF4KSB7CiAgICAgICAgICB2YWx1ZSA9IG1heDsKICAgICAgICB9CiAgICAgICAgb3V0cHV0W2ldID0gdmFsdWU7CiAgICAgICAgYnVmICY9ICgxIDw8IHJlbWFpbmluZ0JpdHMpIC0gMTsKICAgICAgICBiaXRzID0gcmVtYWluaW5nQml0czsKICAgICAgfQogICAgfQogICAgcmV0dXJuIG91dHB1dDsKICB9CiAgZmlsbE9wYWNpdHkocmdiYUJ1Ziwgd2lkdGgsIGhlaWdodCwgYWN0dWFsSGVpZ2h0LCBpbWFnZSkgewogICAgY29u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gICB9CiAgICAgIH0gZWxzZSBpZiAoQXJyYXkuaXNBcnJheShtYXNrKSkgewogICAgICAgIGFscGhhQnVmID0gbmV3IFVpbnQ4Q2xhbXBlZEFycmF5KHdpZHRoICogaGVpZ2h0KTsKICAgICAgICBjb25zdCBudW1Db21wcyA9IHRoaXMubnVtQ29tcHM7CiAgICAgICAgZm9yIChpID0gMCwgaWkgPSB3aWR0aCAqIGhlaWdodDsgaSA8IGlpOyArK2kpIHsKICAgICAgICAgIGxldCBvcGFjaXR5ID0gMDsKICAgICAgICAgIGNvbnN0IGltYWdlT2Zmc2V0ID0gaSAqIG51bUNvbXBzOwogICAgICAgICAgZm9yIChqID0gMDsgaiA8IG51bUNvbXBzOyArK2opIHsKICAgICAgICAgICAgY29uc3QgY29sb3IgPSBpbWFnZVtpbWFnZU9mZnNldCArIGpdOwogICAgICAgICAgICBjb25zdCBtYXNrT2Zmc2V0ID0gaiAqIDI7CiAgICAgICAgICAgIGlmIChjb2xvciA8IG1hc2tbbWFza09mZnNldF0gfHwgY29sb3IgPiBtYXNrW21hc2tPZmZzZXQgKyAxXSkgewogICAgICAgICAgICAgIG9wYWNpdHkgPSAyNTU7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGFscGhhQnVmW2ldID0gb3BhY2l0eTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJVbmtub3duIG1hc2sgZm9ybWF0LiIpOwogICAgICB9CiAgICB9CiAgICBpZiAoYWxwaGFCdWYpIHsKICAgICAgZm9yIChpID0gMCwgaiA9IDMsIGlpID0gd2lkdGggKiBhY3R1YWxIZWlnaHQ7IGkgPCBpaTsgKytpLCBqICs9IDQpIHsKICAgICAgICByZ2JhQnVmW2pdID0gYWxwaGFCdWZbaV07CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGZvciAoaSA9IDAsIG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WZvcmNlUkdCQSkgewogICAgICBsZXQga2luZDsKICAgICAgaWYgKHRoaXMuY29sb3JTcGFjZS5uYW1lID09PSAiRGV2aWNlR3JheSIgJiYgYnBjID09PSAxKSB7CiAgICAgICAga2luZCA9IF91dGlsLkltYWdlS2luZC5HUkFZU0NBTEVfMUJQUDsKICAgICAgfSBlbHNlIGlmICh0aGlzLmNvbG9yU3BhY2UubmFtZSA9PT0gIkRldmljZVJHQiIgJiYgYnBjID09PSA4ICYmICF0aGlzLm5lZWRzRGVjb2RlKSB7CiAgICAgICAga2luZCA9IF91dGlsLkltYWdlS2luZC5SR0JfMjRCUFA7CiAgICAgIH0KICAgICAgaWYgKGtpbmQgJiYgIXRoaXMuc21hc2sgJiYgIXRoaXMubWFzayAmJiBkcmF3V2lkdGggPT09IG9yaWdpbmFsV2lkdGggJiYgZHJhd0hlaWdodCA9PT0gb3JpZ2luYWxIZWlnaHQpIHsKICAgICAgICBjb25zdCBkYXRhID0gdGhpcy5nZXRJbWFnZUJ5dGVzKG9yaWdpbmFsSGVpZ2h0ICogcm93Qnl0ZXMsIHt9KTsKICAgICAgICBpZiAoaXNPZmZzY3JlZW5DYW52YXNTdXBwb3J0ZWQpIHsKICAgICAgICAgIGlmIChtdXN0QmVSZXNpemVkKSB7CiAgICAgICAgICAgIHJldHVybiBfaW1hZ2VfcmVzaXplci5JbWFnZVJlc2l6ZXIuY3JlYXRlSW1hZ2UoewogICAgICAgICAgICAgIGRhdGEsCiAgICAgICAgICAgICAga2luZCwKICAgICAgICAgICAgICB3aWR0aDogZHJhd1dpZHRoLAogICAgICAgICAgICAgIGhlaWdodDogZHJhd0hlaWdodCwKICAgICAgICAgICAgICBpbnRlcnBvbGF0ZTogdGhpcy5pbnRlcnBvbGF0ZQogICAgICAgICAgICB9LCB0aGlzLm5lZWRzRGVjb2RlKTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiB0aGlzLmNyZWF0ZUJpdG1hcChraW5kLCBvcmlnaW5hbFdpZHR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ICAgICAgICBjYXNlICJEZXZpY2VSR0IiOgogICAgICAgICAgICAgIGltYWdlTGVuZ3RoID0gaW1hZ2VMZW5ndGggLyAzICogNDsKICAgICAgICAgICAgICBpc0hhbmRsZWQgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlICJEZXZpY2VDTVlLIjoKICAgICAgICAgICAgICBpc0hhbmRsZWQgPSB0cnVlOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGlzSGFuZGxlZCkgewogICAgICAgICAgICBjb25zdCByZ2JhID0gdGhpcy5nZXRJbWFnZUJ5dGVzKGltYWdlTGVuZ3RoLCB7CiAgICAgICAgICAgICAgZHJhd1dpZHRoLAogICAgICAgICAgICAgIGRyYXdIZWlnaHQsCiAgICAgICAgICAgICAgZm9yY2VSR0JBOiB0cnVlCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICByZXR1cm4gdGhpcy5jcmVhdGVCaXRtYXAoX3V0aWwuSW1hZ2VLaW5kLlJHQkFfMzJCUFAsIGRyYXdXaWR0aCwgZHJhd0hlaWdodCwgcmdiYSk7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHN3aXRjaCAodGhpcy5jb2xvclNwYWNlLm5hbWUpIHsKICAgICAgICAgICAgY2FzZSAiRGV2aWNlR3JheSI6CiAgICAgICAgICAgICAgaW1hZ2VMZW5ndGggKj0gMzsKICAgICAgICAgICAgY2FzZSAiRGV2aWNlUkdCIjoKICAgICAgICAgICAgY2FzZSAiRGV2aWNlQ01ZSyI6CiAgICAgICAgICAgICAgaW1nRGF0YS5raW5kID0gX3V0aWwuSW1hZ2VLaW5kLlJHQl8yNEJQUDsKICAgICAgICAgICAgICBpbWdEYXRhLmRhdGEgPSB0aGlzLmdldEltYWdlQnl0ZXMoaW1hZ2VMZW5ndGgsIHsKICAgICAgICAgICAgICAgIGRyYXdXaWR0aCwKICAgICAgICAgICAgICAgI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WJzdHJpbmcoMSksIDEwKSk7CiAgICAgIH0KICAgICAgc3dpdGNoIChlbnRpdHkpIHsKICAgICAgICBjYXNlICJsdCI6CiAgICAgICAgICByZXR1cm4gIjwiOwogICAgICAgIGNhc2UgImd0IjoKICAgICAgICAgIHJldHVybiAiPiI7CiAgICAgICAgY2FzZSAiYW1wIjoKICAgICAgICAgIHJldHVybiAiJiI7CiAgICAgICAgY2FzZSAicXVvdCI6CiAgICAgICAgICByZXR1cm4gJyInOwogICAgICAgIGNhc2UgImFwb3MiOgogICAgICAgICAgcmV0dXJuICInIjsKICAgICAgfQogICAgICByZXR1cm4gdGhpcy5vblJlc29sdmVFbnRpdHkoZW50aXR5KTsKICAgIH0pOwogIH0KICBfcGFyc2VDb250ZW50KHMsIHN0YXJ0KSB7CiAgICBjb25zdCBhdHRyaWJ1dGVzID0gW107CiAgICBsZXQgcG9zID0gc3RhcnQ7CiAgICBmdW5jdGlvbiBza2lwV3MoKSB7CiAgICAgIHdoaWxlIChwb3MgPCBzLmxlbmd0aCAmJiBpc1doaXRlc3BhY2UocywgcG9zKSkgewogICAgICAgICsrcG9zOwogICAgICB9CiAgICB9CiAgICB3aGlsZSAocG9zIDwgcy5sZW5ndGggJiYgIWlzV2hpdGVzcGFjZShzLCBwb3MpICYmIHNbcG9zXSAhPT0gIj4iICYmIHNbcG9zXSAhPT0gIi8iKSB7CiAgICAgICsrcG9zOwogICAgfQogICAgY29uc3QgbmFtZSA9IHMuc3Vic3RyaW5nKHN0YXJ0LCBwb3MpOwogICAgc2tpcFdzKCk7CiAgICB3aGlsZSAocG9zIDwgcy5sZW5ndGggJiYgc1twb3NdICE9PSAiPiIgJiYgc1twb3NdICE9PSAiLyIgJiYgc1twb3NdICE9PSAiPyIpIHsKICAgICAgc2tpcFdzKCk7CiAgICAgIGxldCBhdHRyTmFtZSA9ICIiLAogICAgICAgIGF0dHJWYWx1ZSA9ICIiOwogICAgICB3aGlsZSAocG9zIDwgcy5sZW5ndGggJiYgIWlzV2hpdGVzcGFjZShzLCBwb3MpICYmIHNbcG9zXSAhPT0gIj0iKSB7CiAgICAgICAgYXR0ck5hbWUgKz0gc1twb3NdOwogICAgICAgICsrcG9zOwogICAgICB9CiAgICAgIHNraXBXcygpOwogICAgICBpZiAoc1twb3NdICE9PSAiPSIpIHsKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgICArK3BvczsKICAgICAgc2tpcFdzKCk7CiAgICAgIGNvbnN0IGF0dHJFbmRDaGFyID0gc1twb3NdOwogICAgICBpZiAoYXR0ckVuZENoYXIgIT09ICciJyAmJiBhdHRyRW5kQ2hhciAhPT0gIiciKSB7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0KICAgICAgY29uc3QgYXR0ckVuZEluZGV4ID0gcy5pbmRleE9mKGF0dHJFbmRDaGFyLCArK3Bvcyk7CiAgICAgIGlmIChhdHRyRW5kSW5kZXggPCAwKSB7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0KICAgICAgYXR0clZhbHVlID0gcy5zdWJzdHJpbmcocG9zLCBhdHRyRW5kSW5kZXgpOwogICAgICBhdHRyaWJ1dGVzLnB1c2goewogICAgICAgIG5hbWU6IGF0dHJOYW1lLAogICAgICAgIHZhbHVlOiB0aGlzLl9yZXNvbHZlRW50aXRpZXMoYXR0clZhbHVlKQogICAgICB9KTsKICAgICAgcG9zID0gYXR0ckVuZEluZGV4ICsgMTsKICAgICAgc2tpcFdzKCk7CiAgICB9CiAgICByZXR1cm4gewogICAgICBuYW1lLAogICAgICBhdHRyaWJ1dGVzLAogICAgICBwYXJzZWQ6IHBvcyAtIHN0YXJ0CiAgICB9OwogIH0KICBfcGFyc2VQcm9jZXNzaW5nSW5zdHJ1Y3Rpb24ocywgc3RhcnQpIHsKICAgIGxldCBwb3MgPSBzdGFydDsKICAgIGZ1bmN0aW9uIHNraXBXcygpIHsKICAgICAgd2hpbGUgKHBvcyA8IHMubGVuZ3RoICYmIGlzV2hpdGVzcGFjZShzLCBwb3MpKSB7CiAgICAgICAgKytwb3M7CiAgICAgIH0KICAgIH0KICAgIHdoaWxlIChwb3MgPCBzLmxlbmd0aCAmJiAhaXNXaGl0ZXNwYWNlKHMsIHBvcykgJiYgc1twb3NdICE9PSAiPiIgJiYgc1twb3NdICE9PSAiPyIgJiYgc1twb3NdICE9PSAiLyIpIHsKICAgICAgKytwb3M7CiAgICB9CiAgICBjb25zdCBuYW1lID0gcy5zdWJzdHJpbmcoc3RhcnQsIHBvcyk7CiAgICBza2lwV3MoKTsKICAgIGNvbnN0IGF0dHJTdGFydCA9IHBvczsKICAgIHdoaWxlIChwb3MgPCBzLmxlbmd0aCAmJiAoc1twb3NdICE9PSAiPyIgfHwgc1twb3MgKyAxXSAhPT0gIj4iKSkgewogICAgICArK3BvczsKICAgIH0KICAgIGNvbnN0IHZhbHVlID0gcy5zdWJzdHJpbmcoYXR0clN0YXJ0LCBwb3MpOwogICAgcmV0dXJuIHsKICAgICAgbmFtZSwKICAgICAgdmFsdWUsCiAgICAgIHBhcnNlZDogcG9zIC0gc3RhcnQKICAgIH07CiAgfQogIHBhcnNlWG1sKHMpIHsKICAgIGxldCBpID0gMDsKICAgIHdoaWxlIChpIDwgcy5sZW5ndGgpIHsKICAgICAgY29uc3QgY2ggPSBzW2ldOwogICAgICBsZXQgaiA9IGk7CiAgICAgIGlmIChjaCA9PT0gIjwiKSB7CiAgICAgICAgKytqOwogICAgICAgIGNvbnN0IGNoMiA9IHNbal07CiAgICAgICAgbGV0IHE7CiAgICAgICAgc3dpdGNoIChjaDIpIHsKICAgICAgICAgIGNhc2UgIi8iOgogICAgICAgICAgICArK2o7CiAgICAgICAgICAgIHEgPSBzLmluZGV4T2YoIj4iLCBqKTsKICAgICAgICAgICAgaWYgKHEgPCAwKSB7CiAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRFbGVtZW50KTsKICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgIH0KICAgICAgICAgICAgdGhpcy5vbkVuZEVsZW1lbnQocy5zdWJzdHJpbmcoaiwgcSkpOwogICAgICAgICAgICBqID0gcSArIDE7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAiPyI6CiAgICAgICAgICAgICsrajsKICAgICAgICAgICAgY29uc3QgcGkgPSB0aGlzLl9wYXJzZVByb2Nlc3NpbmdJbnN0cnVjdGlvbihzLCBqKTsKICAgICAgICAgICAgaWYgKHMuc3Vic3RyaW5nKGogKyBwaS5wYXJzZWQsIGogKyBwaS5wYXJzZWQgKyAyKSAhPT0gIj8+IikgewogICAgICAgICAgICAgIHRoaXMub25FcnJvcihYTUxQYXJzZXJFcnJvckNvZGUuVW50ZXJtaW5hdGVkWG1sRGVjbGFyYXRpb24pOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLm9uUGkocGkubmFtZSwgcGkudmFsdWUpOwogICAgICAgICAgICBqICs9IHBpLnBhcnNlZCArIDI7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAiISI6CiAgICAgICAgICAgIGlmIChzLnN1YnN0cmluZyhqICsgMSwgaiArIDMpID09PSAiLS0iKSB7CiAgICAgICAgICAgICAgcSA9IHMuaW5kZXhPZigiLS0+IiwgaiArIDMpOwogICAgICAgICAgICAgIGlmIChxIDwgMCkgewogICAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRDb21tZW50KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgdGhpcy5vbkNvbW1lbnQocy5zdWJzdHJpbmcoaiArIDMsIHEpKTsKICAgICAgICAgICAgICBqID0gcSArIDM7CiAgICAgICAgICAgIH0gZWxzZSBpZiAocy5zdWJzdHJpbmcoaiArIDEsIGogKyA4KSA9PT0gIltDREFUQVsiKSB7CiAgICAgICAgICAgICAgcSA9IHMuaW5kZXhPZigiXV0+IiwgaiArIDgpOwogICAgICAgICAgICAgIGlmIChxIDwgMCkgewogICAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRDZGF0KTsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgdGhpcy5vbkNkYXRhKHMuc3Vic3RyaW5nKGogKyA4LCBxKSk7CiAgICAgICAgICAgICAgaiA9IHEgKyAzOwogICAgICAgICAgICB9IGVsc2UgaWYgKHMuc3Vic3RyaW5nKGogKyAxLCBqICsgOCkgPT09ICJET0NUWVBFIikgewogICAgICAgICAgICAgIGNvbnN0IHEyID0gcy5pbmRleE9mKCJbIiwgaiArIDgpOwogICAgICAgICAgICAgIGxldCBjb21wbGV4RG9jdHlwZSA9IGZhbHNlOwogICAgICAgICAgICAgIHEgPSBzLmluZGV4T2YoIj4iLCBqICsgOCk7CiAgICAgICAgICAgICAgaWYgKHEgPCAwKSB7CiAgICAgICAgICAgICAgICB0aGlzLm9uRXJyb3IoWE1MUGFyc2VyRXJyb3JDb2RlLlVudGVybWluYXRlZERvY3R5cGVEZWNsYXJhdGlvbik7CiAgICAgICAgICAgICAgICByZXR1cm47CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGlmIChxMiA+IDAgJiYgcSA+IHEyKSB7CiAgICAgICAgICAgICAgICBxID0gcy5pbmRleE9mKCJdPiIsIGogKyA4KTsKICAgICAgICAgICAgICAgIGlmIChxIDwgMCkgewogICAgICAgICAgICAgICAgICB0aGlzLm9uRXJyb3IoWE1MUGFyc2VyRXJyb3JDb2RlLlVudGVybWluYXRlZERvY3R5cGVEZWNsYXJhdGlvbik7CiAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNvbXBsZXhEb2N0eXBlID0gdHJ1ZTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgY29uc3QgZG9jdHlwZUNvbnRlbnQgPSBzLnN1YnN0cmluZyhqICsgOCwgcSArIChjb21wbGV4RG9jdHlwZSA/IDEgOiAwKSk7CiAgICAgICAgICAgICAgdGhpcy5vbkRvY3R5cGUoZG9jdHlwZUNvbnRlbnQpOwogICAgICAgICAgICAgIGogPSBxICsgKGNvbXBsZXhEb2N0eXBlID8gMiA6IDEpOwogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRoaXMub25FcnJvcihYTUxQYXJzZXJFcnJvckNvZGUuTWFsZm9ybWVkRWxlbWVudCk7CiAgICAgICAgICAgICAgcmV0dXJuOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgY29uc3QgY29udGVudCA9IHRoaXMuX3BhcnNlQ29udGVudChzLCBqKTsKICAgICAgICAgICAgaWYgKGNvbnRlbnQgPT09IG51bGwpIHsKICAgICAgICAgICAgICB0aGlzLm9uRXJyb3IoWE1MUGFyc2VyRXJyb3JDb2RlLk1hbGZvcm1lZEVsZW1lbnQpOwogICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgICAgICBsZXQgaXNDbG9zZWQgPSBmYWxzZTsKICAgICAgICAgICAgaWYgKHMuc3Vic3RyaW5nKGogKyBjb250ZW50LnBhcnNlZCwgaiArIGNvbnRlbnQucGFyc2VkICsgMikgPT09ICIvPiIpIHsKICAgICAgICAgICAgICBpc0Nsb3NlZCA9IHRydWU7CiAgICAgICAgICAgIH0gZWxzZSBpZiAocy5zdWJzdHJpbmcoaiArIGNvbnRlbnQucGFyc2VkLCBqICsgY29udGVudC5wYXJzZWQgKyAxKSAhPT0gIj4iKSB7CiAgICAgICAgICAgICAgdGhpcy5vbkVycm9yKFhNTFBhcnNlckVycm9yQ29kZS5VbnRlcm1pbmF0ZWRFbGVtZW50KTsKICAgICAgICAgICAgICByZXR1c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b21wb25lbnQgPSBwYXRoc1twb3NdOwogICAgY29uc3Qgc3RhY2sgPSBbXTsKICAgIGxldCBub2RlID0gdGhpczsKICAgIHdoaWxlICh0cnVlKSB7CiAgICAgIGlmIChjb21wb25lbnQubmFtZSA9PT0gbm9kZS5ub2RlTmFtZSkgewogICAgICAgIGlmIChjb21wb25lbnQucG9zID09PSAwKSB7CiAgICAgICAgICBjb25zdCByZXMgPSBub2RlLnNlYXJjaE5vZGUocGF0aHMsIHBvcyArIDEpOwogICAgICAgICAgaWYgKHJlcyAhPT0gbnVsbCkgewogICAgICAgICAgICByZXR1cm4gcmVzOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY29uc3QgW3BhcmVudF0gPSBzdGFjay5wb3AoKTsKICAgICAgICAgIGxldCBzaWJsaW5nUG9zID0gMDsKICAgICAgICAgIGZvciAoY29uc3QgY2hpbGQgb2YgcGFyZW50LmNoaWxkTm9kZXMpIHsKICAgICAgICAgICAgaWYgKGNvbXBvbmVudC5uYW1lID09PSBjaGlsZC5ub2RlTmFtZSkgewogICAgICAgICAgICAgIGlmIChzaWJsaW5nUG9zID09PSBjb21wb25lbnQucG9zKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gY2hpbGQuc2VhcmNoTm9kZShwYXRocywgcG9zICsgMSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHNpYmxpbmdQb3MrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG5vZGUuc2VhcmNoTm9kZShwYXRocywgcG9zICsgMSk7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChub2RlLmNoaWxkTm9kZXMgJiYgbm9kZS5jaGlsZE5vZGVzLmxlbmd0aCAhPT0gMCkgewogICAgICAgIHN0YWNrLnB1c2goW25vZGUsIDBdKTsKICAgICAgICBub2RlID0gbm9kZS5jaGlsZE5vZGVzWzBdOwogICAgICB9IGVsc2UgaWYgKHN0YWNrLmxlbmd0aCA9PT0gMCkgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9IGVsc2UgewogICAgICAgIHdoaWxlIChzdGFjay5sZW5ndGggIT09IDApIHsKICAgICAgICAgIGNvbnN0IFtwYXJlbnQsIGN1cnJlbnRQb3NdID0gc3RhY2sucG9wKCk7CiAgICAgICAgICBjb25zdCBuZXdQb3MgPSBjdXJyZW50UG9zICsgMTsKICAgICAgICAgIGlmIChuZXdQb3MgPCBwYXJlbnQuY2hpbGROb2Rlcy5sZW5ndGgpIHsKICAgICAgICAgICAgc3RhY2sucHVzaChbcGFyZW50LCBuZXdQb3NdKTsKICAgICAgICAgICAgbm9kZSA9IHBhcmVudC5jaGlsZE5vZGVzW25ld1Bvc107CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoc3RhY2subGVuZ3RoID09PSAwKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICB9CiAgZHVtcChidWZmZXIpIHsKICAgIGlmICh0aGlzLm5vZGVOYW1lID09PSAiI3RleHQiKSB7CiAgICAgIGJ1ZmZlci5wdXNoKCgwLCBfY29yZV91dGlscy5lbmNvZGVUb1htbFN0cmluZykodGhpcy5ub2RlVmFsdWUpKTsKICAgICAgcmV0dXJuOwogICAgfQogICAgYnVmZmVyLnB1c2goYDwke3RoaXMubm9kZU5hbWV9YCk7CiAgICBpZiAodGhpcy5hdHRyaWJ1dGVzKSB7CiAgICAgIGZvciAoY29uc3QgYXR0cmlidXRlIG9mIHRoaXMuYXR0cmlidXRlcykgewogICAgICAgIGJ1ZmZlci5wdXNoKGAgJHthdHRyaWJ1dGUubmFtZX09IiR7KDAsIF9jb3JlX3V0aWxzLmVuY29kZVRvWG1sU3RyaW5nKShhdHRyaWJ1dGUudmFsdWUpf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HBhZGRlZFtpXSB8IHBhZGRlZFtpICsgMV0gPDwgOCB8IHBhZGRlZFtpICsgMl0gPDwgMTYgfCBwYWRkZWRbaSArIDNdIDw8IDI0OwogICAgICB9CiAgICAgIGxldCBhID0gaDAsCiAgICAgICAgYiA9IGgxLAogICAgICAgIGMgPSBoMiwKICAgICAgICBkID0gaDMsCiAgICAgICAgZiwKICAgICAgICBnOwogICAgICBmb3IgKGogPSAwOyBqIDwgNjQ7ICsraikgewogICAgICAgIGlmIChqIDwgMTYpIHsKICAgICAgICAgIGYgPSBiICYgYyB8IH5iICYgZDsKICAgICAgICAgIGcgPSBqOwogICAgICAgIH0gZWxzZSBpZiAoaiA8IDMyKSB7CiAgICAgICAgICBmID0gZCAmIGIgfCB+ZCAmIGM7CiAgICAgICAgICBnID0gNSAqIGogKyAxICYgMTU7CiAgICAgICAgfSBlbHNlIGlmIChqIDwgNDgpIHsKICAgICAgICAgIGYgPSBiIF4gYyBeIGQ7CiAgICAgICAgICBnID0gMyAqIGogKyA1ICYgMTU7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIGYgPSBjIF4gKGIgfCB+ZCk7CiAgICAgICAgICBnID0gNyAqIGogJiAxNTsKICAgICAgICB9CiAgICAgICAgY29uc3QgdG1wID0gZCwKICAgICAgICAgIHJvdGF0ZUFyZyA9IGEgKyBmICsga1tqXSArIHdbZ10gfCAwLAogICAgICAgICAgcm90YXRlID0gcltqXTsKICAgICAgICBkID0gYzsKICAgICAgICBjID0gYjsKICAgICAgICBiID0gYiArIChyb3RhdGVBcmcgPDwgcm90YXRlIHwgcm90YXRlQXJnID4+PiAzMiAtIHJvdGF0ZSkgfCAwOwogICAgICAgIGEgPSB0bXA7CiAgICAgIH0KICAgICAgaDAgPSBoMCArIGEgfCAwOwogICAgICBoMSA9IGgxICsgYiB8IDA7CiAgICAgIGgyID0gaDIgKyBjIHwgMDsKICAgICAgaDMgPSBoMyArIGQgfCAwOwogICAgfQogICAgcmV0dXJuIG5ldyBV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g1KTsKICAgICAgZy5hc3NpZ24oaDYpOwogICAgICBoLmFzc2lnbihoNyk7CiAgICAgIGZvciAoaiA9IDA7IGogPCA4MDsgKytqKSB7CiAgICAgICAgdDEuYXNzaWduKGgpOwogICAgICAgIHNpZ21hUHJpbWUodG1wMSwgZSwgdG1wMik7CiAgICAgICAgdDEuYWRkKHRtcDEpOwogICAgICAgIGNoKHRtcDEsIGUsIGYsIGcsIHRtcDIpOwogICAgICAgIHQxLmFkZCh0bXAxKTsKICAgICAgICB0MS5hZGQoa1tqXSk7CiAgICAgICAgdDEuYWRkKHdbal0pOwogICAgICAgIHNpZ21hKHQyLCBhLCB0bXAyKTsKICAgICAgICBtYWoodG1wMSwgYSwgYiwgYywgdG1wMik7CiAgICAgICAgdDIuYWRkKHRtcDEpOwogICAgICAgIHRtcDMgPSBoOwogICAgICAgIGggPSBnOwogICAgICAgIGcgPSBmOwogICAgICAgIGYgPSBlOwogICAgICAgIGQuYWRkKHQxKTsKICAgICAgICBlID0gZDsKICAgICAgICBkID0gYzsKICAgICAgICBjID0gYjsKICAgICAgICBiID0gYTsKICAgICAgICB0bXAzLmFzc2lnbih0MSk7CiAgICAgICAgdG1wMy5hZGQodDIpOwogICAgICAgIGEgPSB0bXAzOwogICAgICB9CiAgICAgIGgwLmFkZChhKTsKICAgICAgaDEuYWRkKGIpOwogICAgICBoMi5hZGQoYyk7CiAgICAgIGgzLmFkZChkKTsKICAgICAgaDQuYWRkKGUpOwogICAgICBoNS5hZGQoZik7CiAgICAgIGg2LmFkZChnKTsKICAgICAgaDcuYWRkKGgpOwogICAgfQogICAgbGV0IHJlc3VsdDsKICAgIGlmICghbW9kZTM4NCkgewogICAgICByZXN1bHQgPSBuZXcgVWludDhBcnJheSg2NCk7CiAgICAgIGgwLmNvcHlUbyhyZXN1bHQsIDApOwogICAgICBoMS5jb3B5VG8ocmVzdWx0LCA4KTsKICAgICAgaDIuY29weVRvKHJlc3VsdCwgMTYpOwogICAgICBoMy5jb3B5VG8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RkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkLCAweDAxLCAweDAyLCAweDA0LCAweDA4LCAweDEwLCAweDIwLCAweDQwLCAweDgwLCAweDFiLCAweDM2LCAweDZjLCAweGQ4LCAweGFiLCAweDRkLCAweDlhLCAweDJmLCAweDVlLCAweGJjLCAweDYzLCAweGM2LCAweDk3LCAweDM1LCAweDZhLCAweGQ0LCAweGIzLCAweDdkLCAweGZhLCAweGVmLCAweGM1LCAweDkxLCAweDM5LCAweDcyLCAweGU0LCAweGQzLCAweGJkLCAweDYxLCAweGMyLCAweDlmLCAweDI1LCAweDRhLCAweDk0LCAweDMzLCAweDY2LCAweGNjLCAweDgzLCAweDFkLCAweDNhLCAweDc0LCAweGU4LCAweGNiLCAweDhkXSk7CiAgICB0aGlzLl9rZXkgPSB0aGlzLl9leHBhbmRLZXkoa2V5KTsKICB9CiAgX2V4cGFuZEtleShjaXBoZXJLZXkpIHsKICAgIGNvbnN0IGIgPSAxNzY7CiAgICBjb25zdCBzID0gdGhpcy5fczsKICAgIGNvbnN0IHJjb24gPSB0aGlzLl9yY29uOwogICAgY29uc3QgcmVzdWx0ID0gbmV3IFVpbnQ4QXJyYXkoYik7CiAgICByZXN1bHQuc2V0KGNpcGhlcktleSk7CiAgICBmb3IgKGxldCBqID0gMTYsIGkgPSAxOyBqIDwgYjsgKytpKSB7CiAgICAgIGxldCB0MSA9IHJlc3VsdFtqIC0gM107CiAgICAgIGxldCB0MiA9IHJlc3VsdFtqIC0gMl07CiAgICAgIGxldCB0MyA9IHJlc3VsdFtqIC0gMV07CiAgICAgIGxldCB0NCA9IHJlc3VsdFtqIC0gNF07CiAgICAgIHQxID0gc1t0MV07CiAgICAgIHQyID0gc1t0Ml07CiAgICAgIHQzID0gc1t0M107CiAgICAgIHQ0ID0gc1t0NF07CiAgICAgIHQxIF49IHJjb25baV07CiAgICAgIGZvciAobGV0IG4gPSAwOyBuIDwgNDsgKytuKSB7CiAgICAgICAgcmVzdWx0W2pdID0gdDEgXj0gcmVzdWx0W2ogLSAxNl07CiAgICAgICAgaisrOwogICAgICAgIHJlc3VsdFtqXSA9IHQyIF49IHJlc3VsdFtqIC0gMTZdOwogICAgICAgIGorKzsKICAgICAgICByZXN1bHRbal0gPSB0MyBePSByZXN1bHRbaiAtIDE2XTsKICAgICAgICBqKys7CiAgICAgICAgcmVzdWx0W2pdID0gdDQgXj0gcmVzdWx0W2ogLSAxNl07CiAgICAgICAgaisrOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gcmVzdWx0OwogIH0KfQpleHBvcnRzLkFFUzEyOENpcGhlciA9IEFFUzEyOENpcGhlcjsKY2xhc3MgQUVTMjU2Q2lwaGVyIGV4dGVuZHMgQUVTQmFzZUNpcGhlciB7CiAgY29uc3RydWN0b3Ioa2V5KSB7CiAgICBzdXBlcigpOwogICAgdGhpcy5fY3ljbGVzT2ZSZXBldGl0aW9uID0gMTQ7CiAgICB0aGlzLl9rZXlTaXplID0gMjI0OwogICAgdGhpcy5fa2V5ID0gdGhpcy5fZXhwYW5kS2V5KGtleSk7CiAgfQogIF9leHBhbmRLZXkoY2lwaGVyS2V5KSB7CiAgICBjb25zdCBiID0gMjQwOwogICAgY29uc3QgcyA9IHRoaXMuX3M7CiAgICBjb25zdCByZXN1bHQgPSBuZXcgVWludDhBcnJheShiKTsKICAgIHJlc3VsdC5zZXQoY2lwaGVyS2V5KTsKICAgIGxldCByID0gMTsKICAgIGxldCB0MSwgdDIsIHQzLCB0NDsKICAgIGZvciAobGV0IGogPSAzMiwgaSA9IDE7IGogPCBiOyArK2kpIHsKICAgICAgaWYgKGogJSAzMiA9PT0gMTYpIHsKICAgICAgICB0MSA9IHNbdDFdOwogICAgICAgIHQyID0gc1t0Ml07CiAgICAgICAgdDMgPSBzW3QzXTsKICAgICAgICB0NCA9IHNbdDRdOwogICAgICB9IGVsc2UgaWYgKGogJSAzMiA9PT0gMCkgewogICAgICAgIHQxID0gcmVzdWx0W2ogLSAzXTsKICAgICAgICB0MiA9IHJlc3VsdFtqIC0gMl07CiAgICAgICAgdDMgPSByZXN1bHRbaiAtIDFdOwogICAgICAgIHQ0ID0gcmVzdWx0W2ogLSA0XTsKICAgICAgICB0MSA9IHNbdDFdOwogICAgICAgIHQyID0gc1t0Ml07CiAgICAgICAgdDMgPSBzW3QzXTsKICAgICAgICB0NCA9IHNbdDRdOwogICAgICAgIHQxIF49IHI7CiAgICAgICAgaWYgKChyIDw8PSAxKSA+PSAyNTYpIHsKICAgICAgICAgIHIgPSAociBeIDB4MWIpICYgMHhmZjsKICAgICAgICB9CiAgICAgIH0KICAgICAgZm9yIChsZXQgbiA9IDA7IG4gPCA0OyArK24pIHsKICAgICAgICByZXN1bHRbal0gPSB0MSBePSByZXN1bHRbaiAtIDMyXTsKICAgICAgICBqKys7CiAgICAgICAgcmVzdWx0W2pdID0gdDIgXj0gcmVzdWx0W2ogLSAzMl07CiAgICAgICAgaisrOwogICAgICAgIHJlc3VsdFtqXSA9IHQzIF49IHJlc3VsdFtqIC0gMzJdOwogICAgICAgIGorKzsKICAgICAgICByZXN1bHRbal0gPSB0NCBePSByZXN1bHRbaiAtIDMyXTsKICAgICAgICBqKys7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiByZXN1bHQ7CiAgfQp9CmV4cG9ydHMuQUVTMjU2Q2lwaGVyID0gQUVTMjU2Q2lwaGVyOwpjbGFzcyBQREYxNyB7CiAgY2hlY2tPd25lclBhc3N3b3Jk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BpKSk7CiAgICAgIG4gPSBlbmNyeXB0aW9uS2V5Lmxlbmd0aDsKICAgICAgY29uc3QgZGVyaXZlZEtleSA9IG5ldyBVaW50OEFycmF5KG4pOwogICAgICBmb3IgKGogPSAxOyBqIDw9IDE5OyArK2opIHsKICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IG47ICsraykgewogICAgICAgICAgZGVyaXZlZEtleVtrXSA9IGVuY3J5cHRpb25LZXlba10gXiBqOwogICAgICAgIH0KICAgICAgICBjaXBoZXIgPSBuZXcgQVJDRm91ckNpcGhlcihkZXJpdmVkS2V5KTsKICAgICAgICBjaGVja0RhdGEgPSBjaXBoZXIuZW5jcnlwdEJsb2NrKGNoZWNrRGF0YSk7CiAgICAgIH0KICAgICAgZm9yIChqID0gMCwgbiA9IGNoZWNrRGF0YS5sZW5ndGg7IGogPCBuOyArK2opIHsKICAgICAgICBpZiAodXNlclBhc3N3b3JkW2pdICE9PSBjaGVja0RhdGFbal0pIHsKICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgIH0KICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgY2lwaGVyID0gbmV3IEFSQ0ZvdXJDaXBoZXIoZW5jcnlwdGlvbktleSk7CiAgICAgIGNoZWNrRGF0YSA9IGNpcGhlci5lbmNyeXB0QmxvY2soZGVmYXVsdFBhc3N3b3JkQnl0ZXMpOwogICAgICBmb3IgKGogPSAwLCBuID0gY2hlY2tEYXRhLmxlbmd0aDsgaiA8IG47ICsraikgewogICAgICAgIGlmICh1c2VyUGFzc3dvcmRbal0gIT09IGNoZWNrRGF0YVtqXSkgewogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICByZXR1cm4gZW5jcnlwdGlvbktleTsKICB9CiAgZnVuY3Rpb24gZGVjb2RlVXNlclBhc3N3b3JkKHBhc3N3b3JkLCBvd25lclBhc3N3b3JkLCByZXZpc2lvbiwga2V5TGVuZ3RoKSB7CiAgICBjb25zdCBo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TCIpKSB7CiAgICAgICAgICBjb25zdCBkYXRhID0gKDAsIF91dGlsLnN0cmluZ1RvVVRGOFN0cmluZykoc3RyZWFtLmdldFN0cmluZygpKTsKICAgICAgICAgIGlmIChkYXRhKSB7CiAgICAgICAgICAgIG1ldGFkYXRhID0gbmV3IF9tZXRhZGF0YV9wYXJzZXIuTWV0YWRhdGFQYXJzZXIoZGF0YSkuc2VyaWFsaXphYmxlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgfQogICAgfSBjYXRjaCAoZXgpIHsKICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuTWlzc2luZ0RhdGFFeGNlcHRpb24pIHsKICAgICAgICB0aHJvdyBleDsKICAgICAgfQogICAgICAoMCwgX3V0aWwuaW5mbykoYFNraXBwaW5nIGludmFsaWQgTWV0YWRhdGE6ICIke2V4fSIuYCk7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIm1ldGFkYXRhIiwgbWV0YWRhdGEpOwogIH0KICBnZXQgbWFya0luZm8oKSB7CiAgICBsZXQgbWFya0luZm8gPSBudWxsOwogICAgdHJ5IHsKICAgICAgbWFya0luZm8gPSB0aGlzLl9yZWFkTWFya0luZm8oKTsKICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgIGlmIChleCBpbnN0YW5jZW9mIF9jb3JlX3V0aWxzLk1pc3NpbmdEYXRhRXhjZXB0aW9uKSB7CiAgICAgICAgdGhyb3cgZXg7CiAgICAgIH0KICAgICAgKDAsIF91dGlsLndhcm4pKCJVbmFibGUgdG8gcmVhZCBtYXJrIGluZm8uIik7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgIm1hcmtJbmZvIiwgbWFya0luZm8pOwogIH0KICBfcmVhZE1hcmtJbmZvKCkgewogICAgY29uc3Qgb2JqID0gdGhpcy5fY2F0RGljdC5nZXQoIk1hcmtJbmZvIik7CiAgICBpZiAoIShvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KICAgIGNvbnN0IG1hcmtJbmZvID0gewogICAgICBNYXJrZWQ6IGZhbHNlLAogICAgICBVc2VyUHJvcGVydGllczogZmFsc2UsCiAgICAgIFN1c3BlY3RzOiBmYWxzZQogICAgfTsKICAgIGZvciAoY29uc3Qga2V5IGluIG1hcmtJbmZvKSB7CiAgICAgIGNvbnN0IHZhbHVlID0gb2JqLmdldChrZXkpOwogICAgICBpZiAodHlwZW9mIHZhbHVlID09PSAiYm9vbGVhbiIpIHsKICAgICAgICBtYXJrSW5mb1trZXldID0gdmFsdWU7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBtYXJrSW5mbzsKICB9CiAgZ2V0IHN0cnVjdFRyZWVSb290KCkgewogICAgbGV0IHN0cnVjdFRyZWUgPSBudWxsOwogICAgdHJ5IHsKICAgICAgc3RydWN0VHJlZSA9IHRoaXMuX3JlYWRTdHJ1Y3RUcmVlUm9vdCgpOwogICAgfSBjYXRjaCAoZXgpIHsKICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuTWlzc2luZ0RhdGFFeGNlcHRpb24pIHsKICAgICAgICB0aHJvdyBleDsKICAgICAgfQogICAgICAoMCwgX3V0aWwud2FybikoIlVuYWJsZSByZWFkIHRvIHN0cnVjdFRyZWVSb290IGluZm8uIik7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInN0cnVjdFRyZWVSb290Iiwgc3RydWN0VHJlZSk7CiAgfQogIF9yZWFkU3RydWN0VHJlZVJvb3QoKSB7CiAgICBjb25zdCBvYmogPSB0aGlzLl9jYXREaWN0LmdldCgiU3RydWN0VHJlZVJvb3QiKTsKICAgIGlmICghKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgY29uc3Q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ybiBudWxsOwogICAgfQogICAgb2JqID0gb2JqLmdldFJhdygiRmlyc3QiKTsKICAgIGlmICghKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikpIHsKICAgICAgcmV0dXJuIG51bGw7CiAgICB9CiAgICBjb25zdCByb290ID0gewogICAgICBpdGVtczogW10KICAgIH07CiAgICBjb25zdCBxdWV1ZSA9IFt7CiAgICAgIG9iaiwKICAgICAgcGFyZW50OiByb290CiAgICB9XTsKICAgIGNvbnN0IHByb2Nlc3NlZCA9IG5ldyBfcHJpbWl0aXZlcy5SZWZTZXQoKTsKICAgIHByb2Nlc3NlZC5wdXQob2JqKTsKICAgIGNvbnN0IHhyZWYgPSB0aGlzLnhyZWYsCiAgICAgIGJsYWNrQ29sb3IgPSBuZXcgVWludDhDbGFtcGVkQXJyYXkoMyk7CiAgICB3aGlsZSAocXVldWUubGVuZ3RoID4gMCkgewogICAgICBjb25zdCBpID0gcXVldWUuc2hpZnQoKTsKICAgICAgY29uc3Qgb3V0bGluZURpY3QgPSB4cmVmLmZldGNoSWZSZWYoaS5vYmopOwogICAgICBpZiAob3V0bGluZURpY3QgPT09IG51bGwpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoIW91dGxpbmVEaWN0LmhhcygiVGl0bGUiKSkgewogICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBvdXRsaW5lIGl0ZW0gZW5jb3VudGVyZWQuIik7CiAgICAgIH0KICAgICAgY29uc3QgZGF0YSA9IHsKICAgICAgICB1cmw6IG51bGwsCiAgICAgICAgZGVzdDogbnVsbCwKICAgICAgICBhY3Rpb246IG51bGwKICAgICAgfTsKICAgICAgQ2F0YWxvZy5wYXJzZURlc3REaWN0aW9uYXJ5KHsKICAgICAgICBkZXN0RGljdDogb3V0bGluZURpY3QsCiAgICAgICAgcmVzdWx0T2JqOiBkYXRhLAogICAgICAgIGRvY0Jhc2VVcmw6IHRoaXM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zSW50ZWdlcihjb3VudCkgPyBjb3VudCA6IHVuZGVmaW5lZCwKICAgICAgICBib2xkOiAhIShmbGFncyAmIDIpLAogICAgICAgIGl0YWxpYzogISEoZmxhZ3MgJiAxKSwKICAgICAgICBpdGVtczogW10KICAgICAgfTsKICAgICAgaS5wYXJlbnQuaXRlbXMucHVzaChvdXRsaW5lSXRlbSk7CiAgICAgIG9iaiA9IG91dGxpbmVEaWN0LmdldFJhdygiRmlyc3QiKTsKICAgICAgaWYgKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZiAmJiAhcHJvY2Vzc2VkLmhhcyhvYmopKSB7CiAgICAgICAgcXVldWUucHVzaCh7CiAgICAgICAgICBvYmosCiAgICAgICAgICBwYXJlbnQ6IG91dGxpbmVJdGVtCiAgICAgICAgfSk7CiAgICAgICAgcHJvY2Vzc2VkLnB1dChvYmopOwogICAgICB9CiAgICAgIG9iaiA9IG91dGxpbmVEaWN0LmdldFJhdygiTmV4dCIpOwogICAgICBpZiAob2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmICYmICFwcm9jZXNzZWQuaGFzKG9iaikpIHsKICAgICAgICBxdWV1ZS5wdXNoKHsKICAgICAgICAgIG9iaiwKICAgICAgICAgIHBhcmVudDogaS5wYXJlbnQKICAgICAgICB9KTsKICAgICAgICBwcm9jZXNzZWQucHV0KG9iaik7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiByb290Lml0ZW1zLmxlbmd0aCA+IDAgPyByb290Lml0ZW1zIDogbnVsbDsKICB9CiAgZ2V0IHBlcm1pc3Npb25zKCkgewogICAgbGV0IHBlcm1pc3Npb25zID0gbnVsbDsKICAgIHRyeSB7CiAgICAgIHBlcm1pc3Npb25zID0gdGhpcy5fcmVhZFBlcm1pc3Npb25zKCk7CiAgICB9IGNhdGNoIChleCkgewogICAgICBpZiAoZXggaW5zdGFuY2VvZiBfY29yZV91dGlscy5NaXNzaW5nRGF0YUV4Y2VwdGlvbikgewogIC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bnRlbnRDb25maWciLCBudWxsKTsKICAgICAgfQogICAgICBjb25zdCBkZWZhdWx0Q29uZmlnID0gcHJvcGVydGllcy5nZXQoIkQiKTsKICAgICAgaWYgKCFkZWZhdWx0Q29uZmlnKSB7CiAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBudWxsKTsKICAgICAgfQogICAgICBjb25zdCBncm91cHNEYXRhID0gcHJvcGVydGllcy5nZXQoIk9DR3MiKTsKICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGdyb3Vwc0RhdGEpKSB7CiAgICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBudWxsKTsKICAgICAgfQogICAgICBjb25zdCBncm91cHMgPSBbXTsKICAgICAgY29uc3QgZ3JvdXBSZWZzID0gW107CiAgICAgIGZvciAoY29uc3QgZ3JvdXBSZWYgb2YgZ3JvdXBzRGF0YSkgewogICAgICAgIGlmICghKGdyb3VwUmVmIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuUmVmKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGdyb3VwUmVmcy5wdXNoKGdyb3VwUmVmKTsKICAgICAgICBjb25zdCBncm91cCA9IHRoaXMueHJlZi5mZXRjaElmUmVmKGdyb3VwUmVmKTsKICAgICAgICBncm91cHMucHVzaCh7CiAgICAgICAgICBpZDogZ3JvdXBSZWYudG9TdHJpbmcoKSwKICAgICAgICAgIG5hbWU6IHR5cGVvZiBncm91cC5nZXQoIk5hbWUiKSA9PT0gInN0cmluZyIgPyAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKGdyb3VwLmdldCgiTmFtZSIpKSA6IG51bGwsCiAgICAgICAgICBpbnRlbnQ6IHR5cGVvZiBncm91cC5nZXQoIkludGVudCIpID09PSAic3RyaW5nIiA/ICgwLCBfdXRpbC5zdHJpbmdUb1BERlN0cmluZykoZ3JvdXAuZ2V0KCJJbnRlbnQiKSkgOiBudWxsCiAgICAgICAgfSk7CiAgICAgIH0KICAgICAgY29uZmlnID0gdGhpcy5fcmVhZE9wdGlvbmFsQ29udGVudENvbmZpZyhkZWZhdWx0Q29uZmlnLCBncm91cFJlZnMpOwogICAgICBjb25maWcuZ3JvdXBzID0gZ3JvdXBzOwogICAgfSBjYXRjaCAoZXgpIHsKICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuTWlzc2luZ0RhdGFFeGNlcHRpb24pIHsKICAgICAgICB0aHJvdyBleDsKICAgICAgfQogICAgICAoMCwgX3V0aWwud2FybikoYFVuYWJsZSB0byByZWFkIG9wdGlvbmFsIGNvbnRlbnQgY29uZmlnOiAke2V4fWApOwogICAgfQogICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJvcHRpb25hbENvbnRlbnRDb25maWciLCBjb25maWcpOwogIH0KICBfcmVhZE9wdGlvbmFsQ29udGVudENvbmZpZyhjb25maWcsIGNvbnRlbnRHcm91cFJlZnMpIHsKICAgIGZ1bmN0aW9uIHBhcnNlT25PZmYocmVmcykgewogICAgICBjb25zdCBvblBhcnNlZCA9IFtdOwogICAgICBpZiAoQXJyYXkuaXNBcnJheShyZWZzKSkgewogICAgICAgIGZvciAoY29uc3QgdmFsdWUgb2YgcmVmcykgewogICAgICAgICAgaWYgKCEodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGNvbnRlbnRHcm91cFJlZnMuaW5jbHVkZXModmFsdWUpKSB7CiAgICAgICAgICAgIG9uUGFyc2VkLnB1c2godmFsdWUudG9TdHJpbmcoKSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiBvblBhcnNlZDsKICAgIH0KICAgIGZ1bmN0aW9uIHBhcnNlT3JkZXIocmVmcykgewogICAgICBsZXQgbmVzdGVkTGV2ZWxzID0gYXJndW1lbnRzLmxlbmd0aCA+IDEgJiYgYXJndW1lbnRzWzFdICE9PSB1bmRlZmluZWQgPyBhcmd1bWVudHNbMV0gOiAwOwogICAgICBpZiAoIUFycmF5LmlzQXJyYXkocmVmcykpIHsKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgICBjb25zdCBvcmRlciA9IFtdOwogICAgICBmb3IgKGNvbnN0IHZhbHVlIG9mIHJlZnMpIHsKICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYgJiYgY29udGVudEdyb3VwUmVmcy5pbmNsdWRlcyh2YWx1ZSkpIHsKICAgICAgICAgIHBhcnNlZE9yZGVyUmVmcy5wdXQodmFsdWUpOwogICAgICAgICAgb3JkZXIucHVzaCh2YWx1ZS50b1N0cmluZygpKTsKICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBjb25zdCBuZXN0ZWRPcmRlciA9IHBhcnNlTmVzdGVkT3JkZXIodmFsdWUsIG5lc3RlZExldmVscyk7CiAgICAgICAgaWYgKG5lc3RlZE9yZGVyKSB7CiAgICAgICAgICBvcmRlci5wdXNoKG5lc3RlZE9yZGVyKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKG5lc3RlZExldmVscyA+IDApIHsKICAgICAgICByZXR1cm4gb3JkZXI7CiAgICAgIH0KICAgICAgY29uc3QgaGlkZGVuR3JvdXBzID0gW107CiAgICAgIGZvciAoY29uc3QgZ3JvdXBSZWYgb2YgY29udGVudEdyb3VwUmVmcykgewogICAgICAgIGlmIChwYXJzZWRPcmRlclJlZnMuaGFzKGdyb3VwUmVmKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGhpZGRlbkdyb3Vwcy5wdXNoKGdyb3VwUmVmLnRvU3RyaW5nKCkpOwogICAgICB9CiAgICAgIGlmIChoaWRkZW5Hcm91cHMubGVuZ3RoKSB7CiAgICAgICAgb3JkZXIucHVzaCh7CiAgICAgICAgICBuYW1lOiBudWxsLAogICAgICAgICAgb3JkZXI6IGhpZGRlbkdyb3VwcwogICAgICAgIH0pOwogICAgICB9CiAgICAgIHJldHVybiBvcmRlcjsKICAgIH0KICAgIGZ1bmN0aW9uIHBhcnNlTmVzdGVkT3JkZXIocmVmLCBuZXN0ZWRMZXZlbHMpIHsKICAgICAgaWYgKCsrbmVzdGVkTGV2ZWxzID4gTUFYX05FU1RFRF9MRVZFTFMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoInBhcnNlTmVzdGVkT3JkZXIgLSByZWFjaGVkIE1BWF9ORVNURURfTEVWRUxTLiIpOwogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAgIGNvbnN0IHZhbHVlID0geHJlZi5mZXRjaElmUmVmKHJlZik7CiAgICAgIGlmICghQXJyYXkuaXNBcnJheSh2YWx1ZSkpIHsKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgICBjb25zdCBuZXN0ZWROYW1lID0geHJlZi5mZXRjaElmUmVmKHZhbHVlWzBdKTsKICAgICAgaWYgKHR5cGVvZiBuZXN0ZWROYW1lICE9PSAic3RyaW5nIikgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAgIGNvbnN0IG5lc3RlZE9yZGVyID0gcGFyc2VPcmRlcih2YWx1ZS5zbGljZSgxKSwgbmVzdGVkTGV2ZWxzKTsKICAgICAgaWYgKCFuZXN0ZWRPcmRlciB8fCAhbmVzdGVkT3JkZXIubGVuZ3RoKSB7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0KICAgICAgcmV0dXJuIHsKICAgICAgICBuYW1lOiAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKG5lc3RlZE5hbWUpLAogICAgICAgIG9yZGVyOiBuZXN0ZWRPcmRlcgogICAgICB9OwogICAgfQogICAg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2V0KCJQIik7CiAgICAgICAgICBpZiAodHlwZW9mIHAgIT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBwcmVmaXggaW4gUGFnZUxhYmVsIGRpY3Rpb25hcnkuIik7CiAgICAgICAgICB9CiAgICAgICAgICBwcmVmaXggPSAoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKHApOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBwcmVmaXggPSAiIjsKICAgICAgICB9CiAgICAgICAgaWYgKGxhYmVsRGljdC5oYXMoIlN0IikpIHsKICAgICAgICAgIGNvbnN0IHN0ID0gbGFiZWxEaWN0LmdldCgiU3QiKTsKICAgICAgICAgIGlmICghKE51bWJlci5pc0ludGVnZXIoc3QpICYmIHN0ID49IDEpKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBzdGFydCBpbiBQYWdlTGFiZWwgZGljdGlvbmFyeS4iKTsKICAgICAgICAgIH0KICAgICAgICAgIGN1cnJlbnRJbmRleCA9IHN0OwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjdXJyZW50SW5kZXggPSAxOwogICAgICAgIH0KICAgICAgfQogICAgICBzd2l0Y2ggKHN0eWxlKSB7CiAgICAgICAgY2FzZSAiRCI6CiAgICAgICAgICBjdXJyZW50TGFiZWwgPSBjdXJyZW50SW5kZXg7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJSIjoKICAgICAgICBjYXNlICJyIjoKICAgICAgICAgIGN1cnJlbnRMYWJlbCA9ICgwLCBfY29yZV91dGlscy50b1JvbWFuTnVtZXJhbHMpKGN1cnJlbnRJbmRleCwgc3R5bGUgPT09ICJyIik7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJBIjoKICAgICAgICBjYXNlICJhIjoKICAgICAgICAgIGNvbnN0IExJTUlUID0gMjY7Ci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ICAgICAgcmV0dXJuICgwLCBfdXRpbC5zaGFkb3cpKHRoaXMsICJ2aWV3ZXJQcmVmZXJlbmNlcyIsIG51bGwpOwogICAgfQogICAgbGV0IHByZWZzID0gbnVsbDsKICAgIGZvciAoY29uc3Qga2V5IG9mIG9iai5nZXRLZXlzKCkpIHsKICAgICAgY29uc3QgdmFsdWUgPSBvYmouZ2V0KGtleSk7CiAgICAgIGxldCBwcmVmVmFsdWU7CiAgICAgIHN3aXRjaCAoa2V5KSB7CiAgICAgICAgY2FzZSAiSGlkZVRvb2xiYXIiOgogICAgICAgIGNhc2UgIkhpZGVNZW51YmFyIjoKICAgICAgICBjYXNlICJIaWRlV2luZG93VUkiOgogICAgICAgIGNhc2UgIkZpdFdpbmRvdyI6CiAgICAgICAgY2FzZSAiQ2VudGVyV2luZG93IjoKICAgICAgICBjYXNlICJEaXNwbGF5RG9jVGl0bGUiOgogICAgICAgIGNhc2UgIlBpY2tUcmF5QnlQREZTaXplIjoKICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJib29sZWFuIikgewogICAgICAgICAgICBwcmVmVmFsdWUgPSB2YWx1ZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIk5vbkZ1bGxTY3JlZW5QYWdlTW9kZSI6CiAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgICAgICAgICAgIGNhc2UgIlVzZU5vbmUiOgogICAgICAgICAgICAgIGNhc2UgIlVzZU91dGxpbmVzIjoKICAgICAgICAgICAgICBjYXNlICJVc2VUaHVtYnMiOgogICAgICAgICAgICAgIGNhc2UgIlVzZU9DIjoKICAgICAgICAgICAgICAgIHByZWZWYWx1ZSA9IHZhbHVlLm5hbWU7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICAgICAgcHJlZlZhbHVlID0gIlVzZU5vbmUiOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJEaXJlY3Rpb24iOgogICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkgewogICAgICAgICAgICBzd2l0Y2ggKHZhbHVlLm5hbWUpIHsKICAgICAgICAgICAgICBjYXNlICJMMlIiOgogICAgICAgICAgICAgIGNhc2UgIlIyTCI6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSB2YWx1ZS5uYW1lOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHByZWZWYWx1ZSA9ICJMMlIiOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJWaWV3QXJlYSI6CiAgICAgICAgY2FzZSAiVmlld0NsaXAiOgogICAgICAgIGNhc2UgIlByaW50QXJlYSI6CiAgICAgICAgY2FzZSAiUHJpbnRDbGlwIjoKICAgICAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgc3dpdGNoICh2YWx1ZS5uYW1lKSB7CiAgICAgICAgICAgICAgY2FzZSAiTWVkaWFCb3giOgogICAgICAgICAgICAgIGNhc2UgIkNyb3BCb3giOgogICAgICAgICAgICAgIGNhc2UgIkJsZWVkQm94IjoKICAgICAgICAgICAgICBjYXNlICJUcmltQm94IjoKICAgICAgICAgICAgICBjYXNlICJBcnRCb3giOgogICAgICAgICAgICAgICAgcHJlZlZhbHVlID0gdmFsdWUubmFtZTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSAiQ3JvcEJveCI7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIlByaW50U2NhbGluZyI6CiAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgICAgICAgICAgIGNhc2UgIk5vbmUiOgogICAgICAgICAgICAgIGNhc2UgIkFwcERlZmF1bHQiOgogICAgICAgICAgICAgICAgcHJlZlZhbHVlID0gdmFsdWUubmFtZTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSAiQXBwRGVmYXVsdCI7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkR1cGxleCI6CiAgICAgICAgICBpZiAodmFsdWUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHN3aXRjaCAodmFsdWUubmFtZSkgewogICAgICAgICAgICAgIGNhc2UgIlNpbXBsZXgiOgogICAgICAgICAgICAgIGNhc2UgIkR1cGxleEZsaXBTaG9ydEVkZ2UiOgogICAgICAgICAgICAgIGNhc2UgIkR1cGxleEZsaXBMb25nRWRnZSI6CiAgICAgICAgICAgICAgICBwcmVmVmFsdWUgPSB2YWx1ZS5uYW1lOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgICAgIHByZWZWYWx1ZSA9ICJOb25lIjsKICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiUHJpbnRQYWdlUmFuZ2UiOgogICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkodmFsdWUpICYmIHZhbHVlLmxlbmd0aCAlIDIgPT09IDApIHsKICAgICAgICAgICAgY29uc3QgaXNWYWxpZCA9IHZhbHVlLmV2ZXJ5KChwYWdlLCBpLCBhcnIpID0+IHsKICAgICAgICAgICAgICByZXR1cm4gTnVtYmVyLmlzSW50ZWdlcihwYWdlKSAmJiBwYWdlID4gMCAmJiAoaSA9PT0gMCB8fCBwYWdlID49IGFycltpIC0gMV0pICYmIHBhZ2UgPD0gdGhpcy5udW1QYWdlczsKICAgICAgICAgICAgfSk7CiAgICAgICAgICAgIGlmIChpc1ZhbGlkKSB7CiAgICAgICAgICAgICAgcHJlZlZhbHVlID0gdmFsdWU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIk51bUNvcGllcyI6CiAgICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcih2YWx1ZSkgJiYgdmFsdWUgPiAwKSB7CiAgICAgICAgICAgIHByZWZWYWx1ZSA9IHZhbHVlOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgSWdub3Jpbmcgbm9uLXN0YW5kYXJkIGtleSBpbiBWaWV3ZXJQcmVmZXJlbmNlczogJHtrZXl9LmApOwogICAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKHByZWZWYWx1ZSA9PT0gdW5kZWZpbmVkKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKGBCYWQgdmFsdWUsIGZvciBrZXkgIiR7a2V5fSIsIGluIFZpZXdlclByZWZlcmVuY2VzOiAke3ZhbHVlfS5gKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoIXByZWZzKSB7CiAgICAgICAgcHJlZnMgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogICAgICB9CiAgICAgIHByZWZzW2tleV0gPSBwcmVmVmFsdWU7CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgInZpZXdlclByZWZlcmVuY2VzIiwgcH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YgKCgwLCBfcHJpbWl0aXZlcy5pc05hbWUpKHR5cGUsICJQYWdlIikgfHwgIW9iai5oYXMoIktpZHMiKSkgewogICAgICAgICAgICBpZiAoIXBhZ2VLaWRzQ291bnRDYWNoZS5oYXMoY3VycmVudE5vZGUpKSB7CiAgICAgICAgICAgICAgcGFnZUtpZHNDb3VudENhY2hlLnB1dChjdXJyZW50Tm9kZSwgMSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKCFwYWdlSW5kZXhDYWNoZS5oYXMoY3VycmVudE5vZGUpKSB7CiAgICAgICAgICAgICAgcGFnZUluZGV4Q2FjaGUucHV0KGN1cnJlbnROb2RlLCBjdXJyZW50UGFnZUluZGV4KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoY3VycmVudFBhZ2VJbmRleCA9PT0gcGFnZUluZGV4KSB7CiAgICAgICAgICAgICAgcmV0dXJuIFtvYmosIGN1cnJlbnROb2RlXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjdXJyZW50UGFnZUluZGV4Kys7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBub2Rlc1RvVmlzaXQucHVzaChvYmopOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmICghKGN1cnJlbnROb2RlIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlBhZ2UgZGljdGlvbmFyeSBraWQgcmVmZXJlbmNlIHBvaW50cyB0byB3cm9uZyB0eXBlIG9mIG9iamVjdC4iKTsKICAgICAgfQogICAgICBjb25zdCB7CiAgICAgICAgb2JqSWQKICAgICAgfSA9IGN1cnJlbnROb2RlOwogICAgICBsZXQgY291bnQgPSBjdXJyZW50Tm9kZS5nZXRSYXcoIkNvdW50Iik7CiAgICAgIGlmIChjb3VudCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIGNvdW50ID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKGNvdW50KTsKICAgICAgfQogICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihjb3VudCkgJiYgY291bnQgPj0gMCkgewogICAgICAgIGlmIChvYmpJZCAmJiAhcGFnZUtpZHNDb3VudENhY2hlLmhhcyhvYmpJZCkpIHsKICAgICAgICAgIHBhZ2VLaWRzQ291bnRDYWNoZS5wdXQob2JqSWQsIGNvdW50KTsKICAgICAgICB9CiAgICAgICAgaWYgKGN1cnJlbnRQYWdlSW5kZXggKyBjb3VudCA8PSBwYWdlSW5kZXgpIHsKICAgICAgICAgIGN1cnJlbnRQYWdlSW5kZXggKz0gY291bnQ7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgIH0KICAgICAgbGV0IGtpZHMgPSBjdXJyZW50Tm9kZS5nZXRSYXcoIktpZHMiKTsKICAgICAgaWYgKGtpZHMgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICBraWRzID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKGtpZHMpOwogICAgICB9CiAgICAgIGlmICghQXJyYXkuaXNBcnJheShraWRzKSkgewogICAgICAgIGxldCB0eXBlID0gY3VycmVudE5vZGUuZ2V0UmF3KCJUeXBlIik7CiAgICAgICAgaWYgKHR5cGUgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICAgIHR5cGUgPSBhd2FpdCB4cmVmLmZldGNoQXN5bmModHlwZSk7CiAgICAgICAgfQogICAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKSh0eXBlLCAiUGFnZSIpIHx8ICFjdXJyZW50Tm9kZS5oYXMoIktpZHMiKSkgewogICAgICAgICAgaWYgKGN1cnJlbnRQYWdlSW5kZXggPT09IHBhZ2VJbmRleCkgewogICAgICAgICAgICByZXR1cm4gW2N1cnJlbnROb2RlLCBudWxsX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ICAgICB9ID0gcXVldWVJdGVtOwogICAgICBsZXQga2lkcyA9IGN1cnJlbnROb2RlLmdldFJhdygiS2lkcyIpOwogICAgICBpZiAoa2lkcyBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIHRyeSB7CiAgICAgICAgICBraWRzID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKGtpZHMpOwogICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICBhZGRQYWdlRXJyb3IoZXgpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmICghQXJyYXkuaXNBcnJheShraWRzKSkgewogICAgICAgIGFkZFBhZ2VFcnJvcihuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlBhZ2UgZGljdGlvbmFyeSBraWRzIG9iamVjdCBpcyBub3QgYW4gYXJyYXkuIikpOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGlmIChwb3NJbktpZHMgPj0ga2lkcy5sZW5ndGgpIHsKICAgICAgICBxdWV1ZS5wb3AoKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBraWRPYmogPSBraWRzW3Bvc0luS2lkc107CiAgICAgIGxldCBvYmo7CiAgICAgIGlmIChraWRPYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICBpZiAodmlzaXRlZE5vZGVzLmhhcyhraWRPYmopKSB7CiAgICAgICAgICBhZGRQYWdlRXJyb3IobmV3IF91dGlsLkZvcm1hdEVycm9yKCJQYWdlcyB0cmVlIGNvbnRhaW5zIGNpcmN1bGFyIHJlZmVyZW5jZS4iKSk7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgdmlzaXRlZE5vZGVzLnB1dChraWRPYmopOwogICAgICAgIHRyeSB7CiAgICAgICAgICBvYmogPSBhd2FpdCB4cmVmLmZldGNoQXN5bmMoa2lkT2JqKTsKICAgICAgICB9IGNhdGNoIChleCkgewogICAgICAgICAgYWRkUGFnZUVycm9yKGV4KTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICBvYmogPSBraWRPYmo7CiAgICAgIH0KICAgICAgaWYgKCEob2JqIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkpIHsKICAgICAgICBhZGRQYWdlRXJyb3IobmV3IF91dGlsLkZvcm1hdEVycm9yKCJQYWdlIGRpY3Rpb25hcnkga2lkIHJlZmVyZW5jZSBwb2ludHMgdG8gd3JvbmcgdHlwZSBvZiBvYmplY3QuIikpOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICAgIGxldCB0eXBlID0gb2JqLmdldFJhdygiVHlwZSIpOwogICAgICBpZiAodHlwZSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgIHRyeSB7CiAgICAgICAgICB0eXBlID0gYXdhaXQgeHJlZi5mZXRjaEFzeW5jKHR5cGUpOwogICAgICAgIH0gY2F0Y2ggKGV4KSB7CiAgICAgICAgICBhZGRQYWdlRXJyb3IoZXgpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKSh0eXBlLCAiUGFnZSIpIHx8ICFvYmouaGFzKCJLaWRzIikpIHsKICAgICAgICBhZGRQYWdlRGljdChvYmosIGtpZE9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZiA/IGtpZE9iaiA6IG51bGwpOwogICAgICB9IGVsc2UgewogICAgICAgIHF1ZXVlLnB1c2goewogICAgICAgICAgY3VycmVudE5vZGU6IG9iaiwKICAgICAgICAgIHBvc0luS2lkczogMAogICAgICAgIH0pOwogICAgICB9CiAgICAgIHF1ZXVlSXRlbS5wb3NJbktpZHMrKzsKICAgIH0KICAgIHJldHVybiBtYXA7CiAgfQogIGdldFBhZ2VJbmRleChwYWdlUmVmKSB7CiAgICBjb25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gcmV0dXJuIG5vZGUuZ2V0QXN5bmMoIlBhcmVudCIpOwogICAgICB9KS50aGVuKGZ1bmN0aW9uIChwYXJlbnQpIHsKICAgICAgICBpZiAoIXBhcmVudCkgewogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICAgIGlmICghKHBhcmVudCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIlBhcmVudCBtdXN0IGJlIGEgZGljdGlvbmFyeS4iKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHBhcmVudC5nZXRBc3luYygiS2lkcyIpOwogICAgICB9KS50aGVuKGZ1bmN0aW9uIChraWRzKSB7CiAgICAgICAgaWYgKCFraWRzKSB7CiAgICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgICB9CiAgICAgICAgY29uc3Qga2lkUHJvbWlzZXMgPSBbXTsKICAgICAgICBsZXQgZm91bmQgPSBmYWxzZTsKICAgICAgICBmb3IgKGNvbnN0IGtpZCBvZiBraWRzKSB7CiAgICAgICAgICBpZiAoIShraWQgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpKSB7CiAgICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiS2lkIG11c3QgYmUgYSByZWZlcmVuY2UuIik7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoKDAsIF9wcmltaXRpdmVzLmlzUmVmc0VxdWFsKShraWQsIGtpZFJlZikpIHsKICAgICAgICAgICAgZm91bmQgPSB0cnVlOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGtpZFByb21pc2VzLnB1c2goeHJlZi5mZXRjaEFzeW5jKGtpZCkudGhlbihmdW5jdGlvbiAob2JqKSB7CiAgICAgICAgICAgIGlmICghKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpKSB7CiAgICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJLaWQgbm9kZSBtdXN0IGJlIGEgZGljdGlvbmFyeS4iKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAob2JqLmhhcygiQ291bnQiKSkgewogICAgICAgICAgICAgIHRvdGFsICs9IG9iai5nZXQoIkNvdW50Iik7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdG90YWwrKzsKICAgICAgICAgICAgfQogICAgICAgICAgfSkpOwogICAgICAgIH0KICAgICAgICBpZiAoIWZvdW5kKSB7CiAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIktpZCByZWZlcmVuY2Ugbm90IGZvdW5kIGluIHBhcmVudCdzIGtpZHMuIik7CiAgICAgICAgfQogICAgICAgIHJldHVybiBQcm9taXNlLmFsbChraWRQcm9taXNlcykudGhlbihmdW5jdGlvbiAoKSB7CiAgICAgICAgICByZXR1cm4gW3RvdGFsLCBwYXJlbnRSZWZdOwogICAgICAgIH0pOwogICAgICB9KTsKICAgIH0KICAgIGxldCB0b3RhbCA9IDA7CiAgICBjb25zdCBuZXh0ID0gcmVmID0+IHBhZ2VzQmVmb3JlUmVmKHJlZikudGhlbihhcmdzID0+IHsKICAgICAgaWYgKCFhcmdzKSB7CiAgICAgICAgdGhpcy5wYWdlSW5kZXhDYWNoZS5wdXQocGFnZVJlZiwgdG90YWwpOwogICAgICAgIHJldHVybiB0b3RhbDsKICAgICAgfQogICAgICBjb25zdCBbY291bnQsIHBhcmVudFJlZl0gPSBhcmdzOwogICAgICB0b3RhbCArPSBjb3VudDsKICAgICAgcmV0dXJuIG5leHQocGFyZW50UmVmKTsKICAgIH0pOwogICAgcmV0dXJuIG5leHQocGFnZVJlZik7CiAgfQogIGdldCBiYXNlVXJsKCkgewogICAgY29uc3QgdXJpID0gdGhpcy5fY2F0RGljdC5nZXQoIlVSSSIpOwogICAgaWYgKHVyaSBpbnN0YW5jZW9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gICBzd2l0Y2ggKGFjdGlvbk5hbWUpIHsKICAgICAgICBjYXNlICJSZXNldEZvcm0iOgogICAgICAgICAgY29uc3QgZmxhZ3MgPSBhY3Rpb24uZ2V0KCJGbGFncyIpOwogICAgICAgICAgY29uc3QgaW5jbHVkZSA9ICgodHlwZW9mIGZsYWdzID09PSAibnVtYmVyIiA/IGZsYWdzIDogMCkgJiAxKSA9PT0gMDsKICAgICAgICAgIGNvbnN0IGZpZWxkcyA9IFtdOwogICAgICAgICAgY29uc3QgcmVmcyA9IFtdOwogICAgICAgICAgZm9yIChjb25zdCBvYmogb2YgYWN0aW9uLmdldCgiRmllbGRzIikgfHwgW10pIHsKICAgICAgICAgICAgaWYgKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgICAgIHJlZnMucHVzaChvYmoudG9TdHJpbmcoKSk7CiAgICAgICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIG9iaiA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAgICBmaWVsZHMucHVzaCgoMCwgX3V0aWwuc3RyaW5nVG9QREZTdHJpbmcpKG9iaikpOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICByZXN1bHRPYmoucmVzZXRGb3JtID0gewogICAgICAgICAgICBmaWVsZHMsCiAgICAgICAgICAgIHJlZnMsCiAgICAgICAgICAgIGluY2x1ZGUKICAgICAgICAgIH07CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJVUkkiOgogICAgICAgICAgdXJsID0gYWN0aW9uLmdldCgiVVJJIik7CiAgICAgICAgICBpZiAodXJsIGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuTmFtZSkgewogICAgICAgICAgICB1cmwgPSAiLyIgKyB1cmwubmFtZTsKICAgICAgICAgIH0KICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkdvVG8iOgogICAgICAgICAgZGVzdCA9IGFjdGlvbi5nZXQoIkQiKTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgIkxhdW5jaCI6CiAgICAgICAgY2FzZSAiR29Ub1IiOgogICAgICAgICAgY29uc3QgdXJsRGljdCA9IGFjdGlvbi5nZXQoIkYiKTsKICAgICAgICAgIGlmICh1cmxEaWN0IGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICB1cmwgPSB1cmxEaWN0LmdldCgiRiIpIHx8IG51bGw7CiAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiB1cmxEaWN0ID09PSAic3RyaW5nIikgewogICAgICAgICAgICB1cmwgPSB1cmxEaWN0OwogICAgICAgICAgfQogICAgICAgICAgbGV0IHJlbW90ZURlc3QgPSBhY3Rpb24uZ2V0KCJEIik7CiAgICAgICAgICBpZiAocmVtb3RlRGVzdCkgewogICAgICAgICAgICBpZiAocmVtb3RlRGVzdCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgICByZW1vdGVEZXN0ID0gcmVtb3RlRGVzdC5uYW1lOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmICh0eXBlb2YgdXJsID09PSAic3RyaW5nIikgewogICAgICAgICAgICAgIGNvbnN0IGJhc2VVcmwgPSB1cmwuc3BsaXQoIiMiKVswXTsKICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlbW90ZURlc3QgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgICB1cmwgPSBiYXNlVXJsICsgIiMiICsgcmVtb3RlRGVzdDsKICAgICAgICAgICAgICB9IGVsc2UgaWYgKEFycmF5LmlzQXJyYXkocmVtb3RlRGVzdCkpIHsKICAgICAgICAgICAgICAgIHVybCA9IGJhc2VVcmwgKyAiIyIgKyBKU09OLnN0cmluZ2lmeShyZW1vdGVEZXN0KTsKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IG5ld1dpbmRvdyA9IGFjdGlvbi5nZXQoIk5ld1dpbmRvdyIpOwogICAgICAgICAgaWYgKHR5cGVvZiBuZXdXaW5kb3cgPT09ICJib29sZWFuIikgewogICAgICAgICAgICByZXN1bHRPYmoubmV3V2luZG93ID0gbmV3V2luZG93OwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiR29Ub0UiOgogICAgICAgICAgY29uc3QgdGFyZ2V0ID0gYWN0aW9uLmdldCgiVCIpOwogICAgICAgICAgbGV0IGF0dGFjaG1lbnQ7CiAgICAgICAgICBpZiAoZG9jQXR0YWNobWVudHMgJiYgdGFyZ2V0IGluc3RhbmNlb2YgX3ByaW1pdGl2ZXMuRGljdCkgewogICAgICAgICAgICBjb25zdCByZWxhdGlvbnNoaXAgPSB0YXJnZXQuZ2V0KCJSIik7CiAgICAgICAgICAgIGNvbnN0IG5hbWUgPSB0YXJnZXQuZ2V0KCJOIik7CiAgICAgICAgICAgIGlmICgoMCwgX3ByaW1pdGl2ZXMuaXNOYW1lKShyZWxhdGlvbnNoaXAsICJDIikgJiYgdHlwZW9mIG5hbWUgPT09ICJzdHJpbmciKSB7CiAgICAgICAgICAgICAgYXR0YWNobWVudCA9IGRvY0F0dGFjaG1lbnRzWygwLCBfdXRpbC5zdHJpbmdUb1BERlN0cmluZykobmFtZSldOwogICAgICAgICAgICB9CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoYXR0YWNobWVudCkgewogICAgICAgICAgICByZXN1bHRPYmouYXR0YWNobWVudCA9IGF0dGFjaG1lbnQ7CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYHBhcnNlRGVzdERpY3Rpb25hcnkgLSB1bmltcGxlbWVudGVkICJHb1RvRSIgYWN0aW9uLmApOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiTmFtZWQiOgogICAgICAgICAgY29uc3QgbmFtZWRBY3Rpb24gPSBhY3Rpb24uZ2V0KCJOIik7CiAgICAgICAgICBpZiAobmFtZWRBY3Rpb24gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5OYW1lKSB7CiAgICAgICAgICAgIHJlc3VsdE9iai5hY3Rpb24gPSBuYW1lZEFjdGlvbi5uYW1lOwogICAgICAgICAgfQogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiU2V0T0NHU3RhdGUiOgogICAgICAgICAgY29uc3Qgc3RhdGUgPSBhY3Rpb24uZ2V0KCJTdGF0ZSIpOwogICAgICAgICAgY29uc3QgcHJlc2VydmVSQiA9IGFjdGlvbi5nZXQoIlByZXNlcnZlUkIiKTsKICAgICAgICAgIGlmICghQXJyYXkuaXNBcnJheShzdGF0ZSkgfHwgc3RhdGUubGVuZ3RoID09PSAwKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgY29uc3Qgc3RhdGVBcnIgPSBbXTsKICAgICAgICAgIGZvciAoY29uc3QgZWxlbSBvZiBzdGF0ZSkgewogICAgICAgICAgICBpZiAoZWxlbSBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLk5hbWUpIHsKICAgICAgICAgICAgICBzd2l0Y2ggKGVsZW0ubmFtZSkgewogICAgICAgICAgICAgICAgY2FzZSAiT04iOgogICAgICAgICAgICAgICAgY2FzZSAiT0ZGIjoKICAgICAgICAgICAgICAgIGNhc2UgIlRvZ2dsZSI6CiAgICAgICAgICAgICAgICAgIHN0YXRlQXJyLnB1c2goZWxlbS5uYW1lKTsKICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgaWYgKGVsZW0gaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAgICAgICAgICBzdGF0ZUFyci5wdXNoKGVsZW0udG9TdHJpbmcoKSk7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICAgIGlmIChzdGF0ZUFyci5sZW5ndGggIT09IHN0YXRlLmxlbmd0aCkgewogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIHJlc3VsdE9iai5zZXRPQ0dTdGF0ZSA9IHsKICAgICAgICAgICAgc3RhdGU6IHN0YXRlQXJyLAogICAgICAgICAgICBwcmVzZXJ2ZVJCOiB0eXBlb2YgcHJlc2VydmVSQiA9PT0gImJvb2xlYW4iID8gcHJlc2VydmVSQiA6IHRydWUKICAgICAgICAgIH07CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJKYXZhU2NyaXB0IjoKICAgICAgICAgIGNvbnN0IGpzQWN0aW9uID0gYWN0aW9uLmdldCgiSlMiKTsKICAgICAgICAgIGxldCBqczsKICAgICAgICAgIGlmIChqc0FjdGlvbiBpbnN0YW5jZW9mIF9iYXNlX3N0cmVhbS5CYXNlU3RyZWFtKSB7CiAgICAgICAgICAgIGpzID0ganNBY3Rpb24uZ2V0U3RyaW5nKCk7CiAgICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBqc0FjdGlvbiA9PT0gInN0cmluZyIpIHsKICAgICAgICAgICAganMgPSBqc0FjdGlvbjsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnN0IGpzVVJMID0ganMgJiYgKDAsIF9jb3JlX3V0aWxzLnJlY292ZXJKc1VSTCkoKDAsIF91dGlsLnN0cmluZ1RvUERGU3RyaW5nKShqcykpOwogICAgICAgICAgaWYgKGpzVVJMKSB7CiAgICAgICAgICAgIHVybCA9IGpzVVJMLnVybDsKICAgICAgICAgICAgcmVzdWx0T2JqLm5ld1dpbmRvdyA9IGpzVVJMLm5ld1dpbmRvdzsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgZGVmYXVsdDoKICAgICAgICAgIGlmIChhY3Rpb25OYW1lID09PSAiSmF2YVNjcmlwdCIgfHwgYWN0aW9uTmFtZSA9PT0gIlN1Ym1pdEZvcm0iKSB7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgfQogICAgICAgICAgKDAsIF91dGl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kpOwogICAgICBpZiAoIShvYmogaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmIChvYmouaGFzKCJLaWRzIikpIHsKICAgICAgICBjb25zdCBraWRzID0gb2JqLmdldCgiS2lkcyIpOwogICAgICAgIGlmICghQXJyYXkuaXNBcnJheShraWRzKSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGZvciAoY29uc3Qga2lkIG9mIGtpZHMpIHsKICAgICAgICAgIGlmIChwcm9jZXNzZWQuaGFzKGtpZCkpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKGBEdXBsaWNhdGUgZW50cnkgaW4gIiR7dGhpcy5fdHlwZX0iIHRyZWUuYCk7CiAgICAgICAgICB9CiAgICAgICAgICBxdWV1ZS5wdXNoKGtpZCk7CiAgICAgICAgICBwcm9jZXNzZWQucHV0KGtpZCk7CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IGVudHJpZXMgPSBvYmouZ2V0KHRoaXMuX3R5cGUpOwogICAgICBpZiAoIUFycmF5LmlzQXJyYXkoZW50cmllcykpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBmb3IgKGxldCBpID0gMCwgaWkgPSBlbnRyaWVzLmxlbmd0aDsgaSA8IGlpOyBpICs9IDIpIHsKICAgICAgICBtYXAuc2V0KHhyZWYuZmV0Y2hJZlJlZihlbnRyaWVzW2ldKSwgeHJlZi5mZXRjaElmUmVmKGVudHJpZXNbaSArIDFdKSk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBtYXA7CiAgfQogIGdldChrZXkpIHsKICAgIGlmICghdGhpcy5yb290KSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgY29uc3QgeHJlZiA9IHRoaXMueHJlZjsKICAgIGxldCBraWRzT3JFbnRyaWVzID0geHJlZi5mZXRjaElmUmVmKHRoaXMucm9vdCk7CiAgICBsZXQgbG9vcENvdW50ID0gMDsKICAgIGNvbnN0IE1BWF9MRVZFTFMgPSAxMDsKICAgIHdoaWxlIChraWRzT3JFbnRyaWVzLmhhcygiS2lkcyIpKSB7CiAgICAgIGlmICgrK2xvb3BDb3VudCA+IE1BWF9MRVZFTFMpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYFNlYXJjaCBkZXB0aCBsaW1pdCByZWFjaGVkIGZvciAiJHt0aGlzLl90eXBlfSIgdHJlZS5gKTsKICAgICAgICByZXR1cm4gbnVsbDsKICAgICAgfQogICAgICBjb25zdCBraWRzID0ga2lkc09yRW50cmllcy5nZXQoIktpZHMiKTsKICAgICAgaWYgKCFBcnJheS5pc0FycmF5KGtpZHMpKSB7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0KICAgICAgbGV0IGwgPSAwLAogICAgICAgIHIgPSBraWRzLmxlbmd0aCAtIDE7CiAgICAgIHdoaWxlIChsIDw9IHIpIHsKICAgICAgICBjb25zdCBtID0gbCArIHIgPj4gMTsKICAgICAgICBjb25zdCBraWQgPSB4cmVmLmZldGNoSWZSZWYoa2lkc1ttXSk7CiAgICAgICAgY29uc3QgbGltaXRzID0ga2lkLmdldCgiTGltaXRzIik7CiAgICAgICAgaWYgKGtleSA8IHhyZWYuZmV0Y2hJZlJlZihsaW1pdHNbMF0pKSB7CiAgICAgICAgICByID0gbSAtIDE7CiAgICAgICAgfSBlbHNlIGlmIChrZXkgPiB4cmVmLmZldGNoSWZSZWYobGltaXRzWzFdKSkgewogICAgICAgICAgbCA9IG0gKyAxOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBraWRzT3JFbnRyaWVzID0ga2lkOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICB9CiAgICAgIGlmIChsID4gcikgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICB9CiAgICBjb25zdCBlbnRyaWVzID0ga2lkc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sICIiKS5yZXBsYWNlQWxsKC8+XFwzNzZcXDM3NyhbXjxdKykvZywgZnVuY3Rpb24gKGFsbCwgY29kZXMpIHsKICAgICAgY29uc3QgYnl0ZXMgPSBjb2Rlcy5yZXBsYWNlQWxsKC9cXChbMC0zXSkoWzAtN10pKFswLTddKS9nLCBmdW5jdGlvbiAoY29kZSwgZDEsIGQyLCBkMykgewogICAgICAgIHJldHVybiBTdHJpbmcuZnJvbUNoYXJDb2RlKGQxICogNjQgKyBkMiAqIDggKyBkMyAqIDEpOwogICAgICB9KS5yZXBsYWNlQWxsKC8mKGFtcHxhcG9zfGd0fGx0fHF1b3QpOy9nLCBmdW5jdGlvbiAoc3RyLCBuYW1lKSB7CiAgICAgICAgc3dpdGNoIChuYW1lKSB7CiAgICAgICAgICBjYXNlICJhbXAiOgogICAgICAgICAgICByZXR1cm4gIiYiOwogICAgICAgICAgY2FzZSAiYXBvcyI6CiAgICAgICAgICAgIHJldHVybiAiJyI7CiAgICAgICAgICBjYXNlICJndCI6CiAgICAgICAgICAgIHJldHVybiAiPiI7CiAgICAgICAgICBjYXNlICJsdCI6CiAgICAgICAgICAgIHJldHVybiAiPCI7CiAgICAgICAgICBjYXNlICJxdW90IjoKICAgICAgICAgICAgcmV0dXJuICciJzsKICAgICAgICB9CiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBfcmVwYWlyOiAke25hbWV9IGlzbid0IGRlZmluZWQuYCk7CiAgICAgIH0pOwogICAgICBjb25zdCBjaGFyQnVmID0gWyI+Il07CiAgICAgIGZvciAobGV0IGkgPSAwLCBpaSA9IGJ5dGVzLmxlbmd0aDsgaSA8IGlpOyBpICs9IDIpIHsKICAgICAgICBjb25zdCBjb2RlID0gYnl0ZXMuY2hhckNvZGVBdChpKSAqIDI1NiArIGJ5dGVzLmNoYXJDb2RlQXQoaSArIDEpOwogICAgICAgIGlmIChjb2RlID49IDMyICYmIGNvZGUgPCAxMjcgJiYgY29kZSAhPT0gNjAgJiYgY29kZSAhPT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iAgICAgIHJkZiA9IHJkZi5maXJzdENoaWxkOwogICAgICB3aGlsZSAocmRmICYmIHJkZi5ub2RlTmFtZSAhPT0gInJkZjpyZGYiKSB7CiAgICAgICAgcmRmID0gcmRmLm5leHRTaWJsaW5nOwogICAgICB9CiAgICB9CiAgICBpZiAoIXJkZiB8fCByZGYubm9kZU5hbWUgIT09ICJyZGY6cmRmIiB8fCAhcmRmLmhhc0NoaWxkTm9kZXMoKSkgewogICAgICByZXR1cm47CiAgICB9CiAgICBmb3IgKGNvbnN0IGRlc2Mgb2YgcmRmLmNoaWxkTm9kZXMpIHsKICAgICAgaWYgKGRlc2Mubm9kZU5hbWUgIT09ICJyZGY6ZGVzY3JpcHRpb24iKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgZm9yIChjb25zdCBlbnRyeSBvZiBkZXNjLmNoaWxkTm9kZXMpIHsKICAgICAgICBjb25zdCBuYW1lID0gZW50cnkubm9kZU5hbWU7CiAgICAgICAgc3dpdGNoIChuYW1lKSB7CiAgICAgICAgICBjYXNlICIjdGV4dCI6CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgY2FzZSAiZGM6Y3JlYXRvciI6CiAgICAgICAgICBjYXNlICJkYzpzdWJqZWN0IjoKICAgICAgICAgICAgdGhpcy5fcGFyc2VBcnJheShlbnRyeSk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICB0aGlzLl9tZXRhZGF0YU1hcC5zZXQobmFtZSwgZW50cnkudGV4dENvbnRlbnQudHJpbSgpKTsKICAgICAgfQogICAgfQogIH0KICBnZXQgc2VyaWFsaXphYmxlKCkgewogICAgcmV0dXJuIHsKICAgICAgcGFyc2VkRGF0YTogdGhpcy5fbWV0YWRhdGFNYXAsCiAgICAgIHJhd0RhdGE6IHRoaXMuX2RhdGEKICAgIH07CiAgfQp9CmV4cG9ydHMuTWV0YWRhdGFQYXJzZXIgPSBNZXRhZGF0YVBhcnNlcjsKCi8q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LIik7CiAgICBpZiAoQXJyYXkuaXNBcnJheShraWRzKSkgewogICAgICBmb3IgKGNvbnN0IGtpZCBvZiBraWRzKSB7CiAgICAgICAgY29uc3QgZWxlbWVudCA9IHRoaXMucGFyc2VLaWQocGFnZU9iaklkLCBraWQpOwogICAgICAgIGlmIChlbGVtZW50KSB7CiAgICAgICAgICB0aGlzLmtpZHMucHVzaChlbGVtZW50KTsKICAgICAgICB9CiAgICAgIH0KICAgIH0gZWxzZSB7CiAgICAgIGNvbnN0IGVsZW1lbnQgPSB0aGlzLnBhcnNlS2lkKHBhZ2VPYmpJZCwga2lkcyk7CiAgICAgIGlmIChlbGVtZW50KSB7CiAgICAgICAgdGhpcy5raWRzLnB1c2goZWxlbWVudCk7CiAgICAgIH0KICAgIH0KICB9CiAgcGFyc2VLaWQocGFnZU9iaklkLCBraWQpIHsKICAgIGlmIChOdW1iZXIuaXNJbnRlZ2VyKGtpZCkpIHsKICAgICAgaWYgKHRoaXMudHJlZS5wYWdlRGljdC5vYmpJZCAhPT0gcGFnZU9iaklkKSB7CiAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgIH0KICAgICAgcmV0dXJuIG5ldyBTdHJ1Y3RFbGVtZW50KHsKICAgICAgICB0eXBlOiBTdHJ1Y3RFbGVtZW50VHlwZS5QQUdFX0NPTlRFTlQsCiAgICAgICAgbWNpZDoga2lkLAogICAgICAgIHBhZ2VPYmpJZAogICAgICB9KTsKICAgIH0KICAgIGxldCBraWREaWN0ID0gbnVsbDsKICAgIGlmIChraWQgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5SZWYpIHsKICAgICAga2lkRGljdCA9IHRoaXMuZGljdC54cmVmLmZldGNoKGtpZCk7CiAgICB9IGVsc2UgaWYgKGtpZCBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLkRpY3QpIHsKICAgICAga2lkRGljdCA9IGtpZDsKICAgIH0KICAgIGlmICgha2lkRGljdCkgewogICAgICByZXR1cm4gbnVsbDsKICAgIH0KIC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XMucmVmU2V0ID0gbnVsbDsKICAgICAgICAgICAgY29uc3QgewogICAgICAgICAgICAgIG1hbmFnZXIKICAgICAgICAgICAgfSA9IHRoaXMueHJlZi5zdHJlYW07CiAgICAgICAgICAgIHJldHVybiBtYW5hZ2VyLnJlcXVlc3RBbGxDaHVua3MoKTsKICAgICAgICAgIH0KICAgICAgICAgIG5vZGVzVG9SZXZpc2l0LnB1c2goY3VycmVudE5vZGUpOwogICAgICAgICAgcGVuZGluZ1JlcXVlc3RzLnB1c2goewogICAgICAgICAgICBiZWdpbjogZXguYmVnaW4sCiAgICAgICAgICAgIGVuZDogZXguZW5kCiAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKGN1cnJlbnROb2RlIGluc3RhbmNlb2YgX2Jhc2Vfc3RyZWFtLkJhc2VTdHJlYW0pIHsKICAgICAgICBjb25zdCBiYXNlU3RyZWFtcyA9IGN1cnJlbnROb2RlLmdldEJhc2VTdHJlYW1zKCk7CiAgICAgICAgaWYgKGJhc2VTdHJlYW1zKSB7CiAgICAgICAgICBsZXQgZm91bmRNaXNzaW5nRGF0YSA9IGZhbHNlOwogICAgICAgICAgZm9yIChjb25zdCBzdHJlYW0gb2YgYmFzZVN0cmVhbXMpIHsKICAgICAgICAgICAgaWYgKHN0cmVhbS5pc0RhdGFMb2FkZWQpIHsKICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBmb3VuZE1pc3NpbmdEYXRhID0gdHJ1ZTsKICAgICAgICAgICAgcGVuZGluZ1JlcXVlc3RzLnB1c2goewogICAgICAgICAgICAgIGJlZ2luOiBzdHJlYW0uc3RhcnQsCiAgICAgICAgICAgICAgZW5kOiBzdHJlYW0uZW5kCiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQogICAgICAgICAgaWYgKGZvdW5kTWlzc2luZ0RhdGEpIHsKICAgICAgICAgICAgbm9kZXNUb1JldmlzaXQucHVzaChjdXJyZW50Tm9kZS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0ZXJhdGlvbiA9ICgpID0+IHsKICAgICAgICB0cnkgewogICAgICAgICAgY29uc3QgdmFsdWUgPSBpdGVyYXRvci5uZXh0KCk7CiAgICAgICAgICBpZiAodmFsdWUuZG9uZSkgewogICAgICAgICAgICByZXNvbHZlKHZhbHVlLnZhbHVlKTsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHNldFRpbWVvdXQobmV4dEl0ZXJhdGlvbiwgMCk7CiAgICAgICAgICB9CiAgICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgICAgcmVqZWN0KGUpOwogICAgICAgIH0KICAgICAgfTsKICAgICAgc2V0VGltZW91dChuZXh0SXRlcmF0aW9uLCAwKTsKICAgIH0pOwogIH0KICBhc3luYyBfY3JlYXRlUGFnZXMoKSB7CiAgICB0cnkgewogICAgICB0aGlzLnBhZ2VzID0gYXdhaXQgdGhpcy5fY3JlYXRlUGFnZXNIZWxwZXIoKTsKICAgICAgdGhpcy5kaW1zID0gdGhpcy5wYWdlcy5jaGlsZHJlbi5tYXAoYyA9PiB7CiAgICAgICAgY29uc3QgewogICAgICAgICAgd2lkdGgsCiAgICAgICAgICBoZWlnaHQKICAgICAgICB9ID0gYy5hdHRyaWJ1dGVzLnN0eWxlOwogICAgICAgIHJldHVybiBbMCwgMCwgcGFyc2VJbnQod2lkdGgpLCBwYXJzZUludChoZWlnaHQpXTsKICAgICAgfSk7CiAgICB9IGNhdGNoIChlKSB7CiAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gYW4gZXJyb3Igb2NjdXJyZWQgZHVyaW5nIGxheW91dDogJHtlfWApOwogICAgfQogIH0KICBnZXRCb3VuZGluZ0JveChwYWdlSW5kZXgpIHsKICAgIHJldHVybiB0aGlzLmRpbXNbcGFnZUluZGV4XTsKICB9CiAgYXN5bmMgZ2V0TnVtUGFnZXMoKSB7CiAgICBpZiAoIXRoaXMucGFnZXMpIHsKICAgICAgYXdhaXQgdGhpcy5fY3JlYXRlUGFnZXMoKTs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47CiAgICB0aGlzW19wYXJlbnRdID0gbnVsbDsKICAgIHRoaXNbX2NoaWxkcmVuXSA9IFtdOwogICAgdGhpc1skdWlkXSA9IGAke25hbWV9JHt1aWQrK31gOwogICAgdGhpc1skZ2xvYmFsRGF0YV0gPSBudWxsOwogIH0KICBbJG9uQ2hpbGRdKGNoaWxkKSB7CiAgICBpZiAoIXRoaXNbX2hhc0NoaWxkcmVuXSB8fCAhdGhpc1skb25DaGlsZENoZWNrXShjaGlsZCkpIHsKICAgICAgcmV0dXJuIGZhbHNlOwogICAgfQogICAgY29uc3QgbmFtZSA9IGNoaWxkWyRub2RlTmFtZV07CiAgICBjb25zdCBub2RlID0gdGhpc1tuYW1lXTsKICAgIGlmIChub2RlIGluc3RhbmNlb2YgWEZBT2JqZWN0QXJyYXkpIHsKICAgICAgaWYgKG5vZGUucHVzaChjaGlsZCkpIHsKICAgICAgICB0aGlzWyRhcHBlbmRDaGlsZF0oY2hpbGQpOwogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICBpZiAobm9kZSAhPT0gbnVsbCkgewogICAgICAgIHRoaXNbJHJlbW92ZUNoaWxkXShub2RlKTsKICAgICAgfQogICAgICB0aGlzW25hbWVdID0gY2hpbGQ7CiAgICAgIHRoaXNbJGFwcGVuZENoaWxkXShjaGlsZCk7CiAgICAgIHJldHVybiB0cnVlOwogICAgfQogICAgbGV0IGlkID0gIiI7CiAgICBpZiAodGhpcy5pZCkgewogICAgICBpZCA9IGAgKGlkOiAke3RoaXMuaWR9KWA7CiAgICB9IGVsc2UgaWYgKHRoaXMubmFtZSkgewogICAgICBpZCA9IGAgKG5hbWU6ICR7dGhpcy5uYW1lfSAke3RoaXMuaC52YWx1ZX0pYDsKICAgIH0KICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gbm9kZSAiJHt0aGlzWyRub2RlTmFtZV19IiR7aWR9IGhhcyBhbHJlYWR5IGVub3VnaCAiJHtuYW1lfSIhYCk7C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2JhbERhdGFdOwogICAgfQogIH0KICBbJGlzVHJhbnNwYXJlbnRdKCkgewogICAgcmV0dXJuICF0aGlzLm5hbWU7CiAgfQogIFskbGFzdEF0dHJpYnV0ZV0oKSB7CiAgICByZXR1cm4gIiI7CiAgfQogIFskdGV4dF0oKSB7CiAgICBpZiAodGhpc1tfY2hpbGRyZW5dLmxlbmd0aCA9PT0gMCkgewogICAgICByZXR1cm4gdGhpc1skY29udGVudF07CiAgICB9CiAgICByZXR1cm4gdGhpc1tfY2hpbGRyZW5dLm1hcChjID0+IGNbJHRleHRdKCkpLmpvaW4oIiIpOwogIH0KICBnZXQgW19hdHRyaWJ1dGVOYW1lc10oKSB7CiAgICBjb25zdCBwcm90byA9IE9iamVjdC5nZXRQcm90b3R5cGVPZih0aGlzKTsKICAgIGlmICghcHJvdG8uX2F0dHJpYnV0ZXMpIHsKICAgICAgY29uc3QgYXR0cmlidXRlcyA9IHByb3RvLl9hdHRyaWJ1dGVzID0gbmV3IFNldCgpOwogICAgICBmb3IgKGNvbnN0IG5hbWUgb2YgT2JqZWN0LmdldE93blByb3BlcnR5TmFtZXModGhpcykpIHsKICAgICAgICBpZiAodGhpc1tuYW1lXSA9PT0gbnVsbCB8fCB0aGlzW25hbWVdIGluc3RhbmNlb2YgWEZBT2JqZWN0IHx8IHRoaXNbbmFtZV0gaW5zdGFuY2VvZiBYRkFPYmplY3RBcnJheSkgewogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGF0dHJpYnV0ZXMuYWRkKG5hbWUpOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gKDAsIF91dGlsLnNoYWRvdykodGhpcywgX2F0dHJpYnV0ZU5hbWVzLCBwcm90by5fYXR0cmlidXRlcyk7CiAgfQogIFskaXNEZXNjZW5kZW50XShwYXJlbnQpIHsKICAgIGxldCBub2RlID0gdGhpczsKICAgIHdoaWxlIChub2RlKSB7CiAgICAgIGlmIChub2RlID09PSBwYXJlbnQpIHsKICAgICAgICByZXR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2YgWEZBT2JqZWN0QXJyYXkpIHsKICAgICAgICBmb3IgKGNvbnN0IGNoaWxkIG9mIHZhbHVlW19jaGlsZHJlbl0pIHsKICAgICAgICAgIGNoaWxkW19yZXNvbHZlUHJvdG90eXBlc0hlbHBlcl0oaWRzLCBhbmNlc3RvcnMpOwogICAgICAgIH0KICAgICAgICBmb3IgKGxldCBpID0gdmFsdWVbX2NoaWxkcmVuXS5sZW5ndGgsIGlpID0gcHJvdG9WYWx1ZVtfY2hpbGRyZW5dLmxlbmd0aDsgaSA8IGlpOyBpKyspIHsKICAgICAgICAgIGNvbnN0IGNoaWxkID0gcHJvdG9bX2NoaWxkcmVuXVtpXVskY2xvbmVdKCk7CiAgICAgICAgICBpZiAodmFsdWUucHVzaChjaGlsZCkpIHsKICAgICAgICAgICAgY2hpbGRbX3BhcmVudF0gPSB0aGlzOwogICAgICAgICAgICB0aGlzW19jaGlsZHJlbl0ucHVzaChjaGlsZCk7CiAgICAgICAgICAgIGNoaWxkW19yZXNvbHZlUHJvdG90eXBlc0hlbHBlcl0oaWRzLCBhbmNlc3RvcnMpOwogICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGlmICh2YWx1ZSAhPT0gbnVsbCkgewogICAgICAgIHZhbHVlWyRyZXNvbHZlUHJvdG90eXBlc10oaWRzLCBhbmNlc3RvcnMpOwogICAgICAgIGlmIChwcm90b1ZhbHVlKSB7CiAgICAgICAgICB2YWx1ZVtfYXBwbHlQcm90b3R5cGVdKHByb3RvVmFsdWUsIGlkcywgYW5jZXN0b3JzKTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKHByb3RvVmFsdWUgIT09IG51bGwpIHsKICAgICAgICBjb25zdCBjaGlsZCA9IHByb3RvVmFsdWVbJGNsb25lXSgpOwogICAgICAgIGNoaWxkW19wYXJlbnR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GVOYW1lc10uaGFzKG5hbWUpKSB7CiAgICAgICAgY2xvbmVbbmFtZV0gPSBYRkFPYmplY3RbX2Nsb25lQXR0cmlidXRlXSh0aGlzW25hbWVdKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCB2YWx1ZSA9IHRoaXNbbmFtZV07CiAgICAgIGlmICh2YWx1ZSBpbnN0YW5jZW9mIFhGQU9iamVjdEFycmF5KSB7CiAgICAgICAgY2xvbmVbbmFtZV0gPSBuZXcgWEZBT2JqZWN0QXJyYXkodmFsdWVbX21heF0pOwogICAgICB9IGVsc2UgewogICAgICAgIGNsb25lW25hbWVdID0gbnVsbDsKICAgICAgfQogICAgfQogICAgZm9yIChjb25zdCBjaGlsZCBvZiB0aGlzW19jaGlsZHJlbl0pIHsKICAgICAgY29uc3QgbmFtZSA9IGNoaWxkWyRub2RlTmFtZV07CiAgICAgIGNvbnN0IGNsb25lZENoaWxkID0gY2hpbGRbJGNsb25lXSgpOwogICAgICBjbG9uZVtfY2hpbGRyZW5dLnB1c2goY2xvbmVkQ2hpbGQpOwogICAgICBjbG9uZWRDaGlsZFtfcGFyZW50XSA9IGNsb25lOwogICAgICBpZiAoY2xvbmVbbmFtZV0gPT09IG51bGwpIHsKICAgICAgICBjbG9uZVtuYW1lXSA9IGNsb25lZENoaWxkOwogICAgICB9IGVsc2UgewogICAgICAgIGNsb25lW25hbWVdW19jaGlsZHJlbl0ucHVzaChjbG9uZWRDaGlsZCk7CiAgICAgIH0KICAgIH0KICAgIHJldHVybiBjbG9uZTsKICB9CiAgWyRnZXRDaGlsZHJlbl0oKSB7CiAgICBsZXQgbmFtZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAwICYmIGFyZ3VtZW50c1swXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzBdIDogbnVsbDsKICAgIGlmICghbmFtZSkgewogICAgICByZXR1cm4gdGhpc1tfY2hpbGRyZW5dOwogICAgfQogICAgcmV0dXJuIHRoaXNbX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jb25zdCBzcG9zID0gcG9zOwogICAgY29uc3QgY2hhciA9IGV4cHIuY2hhckF0KHBvcysrKTsKICAgIGlmIChjaGFyID09PSAiWyIpIHsKICAgICAgbWF0Y2ggPSBleHByLnNsaWNlKHBvcykubWF0Y2goaW5kZXhQYXR0ZXJuKTsKICAgICAgaWYgKCFtYXRjaCkgewogICAgICAgICgwLCBfdXRpbC53YXJuKSgiWEZBIC0gSW52YWxpZCBpbmRleCBpbiBTT00gZXhwcmVzc2lvbiIpOwogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAgIHBhcnNlZC5hdCgtMSkuaW5kZXggPSBwYXJzZUluZGV4KG1hdGNoWzBdKTsKICAgICAgcG9zICs9IG1hdGNoWzBdLmxlbmd0aCArIDE7CiAgICAgIGNvbnRpbnVlOwogICAgfQogICAgbGV0IG9wZXJhdG9yOwogICAgc3dpdGNoIChleHByLmNoYXJBdChwb3MpKSB7CiAgICAgIGNhc2UgIi4iOgogICAgICAgIGlmICghZG90RG90QWxsb3dlZCkgewogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICAgIHBvcysrOwogICAgICAgIG9wZXJhdG9yID0gb3BlcmF0b3JzLmRvdERvdDsKICAgICAgICBicmVhazsKICAgICAgY2FzZSAiIyI6CiAgICAgICAgcG9zKys7CiAgICAgICAgb3BlcmF0b3IgPSBvcGVyYXRvcnMuZG90SGFzaDsKICAgICAgICBicmVhazsKICAgICAgY2FzZSAiWyI6CiAgICAgICAgaWYgKG5vRXhwcikgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKCJYRkEgLSBTT00gZXhwcmVzc2lvbiBjb250YWlucyBhIEZvcm1DYWxjIHN1YmV4cHJlc3Npb24gd2hpY2ggaXMgbm90IHN1cHBvcnRlZCBmb3Igbm93LiIpOwogICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQogICAgICAgIG9wZXJhdG9yID0gb3BlcmF0b3JzLmRvdEJyYWNrZXQ7CiAgIC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k7CiAgICAgIH0KICAgICAgaWYgKCFjaGlsZHJlbikgewogICAgICAgIHN3aXRjaCAob3BlcmF0b3IpIHsKICAgICAgICAgIGNhc2Ugb3BlcmF0b3JzLmRvdDoKICAgICAgICAgICAgY2hpbGRyZW4gPSBub2RlW194ZmFfb2JqZWN0LiRnZXRDaGlsZHJlbkJ5TmFtZV0obmFtZSwgZmFsc2UpOwogICAgICAgICAgICBicmVhazsKICAgICAgICAgIGNhc2Ugb3BlcmF0b3JzLmRvdERvdDoKICAgICAgICAgICAgY2hpbGRyZW4gPSBub2RlW194ZmFfb2JqZWN0LiRnZXRDaGlsZHJlbkJ5TmFtZV0obmFtZSwgdHJ1ZSk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSBvcGVyYXRvcnMuZG90SGFzaDoKICAgICAgICAgICAgY2hpbGRyZW4gPSBub2RlW194ZmFfb2JqZWN0LiRnZXRDaGlsZHJlbkJ5Q2xhc3NdKG5hbWUpOwogICAgICAgICAgICBpZiAoY2hpbGRyZW4gaW5zdGFuY2VvZiBfeGZhX29iamVjdC5YRkFPYmplY3RBcnJheSkgewogICAgICAgICAgICAgIGNoaWxkcmVuID0gY2hpbGRyZW4uY2hpbGRyZW47CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgY2hpbGRyZW4gPSBbY2hpbGRyZW5dOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmICh1c2VDYWNoZSkgewogICAgICAgICAgY2FjaGVkLnNldChjYWNoZU5hbWUsIGNoaWxkcmVuKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKGNoaWxkcmVuLmxlbmd0aCA+IDApIHsKICAgICAgICBub2Rlcy5wdXNoKGNoaWxkcmVuKTsKICAgICAgfQogICAgfQogICAgaWYgKG5vZGVzLmxlbmd0aCA9PT0gMCAmJiAhaXNRdWFsaWZpZWQgJiYgaSA9PT0gMCkgewogICAgICBjb25zdCBwYXJlbnQgPSBjb250YWluZXJbX3hmYV9vYmplY3QuJGdldFBhcmVudF0oKTsKICAgICAgY29udGFpbmVyID0gcGFyZW50OwogICAgICBpZiAoIWNvbnRhaW5lcikgewogICAgICAgIHJldHVybiBudWxsOwogICAgICB9CiAgICAgIGkgPSAtMTsKICAgICAgcm9vdCA9IFtjb250YWluZXJdOwogICAgICBjb250aW51ZTsKICAgIH0KICAgIGlmIChpc0Zpbml0ZShpbmRleCkpIHsKICAgICAgcm9vdCA9IG5vZGVzLmZpbHRlcihub2RlID0+IGluZGV4IDwgbm9kZS5sZW5ndGgpLm1hcChub2RlID0+IG5vZGVbaW5kZXhdKTsKICAgIH0gZWxzZSB7CiAgICAgIHJvb3QgPSBub2Rlcy5mbGF0KCk7CiAgICB9CiAgfQogIGlmIChyb290Lmxlbmd0aCA9PT0gMCkgewogICAgcmV0dXJuIG51bGw7CiAgfQogIHJldHVybiByb290Owp9CmZ1bmN0aW9uIGNyZWF0ZU5vZGVzKHJvb3QsIHBhdGgpIHsKICBsZXQgbm9kZSA9IG51bGw7CiAgZm9yIChjb25zdCB7CiAgICBuYW1lLAogICAgaW5kZXgKICB9IG9mIHBhdGgpIHsKICAgIGZvciAobGV0IGkgPSAwLCBpaSA9ICFpc0Zpbml0ZShpbmRleCkgPyAwIDogaW5kZXg7IGkgPD0gaWk7IGkrKykgewogICAgICBjb25zdCBuc0lkID0gcm9vdFtfeGZhX29iamVjdC4kbmFtZXNwYWNlSWRdID09PSBOU19EQVRBU0VUUyA/IC0xIDogcm9vdFtfeGZhX29iamVjdC4kbmFtZXNwYWNlSWRdOwogICAgICBub2RlID0gbmV3IF94ZmFfb2JqZWN0LlhtbE9iamVjdChuc0lkLCBuYW1lKTsKICAgICAgcm9vdFtfeGZhX29iamVjdC4kYXBwZW5kQ2hpbGRdKG5vZGUpOwogICAgfQogICAgcm9vdCA9IG5vZGU7CiAgf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ybiBudWxsOwogIH0KICBfc2V0UHJvcGVydGllcyhmb3JtTm9kZSwgZGF0YU5vZGUpIHsKICAgIGlmICghZm9ybU5vZGUuaGFzT3duUHJvcGVydHkoInNldFByb3BlcnR5IikpIHsKICAgICAgcmV0dXJuOwogICAgfQogICAgZm9yIChjb25zdCB7CiAgICAgIHJlZiwKICAgICAgdGFyZ2V0LAogICAgICBjb25uZWN0aW9uCiAgICB9IG9mIGZvcm1Ob2RlLnNldFByb3BlcnR5LmNoaWxkcmVuKSB7CiAgICAgIGlmIChjb25uZWN0aW9uKSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKCFyZWYpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBub2RlcyA9ICgwLCBfc29tLnNlYXJjaE5vZGUpKHRoaXMucm9vdCwgZGF0YU5vZGUsIHJlZiwgZmFsc2UsIGZhbHNlKTsKICAgICAgaWYgKCFub2RlcykgewogICAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gSW52YWxpZCByZWZlcmVuY2U6ICR7cmVmfS5gKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBbbm9kZV0gPSBub2RlczsKICAgICAgaWYgKCFub2RlW194ZmFfb2JqZWN0LiRpc0Rlc2NlbmRlbnRdKHRoaXMuZGF0YSkpIHsKICAgICAgICAoMCwgX3V0aWwud2FybikoYFhGQSAtIEludmFsaWQgbm9kZTogbXVzdCBiZSBhIGRhdGEgbm9kZS5gKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCB0YXJnZXROb2RlcyA9ICgwLCBfc29tLnNlYXJjaE5vZGUpKHRoaXMucm9vdCwgZm9ybU5vZGUsIHRhcmdldCwgZmFsc2UsIGZhbHNlKTsKICAgICAgaWYgKCF0YXJnZXROb2RlcykgewogICAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gSW52YWxpZCB0YXJnZXQ6ICR7dGFyZ2V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GNhc2UgIm5vbmUiOgogICAgICAgICAgICB0aGlzLl9zZXRBbmRCaW5kKGNoaWxkLCBkYXRhTm9kZSk7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgY2FzZSAiZ2xvYmFsIjoKICAgICAgICAgICAgZ2xvYmFsID0gdHJ1ZTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICBjYXNlICJkYXRhUmVmIjoKICAgICAgICAgICAgaWYgKCFjaGlsZC5iaW5kLnJlZikgewogICAgICAgICAgICAgICgwLCBfdXRpbC53YXJuKShgWEZBIC0gcmVmIGlzIGVtcHR5IGluIG5vZGUgJHtjaGlsZFtfeGZhX29iamVjdC4kbm9kZU5hbWVdfS5gKTsKICAgICAgICAgICAgICB0aGlzLl9zZXRBbmRCaW5kKGNoaWxkLCBkYXRhTm9kZSk7CiAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmVmID0gY2hpbGQuYmluZC5yZWY7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgZGVmYXVsdDoKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmIChjaGlsZC5iaW5kLnBpY3R1cmUpIHsKICAgICAgICAgIHBpY3R1cmUgPSBjaGlsZC5iaW5kLnBpY3R1cmVbX3hmYV9vYmplY3QuJGNvbnRlbnRdOwogICAgICAgIH0KICAgICAgfQogICAgICBjb25zdCBbbWluLCBtYXhdID0gdGhpcy5fZ2V0T2NjdXJJbmZvKGNoaWxkKTsKICAgICAgaWYgKHJlZikgewogICAgICAgIG1hdGNoID0gKDAsIF9zb20uc2VhcmNoTm9kZSkodGhpcy5yb290LCBkYXRhTm9kZSwgcmVmLCB0cnVlLCBmYWxzZSk7CiAgICAgICAgaWYgKG1hdGNoID09PSBudWxsKSB7CiAgICAgICAgICBtYXRjaCA9ICgwLCBfc29tLmNyZWF0ZURhdGFOb2RlKSh0aGlzLmRhdGEsIGRhdGFOb2RlLCByZWYpOwogICAgICAgICAgaWYgKCFtYXRjaCkgewogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgIH0KICAgICAgICAgIGlmICh0aGlzLl9pc0NvbnN1bWVEYXRhKCkpIHsKICAgICAgICAgICAgbWF0Y2hbX3hmYV9vYmplY3QuJGNvbnN1bWVkXSA9IHRydWU7CiAgICAgICAgICB9CiAgICAgICAgICB0aGlzLl9zZXRBbmRCaW5kKGNoaWxkLCBtYXRjaCk7CiAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgaWYgKHRoaXMuX2lzQ29uc3VtZURhdGEoKSkgewogICAgICAgICAgICBtYXRjaCA9IG1hdGNoLmZpbHRlcihub2RlID0+ICFub2RlW194ZmFfb2JqZWN0LiRjb25zdW1lZF0pOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG1hdGNoLmxlbmd0aCA+IG1heCkgewogICAgICAgICAgICBtYXRjaCA9IG1hdGNoLnNsaWNlKDAsIG1heCk7CiAgICAgICAgICB9IGVsc2UgaWYgKG1hdGNoLmxlbmd0aCA9PT0gMCkgewogICAgICAgICAgICBtYXRjaCA9IG51bGw7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAobWF0Y2ggJiYgdGhpcy5faXNDb25zdW1lRGF0YSgpKSB7CiAgICAgICAgICAgIG1hdGNoLmZvckVhY2gobm9kZSA9PiB7CiAgICAgICAgICAgICAgbm9kZVtfeGZhX29iamVjdC4kY29uc3VtZWRdID0gdHJ1ZTsKICAgICAgICAgICAgfSk7CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIGlmICghY2hpbGQubmFtZSkgewogICAgICAgICAgdGhpcy5fc2V0QW5kQmluZChjaGlsZCwgZGF0YU5vZGUpOwogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGlmICh0aGlzLl9pc0NvbnN1bWVEYXRhKCkpIHsKICAgICAgICAgIGNvbnN0IG1hdGNoZXMgPSBbXT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aXNSZXF1aXJlZChub2RlKSB7CiAgcmV0dXJuIG5vZGUudmFsaWRhdGUgJiYgbm9kZS52YWxpZGF0ZS5udWxsVGVzdCA9PT0gImVycm9yIjsKfQpmdW5jdGlvbiBzZXRUYWJJbmRleChub2RlKSB7CiAgd2hpbGUgKG5vZGUpIHsKICAgIGlmICghbm9kZS50cmF2ZXJzYWwpIHsKICAgICAgbm9kZVtfeGZhX29iamVjdC4kdGFiSW5kZXhdID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0UGFyZW50XSgpW194ZmFfb2JqZWN0LiR0YWJJbmRleF07CiAgICAgIHJldHVybjsKICAgIH0KICAgIGlmIChub2RlW194ZmFfb2JqZWN0LiR0YWJJbmRleF0pIHsKICAgICAgcmV0dXJuOwogICAgfQogICAgbGV0IG5leHQgPSBudWxsOwogICAgZm9yIChjb25zdCBjaGlsZCBvZiBub2RlLnRyYXZlcnNhbFtfeGZhX29iamVjdC4kZ2V0Q2hpbGRyZW5dKCkpIHsKICAgICAgaWYgKGNoaWxkLm9wZXJhdGlvbiA9PT0gIm5leHQiKSB7CiAgICAgICAgbmV4dCA9IGNoaWxkOwogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBpZiAoIW5leHQgfHwgIW5leHQucmVmKSB7CiAgICAgIG5vZGVbX3hmYV9vYmplY3QuJHRhYkluZGV4XSA9IG5vZGVbX3hmYV9vYmplY3QuJGdldFBhcmVudF0oKVtfeGZhX29iamVjdC4kdGFiSW5kZXhdOwogICAgICByZXR1cm47CiAgICB9CiAgICBjb25zdCByb290ID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0VGVtcGxhdGVSb290XSgpOwogICAgbm9kZVtfeGZhX29iamVjdC4kdGFiSW5kZXhdID0gKytyb290W194ZmFfb2JqZWN0LiR0YWJJbmRleF07CiAgICBjb25zdCByZWYgPSByb290W194ZmFfb2JqZWN0LiRzZWFyY2hOb2RlXShuZXh0LnJlZiwgbm9kZSk7CiAgICBpZiAoIXJlZik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gInB1c2giXSk7CiAgICB0aGlzLmlkID0gYXR0cmlidXRlcy5pZCB8fCAiIjsKICAgIHRoaXMudXNlID0gYXR0cmlidXRlcy51c2UgfHwgIiI7CiAgICB0aGlzLnVzZWhyZWYgPSBhdHRyaWJ1dGVzLnVzZWhyZWYgfHwgIiI7CiAgICB0aGlzLmV4dHJhcyA9IG51bGw7CiAgfQogIFtfeGZhX29iamVjdC4kdG9IVE1MXShhdmFpbGFibGVTcGFjZSkgewogICAgY29uc3QgcGFyZW50ID0gdGhpc1tfeGZhX29iamVjdC4kZ2V0UGFyZW50XSgpOwogICAgY29uc3QgZ3JhbmRwYSA9IHBhcmVudFtfeGZhX29iamVjdC4kZ2V0UGFyZW50XSgpOwogICAgY29uc3QgaHRtbEJ1dHRvbiA9IHsKICAgICAgbmFtZTogImJ1dHRvbiIsCiAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICBpZDogdGhpc1tfeGZhX29iamVjdC4kdWlkXSwKICAgICAgICBjbGFzczogWyJ4ZmFCdXR0b24iXSwKICAgICAgICBzdHlsZToge30KICAgICAgfSwKICAgICAgY2hpbGRyZW46IFtdCiAgICB9OwogICAgZm9yIChjb25zdCBldmVudCBvZiBncmFuZHBhLmV2ZW50LmNoaWxkcmVuKSB7CiAgICAgIGlmIChldmVudC5hY3Rpdml0eSAhPT0gImNsaWNrIiB8fCAhZXZlbnQuc2NyaXB0KSB7CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgY29uc3QganNVUkwgPSAoMCwgX2NvcmVfdXRpbHMucmVjb3ZlckpzVVJMKShldmVudC5zY3JpcHRbX3hmYV9vYmplY3QuJGNvbnRlbnRdKTsKICAgICAgaWYgKCFqc1VSTCkgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IGhyZWYgPSAoMCwgX2h0bWxfdXRpbHMuZml4VVJMKShqc1VSTC51cmwpOwogICAgICBpZiAoIWhyZWYpIHsKICAgICAgICBjb250aW51ZTsKIC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ibGVTcGFjZTsKICAgICAgc3dpdGNoICh0aGlzLnBsYWNlbWVudCkgewogICAgICAgIGNhc2UgImxlZnQiOgogICAgICAgIGNhc2UgInJpZ2h0IjoKICAgICAgICBjYXNlICJpbmxpbmUiOgogICAgICAgICAgd2lkdGggPSB0aGlzLnJlc2VydmUgPD0gMCA/IHdpZHRoIDogdGhpcy5yZXNlcnZlOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAidG9wIjoKICAgICAgICBjYXNlICJib3R0b20iOgogICAgICAgICAgaGVpZ2h0ID0gdGhpcy5yZXNlcnZlIDw9IDAgPyBoZWlnaHQgOiB0aGlzLnJlc2VydmU7CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgICB0aGlzW194ZmFfb2JqZWN0LiRleHRyYV0gPSAoMCwgX2h0bWxfdXRpbHMubGF5b3V0Tm9kZSkodGhpcywgewogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodAogICAgICB9KTsKICAgIH0KICAgIHJldHVybiB0aGlzW194ZmFfb2JqZWN0LiRleHRyYV07CiAgfQogIFtfeGZhX29iamVjdC4kdG9IVE1MXShhdmFpbGFibGVTcGFjZSkgewogICAgaWYgKCF0aGlzLnZhbHVlKSB7CiAgICAgIHJldHVybiBfdXRpbHMuSFRNTFJlc3VsdC5FTVBUWTsKICAgIH0KICAgIHRoaXNbX3hmYV9vYmplY3QuJHB1c2hQYXJhXSgpOwogICAgY29uc3QgdmFsdWUgPSB0aGlzLnZhbHVlW194ZmFfb2JqZWN0LiR0b0hUTUxdKGF2YWlsYWJsZVNwYWNlKS5odG1sOwogICAgaWYgKCF2YWx1ZSkgewogICAgICB0aGlzW194ZmFfb2JqZWN0LiRwb3BQYXJhXSgpOwogICAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuRU1QVFk7CiAgICB9CiAgICBjb25zdCBzYXZlZFJlc2VydmUgPSB0aGlzLnJlc2VydmU7CiAgICBpZiAodGhpcy5yZXNlcnZlIDw9IDApIHsKICAgICAgY29uc3QgewogICAgICAgIHcsCiAgICAgICAgaAogICAgICB9ID0gdGhpc1tfeGZhX29iamVjdC4kZ2V0RXh0cmFdKGF2YWlsYWJsZVNwYWNlKTsKICAgICAgc3dpdGNoICh0aGlzLnBsYWNlbWVudCkgewogICAgICAgIGNhc2UgImxlZnQiOgogICAgICAgIGNhc2UgInJpZ2h0IjoKICAgICAgICBjYXNlICJpbmxpbmUiOgogICAgICAgICAgdGhpcy5yZXNlcnZlID0gdzsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInRvcCI6CiAgICAgICAgY2FzZSAiYm90dG9tIjoKICAgICAgICAgIHRoaXMucmVzZXJ2ZSA9IGg7CiAgICAgICAgICBicmVhazsKICAgICAgfQogICAgfQogICAgY29uc3QgY2hpbGRyZW4gPSBbXTsKICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICJzdHJpbmciKSB7CiAgICAgIGNoaWxkcmVuLnB1c2goewogICAgICAgIG5hbWU6ICIjdGV4dCIsCiAgICAgICAgdmFsdWUKICAgICAgfSk7CiAgICB9IGVsc2UgewogICAgICBjaGlsZHJlbi5wdXNoKHZhbHVlKTsKICAgIH0KICAgIGNvbnN0IHN0eWxlID0gKDAsIF9odG1sX3V0aWxzLnRvU3R5bGUpKHRoaXMsICJmb250IiwgIm1hcmdpbiIsICJ2aXNpYmlsaXR5Iik7CiAgICBzd2l0Y2ggKHRoaXMucGxhY2VtZW50KSB7CiAgICAgIGNhc2UgImxlZnQiOgogICAgICBjYXNlICJyaWdodCI6CiAgICAgICAgaWYgKHRoaXMucmVzZXJ2ZSA+IDApIHsKICAgICAgICAgIHN0eWxlLndpZHRoID0gKDAsIF9odG1sX3V0aWxzLm1lYXN1cmVUb1N0cmluZykodGhpcy5yZXNlcnZlKTsKICAgICAgICB9CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgInRvcCI6CiAgICAgIGNhc2UgImJvdHRvbSI6CiAgICAgICAgaWYgKHRoaXMucmVzZ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KHRoaXMuc3Ryb2tlKSB7CiAgICAgICAgY2FzZSAic29saWQiOgogICAgICAgICAgc3R5bGUuc3R5bGUgPSAic29saWQiOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZGFzaERvdCI6CiAgICAgICAgICBzdHlsZS5zdHlsZSA9ICJkYXNoZWQiOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZGFzaERvdERvdCI6CiAgICAgICAgICBzdHlsZS5zdHlsZSA9ICJkYXNoZWQiOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZGFzaGVkIjoKICAgICAgICAgIHN0eWxlLnN0eWxlID0gImRhc2hlZCI7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJkb3R0ZWQiOgogICAgICAgICAgc3R5bGUuc3R5bGUgPSAiZG90dGVkIjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImVtYm9zc2VkIjoKICAgICAgICAgIHN0eWxlLnN0eWxlID0gInJpZGdlIjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImV0Y2hlZCI6CiAgICAgICAgICBzdHlsZS5zdHlsZSA9ICJncm9vdmUiOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAibG93ZXJlZCI6CiAgICAgICAgICBzdHlsZS5zdHlsZSA9ICJpbnNldCI7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJyYWlzZWQiOgogICAgICAgICAgc3R5bGUuc3R5bGUgPSAib3V0c2V0IjsKICAgICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICByZXR1cm4gc3R5bGU7CiAgfQp9CmNsYXNzIEVuY29kaW5nIGV4dGVuZHMgX3hmYV9vYmplY3QuT3B0aW9uT2JqZWN0IHsKICBjb25zdHJ1Y3RvcihhdHRyaWJ1dGVzKSB7CiAgICBzdXBlcihURU1QTEFURV9OU19JRCwgImVuY29kaW5nIiwgWyJhZGJlLng1MDkucnNhX3NoYTE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MuaCA9PT0gIiIpIHsKICAgICAgbGV0IHdpZHRoID0gbnVsbDsKICAgICAgbGV0IGhlaWdodCA9IG51bGw7CiAgICAgIGxldCB1aVcgPSAwOwogICAgICBsZXQgdWlIID0gMDsKICAgICAgaWYgKHRoaXMudWkuY2hlY2tCdXR0b24pIHsKICAgICAgICB1aVcgPSB1aUggPSB0aGlzLnVpLmNoZWNrQnV0dG9uLnNpemU7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgY29uc3QgewogICAgICAgICAgdywKICAgICAgICAgIGgKICAgICAgICB9ID0gKDAsIF9odG1sX3V0aWxzLmxheW91dE5vZGUpKHRoaXMsIGF2YWlsYWJsZVNwYWNlKTsKICAgICAgICBpZiAodyAhPT0gbnVsbCkgewogICAgICAgICAgdWlXID0gdzsKICAgICAgICAgIHVpSCA9IGg7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHVpSCA9ICgwLCBfZm9udHMuZ2V0TWV0cmljcykodGhpcy5mb250LCB0cnVlKS5saW5lTm9HYXA7CiAgICAgICAgfQogICAgICB9CiAgICAgIGJvcmRlckRpbXMgPSBnZXRCb3JkZXJEaW1zKHRoaXMudWlbX3hmYV9vYmplY3QuJGdldEV4dHJhXSgpKTsKICAgICAgdWlXICs9IGJvcmRlckRpbXMudzsKICAgICAgdWlIICs9IGJvcmRlckRpbXMuaDsKICAgICAgaWYgKHRoaXMuY2FwdGlvbikgewogICAgICAgIGNvbnN0IHsKICAgICAgICAgIHcsCiAgICAgICAgICBoLAogICAgICAgICAgaXNCcm9rZW4KICAgICAgICB9ID0gdGhpcy5jYXB0aW9uW194ZmFfb2JqZWN0LiRnZXRFeHRyYV0oYXZhaWxhYmxlU3BhY2UpOwogICAgICAgIGlmIChpc0Jyb2tlbiAmJiB0aGlzW194ZmFfb2JqZWN0LiRnZXRTdWJmb3JtUGFyZW50XSgpW194ZmFfb2JqZWN0LiRpc1RoZXJlTW9yZVdpZHRoXSgpKSB7CiAgICAgICAgICB0aGlzW194ZmFfb2JqZWN0LiRwb3BQYXJhXSgpOwogICAgICAgICAgcmV0dXJuIF91dGlscy5IVE1MUmVzdWx0LkZBSUxVUkU7CiAgICAgICAgfQogICAgICAgIHdpZHRoID0gdzsKICAgICAgICBoZWlnaHQgPSBoOwogICAgICAgIHN3aXRjaCAodGhpcy5jYXB0aW9uLnBsYWNlbWVudCkgewogICAgICAgICAgY2FzZSAibGVmdCI6CiAgICAgICAgICBjYXNlICJyaWdodCI6CiAgICAgICAgICBjYXNlICJpbmxpbmUiOgogICAgICAgICAgICB3aWR0aCArPSB1aVc7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgY2FzZSAidG9wIjoKICAgICAgICAgIGNhc2UgImJvdHRvbSI6CiAgICAgICAgICAgIGhlaWdodCArPSB1aUg7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgfSBlbHNlIHsKICAgICAgICB3aWR0aCA9IHVpVzsKICAgICAgICBoZWlnaHQgPSB1aUg7CiAgICAgIH0KICAgICAgaWYgKHdpZHRoICYmIHRoaXMudyA9PT0gIiIpIHsKICAgICAgICB3aWR0aCArPSBtYXJnaW5IOwogICAgICAgIHRoaXMudyA9IE1hdGgubWluKHRoaXMubWF4VyA8PSAwID8gSW5maW5pdHkgOiB0aGlzLm1heFcsIHRoaXMubWluVyArIDEgPCB3aWR0aCA/IHdpZHRoIDogdGhpcy5taW5XKTsKICAgICAgfQogICAgICBpZiAoaGVpZ2h0ICYmIHRoaXMuaCA9PT0gIiIpIHsKICAgICAgICBoZWlnaHQgKz0gbWFyZ2luVjsKICAgICAgICB0aGlzLmggPSBNYXRoLm1pbih0aGlzLm1heEggPD0gMCA/IEluZmluaXR5IDogdGhpcy5tYXhILCB0aGlzLm1pbkggKyAxIDwgaGVpZ2h0ID8gaGVpZ2h0IDogdGhpcy5taW5IKTsKICAgICAgfQogICAgfQogICAgdGhpc1tfeGZhX29iamVjdC4kcG9wUGFyYV0oKTsKICAgICgwLCBfaHRtbF91dGl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c1tfeGZhX29iamVjdC4kZ2V0UGFyZW50XSgpOwogICAgY29uc3QgZ3JhbmRwYSA9IHBhcmVudFtfeGZhX29iamVjdC4kZ2V0UGFyZW50XSgpOwogICAgY29uc3QgZ2dyYW5kcGEgPSBncmFuZHBhW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCk7CiAgICBjb25zdCBzdHlsZSA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICBsZXQgcHJvcE5hbWUgPSAiY29sb3IiOwogICAgbGV0IGFsdFByb3BOYW1lID0gcHJvcE5hbWU7CiAgICBpZiAocGFyZW50IGluc3RhbmNlb2YgQm9yZGVyKSB7CiAgICAgIHByb3BOYW1lID0gImJhY2tncm91bmQtY29sb3IiOwogICAgICBhbHRQcm9wTmFtZSA9ICJiYWNrZ3JvdW5kIjsKICAgICAgaWYgKGdncmFuZHBhIGluc3RhbmNlb2YgVWkpIHsKICAgICAgICBzdHlsZS5iYWNrZ3JvdW5kQ29sb3IgPSAid2hpdGUiOwogICAgICB9CiAgICB9CiAgICBpZiAocGFyZW50IGluc3RhbmNlb2YgUmVjdGFuZ2xlIHx8IHBhcmVudCBpbnN0YW5jZW9mIEFyYykgewogICAgICBwcm9wTmFtZSA9IGFsdFByb3BOYW1lID0gImZpbGwiOwogICAgICBzdHlsZS5maWxsID0gIndoaXRlIjsKICAgIH0KICAgIGZvciAoY29uc3QgbmFtZSBvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyh0aGlzKSkgewogICAgICBpZiAobmFtZSA9PT0gImV4dHJhcyIgfHwgbmFtZSA9PT0gImNvbG9yIikgewogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGNvbnN0IG9iaiA9IHRoaXNbbmFtZV07CiAgICAgIGlmICghKG9iaiBpbnN0YW5jZW9mIF94ZmFfb2JqZWN0LlhGQU9iamVjdCkpIHsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCBjb2xvciA9IG9ialtfeGZ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jsKICAgICAgICBzdHlsZS5jb2xvciA9ICJ0cmFuc3BhcmVudCI7CiAgICAgIH0KICAgIH0KICAgIGlmICh0aGlzLmJhc2VsaW5lU2hpZnQpIHsKICAgICAgc3R5bGUudmVydGljYWxBbGlnbiA9ICgwLCBfaHRtbF91dGlscy5tZWFzdXJlVG9TdHJpbmcpKHRoaXMuYmFzZWxpbmVTaGlmdCk7CiAgICB9CiAgICBzdHlsZS5mb250S2VybmluZyA9IHRoaXMua2VybmluZ01vZGUgPT09ICJub25lIiA/ICJub25lIiA6ICJub3JtYWwiOwogICAgc3R5bGUubGV0dGVyU3BhY2luZyA9ICgwLCBfaHRtbF91dGlscy5tZWFzdXJlVG9TdHJpbmcpKHRoaXMubGV0dGVyU3BhY2luZyk7CiAgICBpZiAodGhpcy5saW5lVGhyb3VnaCAhPT0gMCkgewogICAgICBzdHlsZS50ZXh0RGVjb3JhdGlvbiA9ICJsaW5lLXRocm91Z2giOwogICAgICBpZiAodGhpcy5saW5lVGhyb3VnaCA9PT0gMikgewogICAgICAgIHN0eWxlLnRleHREZWNvcmF0aW9uU3R5bGUgPSAiZG91YmxlIjsKICAgICAgfQogICAgfQogICAgaWYgKHRoaXMub3ZlcmxpbmUgIT09IDApIHsKICAgICAgc3R5bGUudGV4dERlY29yYXRpb24gPSAib3ZlcmxpbmUiOwogICAgICBpZiAodGhpcy5vdmVybGluZSA9PT0gMikgewogICAgICAgIHN0eWxlLnRleHREZWNvcmF0aW9uU3R5bGUgPSAiZG91YmxlIjsKICAgICAgfQogICAgfQogICAgc3R5bGUuZm9udFN0eWxlID0gdGhpcy5wb3N0dXJlOwogICAgc3R5bGUuZm9udFNpemUgPSAoMCwgX2h0bWxfdXRpbHMubWVhc3VyZVRvU3RyaW5nKSgwLjk5ICogdGhpcy5zaXplKTsKICAgICgwLCBfaHRtbF91dGlscy5zZXRGb250RmFtaWx5KSh0aGlzLCB0aGlzLCB0aGlzW194ZmFfb2JqZWN0LiRnbG9iYWxEYXRhXS5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lci5sZW5ndGggPiBoZWFkZXIubGVuZ3RoICYmIGhlYWRlci5ldmVyeSgoeCwgaSkgPT4geCA9PT0gYnVmZmVyW2ldKSkgewogICAgICAgICAgdGhpcy5jb250ZW50VHlwZSA9IHR5cGU7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgIH0KICAgICAgaWYgKCF0aGlzLmNvbnRlbnRUeXBlKSB7CiAgICAgICAgcmV0dXJuIF91dGlscy5IVE1MUmVzdWx0LkVNUFRZOwogICAgICB9CiAgICB9CiAgICBjb25zdCBibG9iID0gbmV3IEJsb2IoW2J1ZmZlcl0sIHsKICAgICAgdHlwZTogdGhpcy5jb250ZW50VHlwZQogICAgfSk7CiAgICBsZXQgc3R5bGU7CiAgICBzd2l0Y2ggKHRoaXMuYXNwZWN0KSB7CiAgICAgIGNhc2UgImZpdCI6CiAgICAgIGNhc2UgImFjdHVhbCI6CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgImhlaWdodCI6CiAgICAgICAgc3R5bGUgPSB7CiAgICAgICAgICBoZWlnaHQ6ICIxMDAlIiwKICAgICAgICAgIG9iamVjdEZpdDogImZpbGwiCiAgICAgICAgfTsKICAgICAgICBicmVhazsKICAgICAgY2FzZSAibm9uZSI6CiAgICAgICAgc3R5bGUgPSB7CiAgICAgICAgICB3aWR0aDogIjEwMCUiLAogICAgICAgICAgaGVpZ2h0OiAiMTAwJSIsCiAgICAgICAgICBvYmplY3RGaXQ6ICJmaWxsIgogICAgICAgIH07CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgIndpZHRoIjoKICAgICAgICBzdHlsZSA9IHsKICAgICAgICAgIHdpZHRoOiAiMTAwJSIsCiAgICAgICAgICBvYmplY3RGaXQ6ICJmaWxsIgogICAgICAgIH07CiAgICAgICAgYnJlYWs7CiAgICB9CiAgICBjb25zdCBwYXJlbnQgPSB0aGlzW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCk7CiAgICByZXR1cm4gX3V0aWxzLkh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gfQogICAgc3R5bGUuc3Ryb2tlV2lkdGggPSAoMCwgX2h0bWxfdXRpbHMubWVhc3VyZVRvU3RyaW5nKShlZGdlLnByZXNlbmNlID09PSAidmlzaWJsZSIgPyBlZGdlLnRoaWNrbmVzcyA6IDApOwogICAgc3R5bGUuc3Ryb2tlID0gZWRnZVN0eWxlLmNvbG9yOwogICAgY29uc3QgY29ybmVyID0gdGhpcy5jb3JuZXIuY2hpbGRyZW4ubGVuZ3RoID8gdGhpcy5jb3JuZXIuY2hpbGRyZW5bMF0gOiBuZXcgQ29ybmVyKHt9KTsKICAgIGNvbnN0IGNvcm5lclN0eWxlID0gY29ybmVyW194ZmFfb2JqZWN0LiR0b1N0eWxlXSgpOwogICAgY29uc3QgcmVjdCA9IHsKICAgICAgbmFtZTogInJlY3QiLAogICAgICBhdHRyaWJ1dGVzOiB7CiAgICAgICAgeG1sbnM6IFNWR19OUywKICAgICAgICB3aWR0aDogIjEwMCUiLAogICAgICAgIGhlaWdodDogIjEwMCUiLAogICAgICAgIHg6IDAsCiAgICAgICAgeTogMCwKICAgICAgICByeDogY29ybmVyU3R5bGUucmFkaXVzLAogICAgICAgIHJ5OiBjb3JuZXJTdHlsZS5yYWRpdXMsCiAgICAgICAgc3R5bGUKICAgICAgfQogICAgfTsKICAgIGNvbnN0IHN2ZyA9IHsKICAgICAgbmFtZTogInN2ZyIsCiAgICAgIGNoaWxkcmVuOiBbcmVjdF0sCiAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICB4bWxuczogU1ZHX05TLAogICAgICAgIHN0eWxlOiB7CiAgICAgICAgICBvdmVyZmxvdzogInZpc2libGUiCiAgICAgICAgfSwKICAgICAgICB3aWR0aDogIjEwMCUiLAogICAgICAgIGhlaWdodDogIjEwMCUiCiAgICAgIH0KICAgIH07CiAgICBjb25zdCBwYXJlbnQgPSB0aGlzW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKClbX3hmYV9vYmplY3QuJGdldFBhcmVudF0oKTsKICAg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b1BhZ2VzXSgpIHsKICAgIGlmICghdGhpcy5zdWJmb3JtLmNoaWxkcmVuLmxlbmd0aCkgewogICAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuc3VjY2Vzcyh7CiAgICAgICAgbmFtZTogImRpdiIsCiAgICAgICAgY2hpbGRyZW46IFtdCiAgICAgIH0pOwogICAgfQogICAgdGhpc1tfeGZhX29iamVjdC4kZXh0cmFdID0gewogICAgICBvdmVyZmxvd05vZGU6IG51bGwsCiAgICAgIGZpcnN0VW5zcGxpdHRhYmxlOiBudWxsLAogICAgICBjdXJyZW50Q29udGVudEFyZWE6IG51bGwsCiAgICAgIGN1cnJlbnRQYWdlQXJlYTogbnVsbCwKICAgICAgbm9MYXlvdXRGYWlsdXJlOiBmYWxzZSwKICAgICAgcGFnZU51bWJlcjogMSwKICAgICAgcGFnZVBvc2l0aW9uOiAiZmlyc3QiLAogICAgICBvZGRPckV2ZW46ICJvZGQiLAogICAgICBibGFua09yTm90Qmxhbms6ICJub25CbGFuayIsCiAgICAgIHBhcmFTdGFjazogW10KICAgIH07CiAgICBjb25zdCByb290ID0gdGhpcy5zdWJmb3JtLmNoaWxkcmVuWzBdOwogICAgcm9vdC5wYWdlU2V0W194ZmFfb2JqZWN0LiRjbGVhblBhZ2VdKCk7CiAgICBjb25zdCBwYWdlQXJlYXMgPSByb290LnBhZ2VTZXQucGFnZUFyZWEuY2hpbGRyZW47CiAgICBjb25zdCBtYWluSHRtbCA9IHsKICAgICAgbmFtZTogImRpdiIsCiAgICAgIGNoaWxkcmVuOiBbXQogICAgfTsKICAgIGxldCBwYWdlQXJlYSA9IG51bGw7CiAgICBsZXQgYnJlYWtCZWZvcmUgPSBudWxsOwogICAgbGV0IGJyZWFrQmVmb3JlVGFyZ2V0ID0gbnVsbDsKICAgIGlmIChyb290LmJyZWFrQmVmb3JlLmNoaWxkcmVuLmxlbmd0aCA+PSAxKSB7CiAgICAgIGJyZWFrQmVmb3JlID0gcm9vdC5icmVha0Jl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Y2xhc3MuaW5jbHVkZXMoInhmYUNvbnRlbnRhcmVhIikpOwogICAgICBoYXNTb21ldGhpbmcgPSBmYWxzZTsKICAgICAgdGhpc1tfeGZhX29iamVjdC4kZXh0cmFdLmZpcnN0VW5zcGxpdHRhYmxlID0gbnVsbDsKICAgICAgdGhpc1tfeGZhX29iamVjdC4kZXh0cmFdLm5vTGF5b3V0RmFpbHVyZSA9IGZhbHNlOwogICAgICBjb25zdCBmbHVzaCA9IGluZGV4ID0+IHsKICAgICAgICBjb25zdCBodG1sID0gcm9vdFtfeGZhX29iamVjdC4kZmx1c2hIVE1MXSgpOwogICAgICAgIGlmIChodG1sKSB7CiAgICAgICAgICBoYXNTb21ldGhpbmcgPSBoYXNTb21ldGhpbmcgfHwgaHRtbC5jaGlsZHJlbiAmJiBodG1sLmNoaWxkcmVuLmxlbmd0aCAhPT0gMDsKICAgICAgICAgIGh0bWxDb250ZW50QXJlYXNbaW5kZXhdLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgICAgICAgfQogICAgICB9OwogICAgICBmb3IgKGxldCBpID0gc3RhcnRJbmRleCwgaWkgPSBjb250ZW50QXJlYXMubGVuZ3RoOyBpIDwgaWk7IGkrKykgewogICAgICAgIGNvbnN0IGNvbnRlbnRBcmVhID0gdGhpc1tfeGZhX29iamVjdC4kZXh0cmFdLmN1cnJlbnRDb250ZW50QXJlYSA9IGNvbnRlbnRBcmVhc1tpXTsKICAgICAgICBjb25zdCBzcGFjZSA9IHsKICAgICAgICAgIHdpZHRoOiBjb250ZW50QXJlYS53LAogICAgICAgICAgaGVpZ2h0OiBjb250ZW50QXJlYS5oCiAgICAgICAgfTsKICAgICAgICBzdGFydEluZGV4ID0gMDsKICAgICAgICBpZiAobGVhZGVyKSB7CiAgICAgICAgICBodG1sQ29udGVudEFyZWFzW2ldLmNoaWxkcmVuLnB1c2gobGVhZGVyW194ZmFfb2JqZWN0LiR0b0hUTUxdKHNwYWNlKS5odG1sKTsKICAgICAgICAgIGxlYWRlciA9IG51bGw7CiAgICAgICAgfQogICAgICAgIGlmICh0cmFpbGVyKSB7CiAgICAgICAgICBodG1sQ29udGVudEFyZWFzW2ldLmNoaWxkcmVuLnB1c2godHJhaWxlcltfeGZhX29iamVjdC4kdG9IVE1MXShzcGFjZSkuaHRtbCk7CiAgICAgICAgICB0cmFpbGVyID0gbnVsbDsKICAgICAgICB9CiAgICAgICAgY29uc3QgaHRtbCA9IHJvb3RbX3hmYV9vYmplY3QuJHRvSFRNTF0oc3BhY2UpOwogICAgICAgIGlmIChodG1sLnN1Y2Nlc3MpIHsKICAgICAgICAgIGlmIChodG1sLmh0bWwpIHsKICAgICAgICAgICAgaGFzU29tZXRoaW5nID0gaGFzU29tZXRoaW5nIHx8IGh0bWwuaHRtbC5jaGlsZHJlbiAmJiBodG1sLmh0bWwuY2hpbGRyZW4ubGVuZ3RoICE9PSAwOwogICAgICAgICAgICBodG1sQ29udGVudEFyZWFzW2ldLmNoaWxkcmVuLnB1c2goaHRtbC5odG1sKTsKICAgICAgICAgIH0gZWxzZSBpZiAoIWhhc1NvbWV0aGluZyAmJiBtYWluSHRtbC5jaGlsZHJlbi5sZW5ndGggPiAxKSB7CiAgICAgICAgICAgIG1haW5IdG1sLmNoaWxkcmVuLnBvcCgpOwogICAgICAgICAgfQogICAgICAgICAgcmV0dXJuIG1haW5IdG1sOwogICAgICAgIH0KICAgICAgICBpZiAoaHRtbC5pc0JyZWFrKCkpIHsKICAgICAgICAgIGNvbnN0IG5vZGUgPSBodG1sLmJyZWFrTm9kZTsKICAgICAgICAgIGZsdXNoKGkpOwogICAgICAgICAgaWYgKG5vZGUudGFyZ2V0VHlwZSA9PT0gImF1dG8iKSB7CiAgICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG5vZGUubGVhZGVyKSB7CiAgICAgICAgICAgIGxlYWRlciA9IHRoaXNbX3hmYV9vYmplY3QuJHNlYXJjaE5vZGVdKG5vZGUubGVhZGVyLCBub2RlW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCkpOwogICAgICAgICAgICBsZWFkZXIgPSBsZWFkZXIgPyBsZWFkZXJbMF0gOiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG5vZGUudHJhaWxlcikgewogICAgICAgICAgICB0cmFpbGVyID0gdGhpc1tfeGZhX29iamVjdC4kc2VhcmNoTm9kZV0obm9kZS50cmFpbGVyLCBub2RlW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCkpOwogICAgICAgICAgICB0cmFpbGVyID0gdHJhaWxlciA/IHRyYWlsZXJbMF0gOiBudWxsOwogICAgICAgICAgfQogICAgICAgICAgaWYgKG5vZGUudGFyZ2V0VHlwZSA9PT0gInBhZ2VBcmVhIikgewogICAgICAgICAgICB0YXJnZXRQYWdlQXJlYSA9IG5vZGVbX3hmYV9vYmplY3QuJGV4dHJhXS50YXJnZXQ7CiAgICAgICAgICAgIGkgPSBJbmZpbml0eTsKICAgICAgICAgIH0gZWxzZSBpZiAoIW5vZGVbX3hmYV9vYmplY3QuJGV4dHJhXS50YXJnZXQpIHsKICAgICAgICAgICAgaSA9IG5vZGVbX3hmYV9vYmplY3QuJGV4dHJhXS5pbmRleDsKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHRhcmdldFBhZ2VBcmVhID0gbm9kZVtfeGZhX29iamVjdC4kZXh0cmFdLnRhcmdldDsKICAgICAgICAgICAgc3RhcnRJbmRleCA9IG5vZGVbX3hmYV9vYmplY3QuJGV4dHJhXS5pbmRleCArIDE7CiAgICAgICAgICAgIGkgPSBJbmZpbml0eTsKICAgICAgICAgIH0KICAgICAgICAgIGNvbnRpbnVlOwogICAgICAgIH0KICAgICAgICBpZiAodGhpc1tfeGZhX29iamVjdC4kZXh0cmFdLm92ZXJmbG93Tm9kZSkgewogICAgICAgICAgY29uc3Qgbm9kZSA9IHRoaXNbX3hmYV9vYmplY3QuJGV4dHJhXS5vdmVyZmxvd05vZGU7CiAgICAgICAgICB0aGlzW194ZmFfb2JqZWN0LiRleHRyYV0ub3ZlcmZsb3dOb2RlID0gbnVsbDsKICAgICAgICAgIGNvbnN0IG92ZXJmbG93RXh0cmEgPSBub2RlW194ZmFfb2JqZWN0LiRnZXRFeHRyYV0oKTsKICAgICAgICAgIGNvbnN0IHRhcmdldCA9IG92ZXJmbG93RXh0cmEudGFyZ2V0OwogICAgICAgICAgb3ZlcmZsb3dFeHRyYS5hZGRMZWFkZXIgPSBvdmVyZmxvd0V4dHJhLmxlYWRlciAhPT0gbnVsbDsKICAgICAgICAgIG92ZXJmbG93RXh0cmEuYWRkVHJhaWxlciA9IG92ZXJmbG93RXh0cmEudHJhaWxlciAhPT0gbnVsbDsKICAgICAgICAgIGZsdXNoKGkpOwogICAgICAgICAgY29uc3QgY3VycmVudEluZGV4ID0gaTsKICAgICAgICAgIGkgPSBJbmZpbml0eTsKICAgICAgICAgIGlmICh0YXJnZXQgaW5zdGFuY2VvZiBQYWdlQXJlYSkgewogICAgICAgICAgICB0YXJnZXRQYWdlQXJlYSA9IHRhcmdldDsKICAgICAgICAgIH0gZWxzZSBpZiAodGFyZ2V0IGluc3RhbmNlb2YgQ29udGVudEFyZWEpIHsKICAgICAgICAgICAgY29uc3QgaW5kZXggPSBjb250ZW50QXJlYXMuaW5kZXhPZih0YXJnZXQpOwogICAgICAgICAgICBpZiAoaW5kZXggIT09IC0xKSB7CiAgICAgICAgICAgICAgaWYgKGluZGV4ID4gY3VycmVudEluZGV4KSB7CiAgICAgICAgICAgICAgICBpID0gaW5kZXggLSAxOwogICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBzdGFydEluZGV4ID0gaW5kZXg7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgIHRhcmdldFBhZ2VBcmVhID0gdGFyZ2V0W194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCk7CiAgICAgICAgICAgICAgc3RhcnRJbmRleCA9IHRh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3hmYV9vYmplY3QuJGdldEV4dHJhXSgpIHsKICAgIGlmICh0eXBlb2YgdGhpc1tfeGZhX29iamVjdC4kY29udGVudF0gPT09ICJzdHJpbmciKSB7CiAgICAgIHJldHVybiB0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XS5zcGxpdCgvW1x1MjAyOVx1MjAyOFxuXS8pLnJlZHVjZSgoYWNjLCBsaW5lKSA9PiB7CiAgICAgICAgaWYgKGxpbmUpIHsKICAgICAgICAgIGFjYy5wdXNoKGxpbmUpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gYWNjOwogICAgICB9LCBbXSkuam9pbigiXG4iKTsKICAgIH0KICAgIHJldHVybiB0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XVtfeGZhX29iamVjdC4kdGV4dF0oKTsKICB9CiAgW194ZmFfb2JqZWN0LiR0b0hUTUxdKGF2YWlsYWJsZVNwYWNlKSB7CiAgICBpZiAodHlwZW9mIHRoaXNbX3hmYV9vYmplY3QuJGNvbnRlbnRdID09PSAic3RyaW5nIikgewogICAgICBjb25zdCBodG1sID0gdmFsdWVUb0h0bWwodGhpc1tfeGZhX29iamVjdC4kY29udGVudF0pLmh0bWw7CiAgICAgIGlmICh0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XS5pbmNsdWRlcygiXHUyMDI5IikpIHsKICAgICAgICBodG1sLm5hbWUgPSAiZGl2IjsKICAgICAgICBodG1sLmNoaWxkcmVuID0gW107CiAgICAgICAgdGhpc1tfeGZhX29iamVjdC4kY29udGVudF0uc3BsaXQoIlx1MjAyOSIpLm1hcChwYXJhID0+IHBhcmEuc3BsaXQoL1tcdTIwMjhcbl0vKS5yZWR1Y2UoKGFjYywgbGluZSkgPT4gewogICAgICAgICAgYWNjLnB1c2goewogICAgICAgICAgICBuYW1lOiAic3BhbiIsCiAgICAgICAgICAgIHZhbHVlOiBsaW5lCiAgICAgICAgICB9LCB7CiAgICAgICAgICAgIG5hbWU6ICJiciIKICAgICAgICAgIH0pOwogICAgICAgICAgcmV0dXJuIGFjYzsKICAgICAgICB9LCBbXSkpLmZvckVhY2gobGluZXMgPT4gewogICAgICAgICAgaHRtbC5jaGlsZHJlbi5wdXNoKHsKICAgICAgICAgICAgbmFtZTogInAiLAogICAgICAgICAgICBjaGlsZHJlbjogbGluZXMKICAgICAgICAgIH0pOwogICAgICAgIH0pOwogICAgICB9IGVsc2UgaWYgKC9bXHUyMDI4XG5dLy50ZXN0KHRoaXNbX3hmYV9vYmplY3QuJGNvbnRlbnRdKSkgewogICAgICAgIGh0bWwubmFtZSA9ICJkaXYiOwogICAgICAgIGh0bWwuY2hpbGRyZW4gPSBbXTsKICAgICAgICB0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XS5zcGxpdCgvW1x1MjAyOFxuXS8pLmZvckVhY2gobGluZSA9PiB7CiAgICAgICAgICBodG1sLmNoaWxkcmVuLnB1c2goewogICAgICAgICAgICBuYW1lOiAic3BhbiIsCiAgICAgICAgICAgIHZhbHVlOiBsaW5lCiAgICAgICAgICB9LCB7CiAgICAgICAgICAgIG5hbWU6ICJiciIKICAgICAgICAgIH0pOwogICAgICAgIH0pOwogICAgICB9CiAgICAgIHJldHVybiBfdXRpbHMuSFRNTFJlc3VsdC5zdWNjZXNzKGh0bWwpOwogICAgfQogICAgcmV0dXJuIHRoaXNbX3hmYV9vYmplY3QuJGNvbnRlbnRdW194ZmFfb2JqZWN0LiR0b0hUTUxdKGF2YWlsYWJsZVNwYWNlKTsKICB9Cn0KZXhwb3J0cy5UZXh0ID0gVGV4dDsKY2xhc3MgVGV4dEVkaXQgZXh0ZW5kcyBfeGZhX29iamVjdC5YRkFPYmplY3QgewogIGNvbnN0cnVjdG9yKGF0dHJpYnV0ZXMpIHsKICAgIHN1cGVyKFRFTVBMQVRFX05TX0lELCAidGV4dEVkaXQiLCB0cnVlKTsKICAgIHRoaXMuYWxsb3dSaWNoVGV4dCA9ICgwLCBfdXRpbHMuZ2V0SW50ZWdlcikoewogICAgICBkYXR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eGZhX29iamVjdC4kZ2V0UGFyZW50XSgpW194ZmFfb2JqZWN0LiRnZXRQYXJlbnRdKCk7CiAgICBpZiAodGhpcy5tdWx0aUxpbmUgPT09ICIiKSB7CiAgICAgIHRoaXMubXVsdGlMaW5lID0gZmllbGQgaW5zdGFuY2VvZiBEcmF3ID8gMSA6IDA7CiAgICB9CiAgICBpZiAodGhpcy5tdWx0aUxpbmUgPT09IDEpIHsKICAgICAgaHRtbCA9IHsKICAgICAgICBuYW1lOiAidGV4dGFyZWEiLAogICAgICAgIGF0dHJpYnV0ZXM6IHsKICAgICAgICAgIGRhdGFJZDogZmllbGRbX3hmYV9vYmplY3QuJGRhdGFdICYmIGZpZWxkW194ZmFfb2JqZWN0LiRkYXRhXVtfeGZhX29iamVjdC4kdWlkXSB8fCBmaWVsZFtfeGZhX29iamVjdC4kdWlkXSwKICAgICAgICAgIGZpZWxkSWQ6IGZpZWxkW194ZmFfb2JqZWN0LiR1aWRdLAogICAgICAgICAgY2xhc3M6IFsieGZhVGV4dGZpZWxkIl0sCiAgICAgICAgICBzdHlsZSwKICAgICAgICAgICJhcmlhLWxhYmVsIjogYXJpYUxhYmVsKGZpZWxkKSwKICAgICAgICAgICJhcmlhLXJlcXVpcmVkIjogZmFsc2UKICAgICAgICB9CiAgICAgIH07CiAgICB9IGVsc2UgewogICAgICBodG1sID0gewogICAgICAgIG5hbWU6ICJpbnB1dCIsCiAgICAgICAgYXR0cmlidXRlczogewogICAgICAgICAgdHlwZTogInRleHQiLAogICAgICAgICAgZGF0YUlkOiBmaWVsZFtfeGZhX29iamVjdC4kZGF0YV0gJiYgZmllbGRbX3hmYV9vYmplY3QuJGRhdGFdW194ZmFfb2JqZWN0LiR1aWRdIHx8IGZpZWxkW194ZmFfb2JqZWN0LiR1aWRdLAogICAgICAgICAgZmllbGRJZDogZmllbGRbX3hmYV9vYmplY3QuJHVpZF0sCiAgICAgICAgICBjbGFzczogWyJ4ZmFUZXh0ZmllbGQiXSwKICAgICAgICAg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iBuZXcgRW5jcnlwdGlvbk1ldGhvZChhdHRycyk7CiAgfQogIHN0YXRpYyBlbmNyeXB0aW9uTWV0aG9kcyhhdHRycykgewogICAgcmV0dXJuIG5ldyBFbmNyeXB0aW9uTWV0aG9kcyhhdHRycyk7CiAgfQogIHN0YXRpYyBldmVudChhdHRycykgewogICAgcmV0dXJuIG5ldyBFdmVudChhdHRycyk7CiAgfQogIHN0YXRpYyBleERhdGEoYXR0cnMpIHsKICAgIHJldHVybiBuZXcgRXhEYXRhKGF0dHJzKTsKICB9CiAgc3RhdGljIGV4T2JqZWN0KGF0dHJzKSB7CiAgICByZXR1cm4gbmV3IEV4T2JqZWN0KGF0dHJzKTsKICB9CiAgc3RhdGljIGV4Y2xHcm91cChhdHRycykgewogICAgcmV0dXJuIG5ldyBFeGNsR3JvdXAoYXR0cnMpOwogIH0KICBzdGF0aWMgZXhlY3V0ZShhdHRycykgewogICAgcmV0dXJuIG5ldyBFeGVjdXRlKGF0dHJzKTsKICB9CiAgc3RhdGljIGV4dHJhcyhhdHRycykgewogICAgcmV0dXJuIG5ldyBFeHRyYXMoYXR0cnMpOwogIH0KICBzdGF0aWMgZmllbGQoYXR0cnMpIHsKICAgIHJldHVybiBuZXcgRmllbGQoYXR0cnMpOwogIH0KICBzdGF0aWMgZmlsbChhdHRycykgewogICAgcmV0dXJuIG5ldyBGaWxsKGF0dHJzKTsKICB9CiAgc3RhdGljIGZpbHRlcihhdHRycykgewogICAgcmV0dXJuIG5ldyBGaWx0ZXIoYXR0cnMpOwogIH0KICBzdGF0aWMgZmxvYXQoYXR0cnMpIHsKICAgIHJldHVybiBuZXcgRmxvYXQoYXR0cnMpOwogIH0KICBzdGF0aWMgZm9udChhdHRycykgewogICAgcmV0dXJuIG5ldyBGb250KGF0dHJzKTsKICB9CiAgc3RhdGljIGZvcm1hdChhdHRycykgewogICAgcmV0dXJuIG5ldyBGb3JtYXQoYXR0cnMpOwogIH0KICBzdGF0aWMgaGFuZGxlcihhdHRycykgew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Eud2lkdGggPSBNYXRoLm1heChleHRyYS53aWR0aCwgZXh0cmEuY3VycmVudFdpZHRoKTsKICAgICAgYnJlYWs7CiAgICBjYXNlICJybC1yb3ciOgogICAgY2FzZSAicm93IjoKICAgICAgewogICAgICAgIGV4dHJhLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgICAgICAgZXh0cmEud2lkdGggKz0gdzsKICAgICAgICBleHRyYS5oZWlnaHQgPSBNYXRoLm1heChleHRyYS5oZWlnaHQsIGgpOwogICAgICAgIGNvbnN0IGhlaWdodCA9ICgwLCBfaHRtbF91dGlscy5tZWFzdXJlVG9TdHJpbmcpKGV4dHJhLmhlaWdodCk7CiAgICAgICAgZm9yIChjb25zdCBjaGlsZCBvZiBleHRyYS5jaGlsZHJlbikgewogICAgICAgICAgY2hpbGQuYXR0cmlidXRlcy5zdHlsZS5oZWlnaHQgPSBoZWlnaHQ7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICB9CiAgICBjYXNlICJ0YWJsZSI6CiAgICAgIHsKICAgICAgICBleHRyYS53aWR0aCA9IE1hdGgubWluKGF2YWlsYWJsZVNwYWNlLndpZHRoLCBNYXRoLm1heChleHRyYS53aWR0aCwgdykpOwogICAgICAgIGV4dHJhLmhlaWdodCArPSBoOwogICAgICAgIGV4dHJhLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIGNhc2UgInRiIjoKICAgICAgewogICAgICAgIGV4dHJhLndpZHRoID0gTWF0aC5taW4oYXZhaWxhYmxlU3BhY2Uud2lkdGgsIE1hdGgubWF4KGV4dHJhLndpZHRoLCB3KSk7CiAgICAgICAgZXh0cmEuaGVpZ2h0ICs9IGg7CiAgICAgICAgZXh0cmEuY2hpbGRyZW4ucHVzaChodG1sKTsKICAgICAgICBicmVhazsKICAgICAgfQogIH0KfQpmdW5jdGlvbiBnZXRBdmFpbGFibGVTcGFjZShub2RlKSB7CiAgY29uc3QgYXZhaWxhYmxl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LnJlZHVjZSgoYSwgeCkgPT4gYSArIHgpOwogICAgICByZXR1cm4gewogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodDogYXZhaWxhYmxlU3BhY2UuaGVpZ2h0IC0gbWFyZ2luSAogICAgICB9OwogICAgY2FzZSAidGFibGUiOgogICAgY2FzZSAidGIiOgogICAgICByZXR1cm4gewogICAgICAgIHdpZHRoOiBhdmFpbGFibGVTcGFjZS53aWR0aCAtIG1hcmdpbkgsCiAgICAgICAgaGVpZ2h0OiBhdmFpbGFibGVTcGFjZS5oZWlnaHQgLSBtYXJnaW5WIC0gbm9kZVtfeGZhX29iamVjdC4kZXh0cmFdLmhlaWdodAogICAgICB9OwogICAgY2FzZSAicG9zaXRpb24iOgogICAgZGVmYXVsdDoKICAgICAgcmV0dXJuIGF2YWlsYWJsZVNwYWNlOwogIH0KfQpmdW5jdGlvbiBnZXRUcmFuc2Zvcm1lZEJCb3gobm9kZSkgewogIGxldCB3ID0gbm9kZS53ID09PSAiIiA/IE5hTiA6IG5vZGUudzsKICBsZXQgaCA9IG5vZGUuaCA9PT0gIiIgPyBOYU4gOiBub2RlLmg7CiAgbGV0IFtjZW50ZXJYLCBjZW50ZXJZXSA9IFswLCAwXTsKICBzd2l0Y2ggKG5vZGUuYW5jaG9yVHlwZSB8fCAiIikgewogICAgY2FzZSAiYm90dG9tQ2VudGVyIjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gW3cgLyAyLCBoXTsKICAgICAgYnJlYWs7CiAgICBjYXNlICJib3R0b21MZWZ0IjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gWzAsIGhdOwogICAgICBicmVhazsKICAgIGNhc2UgImJvdHRvbVJpZ2h0IjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gW3csIGhdOwogICAgICBicmVhazsKICAgIGNhc2UgIm1pZGRsZUNlbnRlciI6CiAgICAgIFtjZW50ZXJYLCBjZW50ZXJZXSA9IFt3IC8gMiwgaCAvIDJdOwogICAgICBicmVhazsKICAgIGNhc2UgIm1pZGRsZUxlZnQiOgogICAgICBbY2VudGVyWCwgY2VudGVyWV0gPSBbMCwgaCAvIDJdOwogICAgICBicmVhazsKICAgIGNhc2UgIm1pZGRsZVJpZ2h0IjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gW3csIGggLyAyXTsKICAgICAgYnJlYWs7CiAgICBjYXNlICJ0b3BDZW50ZXIiOgogICAgICBbY2VudGVyWCwgY2VudGVyWV0gPSBbdyAvIDIsIDBdOwogICAgICBicmVhazsKICAgIGNhc2UgInRvcFJpZ2h0IjoKICAgICAgW2NlbnRlclgsIGNlbnRlclldID0gW3csIDBdOwogICAgICBicmVhazsKICB9CiAgbGV0IHgsIHk7CiAgc3dpdGNoIChub2RlLnJvdGF0ZSB8fCAwKSB7CiAgICBjYXNlIDA6CiAgICAgIFt4LCB5XSA9IFstY2VudGVyWCwgLWNlbnRlclldOwogICAgICBicmVhazsKICAgIGNhc2UgOTA6CiAgICAgIFt4LCB5XSA9IFstY2VudGVyWSwgY2VudGVyWF07CiAgICAgIFt3LCBoXSA9IFtoLCAtd107CiAgICAgIGJyZWFrOwogICAgY2FzZSAxODA6CiAgICAgIFt4LCB5XSA9IFtjZW50ZXJYLCBjZW50ZXJZXTsKICAgICAgW3csIGhdID0gWy13LCAtaF07CiAgICAgIGJyZWFrOwogICAgY2FzZSAyNzA6CiAgICAgIFt4LCB5XSA9IFtjZW50ZXJZLCAtY2VudGVyWF07CiAgICAgIFt3LCBoXSA9IFstaCwgd107CiAgICAgIGJyZWFrOwogIH0KICByZXR1cm4gW25vZGUueCArIHggKyBNYXRoLm1pbigwLCB3KSwgbm9kZS55ICsgeSArIE1hdGgubWluKDAsIGgpLCBNYXRoLmFicyh3KSwgTWF0aC5hYnMoaCldOwp9CmZ1bmN0aW9uIGNoZWNrRGltZW5zaW9ucyhub2RlLCBzcGFjZSkgewogIGlmIChub2RlW194ZmFfb2JqZWN0LiRnZXRUZW1wbGF0ZVJvb3R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0dXJuIHNwYWNlLmhlaWdodCA+IEVSUk9SOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgIH0KICAgICAgICAgIHJldHVybiBzcGFjZS53aWR0aCA+IEVSUk9SOwogICAgICAgIH0KICAgICAgICBpZiAobm9kZS53ICE9PSAiIikgewogICAgICAgICAgcmV0dXJuIE1hdGgucm91bmQodyAtIHNwYWNlLndpZHRoKSA8PSBFUlJPUjsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHNwYWNlLndpZHRoID4gRVJST1I7CiAgICAgIH0KICAgICAgaWYgKG5vZGVbX3hmYV9vYmplY3QuJGdldFRlbXBsYXRlUm9vdF0oKVtfeGZhX29iamVjdC4kZXh0cmFdLm5vTGF5b3V0RmFpbHVyZSkgewogICAgICAgIHJldHVybiB0cnVlOwogICAgICB9CiAgICAgIGlmIChub2RlLmggIT09ICIiICYmIE1hdGgucm91bmQoaCAtIHNwYWNlLmhlaWdodCkgPiBFUlJPUikgewogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfQogICAgICBpZiAobm9kZS53ID09PSAiIiB8fCBNYXRoLnJvdW5kKHcgLSBzcGFjZS53aWR0aCkgPD0gRVJST1IpIHsKICAgICAgICByZXR1cm4gc3BhY2UuaGVpZ2h0ID4gRVJST1I7CiAgICAgIH0KICAgICAgaWYgKHBhcmVudFtfeGZhX29iamVjdC4kaXNUaGVyZU1vcmVXaWR0aF0oKSkgewogICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgfQogICAgICByZXR1cm4gc3BhY2UuaGVpZ2h0ID4gRVJST1I7CiAgICBjYXNlICJ0YWJsZSI6CiAgICBjYXNlICJ0YiI6CiAgICAgIGlmIChub2RlW194ZmFfb2JqZWN0LiRnZXRUZW1wbGF0ZVJvb3RdKClbX3hmYV9vYmplY3QuJGV4dHJhXS5ub0xheW91dEZhaWx1cmUpIHsKICAgICAgICByZXR1cm4gdHJ1ZTsKICAgICAgfQogICAgICBpZ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IT09ICJwb3NpdGlvbiIpIHsKICAgICAgcmV0dXJuOwogICAgfQogICAgc3R5bGUucG9zaXRpb24gPSAiYWJzb2x1dGUiOwogICAgc3R5bGUubGVmdCA9IG1lYXN1cmVUb1N0cmluZyhub2RlLngpOwogICAgc3R5bGUudG9wID0gbWVhc3VyZVRvU3RyaW5nKG5vZGUueSk7CiAgfSwKICByb3RhdGUobm9kZSwgc3R5bGUpIHsKICAgIGlmIChub2RlLnJvdGF0ZSkgewogICAgICBpZiAoISgidHJhbnNmb3JtIiBpbiBzdHlsZSkpIHsKICAgICAgICBzdHlsZS50cmFuc2Zvcm0gPSAiIjsKICAgICAgfQogICAgICBzdHlsZS50cmFuc2Zvcm0gKz0gYHJvdGF0ZSgtJHtub2RlLnJvdGF0ZX1kZWcpYDsKICAgICAgc3R5bGUudHJhbnNmb3JtT3JpZ2luID0gInRvcCBsZWZ0IjsKICAgIH0KICB9LAogIHByZXNlbmNlKG5vZGUsIHN0eWxlKSB7CiAgICBzd2l0Y2ggKG5vZGUucHJlc2VuY2UpIHsKICAgICAgY2FzZSAiaW52aXNpYmxlIjoKICAgICAgICBzdHlsZS52aXNpYmlsaXR5ID0gImhpZGRlbiI7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgImhpZGRlbiI6CiAgICAgIGNhc2UgImluYWN0aXZlIjoKICAgICAgICBzdHlsZS5kaXNwbGF5ID0gIm5vbmUiOwogICAgICAgIGJyZWFrOwogICAgfQogIH0sCiAgaEFsaWduKG5vZGUsIHN0eWxlKSB7CiAgICBpZiAobm9kZVtfeGZhX29iamVjdC4kbm9kZU5hbWVdID09PSAicGFyYSIpIHsKICAgICAgc3dpdGNoIChub2RlLmhBbGlnbikgewogICAgICAgIGNhc2UgImp1c3RpZnlBbGwiOgogICAgICAgICAgc3R5bGUudGV4dEFsaWduID0gImp1c3RpZnktYWxsIjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJhZGl4IjoKICAgICAgICAgIHN0eWxlLnRleHRBbGlnbiA9ICJsZWZ0IjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICBzdHlsZS50ZXh0QWxpZ24gPSBub2RlLmhBbGlnbjsKICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgc3dpdGNoIChub2RlLmhBbGlnbikgewogICAgICAgIGNhc2UgImxlZnQiOgogICAgICAgICAgc3R5bGUuYWxpZ25TZWxmID0gInN0YXJ0IjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImNlbnRlciI6CiAgICAgICAgICBzdHlsZS5hbGlnblNlbGYgPSAiY2VudGVyIjsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgInJpZ2h0IjoKICAgICAgICAgIHN0eWxlLmFsaWduU2VsZiA9ICJlbmQiOwogICAgICAgICAgYnJlYWs7CiAgICAgIH0KICAgIH0KICB9LAogIG1hcmdpbihub2RlLCBzdHlsZSkgewogICAgaWYgKG5vZGUubWFyZ2luKSB7CiAgICAgIHN0eWxlLm1hcmdpbiA9IG5vZGUubWFyZ2luW194ZmFfb2JqZWN0LiR0b1N0eWxlXSgpLm1hcmdpbjsKICAgIH0KICB9Cn07CmZ1bmN0aW9uIHNldE1pbk1heERpbWVuc2lvbnMobm9kZSwgc3R5bGUpIHsKICBjb25zdCBwYXJlbnQgPSBub2RlW194ZmFfb2JqZWN0LiRnZXRTdWJmb3JtUGFyZW50XSgpOwogIGlmIChwYXJlbnQubGF5b3V0ID09PSAicG9zaXRpb24iKSB7CiAgICBpZiAobm9kZS5taW5XID4gMCkgewogICAgICBzdHlsZS5taW5XaWR0aCA9IG1lYXN1cmVUb1N0cmluZyhub2RlLm1pblcpOwogICAgfQogICAgaWYgKG5vZGUubWF4VyA+IDApIHsKICAgICAgc3R5bGUubWF4V2lkdGggPSBtZWFzdXJlVG9TdHJpbmcobm9kZS5tYXhXKTsKICAgIH0KICAgIGlmIChub2RlLm1pbkggPiAwKSB7CiAgICAgIHN0e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Z2luVjsKICAgIH0KICB9CiAgcmV0dXJuIHsKICAgIHc6IHdpZHRoLAogICAgaDogaGVpZ2h0LAogICAgaXNCcm9rZW4KICB9Owp9CmZ1bmN0aW9uIGNvbXB1dGVCYm94KG5vZGUsIGh0bWwsIGF2YWlsYWJsZVNwYWNlKSB7CiAgbGV0IGJib3g7CiAgaWYgKG5vZGUudyAhPT0gIiIgJiYgbm9kZS5oICE9PSAiIikgewogICAgYmJveCA9IFtub2RlLngsIG5vZGUueSwgbm9kZS53LCBub2RlLmhdOwogIH0gZWxzZSB7CiAgICBpZiAoIWF2YWlsYWJsZVNwYWNlKSB7CiAgICAgIHJldHVybiBudWxsOwogICAgfQogICAgbGV0IHdpZHRoID0gbm9kZS53OwogICAgaWYgKHdpZHRoID09PSAiIikgewogICAgICBpZiAobm9kZS5tYXhXID09PSAwKSB7CiAgICAgICAgY29uc3QgcGFyZW50ID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0U3ViZm9ybVBhcmVudF0oKTsKICAgICAgICBpZiAocGFyZW50LmxheW91dCA9PT0gInBvc2l0aW9uIiAmJiBwYXJlbnQudyAhPT0gIiIpIHsKICAgICAgICAgIHdpZHRoID0gMDsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgd2lkdGggPSBub2RlLm1pblc7CiAgICAgICAgfQogICAgICB9IGVsc2UgewogICAgICAgIHdpZHRoID0gTWF0aC5taW4obm9kZS5tYXhXLCBhdmFpbGFibGVTcGFjZS53aWR0aCk7CiAgICAgIH0KICAgICAgaHRtbC5hdHRyaWJ1dGVzLnN0eWxlLndpZHRoID0gbWVhc3VyZVRvU3RyaW5nKHdpZHRoKTsKICAgIH0KICAgIGxldCBoZWlnaHQgPSBub2RlLmg7CiAgICBpZiAoaGVpZ2h0ID09PSAiIikgewogICAgICBpZiAobm9kZS5tYXhIID09PSAwKSB7CiAgICAgICAgY29uc3QgcGFyZW50ID0gbm9kZVtfeGZhX29iamVjdC4kZ2V0U3ViZm9ybVBhcmVudF0o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ID0+IGEgKyB3LCAwKTsKICAgIH0KICAgIGlmICghaXNOYU4od2lkdGgpKSB7CiAgICAgIG5vZGUudyA9IHdpZHRoOwogICAgfQogIH0KICBpZiAocGFyZW50LmxheW91dCAmJiBwYXJlbnQubGF5b3V0ICE9PSAicG9zaXRpb24iKSB7CiAgICBub2RlLnggPSBub2RlLnkgPSAwOwogIH0KICBpZiAobm9kZS5sYXlvdXQgPT09ICJ0YWJsZSIpIHsKICAgIGlmIChub2RlLncgPT09ICIiICYmIEFycmF5LmlzQXJyYXkobm9kZS5jb2x1bW5XaWR0aHMpKSB7CiAgICAgIG5vZGUudyA9IG5vZGUuY29sdW1uV2lkdGhzLnJlZHVjZSgoYSwgeCkgPT4gYSArIHgsIDApOwogICAgfQogIH0KfQpmdW5jdGlvbiBsYXlvdXRDbGFzcyhub2RlKSB7CiAgc3dpdGNoIChub2RlLmxheW91dCkgewogICAgY2FzZSAicG9zaXRpb24iOgogICAgICByZXR1cm4gInhmYVBvc2l0aW9uIjsKICAgIGNhc2UgImxyLXRiIjoKICAgICAgcmV0dXJuICJ4ZmFMclRiIjsKICAgIGNhc2UgInJsLXJvdyI6CiAgICAgIHJldHVybiAieGZhUmxSb3ciOwogICAgY2FzZSAicmwtdGIiOgogICAgICByZXR1cm4gInhmYVJsVGIiOwogICAgY2FzZSAicm93IjoKICAgICAgcmV0dXJuICJ4ZmFSb3ciOwogICAgY2FzZSAidGFibGUiOgogICAgICByZXR1cm4gInhmYVRhYmxlIjsKICAgIGNhc2UgInRiIjoKICAgICAgcmV0dXJuICJ4ZmFUYiI7CiAgICBkZWZhdWx0OgogICAgICByZXR1cm4gInhmYVBvc2l0aW9uIjsKICB9Cn0KZnVuY3Rpb24gdG9TdHlsZShub2RlKSB7CiAgY29uc3Qgc3R5bGUgPSBPYmplY3QuY3JlYXRlKG51bGwpOwogIGZvciAodmFyIF9sZW4gPSBhcmd1bWVudHMubGVuZ3RoLCBuYW1lcyA9IG5ldyBBcnJheShfbGVuID4gM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ICAgIGNhc2UgInJpZ2h0IjoKICAgICAgICB3aWR0aCA9IGluc2V0c1cgPyBgY2FsYygxMDAlIC0gJHtpbnNldHNXfXB4KWAgOiAiMTAwJSI7CiAgICAgICAgaGVpZ2h0ID0gaW5zZXRzSCA/IGBjYWxjKDEwMCUgLSAke2luc2V0c0h9cHgpYCA6ICIxMDAlIjsKICAgICAgICBicmVhazsKICAgIH0KICAgIGNvbnN0IGNsYXNzTmFtZXMgPSBbInhmYUJvcmRlciJdOwogICAgaWYgKGlzUHJpbnRPbmx5KG5vZGUuYm9yZGVyKSkgewogICAgICBjbGFzc05hbWVzLnB1c2goInhmYVByaW50T25seSIpOwogICAgfQogICAgY29uc3QgYm9yZGVyID0gewogICAgICBuYW1lOiAiZGl2IiwKICAgICAgYXR0cmlidXRlczogewogICAgICAgIGNsYXNzOiBjbGFzc05hbWVzLAogICAgICAgIHN0eWxlOiB7CiAgICAgICAgICB0b3A6IGAke3RvcH1weGAsCiAgICAgICAgICBsZWZ0OiBgJHtsZWZ0fXB4YCwKICAgICAgICAgIHdpZHRoLAogICAgICAgICAgaGVpZ2h0CiAgICAgICAgfQogICAgICB9LAogICAgICBjaGlsZHJlbjogW10KICAgIH07CiAgICBmb3IgKGNvbnN0IGtleSBvZiBbImJvcmRlciIsICJib3JkZXJXaWR0aCIsICJib3JkZXJDb2xvciIsICJib3JkZXJSYWRpdXMiLCAiYm9yZGVyU3R5bGUiXSkgewogICAgICBpZiAoc3R5bGVba2V5XSAhPT0gdW5kZWZpbmVkKSB7CiAgICAgICAgYm9yZGVyLmF0dHJpYnV0ZXMuc3R5bGVba2V5XSA9IHN0eWxlW2tleV07CiAgICAgICAgZGVsZXRlIHN0eWxlW2tleV07CiAgICAgIH0KICAgIH0KICAgIHdyYXBwZXIuY2hpbGRyZW4ucHVzaChib3JkZXIsIGh0bWwpOwogIH0gZWxzZSB7CiAgICB3cmFwcGVyLmNoaWxkcmVuLnB1c2goaHRtbCk7CiAgfQogIGZvciAoY29uc3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cy5sZW5ndGggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogbnVsbDsKICAgIGZvciAoY29uc3QgcGRmRm9udCBvZiBwZGZGb250cykgewogICAgICB0aGlzLmFkZFBkZkZvbnQocGRmRm9udCk7CiAgICB9CiAgICBmb3IgKGNvbnN0IHBkZkZvbnQgb2YgdGhpcy5mb250cy52YWx1ZXMoKSkgewogICAgICBpZiAoIXBkZkZvbnQucmVndWxhcikgewogICAgICAgIHBkZkZvbnQucmVndWxhciA9IHBkZkZvbnQuaXRhbGljIHx8IHBkZkZvbnQuYm9sZCB8fCBwZGZGb250LmJvbGRpdGFsaWM7CiAgICAgIH0KICAgIH0KICAgIGlmICghcmVhbGx5TWlzc2luZ0ZvbnRzIHx8IHJlYWxseU1pc3NpbmdGb250cy5zaXplID09PSAwKSB7CiAgICAgIHJldHVybjsKICAgIH0KICAgIGNvbnN0IG15cmlhZCA9IHRoaXMuZm9udHMuZ2V0KCJQZGZKUy1GYWxsYmFjay1QZGZKUy1YRkEiKTsKICAgIGZvciAoY29uc3QgbWlzc2luZyBvZiByZWFsbHlNaXNzaW5nRm9udHMpIHsKICAgICAgdGhpcy5mb250cy5zZXQobWlzc2luZywgbXlyaWFkKTsKICAgIH0KICB9CiAgYWRkUGRmRm9udChwZGZGb250KSB7CiAgICBjb25zdCBjc3NGb250SW5mbyA9IHBkZkZvbnQuY3NzRm9udEluZm87CiAgICBjb25zdCBuYW1lID0gY3NzRm9udEluZm8uZm9udEZhbWlseTsKICAgIGxldCBmb250ID0gdGhpcy5mb250cy5nZXQobmFtZSk7CiAgICBpZiAoIWZvbnQpIHsKICAgICAgZm9udCA9IE9iamVjdC5jcmVhdGUobnVsbCk7CiAgICAgIHRoaXMuZm9udHMuc2V0KG5hbWUsIGZvbnQpOwogICAgICBpZiAoIXRoaXMuZGVmYXVsdEZvbnQpIHsKICAgICAgICB0aGlzLmRlZmF1bHRGb250ID0gZm9ud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ggPiAxICYmIGFyZ3VtZW50c1sxXSAhPT0gdW5kZWZpbmVkID8gYXJndW1lbnRzWzFdIDogdHJ1ZTsKICAgIGxldCBmb250ID0gdGhpcy5mb250cy5nZXQoZm9udE5hbWUpIHx8IHRoaXMuY2FjaGUuZ2V0KGZvbnROYW1lKTsKICAgIGlmIChmb250KSB7CiAgICAgIHJldHVybiBmb250OwogICAgfQogICAgY29uc3QgcGF0dGVybiA9IC8sfC18X3wgfGJvbGRpdGFsaWN8Ym9sZHxpdGFsaWN8cmVndWxhcnxpdC9naTsKICAgIGxldCBuYW1lID0gZm9udE5hbWUucmVwbGFjZUFsbChwYXR0ZXJuLCAiIik7CiAgICBmb250ID0gdGhpcy5mb250cy5nZXQobmFtZSk7CiAgICBpZiAoZm9udCkgewogICAgICB0aGlzLmNhY2hlLnNldChmb250TmFtZSwgZm9udCk7CiAgICAgIHJldHVybiBmb250OwogICAgfQogICAgbmFtZSA9IG5hbWUudG9Mb3dlckNhc2UoKTsKICAgIGNvbnN0IG1heWJlID0gW107CiAgICBmb3IgKGNvbnN0IFtmYW1pbHksIHBkZkZvbnRdIG9mIHRoaXMuZm9udHMuZW50cmllcygpKSB7CiAgICAgIGlmIChmYW1pbHkucmVwbGFjZUFsbChwYXR0ZXJuLCAiIikudG9Mb3dlckNhc2UoKS5zdGFydHNXaXRoKG5hbWUpKSB7CiAgICAgICAgbWF5YmUucHVzaChwZGZGb250KTsKICAgICAgfQogICAgfQogICAgaWYgKG1heWJlLmxlbmd0aCA9PT0gMCkgewogICAgICBmb3IgKGNvbnN0IFssIHBkZkZvbnRdIG9mIHRoaXMuZm9udHMuZW50cmllcygpKSB7CiAgICAgICAgaWYgKHBkZkZvbnQucmVndWxhci5uYW1lICYmIHBkZkZvbnQucmVndWxhci5uYW1lLnJlcGxhY2VBbGwocGF0dGVybiwgIiIpLnRvTG93ZXJDYXNlKCkuc3RhcnRzV2l0aChuYW1lKSkgewogICAgICAgICAgbWF5YmUucHVzaChwZGZGb250KTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGlmIChtYXliZS5sZW5ndGggPT09IDApIHsKICAgICAgbmFtZSA9IG5hbWUucmVwbGFjZUFsbCgvcHNtdHxtdC9naSwgIiIpOwogICAgICBmb3IgKGNvbnN0IFtmYW1pbHksIHBkZkZvbnRdIG9mIHRoaXMuZm9udHMuZW50cmllcygpKSB7CiAgICAgICAgaWYgKGZhbWlseS5yZXBsYWNlQWxsKHBhdHRlcm4sICIiKS50b0xvd2VyQ2FzZSgpLnN0YXJ0c1dpdGgobmFtZSkpIHsKICAgICAgICAgIG1heWJlLnB1c2gocGRmRm9udCk7CiAgICAgICAgfQogICAgICB9CiAgICB9CiAgICBpZiAobWF5YmUubGVuZ3RoID09PSAwKSB7CiAgICAgIGZvciAoY29uc3QgcGRmRm9udCBvZiB0aGlzLmZvbnRzLnZhbHVlcygpKSB7CiAgICAgICAgaWYgKHBkZkZvbnQucmVndWxhci5uYW1lICYmIHBkZkZvbnQucmVndWxhci5uYW1lLnJlcGxhY2VBbGwocGF0dGVybiwgIiIpLnRvTG93ZXJDYXNlKCkuc3RhcnRzV2l0aChuYW1lKSkgewogICAgICAgICAgbWF5YmUucHVzaChwZGZGb250KTsKICAgICAgICB9CiAgICAgIH0KICAgIH0KICAgIGlmIChtYXliZS5sZW5ndGggPj0gMSkgewogICAgICBpZiAobWF5YmUubGVuZ3RoICE9PSAxICYmIG11c3RXYXJuKSB7CiAgICAgICAgKDAsIF91dGlsLndhcm4pKGBYRkEgLSBUb28gbWFueSBjaG9pY2VzIHRvIGd1ZXNzIHRoZSBjb3JyZWN0IGZvbnQ6ICR7Zm9udE5hbWV9YCk7CiAgICAgIH0KICAgICAgdGhpcy5jYWNoZS5zZXQoZm9udE5hbWUsIG1heWJlWzBdKTsKICAgICAgcmV0dXJuIG1heWJlWzBdOwogICAgfQogICAgaWYgKG11c3RXYXJuICYmICF0aGlzLndhcm5lZC5oYXMoZm9udE5hbWUpKSB7CiAgICAgIHRoaX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XN0U3BhY2VQb3MgPSAtMTsKICAgICAgICBsYXN0U3BhY2VXaWR0aCA9IDA7CiAgICAgICAgaXNGaXJzdExpbmUgPSBmYWxzZTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoaXNTcGFjZSkgewogICAgICAgIGlmIChjdXJyZW50TGluZVdpZHRoICsgZ2x5cGhXaWR0aCA+IG1heFdpZHRoKSB7CiAgICAgICAgICB3aWR0aCA9IE1hdGgubWF4KHdpZHRoLCBjdXJyZW50TGluZVdpZHRoKTsKICAgICAgICAgIGN1cnJlbnRMaW5lV2lkdGggPSAwOwogICAgICAgICAgaGVpZ2h0ICs9IGN1cnJlbnRMaW5lSGVpZ2h0OwogICAgICAgICAgY3VycmVudExpbmVIZWlnaHQgPSBnbHlwaEhlaWdodDsKICAgICAgICAgIGxhc3RTcGFjZVBvcyA9IC0xOwogICAgICAgICAgbGFzdFNwYWNlV2lkdGggPSAwOwogICAgICAgICAgaXNCcm9rZW4gPSB0cnVlOwogICAgICAgICAgaXNGaXJzdExpbmUgPSBmYWxzZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgY3VycmVudExpbmVIZWlnaHQgPSBNYXRoLm1heChnbHlwaEhlaWdodCwgY3VycmVudExpbmVIZWlnaHQpOwogICAgICAgICAgbGFzdFNwYWNlV2lkdGggPSBjdXJyZW50TGluZVdpZHRoOwogICAgICAgICAgY3VycmVudExpbmVXaWR0aCArPSBnbHlwaFdpZHRoOwogICAgICAgICAgbGFzdFNwYWNlUG9zID0gaTsKICAgICAgICB9CiAgICAgICAgY29udGludWU7CiAgICAgIH0KICAgICAgaWYgKGN1cnJlbnRMaW5lV2lkdGggKyBnbHlwaFdpZHRoID4gbWF4V2lkdGgpIHsKICAgICAgICBoZWlnaHQgKz0gY3VycmVudExpbmVIZWlnaHQ7CiAgICAgICAgY3VycmVudExpbmVIZWlnaHQgPSBnbHlwaEhlaWdodDsKICAgICAgICBpZiAobGFzdFNwYWNlUG9zICE9PSAtMSkgewogICAgICAgICAgaSA9IGxhc3RTcGFjZVBvczsKICAgICAgICAgIHdpZHRoID0gTWF0aC5tYXgod2lkdGgsIGxhc3RTcGFjZVdpZHRoKTsKICAgICAgICAgIGN1cnJlbnRMaW5lV2lkdGggPSAwOwogICAgICAgICAgbGFzdFNwYWNlUG9zID0gLTE7CiAgICAgICAgICBsYXN0U3BhY2VXaWR0aCA9IDA7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHdpZHRoID0gTWF0aC5tYXgod2lkdGgsIGN1cnJlbnRMaW5lV2lkdGgpOwogICAgICAgICAgY3VycmVudExpbmVXaWR0aCA9IGdseXBoV2lkdGg7CiAgICAgICAgfQogICAgICAgIGlzQnJva2VuID0gdHJ1ZTsKICAgICAgICBpc0ZpcnN0TGluZSA9IGZhbHNlOwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgIGN1cnJlbnRMaW5lV2lkdGggKz0gZ2x5cGhXaWR0aDsKICAgICAgY3VycmVudExpbmVIZWlnaHQgPSBNYXRoLm1heChnbHlwaEhlaWdodCwgY3VycmVudExpbmVIZWlnaHQpOwogICAgfQogICAgd2lkdGggPSBNYXRoLm1heCh3aWR0aCwgY3VycmVudExpbmVXaWR0aCk7CiAgICBoZWlnaHQgKz0gY3VycmVudExpbmVIZWlnaHQgKyB0aGlzLmV4dHJhSGVpZ2h0OwogICAgcmV0dXJuIHsKICAgICAgd2lkdGg6IFdJRFRIX0ZBQ1RPUiAqIHdpZHRoLAogICAgICBoZWlnaHQsCiAgICAgIGlzQnJva2VuCiAgICB9OwogIH0KfQpleHBvcnRzLlRleHRNZWFzdXJlID0gVGV4dE1lYXN1cmU7CgovKioqLyB9KSwKLyogMjIyICovCi8qKiovICgoX191bnVzZWRfd2VicGFja19tb2R1bGUsIGV4cG9ydHMsIF9fd19wZGZqc19yZXF1aXJlX18pID0+IHsKCiJ1c2Ugc3RyaWN0IjsKCgpPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0c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WVzcGFjZSA9IG51bGw7CiAgICBsZXQgcHJlZml4ZXMgPSBudWxsOwogICAgY29uc3QgYXR0cmlidXRlT2JqID0gT2JqZWN0LmNyZWF0ZSh7fSk7CiAgICBmb3IgKGNvbnN0IHsKICAgICAgbmFtZSwKICAgICAgdmFsdWUKICAgIH0gb2YgYXR0cmlidXRlcykgewogICAgICBpZiAobmFtZSA9PT0gInhtbG5zIikgewogICAgICAgIGlmICghbmFtZXNwYWNlKSB7CiAgICAgICAgICBuYW1lc3BhY2UgPSB2YWx1ZTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBYRkEgLSBtdWx0aXBsZSBuYW1lc3BhY2UgZGVmaW5pdGlvbiBpbiA8JHt0YWdOYW1lfT5gKTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZiAobmFtZS5zdGFydHNXaXRoKCJ4bWxuczoiKSkgewogICAgICAgIGNvbnN0IHByZWZpeCA9IG5hbWUuc3Vic3RyaW5nKCJ4bWxuczoiLmxlbmd0aCk7CiAgICAgICAgaWYgKCFwcmVmaXhlcykgewogICAgICAgICAgcHJlZml4ZXMgPSBbXTsKICAgICAgICB9CiAgICAgICAgcHJlZml4ZXMucHVzaCh7CiAgICAgICAgICBwcmVmaXgsCiAgICAgICAgICB2YWx1ZQogICAgICAgIH0pOwogICAgICB9IGVsc2UgewogICAgICAgIGNvbnN0IGkgPSBuYW1lLmluZGV4T2YoIjoiKTsKICAgICAgICBpZiAoaSA9PT0gLTEpIHsKICAgICAgICAgIGF0dHJpYnV0ZU9ialtuYW1lXSA9IHZhbHVlOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBsZXQgbnNBdHRycyA9IGF0dHJpYnV0ZU9ialtfeGZhX29iamVjdC4kbnNBdHRyaWJ1dGVzXTsKICAgICAgICAgIGlmICghbnNBdHRycykgewogICAgICAgICAgICBuc0F0dHJzID0gYXR0cmlidXRlT2JqW194ZmFfb2JqZWN0LiRuc0F0dHJp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ewogICAgICBuc1ByZWZpeCwKICAgICAgbmFtZSwKICAgICAgYXR0cmlidXRlczogYXR0cmlidXRlc09iaiwKICAgICAgbmFtZXNwYWNlLAogICAgICBwcmVmaXhlcwogICAgfSk7CiAgICBub2RlW194ZmFfb2JqZWN0LiRnbG9iYWxEYXRhXSA9IHRoaXMuX2dsb2JhbERhdGE7CiAgICBpZiAoaXNFbXB0eSkgewogICAgICBub2RlW194ZmFfb2JqZWN0LiRmaW5hbGl6ZV0oKTsKICAgICAgaWYgKHRoaXMuX2N1cnJlbnRbX3hmYV9vYmplY3QuJG9uQ2hpbGRdKG5vZGUpKSB7CiAgICAgICAgbm9kZVtfeGZhX29iamVjdC4kc2V0SWRdKHRoaXMuX2lkcyk7CiAgICAgIH0KICAgICAgbm9kZVtfeGZhX29iamVjdC4kY2xlYW5dKHRoaXMuX2J1aWxkZXIpOwogICAgICByZXR1cm47CiAgICB9CiAgICB0aGlzLl9zdGFjay5wdXNoKHRoaXMuX2N1cnJlbnQpOwogICAgdGhpcy5fY3VycmVudCA9IG5vZGU7CiAgfQogIG9uRW5kRWxlbWVudChuYW1lKSB7CiAgICBjb25zdCBub2RlID0gdGhpcy5fY3VycmVudDsKICAgIGlmIChub2RlW194ZmFfb2JqZWN0LiRpc0NEQVRBWG1sXSgpICYmIHR5cGVvZiBub2RlW194ZmFfb2JqZWN0LiRjb250ZW50XSA9PT0gInN0cmluZyIpIHsKICAgICAgY29uc3QgcGFyc2VyID0gbmV3IFhGQVBhcnNlcigpOwogICAgICBwYXJzZXIuX2dsb2JhbERhdGEgPSB0aGlzLl9nbG9iYWxEYXRhOwogICAgICBjb25zdCByb290ID0gcGFyc2VyLnBhcnNlKG5vZGVbX3hmYV9vYmplY3QuJGNvbnRlbnRdKTsKICAgICAgbm9kZVtfeGZhX29iamVjdC4kY29udGVudF0gPSBudWxsOwogICAgICBub2RlW194ZmFfb2JqZWN0LiRvbkNoaWxkXShyb290KTsKICAgIH0KICAgIG5vZGVbX3hmYV9v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WNdKCkpIHsKICAgICAgdGhpcy5fbnNBZ25vc3RpY0xldmVsKys7CiAgICB9CiAgICBpZiAoaGFzTmFtZXNwYWNlRGVmIHx8IHByZWZpeGVzIHx8IG5vZGVbX3hmYV9vYmplY3QuJGlzTnNBZ25vc3RpY10oKSkgewogICAgICBub2RlW194ZmFfb2JqZWN0LiRjbGVhbnVwXSA9IHsKICAgICAgICBoYXNOYW1lc3BhY2U6IGhhc05hbWVzcGFjZURlZiwKICAgICAgICBwcmVmaXhlcywKICAgICAgICBuc0Fnbm9zdGljOiBub2RlW194ZmFfb2JqZWN0LiRpc05zQWdub3N0aWNdKCkKICAgICAgfTsKICAgIH0KICAgIHJldHVybiBub2RlOwogIH0KICBpc05zQWdub3N0aWMoKSB7CiAgICByZXR1cm4gdGhpcy5fbnNBZ25vc3RpY0xldmVsID4gMDsKICB9CiAgX3NlYXJjaE5hbWVzcGFjZShuc05hbWUpIHsKICAgIGxldCBucyA9IHRoaXMuX25hbWVzcGFjZXMuZ2V0KG5zTmFtZSk7CiAgICBpZiAobnMpIHsKICAgICAgcmV0dXJuIG5zOwogICAgfQogICAgZm9yIChjb25zdCBbbmFtZSwgewogICAgICBjaGVjawogICAgfV0gb2YgT2JqZWN0LmVudHJpZXMoX25hbWVzcGFjZXMuTmFtZXNwYWNlSWRzKSkgewogICAgICBpZiAoY2hlY2sobnNOYW1lKSkgewogICAgICAgIG5zID0gX3NldHVwLk5hbWVzcGFjZVNldFVwW25hbWVdOwogICAgICAgIGlmIChucykgewogICAgICAgICAgdGhpcy5fbmFtZXNwYWNlcy5zZXQobnNOYW1lLCBucyk7CiAgICAgICAgICByZXR1cm4gbnM7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICB9CiAgICB9CiAgICBucyA9IG5ldyBfdW5rbm93bi5Vbmtub3duTmFtZXNwYWNlKCsrdGhpcy5fbmV4dE5zSWQpOwogICAgdGhpcy5fbmFtZXNwYWNlcy5zZXQobnNOYW1lLCBucyk7CiAgICByZ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yLnJlcGxhY2VBbGwoc3BhY2VzUmVnRXhwLCAiICIpOwogICAgICB9CiAgICB9IGVsc2UgewogICAgICB0aGlzWyRyaWNoVGV4dF0gPSB0cnVlOwogICAgfQogICAgaWYgKHN0cikgewogICAgICB0aGlzW194ZmFfb2JqZWN0LiRjb250ZW50XSArPSBzdHI7CiAgICB9CiAgfQogIFtfeGZhX29iamVjdC4kcHVzaEdseXBoc10obWVhc3VyZSkgewogICAgbGV0IG11c3RQb3AgPSBhcmd1bWVudHMubGVuZ3RoID4gMSAmJiBhcmd1bWVudHNbMV0gIT09IHVuZGVmaW5lZCA/IGFyZ3VtZW50c1sxXSA6IHRydWU7CiAgICBjb25zdCB4ZmFGb250ID0gT2JqZWN0LmNyZWF0ZShudWxsKTsKICAgIGNvbnN0IG1hcmdpbiA9IHsKICAgICAgdG9wOiBOYU4sCiAgICAgIGJvdHRvbTogTmFOLAogICAgICBsZWZ0OiBOYU4sCiAgICAgIHJpZ2h0OiBOYU4KICAgIH07CiAgICBsZXQgbGluZUhlaWdodCA9IG51bGw7CiAgICBmb3IgKGNvbnN0IFtrZXksIHZhbHVlXSBvZiB0aGlzLnN0eWxlLnNwbGl0KCI7IikubWFwKHMgPT4gcy5zcGxpdCgiOiIsIDIpKSkgewogICAgICBzd2l0Y2ggKGtleSkgewogICAgICAgIGNhc2UgImZvbnQtZmFtaWx5IjoKICAgICAgICAgIHhmYUZvbnQudHlwZWZhY2UgPSAoMCwgX3V0aWxzLnN0cmlwUXVvdGVzKSh2YWx1ZSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJmb250LXNpemUiOgogICAgICAgICAgeGZhRm9udC5zaXplID0gKDAsIF91dGlscy5nZXRNZWFzdXJlbWVudCkodmFsdWUpOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAiZm9udC13ZWlnaHQiOgogICAgICAgICAgeGZhRm9udC53ZWlnaHQgPSB2YWx1ZTsKICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgImZvbnQtc3R5bGUiOgogICAgICAgICAgeGZhRm9udC5wb3N0dXJlID0gdmFsdWU7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJsZXR0ZXItc3BhY2luZyI6CiAgICAgICAgICB4ZmFGb250LmxldHRlclNwYWNpbmcgPSAoMCwgX3V0aWxzLmdldE1lYXN1cmVtZW50KSh2YWx1ZSk7CiAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlICJtYXJnaW4iOgogICAgICAgICAgY29uc3QgdmFsdWVzID0gdmFsdWUuc3BsaXQoLyBcdC8pLm1hcCh4ID0+ICgwLCBfdXRpbHMuZ2V0TWVhc3VyZW1lbnQpKHgpKTsKICAgICAgICAgIHN3aXRjaCAodmFsdWVzLmxlbmd0aCkgewogICAgICAgICAgICBjYXNlIDE6CiAgICAgICAgICAgICAgbWFyZ2luLnRvcCA9IG1hcmdpbi5ib3R0b20gPSBtYXJnaW4ubGVmdCA9IG1hcmdpbi5yaWdodCA9IHZhbHVlc1swXTsKICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICAgIG1hcmdpbi50b3AgPSBtYXJnaW4uYm90dG9tID0gdmFsdWVzWzBdOwogICAgICAgICAgICAgIG1hcmdpbi5sZWZ0ID0gbWFyZ2luLnJpZ2h0ID0gdmFsdWVzWzFdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDM6CiAgICAgICAgICAgICAgbWFyZ2luLnRvcCA9IHZhbHVlc1swXTsKICAgICAgICAgICAgICBtYXJnaW4uYm90dG9tID0gdmFsdWVzWzJdOwogICAgICAgICAgICAgIG1hcmdpbi5sZWZ0ID0gbWFyZ2luLnJpZ2h0ID0gdmFsdWVzWzFdOwogICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDQ6CiAgICAgICAgICAgICAgbWFyZ2luLnRvcCA9IHZhbHVlc1swXTsKICAgICAgICAgICAgICBtYXJnaW4ubGV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md0aCA9PT0gMCkgewogICAgICByZXR1cm4gX3V0aWxzLkhUTUxSZXN1bHQuc3VjY2Vzcyh7CiAgICAgICAgbmFtZTogImRpdiIsCiAgICAgICAgYXR0cmlidXRlczogewogICAgICAgICAgY2xhc3M6IFsieGZhUmljaCJdLAogICAgICAgICAgc3R5bGU6IHt9CiAgICAgICAgfSwKICAgICAgICB2YWx1ZTogdGhpc1tfeGZhX29iamVjdC4kY29udGVudF0gfHwgIiIKICAgICAgfSk7CiAgICB9CiAgICBpZiAoY2hpbGRyZW4ubGVuZ3RoID09PSAxKSB7CiAgICAgIGNvbnN0IGNoaWxkID0gY2hpbGRyZW5bMF07CiAgICAgIGlmIChjaGlsZC5hdHRyaWJ1dGVzICYmIGNoaWxkLmF0dHJpYnV0ZXMuY2xhc3MuaW5jbHVkZXMoInhmYVJpY2giKSkgewogICAgICAgIHJldHVybiBfdXRpbHMuSFRNTFJlc3VsdC5zdWNjZXNzKGNoaWxkKTsKICAgICAgfQogICAgfQogICAgcmV0dXJuIF91dGlscy5IVE1MUmVzdWx0LnN1Y2Nlc3MoewogICAgICBuYW1lOiAiZGl2IiwKICAgICAgYXR0cmlidXRlczogewogICAgICAgIGNsYXNzOiBbInhmYVJpY2giXSwKICAgICAgICBzdHlsZToge30KICAgICAgfSwKICAgICAgY2hpbGRyZW4KICAgIH0pOwogIH0KfQpjbGFzcyBJIGV4dGVuZHMgWGh0bWxPYmplY3QgewogIGNvbnN0cnVjdG9yKGF0dHJpYnV0ZXMpIHsKICAgIHN1cGVyKGF0dHJpYnV0ZXMsICJpIik7CiAgfQogIFtfeGZhX29iamVjdC4kcHVzaEdseXBoc10obWVhc3VyZSkgewogICAgbWVhc3VyZS5wdXNoRm9udCh7CiAgICAgIHBvc3R1cmU6ICJpdGFsaWMiCiAgICB9KTsKICAgIHN1cGVyW194ZmFfb2JqZWN0LiRwdXNoR2x5cGhzXShtZWFzdXJlKTsKICAgIG1lYXN1cmUucG9wRm9udCgpOwogIH0KfQpj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gIGxlbmd0aCA9IGJ1ZmZlci5sZW5ndGg7CiAgICBsZXQgcG9zaXRpb24gPSBzdHJlYW0uc3RhcnQ7CiAgICBjb25zdCB0cmFpbGVycyA9IFtdLAogICAgICB4cmVmU3RtcyA9IFtdOwogICAgd2hpbGUgKHBvc2l0aW9uIDwgbGVuZ3RoKSB7CiAgICAgIGxldCBjaCA9IGJ1ZmZlcltwb3NpdGlvbl07CiAgICAgIGlmIChjaCA9PT0gVEFCIHx8IGNoID09PSBMRiB8fCBjaCA9PT0gQ1IgfHwgY2ggPT09IFNQQUNFKSB7CiAgICAgICAgKytwb3NpdGlvbjsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBpZiAoY2ggPT09IFBFUkNFTlQpIHsKICAgICAgICBkbyB7CiAgICAgICAgICArK3Bvc2l0aW9uOwogICAgICAgICAgaWYgKHBvc2l0aW9uID49IGxlbmd0aCkgewogICAgICAgICAgICBicmVhazsKICAgICAgICAgIH0KICAgICAgICAgIGNoID0gYnVmZmVyW3Bvc2l0aW9uXTsKICAgICAgICB9IHdoaWxlIChjaCAhPT0gTEYgJiYgY2ggIT09IENSKTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBjb25zdCB0b2tlbiA9IHJlYWRUb2tlbihidWZmZXIsIHBvc2l0aW9uKTsKICAgICAgbGV0IG07CiAgICAgIGlmICh0b2tlbi5zdGFydHNXaXRoKCJ4cmVmIikgJiYgKHRva2VuLmxlbmd0aCA9PT0gNCB8fCAvXHMvLnRlc3QodG9rZW5bNF0pKSkgewogICAgICAgIHBvc2l0aW9uICs9IHNraXBVbnRpbChidWZmZXIsIHBvc2l0aW9uLCB0cmFpbGVyQnl0ZXMpOwogICAgICAgIHRyYWlsZXJzLnB1c2gocG9zaXRpb24pOwogICAgICAgIHBvc2l0aW9uICs9IHNraXBVbnRpbChidWZmZXIsIHBvc2l0aW9uLCBzdGFydHhyZWZCeXRlcyk7CiAgICAgIH0gZWxzZSBpZiAobSA9IG9ialJlZ0V4cC5leGVjKHRva2VuKSkgewogICAgICAgIGNvbnN0IG51bSA9IG1bMV0gfCAwLAogICAgICAgICAgZ2VuID0gbVsyXSB8IDA7CiAgICAgICAgY29uc3Qgc3RhcnRQb3MgPSBwb3NpdGlvbiArIHRva2VuLmxlbmd0aDsKICAgICAgICBsZXQgY29udGVudExlbmd0aCwKICAgICAgICAgIHVwZGF0ZUVudHJpZXMgPSBmYWxzZTsKICAgICAgICBpZiAoIXRoaXMuZW50cmllc1tudW1dKSB7CiAgICAgICAgICB1cGRhdGVFbnRyaWVzID0gdHJ1ZTsKICAgICAgICB9IGVsc2UgaWYgKHRoaXMuZW50cmllc1tudW1dLmdlbiA9PT0gZ2VuKSB7CiAgICAgICAgICB0cnkgewogICAgICAgICAgICBjb25zdCBwYXJzZXIgPSBuZXcgX3BhcnNlci5QYXJzZXIoewogICAgICAgICAgICAgIGxleGVyOiBuZXcgX3BhcnNlci5MZXhlcihzdHJlYW0ubWFrZVN1YlN0cmVhbShzdGFydFBvcykpCiAgICAgICAgICAgIH0pOwogICAgICAgICAgICBwYXJzZXIuZ2V0T2JqKCk7CiAgICAgICAgICAgIHVwZGF0ZUVudHJpZXMgPSB0cnVlOwogICAgICAgICAgfSBjYXRjaCAoZXgpIHsKICAgICAgICAgICAgaWYgKGV4IGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuUGFyc2VyRU9GRXhjZXB0aW9uKSB7CiAgICAgICAgICAgICAgKDAsIF91dGlsLndhcm4pKGBpbmRleE9iamVjdHMgLS0gY2hlY2tpbmcgb2JqZWN0ICgke3Rva2VufSk6ICIke2V4fSIuYCk7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgdXBkYXRlRW50cmllcyA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKHVwZGF0ZUVudHJpZXMpIHsKICAgICAgICAgIHRoaXMuZW50cmllc1tudW1dID0gewogICAgICAgICAgICBvZmZzZXQ6IHBvc2l0aW9uIC0gc3RyZWFtLnN0YXJ0LAogICAgICAgICAgICBnZW4sCiAgICAgICAgICAgIHVuY29tcHJlc3NlZDogdHJ1ZQogICAgICAgICAgfTsKICAgICAgICB9CiAgICAgICAgZ0VuZG9ialJlZ0V4cC5sYXN0SW5kZXggPSBzdGFydFBvczsKICAgICAgICBjb25zdCBtYXRjaCA9IGdFbmRvYmpSZWdFeHAuZXhlYyhidWZmZXJTdHIpOwogICAgICAgIGlmIChtYXRjaCkgewogICAgICAgICAgY29uc3QgZW5kUG9zID0gZ0VuZG9ialJlZ0V4cC5sYXN0SW5kZXggKyAxOwogICAgICAgICAgY29udGVudExlbmd0aCA9IGVuZFBvcyAtIHBvc2l0aW9uOwogICAgICAgICAgaWYgKG1hdGNoWzFdICE9PSAiZW5kb2JqIikgewogICAgICAgICAgICAoMCwgX3V0aWwud2FybikoYGluZGV4T2JqZWN0czogRm91bmQgIiR7bWF0Y2hbMV19IiBpbnNpZGUgb2YgYW5vdGhlciAib2JqIiwgYCArICdjYXVzZWQgYnkgbWlzc2luZyAiZW5kb2JqIiAtLSB0cnlpbmcgdG8gcmVjb3Zlci4nKTsKICAgICAgICAgICAgY29udGVudExlbmd0aCAtPSBtYXRjaFsxXS5sZW5ndGggKyAxOwogICAgICAgICAgfQogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBjb250ZW50TGVuZ3RoID0gbGVuZ3RoIC0gcG9zaXRpb247CiAgICAgICAgfQogICAgICAgIGNvbnN0IGNvbnRlbnQgPSBidWZmZXIuc3ViYXJyYXkocG9zaXRpb24sIHBvc2l0aW9uICsgY29udGVudExlbmd0aCk7CiAgICAgICAgY29uc3QgeHJlZlRhZ09mZnNldCA9IHNraXBVbnRpbChjb250ZW50LCAwLCB4cmVmQnl0ZXMpOwogICAgICAgIGlmICh4cmVmVGFnT2Zmc2V0IDwgY29udGVudExlbmd0aCAmJiBjb250ZW50W3hyZWZUYWdPZmZzZXQgKyA1XSA8ID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C5oYXMoIkVuY3J5cHQiKSkgewogICAgICAgIGlzRW5jcnlwdGVkID0gdHJ1ZTsKICAgICAgfQogICAgfQogICAgbGV0IHRyYWlsZXJEaWN0LCB0cmFpbGVyRXJyb3I7CiAgICBmb3IgKGNvbnN0IGRpY3Qgb2YgWy4uLnRyYWlsZXJEaWN0cywgImdlbkZhbGxiYWNrIiwgLi4udHJhaWxlckRpY3RzXSkgewogICAgICBpZiAoZGljdCA9PT0gImdlbkZhbGxiYWNrIikgewogICAgICAgIGlmICghdHJhaWxlckVycm9yKSB7CiAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICAgICAgdGhpcy5fZ2VuZXJhdGlvbkZhbGxiYWNrID0gdHJ1ZTsKICAgICAgICBjb250aW51ZTsKICAgICAgfQogICAgICBsZXQgdmFsaWRQYWdlc0RpY3QgPSBmYWxzZTsKICAgICAgdHJ5IHsKICAgICAgICBjb25zdCByb290RGljdCA9IGRpY3QuZ2V0KCJSb290Iik7CiAgICAgICAgaWYgKCEocm9vdERpY3QgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHBhZ2VzRGljdCA9IHJvb3REaWN0LmdldCgiUGFnZXMiKTsKICAgICAgICBpZiAoIShwYWdlc0RpY3QgaW5zdGFuY2VvZiBfcHJpbWl0aXZlcy5EaWN0KSkgewogICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHBhZ2VzQ291bnQgPSBwYWdlc0RpY3QuZ2V0KCJDb3VudCIpOwogICAgICAgIGlmIChOdW1iZXIuaXNJbnRlZ2VyKHBhZ2VzQ291bnQpKSB7CiAgICAgICAgICB2YWxpZFBhZ2VzRGljdCA9IHRydWU7CiAgICAgICAgfQogICAgICB9IGNhdGNoIChleCkgewogICAgICAgIHRyYWlsZXJFcnJvciA9IGV4OwogICAgICAgIGNvbnRpbnVlOwogICAgICB9CiAgICAgI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ooKSkgaW5zdGFuY2VvZiBfYmFzZV9zdHJlYW0uQmFzZVN0cmVhbSkpIHsKICAgICAgICAgICAgdGhyb3cgbmV3IF91dGlsLkZvcm1hdEVycm9yKCJJbnZhbGlkIFhSZWYgc3RyZWFtIik7CiAgICAgICAgICB9CiAgICAgICAgICBkaWN0ID0gdGhpcy5wcm9jZXNzWFJlZlN0cmVhbShvYmopOwogICAgICAgICAgaWYgKCF0aGlzLnRvcERpY3QpIHsKICAgICAgICAgICAgdGhpcy50b3BEaWN0ID0gZGljdDsKICAgICAgICAgIH0KICAgICAgICAgIGlmICghZGljdCkgewogICAgICAgICAgICB0aHJvdyBuZXcgX3V0aWwuRm9ybWF0RXJyb3IoIkZhaWxlZCB0byByZWFkIFhSZWYgc3RyZWFtIik7CiAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHRocm93IG5ldyBfdXRpbC5Gb3JtYXRFcnJvcigiSW52YWxpZCBYUmVmIHN0cmVhbSBoZWFkZXIiKTsKICAgICAgICB9CiAgICAgICAgb2JqID0gZGljdC5nZXQoIlByZXYiKTsKICAgICAgICBpZiAoTnVtYmVyLmlzSW50ZWdlcihvYmopKSB7CiAgICAgICAgICB0aGlzLnN0YXJ0WFJlZlF1ZXVlLnB1c2gob2JqKTsKICAgICAgICB9IGVsc2UgaWYgKG9iaiBpbnN0YW5jZW9mIF9wcmltaXRpdmVzLlJlZikgewogICAgICAgICAgdGhpcy5zdGFydFhSZWZRdWV1ZS5wdXNoKG9iai5udW0pOwogICAgICAgIH0KICAgICAgfSBjYXRjaCAoZSkgewogICAgICAgIGlmIChlIGluc3RhbmNlb2YgX2NvcmVfdXRpbHMuTWlzc2luZ0RhdGFFeGNlcHRpb24pIHsKICAgICAgICAgIHRocm93IGU7CiAgICAgICAgfQogICAgICAgICgwLCBfdXRpbC5pbmZvKSgiKHdoaWxlIHJlYWRpbmcgWFJlZik6ICIgKyBlKTsKICAgICAgfQogICAgICB0aGlzLnN0YXJ0W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sKICAgICAgICB9CiAgICAgICAgcmV0dXJuOwogICAgICB9CiAgICAgIGNvbnN0IGFjdGlvbiA9IHRoaXMuYWN0aW9uSGFuZGxlcltkYXRhLmFjdGlvbl07CiAgICAgIGlmICghYWN0aW9uKSB7CiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBVbmtub3duIGFjdGlvbiBmcm9tIHdvcmtlcjogJHtkYXRhLmFjdGlvbn1gKTsKICAgICAgfQogICAgICBpZiAoZGF0YS5jYWxsYmFja0lkKSB7CiAgICAgICAgY29uc3QgY2JTb3VyY2VOYW1lID0gdGhpcy5zb3VyY2VOYW1lOwogICAgICAgIGNvbnN0IGNiVGFyZ2V0TmFtZSA9IGRhdGEuc291cmNlTmFtZTsKICAgICAgICBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSkgewogICAgICAgICAgcmVzb2x2ZShhY3Rpb24oZGF0YS5kYXRhKSk7CiAgICAgICAgfSkudGhlbihmdW5jdGlvbiAocmVzdWx0KSB7CiAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICBzb3VyY2VOYW1lOiBjYlNvdXJjZU5hbWUsCiAgICAgICAgICAgIHRhcmdldE5hbWU6IGNiVGFyZ2V0TmFtZSwKICAgICAgICAgICAgY2FsbGJhY2s6IENhbGxiYWNrS2luZC5EQVRBLAogICAgICAgICAgICBjYWxsYmFja0lkOiBkYXRhLmNhbGxiYWNrSWQsCiAgICAgICAgICAgIGRhdGE6IHJlc3VsdAogICAgICAgICAgfSk7CiAgICAgICAgfSwgZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgc291cmNlTmFtZTogY2JTb3VyY2VOYW1lLAogICAgICAgICAgICB0YXJnZXROYW1lOiBjYlRhcmdldE5hbWUsCiAgICAgICAgICAgIGNhbGxiYWNrOiBDYWxsYmFja0tpbmQuRVJST1IsCiAgICAgICAgICAgIGNhbGxiY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AgICAgICAgICBwdWxsQ2FsbDogbnVsbCwKICAgICAgICAgIGNhbmNlbENhbGw6IG51bGwsCiAgICAgICAgICBpc0Nsb3NlZDogZmFsc2UKICAgICAgICB9OwogICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgIGFjdGlvbjogYWN0aW9uTmFtZSwKICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgZGF0YSwKICAgICAgICAgIGRlc2lyZWRTaXplOiBjb250cm9sbGVyLmRlc2lyZWRTaXplCiAgICAgICAgfSwgdHJhbnNmZXJzKTsKICAgICAgICByZXR1cm4gc3RhcnRDYXBhYmlsaXR5LnByb21pc2U7CiAgICAgIH0sCiAgICAgIHB1bGw6IGNvbnRyb2xsZXIgPT4gewogICAgICAgIGNvbnN0IHB1bGxDYXBhYmlsaXR5ID0gKDAsIF91dGlsLmNyZWF0ZVByb21pc2VDYXBhYmlsaXR5KSgpOwogICAgICAgIHRoaXMuc3RyZWFtQ29udHJvbGxlcnNbc3RyZWFtSWRdLnB1bGxDYWxsID0gcHVsbENhcGFiaWxpdHk7CiAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLlBVTEwsCiAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgIGRlc2lyZWRTaXplOiBjb250cm9sbGVyLmRlc2lyZWRTaXplCiAgICAgICAgfSk7CiAgICAgICAgcmV0dXJuIHB1bGxDYXBhYmlsaXR5LnByb21pc2U7CiAgICAgIH0sCiAgICAgIGNhbmNlbDogcmVhc29uID0+IHsKICAgICAgICAoMCwgX3V0aWwuYXNzZXJ0KShyZWFzb24gaW5zdGFuY2VvZiBFcnJvciwgImNhbmNlbCBtdXN0IGhhdmUgYSB2YWx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VtZW50c1sxXSA6IDE7CiAgICAgICAgbGV0IHRyYW5zZmVycyA9IGFyZ3VtZW50cy5sZW5ndGggPiAyID8gYXJndW1lbnRzWzJdIDogdW5kZWZpbmVkOwogICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICAgIGNvbnN0IGxhc3REZXNpcmVkU2l6ZSA9IHRoaXMuZGVzaXJlZFNpemU7CiAgICAgICAgdGhpcy5kZXNpcmVkU2l6ZSAtPSBzaXplOwogICAgICAgIGlmIChsYXN0RGVzaXJlZFNpemUgPiAwICYmIHRoaXMuZGVzaXJlZFNpemUgPD0gMCkgewogICAgICAgICAgdGhpcy5zaW5rQ2FwYWJpbGl0eSA9ICgwLCBfdXRpbC5jcmVhdGVQcm9taXNlQ2FwYWJpbGl0eSkoKTsKICAgICAgICAgIHRoaXMucmVhZHkgPSB0aGlzLnNpbmtDYXBhYmlsaXR5LnByb21pc2U7CiAgICAgICAgfQogICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5FTlFVRVVFLAogICAgICAgICAgc3RyZWFtSWQsCiAgICAgICAgICBjaHVuawogICAgICAgIH0sIHRyYW5zZmVycyk7CiAgICAgIH0sCiAgICAgIGNsb3NlKCkgewogICAgICAgIGlmICh0aGlzLmlzQ2FuY2VsbGVkKSB7CiAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICAgIHRoaXMuaXNDYW5jZWxsZWQgPSB0cnVlOwogICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5DTE9TRSwKICAgICAgICAgIHN0cmVhbUlkCiAgICAgICAg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yZXNvbHZlKCk7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgIHN0cmVhbUNvbnRyb2xsZXIuc3RhcnRDYWxsLnJlamVjdCh3cmFwUmVhc29uKGRhdGEucmVhc29uKSk7CiAgICAgICAgfQogICAgICAgIGJyZWFrOwogICAgICBjYXNlIFN0cmVhbUtpbmQuUFVMTF9DT01QTEVURToKICAgICAgICBpZiAoZGF0YS5zdWNjZXNzKSB7CiAgICAgICAgICBzdHJlYW1Db250cm9sbGVyLnB1bGxDYWxsLnJlc29sdmUoKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgc3RyZWFtQ29udHJvbGxlci5wdWxsQ2FsbC5yZWplY3Qod3JhcFJlYXNvbihkYXRhLnJlYXNvbikpOwogICAgICAgIH0KICAgICAgICBicmVhazsKICAgICAgY2FzZSBTdHJlYW1LaW5kLlBVTEw6CiAgICAgICAgaWYgKCFzdHJlYW1TaW5rKSB7CiAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuUFVMTF9DT01QTEVURSwKICAgICAgICAgICAgc3RyZWFtSWQsCiAgICAgICAgICAgIHN1Y2Nlc3M6IHRydWUKICAgICAgICAgIH0pOwogICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgIGlmIChzdHJlYW1TaW5rLmRlc2lyZWRTaXplIDw9IDAgJiYgZGF0YS5kZXNpcmVkU2l6ZSA+IDApIHsKICAgICAgICAgIHN0cmVhbVNpbmsuc2lua0NhcGFiaWxpdHkucmVzb2x2ZSgpOwogICAgICAgIH0KICAgICAgICBzdHJlYW1TaW5rLmRlc2lyZWRTaXplID0gZGF0YS5kZXNpcmVkU2l6ZTsKICAgICAgICBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSkgewogICAgICAgICAgcmVzb2x2ZShzdHJlYW1TaW5rLm9uUHVsbCAmJiBzdHJlYW1TaW5rLm9uUHVsbCgpKTsKICAgICAgICB9KS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgIHRhcmdldE5hbWUsCiAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5QVUxMX0NPTVBMRVRFLAogICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgc3VjY2VzczogdHJ1ZQogICAgICAgICAgfSk7CiAgICAgICAgfSwgZnVuY3Rpb24gKHJlYXNvbikgewogICAgICAgICAgY29tT2JqLnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgc291cmNlTmFtZSwKICAgICAgICAgICAgdGFyZ2V0TmFtZSwKICAgICAgICAgICAgc3RyZWFtOiBTdHJlYW1LaW5kLlBVTExfQ09NUExFVEUsCiAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICByZWFzb246IHdyYXBSZWFzb24ocmVhc29uKQogICAgICAgICAgfSk7CiAgICAgICAgfSk7CiAgICAgICAgYnJlYWs7CiAgICAgIGNhc2UgU3RyZWFtS2luZC5FTlFVRVVFOgogICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHN0cmVhbUNvbnRyb2xsZXIsICJlbnF1ZXVlIHNob3VsZCBoYXZlIHN0cmVhbSBjb250cm9sbGVyIik7CiAgICAgICAgaWYgKHN0cmVhbUNvbnRyb2xsZXIuaXNDbG9zZWQpIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBzdHJlYW1Db250cm9sbGVyLmNvbnRyb2xsZXIuZW5xdWV1ZShkYXRhLmNodW5rKTsKICAgICAgICBicmVhazsKICAgICAgY2FzZSBTdHJlYW1LaW5kLkNMT1NFOgogICAgICAgICgwLCBfdXRpbC5hc3NlcnQpKHN0cmVhbUNvbnRyb2xsZXIsICJjbG9zZSBzaG91bGQ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SBTdHJlYW1LaW5kLkNBTkNFTDoKICAgICAgICBpZiAoIXN0cmVhbVNpbmspIHsKICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgICAgICBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSkgewogICAgICAgICAgcmVzb2x2ZShzdHJlYW1TaW5rLm9uQ2FuY2VsICYmIHN0cmVhbVNpbmsub25DYW5jZWwod3JhcFJlYXNvbihkYXRhLnJlYXNvbikpKTsKICAgICAgICB9KS50aGVuKGZ1bmN0aW9uICgpIHsKICAgICAgICAgIGNvbU9iai5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgIHNvdXJjZU5hbWUsCiAgICAgICAgICAgIHRhcmdldE5hbWUsCiAgICAgICAgICAgIHN0cmVhbTogU3RyZWFtS2luZC5DQU5DRUxfQ09NUExFVEUsCiAgICAgICAgICAgIHN0cmVhbUlkLAogICAgICAgICAgICBzdWNjZXNzOiB0cnVlCiAgICAgICAgICB9KTsKICAgICAgICB9LCBmdW5jdGlvbiAocmVhc29uKSB7CiAgICAgICAgICBjb21PYmoucG9zdE1lc3NhZ2UoewogICAgICAgICAgICBzb3VyY2VOYW1lLAogICAgICAgICAgICB0YXJnZXROYW1lLAogICAgICAgICAgICBzdHJlYW06IFN0cmVhbUtpbmQuQ0FOQ0VMX0NPTVBMRVRFLAogICAgICAgICAgICBzdHJlYW1JZCwKICAgICAgICAgICAgcmVhc29uOiB3cmFwUmVhc29uKHJlYXNvbikKICAgICAgICAgIH0pOwogICAgICAgIH0pOwogICAgICAgIHN0cmVhbVNpbmsuc2lua0NhcGFiaWxpdHkucmVqZWN0KHdyYXBSZWFzb24oZGF0YS5yZWFzb24pKTsKICAgICAgICBzdHJlYW1TaW5rLmlzQ2FuY2VsbGVkID0gdHJ1ZTsKICAgICAgICBkZWxldGUgdGhpcy5zdHJlYW1TaW5rc1tzdHJlYW1JZF07CiAgICAgICAgYnJlYWs7CiAgICAgIGRlZmF1bHQ6CiAgICAgICAgd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vcnRzX18gPSB7fTsKLy8gVGhpcyBlbnRyeSBuZWVkIHRvIGJlIHdyYXBwZWQgaW4gYW4gSUlGRSBiZWNhdXNlIGl0IG5lZWQgdG8gYmUgaW4gc3RyaWN0IG1vZGUuCigoKSA9PiB7CiJ1c2Ugc3RyaWN0IjsKdmFyIGV4cG9ydHMgPSBfX3dlYnBhY2tfZXhwb3J0c19fOwoKCk9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAiX19lc01vZHVsZSIsICh7CiAgdmFsdWU6IHRydWUKfSkpOwpPYmplY3QuZGVmaW5lUHJvcGVydHkoZXhwb3J0cywgIldvcmtlck1lc3NhZ2VIYW5kbGVyIiwgKHsKICBlbnVtZXJhYmxlOiB0cnVlLAogIGdldDogZnVuY3Rpb24gKCkgewogICAgcmV0dXJuIF93b3JrZXIuV29ya2VyTWVzc2FnZUhhbmRsZXI7CiAgfQp9KSk7CnZhciBfd29ya2VyID0gX193X3BkZmpzX3JlcXVpcmVfXygxKTsKY29uc3QgcGRmanNWZXJzaW9uID0gJzMuNS4xMjInOwpjb25zdCBwZGZqc0J1aWxkID0gJzYyMjQ2NWRjMic7Cn0pKCk7CgovKioqKioqLyAJcmV0dXJuIF9fd2VicGFja19leHBvcnRzX187Ci8qKioqKiovIH0pKCkKOwp9KTsKLy8jIHNvdXJjZU1hcHBpbmdVUkw9cGRmLndvcmtlci5qcy5tYXA=",H=`data:text/javascript;base64,${o}`,K=`data:text/javascript;base64,${h}`;class J{constructor(I,g){C(this,"pdfDoc"),C(this,"pageNumber"),C(this,"total"),C(this,"dom"),C(this,"pdf"),C(this,"onError"),C(this,"onLoad"),C(this,"getPdfPage",G=>new Promise((b,Y)=>{this.pdfDoc?this.pdfDoc.getPage(G).then(W=>{const l=W.getViewport(),d=document.createElement("canvas");this.dom.appendChild(d);const w=d.getContext("2d"),B=document.body.clientWidth-20,[a,M,m,i]=l.viewBox,V=m>B?B/m:1;d.width=m,d.height=i,l.width=m,l.height=i,d.style.width=Math.floor(l.width)*V+"px",d.style.height=Math.floor(l.height)*V+"px";const R={canvasContext:w,viewport:l,transform:[1,0,0,-1,0,l.height]};W.render(R),b({success:!0,data:W})}):Y({success:!1,data:null,message:"pdfDoc is undefined"})})),C(this,"pdfPreview",()=>{N(H).then(()=>{window.pdfjsLib.GlobalWorkerOptions.workerSrc=K,window.pdfjsLib.getDocument(this.pdf).promise.then(async G=>{this.pdfDoc=G,this.total=G.numPages,this.onLoad&&this.onLoad({success:!0,data:this.pdfDoc});for(let b=1;b<=this.total;b++)await this.getPdfPage(b)})}).catch(G=>{this.onError&&this.onError({success:!1,data:G,message:G})})}),C(this,"prevPage",()=>{this.pageNumber>1?this.pageNumber-=1:this.pageNumber=1,this.getPdfPage(this.pageNumber)}),C(this,"nextPage",()=>{this.pageNumbernew Promise((I,g)=>{const Z=new FileReader;Z.readAsDataURL(A),Z.onload=()=>{I(Z.result)},Z.onerror=c=>{g(c)},Z.onabort=c=>{g(c)}}),u=async(A,I)=>{try{if(typeof window<"u"){const g=await F(A);g&&new J(g,I).pdfPreview()}}catch{}};export{u as renderPdf}; diff --git a/assets/chunks/pwa-install.es.DI7OvJx5.js b/assets/chunks/pwa-install.es.DI7OvJx5.js new file mode 100644 index 0000000000..e6f600a900 --- /dev/null +++ b/assets/chunks/pwa-install.es.DI7OvJx5.js @@ -0,0 +1,39 @@ +/** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const Y=globalThis,Ce=Y.ShadowRoot&&(Y.ShadyCSS===void 0||Y.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ze=Symbol(),Me=new WeakMap;let Qe=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==ze)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(Ce&&e===void 0){const i=t!==void 0&&t.length===1;i&&(e=Me.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&Me.set(t,e))}return e}toString(){return this.cssText}};const gt=a=>new Qe(typeof a=="string"?a:a+"",void 0,ze),bt=(a,...e)=>{const t=a.length===1?a[0]:e.reduce((i,o,s)=>i+(l=>{if(l._$cssResult$===!0)return l.cssText;if(typeof l=="number")return l;throw Error("Value passed to 'css' function must be a 'css' function result: "+l+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(o)+a[s+1],a[0]);return new Qe(t,a,ze)},mt=(a,e)=>{if(Ce)a.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const i=document.createElement("style"),o=Y.litNonce;o!==void 0&&i.setAttribute("nonce",o),i.textContent=t.cssText,a.appendChild(i)}},Ie=Ce?a=>a:a=>a instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return gt(t)})(a):a;/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const{is:ut,defineProperty:ft,getOwnPropertyDescriptor:vt,getOwnPropertyNames:wt,getOwnPropertySymbols:yt,getPrototypeOf:xt}=Object,E=globalThis,Ue=E.trustedTypes,kt=Ue?Ue.emptyScript:"",X=E.reactiveElementPolyfillSupport,O=(a,e)=>a,F={toAttribute(a,e){switch(e){case Boolean:a=a?kt:null;break;case Object:case Array:a=a==null?a:JSON.stringify(a)}return a},fromAttribute(a,e){let t=a;switch(e){case Boolean:t=a!==null;break;case Number:t=a===null?null:Number(a);break;case Object:case Array:try{t=JSON.parse(a)}catch{t=null}}return t}},je=(a,e)=>!ut(a,e),He={attribute:!0,type:String,converter:F,reflect:!1,hasChanged:je};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),E.litPropertyMetadata??(E.litPropertyMetadata=new WeakMap);let R=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=He){if(t.state&&(t.attribute=!1),this._$Ei(),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),o=this.getPropertyDescriptor(e,i,t);o!==void 0&&ft(this.prototype,e,o)}}static getPropertyDescriptor(e,t,i){const{get:o,set:s}=vt(this.prototype,e)??{get(){return this[t]},set(l){this[t]=l}};return{get(){return o==null?void 0:o.call(this)},set(l){const n=o==null?void 0:o.call(this);s.call(this,l),this.requestUpdate(e,n,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??He}static _$Ei(){if(this.hasOwnProperty(O("elementProperties")))return;const e=xt(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(O("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(O("properties"))){const t=this.properties,i=[...wt(t),...yt(t)];for(const o of i)this.createProperty(o,t[o])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[i,o]of t)this.elementProperties.set(i,o)}this._$Eh=new Map;for(const[t,i]of this.elementProperties){const o=this._$Eu(t,i);o!==void 0&&this._$Eh.set(o,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const o of i)t.unshift(Ie(o))}else e!==void 0&&t.push(Ie(e));return t}static _$Eu(e,t){const i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$EO)==null||t.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return mt(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(t=>{var i;return(i=t.hostConnected)==null?void 0:i.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(t=>{var i;return(i=t.hostDisconnected)==null?void 0:i.call(t)})}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$EC(e,t){var s;const i=this.constructor.elementProperties.get(e),o=this.constructor._$Eu(e,i);if(o!==void 0&&i.reflect===!0){const l=(((s=i.converter)==null?void 0:s.toAttribute)!==void 0?i.converter:F).toAttribute(t,i.type);this._$Em=e,l==null?this.removeAttribute(o):this.setAttribute(o,l),this._$Em=null}}_$AK(e,t){var s;const i=this.constructor,o=i._$Eh.get(e);if(o!==void 0&&this._$Em!==o){const l=i.getPropertyOptions(o),n=typeof l.converter=="function"?{fromAttribute:l.converter}:((s=l.converter)==null?void 0:s.fromAttribute)!==void 0?l.converter:F;this._$Em=o,this[o]=n.fromAttribute(t,l.type),this._$Em=null}}requestUpdate(e,t,i){if(e!==void 0){if(i??(i=this.constructor.getPropertyOptions(e)),!(i.hasChanged??je)(this[e],t))return;this.P(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(e,t,i){this._$AL.has(e)||this._$AL.set(e,t),i.reflect===!0&&this._$Em!==e&&(this._$Ej??(this._$Ej=new Set)).add(e)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[s,l]of this._$Ep)this[s]=l;this._$Ep=void 0}const o=this.constructor.elementProperties;if(o.size>0)for(const[s,l]of o)l.wrapped!==!0||this._$AL.has(s)||this[s]===void 0||this.P(s,this[s],l)}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(i=this._$EO)==null||i.forEach(o=>{var s;return(s=o.hostUpdate)==null?void 0:s.call(o)}),this.update(t)):this._$EU()}catch(o){throw e=!1,this._$EU(),o}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$EO)==null||t.forEach(i=>{var o;return(o=i.hostUpdated)==null?void 0:o.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Ej&&(this._$Ej=this._$Ej.forEach(t=>this._$EC(t,this[t]))),this._$EU()}updated(e){}firstUpdated(e){}};R.elementStyles=[],R.shadowRootOptions={mode:"open"},R[O("elementProperties")]=new Map,R[O("finalized")]=new Map,X==null||X({ReactiveElement:R}),(E.reactiveElementVersions??(E.reactiveElementVersions=[])).push("2.0.4");/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const B=globalThis,G=B.trustedTypes,Oe=G?G.createPolicy("lit-html",{createHTML:a=>a}):void 0,Xe="$lit$",A=`lit$${Math.random().toFixed(9).slice(2)}$`,et="?"+A,$t=`<${et}>`,z=document,q=()=>z.createComment(""),W=a=>a===null||typeof a!="object"&&typeof a!="function",Te=Array.isArray,_t=a=>Te(a)||typeof(a==null?void 0:a[Symbol.iterator])=="function",ee=`[ +\f\r]`,M=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Be=/-->/g,Ne=/>/g,S=RegExp(`>|${ee}(?:([^\\s"'>=/]+)(${ee}*=${ee}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`,"g"),qe=/'/g,We=/"/g,tt=/^(?:script|style|textarea|title)$/i,At=a=>(e,...t)=>({_$litType$:a,strings:e,values:t}),Et=At(1),j=Symbol.for("lit-noChange"),u=Symbol.for("lit-nothing"),Ve=new WeakMap,C=z.createTreeWalker(z,129);function at(a,e){if(!Te(a)||!a.hasOwnProperty("raw"))throw Error("invalid template strings array");return Oe!==void 0?Oe.createHTML(e):e}const St=(a,e)=>{const t=a.length-1,i=[];let o,s=e===2?"":e===3?"":"",l=M;for(let n=0;n"?(l=o??M,d=-1):p[1]===void 0?d=-2:(d=l.lastIndex-p[2].length,g=p[1],l=p[3]===void 0?S:p[3]==='"'?We:qe):l===We||l===qe?l=S:l===Be||l===Ne?l=M:(l=S,o=void 0);const x=l===S&&a[n+1].startsWith("/>")?" ":"";s+=l===M?r+$t:d>=0?(i.push(g),r.slice(0,d)+Xe+r.slice(d)+A+x):r+A+(d===-2?n:x)}return[at(a,s+(a[t]||"")+(e===2?"":e===3?"":"")),i]};let le=class it{constructor({strings:e,_$litType$:t},i){let o;this.parts=[];let s=0,l=0;const n=e.length-1,r=this.parts,[g,p]=St(e,t);if(this.el=it.createElement(g,i),C.currentNode=this.el.content,t===2||t===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(o=C.nextNode())!==null&&r.length0){o.textContent=G?G.emptyScript:"";for(let x=0;x2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=u}_$AI(e,t=this,i,o){const s=this.strings;let l=!1;if(s===void 0)e=L(this,e,t,0),l=!W(e)||e!==this._$AH&&e!==j,l&&(this._$AH=e);else{const n=e;let r,g;for(e=s[0],r=0;r{const i=(t==null?void 0:t.renderBefore)??e;let o=i._$litPart$;if(o===void 0){const s=(t==null?void 0:t.renderBefore)??null;i._$litPart$=o=new Re(e.insertBefore(q(),s),s,void 0,t??{})}return o._$AI(a),o};/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */let N=class extends R{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Tt(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return j}};var Je;N._$litElement$=!0,N.finalized=!0,(Je=globalThis.litElementHydrateSupport)==null||Je.call(globalThis,{LitElement:N});const ae=globalThis.litElementPolyfillSupport;ae==null||ae({LitElement:N});(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.1");/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const Rt=a=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(a,e)}):customElements.define(a,e)};/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const Lt={attribute:!0,type:String,converter:F,reflect:!1,hasChanged:je},Mt=(a=Lt,e,t)=>{const{kind:i,metadata:o}=t;let s=globalThis.litPropertyMetadata.get(o);if(s===void 0&&globalThis.litPropertyMetadata.set(o,s=new Map),s.set(t.name,a),i==="accessor"){const{name:l}=t;return{set(n){const r=e.get.call(this);e.set.call(this,n),this.requestUpdate(l,r,a)},init(n){return n!==void 0&&this.P(l,void 0,a),n}}}if(i==="setter"){const{name:l}=t;return function(n){const r=this[l];e.call(this,n),this.requestUpdate(l,r,a)}}throw Error("Unsupported decorator location: "+i)};function st(a){return(e,t)=>typeof t=="object"?Mt(a,e,t):((i,o,s)=>{const l=o.hasOwnProperty(s);return o.constructor.createProperty(s,l?{...i,wrapped:!0}:i),l?Object.getOwnPropertyDescriptor(o,s):void 0})(a,e,t)}/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */function It(a){return st({...a,state:!0,attribute:!1})}/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const Ut={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Ht=a=>(...e)=>({_$litDirective$:a,values:e});let Ot=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};/** + * @license + * Copyright 2018 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const Bt=Ht(class extends Ot{constructor(a){var e;if(super(a),a.type!==Ut.ATTRIBUTE||a.name!=="class"||((e=a.strings)==null?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(a){return" "+Object.keys(a).filter(e=>a[e]).join(" ")+" "}update(a,[e]){var i,o;if(this.st===void 0){this.st=new Set,a.strings!==void 0&&(this.nt=new Set(a.strings.join(" ").split(/\s/).filter(s=>s!=="")));for(const s in e)e[s]&&!((i=this.nt)!=null&&i.has(s))&&this.st.add(s);return this.render(e)}const t=a.element.classList;for(const s of this.st)s in e||(t.remove(s),this.st.delete(s));for(const s in e){const l=!!e[s];l===this.st.has(s)||(o=this.nt)!=null&&o.has(s)||(l?(t.add(s),this.st.add(s)):(t.remove(s),this.st.delete(s)))}return j}});var c={d:(a,e)=>{for(var t in e)c.o(e,t)&&!c.o(a,t)&&Object.defineProperty(a,t,{enumerable:!0,get:e[t]})},o:(a,e)=>Object.prototype.hasOwnProperty.call(a,e),r:a=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})}},lt={};c.d(lt,{w:()=>f});var ne={};c.r(ne),c.d(ne,{templates:()=>Qt});var re={};c.r(re),c.d(re,{templates:()=>Xt});var de={};c.r(de),c.d(de,{templates:()=>ea});var ce={};c.r(ce),c.d(ce,{templates:()=>ta});var pe={};c.r(pe),c.d(pe,{templates:()=>aa});var he={};c.r(he),c.d(he,{templates:()=>ia});var ge={};c.r(ge),c.d(ge,{templates:()=>oa});var be={};c.r(be),c.d(be,{templates:()=>sa});var me={};c.r(me),c.d(me,{templates:()=>la});var ue={};c.r(ue),c.d(ue,{templates:()=>na});var fe={};c.r(fe),c.d(fe,{templates:()=>ra});var ve={};c.r(ve),c.d(ve,{templates:()=>da});var we={};c.r(we),c.d(we,{templates:()=>ca});var ye={};c.r(ye),c.d(ye,{templates:()=>pa});var xe={};c.r(xe),c.d(xe,{templates:()=>ha});var ke={};c.r(ke),c.d(ke,{templates:()=>ga});var $e={};c.r($e),c.d($e,{templates:()=>ba});var _e={};c.r(_e),c.d(_e,{templates:()=>ma});var Ae={};c.r(Ae),c.d(Ae,{templates:()=>ua});var Ee={};c.r(Ee),c.d(Ee,{templates:()=>fa});const h=(a=>{var e={};return c.d(e,a),e})({LitElement:()=>N,css:()=>bt,html:()=>Et}),nt=(a,e,t)=>{let i=a[0];for(let o=1;o{return typeof(e=a)!="string"&&"strTag"in e?nt(a.strings,a.values):a;var e};let k=rt,Ze=!1;const Se="lit-localize-status";class Nt{constructor(e){this.__litLocalizeEventHandler=t=>{t.detail.status==="ready"&&this.host.requestUpdate()},this.host=e}hostConnected(){window.addEventListener(Se,this.__litLocalizeEventHandler)}hostDisconnected(){window.removeEventListener(Se,this.__litLocalizeEventHandler)}}const qt=a=>a.addController(new Nt(a));class dt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}resolve(e){this.settled=!0,this._resolve(e)}reject(e){this.settled=!0,this._reject(e)}}const _=[];for(let a=0;a<256;a++)_[a]=(a>>4&15).toString(16)+(15&a).toString(16);const Wt="",Vt="h",Zt="s";function Yt(a,e){return(e?Vt:Zt)+function(t){let i=0,o=8997,s=0,l=33826,n=0,r=40164,g=0,p=52210;for(let d=0;d>>16,o=65535&i,n+=s>>>16,l=65535&s,p=g+(n>>>16)&65535,r=65535&n;return _[p>>8]+_[255&p]+_[r>>8]+_[255&r]+_[l>>8]+_[255&l]+_[o>>8]+_[255&o]}(typeof a=="string"?a:a.join(Wt))}const Ye=new WeakMap,Fe=new Map;function Ft(a,e,t){if(a){const i=(t==null?void 0:t.id)??function(s){const l=typeof s=="string"?s:s.strings;let n=Fe.get(l);return n===void 0&&(n=Yt(l,typeof s!="string"&&!("strTag"in s)),Fe.set(l,n)),n}(e),o=a[i];if(o){if(typeof o=="string")return o;if("strTag"in o)return nt(o.strings,e.values,o.values);{let s=Ye.get(o);return s===void 0&&(s=o.values,Ye.set(o,s)),{...o,values:s.map(l=>e.values[l])}}}}return rt(e)}function ie(a){window.dispatchEvent(new CustomEvent(Se,{detail:a}))}let oe,ct,K,De,pt,J="",D=new dt;D.resolve();let V=0;const Gt=()=>J,Kt=a=>{if(a===(oe??J))return D.promise;if(!K||!De)throw Error("Internal error");if(!K.has(a))throw Error("Invalid locale code");V++;const e=V;return oe=a,D.settled&&(D=new dt),ie({status:"loading",loadingLocale:a}),(a===ct?Promise.resolve({templates:void 0}):De(a)).then(t=>{V===e&&(J=a,oe=void 0,pt=t.templates,ie({status:"ready",readyLocale:a}),D.resolve())},t=>{V===e&&(ie({status:"error",errorLocale:a,errorMessage:t.toString()}),D.reject(t))}),D.promise},b=(a=>{var e={};return c.d(e,a),e})({customElement:()=>Rt,property:()=>st,state:()=>It}),Jt=["cs","de","el","es","fr","it","ja","km","ko","nl","no","pl","pt","ru","sr","sv","tr","uk","zh-CN","zh-HK"],Qt={s182ab2d6c997515f:"Добавьте его на главный экран, чтобы получить дополнительные возможности и удобство использования.",s1b9047d53d9f9d22:'2) Нажать "Поделиться"',s37a9e8aec5713460:"Подробнее",s5c6aad7a7e4a1437:'3) Нажать "На экран «Домой»"',s6196153c4b0c1ea0:"Установить",s922329d6f6213590:"Добавить в Dock",sa5ef80b4bb9b39f8:"Свернуть",sa7551383d1897fcc:'2) Нажмите "Добавить в Dock"',sba52286c21552a4e:"Установите это на ваше устройство, чтобы получить дополнительные возможности и удобство использования.",sc79fd7641eb9a975:"Спрятать Инструкцию",scdaf4bbff76674c8:"На экран «Домой»",sdfe23506a3b0cdc8:"1) Открыть в Safari браузере",se740f75b95a51807:"Добавьте его в Dock, чтобы получить дополнительные возможности и удобство использования.",sfea652f6580ff086:"Этот веб-сайт имеет функционал приложения."},Xt={s182ab2d6c997515f:"Daha iyi bir deneyim ve kolay erişim için Ana Ekranınıza ekleyin.",s1b9047d53d9f9d22:"2) Gezinme çubuğunda Paylaş'a basın",s37a9e8aec5713460:"Daha Fazla",s5c6aad7a7e4a1437:"3) Ana Ekrana Ekle'ye basın",s6196153c4b0c1ea0:"Yükle",s922329d6f6213590:"Dock’a Ekle",sa5ef80b4bb9b39f8:"Küçült",sa7551383d1897fcc:"2) Dock’a ekleye basın",sba52286c21552a4e:"Daha iyi bir deneyim ve kolay erişim için cihazınıza yükleyin.",sc79fd7641eb9a975:"Talimatları gizle",scdaf4bbff76674c8:"Ana Ekrana Ekle",sdfe23506a3b0cdc8:"1) Safari tarayıcısında açın",se740f75b95a51807:"Daha iyi bir deneyim ve kolay erişim için Dock’a ekleyin.",sfea652f6580ff086:"Bu site uygulama işlevselliğine sahiptir."},ea={s182ab2d6c997515f:"Fügen Sie es zu Ihrem Startbildschirm hinzu, um eine umfassende Erfahrung und einen leichten Zugriff zu erhalten.",s1b9047d53d9f9d22:"2) Drücken Sie auf Teilen in der Navigationsleiste",s37a9e8aec5713460:"Mehr",s5c6aad7a7e4a1437:"3) Drücken Sie Hinzufügen zum Startbildschirm",s6196153c4b0c1ea0:"Installieren",s922329d6f6213590:"Zum Dock hinzufügen",sa5ef80b4bb9b39f8:"Weniger",sa7551383d1897fcc:"2) Drücken Sie auf Zum Dock hinzufügen",sba52286c21552a4e:"Installieren Sie es auf Ihrem Gerät für eine umfassende Erfahrung und einen leichten Zugriff.",sc79fd7641eb9a975:"Anleitung ausblenden",scdaf4bbff76674c8:"Hinzufügen zum Startbildschirm",sdfe23506a3b0cdc8:"1) In Safari-Browser öffnen",se740f75b95a51807:"Fügen Sie es zu Ihrem Dock hinzu, um eine umfassende Erfahrung und einen leichten Zugriff zu erhalten.",sfea652f6580ff086:"Diese Website verfügt über App-Funktionalität."},ta={s182ab2d6c997515f:"Añádelo a tu pantalla de inicio para una experiencia amplia y acceso fácil.",s1b9047d53d9f9d22:"2) Presionar Compartir en la barra de direcciones",s37a9e8aec5713460:"Más",s5c6aad7a7e4a1437:"3) Presionar Añadir a pantalla de inicio",s6196153c4b0c1ea0:"Instalar",s922329d6f6213590:"Añadir al Dock",sa5ef80b4bb9b39f8:"Menos",sa7551383d1897fcc:"2) Presionar Añadir al Dock",sba52286c21552a4e:"Instálalo en tu dispositivo para una experiencia amplia y acceso fácil.",sc79fd7641eb9a975:"Esconder instrucciones",scdaf4bbff76674c8:"Añadir a pantalla de inicio",sdfe23506a3b0cdc8:"1) Abrir en el navegador web Safari",se740f75b95a51807:"Añádelo a tu Dock para una experiencia amplia y acceso fácil.",sfea652f6580ff086:"Este sitio tiene funcionalidad de aplicación."},aa={s182ab2d6c997515f:"Voeg het toe aan je startscherm voor een uitgebreide ervaring en gemakkelijke toegang.",s1b9047d53d9f9d22:"2) Druk op delen in de navigatiebalk",s37a9e8aec5713460:"Meer",s5c6aad7a7e4a1437:"3) Druk op Toevoegen aan het startscherm",s6196153c4b0c1ea0:"Installeren",s922329d6f6213590:"Toevoegen aan Dock",sa5ef80b4bb9b39f8:"Minder",sa7551383d1897fcc:"2) Druk op Toevoegen aan Dock",sba52286c21552a4e:"Installeer het op je apparaat voor een uitgebreide ervaring en gemakkelijke toegang.",sc79fd7641eb9a975:"Instructie verbergen",scdaf4bbff76674c8:"Toevoegen aan het startscherm",sdfe23506a3b0cdc8:"1) Open in Safari-browser",se740f75b95a51807:"Voeg het toe aan je Dock voor een uitgebreide ervaring en makkelijke toegang.",sfea652f6580ff086:"Deze site heeft app-functionaliteit."},ia={s182ab2d6c997515f:"Προσθέστε το στην οθόνη Αφετηρίας για εκτεταμένη εμπειρία και εύκολη πρόσβαση.",s1b9047d53d9f9d22:"2) Πατήστε Κοινοποίηση στη γραμμή πλοήγησης",s37a9e8aec5713460:"Περισσότερα",s5c6aad7a7e4a1437:"3) Πατήστε Προσθήκη στην οθόνη Αφετηρίας",s6196153c4b0c1ea0:"Εγκατάσταση",s922329d6f6213590:"Προσθήκη στην Πρόσβαση",sa5ef80b4bb9b39f8:"Λιγότερα",sa7551383d1897fcc:"2) Πατήστε Προσθήκη στην Πρόσβαση",sba52286c21552a4e:"Εγκαταστήστε το στη συσκευή σας για εκτεταμένη εμπειρία και εύκολη πρόσβαση.",sc79fd7641eb9a975:"Απόκρυψη Οδηγιών",scdaf4bbff76674c8:"Προσθήκη στην Οθόνη Αφετηρίας",sdfe23506a3b0cdc8:"1) Ανοίξτε τον περιηγητή Safari",se740f75b95a51807:"Προσθέστε το στην Πρόσβαση για εκτεταμένη εμπειρία και εύκολη πρόσβαση.",sfea652f6580ff086:"Αυτός ο ιστότοπος έχει λειτουργική εφαρμογής."},oa={s182ab2d6c997515f:"Ajoutez-le à votre écran d'accueil pour une expérience étendue et un accès facile.",s1b9047d53d9f9d22:"2) Appuyez sur Partager dans la barre de navigation",s37a9e8aec5713460:"Plus",s5c6aad7a7e4a1437:"3) Appuyez sur Ajouter à l'écran d'accueil",s6196153c4b0c1ea0:"Installer",s922329d6f6213590:"Ajouter au Dock",sa5ef80b4bb9b39f8:"Moins",sa7551383d1897fcc:"2) Appuyez sur Ajouter au Dock",sba52286c21552a4e:"Installez-le sur votre appareil pour une expérience complète et un accès facile.",sc79fd7641eb9a975:"Masquer les instructions",scdaf4bbff76674c8:"Ajouter à l'écran d'accueil",sdfe23506a3b0cdc8:"1) Ouvrir dans le navigateur Safari",se740f75b95a51807:"Ajoutez-le à votre Dock pour une expérience étendue et un accès facile.",sfea652f6580ff086:"Ce site possède des fonctionnalités d'application."},sa={s182ab2d6c997515f:"Додајте га на Home Screen за широке могућности и лак приступ.",s1b9047d53d9f9d22:"2) Притисните Share у навигационој траци",s37a9e8aec5713460:"Више",s5c6aad7a7e4a1437:"3) Притисните Add to Home Screen",s6196153c4b0c1ea0:"Инсталирај",sa5ef80b4bb9b39f8:"Мање",sa7551383d1897fcc:"3) Притисните Add to Dock",sba52286c21552a4e:"Инсталирајте га на вашем уређају за широке могућности и лак приступ.",sc79fd7641eb9a975:"Сакриј упутство",sdfe23506a3b0cdc8:"1) Отворите у Safari прегледачу",se740f75b95a51807:"Додајте га у вашу Dock за широке могућности и лак приступ.",sfea652f6580ff086:"Овај сајт има функционалност апликације.",s922329d6f6213590:"Add to Dock",scdaf4bbff76674c8:"Add to Home Screen"},la={s182ab2d6c997515f:"Dodaj do swojego Ekranu Głównego, aby uzyskać bogate doświadczenie i łatwy dostęp.",s1b9047d53d9f9d22:'2) Wybierz "Udostępnij"',s37a9e8aec5713460:"Więcej",s5c6aad7a7e4a1437:'3) Wybierz "Dodaj do Ekranu Głównego"',s6196153c4b0c1ea0:"Zainstaluj",s922329d6f6213590:"Dodaj do Docka",sa5ef80b4bb9b39f8:"Mniej",sa7551383d1897fcc:'2) Wybierz "Dodaj do Docka"',sba52286c21552a4e:"Zainstaluj na swoim urządzeniu, aby uzyskać bogate doświadczenie i łatwy dostęp.",sc79fd7641eb9a975:"Ukryj instrukcję",scdaf4bbff76674c8:"Dodaj do Ekranu Głównego",sdfe23506a3b0cdc8:"1) Otwórz przeglądarkę Safari",se740f75b95a51807:"Dodaj do swojego Docka, aby uzyskać bogate doświadczenie i łatwy dostęp.",sfea652f6580ff086:"Ta strona posiada funkcje aplikacji."},na={s182ab2d6c997515f:"Додайте на Домашній екран для зручного доступу та ширших можливостей.",s1b9047d53d9f9d22:"2) Натиснути «Поділитися»",s37a9e8aec5713460:"Детальніше",s5c6aad7a7e4a1437:"3) Натиснути «На Початковий екран»",s6196153c4b0c1ea0:"Встановити",s922329d6f6213590:"Додати на Dock",sa5ef80b4bb9b39f8:"Згорнути",sa7551383d1897fcc:"2) Натиснути «Додати на Dock»",sba52286c21552a4e:"Встановіть на ваш пристрій для зручного доступу та ширших можливостей.",sc79fd7641eb9a975:"Сховати Інструкцію",scdaf4bbff76674c8:"На Початковий экран",sdfe23506a3b0cdc8:"1) Відкрити в Safari браузері",se740f75b95a51807:"Додайте на панель Dock для зручного доступу та ширших можливостей.",sfea652f6580ff086:"Цей сайт має функції додатку."},ra={s182ab2d6c997515f:"將其加入主屏幕,以獲得更豐富的體驗和便捷訪問。",s1b9047d53d9f9d22:"2) 點擊列表上的分享按鈕",s37a9e8aec5713460:"詳細資訊",s5c6aad7a7e4a1437:"3) 點擊加入主畫面",s6196153c4b0c1ea0:"安裝",s922329d6f6213590:"添加到Dock欄",sa5ef80b4bb9b39f8:"簡短資訊",sa7551383d1897fcc:"2) 點選添加到Dock欄",sba52286c21552a4e:"在您的裝置上安裝它,以獲得更豐富的體驗和便捷訪問。",sc79fd7641eb9a975:"隱藏安裝流程",scdaf4bbff76674c8:"將App加入主畫面",sdfe23506a3b0cdc8:"1) 在Safari上瀏覽此網頁",se740f75b95a51807:"將其加入你的Dock欄,以獲得更豐富的體驗和便捷訪問。",sfea652f6580ff086:"此網站具有應用程式功能。"},da={s182ab2d6c997515f:"将其添加到主屏幕,以享受更丰富的体验并便于访问。",s1b9047d53d9f9d22:"2) 点击导航栏中的“分享”按钮",s37a9e8aec5713460:"更多",s5c6aad7a7e4a1437:"3) 点击“添加到主屏幕”",s6196153c4b0c1ea0:"安装",s922329d6f6213590:"添加到程序坞",sa5ef80b4bb9b39f8:"收起",sa7551383d1897fcc:"2) 点击“添加到程序坞”",sba52286c21552a4e:"在您的设备上安装,以享受更丰富的体验并便于访问。",sc79fd7641eb9a975:"隐藏安装步骤",scdaf4bbff76674c8:"添加到主屏幕",sdfe23506a3b0cdc8:"1) 在 Safari 浏览器中打开此页面",se740f75b95a51807:"将其添加到您的程序坞,以享受更全面的体验并便于访问。",sfea652f6580ff086:"此网站具备 App 功能特性。"},ca={s182ab2d6c997515f:"Aggiungilo alla schermata principale per un'esperienza più completa e un accesso facile.",s1b9047d53d9f9d22:"2) Premi Condividi nella barra di navigazione",s37a9e8aec5713460:"Più",s5c6aad7a7e4a1437:"3) Premi Aggiungi alla schermata principale",s6196153c4b0c1ea0:"Installa",s922329d6f6213590:"Aggiungi al Dock",sa5ef80b4bb9b39f8:"Meno",sa7551383d1897fcc:"2) Premi Aggiungi al Dock",sba52286c21552a4e:"Installalo sul tuo dispositivo per un'esperienza più completa e un accesso facile.",sc79fd7641eb9a975:"Nascondi istruzioni",scdaf4bbff76674c8:"Aggiungi alla schermata principale",sdfe23506a3b0cdc8:"1) Apri nel browser Safari",se740f75b95a51807:"Aggiungilo al Dock per un'esperienza più completa e un accesso facile.",sfea652f6580ff086:"Questo sito ha funzionalità di app."},pa={s182ab2d6c997515f:"Přidejte jej na plochu pro rozšířené využití a snadný přístup.",s1b9047d53d9f9d22:"2) Stiskněte tlačítko Sdílet na navigačním panelu",s37a9e8aec5713460:"Vice",s5c6aad7a7e4a1437:"3) Stiskněte tlačítko Přidat na plochu",s6196153c4b0c1ea0:"Nainstalovat",s922329d6f6213590:"Přidat do Docku",sa5ef80b4bb9b39f8:"Méně",sa7551383d1897fcc:"2) Stiskněte Přidat do Docku",sba52286c21552a4e:"Nainstalujte si jej na své zařízení pro rozšířené využití a snadný přístup.",sc79fd7641eb9a975:"Skrýt instrukce",scdaf4bbff76674c8:"Přidat na plochu",sdfe23506a3b0cdc8:"1) Otevřete v prohlížeči Safari",se740f75b95a51807:"Přidejte jej do svého Docku pro rozšířené využití a snadný přístup.",sfea652f6580ff086:"Tento web má funkce aplikace."},ha={s182ab2d6c997515f:"Legg den til på Hjem-skjermen din for å få en bedre brukeropplevelse og raskere tilgang.",s1b9047d53d9f9d22:"2) Trykk på Del-knappen i navigasjonslinjen",s37a9e8aec5713460:"Mer",s5c6aad7a7e4a1437:"3) Velg Legg til på Hjem-skjerm",s6196153c4b0c1ea0:"Installer",s922329d6f6213590:"Legg til i Dock",sa5ef80b4bb9b39f8:"Mindre",sa7551383d1897fcc:"2) Velg Legg til i Dock",sba52286c21552a4e:"Installer den på enheten din for å få en bedre brukeropplevelse og raskere tilgang.",sc79fd7641eb9a975:"Skjul instruksjoner",scdaf4bbff76674c8:"Legg til på Hjem-skjerm",sdfe23506a3b0cdc8:"1) Åpne i Safari",se740f75b95a51807:"Legg den til i Docken din for å få en bedre brukeropplevelse og raskere tilgang.",sfea652f6580ff086:"Denne siden har app-funksjonalitet."},ga={s182ab2d6c997515f:"Adicione à Tela de Início para uma melhor experiência e mais fácil acesso.",s1b9047d53d9f9d22:"2) Pressione Compartilhar na barra de endereço",s37a9e8aec5713460:"Mais",s5c6aad7a7e4a1437:"3) Pressione Adicionar à Tela de Início",s6196153c4b0c1ea0:"Instalar",s922329d6f6213590:"Adicionar ao Dock",sa5ef80b4bb9b39f8:"Menos",sa7551383d1897fcc:"2) Pressione Adicionar ao Dock",sba52286c21552a4e:"Instale no dispositivo para uma melhor experiência e mais fácil acesso.",sc79fd7641eb9a975:"Ocultar Instruções",scdaf4bbff76674c8:"Adicionar à Tela de Início",sdfe23506a3b0cdc8:"1) Abra no navegador Safari",se740f75b95a51807:"Adicione ao Dock para uma melhor experiência e mais fácil acesso.",sfea652f6580ff086:"Este site possui funcionalidade de aplicativo."},ba={s182ab2d6c997515f:"ホーム画面に追加して、幅広い体験と簡単なアクセスを実現してください。",s1b9047d53d9f9d22:"2) ナビゲーションバーで共有を押す",s37a9e8aec5713460:"展開",s5c6aad7a7e4a1437:"3) 「ホーム画面に追加」を押す",s6196153c4b0c1ea0:"インストール",s922329d6f6213590:"Dockに追加",sa5ef80b4bb9b39f8:"折りたたむ",sa7551383d1897fcc:"2) 「Dockに追加」を押す",sba52286c21552a4e:"デバイスにインストールすることで、より充実した体験と簡単なアクセスを実現できます。",sc79fd7641eb9a975:"説明を非表示",scdaf4bbff76674c8:"ホーム画面に追加",sdfe23506a3b0cdc8:"1) Safariで開く",se740f75b95a51807:"ドックに追加して、幅広い体験と簡単なアクセスを実現してください。",sfea652f6580ff086:"このサイトはアプリ機能があります。"},ma={s182ab2d6c997515f:"Lägg till på hemskärmen för att få en bättre användarupplevelse och enklare åtkomst.",s1b9047d53d9f9d22:"2) Tryck på Dela-knappen i verktygsfältet",s37a9e8aec5713460:"Mer",s5c6aad7a7e4a1437:"3) Välj Lägg till på hemskärmen",s6196153c4b0c1ea0:"Installera",s922329d6f6213590:"Lägg till i Dock",sa5ef80b4bb9b39f8:"Mindre",sa7551383d1897fcc:"2) Välj Lägg till i Dock",sba52286c21552a4e:"Installera den på din enhet för att få en bättre användarupplevelse och enklare åtkomst.",sc79fd7641eb9a975:"Göm instruktioner",scdaf4bbff76674c8:"Lägg till på hemskärmen",sdfe23506a3b0cdc8:"1) Öppna i Safari",se740f75b95a51807:"Lägg till i Dock för att få en bättre användarupplevelse och enklare åtkomst.",sfea652f6580ff086:"Denna webbsajt har app-funktionalitet."},ua={s182ab2d6c997515f:"더 많은 기능과 쉬운 접근을 위해 홈 화면에 추가해주세요.",s1b9047d53d9f9d22:"2) 내비게이션 바에서 공유 버튼 누르기",s37a9e8aec5713460:"더보기",s5c6aad7a7e4a1437:"3) 홈 화면에 추가 버튼 누르기",s6196153c4b0c1ea0:"설치",s922329d6f6213590:"Dock에 추가",sa5ef80b4bb9b39f8:"닫기",sa7551383d1897fcc:"2) Dock에 추가 버튼 누르기",sba52286c21552a4e:"더 많은 기능과 쉬운 접근을 위해 기기에 설치해주세요.",sc79fd7641eb9a975:"안내 숨기기",scdaf4bbff76674c8:"홈 화면에 추가",sdfe23506a3b0cdc8:"1) Safari 브라우저에서 열기",se740f75b95a51807:"더 많은 기능과 쉬운 접근을 위해 Dock에 추가해주세요.",sfea652f6580ff086:"이 사이트는 앱 기능을 가지고 있습니다."},fa={s182ab2d6c997515f:"បន្ថែមវាទៅកាន់ផ្ទាំងអេក្រង់ដើមដើម្បីទទួលបាននូវបទពិសោធន៍កាន់តែល្អនិងងាយស្រួលប្រើ។",s1b9047d53d9f9d22:"2) ចុចលើ ប៊ូតុងចែករំលែក នៅក្នុងរបារទិសដៅ",s37a9e8aec5713460:"បង្ហាញបន្ថែម",s5c6aad7a7e4a1437:"3) ចុចលើ បន្ថែមទៅកាន់ផ្ទាំងអេក្រង់ដើម",s6196153c4b0c1ea0:"តំឡើង",s922329d6f6213590:"បន្ថែមទៅកាន់ Dock",sa5ef80b4bb9b39f8:"បង្ហាញតិច",sa7551383d1897fcc:"2) ចុចលើ បន្ថែមទៅកាន់ Dock",sba52286c21552a4e:"តំឡើងវានៅលើឧបករណ៍របស់អ្នកដើម្បីទទួលបាននូវបទពិសោធន៍កាន់តែល្អនិងងាយស្រួលប្រើ។",sc79fd7641eb9a975:"បិទការណែនាំ",scdaf4bbff76674c8:"បន្ថែមទៅកាន់ផ្ទាំងអេក្រង់ដើម",sdfe23506a3b0cdc8:"1) បើកនៅក្នុងកម្មវិធី Safari",se740f75b95a51807:"បន្ថែមវាទៅកាន់ Dock ដើម្បីទទួលបាននូវបទពិសោធន៍កាន់តែល្អនិងងាយស្រួលប្រើ។",sfea652f6580ff086:"គេហទំព័រនេះមានមុខងារជាកម្មវិធី។"},ht=new Map([["ru",ne],["tr",re],["de",de],["es",ce],["nl",pe],["el",he],["fr",ge],["sr",be],["pl",me],["uk",ue],["zh-HK",fe],["zh-CN",ve],["it",we],["cs",ye],["no",xe],["pt",ke],["ja",$e],["sv",_e],["ko",Ae],["km",Ee]]),{getLocale:Ua,setLocale:Ge}=(I={sourceLocale:"en",targetLocales:Jt,loadLocale:async a=>ht.get(a)},function(a){if(Ze)throw Error("lit-localize can only be configured once");k=a,Ze=!0}((a,e)=>Ft(pt,a,e)),J=ct=I.sourceLocale,K=new Set(I.targetLocales),K.add(I.sourceLocale),De=I.loadLocale,{getLocale:Gt,setLocale:Kt});var I;class va{constructor(){this.icons=[{src:""}],this.screenshots=void 0,this.short_name="PWA",this.name="Progressive web application",this.description="Progressive web application"}}const wa=h.css`.gallery{position:relative;--scrollbar-background-color:#fff;--scrollbar-thumb-color:rgb(146, 146, 146);--scrollbar-thumb-hover-color:rgb(100, 100, 100);--nav-btn-background-color:#fff;--nav-btn-fill-color:#141414}.gallery .gallery_scroller{scroll-snap-type:x mandatory;overflow-x:auto;overflow-y:hidden;display:flex;align-items:center;padding:10px 13px;padding-bottom:10px;margin:0 10px;-webkit-overflow-scrolling:touch}.gallery .gallery_scroller img{border-radius:6px;max-height:min(45vh,500px);box-shadow:0 3px 10px 0 rgba(0,0,0,.15);scroll-snap-align:center;scroll-snap-stop:always;position:relative}.gallery .gallery_scroller img+img{margin-left:15px}.gallery .gallery_scroller::-webkit-scrollbar{width:4px;height:2px}.gallery .gallery_scroller::-webkit-scrollbar-thumb{background:var(--scrollbar-thumb-color);border-radius:4px}.gallery .gallery_scroller::-webkit-scrollbar-thumb:hover{background:var(--scrollbar-thumb-hover-color)}.gallery .gallery_scroller::-webkit-scrollbar-track{background:var(--scrollbar-background-color);border-radius:4px}.gallery .gallery_scroller .scroller_wrap{display:flex;flex-direction:row;padding-right:13px}.gallery .btn{position:absolute;display:flex;align-items:center;-webkit-user-select:none;user-select:none;top:50%;transform:translateY(-50%);height:30px;width:30px;border-radius:50%;background-color:var(--nav-btn-background-color);box-shadow:rgba(0,0,0,.3) 2px 4px 4px 1px;background-repeat:no-repeat;opacity:.8;z-index:1}.gallery .btn.prev{left:5px}.gallery .btn.prev svg{margin-left:4px}.gallery .btn.next{right:5px}.gallery .btn.next svg{transform:rotate(180deg);margin-left:6px}.gallery .btn:hover{box-shadow:rgba(0,0,0,.5) 2px 4px 4px 1px;cursor:pointer;opacity:1}.gallery .btn svg{width:20px;height:20px}.gallery .btn svg path{fill:var(--nav-btn-fill-color)}.gallery.apple_desktop{--scrollbar-background-color:rgba(0, 0, 0, 0.1);--scrollbar-thumb-color:rgb(100, 100, 100);--scrollbar-thumb-hover-color:rgba(0, 0, 0, 0.85)}.gallery.apple_desktop .gallery_scroller{margin:0;padding-top:15px}.gallery.apple_desktop .btn{height:26px;width:26px;box-shadow:rgba(0,0,0,.3) 0 2px 2px 1px}.gallery.apple_desktop .btn:hover{box-shadow:rgba(0,0,0,.3) 0 2px 2px 1px}.gallery.apple_desktop .btn:active{filter:brightness(95%)}.gallery.apple_desktop .btn:active .svg{filter:brightness(110%)}.gallery.apple_desktop .btn svg{width:12px;height:auto;opacity:1}.gallery.apple_desktop .btn svg{margin-left:7px}.gallery.apple_mobile .btn.prev svg{margin-left:7px}.gallery.apple_mobile .btn svg{width:16px;height:auto}.gallery.apple_desktop .btn,.gallery.apple_mobile .btn{opacity:1}@media(hover:none)and (pointer:coarse){.gallery .btn.next,.gallery .btn.prev{display:none}.gallery_scroller::-webkit-scrollbar{display:none}}@media(prefers-color-scheme:dark){.gallery{--scrollbar-background-color:#424242;--nav-btn-background-color:#555555;--nav-btn-fill-color:#fff}.gallery.apple_desktop{--scrollbar-thumb-color:var(--nav-btn-fill-color);--scrollbar-background-color:var(--nav-btn-background-color);--scrollbar-thumb-hover-color:var(--nav-btn-fill-color)}.gallery.apple_desktop .btn:active{filter:brightness(110%)}.gallery.apple_desktop .btn:active .svg{filter:brightness(90%)}}`,ya=(a,e,t,i)=>h.html`${a?h.html``:""}`;var se=function(a,e,t,i){var o,s=arguments.length,l=s<3?e:i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(a,e,t,i);else for(var n=a.length-1;n>=0;n--)(o=a[n])&&(l=(s<3?o(l):s>3?o(e,t,l):o(e,t))||l);return s>3&&l&&Object.defineProperty(e,t,l),l},Ke=function(a,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(a,e)};let H=class extends h.LitElement{constructor(){super(...arguments),this.screenshots=[],this.theme="default",this.calcScrollSize=()=>{const a=this.shadowRoot.querySelector("#paginated_gallery");if(!a)return;const e=a.querySelector(".gallery_scroller");if(!e)return;const t=Array.from(e.querySelectorAll("img"));if(!t)return;const i=t.find(o=>o.offsetWidth+o.offsetLeft>=e.scrollLeft);return i?{scroller:e,item:i}:void 0},this.scrollToNextPage=()=>{const a=this.calcScrollSize();a&&a.item.nextElementSibling&&a.scroller.scrollTo({top:0,left:a.scroller.scrollLeft+a.scroller.clientWidth+a.item.nextElementSibling.clientWidth/2,behavior:"smooth"})},this.scrollToPrevPage=()=>{const a=this.calcScrollSize();a&&a.item.previousElementSibling&&a.scroller.scrollTo({top:0,left:a.scroller.scrollLeft-a.scroller.clientWidth-a.item.previousElementSibling.clientWidth/2,behavior:"smooth"})},this._init=()=>{}}static get styles(){return wa}firstUpdated(){const a=this.calcScrollSize();a&&setTimeout(()=>{a.scroller.scrollTo({top:0,left:0})},300)}connectedCallback(){super.connectedCallback(),this._init()}render(){return h.html`${ya(this.screenshots,this.theme,this.scrollToNextPage,this.scrollToPrevPage)}`}};se([(0,b.property)(),Ke("design:type",Object)],H.prototype,"screenshots",void 0),se([(0,b.property)(),Ke("design:type",String)],H.prototype,"theme",void 0),H=se([(0,b.customElement)("pwa-gallery")],H);const xa=H,ka=(a,e,t,i)=>h.html`
icon
${location.hostname}
${e?h.html`
${e}
`:""}`,T=(a,e,t)=>{const i=new CustomEvent(e,{detail:{message:t}});a.dispatchEvent(i)};class v{static isAppleMobile(){return!(!(["iPhone","iPad","iPod"].includes(navigator.platform)||navigator.userAgent.match(/Mac/)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2)||!("serviceWorker"in navigator))}static isAppleDesktop(){const e=navigator.userAgent.toLowerCase();if(navigator.maxTouchPoints||!e.match(/macintosh/))return!1;const t=/version\/(\d{2})\./.exec(e);if(!(t&&t[1]&&parseInt(t[1])>=17))return!1;const i=!!document.createElement("audio").canPlayType('audio/wav; codecs="1"'),o=!!new OffscreenCanvas(1,1).getContext("webgl");return i&&o}static isStandalone(){return!!(window.matchMedia("(display-mode: standalone)").matches||"standalone"in navigator&&navigator.standalone===!0)}static async getInstalledRelatedApps(){if("getInstalledRelatedApps"in navigator)try{return await navigator.getInstalledRelatedApps().then(e=>e)}catch{}return[]}static async isRelatedAppsInstalled(){return!!(await this.getInstalledRelatedApps()).length}static eventInstalledSuccess(e){T(e,"pwa-install-success-event","App install success (Chromium/Android only)")}static eventInstalledFail(e){T(e,"pwa-install-fail-event","App install failed (Chromium/Android only)")}static eventUserChoiceResult(e,t){T(e,"pwa-user-choice-result-event",t)}static eventInstallAvailable(e){T(e,"pwa-install-available-event","App install available")}static eventInstallHowTo(e){T(e,"pwa-install-how-to-event","App install instruction showed")}static eventGallery(e){T(e,"pwa-install-gallery-event","App install gallery showed")}static normalizeManifestAssetUrls(e,t){const i=new URL(t,document.location.href);[...e.icons||[],...e.screenshots||[]].forEach(o=>{o.src=new URL(o.src,i).href})}}var U=function(a,e,t,i){var o,s=arguments.length,l=s<3?e:i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(a,e,t,i);else for(var n=a.length-1;n>=0;n--)(o=a[n])&&(l=(s<3?o(l):s>3?o(e,t,l):o(e,t))||l);return s>3&&l&&Object.defineProperty(e,t,l),l},Z=function(a,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(a,e)};let P=class extends h.LitElement{constructor(){super(...arguments),this.props={name:"",description:"",icon:""},this.install={handleEvent:()=>{}},this.hideDialog=()=>{},this.disableClose=!1,this._callInstall=()=>{this.install.handleEvent()},this._callHide=()=>{this.hideDialog(),this.setupAppearence()},this.bindedElement=null,this._saveBodyStyle=document.body.style.overscrollBehaviorY,this.dragMobileSheet=(a,e,t)=>{if(!a||!e||!t)return null;let i=0;const o=e.clientHeight+t.clientHeight,s=p=>p.clientY||(p.changedTouches&&p.changedTouches.length?p.changedTouches[0].clientY:0),l=p=>{window.addEventListener("mouseup",n),window.addEventListener("mousemove",r),window.addEventListener("touchend",n),window.addEventListener("touchmove",r),i=s(p)-e.getBoundingClientRect().top,document.body.style.overscrollBehaviorY="none"},n=p=>{if(document.body.style.overscrollBehaviorY=this._saveBodyStyle,!this.disableClose&&s(p)>=window.innerHeight-25)g(p,window.innerHeight+50,!0);else if(window.innerHeight-s(p)>a.clientHeight/2.5){g(p,window.innerHeight-a.clientHeight);try{v.eventGallery(this.getRootNode().host)}catch{}}else g(p,window.innerHeight-o-35)},r=p=>{const d=s(p);this.disableClose&&window.innerHeight-d<70||d<=window.innerHeight-a.clientHeight+i||(a.style.setProperty("transition","none"),a.style.setProperty("--translateY",`translateY(${d-i}px)`))},g=(p,d,m)=>{window.removeEventListener("mouseup",n),window.removeEventListener("mousemove",r),window.removeEventListener("touchend",n),window.removeEventListener("touchmove",r),window.innerWidth>=768||(!d&&s(p)>=window.innerHeight-o?a.style.setProperty("--translateY",`translateY(calc(100vh - ${o}px))`):a.style.setProperty("--translateY",`translateY(${(d||s(p))+35}px)`),a.style.setProperty("transition","transform 500ms cubic-bezier(0.4, 0, 0, 1) 0s"),m&&(e.removeEventListener("mousedown",l),e.removeEventListener("touchstart",l),setTimeout(this._callHide,250)))};return e.addEventListener("mousedown",l),e.addEventListener("touchstart",l,{passive:!0}),g(new MouseEvent("mouseup"),window.innerHeight-o-35),{touchElement:e,listener:l}},this.setupAppearence=()=>{var a,e,t;this.bindedElement&&(this.bindedElement.touchElement.removeEventListener("mousedown",this.bindedElement.listener),this.bindedElement.touchElement.removeEventListener("touchstart",this.bindedElement.listener)),this.bindedElement=this.dragMobileSheet((a=this.parentElement)==null?void 0:a.parentElement,(e=this.parentElement)==null?void 0:e.getElementsByClassName("touch-header")[0],(t=this.parentElement)==null?void 0:t.getElementsByClassName("body-header")[0])},this._init=()=>{this.setupAppearence(),window.addEventListener("resize",this.setupAppearence)}}firstUpdated(){this._init()}createRenderRoot(){return this}connectedCallback(){super.connectedCallback()}render(){return h.html`${ka(this.props.name,this.props.description,this.props.icon,this._callInstall)}`}};U([(0,b.property)({type:Object}),Z("design:type",Object)],P.prototype,"props",void 0),U([(0,b.property)({type:Object}),Z("design:type",Object)],P.prototype,"install",void 0),U([(0,b.property)(),Z("design:type",Object)],P.prototype,"hideDialog",void 0),U([(0,b.property)(),Z("design:type",Object)],P.prototype,"disableClose",void 0),P=U([(0,b.customElement)("pwa-bottom-sheet")],P);const $a=P,_a=h.css`#pwa-install-element{-webkit-user-select:none;user-select:none}#pwa-install-element .install-dialog{--text-color-normal:#212121;--background-color:#fff;--border-bottom-color:#DBDCDE;--scrollbar-background-color:#fff;font-family:Roboto,"Segoe UI",system-ui;position:fixed;display:inline-block;opacity:0;visibility:hidden;z-index:2147483001}#pwa-install-element .install-dialog.chrome{max-width:380px;width:90%;min-height:90px;margin:0 auto;right:150px;left:auto;background-color:var(--background-color);filter:drop-shadow(0 5px 15px rgba(0, 0, 0, .3));font-size:15px;color:var(--text-color-normal);border-radius:8px;top:-100px;transition:top .5s ease-in-out,opacity .8s ease-in-out,max-height .35s ease-in-out}#pwa-install-element .install-dialog.chrome.available{opacity:1;top:28px;visibility:visible}#pwa-install-element .install-dialog.chrome .dialog-body{display:grid;grid-template-columns:70px 1fr}#pwa-install-element .install-dialog.chrome .dialog-body .icon{display:flex;align-items:flex-start}#pwa-install-element .install-dialog.chrome .dialog-body .icon .icon-image{width:48px;height:48px;margin:0 auto;margin-top:10px;border-radius:6px}#pwa-install-element .install-dialog.chrome .dialog-body .about{display:grid;grid-template-rows:30px auto}#pwa-install-element .install-dialog.chrome .dialog-body .about .hostname,#pwa-install-element .install-dialog.chrome .dialog-body .about .name{padding:0 5px;overflow:hidden}#pwa-install-element .install-dialog.chrome .dialog-body .about .name{font-weight:500;font-size:18px;line-height:24px;margin-top:5px;align-items:flex-start;display:flex}#pwa-install-element .install-dialog.chrome .dialog-body .about .name label{text-overflow:ellipsis;word-break:break-all;white-space:nowrap;overflow:hidden}#pwa-install-element .install-dialog.chrome .dialog-body .about .hostname{font-size:13px;font-weight:400;opacity:.7;line-height:14px;overflow-x:hidden;text-overflow:ellipsis;text-align:left;word-break:break-all;white-space:nowrap}#pwa-install-element .install-dialog.chrome .dialog-body .about+hr{margin-top:10px}#pwa-install-element .install-dialog.chrome .dialog-body .description{font-weight:400;line-height:20px;grid-column:1/3;padding:0 6px;margin:10px 5px 5px;display:-webkit-box;-webkit-line-clamp:5;-webkit-box-orient:vertical;max-height:115px;overflow:hidden;overflow-y:auto;text-overflow:ellipsis;text-align:left}#pwa-install-element .install-dialog.chrome .dialog-body .app-description{font-size:13px;margin-bottom:10px}#pwa-install-element .install-dialog.chrome .dialog-body .app-description::-webkit-scrollbar{width:4px;height:4px}#pwa-install-element .install-dialog.chrome .dialog-body .app-description::-webkit-scrollbar-thumb{background:#929292;border-radius:4px}#pwa-install-element .install-dialog.chrome .dialog-body .app-description::-webkit-scrollbar-thumb:hover{background:#646464}#pwa-install-element .install-dialog.chrome .dialog-body .app-description::-webkit-scrollbar-track{background:var(--scrollbar-background-color);border-radius:4px}#pwa-install-element .install-dialog.chrome .dialog-body .install-description{font-size:14px}#pwa-install-element .install-dialog.chrome .dialog-body hr{height:1px;width:100%;grid-column:1/3;background-color:var(--border-bottom-color);border:none;margin:0}#pwa-install-element .install-dialog.chrome .dialog-body .action-buttons{display:grid;grid-template-columns:50% auto;grid-column-start:1;grid-column-end:3;gap:10px;padding:10px 10px}#pwa-install-element .install-dialog.chrome .dialog-body .action-buttons .primary{grid-column-start:2}#pwa-install-element .install-dialog.chrome .dialog-body pwa-gallery{grid-column:1/3;max-height:0;opacity:0;transition:opacity ease-in-out .5s,max-height .5s ease-in-out;overflow:hidden}#pwa-install-element .install-dialog.chrome.gallery pwa-gallery{transition:opacity .3s ease-in-out .2s,max-height .5s ease-in-out;max-height:70vh;opacity:1}#pwa-install-element .install-dialog.mobile{--touch-header-color:#DBDCE0;top:0;max-width:414px;width:100%;bottom:auto;left:0;right:0;transition:none;transform:translateY(100vh);border-radius:0;border-top-left-radius:15px;border-top-right-radius:15px;padding-bottom:35px}#pwa-install-element .install-dialog.mobile .dialog-body{grid-template-columns:1fr}#pwa-install-element .install-dialog.mobile .dialog-body .touch-header{height:30px;width:100%;padding-top:10px;box-sizing:border-box;cursor:grab}#pwa-install-element .install-dialog.mobile .dialog-body .touch-header:active{cursor:grabbing}#pwa-install-element .install-dialog.mobile .dialog-body .touch-header::before{content:"";width:40px;height:5px;border-radius:3px;background:var(--touch-header-color);margin:0 auto;display:block}#pwa-install-element .install-dialog.mobile .dialog-body .body-header{display:grid;grid-template-columns:max-content 1fr max-content;grid-gap:15px;padding:18px 20px;padding-top:0;border-bottom:1px solid var(--border-bottom-color)}#pwa-install-element .install-dialog.mobile .dialog-body .body-header .install{text-transform:capitalize;height:40px;padding:0 23px}#pwa-install-element .install-dialog.mobile .dialog-body .body-header .about{grid-template-rows:auto auto;grid-gap:6px}#pwa-install-element .install-dialog.mobile .dialog-body .body-header .about .name{padding:0;line-height:20px;font-size:16px}#pwa-install-element .install-dialog.mobile .dialog-body .body-header .about .hostname{font-size:14px;font-weight:400;opacity:.7;line-height:14px;overflow-x:hidden;text-overflow:ellipsis;word-break:break-all;white-space:nowrap;padding:0}#pwa-install-element .install-dialog.mobile .dialog-body .body-header .icon .icon-image{margin:0;width:45px;height:45px}#pwa-install-element .install-dialog.mobile .dialog-body .description{padding:15px 20px 0;margin:0;margin-bottom:15px;-webkit-line-clamp:6;max-height:150px}#pwa-install-element .install-dialog.mobile .dialog-body pwa-gallery{max-height:100%;padding-bottom:15px;opacity:1}#pwa-install-element .install-dialog.mobile .material-button{border-radius:20px}#pwa-install-element .install-dialog.mobile.available{--translateY:translateY(calc(100vh - 85px));opacity:1;top:0;visibility:visible;transform:var(--translateY)}#pwa-install-element .material-button{--text-color-primary:#fff;--text-color-secondary:#374fc6;--background-color-primary:#374fc6;--background-color-ripple:#fff;position:relative;display:inline-block;box-sizing:border-box;border:none;border-radius:6px;padding:0 16px;min-width:64px;height:36px;vertical-align:middle;text-align:center;text-overflow:ellipsis;text-transform:uppercase;box-shadow:0 3px 1px -2px rgba(0,0,0,.2),0 2px 2px 0 rgba(0,0,0,.14),0 1px 5px 0 rgba(0,0,0,.12);font-family:Roboto,"Segoe UI",BlinkMacSystemFont,system-ui,-apple-system;font-size:14px;font-weight:500;line-height:37px;overflow:hidden;outline:0;cursor:pointer;transition:box-shadow .2s}#pwa-install-element .material-button.primary{color:var(--text-color-primary);background-color:var(--background-color-primary)}#pwa-install-element .material-button.secondary{background-color:rgba(0,0,0,0);color:var(--text-color-secondary);box-shadow:none}#pwa-install-element .material-button.secondary::after,#pwa-install-element .material-button.secondary::before{background-color:var(--background-color-primary)}#pwa-install-element .material-button.secondary:active,#pwa-install-element .material-button.secondary:hover{box-shadow:none}#pwa-install-element .material-button.secondary.close{height:26px;min-width:26px;line-height:0;margin-right:0;margin-left:auto;padding:0;border-radius:50%}#pwa-install-element .material-button.secondary.close svg{width:16px;fill:var(--text-color-secondary)}#pwa-install-element .material-button.secondary.close::after{width:25px;height:25px;border-radius:50%}#pwa-install-element .material-button.secondary.close::before{border-radius:50%}#pwa-install-element .material-button::before{content:"";position:absolute;top:0;bottom:0;left:0;right:0;background-color:var(--background-color-ripple);opacity:0;transition:opacity .2s}#pwa-install-element .material-button::after{content:"";position:absolute;left:50%;top:50%;border-radius:50%;padding:50%;width:32px;height:32px;background-color:var(--background-color-ripple);opacity:0;transform:translate(-50%,-50%) scale(1);transition:opacity 1s,transform .5s}#pwa-install-element .material-button:hover{box-shadow:0 2px 4px -1px rgba(0,0,0,.2),0 4px 5px 0 rgba(0,0,0,.14),0 1px 10px 0 rgba(0,0,0,.12)}#pwa-install-element .material-button:hover::before{opacity:.08}#pwa-install-element .material-button:hover:focus::before{opacity:.3}#pwa-install-element .material-button:active{box-shadow:0 5px 5px -3px rgba(0,0,0,.2),0 8px 10px 1px rgba(0,0,0,.14),0 3px 14px 2px rgba(0,0,0,.12)}#pwa-install-element .material-button:active::after{opacity:.32;transform:translate(-50%,-50%) scale(0);transition:transform 0s}@media(prefers-color-scheme:dark){#pwa-install-element .install-dialog{--text-color-normal:#fff;--background-color:#1e1e1e;--border-bottom-color:#404140;--scrollbar-background-color:#424242}#pwa-install-element .install-dialog.mobile{--touch-header-color:#3f403f}#pwa-install-element .install-dialog .material-button{--text-color-primary:#1B222C;--text-color-secondary:#a7c7fa;--background-color-primary:#a7c7fa}}@media(max-width:767px)and (min-height:495px){#pwa-install-element .install-dialog.chrome.mobile{display:inline-block}#pwa-install-element .install-dialog.chrome{display:none}}@media(min-width:768px),(max-height:495px){#pwa-install-element .install-dialog.chrome.mobile{display:none}#pwa-install-element .install-dialog.chrome{display:inline-block}}@media(max-height:420px){#pwa-install-element .install-dialog.chrome .dialog-body .description{-webkit-line-clamp:3;max-height:70px}}@media(hover:none)and (pointer:coarse){#pwa-install-element .install-dialog.chrome .dialog-body .description::-webkit-scrollbar{display:none}}`,Aa=h.css`#pwa-install-element .install-dialog.apple{--text-color-normal:#333;--text-color-description:#333;--background-color:rgba(255, 255, 255, 0.8);--text-color-button:#fff;--background-color-button:#fff;--background-color-button-active:#DBDAE0;--border-bottom-color:rgba(0, 0, 0, 0.1);--icon-how-to-color:#527AFB;font-family:system-ui,-apple-system,HelveticaNeue,BlinkMacSystemFont,Roboto,"Segoe UI";max-width:380px;width:auto;margin:0 auto;right:0;left:0;font-size:15px;color:var(--text-color-normal);bottom:0;transition:transform .4s cubic-bezier(.33,1,.66,1),opacity .5s cubic-bezier(1,0,1,-2),border .35s ease-in-out;overflow:hidden;pointer-events:none;opacity:0;visibility:visible;transform:translateY(100%);will-change:opacity,transform}#pwa-install-element .install-dialog.apple.dialog-body{display:grid;grid-template-columns:95px 1fr;grid-template-rows:1fr auto;grid-template-areas:"icon description" "welcome welcome" "how-to how-to" "gallery gallery" "button button";border-radius:10px;border-bottom:1px solid transparent;background-color:var(--background-color);filter:drop-shadow(0 5px 15px rgba(0, 0, 0, .5));backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}#pwa-install-element .install-dialog.apple.dialog-body .icon{display:flex;align-items:center;grid-area:icon;border-bottom:1px solid var(--border-bottom-color)}#pwa-install-element .install-dialog.apple.dialog-body .icon .icon-image{width:64px;height:64px;margin:0 auto;border-radius:6px}#pwa-install-element .install-dialog.apple.dialog-body .close{height:26px;min-width:26px;line-height:0;margin-right:7px;margin-top:7px;margin-left:auto;padding:0;border-radius:50%;opacity:.5;outline:0;color:var(--text-color-normal);border:none;background-color:rgba(0,0,0,0);cursor:pointer;transition:opacity .2s ease-in-out,background-color .2s ease-in-out;grid-area:description}#pwa-install-element .install-dialog.apple.dialog-body .close svg{fill:var(--text-color-normal);width:18px}#pwa-install-element .install-dialog.apple.dialog-body .close:active,#pwa-install-element .install-dialog.apple.dialog-body .close:hover{opacity:1;background-color:var(--background-color-button)}#pwa-install-element .install-dialog.apple.dialog-body .about{display:grid;grid-template-rows:35px 60px;border-bottom:1px solid var(--border-bottom-color);grid-area:description}#pwa-install-element .install-dialog.apple.dialog-body .about .description,#pwa-install-element .install-dialog.apple.dialog-body .about .name{padding-right:15px;overflow:hidden}#pwa-install-element .install-dialog.apple.dialog-body .about .name{font-weight:600;padding-top:10px;padding-right:10px;line-height:22px;align-items:flex-start;display:flex}#pwa-install-element .install-dialog.apple.dialog-body .about .description{font-size:12px;line-height:15px;margin-bottom:15px;overflow-y:auto;color:var(--text-color-description)}#pwa-install-element .install-dialog.apple.dialog-body .welcome-to-install{font-size:15px;grid-area:welcome;text-align:left;font-weight:400;padding:15px;width:auto;border-bottom:1px solid var(--border-bottom-color)}#pwa-install-element .install-dialog.apple .action-buttons{grid-area:button;grid-column-start:1;grid-column-end:3;padding:15px}#pwa-install-element .install-dialog.apple .dialog-button{display:grid;height:50px;width:100%;line-height:50px;border-radius:8px;color:var(--text-color-normal)}#pwa-install-element .install-dialog.apple .dialog-button.button{border:none;outline:0;font-family:system-ui,-apple-system,HelveticaNeue,BlinkMacSystemFont;cursor:pointer;-webkit-user-select:none;user-select:none;font-weight:400;font-size:17px;padding:0;margin:0;background-color:var(--background-color-button)}#pwa-install-element .install-dialog.apple .dialog-button.button.install{padding:0 15px;text-align:left}#pwa-install-element .install-dialog.apple .dialog-button.button.install .button-text{opacity:0;display:flex;align-items:center;justify-content:space-between;transition:opacity .4s ease-in-out .1s;overflow:hidden}#pwa-install-element .install-dialog.apple .dialog-button.button.install .button-text>span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#pwa-install-element .install-dialog.apple .dialog-button.button.install .button-text>svg{flex-shrink:0;width:20px}#pwa-install-element .install-dialog.apple .dialog-button.button.install .button-text.show{opacity:1;visibility:visible;width:auto;height:auto}#pwa-install-element .install-dialog.apple .dialog-button.button.install .button-text.hide{opacity:0;position:absolute;width:0;height:0;visibility:hidden}#pwa-install-element .install-dialog.apple .dialog-button.button.gallery{display:flex;align-items:center;min-width:50px;width:auto;margin-right:15px}#pwa-install-element .install-dialog.apple .dialog-button.button.gallery #pwa-gallery{margin:0 auto;width:23px;fill:var(--text-color-normal)}#pwa-install-element .install-dialog.apple .dialog-button.button:active{background-color:var(--background-color-button-active)}#pwa-install-element .install-dialog.apple .how-to-body{opacity:0;max-height:0;overflow:hidden;transition:opacity ease-in-out .5s,max-height .5s ease-in-out;grid-area:how-to}#pwa-install-element .install-dialog.apple .how-to-body .how-to-description{display:grid;-webkit-user-select:none;user-select:none;grid-auto-columns:1fr;grid-template-rows:1fr 1fr 1fr;gap:10px;padding:15px;padding-bottom:0}#pwa-install-element .install-dialog.apple .how-to-body .how-to-description .description-step{display:inline-flex;flex-direction:row;gap:15px;align-items:center;font-size:14px}#pwa-install-element .install-dialog.apple .how-to-body .how-to-description .description-step .svg-wrap{position:relative;display:inline-flex;flex-shrink:0;color:var(--icon-how-to-color);width:50px;height:50px;align-items:center;border-radius:6px}#pwa-install-element .install-dialog.apple .how-to-body .how-to-description .description-step .svg-wrap #pwa-add,#pwa-install-element .install-dialog.apple .how-to-body .how-to-description .description-step .svg-wrap #pwa-safari,#pwa-install-element .install-dialog.apple .how-to-body .how-to-description .description-step .svg-wrap #pwa-share{margin:0 auto}#pwa-install-element .install-dialog.apple .how-to-body .how-to-description .description-step .svg-wrap #pwa-share{margin-bottom:4px;transform:scale(.9)}#pwa-install-element .install-dialog.apple .how-to-body .how-to-description .description-step .svg-wrap #pwa-add{transform:scale(.8);fill:var(--text-color-normal)}#pwa-install-element .install-dialog.apple .how-to-body .how-to-description .description-step .svg-wrap #pwa-safari{transform:scale(.92)}#pwa-install-element .install-dialog.apple .how-to-body .how-to-description .description-step .svg-wrap .step-count{position:absolute;line-height:12px;top:3px;left:4px}#pwa-install-element .install-dialog.apple .how-to-body .how-to-description .description-step .step-text{font-weight:600;text-align:left}#pwa-install-element .install-dialog.apple pwa-gallery{grid-column:1/3;max-height:0;opacity:0;transition:opacity ease-in-out .5s,max-height .5s ease-in-out;overflow:hidden}#pwa-install-element .install-dialog.apple pwa-gallery+.action-buttons{display:flex}#pwa-install-element .install-dialog.apple.available{opacity:1;pointer-events:unset;transform:translateY(0);transition:transform .5s cubic-bezier(.33,1,.66,1),border .35s ease-in-out}#pwa-install-element .install-dialog.apple.gallery pwa-gallery{transition:opacity .3s ease-in-out .2s,max-height .5s ease-in-out;max-height:70vh;opacity:1}#pwa-install-element .install-dialog.apple.how-to .dialog-body{border-bottom:1px solid #e0e0e0}#pwa-install-element .install-dialog.apple.how-to .how-to-body{opacity:1;max-height:400px;overflow-y:auto;transition:opacity .3s ease-in-out .2s,max-height .5s ease-in-out}#pwa-install-element .install-dialog.apple.desktop{--text-color-normal:rgba(0, 0, 0, 0.85);--text-color-description:rgba(0, 0, 0, 0.85);--icon-how-to-color:rgba(0, 0, 0, 0.50);--background-color:rgb(246 246 246 / 85%);--background-color-button:#c6c1c6;--background-color-button-active:linear-gradient(0deg, rgba(64,121,250,1) 0%, rgba(84,144,251,1) 100%);--border-bottom-color:rgb(185 185 185);grid-template-columns:1fr;grid-template-rows:1fr auto;grid-template-areas:"icon" "description" "welcome" "how-to" "gallery" "button";gap:0;column-gap:0;padding:16px;max-width:260px;background:var(--background-color);border:1px solid var(--border-bottom-color)}#pwa-install-element .install-dialog.apple.desktop .icon{height:64px;padding-bottom:16px}#pwa-install-element .install-dialog.apple.desktop .icon .icon-image{border-radius:10px;width:52px;height:52px;filter:drop-shadow(0 1px 1px rgba(0, 0, 0, .15))}#pwa-install-element .install-dialog.apple.desktop .close{grid-area:icon;background:var(--background-color-button);opacity:1;height:20px;min-width:20px;margin-right:-5px;margin-top:-5px}#pwa-install-element .install-dialog.apple.desktop .close svg{width:14px}#pwa-install-element .install-dialog.apple.desktop .about{display:flex;flex-direction:column;align-items:center}#pwa-install-element .install-dialog.apple.desktop .about .name{font-size:13px;line-height:16px;font-weight:700;padding:0}#pwa-install-element .install-dialog.apple.desktop .about .description{padding:16px 0;margin:0;padding-top:10px;border-bottom:1px solid var(--border-bottom-color);min-width:100%}#pwa-install-element .install-dialog.apple.desktop .about .description,#pwa-install-element .install-dialog.apple.desktop .welcome-to-install{text-align:center;font-size:11px;line-height:14px}#pwa-install-element .install-dialog.apple.desktop .about,#pwa-install-element .install-dialog.apple.desktop .icon,#pwa-install-element .install-dialog.apple.desktop .welcome-to-install{border:none}#pwa-install-element .install-dialog.apple.desktop .welcome-to-install{padding:0;padding-top:16px}#pwa-install-element .install-dialog.apple.desktop .action-buttons{padding:0;padding-top:16px}#pwa-install-element .install-dialog.apple.desktop .action-buttons .dialog-button.button{font-size:13px;font-weight:400;padding:6px 8px;border-radius:6px;height:auto;line-height:18px}#pwa-install-element .install-dialog.apple.desktop .action-buttons .dialog-button.button.install{color:#fff;background:var(--background-color-button-active);transition:background .3s ease-in-out .1s,color .3s ease-in-out}#pwa-install-element .install-dialog.apple.desktop .action-buttons .dialog-button.button.install svg{transform:none;width:18px}#pwa-install-element .install-dialog.apple.desktop .action-buttons .dialog-button.button.gallery{width:30px;min-width:30px;margin-right:10px;background:var(--background-color-button)}#pwa-install-element .install-dialog.apple.desktop .action-buttons .dialog-button.button.gallery #pwa-gallery{width:14px;transition:transform .4s ease-in-out}#pwa-install-element .install-dialog.apple.desktop .close:active,#pwa-install-element .install-dialog.apple.desktop .dialog-button.button:active{filter:brightness(105%)}#pwa-install-element .install-dialog.apple.desktop .close:active .button-text,#pwa-install-element .install-dialog.apple.desktop .dialog-button.button:active .button-text{filter:brightness(90%)}#pwa-install-element .install-dialog.apple.desktop .how-to-body .how-to-description{padding:0;padding-top:16px;grid-template-rows:1fr 1fr}#pwa-install-element .install-dialog.apple.desktop .how-to-body .how-to-description .description-step{font-size:12px;gap:16px}#pwa-install-element .install-dialog.apple.desktop .how-to-body .how-to-description .description-step .svg-wrap{width:32px;height:32px;color:var(--icon-how-to-color)}#pwa-install-element .install-dialog.apple.desktop .how-to-body .how-to-description .description-step .svg-wrap #pwa-share{width:16px;margin-bottom:2px;transform:none}#pwa-install-element .install-dialog.apple.desktop .how-to-body .how-to-description .description-step .svg-wrap #pwa-add{width:18px;transform:none}#pwa-install-element .install-dialog.apple.desktop.gallery #pwa-gallery{transform:rotate(180deg)}#pwa-install-element .install-dialog.apple.desktop.how-to .action-buttons .dialog-button.button.install{color:var(--text-color-normal);background:var(--background-color-button)}@media(min-width:667px){#pwa-install-element .install-dialog.apple{top:0;bottom:unset;transform:translateY(calc(-100% - 40px));right:28px;left:auto}#pwa-install-element .install-dialog.apple.available{top:28px;bottom:auto;max-height:calc(95vh - 28px)}}@media(min-width:667px)and (max-width:1366px){#pwa-install-element .install-dialog.apple{right:max(28px,env(safe-area-inset-right,28px));left:auto}}@media(max-width:666px){#pwa-install-element .install-dialog.apple .description-step .step-text{font-size:13px}#pwa-install-element .install-dialog.apple.available{bottom:20px;max-height:calc(85vh - 20px)}#pwa-install-element .install-dialog.apple.dialog-body{filter:drop-shadow(rgba(0, 0, 0, .5) 0 0 15px)}}@media(max-width:428px){#pwa-install-element .install-dialog.apple.dialog-body{max-width:100vw;filter:drop-shadow(rgba(0, 0, 0, .5) 0 -5px 10px);border-bottom-left-radius:0;border-bottom-right-radius:0}#pwa-install-element .install-dialog.apple.dialog-body .action-buttons{padding-bottom:max(15px,env(safe-area-inset-bottom))}#pwa-install-element .install-dialog.apple.dialog-body.available{bottom:0;max-height:85vh}}@media(max-height:548px){#pwa-install-element .install-dialog.apple.dialog-body.available{overflow-y:auto;max-height:calc(90vh - 28px - env(safe-area-inset-bottom,0px))}}@media(max-height:600px){#pwa-install-element .install-dialog.apple pwa-gallery{overflow-y:auto}}@media(prefers-color-scheme:dark){#pwa-install-element .install-dialog.apple.dialog-body{--text-color-normal:#fff;--text-color-description:#9E9AA1;--background-color:rgb(25 25 25 / 90%);--background-color-button:#353535;--background-color-button-active:#454545;--border-bottom-color:#353535}#pwa-install-element .install-dialog.apple.dialog-body .close:active,#pwa-install-element .install-dialog.apple.dialog-body .dialog-button.button:active{filter:brightness(105%)}#pwa-install-element .install-dialog.apple.dialog-body .close:active .button-text,#pwa-install-element .install-dialog.apple.dialog-body .dialog-button.button:active .button-text{filter:brightness(90%)}#pwa-install-element .install-dialog.apple.dialog-body.desktop{--text-color-description:var(--text-color-normal);--icon-how-to-color:#bcb8b6;--background-color:rgb(45 45 45 / 90%);--border-bottom-color:#5b5b5b;--background-color-button:#6d6765;--background-color-button-active:linear-gradient(0deg, rgba(59,108,200,1) 0%, rgba(66,123,250,1) 100%);outline:1px solid #1c1c1c;color-scheme:dark}}`,Pe=(a=>{var e={};return c.d(e,a),e})({classMap:()=>Bt}),Ea=(a,e,t,i,o,s,l,n,r,g,p,d,m)=>{const x=()=>({available:r,gallery:m}),$=!o&&n.screenshots&&n.screenshots.length;return h.html`
icon
${s?"":h.html``}
${location.hostname}
${e?h.html`
${e}
`:""} ${i?"":h.html`
${t||`${k("This site has app functionality.")} ${k("Install it on your device for extensive experience and easy access.")}`}
`} ${$?h.html``:""}
${$?h.html``:""}
${$?h.html``:""}
`},Sa=(a,e,t,i,o,s,l,n,r,g,p,d,m,x,$)=>{const Le=!o&&n.screenshots&&n.screenshots.length;return h.html``};var w=function(a,e,t,i){var o,s=arguments.length,l=s<3?e:i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(a,e,t,i);else for(var n=a.length-1;n>=0;n--)(o=a[n])&&(l=(s<3?o(l):s>3?o(e,t,l):o(e,t))||l);return s>3&&l&&Object.defineProperty(e,t,l),l},y=function(a,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(a,e)};let f=class extends h.LitElement{constructor(){super(...arguments),this.manifestUrl="/manifest.json",this.icon="",this.name="",this.description="",this.installDescription="",this.disableDescription=!1,this.disableScreenshots=!1,this.disableScreenshotsApple=!1,this.disableScreenshotsChrome=!1,this.manualApple=!1,this.manualChrome=!1,this.disableChrome=!1,this.disableClose=!1,this.externalPromptEvent=null,this.platforms=[],this.userChoiceResult="",this.isDialogHidden=JSON.parse(window.sessionStorage.getItem("pwa-hide-install")||"false"),this.isInstallAvailable=!1,this.isAppleMobilePlatform=!1,this.isAppleDesktopPlatform=!1,this.isUnderStandaloneMode=!1,this.isRelatedAppsInstalled=!1,this._manifest=new va,this._howToRequested=!1,this._galleryRequested=!1,this._install={handleEvent:()=>{window.defferedPromptEvent&&(this.hideDialog(),window.defferedPromptEvent.prompt(),window.defferedPromptEvent.userChoice.then(a=>{this.userChoiceResult=a.outcome,v.eventUserChoiceResult(this,this.userChoiceResult)}).catch(a=>{v.eventInstalledFail(this)}),window.defferedPromptEvent=null)},passive:!0},this.install=()=>{this.isAppleMobilePlatform||this.isAppleDesktopPlatform?(this._howToRequested=!0,this.requestUpdate()):this._install.handleEvent()},this._hideDialog={handleEvent:()=>{this.isDialogHidden=!0,window.sessionStorage.setItem("pwa-hide-install","true"),this.requestUpdate()},passive:!0},this._hideDialogUser=()=>{v.eventUserChoiceResult(this,"dismissed"),this.userChoiceResult="dismissed",this.hideDialog()},this.hideDialog=()=>{this._hideDialog.handleEvent()},this.showDialog=(a=!1)=>{this.isDialogHidden=!1,a&&(this.isInstallAvailable=!0),window.sessionStorage.setItem("pwa-hide-install","false"),this.requestUpdate()},this.getInstalledRelatedApps=async()=>await v.getInstalledRelatedApps(),this._howToForApple={handleEvent:()=>{this._howToRequested=!this._howToRequested,this._howToRequested&&this._galleryRequested&&(this._galleryRequested=!1),this.requestUpdate(),this._howToRequested&&v.eventInstallHowTo(this)},passive:!0},this._toggleGallery={handleEvent:()=>{this._galleryRequested=!this._galleryRequested,this._howToRequested&&this._galleryRequested&&(this._howToRequested=!1),this._galleryRequested&&v.eventGallery(this),this.requestUpdate()},passive:!0},this._init=async()=>{var a,e;if(window.defferedPromptEvent=null,this._checkInstalled(),!this.disableChrome){const t=i=>{window.defferedPromptEvent=i,i.preventDefault(),this.platforms=i.platforms,this.isRelatedAppsInstalled||this.isUnderStandaloneMode?this.isInstallAvailable=!1:(this.isInstallAvailable=!0,v.eventInstallAvailable(this)),this.userChoiceResult==="accepted"&&(this.isDialogHidden=!0,v.eventInstalledSuccess(this)),this.requestUpdate()};this.externalPromptEvent!=null?setTimeout(()=>t(this.externalPromptEvent),300):window.addEventListener("beforeinstallprompt",t)}window.addEventListener("appinstalled",t=>{window.defferedPromptEvent=null,this.isInstallAvailable=!1,this.requestUpdate(),v.eventInstalledSuccess(this)});try{const t=await fetch(this.manifestUrl),i=await t.json();if(!t.ok||!i||!Object.keys(i))throw Error("Manifest not found");v.normalizeManifestAssetUrls(i,this.manifestUrl),this.icon=this.icon||(a=i.icons)!=null&&a.length?i.icons[0].src:"",this.name=this.name||i.short_name||i.name||"",this.description=this.description||i.description||"",this._manifest=i}catch{this.icon=this.icon||((e=this._manifest.icons)==null?void 0:e[0].src)||"",this.name=this.name||this._manifest.short_name||"",this.description=this.description||this._manifest.description||""}},this._requestUpdate=()=>{this.requestUpdate()}}static get styles(){return[_a,Aa]}async _checkInstalled(){this.isUnderStandaloneMode=v.isStandalone(),this.isRelatedAppsInstalled=await v.isRelatedAppsInstalled(),this.isAppleMobilePlatform=v.isAppleMobile(),this.isAppleDesktopPlatform=v.isAppleDesktop(),this.isAppleMobilePlatform||this.isAppleDesktopPlatform?this.isUnderStandaloneMode||(this.manualApple&&this.hideDialog(),setTimeout(()=>{this.isInstallAvailable=!0,this.requestUpdate(),v.eventInstallAvailable(this)},1e3)):this.manualChrome&&this.hideDialog()}connectedCallback(){(a=>{switch(a.slice(0,2)==="nb"&&(a="no"),a){case"zh":case"zh-TW":a="zh-CN"}try{ht.get(a)?Ge(a):Ge(a.slice(0,2))}catch{}})(navigator.language),this._init(),xa.finalized,$a.finalized,super.connectedCallback()}willUpdate(a){this.externalPromptEvent&&a.has("externalPromptEvent")&&typeof this.externalPromptEvent=="object"&&this._init()}render(){return this.isAppleMobilePlatform||this.isAppleDesktopPlatform?h.html`${Sa(this.name,this.description,this.installDescription,this.disableDescription,this.disableScreenshots||this.disableScreenshotsApple,this.disableClose,this.icon,this._manifest,this.isInstallAvailable&&!this.isDialogHidden,this._hideDialogUser,this._howToForApple,this.isAppleDesktopPlatform,this._howToRequested,this._toggleGallery,this._galleryRequested)}`:h.html`${Ea(this.name,this.description,this.installDescription,this.disableDescription,this.disableScreenshots||this.disableScreenshotsChrome,this.disableClose,this.icon,this._manifest,this.isInstallAvailable&&!this.isDialogHidden,this._hideDialogUser,this._install,this._toggleGallery,this._galleryRequested)}`}};w([(0,b.property)({attribute:"manifest-url"}),y("design:type",Object)],f.prototype,"manifestUrl",void 0),w([(0,b.property)(),y("design:type",Object)],f.prototype,"icon",void 0),w([(0,b.property)(),y("design:type",Object)],f.prototype,"name",void 0),w([(0,b.property)(),y("design:type",Object)],f.prototype,"description",void 0),w([(0,b.property)({attribute:"install-description"}),y("design:type",Object)],f.prototype,"installDescription",void 0),w([(0,b.property)({attribute:"disable-install-description",type:Boolean}),y("design:type",Object)],f.prototype,"disableDescription",void 0),w([(0,b.property)({attribute:"disable-screenshots",type:Boolean}),y("design:type",Object)],f.prototype,"disableScreenshots",void 0),w([(0,b.property)({attribute:"disable-screenshots-apple",type:Boolean}),y("design:type",Object)],f.prototype,"disableScreenshotsApple",void 0),w([(0,b.property)({attribute:"disable-screenshots-chrome",type:Boolean}),y("design:type",Object)],f.prototype,"disableScreenshotsChrome",void 0),w([(0,b.property)({attribute:"manual-apple",type:Boolean}),y("design:type",Object)],f.prototype,"manualApple",void 0),w([(0,b.property)({attribute:"manual-chrome",type:Boolean}),y("design:type",Object)],f.prototype,"manualChrome",void 0),w([(0,b.property)({attribute:"disable-chrome",type:Boolean}),y("design:type",Object)],f.prototype,"disableChrome",void 0),w([(0,b.property)({attribute:"disable-close",type:Boolean}),y("design:type",Object)],f.prototype,"disableClose",void 0),w([(0,b.state)(),y("design:type",Object)],f.prototype,"externalPromptEvent",void 0),f=w([(a,e)=>(a.addInitializer(qt),a),(0,b.customElement)("pwa-install")],f);var Ha=lt.w;export{Ha as PWAInstallElement}; diff --git a/assets/chunks/pwa-install.es.DuMXkPrI.js b/assets/chunks/pwa-install.es.DuMXkPrI.js deleted file mode 100644 index 5c607e1e60..0000000000 --- a/assets/chunks/pwa-install.es.DuMXkPrI.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * Copyright 2019 Google LLC - * SPDX-License-Identifier: BSD-3-Clause - */const F=globalThis,je=F.ShadowRoot&&(F.ShadyCSS===void 0||F.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ce=Symbol(),Le=new WeakMap;let Qe=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==Ce)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(je&&e===void 0){const i=t!==void 0&&t.length===1;i&&(e=Le.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&Le.set(t,e))}return e}toString(){return this.cssText}};const ht=a=>new Qe(typeof a=="string"?a:a+"",void 0,Ce),gt=(a,...e)=>{const t=a.length===1?a[0]:e.reduce((i,o,s)=>i+(l=>{if(l._$cssResult$===!0)return l.cssText;if(typeof l=="number")return l;throw Error("Value passed to 'css' function must be a 'css' function result: "+l+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(o)+a[s+1],a[0]);return new Qe(t,a,Ce)},bt=(a,e)=>{if(je)a.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const i=document.createElement("style"),o=F.litNonce;o!==void 0&&i.setAttribute("nonce",o),i.textContent=t.cssText,a.appendChild(i)}},Ie=je?a=>a:a=>a instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return ht(t)})(a):a;/** - * @license - * Copyright 2017 Google LLC - * SPDX-License-Identifier: BSD-3-Clause - */const{is:mt,defineProperty:ut,getOwnPropertyDescriptor:ft,getOwnPropertyNames:vt,getOwnPropertySymbols:wt,getPrototypeOf:yt}=Object,E=globalThis,Ue=E.trustedTypes,xt=Ue?Ue.emptyScript:"",ee=E.reactiveElementPolyfillSupport,O=(a,e)=>a,G={toAttribute(a,e){switch(e){case Boolean:a=a?xt:null;break;case Object:case Array:a=a==null?a:JSON.stringify(a)}return a},fromAttribute(a,e){let t=a;switch(e){case Boolean:t=a!==null;break;case Number:t=a===null?null:Number(a);break;case Object:case Array:try{t=JSON.parse(a)}catch{t=null}}return t}},Te=(a,e)=>!mt(a,e),He={attribute:!0,type:String,converter:G,reflect:!1,hasChanged:Te};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),E.litPropertyMetadata??(E.litPropertyMetadata=new WeakMap);let R=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=He){if(t.state&&(t.attribute=!1),this._$Ei(),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),o=this.getPropertyDescriptor(e,i,t);o!==void 0&&ut(this.prototype,e,o)}}static getPropertyDescriptor(e,t,i){const{get:o,set:s}=ft(this.prototype,e)??{get(){return this[t]},set(l){this[t]=l}};return{get(){return o==null?void 0:o.call(this)},set(l){const n=o==null?void 0:o.call(this);s.call(this,l),this.requestUpdate(e,n,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??He}static _$Ei(){if(this.hasOwnProperty(O("elementProperties")))return;const e=yt(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(O("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(O("properties"))){const t=this.properties,i=[...vt(t),...wt(t)];for(const o of i)this.createProperty(o,t[o])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[i,o]of t)this.elementProperties.set(i,o)}this._$Eh=new Map;for(const[t,i]of this.elementProperties){const o=this._$Eu(t,i);o!==void 0&&this._$Eh.set(o,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const o of i)t.unshift(Ie(o))}else e!==void 0&&t.push(Ie(e));return t}static _$Eu(e,t){const i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$EO)==null||t.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return bt(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(t=>{var i;return(i=t.hostConnected)==null?void 0:i.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(t=>{var i;return(i=t.hostDisconnected)==null?void 0:i.call(t)})}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$EC(e,t){var s;const i=this.constructor.elementProperties.get(e),o=this.constructor._$Eu(e,i);if(o!==void 0&&i.reflect===!0){const l=(((s=i.converter)==null?void 0:s.toAttribute)!==void 0?i.converter:G).toAttribute(t,i.type);this._$Em=e,l==null?this.removeAttribute(o):this.setAttribute(o,l),this._$Em=null}}_$AK(e,t){var s;const i=this.constructor,o=i._$Eh.get(e);if(o!==void 0&&this._$Em!==o){const l=i.getPropertyOptions(o),n=typeof l.converter=="function"?{fromAttribute:l.converter}:((s=l.converter)==null?void 0:s.fromAttribute)!==void 0?l.converter:G;this._$Em=o,this[o]=n.fromAttribute(t,l.type),this._$Em=null}}requestUpdate(e,t,i){if(e!==void 0){if(i??(i=this.constructor.getPropertyOptions(e)),!(i.hasChanged??Te)(this[e],t))return;this.P(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(e,t,i){this._$AL.has(e)||this._$AL.set(e,t),i.reflect===!0&&this._$Em!==e&&(this._$Ej??(this._$Ej=new Set)).add(e)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[s,l]of this._$Ep)this[s]=l;this._$Ep=void 0}const o=this.constructor.elementProperties;if(o.size>0)for(const[s,l]of o)l.wrapped!==!0||this._$AL.has(s)||this[s]===void 0||this.P(s,this[s],l)}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(i=this._$EO)==null||i.forEach(o=>{var s;return(s=o.hostUpdate)==null?void 0:s.call(o)}),this.update(t)):this._$EU()}catch(o){throw e=!1,this._$EU(),o}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$EO)==null||t.forEach(i=>{var o;return(o=i.hostUpdated)==null?void 0:o.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Ej&&(this._$Ej=this._$Ej.forEach(t=>this._$EC(t,this[t]))),this._$EU()}updated(e){}firstUpdated(e){}};R.elementStyles=[],R.shadowRootOptions={mode:"open"},R[O("elementProperties")]=new Map,R[O("finalized")]=new Map,ee==null||ee({ReactiveElement:R}),(E.reactiveElementVersions??(E.reactiveElementVersions=[])).push("2.0.4");/** - * @license - * Copyright 2017 Google LLC - * SPDX-License-Identifier: BSD-3-Clause - */const B=globalThis,K=B.trustedTypes,Oe=K?K.createPolicy("lit-html",{createHTML:a=>a}):void 0,Xe="$lit$",A=`lit$${Math.random().toFixed(9).slice(2)}$`,et="?"+A,kt=`<${et}>`,j=document,q=()=>j.createComment(""),W=a=>a===null||typeof a!="object"&&typeof a!="function",Re=Array.isArray,$t=a=>Re(a)||typeof(a==null?void 0:a[Symbol.iterator])=="function",te=`[ -\f\r]`,L=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Be=/-->/g,Ne=/>/g,S=RegExp(`>|${te}(?:([^\\s"'>=/]+)(${te}*=${te}*(?:[^ -\f\r"'\`<>=]|("|')|))|$)`,"g"),qe=/'/g,We=/"/g,tt=/^(?:script|style|textarea|title)$/i,_t=a=>(e,...t)=>({_$litType$:a,strings:e,values:t}),At=_t(1),C=Symbol.for("lit-noChange"),u=Symbol.for("lit-nothing"),Ze=new WeakMap,z=j.createTreeWalker(j,129);function at(a,e){if(!Re(a)||!a.hasOwnProperty("raw"))throw Error("invalid template strings array");return Oe!==void 0?Oe.createHTML(e):e}const Et=(a,e)=>{const t=a.length-1,i=[];let o,s=e===2?"":e===3?"":"",l=L;for(let n=0;n"?(l=o??L,d=-1):p[1]===void 0?d=-2:(d=l.lastIndex-p[2].length,g=p[1],l=p[3]===void 0?S:p[3]==='"'?We:qe):l===We||l===qe?l=S:l===Be||l===Ne?l=L:(l=S,o=void 0);const x=l===S&&a[n+1].startsWith("/>")?" ":"";s+=l===L?r+kt:d>=0?(i.push(g),r.slice(0,d)+Xe+r.slice(d)+A+x):r+A+(d===-2?n:x)}return[at(a,s+(a[t]||"")+(e===2?"":e===3?"":"")),i]};let ne=class it{constructor({strings:e,_$litType$:t},i){let o;this.parts=[];let s=0,l=0;const n=e.length-1,r=this.parts,[g,p]=Et(e,t);if(this.el=it.createElement(g,i),z.currentNode=this.el.content,t===2||t===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(o=z.nextNode())!==null&&r.length0){o.textContent=K?K.emptyScript:"";for(let x=0;x2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=u}_$AI(e,t=this,i,o){const s=this.strings;let l=!1;if(s===void 0)e=M(this,e,t,0),l=!W(e)||e!==this._$AH&&e!==C,l&&(this._$AH=e);else{const n=e;let r,g;for(e=s[0],r=0;r{const i=(t==null?void 0:t.renderBefore)??e;let o=i._$litPart$;if(o===void 0){const s=(t==null?void 0:t.renderBefore)??null;i._$litPart$=o=new Z(e.insertBefore(q(),s),s,void 0,t??{})}return o._$AI(a),o};/** - * @license - * Copyright 2017 Google LLC - * SPDX-License-Identifier: BSD-3-Clause - */let N=class extends R{constructor(){super(...arguments),this.renderOptions={host:this},this.o=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this.o=Ct(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this.o)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this.o)==null||e.setConnected(!1)}render(){return C}};var Je;N._$litElement$=!0,N.finalized=!0,(Je=globalThis.litElementHydrateSupport)==null||Je.call(globalThis,{LitElement:N});const ie=globalThis.litElementPolyfillSupport;ie==null||ie({LitElement:N});(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.0");/** - * @license - * Copyright 2017 Google LLC - * SPDX-License-Identifier: BSD-3-Clause - */const Tt=a=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(a,e)}):customElements.define(a,e)};/** - * @license - * Copyright 2017 Google LLC - * SPDX-License-Identifier: BSD-3-Clause - */const Rt={attribute:!0,type:String,converter:G,reflect:!1,hasChanged:Te},Mt=(a=Rt,e,t)=>{const{kind:i,metadata:o}=t;let s=globalThis.litPropertyMetadata.get(o);if(s===void 0&&globalThis.litPropertyMetadata.set(o,s=new Map),s.set(t.name,a),i==="accessor"){const{name:l}=t;return{set(n){const r=e.get.call(this);e.set.call(this,n),this.requestUpdate(l,r,a)},init(n){return n!==void 0&&this.P(l,void 0,a),n}}}if(i==="setter"){const{name:l}=t;return function(n){const r=this[l];e.call(this,n),this.requestUpdate(l,r,a)}}throw Error("Unsupported decorator location: "+i)};function ot(a){return(e,t)=>typeof t=="object"?Mt(a,e,t):((i,o,s)=>{const l=o.hasOwnProperty(s);return o.constructor.createProperty(s,l?{...i,wrapped:!0}:i),l?Object.getOwnPropertyDescriptor(o,s):void 0})(a,e,t)}/** - * @license - * Copyright 2017 Google LLC - * SPDX-License-Identifier: BSD-3-Clause - */function Lt(a){return ot({...a,state:!0,attribute:!1})}/** - * @license - * Copyright 2017 Google LLC - * SPDX-License-Identifier: BSD-3-Clause - */const It={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Ut=a=>(...e)=>({_$litDirective$:a,values:e});let Ht=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this.t=e,this._$AM=t,this.i=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};/** - * @license - * Copyright 2018 Google LLC - * SPDX-License-Identifier: BSD-3-Clause - */const Ot=Ut(class extends Ht{constructor(a){var e;if(super(a),a.type!==It.ATTRIBUTE||a.name!=="class"||((e=a.strings)==null?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(a){return" "+Object.keys(a).filter(e=>a[e]).join(" ")+" "}update(a,[e]){var i,o;if(this.st===void 0){this.st=new Set,a.strings!==void 0&&(this.nt=new Set(a.strings.join(" ").split(/\s/).filter(s=>s!=="")));for(const s in e)e[s]&&!((i=this.nt)!=null&&i.has(s))&&this.st.add(s);return this.render(e)}const t=a.element.classList;for(const s of this.st)s in e||(t.remove(s),this.st.delete(s));for(const s in e){const l=!!e[s];l===this.st.has(s)||(o=this.nt)!=null&&o.has(s)||(l?(t.add(s),this.st.add(s)):(t.remove(s),this.st.delete(s)))}return C}});var c={d:(a,e)=>{for(var t in e)c.o(e,t)&&!c.o(a,t)&&Object.defineProperty(a,t,{enumerable:!0,get:e[t]})},o:(a,e)=>Object.prototype.hasOwnProperty.call(a,e),r:a=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})}},st={};c.d(st,{w:()=>f});var re={};c.r(re),c.d(re,{templates:()=>Jt});var de={};c.r(de),c.d(de,{templates:()=>Qt});var ce={};c.r(ce),c.d(ce,{templates:()=>Xt});var pe={};c.r(pe),c.d(pe,{templates:()=>ea});var he={};c.r(he),c.d(he,{templates:()=>ta});var ge={};c.r(ge),c.d(ge,{templates:()=>aa});var be={};c.r(be),c.d(be,{templates:()=>ia});var me={};c.r(me),c.d(me,{templates:()=>oa});var ue={};c.r(ue),c.d(ue,{templates:()=>sa});var fe={};c.r(fe),c.d(fe,{templates:()=>la});var ve={};c.r(ve),c.d(ve,{templates:()=>na});var we={};c.r(we),c.d(we,{templates:()=>ra});var ye={};c.r(ye),c.d(ye,{templates:()=>da});var xe={};c.r(xe),c.d(xe,{templates:()=>ca});var ke={};c.r(ke),c.d(ke,{templates:()=>pa});var $e={};c.r($e),c.d($e,{templates:()=>ha});var _e={};c.r(_e),c.d(_e,{templates:()=>ga});var Ae={};c.r(Ae),c.d(Ae,{templates:()=>ba});var Ee={};c.r(Ee),c.d(Ee,{templates:()=>ma});var Se={};c.r(Se),c.d(Se,{templates:()=>ua});const h=(a=>{var e={};return c.d(e,a),e})({LitElement:()=>N,css:()=>gt,html:()=>At}),lt=(a,e,t)=>{let i=a[0];for(let o=1;o{return typeof(e=a)!="string"&&"strTag"in e?lt(a.strings,a.values):a;var e};let k=nt,Ye=!1;const De="lit-localize-status";class Bt{constructor(e){this.__litLocalizeEventHandler=t=>{t.detail.status==="ready"&&this.host.requestUpdate()},this.host=e}hostConnected(){window.addEventListener(De,this.__litLocalizeEventHandler)}hostDisconnected(){window.removeEventListener(De,this.__litLocalizeEventHandler)}}const Nt=a=>a.addController(new Bt(a));class rt{constructor(){this.settled=!1,this.promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}resolve(e){this.settled=!0,this._resolve(e)}reject(e){this.settled=!0,this._reject(e)}}const _=[];for(let a=0;a<256;a++)_[a]=(a>>4&15).toString(16)+(15&a).toString(16);const qt="",Wt="h",Zt="s";function Yt(a,e){return(e?Wt:Zt)+function(t){let i=0,o=8997,s=0,l=33826,n=0,r=40164,g=0,p=52210;for(let d=0;d>>16,o=65535&i,n+=s>>>16,l=65535&s,p=g+(n>>>16)&65535,r=65535&n;return _[p>>8]+_[255&p]+_[r>>8]+_[255&r]+_[l>>8]+_[255&l]+_[o>>8]+_[255&o]}(typeof a=="string"?a:a.join(qt))}const Ve=new WeakMap,Fe=new Map;function Vt(a,e,t){if(a){const i=(t==null?void 0:t.id)??function(s){const l=typeof s=="string"?s:s.strings;let n=Fe.get(l);return n===void 0&&(n=Yt(l,typeof s!="string"&&!("strTag"in s)),Fe.set(l,n)),n}(e),o=a[i];if(o){if(typeof o=="string")return o;if("strTag"in o)return lt(o.strings,e.values,o.values);{let s=Ve.get(o);return s===void 0&&(s=o.values,Ve.set(o,s)),{...o,values:s.map(l=>e.values[l])}}}}return nt(e)}function oe(a){window.dispatchEvent(new CustomEvent(De,{detail:a}))}let se,dt,J,Pe,ct,Q="",D=new rt;D.resolve();let Y=0;const Ft=()=>Q,Gt=a=>{if(a===(se??Q))return D.promise;if(!J||!Pe)throw Error("Internal error");if(!J.has(a))throw Error("Invalid locale code");Y++;const e=Y;return se=a,D.settled&&(D=new rt),oe({status:"loading",loadingLocale:a}),(a===dt?Promise.resolve({templates:void 0}):Pe(a)).then(t=>{Y===e&&(Q=a,se=void 0,ct=t.templates,oe({status:"ready",readyLocale:a}),D.resolve())},t=>{Y===e&&(oe({status:"error",errorLocale:a,errorMessage:t.toString()}),D.reject(t))}),D.promise},b=(a=>{var e={};return c.d(e,a),e})({customElement:()=>Tt,property:()=>ot,state:()=>Lt}),Kt=["cs","de","el","es","fr","it","ja","km","ko","nl","no","pl","pt","ru","sr","sv","tr","uk","zh","zh-CN"],Jt={s182ab2d6c997515f:"Добавьте его на главный экран, чтобы получить дополнительные возможности и удобство использования.",s1b9047d53d9f9d22:'2) Нажать "Поделиться"',s37a9e8aec5713460:"Подробнее",s5c6aad7a7e4a1437:'3) Нажать "На экран «Домой»"',s6196153c4b0c1ea0:"Установить",s922329d6f6213590:"Добавить в Dock",sa5ef80b4bb9b39f8:"Свернуть",sa7551383d1897fcc:'2) Нажмите "Добавить в Dock"',sba52286c21552a4e:"Установите это на ваше устройство, чтобы получить дополнительные возможности и удобство использования.",sc79fd7641eb9a975:"Спрятать Инструкцию",scdaf4bbff76674c8:"На экран «Домой»",sdfe23506a3b0cdc8:"1) Открыть в Safari браузере",se740f75b95a51807:"Добавьте его в Dock, чтобы получить дополнительные возможности и удобство использования.",sfea652f6580ff086:"Этот веб-сайт имеет функционал приложения."},Qt={s182ab2d6c997515f:"Daha iyi bir deneyim ve kolay erişim için Ana Ekranınıza ekleyin.",s1b9047d53d9f9d22:"2) Gezinme çubuğunda Paylaş'a basın",s37a9e8aec5713460:"Daha Fazla",s5c6aad7a7e4a1437:"3) Ana Ekrana Ekle'ye basın",s6196153c4b0c1ea0:"Yükle",s922329d6f6213590:"Dock’a Ekle",sa5ef80b4bb9b39f8:"Küçült",sa7551383d1897fcc:"2) Dock’a ekleye basın",sba52286c21552a4e:"Daha iyi bir deneyim ve kolay erişim için cihazınıza yükleyin.",sc79fd7641eb9a975:"Talimatları gizle",scdaf4bbff76674c8:"Ana Ekrana Ekle",sdfe23506a3b0cdc8:"1) Safari tarayıcısında açın",se740f75b95a51807:"Daha iyi bir deneyim ve kolay erişim için Dock’a ekleyin.",sfea652f6580ff086:"Bu site uygulama işlevselliğine sahiptir."},Xt={s182ab2d6c997515f:"Fügen Sie es zu Ihrem Startbildschirm hinzu, um eine umfassende Erfahrung und einen leichten Zugriff zu erhalten.",s1b9047d53d9f9d22:"2) Drücken Sie auf Teilen in der Navigationsleiste",s37a9e8aec5713460:"Mehr",s5c6aad7a7e4a1437:"3) Drücken Sie Hinzufügen zum Startbildschirm",s6196153c4b0c1ea0:"Installieren",s922329d6f6213590:"Zum Dock hinzufügen",sa5ef80b4bb9b39f8:"Weniger",sa7551383d1897fcc:"2) Drücken Sie auf Zum Dock hinzufügen",sba52286c21552a4e:"Installieren Sie es auf Ihrem Gerät für eine umfassende Erfahrung und einen leichten Zugriff.",sc79fd7641eb9a975:"Anleitung ausblenden",scdaf4bbff76674c8:"Hinzufügen zum Startbildschirm",sdfe23506a3b0cdc8:"1) In Safari-Browser öffnen",se740f75b95a51807:"Fügen Sie es zu Ihrem Dock hinzu, um eine umfassende Erfahrung und einen leichten Zugriff zu erhalten.",sfea652f6580ff086:"Diese Website verfügt über App-Funktionalität."},ea={s182ab2d6c997515f:"Añádelo a tu pantalla de inicio para una experiencia amplia y acceso fácil.",s1b9047d53d9f9d22:"2) Presionar Compartir en la barra de direcciones",s37a9e8aec5713460:"Más",s5c6aad7a7e4a1437:"3) Presionar Añadir a pantalla de inicio",s6196153c4b0c1ea0:"Instalar",s922329d6f6213590:"Añadir al Dock",sa5ef80b4bb9b39f8:"Menos",sa7551383d1897fcc:"2) Presionar Añadir al Dock",sba52286c21552a4e:"Instálalo en tu dispositivo para una experiencia amplia y acceso fácil.",sc79fd7641eb9a975:"Esconder instrucciones",scdaf4bbff76674c8:"Añadir a pantalla de inicio",sdfe23506a3b0cdc8:"1) Abrir en el navegador web Safari",se740f75b95a51807:"Añádelo a tu Dock para una experiencia amplia y acceso fácil.",sfea652f6580ff086:"Este sitio tiene funcionalidad de aplicación."},ta={s182ab2d6c997515f:"Voeg het toe aan je startscherm voor een uitgebreide ervaring en gemakkelijke toegang.",s1b9047d53d9f9d22:"2) Druk op delen in de navigatiebalk",s37a9e8aec5713460:"Meer",s5c6aad7a7e4a1437:"3) Druk op Toevoegen aan het startscherm",s6196153c4b0c1ea0:"Installeren",s922329d6f6213590:"Toevoegen aan Dock",sa5ef80b4bb9b39f8:"Minder",sa7551383d1897fcc:"2) Druk op Toevoegen aan Dock",sba52286c21552a4e:"Installeer het op je apparaat voor een uitgebreide ervaring en gemakkelijke toegang.",sc79fd7641eb9a975:"Instructie verbergen",scdaf4bbff76674c8:"Toevoegen aan het startscherm",sdfe23506a3b0cdc8:"1) Open in Safari-browser",se740f75b95a51807:"Voeg het toe aan je Dock voor een uitgebreide ervaring en makkelijke toegang.",sfea652f6580ff086:"Deze site heeft app-functionaliteit."},aa={s182ab2d6c997515f:"Προσθέστε το στην οθόνη Αφετηρίας για εκτεταμένη εμπειρία και εύκολη πρόσβαση.",s1b9047d53d9f9d22:"2) Πατήστε Κοινοποίηση στη γραμμή πλοήγησης",s37a9e8aec5713460:"Περισσότερα",s5c6aad7a7e4a1437:"3) Πατήστε Προσθήκη στην οθόνη Αφετηρίας",s6196153c4b0c1ea0:"Εγκατάσταση",s922329d6f6213590:"Προσθήκη στην Πρόσβαση",sa5ef80b4bb9b39f8:"Λιγότερα",sa7551383d1897fcc:"2) Πατήστε Προσθήκη στην Πρόσβαση",sba52286c21552a4e:"Εγκαταστήστε το στη συσκευή σας για εκτεταμένη εμπειρία και εύκολη πρόσβαση.",sc79fd7641eb9a975:"Απόκρυψη Οδηγιών",scdaf4bbff76674c8:"Προσθήκη στην Οθόνη Αφετηρίας",sdfe23506a3b0cdc8:"1) Ανοίξτε τον περιηγητή Safari",se740f75b95a51807:"Προσθέστε το στην Πρόσβαση για εκτεταμένη εμπειρία και εύκολη πρόσβαση.",sfea652f6580ff086:"Αυτός ο ιστότοπος έχει λειτουργική εφαρμογής."},ia={s182ab2d6c997515f:"Ajoutez-le à votre écran d'accueil pour une expérience étendue et un accès facile.",s1b9047d53d9f9d22:"2) Appuyez sur Partager dans la barre de navigation",s37a9e8aec5713460:"Plus",s5c6aad7a7e4a1437:"3) Appuyez sur Ajouter à l'écran d'accueil",s6196153c4b0c1ea0:"Installer",s922329d6f6213590:"Ajouter au Dock",sa5ef80b4bb9b39f8:"Moins",sa7551383d1897fcc:"2) Appuyez sur Ajouter au Dock",sba52286c21552a4e:"Installez-le sur votre appareil pour une expérience complète et un accès facile.",sc79fd7641eb9a975:"Masquer les instructions",scdaf4bbff76674c8:"Ajouter à l'écran d'accueil",sdfe23506a3b0cdc8:"1) Ouvrir dans le navigateur Safari",se740f75b95a51807:"Ajoutez-le à votre Dock pour une expérience étendue et un accès facile.",sfea652f6580ff086:"Ce site possède des fonctionnalités d'application."},oa={s182ab2d6c997515f:"Додајте га на Home Screen за широке могућности и лак приступ.",s1b9047d53d9f9d22:"2) Притисните Share у навигационој траци",s37a9e8aec5713460:"Више",s5c6aad7a7e4a1437:"3) Притисните Add to Home Screen",s6196153c4b0c1ea0:"Инсталирај",sa5ef80b4bb9b39f8:"Мање",sa7551383d1897fcc:"3) Притисните Add to Dock",sba52286c21552a4e:"Инсталирајте га на вашем уређају за широке могућности и лак приступ.",sc79fd7641eb9a975:"Сакриј упутство",sdfe23506a3b0cdc8:"1) Отворите у Safari прегледачу",se740f75b95a51807:"Додајте га у вашу Dock за широке могућности и лак приступ.",sfea652f6580ff086:"Овај сајт има функционалност апликације.",s922329d6f6213590:"Add to Dock",scdaf4bbff76674c8:"Add to Home Screen"},sa={s182ab2d6c997515f:"Dodaj do swojego Ekranu Głównego, aby uzyskać bogate doświadczenie i łatwy dostęp.",s1b9047d53d9f9d22:'2) Wybierz "Udostępnij"',s37a9e8aec5713460:"Więcej",s5c6aad7a7e4a1437:'3) Wybierz "Dodaj do Ekranu Głównego"',s6196153c4b0c1ea0:"Zainstaluj",s922329d6f6213590:"Dodaj do Docka",sa5ef80b4bb9b39f8:"Mniej",sa7551383d1897fcc:'2) Wybierz "Dodaj do Docka"',sba52286c21552a4e:"Zainstaluj na swoim urządzeniu, aby uzyskać bogate doświadczenie i łatwy dostęp.",sc79fd7641eb9a975:"Ukryj instrukcję",scdaf4bbff76674c8:"Dodaj do Ekranu Głównego",sdfe23506a3b0cdc8:"1) Otwórz przeglądarkę Safari",se740f75b95a51807:"Dodaj do swojego Docka, aby uzyskać bogate doświadczenie i łatwy dostęp.",sfea652f6580ff086:"Ta strona posiada funkcje aplikacji."},la={s182ab2d6c997515f:"Додайте на Домашній екран для зручного доступу та ширших можливостей.",s1b9047d53d9f9d22:"2) Натиснути «Поділитися»",s37a9e8aec5713460:"Детальніше",s5c6aad7a7e4a1437:"3) Натиснути «На Початковий екран»",s6196153c4b0c1ea0:"Встановити",s922329d6f6213590:"Додати на Dock",sa5ef80b4bb9b39f8:"Згорнути",sa7551383d1897fcc:"2) Натиснути «Додати на Dock»",sba52286c21552a4e:"Встановіть на ваш пристрій для зручного доступу та ширших можливостей.",sc79fd7641eb9a975:"Сховати Інструкцію",scdaf4bbff76674c8:"На Початковий экран",sdfe23506a3b0cdc8:"1) Відкрити в Safari браузері",se740f75b95a51807:"Додайте на панель Dock для зручного доступу та ширших можливостей.",sfea652f6580ff086:"Цей сайт має функції додатку."},na={s182ab2d6c997515f:"將其加入主屏幕,以獲得更豐富的體驗和便捷訪問。",s1b9047d53d9f9d22:"2) 點擊列表上的分享按鈕",s37a9e8aec5713460:"詳細資訊",s5c6aad7a7e4a1437:"3) 點擊加入主畫面",s6196153c4b0c1ea0:"安裝",s922329d6f6213590:"添加到Dock欄",sa5ef80b4bb9b39f8:"簡短資訊",sa7551383d1897fcc:"2) 點選添加到Dock欄",sba52286c21552a4e:"在您的裝置上安裝它,以獲得更豐富的體驗和便捷訪問。",sc79fd7641eb9a975:"隱藏安裝流程",scdaf4bbff76674c8:"將App加入主畫面",sdfe23506a3b0cdc8:"1) 在Safari上瀏覽此網頁",se740f75b95a51807:"將其加入你的Dock欄,以獲得更豐富的體驗和便捷訪問。",sfea652f6580ff086:"此網站具有應用程式功能。"},ra={s182ab2d6c997515f:"将其添加到主屏幕,以享受更全面的体验并便于访问。",s1b9047d53d9f9d22:"2) 点击列表上的分享按钮",s37a9e8aec5713460:"详细资讯",s5c6aad7a7e4a1437:"3) 点击添加到主屏幕",s6196153c4b0c1ea0:"安装",s922329d6f6213590:"添加到Dock",sa5ef80b4bb9b39f8:"简短资讯",sa7551383d1897fcc:"2) 按下添加到Dock",sba52286c21552a4e:"在您的设备上安装,以享有更全面的体验和便捷的访问。",sc79fd7641eb9a975:"隐藏安装流程",scdaf4bbff76674c8:"将App添加到主屏幕",sdfe23506a3b0cdc8:"1) 在Safari上浏览此网页",se740f75b95a51807:"将其添加到您的Dock,以享受更全面的体验并便于访问。",sfea652f6580ff086:"此网站具备app的功能性。"},da={s182ab2d6c997515f:"Aggiungilo alla schermata principale per un'esperienza più completa e un accesso facile.",s1b9047d53d9f9d22:"2) Premi Condividi nella barra di navigazione",s37a9e8aec5713460:"Più",s5c6aad7a7e4a1437:"3) Premi Aggiungi alla schermata principale",s6196153c4b0c1ea0:"Installa",s922329d6f6213590:"Aggiungi al Dock",sa5ef80b4bb9b39f8:"Meno",sa7551383d1897fcc:"2) Premi Aggiungi al Dock",sba52286c21552a4e:"Installalo sul tuo dispositivo per un'esperienza più completa e un accesso facile.",sc79fd7641eb9a975:"Nascondi istruzioni",scdaf4bbff76674c8:"Aggiungi alla schermata principale",sdfe23506a3b0cdc8:"1) Apri nel browser Safari",se740f75b95a51807:"Aggiungilo al Dock per un'esperienza più completa e un accesso facile.",sfea652f6580ff086:"Questo sito ha funzionalità di app."},ca={s182ab2d6c997515f:"Přidejte jej na plochu pro rozšířené využití a snadný přístup.",s1b9047d53d9f9d22:"2) Stiskněte tlačítko Sdílet na navigačním panelu",s37a9e8aec5713460:"Vice",s5c6aad7a7e4a1437:"3) Stiskněte tlačítko Přidat na plochu",s6196153c4b0c1ea0:"Nainstalovat",s922329d6f6213590:"Přidat do Docku",sa5ef80b4bb9b39f8:"Méně",sa7551383d1897fcc:"2) Stiskněte Přidat do Docku",sba52286c21552a4e:"Nainstalujte si jej na své zařízení pro rozšířené využití a snadný přístup.",sc79fd7641eb9a975:"Skrýt instrukce",scdaf4bbff76674c8:"Přidat na plochu",sdfe23506a3b0cdc8:"1) Otevřete v prohlížeči Safari",se740f75b95a51807:"Přidejte jej do svého Docku pro rozšířené využití a snadný přístup.",sfea652f6580ff086:"Tento web má funkce aplikace."},pa={s182ab2d6c997515f:"Legg den til på Hjem-skjermen din for å få en bedre brukeropplevelse og raskere tilgang.",s1b9047d53d9f9d22:"2) Trykk på Del-knappen i navigasjonslinjen",s37a9e8aec5713460:"Mer",s5c6aad7a7e4a1437:"3) Velg Legg til på Hjem-skjerm",s6196153c4b0c1ea0:"Installer",s922329d6f6213590:"Legg til i Dock",sa5ef80b4bb9b39f8:"Mindre",sa7551383d1897fcc:"2) Velg Legg til i Dock",sba52286c21552a4e:"Installer den på enheten din for å få en bedre brukeropplevelse og raskere tilgang.",sc79fd7641eb9a975:"Skjul instruksjoner",scdaf4bbff76674c8:"Legg til på Hjem-skjerm",sdfe23506a3b0cdc8:"1) Åpne i Safari",se740f75b95a51807:"Legg den til i Docken din for å få en bedre brukeropplevelse og raskere tilgang.",sfea652f6580ff086:"Denne siden har app-funksjonalitet."},ha={s182ab2d6c997515f:"Adicione à Tela de Início para uma melhor experiência e mais fácil acesso.",s1b9047d53d9f9d22:"2) Pressione Compartilhar na barra de endereço",s37a9e8aec5713460:"Mais",s5c6aad7a7e4a1437:"3) Pressione Adicionar à Tela de Início",s6196153c4b0c1ea0:"Instalar",s922329d6f6213590:"Adicionar ao Dock",sa5ef80b4bb9b39f8:"Menos",sa7551383d1897fcc:"2) Pressione Adicionar ao Dock",sba52286c21552a4e:"Instale no dispositivo para uma melhor experiência e mais fácil acesso.",sc79fd7641eb9a975:"Ocultar Instruções",scdaf4bbff76674c8:"Adicionar à Tela de Início",sdfe23506a3b0cdc8:"1) Abra no navegador Safari",se740f75b95a51807:"Adicione ao Dock para uma melhor experiência e mais fácil acesso.",sfea652f6580ff086:"Este site possui funcionalidade de aplicativo."},ga={s182ab2d6c997515f:"ホーム画面に追加して、幅広い体験と簡単なアクセスを実現してください。",s1b9047d53d9f9d22:"2) ナビゲーションバーで共有を押す",s37a9e8aec5713460:"展開",s5c6aad7a7e4a1437:"3) 「ホーム画面に追加」を押す",s6196153c4b0c1ea0:"インストール",s922329d6f6213590:"Dockに追加",sa5ef80b4bb9b39f8:"折りたたむ",sa7551383d1897fcc:"2) 「Dockに追加」を押す",sba52286c21552a4e:"デバイスにインストールすることで、より充実した体験と簡単なアクセスを実現できます。",sc79fd7641eb9a975:"説明を非表示",scdaf4bbff76674c8:"ホーム画面に追加",sdfe23506a3b0cdc8:"1) Safariで開く",se740f75b95a51807:"ドックに追加して、幅広い体験と簡単なアクセスを実現してください。",sfea652f6580ff086:"このサイトはアプリ機能があります。"},ba={s182ab2d6c997515f:"Lägg till på hemskärmen för att få en bättre användarupplevelse och enklare åtkomst.",s1b9047d53d9f9d22:"2) Tryck på Dela-knappen i verktygsfältet",s37a9e8aec5713460:"Mer",s5c6aad7a7e4a1437:"3) Välj Lägg till på hemskärmen",s6196153c4b0c1ea0:"Installera",s922329d6f6213590:"Lägg till i Dock",sa5ef80b4bb9b39f8:"Mindre",sa7551383d1897fcc:"2) Välj Lägg till i Dock",sba52286c21552a4e:"Installera den på din enhet för att få en bättre användarupplevelse och enklare åtkomst.",sc79fd7641eb9a975:"Göm instruktioner",scdaf4bbff76674c8:"Lägg till på hemskärmen",sdfe23506a3b0cdc8:"1) Öppna i Safari",se740f75b95a51807:"Lägg till i Dock för att få en bättre användarupplevelse och enklare åtkomst.",sfea652f6580ff086:"Denna webbsajt har app-funktionalitet."},ma={s182ab2d6c997515f:"더 많은 기능과 쉬운 접근을 위해 홈 화면에 추가해주세요.",s1b9047d53d9f9d22:"2) 내비게이션 바에서 공유 버튼 누르기",s37a9e8aec5713460:"더보기",s5c6aad7a7e4a1437:"3) 홈 화면에 추가 버튼 누르기",s6196153c4b0c1ea0:"설치",s922329d6f6213590:"Dock에 추가",sa5ef80b4bb9b39f8:"닫기",sa7551383d1897fcc:"2) Dock에 추가 버튼 누르기",sba52286c21552a4e:"더 많은 기능과 쉬운 접근을 위해 기기에 설치해주세요.",sc79fd7641eb9a975:"안내 숨기기",scdaf4bbff76674c8:"홈 화면에 추가",sdfe23506a3b0cdc8:"1) Safari 브라우저에서 열기",se740f75b95a51807:"더 많은 기능과 쉬운 접근을 위해 Dock에 추가해주세요.",sfea652f6580ff086:"이 사이트는 앱 기능을 가지고 있습니다."},ua={s182ab2d6c997515f:"បន្ថែមវាទៅកាន់ផ្ទាំងអេក្រង់ដើមដើម្បីទទួលបាននូវបទពិសោធន៍កាន់តែល្អនិងងាយស្រួលប្រើ។",s1b9047d53d9f9d22:"2) ចុចលើ ប៊ូតុងចែករំលែក នៅក្នុងរបារទិសដៅ",s37a9e8aec5713460:"បង្ហាញបន្ថែម",s5c6aad7a7e4a1437:"3) ចុចលើ បន្ថែមទៅកាន់ផ្ទាំងអេក្រង់ដើម",s6196153c4b0c1ea0:"តំឡើង",s922329d6f6213590:"បន្ថែមទៅកាន់ Dock",sa5ef80b4bb9b39f8:"បង្ហាញតិច",sa7551383d1897fcc:"2) ចុចលើ បន្ថែមទៅកាន់ Dock",sba52286c21552a4e:"តំឡើងវានៅលើឧបករណ៍របស់អ្នកដើម្បីទទួលបាននូវបទពិសោធន៍កាន់តែល្អនិងងាយស្រួលប្រើ។",sc79fd7641eb9a975:"បិទការណែនាំ",scdaf4bbff76674c8:"បន្ថែមទៅកាន់ផ្ទាំងអេក្រង់ដើម",sdfe23506a3b0cdc8:"1) បើកនៅក្នុងកម្មវិធី Safari",se740f75b95a51807:"បន្ថែមវាទៅកាន់ Dock ដើម្បីទទួលបាននូវបទពិសោធន៍កាន់តែល្អនិងងាយស្រួលប្រើ។",sfea652f6580ff086:"គេហទំព័រនេះមានមុខងារជាកម្មវិធី។"},pt=new Map([["ru",re],["tr",de],["de",ce],["es",pe],["nl",he],["el",ge],["fr",be],["sr",me],["pl",ue],["uk",fe],["zh",ve],["zh-CN",we],["it",ye],["cs",xe],["no",ke],["pt",$e],["ja",_e],["sv",Ae],["ko",Ee],["km",Se]]),{getLocale:Ia,setLocale:Ge}=(I={sourceLocale:"en",targetLocales:Kt,loadLocale:async a=>pt.get(a)},function(a){if(Ye)throw Error("lit-localize can only be configured once");k=a,Ye=!0}((a,e)=>Vt(ct,a,e)),Q=dt=I.sourceLocale,J=new Set(I.targetLocales),J.add(I.sourceLocale),Pe=I.loadLocale,{getLocale:Ft,setLocale:Gt});var I;class fa{constructor(){this.icons=[{src:""}],this.screenshots=void 0,this.short_name="PWA",this.name="Progressive web application",this.description="Progressive web application"}}const va=h.css`.gallery{position:relative;--scrollbar-background-color:#fff;--scrollbar-thumb-color:rgb(146, 146, 146);--scrollbar-thumb-hover-color:rgb(100, 100, 100);--nav-btn-background-color:#fff;--nav-btn-fill-color:#141414}.gallery .gallery_scroller{scroll-snap-type:x mandatory;overflow-x:auto;overflow-y:hidden;display:flex;align-items:center;padding:10px 13px;padding-bottom:10px;margin:0 10px;-webkit-overflow-scrolling:touch}.gallery .gallery_scroller img{border-radius:6px;max-height:min(45vh,500px);box-shadow:0 3px 10px 0 rgba(0,0,0,.15);scroll-snap-align:center;scroll-snap-stop:always;position:relative}.gallery .gallery_scroller img+img{margin-left:15px}.gallery .gallery_scroller::-webkit-scrollbar{width:4px;height:2px}.gallery .gallery_scroller::-webkit-scrollbar-thumb{background:var(--scrollbar-thumb-color);border-radius:4px}.gallery .gallery_scroller::-webkit-scrollbar-thumb:hover{background:var(--scrollbar-thumb-hover-color)}.gallery .gallery_scroller::-webkit-scrollbar-track{background:var(--scrollbar-background-color);border-radius:4px}.gallery .gallery_scroller .scroller_wrap{display:flex;flex-direction:row;padding-right:13px}.gallery .btn{position:absolute;display:flex;align-items:center;-webkit-user-select:none;user-select:none;top:50%;transform:translateY(-50%);height:30px;width:30px;border-radius:50%;background-color:var(--nav-btn-background-color);box-shadow:rgba(0,0,0,.3) 2px 4px 4px 1px;background-repeat:no-repeat;opacity:.8;z-index:1}.gallery .btn.prev{left:5px}.gallery .btn.prev svg{margin-left:4px}.gallery .btn.next{right:5px}.gallery .btn.next svg{transform:rotate(180deg);margin-left:6px}.gallery .btn:hover{box-shadow:rgba(0,0,0,.5) 2px 4px 4px 1px;cursor:pointer;opacity:1}.gallery .btn svg{width:20px;height:20px}.gallery .btn svg path{fill:var(--nav-btn-fill-color)}.gallery.apple_desktop{--scrollbar-background-color:rgba(0, 0, 0, 0.1);--scrollbar-thumb-color:rgb(100, 100, 100);--scrollbar-thumb-hover-color:rgba(0, 0, 0, 0.85)}.gallery.apple_desktop .gallery_scroller{margin:0;padding-top:15px}.gallery.apple_desktop .btn{height:26px;width:26px;box-shadow:rgba(0,0,0,.3) 0 2px 2px 1px}.gallery.apple_desktop .btn:hover{box-shadow:rgba(0,0,0,.3) 0 2px 2px 1px}.gallery.apple_desktop .btn:active{filter:brightness(95%)}.gallery.apple_desktop .btn:active .svg{filter:brightness(110%)}.gallery.apple_desktop .btn svg{width:12px;height:auto;opacity:1}.gallery.apple_desktop .btn svg{margin-left:7px}.gallery.apple_mobile .btn.prev svg{margin-left:7px}.gallery.apple_mobile .btn svg{width:16px;height:auto}.gallery.apple_desktop .btn,.gallery.apple_mobile .btn{opacity:1}@media(hover:none)and (pointer:coarse){.gallery .btn.next,.gallery .btn.prev{display:none}.gallery_scroller::-webkit-scrollbar{display:none}}@media(prefers-color-scheme:dark){.gallery{--scrollbar-background-color:#424242;--nav-btn-background-color:#555555;--nav-btn-fill-color:#fff}.gallery.apple_desktop{--scrollbar-thumb-color:var(--nav-btn-fill-color);--scrollbar-background-color:var(--nav-btn-background-color);--scrollbar-thumb-hover-color:var(--nav-btn-fill-color)}.gallery.apple_desktop .btn:active{filter:brightness(110%)}.gallery.apple_desktop .btn:active .svg{filter:brightness(90%)}}`,wa=(a,e,t,i)=>h.html`${a?h.html``:""}`;var le=function(a,e,t,i){var o,s=arguments.length,l=s<3?e:i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(a,e,t,i);else for(var n=a.length-1;n>=0;n--)(o=a[n])&&(l=(s<3?o(l):s>3?o(e,t,l):o(e,t))||l);return s>3&&l&&Object.defineProperty(e,t,l),l},Ke=function(a,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(a,e)};let H=class extends h.LitElement{constructor(){super(...arguments),this.screenshots=[],this.theme="default",this.calcScrollSize=()=>{const a=this.shadowRoot.querySelector("#paginated_gallery");if(!a)return;const e=a.querySelector(".gallery_scroller");if(!e)return;const t=Array.from(e.querySelectorAll("img"));if(!t)return;const i=t.find(o=>o.offsetWidth+o.offsetLeft>=e.scrollLeft);return i?{scroller:e,item:i}:void 0},this.scrollToNextPage=()=>{const a=this.calcScrollSize();a&&a.item.nextElementSibling&&a.scroller.scrollTo({top:0,left:a.scroller.scrollLeft+a.scroller.clientWidth+a.item.nextElementSibling.clientWidth/2,behavior:"smooth"})},this.scrollToPrevPage=()=>{const a=this.calcScrollSize();a&&a.item.previousElementSibling&&a.scroller.scrollTo({top:0,left:a.scroller.scrollLeft-a.scroller.clientWidth-a.item.previousElementSibling.clientWidth/2,behavior:"smooth"})},this._init=()=>{}}static get styles(){return va}firstUpdated(){const a=this.calcScrollSize();a&&setTimeout(()=>{a.scroller.scrollTo({top:0,left:0})},300)}connectedCallback(){super.connectedCallback(),this._init()}render(){return h.html`${wa(this.screenshots,this.theme,this.scrollToNextPage,this.scrollToPrevPage)}`}};le([(0,b.property)(),Ke("design:type",Object)],H.prototype,"screenshots",void 0),le([(0,b.property)(),Ke("design:type",String)],H.prototype,"theme",void 0),H=le([(0,b.customElement)("pwa-gallery")],H);const ya=H,xa=(a,e,t,i)=>h.html`
icon
${location.hostname}
${e?h.html`
${e}
`:""}`,T=(a,e,t)=>{const i=new CustomEvent(e,{detail:{message:t}});a.dispatchEvent(i)};class v{static isAppleMobile(){return!(!(["iPhone","iPad","iPod"].includes(navigator.platform)||navigator.userAgent.match(/Mac/)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2)||!("serviceWorker"in navigator))}static isAppleDesktop(){const e=navigator.userAgent.toLowerCase();if(navigator.maxTouchPoints||!e.match(/macintosh/))return!1;const t=/version\/(\d{2})\./.exec(e);if(!(t&&t[1]&&parseInt(t[1])>=17))return!1;const i=!!document.createElement("audio").canPlayType('audio/wav; codecs="1"'),o=!!new OffscreenCanvas(1,1).getContext("webgl");return i&&o}static isStandalone(){return!!(window.matchMedia("(display-mode: standalone)").matches||"standalone"in navigator&&navigator.standalone===!0)}static async getInstalledRelatedApps(){if("getInstalledRelatedApps"in navigator)try{return await navigator.getInstalledRelatedApps().then(e=>e)}catch{}return[]}static async isRelatedAppsInstalled(){return!!(await this.getInstalledRelatedApps()).length}static eventInstalledSuccess(e){T(e,"pwa-install-success-event","App install success (Chromium/Android only)")}static eventInstalledFail(e){T(e,"pwa-install-fail-event","App install failed (Chromium/Android only)")}static eventUserChoiceResult(e,t){T(e,"pwa-user-choice-result-event",t)}static eventInstallAvailable(e){T(e,"pwa-install-available-event","App install available")}static eventInstallHowTo(e){T(e,"pwa-install-how-to-event","App install instruction showed")}static eventGallery(e){T(e,"pwa-install-gallery-event","App install gallery showed")}static normalizeManifestAssetUrls(e,t){const i=new URL(t,document.location.href);[...e.icons||[],...e.screenshots||[]].forEach(o=>{o.src=new URL(o.src,i).href})}}var U=function(a,e,t,i){var o,s=arguments.length,l=s<3?e:i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(a,e,t,i);else for(var n=a.length-1;n>=0;n--)(o=a[n])&&(l=(s<3?o(l):s>3?o(e,t,l):o(e,t))||l);return s>3&&l&&Object.defineProperty(e,t,l),l},V=function(a,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(a,e)};let P=class extends h.LitElement{constructor(){super(...arguments),this.props={name:"",description:"",icon:""},this.install={handleEvent:()=>{}},this.hideDialog=()=>{},this.disableClose=!1,this._callInstall=()=>{this.install.handleEvent()},this._callHide=()=>{this.hideDialog(),this.setupAppearence()},this.bindedElement=null,this._saveBodyStyle=document.body.style.overscrollBehaviorY,this.dragMobileSheet=(a,e,t)=>{if(!a||!e||!t)return null;let i=0;const o=e.clientHeight+t.clientHeight,s=p=>p.clientY||(p.changedTouches&&p.changedTouches.length?p.changedTouches[0].clientY:0),l=p=>{window.addEventListener("mouseup",n),window.addEventListener("mousemove",r),window.addEventListener("touchend",n),window.addEventListener("touchmove",r),i=s(p)-e.getBoundingClientRect().top,document.body.style.overscrollBehaviorY="none"},n=p=>{if(document.body.style.overscrollBehaviorY=this._saveBodyStyle,!this.disableClose&&s(p)>=window.innerHeight-25)g(p,window.innerHeight+50,!0);else if(window.innerHeight-s(p)>a.clientHeight/2.5){g(p,window.innerHeight-a.clientHeight);try{v.eventGallery(this.getRootNode().host)}catch{}}else g(p,window.innerHeight-o-35)},r=p=>{const d=s(p);this.disableClose&&window.innerHeight-d<70||d<=window.innerHeight-a.clientHeight+i||(a.style.setProperty("transition","none"),a.style.setProperty("--translateY",`translateY(${d-i}px)`))},g=(p,d,m)=>{window.removeEventListener("mouseup",n),window.removeEventListener("mousemove",r),window.removeEventListener("touchend",n),window.removeEventListener("touchmove",r),window.innerWidth>=768||(!d&&s(p)>=window.innerHeight-o?a.style.setProperty("--translateY",`translateY(calc(100vh - ${o}px))`):a.style.setProperty("--translateY",`translateY(${(d||s(p))+35}px)`),a.style.setProperty("transition","transform 500ms cubic-bezier(0.4, 0, 0, 1) 0s"),m&&(e.removeEventListener("mousedown",l),e.removeEventListener("touchstart",l),setTimeout(this._callHide,250)))};return e.addEventListener("mousedown",l),e.addEventListener("touchstart",l,{passive:!0}),g(new MouseEvent("mouseup"),window.innerHeight-o-35),{touchElement:e,listener:l}},this.setupAppearence=()=>{var a,e,t;this.bindedElement&&(this.bindedElement.touchElement.removeEventListener("mousedown",this.bindedElement.listener),this.bindedElement.touchElement.removeEventListener("touchstart",this.bindedElement.listener)),this.bindedElement=this.dragMobileSheet((a=this.parentElement)==null?void 0:a.parentElement,(e=this.parentElement)==null?void 0:e.getElementsByClassName("touch-header")[0],(t=this.parentElement)==null?void 0:t.getElementsByClassName("body-header")[0])},this._init=()=>{this.setupAppearence(),window.addEventListener("resize",this.setupAppearence)}}firstUpdated(){this._init()}createRenderRoot(){return this}connectedCallback(){super.connectedCallback()}render(){return h.html`${xa(this.props.name,this.props.description,this.props.icon,this._callInstall)}`}};U([(0,b.property)({type:Object}),V("design:type",Object)],P.prototype,"props",void 0),U([(0,b.property)({type:Object}),V("design:type",Object)],P.prototype,"install",void 0),U([(0,b.property)(),V("design:type",Object)],P.prototype,"hideDialog",void 0),U([(0,b.property)(),V("design:type",Object)],P.prototype,"disableClose",void 0),P=U([(0,b.customElement)("pwa-bottom-sheet")],P);const ka=P,$a=h.css`#pwa-install-element{-webkit-user-select:none;user-select:none}#pwa-install-element .install-dialog{--text-color-normal:#212121;--background-color:#fff;--border-bottom-color:#DBDCDE;--scrollbar-background-color:#fff;font-family:Roboto,"Segoe UI",system-ui;position:fixed;display:inline-block;opacity:0;visibility:hidden;z-index:2147483001}#pwa-install-element .install-dialog.chrome{max-width:380px;width:90%;min-height:90px;margin:0 auto;right:150px;left:auto;background-color:var(--background-color);filter:drop-shadow(0 5px 15px rgba(0, 0, 0, .3));font-size:15px;color:var(--text-color-normal);border-radius:8px;top:-100px;transition:top .5s ease-in-out,opacity .8s ease-in-out,max-height .35s ease-in-out}#pwa-install-element .install-dialog.chrome.available{opacity:1;top:28px;visibility:visible}#pwa-install-element .install-dialog.chrome .dialog-body{display:grid;grid-template-columns:70px 1fr}#pwa-install-element .install-dialog.chrome .dialog-body .icon{display:flex;align-items:flex-start}#pwa-install-element .install-dialog.chrome .dialog-body .icon .icon-image{width:48px;height:48px;margin:0 auto;margin-top:10px;border-radius:6px}#pwa-install-element .install-dialog.chrome .dialog-body .about{display:grid;grid-template-rows:30px auto}#pwa-install-element .install-dialog.chrome .dialog-body .about .hostname,#pwa-install-element .install-dialog.chrome .dialog-body .about .name{padding:0 5px;overflow:hidden}#pwa-install-element .install-dialog.chrome .dialog-body .about .name{font-weight:500;font-size:18px;line-height:24px;margin-top:5px;align-items:flex-start;display:flex}#pwa-install-element .install-dialog.chrome .dialog-body .about .name label{text-overflow:ellipsis;word-break:break-all;white-space:nowrap;overflow:hidden}#pwa-install-element .install-dialog.chrome .dialog-body .about .hostname{font-size:13px;font-weight:400;opacity:.7;line-height:14px;overflow-x:hidden;text-overflow:ellipsis;text-align:left;word-break:break-all;white-space:nowrap}#pwa-install-element .install-dialog.chrome .dialog-body .about+hr{margin-top:10px}#pwa-install-element .install-dialog.chrome .dialog-body .description{font-weight:400;line-height:20px;grid-column:1/3;padding:0 6px;margin:10px 5px 5px;display:-webkit-box;-webkit-line-clamp:5;-webkit-box-orient:vertical;max-height:115px;overflow:hidden;overflow-y:auto;text-overflow:ellipsis;text-align:left}#pwa-install-element .install-dialog.chrome .dialog-body .app-description{font-size:13px;margin-bottom:10px}#pwa-install-element .install-dialog.chrome .dialog-body .app-description::-webkit-scrollbar{width:4px;height:4px}#pwa-install-element .install-dialog.chrome .dialog-body .app-description::-webkit-scrollbar-thumb{background:#929292;border-radius:4px}#pwa-install-element .install-dialog.chrome .dialog-body .app-description::-webkit-scrollbar-thumb:hover{background:#646464}#pwa-install-element .install-dialog.chrome .dialog-body .app-description::-webkit-scrollbar-track{background:var(--scrollbar-background-color);border-radius:4px}#pwa-install-element .install-dialog.chrome .dialog-body .install-description{font-size:14px}#pwa-install-element .install-dialog.chrome .dialog-body hr{height:1px;width:100%;grid-column:1/3;background-color:var(--border-bottom-color);border:none;margin:0}#pwa-install-element .install-dialog.chrome .dialog-body .action-buttons{display:grid;grid-template-columns:50% auto;grid-column-start:1;grid-column-end:3;gap:10px;padding:10px 10px}#pwa-install-element .install-dialog.chrome .dialog-body .action-buttons .primary{grid-column-start:2}#pwa-install-element .install-dialog.chrome .dialog-body pwa-gallery{grid-column:1/3;max-height:0;opacity:0;transition:opacity ease-in-out .5s,max-height .5s ease-in-out;overflow:hidden}#pwa-install-element .install-dialog.chrome.gallery pwa-gallery{transition:opacity .3s ease-in-out .2s,max-height .5s ease-in-out;max-height:70vh;opacity:1}#pwa-install-element .install-dialog.mobile{--touch-header-color:#DBDCE0;top:0;max-width:414px;width:100%;bottom:auto;left:0;right:0;transition:none;transform:translateY(100vh);border-radius:0;border-top-left-radius:15px;border-top-right-radius:15px;padding-bottom:35px}#pwa-install-element .install-dialog.mobile .dialog-body{grid-template-columns:1fr}#pwa-install-element .install-dialog.mobile .dialog-body .touch-header{height:30px;width:100%;padding-top:10px;box-sizing:border-box;cursor:grab}#pwa-install-element .install-dialog.mobile .dialog-body .touch-header:active{cursor:grabbing}#pwa-install-element .install-dialog.mobile .dialog-body .touch-header::before{content:"";width:40px;height:5px;border-radius:3px;background:var(--touch-header-color);margin:0 auto;display:block}#pwa-install-element .install-dialog.mobile .dialog-body .body-header{display:grid;grid-template-columns:max-content 1fr max-content;grid-gap:15px;padding:18px 20px;padding-top:0;border-bottom:1px solid var(--border-bottom-color)}#pwa-install-element .install-dialog.mobile .dialog-body .body-header .install{text-transform:capitalize;height:40px;padding:0 23px}#pwa-install-element .install-dialog.mobile .dialog-body .body-header .about{grid-template-rows:auto auto;grid-gap:6px}#pwa-install-element .install-dialog.mobile .dialog-body .body-header .about .name{padding:0;line-height:20px;font-size:16px}#pwa-install-element .install-dialog.mobile .dialog-body .body-header .about .hostname{font-size:14px;font-weight:400;opacity:.7;line-height:14px;overflow-x:hidden;text-overflow:ellipsis;word-break:break-all;white-space:nowrap;padding:0}#pwa-install-element .install-dialog.mobile .dialog-body .body-header .icon .icon-image{margin:0;width:45px;height:45px}#pwa-install-element .install-dialog.mobile .dialog-body .description{padding:15px 20px 0;margin:0;margin-bottom:15px;-webkit-line-clamp:6;max-height:150px}#pwa-install-element .install-dialog.mobile .dialog-body pwa-gallery{max-height:100%;padding-bottom:15px;opacity:1}#pwa-install-element .install-dialog.mobile .material-button{border-radius:20px}#pwa-install-element .install-dialog.mobile.available{--translateY:translateY(calc(100vh - 85px));opacity:1;top:0;visibility:visible;transform:var(--translateY)}#pwa-install-element .material-button{--text-color-primary:#fff;--text-color-secondary:#374fc6;--background-color-primary:#374fc6;--background-color-ripple:#fff;position:relative;display:inline-block;box-sizing:border-box;border:none;border-radius:6px;padding:0 16px;min-width:64px;height:36px;vertical-align:middle;text-align:center;text-overflow:ellipsis;text-transform:uppercase;box-shadow:0 3px 1px -2px rgba(0,0,0,.2),0 2px 2px 0 rgba(0,0,0,.14),0 1px 5px 0 rgba(0,0,0,.12);font-family:Roboto,"Segoe UI",BlinkMacSystemFont,system-ui,-apple-system;font-size:14px;font-weight:500;line-height:37px;overflow:hidden;outline:0;cursor:pointer;transition:box-shadow .2s}#pwa-install-element .material-button.primary{color:var(--text-color-primary);background-color:var(--background-color-primary)}#pwa-install-element .material-button.secondary{background-color:rgba(0,0,0,0);color:var(--text-color-secondary);box-shadow:none}#pwa-install-element .material-button.secondary::after,#pwa-install-element .material-button.secondary::before{background-color:var(--background-color-primary)}#pwa-install-element .material-button.secondary:active,#pwa-install-element .material-button.secondary:hover{box-shadow:none}#pwa-install-element .material-button.secondary.close{height:26px;min-width:26px;line-height:0;margin-right:0;margin-left:auto;padding:0;border-radius:50%}#pwa-install-element .material-button.secondary.close svg{width:16px;fill:var(--text-color-secondary)}#pwa-install-element .material-button.secondary.close::after{width:25px;height:25px;border-radius:50%}#pwa-install-element .material-button.secondary.close::before{border-radius:50%}#pwa-install-element .material-button::before{content:"";position:absolute;top:0;bottom:0;left:0;right:0;background-color:var(--background-color-ripple);opacity:0;transition:opacity .2s}#pwa-install-element .material-button::after{content:"";position:absolute;left:50%;top:50%;border-radius:50%;padding:50%;width:32px;height:32px;background-color:var(--background-color-ripple);opacity:0;transform:translate(-50%,-50%) scale(1);transition:opacity 1s,transform .5s}#pwa-install-element .material-button:hover{box-shadow:0 2px 4px -1px rgba(0,0,0,.2),0 4px 5px 0 rgba(0,0,0,.14),0 1px 10px 0 rgba(0,0,0,.12)}#pwa-install-element .material-button:hover::before{opacity:.08}#pwa-install-element .material-button:hover:focus::before{opacity:.3}#pwa-install-element .material-button:active{box-shadow:0 5px 5px -3px rgba(0,0,0,.2),0 8px 10px 1px rgba(0,0,0,.14),0 3px 14px 2px rgba(0,0,0,.12)}#pwa-install-element .material-button:active::after{opacity:.32;transform:translate(-50%,-50%) scale(0);transition:transform 0s}@media(prefers-color-scheme:dark){#pwa-install-element .install-dialog{--text-color-normal:#fff;--background-color:#1e1e1e;--border-bottom-color:#404140;--scrollbar-background-color:#424242}#pwa-install-element .install-dialog.mobile{--touch-header-color:#3f403f}#pwa-install-element .install-dialog .material-button{--text-color-primary:#1B222C;--text-color-secondary:#a7c7fa;--background-color-primary:#a7c7fa}}@media(max-width:767px)and (min-height:495px){#pwa-install-element .install-dialog.chrome.mobile{display:inline-block}#pwa-install-element .install-dialog.chrome{display:none}}@media(min-width:768px),(max-height:495px){#pwa-install-element .install-dialog.chrome.mobile{display:none}#pwa-install-element .install-dialog.chrome{display:inline-block}}@media(max-height:420px){#pwa-install-element .install-dialog.chrome .dialog-body .description{-webkit-line-clamp:3;max-height:70px}}@media(hover:none)and (pointer:coarse){#pwa-install-element .install-dialog.chrome .dialog-body .description::-webkit-scrollbar{display:none}}`,_a=h.css`#pwa-install-element .install-dialog.apple{--text-color-normal:#333;--text-color-description:#333;--background-color:rgba(255, 255, 255, 0.8);--text-color-button:#fff;--background-color-button:#fff;--background-color-button-active:#DBDAE0;--border-bottom-color:rgba(0, 0, 0, 0.1);--icon-how-to-color:#527AFB;font-family:system-ui,-apple-system,HelveticaNeue,BlinkMacSystemFont,Roboto,"Segoe UI";max-width:380px;width:auto;margin:0 auto;right:0;left:0;font-size:15px;color:var(--text-color-normal);bottom:0;transition:transform .4s cubic-bezier(.33,1,.66,1),opacity .5s cubic-bezier(1,0,1,-2),border .35s ease-in-out;overflow:hidden;pointer-events:none;opacity:0;visibility:visible;transform:translateY(100%);will-change:opacity,transform}#pwa-install-element .install-dialog.apple.dialog-body{display:grid;grid-template-columns:95px 1fr;grid-template-rows:1fr auto;grid-template-areas:"icon description" "welcome welcome" "how-to how-to" "gallery gallery" "button button";border-radius:10px;border-bottom:1px solid transparent;background-color:var(--background-color);filter:drop-shadow(0 5px 15px rgba(0, 0, 0, .5));backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}#pwa-install-element .install-dialog.apple.dialog-body .icon{display:flex;align-items:center;grid-area:icon;border-bottom:1px solid var(--border-bottom-color)}#pwa-install-element .install-dialog.apple.dialog-body .icon .icon-image{width:64px;height:64px;margin:0 auto;border-radius:6px}#pwa-install-element .install-dialog.apple.dialog-body .close{height:26px;min-width:26px;line-height:0;margin-right:7px;margin-top:7px;margin-left:auto;padding:0;border-radius:50%;opacity:.5;outline:0;color:var(--text-color-normal);border:none;background-color:rgba(0,0,0,0);cursor:pointer;transition:opacity .2s ease-in-out,background-color .2s ease-in-out;grid-area:description}#pwa-install-element .install-dialog.apple.dialog-body .close svg{fill:var(--text-color-normal);width:18px}#pwa-install-element .install-dialog.apple.dialog-body .close:active,#pwa-install-element .install-dialog.apple.dialog-body .close:hover{opacity:1;background-color:var(--background-color-button)}#pwa-install-element .install-dialog.apple.dialog-body .about{display:grid;grid-template-rows:35px 60px;border-bottom:1px solid var(--border-bottom-color);grid-area:description}#pwa-install-element .install-dialog.apple.dialog-body .about .description,#pwa-install-element .install-dialog.apple.dialog-body .about .name{padding-right:15px;overflow:hidden}#pwa-install-element .install-dialog.apple.dialog-body .about .name{font-weight:600;padding-top:10px;padding-right:10px;line-height:22px;align-items:flex-start;display:flex}#pwa-install-element .install-dialog.apple.dialog-body .about .description{font-size:12px;line-height:15px;margin-bottom:15px;overflow-y:auto;color:var(--text-color-description)}#pwa-install-element .install-dialog.apple.dialog-body .welcome-to-install{font-size:15px;grid-area:welcome;text-align:left;font-weight:400;padding:15px;width:auto;border-bottom:1px solid var(--border-bottom-color)}#pwa-install-element .install-dialog.apple .action-buttons{grid-area:button;grid-column-start:1;grid-column-end:3;padding:15px}#pwa-install-element .install-dialog.apple .dialog-button{display:grid;height:50px;width:100%;line-height:50px;border-radius:8px;color:var(--text-color-normal)}#pwa-install-element .install-dialog.apple .dialog-button.button{border:none;outline:0;font-family:system-ui,-apple-system,HelveticaNeue,BlinkMacSystemFont;cursor:pointer;-webkit-user-select:none;user-select:none;font-weight:400;font-size:17px;padding:0;margin:0;background-color:var(--background-color-button)}#pwa-install-element .install-dialog.apple .dialog-button.button.install{padding:0 15px;text-align:left}#pwa-install-element .install-dialog.apple .dialog-button.button.install .button-text{opacity:0;display:flex;align-items:center;justify-content:space-between;transition:opacity .4s ease-in-out .1s;overflow:hidden}#pwa-install-element .install-dialog.apple .dialog-button.button.install .button-text>span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#pwa-install-element .install-dialog.apple .dialog-button.button.install .button-text>svg{flex-shrink:0;width:20px}#pwa-install-element .install-dialog.apple .dialog-button.button.install .button-text.show{opacity:1;visibility:visible;width:auto;height:auto}#pwa-install-element .install-dialog.apple .dialog-button.button.install .button-text.hide{opacity:0;position:absolute;width:0;height:0;visibility:hidden}#pwa-install-element .install-dialog.apple .dialog-button.button.gallery{display:flex;align-items:center;min-width:50px;width:auto;margin-right:15px}#pwa-install-element .install-dialog.apple .dialog-button.button.gallery #pwa-gallery{margin:0 auto;width:23px;fill:var(--text-color-normal)}#pwa-install-element .install-dialog.apple .dialog-button.button:active{background-color:var(--background-color-button-active)}#pwa-install-element .install-dialog.apple .how-to-body{opacity:0;max-height:0;overflow:hidden;transition:opacity ease-in-out .5s,max-height .5s ease-in-out;grid-area:how-to}#pwa-install-element .install-dialog.apple .how-to-body .how-to-description{display:grid;-webkit-user-select:none;user-select:none;grid-auto-columns:1fr;grid-template-rows:1fr 1fr 1fr;gap:10px;padding:15px;padding-bottom:0}#pwa-install-element .install-dialog.apple .how-to-body .how-to-description .description-step{display:inline-flex;flex-direction:row;gap:15px;align-items:center;font-size:14px}#pwa-install-element .install-dialog.apple .how-to-body .how-to-description .description-step .svg-wrap{position:relative;display:inline-flex;flex-shrink:0;color:var(--icon-how-to-color);width:50px;height:50px;align-items:center;border-radius:6px}#pwa-install-element .install-dialog.apple .how-to-body .how-to-description .description-step .svg-wrap #pwa-add,#pwa-install-element .install-dialog.apple .how-to-body .how-to-description .description-step .svg-wrap #pwa-safari,#pwa-install-element .install-dialog.apple .how-to-body .how-to-description .description-step .svg-wrap #pwa-share{margin:0 auto}#pwa-install-element .install-dialog.apple .how-to-body .how-to-description .description-step .svg-wrap #pwa-share{margin-bottom:4px;transform:scale(.9)}#pwa-install-element .install-dialog.apple .how-to-body .how-to-description .description-step .svg-wrap #pwa-add{transform:scale(.8);fill:var(--text-color-normal)}#pwa-install-element .install-dialog.apple .how-to-body .how-to-description .description-step .svg-wrap #pwa-safari{transform:scale(.92)}#pwa-install-element .install-dialog.apple .how-to-body .how-to-description .description-step .svg-wrap .step-count{position:absolute;line-height:12px;top:3px;left:4px}#pwa-install-element .install-dialog.apple .how-to-body .how-to-description .description-step .step-text{font-weight:600;text-align:left}#pwa-install-element .install-dialog.apple pwa-gallery{grid-column:1/3;max-height:0;opacity:0;transition:opacity ease-in-out .5s,max-height .5s ease-in-out;overflow:hidden}#pwa-install-element .install-dialog.apple pwa-gallery+.action-buttons{display:flex}#pwa-install-element .install-dialog.apple.available{opacity:1;pointer-events:unset;transform:translateY(0);transition:transform .5s cubic-bezier(.33,1,.66,1),border .35s ease-in-out}#pwa-install-element .install-dialog.apple.gallery pwa-gallery{transition:opacity .3s ease-in-out .2s,max-height .5s ease-in-out;max-height:70vh;opacity:1}#pwa-install-element .install-dialog.apple.how-to .dialog-body{border-bottom:1px solid #e0e0e0}#pwa-install-element .install-dialog.apple.how-to .how-to-body{opacity:1;max-height:400px;overflow-y:auto;transition:opacity .3s ease-in-out .2s,max-height .5s ease-in-out}#pwa-install-element .install-dialog.apple.desktop{--text-color-normal:rgba(0, 0, 0, 0.85);--text-color-description:rgba(0, 0, 0, 0.85);--icon-how-to-color:rgba(0, 0, 0, 0.50);--background-color:rgb(246 246 246 / 85%);--background-color-button:#c6c1c6;--background-color-button-active:linear-gradient(0deg, rgba(64,121,250,1) 0%, rgba(84,144,251,1) 100%);--border-bottom-color:rgb(185 185 185);grid-template-columns:1fr;grid-template-rows:1fr auto;grid-template-areas:"icon" "description" "welcome" "how-to" "gallery" "button";gap:0;column-gap:0;padding:16px;max-width:260px;background:var(--background-color);border:1px solid var(--border-bottom-color)}#pwa-install-element .install-dialog.apple.desktop .icon{height:64px;padding-bottom:16px}#pwa-install-element .install-dialog.apple.desktop .icon .icon-image{border-radius:10px;width:52px;height:52px;filter:drop-shadow(0 1px 1px rgba(0, 0, 0, .15))}#pwa-install-element .install-dialog.apple.desktop .close{grid-area:icon;background:var(--background-color-button);opacity:1;height:20px;min-width:20px;margin-right:-5px;margin-top:-5px}#pwa-install-element .install-dialog.apple.desktop .close svg{width:14px}#pwa-install-element .install-dialog.apple.desktop .about{display:flex;flex-direction:column;align-items:center}#pwa-install-element .install-dialog.apple.desktop .about .name{font-size:13px;line-height:16px;font-weight:700;padding:0}#pwa-install-element .install-dialog.apple.desktop .about .description{padding:16px 0;margin:0;padding-top:10px;border-bottom:1px solid var(--border-bottom-color);min-width:100%}#pwa-install-element .install-dialog.apple.desktop .about .description,#pwa-install-element .install-dialog.apple.desktop .welcome-to-install{text-align:center;font-size:11px;line-height:14px}#pwa-install-element .install-dialog.apple.desktop .about,#pwa-install-element .install-dialog.apple.desktop .icon,#pwa-install-element .install-dialog.apple.desktop .welcome-to-install{border:none}#pwa-install-element .install-dialog.apple.desktop .welcome-to-install{padding:0;padding-top:16px}#pwa-install-element .install-dialog.apple.desktop .action-buttons{padding:0;padding-top:16px}#pwa-install-element .install-dialog.apple.desktop .action-buttons .dialog-button.button{font-size:13px;font-weight:400;padding:6px 8px;border-radius:6px;height:auto;line-height:18px}#pwa-install-element .install-dialog.apple.desktop .action-buttons .dialog-button.button.install{color:#fff;background:var(--background-color-button-active);transition:background .3s ease-in-out .1s,color .3s ease-in-out}#pwa-install-element .install-dialog.apple.desktop .action-buttons .dialog-button.button.install svg{transform:none;width:18px}#pwa-install-element .install-dialog.apple.desktop .action-buttons .dialog-button.button.gallery{width:30px;min-width:30px;margin-right:10px;background:var(--background-color-button)}#pwa-install-element .install-dialog.apple.desktop .action-buttons .dialog-button.button.gallery #pwa-gallery{width:14px;transition:transform .4s ease-in-out}#pwa-install-element .install-dialog.apple.desktop .close:active,#pwa-install-element .install-dialog.apple.desktop .dialog-button.button:active{filter:brightness(105%)}#pwa-install-element .install-dialog.apple.desktop .close:active .button-text,#pwa-install-element .install-dialog.apple.desktop .dialog-button.button:active .button-text{filter:brightness(90%)}#pwa-install-element .install-dialog.apple.desktop .how-to-body .how-to-description{padding:0;padding-top:16px;grid-template-rows:1fr 1fr}#pwa-install-element .install-dialog.apple.desktop .how-to-body .how-to-description .description-step{font-size:12px;gap:16px}#pwa-install-element .install-dialog.apple.desktop .how-to-body .how-to-description .description-step .svg-wrap{width:32px;height:32px;color:var(--icon-how-to-color)}#pwa-install-element .install-dialog.apple.desktop .how-to-body .how-to-description .description-step .svg-wrap #pwa-share{width:16px;margin-bottom:2px;transform:none}#pwa-install-element .install-dialog.apple.desktop .how-to-body .how-to-description .description-step .svg-wrap #pwa-add{width:18px;transform:none}#pwa-install-element .install-dialog.apple.desktop.gallery #pwa-gallery{transform:rotate(180deg)}#pwa-install-element .install-dialog.apple.desktop.how-to .action-buttons .dialog-button.button.install{color:var(--text-color-normal);background:var(--background-color-button)}@media(min-width:667px){#pwa-install-element .install-dialog.apple{top:0;bottom:unset;transform:translateY(calc(-100% - 40px));right:28px;left:auto}#pwa-install-element .install-dialog.apple.available{top:28px;bottom:auto;max-height:calc(95vh - 28px)}}@media(min-width:667px)and (max-width:1366px){#pwa-install-element .install-dialog.apple{right:max(28px,env(safe-area-inset-right,28px));left:auto}}@media(max-width:666px){#pwa-install-element .install-dialog.apple .description-step .step-text{font-size:13px}#pwa-install-element .install-dialog.apple.available{bottom:20px;max-height:calc(85vh - 20px)}#pwa-install-element .install-dialog.apple.dialog-body{filter:drop-shadow(rgba(0, 0, 0, .5) 0 0 15px)}}@media(max-width:428px){#pwa-install-element .install-dialog.apple.dialog-body{max-width:100vw;filter:drop-shadow(rgba(0, 0, 0, .5) 0 -5px 10px);border-bottom-left-radius:0;border-bottom-right-radius:0}#pwa-install-element .install-dialog.apple.dialog-body .action-buttons{padding-bottom:max(15px,env(safe-area-inset-bottom))}#pwa-install-element .install-dialog.apple.dialog-body.available{bottom:0;max-height:85vh}}@media(max-height:548px){#pwa-install-element .install-dialog.apple.dialog-body.available{overflow-y:auto;max-height:calc(90vh - 28px - env(safe-area-inset-bottom,0px))}}@media(max-height:600px){#pwa-install-element .install-dialog.apple pwa-gallery{overflow-y:auto}}@media(prefers-color-scheme:dark){#pwa-install-element .install-dialog.apple.dialog-body{--text-color-normal:#fff;--text-color-description:#9E9AA1;--background-color:rgb(25 25 25 / 90%);--background-color-button:#353535;--background-color-button-active:#454545;--border-bottom-color:#353535}#pwa-install-element .install-dialog.apple.dialog-body .close:active,#pwa-install-element .install-dialog.apple.dialog-body .dialog-button.button:active{filter:brightness(105%)}#pwa-install-element .install-dialog.apple.dialog-body .close:active .button-text,#pwa-install-element .install-dialog.apple.dialog-body .dialog-button.button:active .button-text{filter:brightness(90%)}#pwa-install-element .install-dialog.apple.dialog-body.desktop{--text-color-description:var(--text-color-normal);--icon-how-to-color:#bcb8b6;--background-color:rgb(45 45 45 / 90%);--border-bottom-color:#5b5b5b;--background-color-button:#6d6765;--background-color-button-active:linear-gradient(0deg, rgba(59,108,200,1) 0%, rgba(66,123,250,1) 100%);outline:1px solid #1c1c1c;color-scheme:dark}}`,ze=(a=>{var e={};return c.d(e,a),e})({classMap:()=>Ot}),Aa=(a,e,t,i,o,s,l,n,r,g,p,d,m)=>{const x=()=>({available:r,gallery:m}),$=!o&&n.screenshots&&n.screenshots.length;return h.html`
icon
${s?"":h.html``}
${location.hostname}
${e?h.html`
${e}
`:""} ${i?"":h.html`
${t||`${k("This site has app functionality.")} ${k("Install it on your device for extensive experience and easy access.")}`}
`} ${$?h.html``:""}
${$?h.html``:""}
${$?h.html``:""}
`},Ea=(a,e,t,i,o,s,l,n,r,g,p,d,m,x,$)=>{const Me=!o&&n.screenshots&&n.screenshots.length;return h.html``};var w=function(a,e,t,i){var o,s=arguments.length,l=s<3?e:i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(a,e,t,i);else for(var n=a.length-1;n>=0;n--)(o=a[n])&&(l=(s<3?o(l):s>3?o(e,t,l):o(e,t))||l);return s>3&&l&&Object.defineProperty(e,t,l),l},y=function(a,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(a,e)};let f=class extends h.LitElement{constructor(){super(...arguments),this.manifestUrl="/manifest.json",this.icon="",this.name="",this.description="",this.installDescription="",this.disableDescription=!1,this.disableScreenshots=!1,this.disableScreenshotsApple=!1,this.disableScreenshotsChrome=!1,this.manualApple=!1,this.manualChrome=!1,this.disableChrome=!1,this.disableClose=!1,this.externalPromptEvent=null,this.platforms=[],this.userChoiceResult="",this.isDialogHidden=JSON.parse(window.sessionStorage.getItem("pwa-hide-install")||"false"),this.isInstallAvailable=!1,this.isAppleMobilePlatform=!1,this.isAppleDesktopPlatform=!1,this.isUnderStandaloneMode=!1,this.isRelatedAppsInstalled=!1,this._manifest=new fa,this._howToRequested=!1,this._galleryRequested=!1,this._install={handleEvent:()=>{window.defferedPromptEvent&&(this.hideDialog(),window.defferedPromptEvent.prompt(),window.defferedPromptEvent.userChoice.then(a=>{this.userChoiceResult=a.outcome,v.eventUserChoiceResult(this,this.userChoiceResult)}).catch(a=>{v.eventInstalledFail(this)}),window.defferedPromptEvent=null)},passive:!0},this.install=()=>{this.isAppleMobilePlatform||this.isAppleDesktopPlatform?(this._howToRequested=!0,this.requestUpdate()):this._install.handleEvent()},this._hideDialog={handleEvent:()=>{this.isDialogHidden=!0,window.sessionStorage.setItem("pwa-hide-install","true"),this.requestUpdate()},passive:!0},this._hideDialogUser=()=>{v.eventUserChoiceResult(this,"dismissed"),this.userChoiceResult="dismissed",this.hideDialog()},this.hideDialog=()=>{this._hideDialog.handleEvent()},this.showDialog=(a=!1)=>{this.isDialogHidden=!1,a&&(this.isInstallAvailable=!0),window.sessionStorage.setItem("pwa-hide-install","false"),this.requestUpdate()},this.getInstalledRelatedApps=async()=>await v.getInstalledRelatedApps(),this._howToForApple={handleEvent:()=>{this._howToRequested=!this._howToRequested,this._howToRequested&&this._galleryRequested&&(this._galleryRequested=!1),this.requestUpdate(),this._howToRequested&&v.eventInstallHowTo(this)},passive:!0},this._toggleGallery={handleEvent:()=>{this._galleryRequested=!this._galleryRequested,this._howToRequested&&this._galleryRequested&&(this._howToRequested=!1),this._galleryRequested&&v.eventGallery(this),this.requestUpdate()},passive:!0},this._init=async()=>{var a,e;if(window.defferedPromptEvent=null,this._checkInstalled(),!this.disableChrome){const t=i=>{window.defferedPromptEvent=i,i.preventDefault(),this.platforms=i.platforms,this.isRelatedAppsInstalled||this.isUnderStandaloneMode?this.isInstallAvailable=!1:(this.isInstallAvailable=!0,v.eventInstallAvailable(this)),this.userChoiceResult==="accepted"&&(this.isDialogHidden=!0,v.eventInstalledSuccess(this)),this.requestUpdate()};this.externalPromptEvent!=null?setTimeout(()=>t(this.externalPromptEvent),300):window.addEventListener("beforeinstallprompt",t)}window.addEventListener("appinstalled",t=>{window.defferedPromptEvent=null,this.isInstallAvailable=!1,this.requestUpdate(),v.eventInstalledSuccess(this)});try{const t=await fetch(this.manifestUrl),i=await t.json();if(!t.ok||!i||!Object.keys(i))throw Error("Manifest not found");v.normalizeManifestAssetUrls(i,this.manifestUrl),this.icon=this.icon||(a=i.icons)!=null&&a.length?i.icons[0].src:"",this.name=this.name||i.short_name||i.name||"",this.description=this.description||i.description||"",this._manifest=i}catch{this.icon=this.icon||((e=this._manifest.icons)==null?void 0:e[0].src)||"",this.name=this.name||this._manifest.short_name||"",this.description=this.description||this._manifest.description||""}},this._requestUpdate=()=>{this.requestUpdate()}}static get styles(){return[$a,_a]}async _checkInstalled(){this.isUnderStandaloneMode=v.isStandalone(),this.isRelatedAppsInstalled=await v.isRelatedAppsInstalled(),this.isAppleMobilePlatform=v.isAppleMobile(),this.isAppleDesktopPlatform=v.isAppleDesktop(),this.isAppleMobilePlatform||this.isAppleDesktopPlatform?this.isUnderStandaloneMode||(this.manualApple&&this.hideDialog(),setTimeout(()=>{this.isInstallAvailable=!0,this.requestUpdate(),v.eventInstallAvailable(this)},1e3)):this.manualChrome&&this.hideDialog()}connectedCallback(){(a=>{a.slice(0,2)==="nb"&&(a="no");try{pt.get(a)?Ge(a):Ge(a.slice(0,2))}catch{}})(navigator.language),this._init(),ya.finalized,ka.finalized,super.connectedCallback()}willUpdate(a){this.externalPromptEvent&&a.has("externalPromptEvent")&&typeof this.externalPromptEvent=="object"&&this._init()}render(){return this.isAppleMobilePlatform||this.isAppleDesktopPlatform?h.html`${Ea(this.name,this.description,this.installDescription,this.disableDescription,this.disableScreenshots||this.disableScreenshotsApple,this.disableClose,this.icon,this._manifest,this.isInstallAvailable&&!this.isDialogHidden,this._hideDialogUser,this._howToForApple,this.isAppleDesktopPlatform,this._howToRequested,this._toggleGallery,this._galleryRequested)}`:h.html`${Aa(this.name,this.description,this.installDescription,this.disableDescription,this.disableScreenshots||this.disableScreenshotsChrome,this.disableClose,this.icon,this._manifest,this.isInstallAvailable&&!this.isDialogHidden,this._hideDialogUser,this._install,this._toggleGallery,this._galleryRequested)}`}};w([(0,b.property)({attribute:"manifest-url"}),y("design:type",Object)],f.prototype,"manifestUrl",void 0),w([(0,b.property)(),y("design:type",Object)],f.prototype,"icon",void 0),w([(0,b.property)(),y("design:type",Object)],f.prototype,"name",void 0),w([(0,b.property)(),y("design:type",Object)],f.prototype,"description",void 0),w([(0,b.property)({attribute:"install-description"}),y("design:type",Object)],f.prototype,"installDescription",void 0),w([(0,b.property)({attribute:"disable-install-description",type:Boolean}),y("design:type",Object)],f.prototype,"disableDescription",void 0),w([(0,b.property)({attribute:"disable-screenshots",type:Boolean}),y("design:type",Object)],f.prototype,"disableScreenshots",void 0),w([(0,b.property)({attribute:"disable-screenshots-apple",type:Boolean}),y("design:type",Object)],f.prototype,"disableScreenshotsApple",void 0),w([(0,b.property)({attribute:"disable-screenshots-chrome",type:Boolean}),y("design:type",Object)],f.prototype,"disableScreenshotsChrome",void 0),w([(0,b.property)({attribute:"manual-apple",type:Boolean}),y("design:type",Object)],f.prototype,"manualApple",void 0),w([(0,b.property)({attribute:"manual-chrome",type:Boolean}),y("design:type",Object)],f.prototype,"manualChrome",void 0),w([(0,b.property)({attribute:"disable-chrome",type:Boolean}),y("design:type",Object)],f.prototype,"disableChrome",void 0),w([(0,b.property)({attribute:"disable-close",type:Boolean}),y("design:type",Object)],f.prototype,"disableClose",void 0),w([(0,b.state)(),y("design:type",Object)],f.prototype,"externalPromptEvent",void 0),f=w([(a,e)=>(a.addInitializer(Nt),a),(0,b.customElement)("pwa-install")],f);var Ua=st.w;export{Ua as PWAInstallElement}; diff --git a/assets/chunks/theme.B08u4faT.js b/assets/chunks/theme.B08u4faT.js new file mode 100644 index 0000000000..4dacc6eab6 --- /dev/null +++ b/assets/chunks/theme.B08u4faT.js @@ -0,0 +1,20 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/chunks/index.MWfHGcqb.js","assets/chunks/framework.CHSXtLMd.js"])))=>i.map(i=>d[i]); +import{d as R,o as _,c as A,r as C,a as Ve,t as Z,n as ue,b as K,w as M,e as j,T as _n,_ as q,u as hr,i as io,f as lo,g as vn,h as U,j as w,k as v,l as pt,m as Bn,p as X,q as pe,s as it,v as Ye,x as gn,y as mr,z as co,A as uo,B as lt,F as he,C as Ce,D as bn,E as yn,G as x,H as Ws,I as We,J as Yt,K as at,L as Nt,M as fo,N as js,O as ho,P as Ue,Q as xs,R as wn,S as Ks,U as Bt,V as pr,W as kn,X as mo,Y as Gs,Z as Ys,$ as po,a0 as Ct,a1 as zs,a2 as Xs,a3 as _o,a4 as vo,a5 as go,a6 as qs,a7 as bo,a8 as yo,a9 as wo,aa as ko,ab as Lo,ac as So,ad as Wt,ae as Eo,af as Oo,ag as cn}from"./framework.CHSXtLMd.js";const Co=R({__name:"VPBadge",props:{text:{},type:{default:"tip"}},setup(t){return(e,n)=>(_(),A("span",{class:ue(["VPBadge",e.type])},[C(e.$slots,"default",{},()=>[Ve(Z(e.text),1)])],2))}}),Ao={key:0,class:"VPBackdrop"},Io=R({__name:"VPBackdrop",props:{show:{type:Boolean}},setup(t){return(e,n)=>(_(),K(_n,{name:"fade"},{default:M(()=>[e.show?(_(),A("div",Ao)):j("",!0)]),_:1}))}}),Mo=q(Io,[["__scopeId","data-v-83bbca5b"]]),se=hr;function No(t,e){let n,r=!1;return()=>{n&&clearTimeout(n),r?n=setTimeout(t,e):(t(),(r=!0)&&setTimeout(()=>r=!1,e))}}function Wn(t){return/^\//.test(t)?t:`/${t}`}function _r(t){const{pathname:e,search:n,hash:r,protocol:s}=new URL(t,"http://a.com");if(io(t)||t.startsWith("#")||!s.startsWith("http")||!lo(e))return t;const{site:a}=se(),o=e.endsWith("/")||e.endsWith(".html")?t:t.replace(/(?:(^\.+)\/)?.*$/,`$1${e.replace(/(\.md)?$/,a.value.cleanUrls?"":".html")}${n}${r}`);return vn(o)}function zt({correspondingLink:t=!1}={}){const{site:e,localeIndex:n,page:r,theme:s,hash:a}=se(),o=U(()=>{var l,c;return{label:(l=e.value.locales[n.value])==null?void 0:l.label,link:((c=e.value.locales[n.value])==null?void 0:c.link)||(n.value==="root"?"/":`/${n.value}/`)}});return{localeLinks:U(()=>Object.entries(e.value.locales).flatMap(([l,c])=>o.value.label===c.label?[]:{text:c.label,link:$o(c.link||(l==="root"?"/":`/${l}/`),s.value.i18nRouting!==!1&&t,r.value.relativePath.slice(o.value.link.length-1),!e.value.cleanUrls)+a.value})),currentLang:o}}function $o(t,e,n,r){return e?t.replace(/\/$/,"")+Wn(n.replace(/(^|\/)index\.md$/,"$1").replace(/\.md$/,r?".html":"")):t}const Po={class:"NotFound"},To={class:"code"},Fo={class:"title"},Ro={class:"quote"},Vo={class:"action"},Do=["href","aria-label"],Ho=R({__name:"NotFound",setup(t){const{theme:e}=se(),{currentLang:n}=zt();return(r,s)=>{var a,o,i,l,c;return _(),A("div",Po,[w("p",To,Z(((a=v(e).notFound)==null?void 0:a.code)??"404"),1),w("h1",Fo,Z(((o=v(e).notFound)==null?void 0:o.title)??"PAGE NOT FOUND"),1),s[0]||(s[0]=w("div",{class:"divider"},null,-1)),w("blockquote",Ro,Z(((i=v(e).notFound)==null?void 0:i.quote)??"But if you don't change your direction, and if you keep looking, you may end up where you are heading."),1),w("div",Vo,[w("a",{class:"link",href:v(vn)(v(n).link),"aria-label":((l=v(e).notFound)==null?void 0:l.linkLabel)??"go to home"},Z(((c=v(e).notFound)==null?void 0:c.linkText)??"Take me home"),9,Do)])])}}}),Uo=q(Ho,[["__scopeId","data-v-938cfa09"]]);function Js(t,e){if(Array.isArray(t))return sn(t);if(t==null)return[];e=Wn(e);const n=Object.keys(t).sort((s,a)=>a.split("/").length-s.split("/").length).find(s=>e.startsWith(Wn(s))),r=n?t[n]:[];return Array.isArray(r)?sn(r):sn(r.items,r.base)}function Bo(t){const e=[];let n=0;for(const r in t){const s=t[r];if(s.items){n=e.push(s);continue}e[n]||e.push({items:[]}),e[n].items.push(s)}return e}function Wo(t){const e=[];function n(r){for(const s of r)s.text&&s.link&&e.push({text:s.text,link:s.link,docFooterText:s.docFooterText}),s.items&&n(s.items)}return n(t),e}function jn(t,e){return Array.isArray(e)?e.some(n=>jn(t,n)):pt(t,e.link)?!0:e.items?jn(t,e.items):!1}function sn(t,e){return[...t].map(n=>{const r={...n},s=r.base||e;return s&&r.link&&(r.link=s+r.link),r.items&&(r.items=sn(r.items,s)),r})}function et(){const{frontmatter:t,page:e,theme:n}=se(),r=Bn("(min-width: 960px)"),s=X(!1),a=U(()=>{const g=n.value.sidebar,b=e.value.relativePath;return g?Js(g,b):[]}),o=X(a.value);pe(a,(g,b)=>{JSON.stringify(g)!==JSON.stringify(b)&&(o.value=a.value)});const i=U(()=>t.value.sidebar!==!1&&o.value.length>0&&t.value.layout!=="home"),l=U(()=>c?t.value.aside==null?n.value.aside==="left":t.value.aside==="left":!1),c=U(()=>t.value.layout==="home"?!1:t.value.aside!=null?!!t.value.aside:n.value.aside!==!1),u=U(()=>i.value&&r.value),d=U(()=>i.value?Bo(o.value):[]);function f(){s.value=!0}function y(){s.value=!1}function S(){s.value?y():f()}return{isOpen:s,sidebar:o,sidebarGroups:d,hasSidebar:i,hasAside:c,leftAside:l,isSidebarEnabled:u,open:f,close:y,toggle:S}}function jo(t,e){let n;it(()=>{n=t.value?document.activeElement:void 0}),Ye(()=>{window.addEventListener("keyup",r)}),gn(()=>{window.removeEventListener("keyup",r)});function r(s){s.key==="Escape"&&t.value&&(e(),n==null||n.focus())}}function xo(t){const{page:e,hash:n}=se(),r=X(!1),s=U(()=>t.value.collapsed!=null),a=U(()=>!!t.value.link),o=X(!1),i=()=>{o.value=pt(e.value.relativePath,t.value.link)};pe([e,t,n],i),Ye(i);const l=U(()=>o.value?!0:t.value.items?jn(e.value.relativePath,t.value.items):!1),c=U(()=>!!(t.value.items&&t.value.items.length));it(()=>{r.value=!!(s.value&&t.value.collapsed)}),mr(()=>{(o.value||l.value)&&(r.value=!1)});function u(){s.value&&(r.value=!r.value)}return{collapsed:r,collapsible:s,isLink:a,isActiveLink:o,hasActiveLink:l,hasChildren:c,toggle:u}}function Ko(){const{hasSidebar:t}=et(),e=Bn("(min-width: 960px)"),n=Bn("(min-width: 1280px)");return{isAsideEnabled:U(()=>!n.value&&!e.value?!1:t.value?n.value:e.value)}}const xn=[];function Qs(t){return typeof t.outline=="object"&&!Array.isArray(t.outline)&&t.outline.label||t.outlineTitle||"On this page"}function vr(t){const e=[...document.querySelectorAll(".VPDoc :where(h1,h2,h3,h4,h5,h6)")].filter(n=>n.id&&n.hasChildNodes()).map(n=>{const r=Number(n.tagName[1]);return{element:n,title:Go(n),link:"#"+n.id,level:r}});return Yo(e,t)}function Go(t){let e="";for(const n of t.childNodes)if(n.nodeType===1){if(n.classList.contains("VPBadge")||n.classList.contains("header-anchor")||n.classList.contains("ignore-header"))continue;e+=n.textContent}else n.nodeType===3&&(e+=n.textContent);return e.trim()}function Yo(t,e){if(e===!1)return[];const n=(typeof e=="object"&&!Array.isArray(e)?e.level:e)||2,[r,s]=typeof n=="number"?[n,n]:n==="deep"?[2,6]:n;return qo(t,r,s)}function zo(t,e){const{isAsideEnabled:n}=Ko(),r=No(a,100);let s=null;Ye(()=>{requestAnimationFrame(a),window.addEventListener("scroll",r)}),co(()=>{o(location.hash)}),gn(()=>{window.removeEventListener("scroll",r)});function a(){if(!n.value)return;const i=window.scrollY,l=window.innerHeight,c=document.body.offsetHeight,u=Math.abs(i+l-c)<1,d=xn.map(({element:y,link:S})=>({link:S,top:Xo(y)})).filter(({top:y})=>!Number.isNaN(y)).sort((y,S)=>y.top-S.top);if(!d.length){o(null);return}if(i<1){o(null);return}if(u){o(d[d.length-1].link);return}let f=null;for(const{link:y,top:S}of d){if(S>i+uo()+4)break;f=y}o(f)}function o(i){s&&s.classList.remove("active"),i==null?s=null:s=t.value.querySelector(`a[href="${decodeURIComponent(i)}"]`);const l=s;l?(l.classList.add("active"),e.value.style.top=l.offsetTop+39+"px",e.value.style.opacity="1"):(e.value.style.top="33px",e.value.style.opacity="0")}}function Xo(t){let e=0;for(;t!==document.body;){if(t===null)return NaN;e+=t.offsetTop,t=t.offsetParent}return e}function qo(t,e,n){xn.length=0;const r=[],s=[];return t.forEach(a=>{const o={...a,children:[]};let i=s[s.length-1];for(;i&&i.level>=o.level;)s.pop(),i=s[s.length-1];if(o.element.classList.contains("ignore-header")||i&&"shouldIgnore"in i){s.push({level:o.level,shouldIgnore:!0});return}o.level>n||o.level{const s=lt("VPDocOutlineItem",!0);return _(),A("ul",{class:ue(["VPDocOutlineItem",n.root?"root":"nested"])},[(_(!0),A(he,null,Ce(n.headers,({children:a,link:o,title:i})=>(_(),A("li",null,[w("a",{class:"outline-link",href:o,onClick:e,title:i},Z(i),9,Jo),a!=null&&a.length?(_(),K(s,{key:0,headers:a},null,8,["headers"])):j("",!0)]))),256))],2)}}}),Zs=q(Qo,[["__scopeId","data-v-11918db9"]]),Zo={class:"content"},ei={"aria-level":"2",class:"outline-title",id:"doc-outline-aria-label",role:"heading"},ti=R({__name:"VPDocAsideOutline",setup(t){const{frontmatter:e,theme:n}=se(),r=bn([]);yn(()=>{r.value=vr(e.value.outline??n.value.outline)});const s=X(),a=X();return zo(s,a),(o,i)=>(_(),A("nav",{"aria-labelledby":"doc-outline-aria-label",class:ue(["VPDocAsideOutline",{"has-outline":r.value.length>0}]),ref_key:"container",ref:s},[w("div",Zo,[w("div",{class:"outline-marker",ref_key:"marker",ref:a},null,512),w("div",ei,Z(v(Qs)(v(n))),1),x(Zs,{headers:r.value,root:!0},null,8,["headers"])])],2))}}),ni=q(ti,[["__scopeId","data-v-a6bb1831"]]),ri={class:"VPDocAsideCarbonAds"},si=R({__name:"VPDocAsideCarbonAds",props:{carbonAds:{}},setup(t){const e=()=>null;return(n,r)=>(_(),A("div",ri,[x(v(e),{"carbon-ads":n.carbonAds},null,8,["carbon-ads"])]))}}),ai={class:"VPDocAside"},oi=R({__name:"VPDocAside",setup(t){const{theme:e}=se();return(n,r)=>(_(),A("div",ai,[C(n.$slots,"aside-top",{},void 0,!0),C(n.$slots,"aside-outline-before",{},void 0,!0),x(ni),C(n.$slots,"aside-outline-after",{},void 0,!0),r[0]||(r[0]=w("div",{class:"spacer"},null,-1)),C(n.$slots,"aside-ads-before",{},void 0,!0),v(e).carbonAds?(_(),K(si,{key:0,"carbon-ads":v(e).carbonAds},null,8,["carbon-ads"])):j("",!0),C(n.$slots,"aside-ads-after",{},void 0,!0),C(n.$slots,"aside-bottom",{},void 0,!0)]))}}),ii=q(oi,[["__scopeId","data-v-4df27cae"]]);function li(){const{theme:t,page:e}=se();return U(()=>{const{text:n="Edit this page",pattern:r=""}=t.value.editLink||{};let s;return typeof r=="function"?s=r(e.value):s=r.replace(/:path/g,e.value.filePath),{url:s,text:n}})}function ci(){const{page:t,theme:e,frontmatter:n}=se();return U(()=>{var c,u,d,f,y,S,g,b;const r=Js(e.value.sidebar,t.value.relativePath),s=Wo(r),a=ui(s,p=>p.link.replace(/[?#].*$/,"")),o=a.findIndex(p=>pt(t.value.relativePath,p.link)),i=((c=e.value.docFooter)==null?void 0:c.prev)===!1&&!n.value.prev||n.value.prev===!1,l=((u=e.value.docFooter)==null?void 0:u.next)===!1&&!n.value.next||n.value.next===!1;return{prev:i?void 0:{text:(typeof n.value.prev=="string"?n.value.prev:typeof n.value.prev=="object"?n.value.prev.text:void 0)??((d=a[o-1])==null?void 0:d.docFooterText)??((f=a[o-1])==null?void 0:f.text),link:(typeof n.value.prev=="object"?n.value.prev.link:void 0)??((y=a[o-1])==null?void 0:y.link)},next:l?void 0:{text:(typeof n.value.next=="string"?n.value.next:typeof n.value.next=="object"?n.value.next.text:void 0)??((S=a[o+1])==null?void 0:S.docFooterText)??((g=a[o+1])==null?void 0:g.text),link:(typeof n.value.next=="object"?n.value.next.link:void 0)??((b=a[o+1])==null?void 0:b.link)}}})}function ui(t,e){const n=new Set;return t.filter(r=>{const s=e(r);return n.has(s)?!1:n.add(s)})}const je=R({__name:"VPLink",props:{tag:{},href:{},noIcon:{type:Boolean},target:{},rel:{}},setup(t){const e=t,n=U(()=>e.tag??(e.href?"a":"span")),r=U(()=>e.href&&Ws.test(e.href)||e.target==="_blank");return(s,a)=>(_(),K(We(n.value),{class:ue(["VPLink",{link:s.href,"vp-external-link-icon":r.value,"no-icon":s.noIcon}]),href:s.href?v(_r)(s.href):void 0,target:s.target??(r.value?"_blank":void 0),rel:s.rel??(r.value?"noreferrer":void 0)},{default:M(()=>[C(s.$slots,"default")]),_:3},8,["class","href","target","rel"]))}}),di={class:"VPLastUpdated"},fi=["datetime"],hi=R({__name:"VPDocFooterLastUpdated",setup(t){const{theme:e,page:n,lang:r}=se(),s=U(()=>new Date(n.value.lastUpdated)),a=U(()=>s.value.toISOString()),o=X("");return Ye(()=>{it(()=>{var i,l,c;o.value=new Intl.DateTimeFormat((l=(i=e.value.lastUpdated)==null?void 0:i.formatOptions)!=null&&l.forceLocale?r.value:void 0,((c=e.value.lastUpdated)==null?void 0:c.formatOptions)??{dateStyle:"short",timeStyle:"short"}).format(s.value)})}),(i,l)=>{var c;return _(),A("p",di,[Ve(Z(((c=v(e).lastUpdated)==null?void 0:c.text)||v(e).lastUpdatedText||"Last updated")+": ",1),w("time",{datetime:a.value},Z(o.value),9,fi)])}}}),mi=q(hi,[["__scopeId","data-v-b6f16cf9"]]),pi={key:0,class:"VPDocFooter"},_i={key:0,class:"edit-info"},vi={key:0,class:"edit-link"},gi={key:1,class:"last-updated"},bi={key:1,class:"prev-next","aria-labelledby":"doc-footer-aria-label"},yi={class:"pager"},wi=["innerHTML"],ki=["innerHTML"],Li={class:"pager"},Si=["innerHTML"],Ei=["innerHTML"],Oi=R({__name:"VPDocFooter",setup(t){const{theme:e,page:n,frontmatter:r}=se(),s=li(),a=ci(),o=U(()=>e.value.editLink&&r.value.editLink!==!1),i=U(()=>n.value.lastUpdated),l=U(()=>o.value||i.value||a.value.prev||a.value.next);return(c,u)=>{var d,f,y,S;return l.value?(_(),A("footer",pi,[C(c.$slots,"doc-footer-before",{},void 0,!0),o.value||i.value?(_(),A("div",_i,[o.value?(_(),A("div",vi,[x(je,{class:"edit-link-button",href:v(s).url,"no-icon":!0},{default:M(()=>[u[0]||(u[0]=w("span",{class:"vpi-square-pen edit-link-icon"},null,-1)),Ve(" "+Z(v(s).text),1)]),_:1},8,["href"])])):j("",!0),i.value?(_(),A("div",gi,[x(mi)])):j("",!0)])):j("",!0),(d=v(a).prev)!=null&&d.link||(f=v(a).next)!=null&&f.link?(_(),A("nav",bi,[u[1]||(u[1]=w("span",{class:"visually-hidden",id:"doc-footer-aria-label"},"Pager",-1)),w("div",yi,[(y=v(a).prev)!=null&&y.link?(_(),K(je,{key:0,class:"pager-link prev",href:v(a).prev.link},{default:M(()=>{var g;return[w("span",{class:"desc",innerHTML:((g=v(e).docFooter)==null?void 0:g.prev)||"Previous page"},null,8,wi),w("span",{class:"title",innerHTML:v(a).prev.text},null,8,ki)]}),_:1},8,["href"])):j("",!0)]),w("div",Li,[(S=v(a).next)!=null&&S.link?(_(),K(je,{key:0,class:"pager-link next",href:v(a).next.link},{default:M(()=>{var g;return[w("span",{class:"desc",innerHTML:((g=v(e).docFooter)==null?void 0:g.next)||"Next page"},null,8,Si),w("span",{class:"title",innerHTML:v(a).next.text},null,8,Ei)]}),_:1},8,["href"])):j("",!0)])])):j("",!0)])):j("",!0)}}}),Ci=q(Oi,[["__scopeId","data-v-8e5d41f8"]]),Ai={class:"container"},Ii={class:"aside-container"},Mi={class:"aside-content"},Ni={class:"content"},$i={class:"content-container"},Pi={class:"main"},Ti=R({__name:"VPDoc",setup(t){const{theme:e}=se(),n=Yt(),{hasSidebar:r,hasAside:s,leftAside:a}=et(),o=U(()=>n.path.replace(/[./]+/g,"_").replace(/_html$/,""));return(i,l)=>{const c=lt("Content");return _(),A("div",{class:ue(["VPDoc",{"has-sidebar":v(r),"has-aside":v(s)}])},[C(i.$slots,"doc-top",{},void 0,!0),w("div",Ai,[v(s)?(_(),A("div",{key:0,class:ue(["aside",{"left-aside":v(a)}])},[l[0]||(l[0]=w("div",{class:"aside-curtain"},null,-1)),w("div",Ii,[w("div",Mi,[x(ii,null,{"aside-top":M(()=>[C(i.$slots,"aside-top",{},void 0,!0)]),"aside-bottom":M(()=>[C(i.$slots,"aside-bottom",{},void 0,!0)]),"aside-outline-before":M(()=>[C(i.$slots,"aside-outline-before",{},void 0,!0)]),"aside-outline-after":M(()=>[C(i.$slots,"aside-outline-after",{},void 0,!0)]),"aside-ads-before":M(()=>[C(i.$slots,"aside-ads-before",{},void 0,!0)]),"aside-ads-after":M(()=>[C(i.$slots,"aside-ads-after",{},void 0,!0)]),_:3})])])],2)):j("",!0),w("div",Ni,[w("div",$i,[C(i.$slots,"doc-before",{},void 0,!0),w("main",Pi,[x(c,{class:ue(["vp-doc",[o.value,v(e).externalLinkIcon&&"external-link-icon-enabled"]])},null,8,["class"])]),x(Ci,null,{"doc-footer-before":M(()=>[C(i.$slots,"doc-footer-before",{},void 0,!0)]),_:3}),C(i.$slots,"doc-after",{},void 0,!0)])])]),C(i.$slots,"doc-bottom",{},void 0,!0)],2)}}}),Fi=q(Ti,[["__scopeId","data-v-6e3c7a3c"]]),Ri=R({__name:"VPButton",props:{tag:{},size:{default:"medium"},theme:{default:"brand"},text:{},href:{},target:{},rel:{}},setup(t){const e=t,n=U(()=>e.href&&Ws.test(e.href)),r=U(()=>e.tag||(e.href?"a":"button"));return(s,a)=>(_(),K(We(r.value),{class:ue(["VPButton",[s.size,s.theme]]),href:s.href?v(_r)(s.href):void 0,target:e.target??(n.value?"_blank":void 0),rel:e.rel??(n.value?"noreferrer":void 0)},{default:M(()=>[Ve(Z(s.text),1)]),_:1},8,["class","href","target","rel"]))}}),Vi=q(Ri,[["__scopeId","data-v-96b5e542"]]),Di=["src","alt"],Hi=R({inheritAttrs:!1,__name:"VPImage",props:{image:{},alt:{}},setup(t){return(e,n)=>{const r=lt("VPImage",!0);return e.image?(_(),A(he,{key:0},[typeof e.image=="string"||"src"in e.image?(_(),A("img",at({key:0,class:"VPImage"},typeof e.image=="string"?e.$attrs:{...e.image,...e.$attrs},{src:v(vn)(typeof e.image=="string"?e.image:e.image.src),alt:e.alt??(typeof e.image=="string"?"":e.image.alt||"")}),null,16,Di)):(_(),A(he,{key:1},[x(r,at({class:"dark",image:e.image.dark,alt:e.image.alt},e.$attrs),null,16,["image","alt"]),x(r,at({class:"light",image:e.image.light,alt:e.image.alt},e.$attrs),null,16,["image","alt"])],64))],64)):j("",!0)}}}),un=q(Hi,[["__scopeId","data-v-e0e5e5de"]]),Ui={class:"container"},Bi={class:"main"},Wi={key:0,class:"name"},ji=["innerHTML"],xi=["innerHTML"],Ki=["innerHTML"],Gi={key:0,class:"actions"},Yi={key:0,class:"image"},zi={class:"image-container"},Xi=R({__name:"VPHero",props:{name:{},text:{},tagline:{},image:{},actions:{}},setup(t){const e=Nt("hero-image-slot-exists");return(n,r)=>(_(),A("div",{class:ue(["VPHero",{"has-image":n.image||v(e)}])},[w("div",Ui,[w("div",Bi,[C(n.$slots,"home-hero-info-before",{},void 0,!0),C(n.$slots,"home-hero-info",{},()=>[n.name?(_(),A("h1",Wi,[w("span",{innerHTML:n.name,class:"clip"},null,8,ji)])):j("",!0),n.text?(_(),A("p",{key:1,innerHTML:n.text,class:"text"},null,8,xi)):j("",!0),n.tagline?(_(),A("p",{key:2,innerHTML:n.tagline,class:"tagline"},null,8,Ki)):j("",!0)],!0),C(n.$slots,"home-hero-info-after",{},void 0,!0),n.actions?(_(),A("div",Gi,[(_(!0),A(he,null,Ce(n.actions,s=>(_(),A("div",{key:s.link,class:"action"},[x(Vi,{tag:"a",size:"medium",theme:s.theme,text:s.text,href:s.link,target:s.target,rel:s.rel},null,8,["theme","text","href","target","rel"])]))),128))])):j("",!0),C(n.$slots,"home-hero-actions-after",{},void 0,!0)]),n.image||v(e)?(_(),A("div",Yi,[w("div",zi,[r[0]||(r[0]=w("div",{class:"image-bg"},null,-1)),C(n.$slots,"home-hero-image",{},()=>[n.image?(_(),K(un,{key:0,class:"image-src",image:n.image},null,8,["image"])):j("",!0)],!0)])])):j("",!0)])],2))}}),qi=q(Xi,[["__scopeId","data-v-5d212603"]]),Ji=R({__name:"VPHomeHero",setup(t){const{frontmatter:e}=se();return(n,r)=>v(e).hero?(_(),K(qi,{key:0,class:"VPHomeHero",name:v(e).hero.name,text:v(e).hero.text,tagline:v(e).hero.tagline,image:v(e).hero.image,actions:v(e).hero.actions},{"home-hero-info-before":M(()=>[C(n.$slots,"home-hero-info-before")]),"home-hero-info":M(()=>[C(n.$slots,"home-hero-info")]),"home-hero-info-after":M(()=>[C(n.$slots,"home-hero-info-after")]),"home-hero-actions-after":M(()=>[C(n.$slots,"home-hero-actions-after")]),"home-hero-image":M(()=>[C(n.$slots,"home-hero-image")]),_:3},8,["name","text","tagline","image","actions"])):j("",!0)}}),Qi={class:"box"},Zi={key:0,class:"icon"},el=["innerHTML"],tl=["innerHTML"],nl=["innerHTML"],rl={key:4,class:"link-text"},sl={class:"link-text-value"},al=R({__name:"VPFeature",props:{icon:{},title:{},details:{},link:{},linkText:{},rel:{},target:{}},setup(t){return(e,n)=>(_(),K(je,{class:"VPFeature",href:e.link,rel:e.rel,target:e.target,"no-icon":!0,tag:e.link?"a":"div"},{default:M(()=>[w("article",Qi,[typeof e.icon=="object"&&e.icon.wrap?(_(),A("div",Zi,[x(un,{image:e.icon,alt:e.icon.alt,height:e.icon.height||48,width:e.icon.width||48},null,8,["image","alt","height","width"])])):typeof e.icon=="object"?(_(),K(un,{key:1,image:e.icon,alt:e.icon.alt,height:e.icon.height||48,width:e.icon.width||48},null,8,["image","alt","height","width"])):e.icon?(_(),A("div",{key:2,class:"icon",innerHTML:e.icon},null,8,el)):j("",!0),w("h2",{class:"title",innerHTML:e.title},null,8,tl),e.details?(_(),A("p",{key:3,class:"details",innerHTML:e.details},null,8,nl)):j("",!0),e.linkText?(_(),A("div",rl,[w("p",sl,[Ve(Z(e.linkText)+" ",1),n[0]||(n[0]=w("span",{class:"vpi-arrow-right link-text-icon"},null,-1))])])):j("",!0)])]),_:1},8,["href","rel","target","tag"]))}}),ol=q(al,[["__scopeId","data-v-afde7592"]]),il={key:0,class:"VPFeatures"},ll={class:"container"},cl={class:"items"},ul=R({__name:"VPFeatures",props:{features:{}},setup(t){const e=t,n=U(()=>{const r=e.features.length;if(r){if(r===2)return"grid-2";if(r===3)return"grid-3";if(r%3===0)return"grid-6";if(r>3)return"grid-4"}else return});return(r,s)=>r.features?(_(),A("div",il,[w("div",ll,[w("div",cl,[(_(!0),A(he,null,Ce(r.features,a=>(_(),A("div",{key:a.title,class:ue(["item",[n.value]])},[x(ol,{icon:a.icon,title:a.title,details:a.details,link:a.link,"link-text":a.linkText,rel:a.rel,target:a.target},null,8,["icon","title","details","link","link-text","rel","target"])],2))),128))])])])):j("",!0)}}),dl=q(ul,[["__scopeId","data-v-5aa445b2"]]),fl=R({__name:"VPHomeFeatures",setup(t){const{frontmatter:e}=se();return(n,r)=>v(e).features?(_(),K(dl,{key:0,class:"VPHomeFeatures",features:v(e).features},null,8,["features"])):j("",!0)}}),hl=R({__name:"VPHomeContent",setup(t){const{width:e}=fo({initialWidth:0,includeScrollbar:!1});return(n,r)=>(_(),A("div",{class:"vp-doc container",style:js(v(e)?{"--vp-offset":`calc(50% - ${v(e)/2}px)`}:{})},[C(n.$slots,"default",{},void 0,!0)],4))}}),ml=q(hl,[["__scopeId","data-v-2f74a256"]]),pl={class:"VPHome"},_l=R({__name:"VPHome",setup(t){const{frontmatter:e}=se();return(n,r)=>{const s=lt("Content");return _(),A("div",pl,[C(n.$slots,"home-hero-before",{},void 0,!0),x(Ji,null,{"home-hero-info-before":M(()=>[C(n.$slots,"home-hero-info-before",{},void 0,!0)]),"home-hero-info":M(()=>[C(n.$slots,"home-hero-info",{},void 0,!0)]),"home-hero-info-after":M(()=>[C(n.$slots,"home-hero-info-after",{},void 0,!0)]),"home-hero-actions-after":M(()=>[C(n.$slots,"home-hero-actions-after",{},void 0,!0)]),"home-hero-image":M(()=>[C(n.$slots,"home-hero-image",{},void 0,!0)]),_:3}),C(n.$slots,"home-hero-after",{},void 0,!0),C(n.$slots,"home-features-before",{},void 0,!0),x(fl),C(n.$slots,"home-features-after",{},void 0,!0),v(e).markdownStyles!==!1?(_(),K(ml,{key:0},{default:M(()=>[x(s)]),_:1})):(_(),K(s,{key:1}))])}}}),vl=q(_l,[["__scopeId","data-v-fae02f30"]]),gl={},bl={class:"VPPage"};function yl(t,e){const n=lt("Content");return _(),A("div",bl,[C(t.$slots,"page-top"),x(n),C(t.$slots,"page-bottom")])}const wl=q(gl,[["render",yl]]),kl=R({__name:"VPContent",setup(t){const{page:e,frontmatter:n}=se(),{hasSidebar:r}=et();return(s,a)=>(_(),A("div",{class:ue(["VPContent",{"has-sidebar":v(r),"is-home":v(n).layout==="home"}]),id:"VPContent"},[v(e).isNotFound?C(s.$slots,"not-found",{key:0},()=>[x(Uo)],!0):v(n).layout==="page"?(_(),K(wl,{key:1},{"page-top":M(()=>[C(s.$slots,"page-top",{},void 0,!0)]),"page-bottom":M(()=>[C(s.$slots,"page-bottom",{},void 0,!0)]),_:3})):v(n).layout==="home"?(_(),K(vl,{key:2},{"home-hero-before":M(()=>[C(s.$slots,"home-hero-before",{},void 0,!0)]),"home-hero-info-before":M(()=>[C(s.$slots,"home-hero-info-before",{},void 0,!0)]),"home-hero-info":M(()=>[C(s.$slots,"home-hero-info",{},void 0,!0)]),"home-hero-info-after":M(()=>[C(s.$slots,"home-hero-info-after",{},void 0,!0)]),"home-hero-actions-after":M(()=>[C(s.$slots,"home-hero-actions-after",{},void 0,!0)]),"home-hero-image":M(()=>[C(s.$slots,"home-hero-image",{},void 0,!0)]),"home-hero-after":M(()=>[C(s.$slots,"home-hero-after",{},void 0,!0)]),"home-features-before":M(()=>[C(s.$slots,"home-features-before",{},void 0,!0)]),"home-features-after":M(()=>[C(s.$slots,"home-features-after",{},void 0,!0)]),_:3})):v(n).layout&&v(n).layout!=="doc"?(_(),K(We(v(n).layout),{key:3})):(_(),K(Fi,{key:4},{"doc-top":M(()=>[C(s.$slots,"doc-top",{},void 0,!0)]),"doc-bottom":M(()=>[C(s.$slots,"doc-bottom",{},void 0,!0)]),"doc-footer-before":M(()=>[C(s.$slots,"doc-footer-before",{},void 0,!0)]),"doc-before":M(()=>[C(s.$slots,"doc-before",{},void 0,!0)]),"doc-after":M(()=>[C(s.$slots,"doc-after",{},void 0,!0)]),"aside-top":M(()=>[C(s.$slots,"aside-top",{},void 0,!0)]),"aside-outline-before":M(()=>[C(s.$slots,"aside-outline-before",{},void 0,!0)]),"aside-outline-after":M(()=>[C(s.$slots,"aside-outline-after",{},void 0,!0)]),"aside-ads-before":M(()=>[C(s.$slots,"aside-ads-before",{},void 0,!0)]),"aside-ads-after":M(()=>[C(s.$slots,"aside-ads-after",{},void 0,!0)]),"aside-bottom":M(()=>[C(s.$slots,"aside-bottom",{},void 0,!0)]),_:3}))],2))}}),Ll=q(kl,[["__scopeId","data-v-75e53c5a"]]),Sl={class:"container"},El=["innerHTML"],Ol=["innerHTML"],Cl=R({__name:"VPFooter",setup(t){const{theme:e,frontmatter:n}=se(),{hasSidebar:r}=et();return(s,a)=>v(e).footer&&v(n).footer!==!1?(_(),A("footer",{key:0,class:ue(["VPFooter",{"has-sidebar":v(r)}])},[w("div",Sl,[v(e).footer.message?(_(),A("p",{key:0,class:"message",innerHTML:v(e).footer.message},null,8,El)):j("",!0),v(e).footer.copyright?(_(),A("p",{key:1,class:"copyright",innerHTML:v(e).footer.copyright},null,8,Ol)):j("",!0)])],2)):j("",!0)}}),Al=q(Cl,[["__scopeId","data-v-96de3340"]]);function Il(){const{theme:t,frontmatter:e}=se(),n=bn([]),r=U(()=>n.value.length>0);return yn(()=>{n.value=vr(e.value.outline??t.value.outline)}),{headers:n,hasLocalNav:r}}const Ml={class:"menu-text"},Nl={class:"header"},$l={class:"outline"},Pl=R({__name:"VPLocalNavOutlineDropdown",props:{headers:{},navHeight:{}},setup(t){const e=t,{theme:n}=se(),r=X(!1),s=X(0),a=X(),o=X();function i(d){var f;(f=a.value)!=null&&f.contains(d.target)||(r.value=!1)}pe(r,d=>{if(d){document.addEventListener("click",i);return}document.removeEventListener("click",i)}),ho("Escape",()=>{r.value=!1}),yn(()=>{r.value=!1});function l(){r.value=!r.value,s.value=window.innerHeight+Math.min(window.scrollY-e.navHeight,0)}function c(d){d.target.classList.contains("outline-link")&&(o.value&&(o.value.style.transition="none"),Ue(()=>{r.value=!1}))}function u(){r.value=!1,window.scrollTo({top:0,left:0,behavior:"smooth"})}return(d,f)=>(_(),A("div",{class:"VPLocalNavOutlineDropdown",style:js({"--vp-vh":s.value+"px"}),ref_key:"main",ref:a},[d.headers.length>0?(_(),A("button",{key:0,onClick:l,class:ue({open:r.value})},[w("span",Ml,Z(v(Qs)(v(n))),1),f[0]||(f[0]=w("span",{class:"vpi-chevron-right icon"},null,-1))],2)):(_(),A("button",{key:1,onClick:u},Z(v(n).returnToTopLabel||"Return to top"),1)),x(_n,{name:"flyout"},{default:M(()=>[r.value?(_(),A("div",{key:0,ref_key:"items",ref:o,class:"items",onClick:c},[w("div",Nl,[w("a",{class:"top-link",href:"#",onClick:u},Z(v(n).returnToTopLabel||"Return to top"),1)]),w("div",$l,[x(Zs,{headers:d.headers},null,8,["headers"])])],512)):j("",!0)]),_:1})],4))}}),Tl=q(Pl,[["__scopeId","data-v-b940033a"]]),Fl={class:"container"},Rl=["aria-expanded"],Vl={class:"menu-text"},Dl=R({__name:"VPLocalNav",props:{open:{type:Boolean}},emits:["open-menu"],setup(t){const{theme:e,frontmatter:n}=se(),{hasSidebar:r}=et(),{headers:s}=Il(),{y:a}=xs(),o=X(0);Ye(()=>{o.value=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--vp-nav-height"))}),yn(()=>{s.value=vr(n.value.outline??e.value.outline)});const i=U(()=>s.value.length===0),l=U(()=>i.value&&!r.value),c=U(()=>({VPLocalNav:!0,"has-sidebar":r.value,empty:i.value,fixed:l.value}));return(u,d)=>v(n).layout!=="home"&&(!l.value||v(a)>=o.value)?(_(),A("div",{key:0,class:ue(c.value)},[w("div",Fl,[v(r)?(_(),A("button",{key:0,class:"menu","aria-expanded":u.open,"aria-controls":"VPSidebarNav",onClick:d[0]||(d[0]=f=>u.$emit("open-menu"))},[d[1]||(d[1]=w("span",{class:"vpi-align-left menu-icon"},null,-1)),w("span",Vl,Z(v(e).sidebarMenuLabel||"Menu"),1)],8,Rl)):j("",!0),x(Tl,{headers:v(s),navHeight:o.value},null,8,["headers","navHeight"])])],2)):j("",!0)}}),Hl=q(Dl,[["__scopeId","data-v-39bb13ec"]]);function Ul(){const t=X(!1);function e(){t.value=!0,window.addEventListener("resize",s)}function n(){t.value=!1,window.removeEventListener("resize",s)}function r(){t.value?n():e()}function s(){window.outerWidth>=768&&n()}const a=Yt();return pe(()=>a.path,n),{isScreenOpen:t,openScreen:e,closeScreen:n,toggleScreen:r}}const Bl={},Wl={class:"VPSwitch",type:"button",role:"switch"},jl={class:"check"},xl={key:0,class:"icon"};function Kl(t,e){return _(),A("button",Wl,[w("span",jl,[t.$slots.default?(_(),A("span",xl,[C(t.$slots,"default",{},void 0,!0)])):j("",!0)])])}const Gl=q(Bl,[["render",Kl],["__scopeId","data-v-d2bb6b64"]]),Yl=R({__name:"VPSwitchAppearance",setup(t){const{isDark:e,theme:n}=se(),r=Nt("toggle-appearance",()=>{e.value=!e.value}),s=X("");return mr(()=>{s.value=e.value?n.value.lightModeSwitchTitle||"Switch to light theme":n.value.darkModeSwitchTitle||"Switch to dark theme"}),(a,o)=>(_(),K(Gl,{title:s.value,class:"VPSwitchAppearance","aria-checked":v(e),onClick:v(r)},{default:M(()=>o[0]||(o[0]=[w("span",{class:"vpi-sun sun"},null,-1),w("span",{class:"vpi-moon moon"},null,-1)])),_:1},8,["title","aria-checked","onClick"]))}}),gr=q(Yl,[["__scopeId","data-v-d9e1397d"]]),zl={key:0,class:"VPNavBarAppearance"},Xl=R({__name:"VPNavBarAppearance",setup(t){const{site:e}=se();return(n,r)=>v(e).appearance&&v(e).appearance!=="force-dark"&&v(e).appearance!=="force-auto"?(_(),A("div",zl,[x(gr)])):j("",!0)}}),ql=q(Xl,[["__scopeId","data-v-ebdf52b9"]]),br=X();let ea=!1,Pn=0;function Jl(t){const e=X(!1);if(wn){!ea&&Ql(),Pn++;const n=pe(br,r=>{var s,a,o;r===t.el.value||(s=t.el.value)!=null&&s.contains(r)?(e.value=!0,(a=t.onFocus)==null||a.call(t)):(e.value=!1,(o=t.onBlur)==null||o.call(t))});gn(()=>{n(),Pn--,Pn||Zl()})}return Ks(e)}function Ql(){document.addEventListener("focusin",ta),ea=!0,br.value=document.activeElement}function Zl(){document.removeEventListener("focusin",ta)}function ta(){br.value=document.activeElement}const ec={class:"VPMenuLink"},tc=R({__name:"VPMenuLink",props:{item:{}},setup(t){const{page:e}=se();return(n,r)=>(_(),A("div",ec,[x(je,{class:ue({active:v(pt)(v(e).relativePath,n.item.activeMatch||n.item.link,!!n.item.activeMatch)}),href:n.item.link,target:n.item.target,rel:n.item.rel},{default:M(()=>[Ve(Z(n.item.text),1)]),_:1},8,["class","href","target","rel"])]))}}),Ln=q(tc,[["__scopeId","data-v-539cebd5"]]),nc={class:"VPMenuGroup"},rc={key:0,class:"title"},sc=R({__name:"VPMenuGroup",props:{text:{},items:{}},setup(t){return(e,n)=>(_(),A("div",nc,[e.text?(_(),A("p",rc,Z(e.text),1)):j("",!0),(_(!0),A(he,null,Ce(e.items,r=>(_(),A(he,null,["link"in r?(_(),K(Ln,{key:0,item:r},null,8,["item"])):j("",!0)],64))),256))]))}}),ac=q(sc,[["__scopeId","data-v-0916ffd6"]]),oc={class:"VPMenu"},ic={key:0,class:"items"},lc=R({__name:"VPMenu",props:{items:{}},setup(t){return(e,n)=>(_(),A("div",oc,[e.items?(_(),A("div",ic,[(_(!0),A(he,null,Ce(e.items,r=>(_(),A(he,{key:JSON.stringify(r)},["link"in r?(_(),K(Ln,{key:0,item:r},null,8,["item"])):"component"in r?(_(),K(We(r.component),at({key:1,ref_for:!0},r.props),null,16)):(_(),K(ac,{key:2,text:r.text,items:r.items},null,8,["text","items"]))],64))),128))])):j("",!0),C(e.$slots,"default",{},void 0,!0)]))}}),cc=q(lc,[["__scopeId","data-v-741d072f"]]),uc=["aria-expanded","aria-label"],dc={key:0,class:"text"},fc=["innerHTML"],hc={key:1,class:"vpi-more-horizontal icon"},mc={class:"menu"},pc=R({__name:"VPFlyout",props:{icon:{},button:{},label:{},items:{}},setup(t){const e=X(!1),n=X();Jl({el:n,onBlur:r});function r(){e.value=!1}return(s,a)=>(_(),A("div",{class:"VPFlyout",ref_key:"el",ref:n,onMouseenter:a[1]||(a[1]=o=>e.value=!0),onMouseleave:a[2]||(a[2]=o=>e.value=!1)},[w("button",{type:"button",class:"button","aria-haspopup":"true","aria-expanded":e.value,"aria-label":s.label,onClick:a[0]||(a[0]=o=>e.value=!e.value)},[s.button||s.icon?(_(),A("span",dc,[s.icon?(_(),A("span",{key:0,class:ue([s.icon,"option-icon"])},null,2)):j("",!0),s.button?(_(),A("span",{key:1,innerHTML:s.button},null,8,fc)):j("",!0),a[3]||(a[3]=w("span",{class:"vpi-chevron-down text-icon"},null,-1))])):(_(),A("span",hc))],8,uc),w("div",mc,[x(cc,{items:s.items},{default:M(()=>[C(s.$slots,"default",{},void 0,!0)]),_:3},8,["items"])])],544))}}),yr=q(pc,[["__scopeId","data-v-30554091"]]),_c=["href","aria-label","innerHTML"],vc=R({__name:"VPSocialLink",props:{icon:{},link:{},ariaLabel:{}},setup(t){const e=t,n=U(()=>typeof e.icon=="object"?e.icon.svg:``);return(r,s)=>(_(),A("a",{class:"VPSocialLink no-icon",href:r.link,"aria-label":r.ariaLabel??(typeof r.icon=="string"?r.icon:""),target:"_blank",rel:"noopener",innerHTML:n.value},null,8,_c))}}),gc=q(vc,[["__scopeId","data-v-84781e74"]]),bc={class:"VPSocialLinks"},yc=R({__name:"VPSocialLinks",props:{links:{}},setup(t){return(e,n)=>(_(),A("div",bc,[(_(!0),A(he,null,Ce(e.links,({link:r,icon:s,ariaLabel:a})=>(_(),K(gc,{key:r,icon:s,link:r,ariaLabel:a},null,8,["icon","link","ariaLabel"]))),128))]))}}),wr=q(yc,[["__scopeId","data-v-4d8e32d0"]]),wc={key:0,class:"group translations"},kc={class:"trans-title"},Lc={key:1,class:"group"},Sc={class:"item appearance"},Ec={class:"label"},Oc={class:"appearance-action"},Cc={key:2,class:"group"},Ac={class:"item social-links"},Ic=R({__name:"VPNavBarExtra",setup(t){const{site:e,theme:n}=se(),{localeLinks:r,currentLang:s}=zt({correspondingLink:!0}),a=U(()=>r.value.length&&s.value.label||e.value.appearance||n.value.socialLinks);return(o,i)=>a.value?(_(),K(yr,{key:0,class:"VPNavBarExtra",label:"extra navigation"},{default:M(()=>[v(r).length&&v(s).label?(_(),A("div",wc,[w("p",kc,Z(v(s).label),1),(_(!0),A(he,null,Ce(v(r),l=>(_(),K(Ln,{key:l.link,item:l},null,8,["item"]))),128))])):j("",!0),v(e).appearance&&v(e).appearance!=="force-dark"&&v(e).appearance!=="force-auto"?(_(),A("div",Lc,[w("div",Sc,[w("p",Ec,Z(v(n).darkModeSwitchLabel||"Appearance"),1),w("div",Oc,[x(gr)])])])):j("",!0),v(n).socialLinks?(_(),A("div",Cc,[w("div",Ac,[x(wr,{class:"social-links-list",links:v(n).socialLinks},null,8,["links"])])])):j("",!0)]),_:1})):j("",!0)}}),Mc=q(Ic,[["__scopeId","data-v-5eb5ec11"]]),Nc=["aria-expanded"],$c=R({__name:"VPNavBarHamburger",props:{active:{type:Boolean}},emits:["click"],setup(t){return(e,n)=>(_(),A("button",{type:"button",class:ue(["VPNavBarHamburger",{active:e.active}]),"aria-label":"mobile navigation","aria-expanded":e.active,"aria-controls":"VPNavScreen",onClick:n[0]||(n[0]=r=>e.$emit("click"))},n[1]||(n[1]=[w("span",{class:"container"},[w("span",{class:"top"}),w("span",{class:"middle"}),w("span",{class:"bottom"})],-1)]),10,Nc))}}),Pc=q($c,[["__scopeId","data-v-9d6e8671"]]),Tc=["innerHTML"],Fc=R({__name:"VPNavBarMenuLink",props:{item:{}},setup(t){const{page:e}=se();return(n,r)=>(_(),K(je,{class:ue({VPNavBarMenuLink:!0,active:v(pt)(v(e).relativePath,n.item.activeMatch||n.item.link,!!n.item.activeMatch)}),href:n.item.link,noIcon:n.item.noIcon,target:n.item.target,rel:n.item.rel,tabindex:"0"},{default:M(()=>[w("span",{innerHTML:n.item.text},null,8,Tc)]),_:1},8,["class","href","noIcon","target","rel"]))}}),Rc=q(Fc,[["__scopeId","data-v-dbfe5822"]]),Vc=R({__name:"VPNavBarMenuGroup",props:{item:{}},setup(t){const e=t,{page:n}=se(),r=a=>"component"in a?!1:"link"in a?pt(n.value.relativePath,a.link,!!e.item.activeMatch):a.items.some(r),s=U(()=>r(e.item));return(a,o)=>(_(),K(yr,{class:ue({VPNavBarMenuGroup:!0,active:v(pt)(v(n).relativePath,a.item.activeMatch,!!a.item.activeMatch)||s.value}),button:a.item.text,items:a.item.items},null,8,["class","button","items"]))}}),Dc={key:0,"aria-labelledby":"main-nav-aria-label",class:"VPNavBarMenu"},Hc=R({__name:"VPNavBarMenu",setup(t){const{theme:e}=se();return(n,r)=>v(e).nav?(_(),A("nav",Dc,[r[0]||(r[0]=w("span",{id:"main-nav-aria-label",class:"visually-hidden"}," Main Navigation ",-1)),(_(!0),A(he,null,Ce(v(e).nav,s=>(_(),A(he,{key:JSON.stringify(s)},["link"in s?(_(),K(Rc,{key:0,item:s},null,8,["item"])):"component"in s?(_(),K(We(s.component),at({key:1,ref_for:!0},s.props),null,16)):(_(),K(Vc,{key:2,item:s},null,8,["item"]))],64))),128))])):j("",!0)}}),Uc=q(Hc,[["__scopeId","data-v-36265739"]]);var $r;const na=typeof window<"u",Bc=t=>typeof t=="string",an=()=>{};na&&(($r=window==null?void 0:window.navigator)!=null&&$r.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);function Kn(t){return typeof t=="function"?t():v(t)}function Wc(t,e){function n(...r){t(()=>e.apply(this,r),{fn:e,thisArg:this,args:r})}return n}function jc(t,e={}){let n,r;return s=>{const a=Kn(t),o=Kn(e.maxWait);if(n&&clearTimeout(n),a<=0||o!==void 0&&o<=0)return r&&(clearTimeout(r),r=null),s();o&&!r&&(r=setTimeout(()=>{n&&clearTimeout(n),r=null,s()},o)),n=setTimeout(()=>{r&&clearTimeout(r),r=null,s()},a)}}function xc(t){return t}function Kc(t){return zs()?(Xs(t),!0):!1}function ra(t,e=200,n={}){return Wc(jc(e,n),t)}function Tn(t,e=200,n={}){if(e<=0)return t;const r=X(t.value),s=ra(()=>{r.value=t.value},e,n);return pe(t,()=>s()),r}function sa(t,e,n){return pe(t,(r,s,a)=>{r&&e(r,s,a)},n)}function Gc(t){var e;const n=Kn(t);return(e=n==null?void 0:n.$el)!=null?e:n}const aa=na?window:void 0;function en(...t){let e,n,r,s;if(Bc(t[0])?([n,r,s]=t,e=aa):[e,n,r,s]=t,!e)return an;let a=an;const o=pe(()=>Gc(e),l=>{a(),l&&(l.addEventListener(n,r,s),a=()=>{l.removeEventListener(n,r,s),a=an})},{immediate:!0,flush:"post"}),i=()=>{o(),a()};return Kc(i),i}const Pr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Tr="__vueuse_ssr_handlers__";Pr[Tr]=Pr[Tr]||{};const Yc={ctrl:"control",command:"meta",cmd:"meta",option:"alt",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright"};function zc(t={}){const{reactive:e=!1,target:n=aa,aliasMap:r=Yc,passive:s=!0,onEventFired:a=an}=t,o=Bt(new Set),i={toJSON(){return{}},current:o},l=e?Bt(i):i,c=new Set,u=new Set;function d(g,b){g in l&&(e?l[g]=b:l[g].value=b)}function f(){for(const g of u)d(g,!1)}function y(g,b){var p,E;const I=(p=g.key)==null?void 0:p.toLowerCase(),L=[(E=g.code)==null?void 0:E.toLowerCase(),I].filter(Boolean);I&&(b?o.add(I):o.delete(I));for(const P of L)u.add(P),d(P,b);I==="meta"&&!b?(c.forEach(P=>{o.delete(P),d(P,!1)}),c.clear()):typeof g.getModifierState=="function"&&g.getModifierState("Meta")&&b&&[...o,...L].forEach(P=>c.add(P))}en(n,"keydown",g=>(y(g,!0),a(g)),{passive:s}),en(n,"keyup",g=>(y(g,!1),a(g)),{passive:s}),en("blur",f,{passive:!0}),en("focus",f,{passive:!0});const S=new Proxy(l,{get(g,b,p){if(typeof b!="string")return Reflect.get(g,b,p);if(b=b.toLowerCase(),b in r&&(b=r[b]),!(b in l))if(/[+_-]/.test(b)){const I=b.split(/[+_-]/g).map(L=>L.trim());l[b]=U(()=>I.every(L=>v(S[L])))}else l[b]=X(!1);const E=Reflect.get(g,b,p);return e?v(E):E}});return S}var Fr;(function(t){t.UP="UP",t.RIGHT="RIGHT",t.DOWN="DOWN",t.LEFT="LEFT",t.NONE="NONE"})(Fr||(Fr={}));var Xc=Object.defineProperty,Rr=Object.getOwnPropertySymbols,qc=Object.prototype.hasOwnProperty,Jc=Object.prototype.propertyIsEnumerable,Vr=(t,e,n)=>e in t?Xc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Qc=(t,e)=>{for(var n in e||(e={}))qc.call(e,n)&&Vr(t,n,e[n]);if(Rr)for(var n of Rr(e))Jc.call(e,n)&&Vr(t,n,e[n]);return t};const Zc={easeInSine:[.12,0,.39,0],easeOutSine:[.61,1,.88,1],easeInOutSine:[.37,0,.63,1],easeInQuad:[.11,0,.5,0],easeOutQuad:[.5,1,.89,1],easeInOutQuad:[.45,0,.55,1],easeInCubic:[.32,0,.67,0],easeOutCubic:[.33,1,.68,1],easeInOutCubic:[.65,0,.35,1],easeInQuart:[.5,0,.75,0],easeOutQuart:[.25,1,.5,1],easeInOutQuart:[.76,0,.24,1],easeInQuint:[.64,0,.78,0],easeOutQuint:[.22,1,.36,1],easeInOutQuint:[.83,0,.17,1],easeInExpo:[.7,0,.84,0],easeOutExpo:[.16,1,.3,1],easeInOutExpo:[.87,0,.13,1],easeInCirc:[.55,0,1,.45],easeOutCirc:[0,.55,.45,1],easeInOutCirc:[.85,0,.15,1],easeInBack:[.36,0,.66,-.56],easeOutBack:[.34,1.56,.64,1],easeInOutBack:[.68,-.6,.32,1.6]};Qc({linear:xc},Zc);function Ze(t){return Array.isArray?Array.isArray(t):la(t)==="[object Array]"}const eu=1/0;function tu(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-eu?"-0":e}function nu(t){return t==null?"":tu(t)}function Be(t){return typeof t=="string"}function oa(t){return typeof t=="number"}function ru(t){return t===!0||t===!1||su(t)&&la(t)=="[object Boolean]"}function ia(t){return typeof t=="object"}function su(t){return ia(t)&&t!==null}function $e(t){return t!=null}function Fn(t){return!t.trim().length}function la(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const au="Incorrect 'index' type",ou=t=>`Invalid value for key ${t}`,iu=t=>`Pattern length exceeds max of ${t}.`,lu=t=>`Missing ${t} property in key`,cu=t=>`Property 'weight' in key '${t}' must be a positive integer`,Dr=Object.prototype.hasOwnProperty;class uu{constructor(e){this._keys=[],this._keyMap={};let n=0;e.forEach(r=>{let s=ca(r);n+=s.weight,this._keys.push(s),this._keyMap[s.id]=s,n+=s.weight}),this._keys.forEach(r=>{r.weight/=n})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function ca(t){let e=null,n=null,r=null,s=1,a=null;if(Be(t)||Ze(t))r=t,e=Hr(t),n=Gn(t);else{if(!Dr.call(t,"name"))throw new Error(lu("name"));const o=t.name;if(r=o,Dr.call(t,"weight")&&(s=t.weight,s<=0))throw new Error(cu(o));e=Hr(o),n=Gn(o),a=t.getFn}return{path:e,id:n,weight:s,src:r,getFn:a}}function Hr(t){return Ze(t)?t:t.split(".")}function Gn(t){return Ze(t)?t.join("."):t}function du(t,e){let n=[],r=!1;const s=(a,o,i)=>{if($e(a))if(!o[i])n.push(a);else{let l=o[i];const c=a[l];if(!$e(c))return;if(i===o.length-1&&(Be(c)||oa(c)||ru(c)))n.push(nu(c));else if(Ze(c)){r=!0;for(let u=0,d=c.length;ut.score===e.score?t.idx{this._keysMap[n.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Be(this.docs[0])?this.docs.forEach((e,n)=>{this._addString(e,n)}):this.docs.forEach((e,n)=>{this._addObject(e,n)}),this.norm.clear())}add(e){const n=this.size();Be(e)?this._addString(e,n):this._addObject(e,n)}removeAt(e){this.records.splice(e,1);for(let n=e,r=this.size();n{let o=s.getFn?s.getFn(e):this.getFn(e,s.path);if($e(o)){if(Ze(o)){let i=[];const l=[{nestedArrIndex:-1,value:o}];for(;l.length;){const{nestedArrIndex:c,value:u}=l.pop();if($e(u))if(Be(u)&&!Fn(u)){let d={v:u,i:c,n:this.norm.get(u)};i.push(d)}else Ze(u)&&u.forEach((d,f)=>{l.push({nestedArrIndex:f,value:d})})}r.$[a]=i}else if(Be(o)&&!Fn(o)){let i={v:o,n:this.norm.get(o)};r.$[a]=i}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function ua(t,e,{getFn:n=Q.getFn,fieldNormWeight:r=Q.fieldNormWeight}={}){const s=new kr({getFn:n,fieldNormWeight:r});return s.setKeys(t.map(ca)),s.setSources(e),s.create(),s}function gu(t,{getFn:e=Q.getFn,fieldNormWeight:n=Q.fieldNormWeight}={}){const{keys:r,records:s}=t,a=new kr({getFn:e,fieldNormWeight:n});return a.setKeys(r),a.setIndexRecords(s),a}function tn(t,{errors:e=0,currentLocation:n=0,expectedLocation:r=0,distance:s=Q.distance,ignoreLocation:a=Q.ignoreLocation}={}){const o=e/t.length;if(a)return o;const i=Math.abs(r-n);return s?o+i/s:i?1:o}function bu(t=[],e=Q.minMatchCharLength){let n=[],r=-1,s=-1,a=0;for(let o=t.length;a=e&&n.push([r,s]),r=-1)}return t[a-1]&&a-r>=e&&n.push([r,a-1]),n}const ht=32;function yu(t,e,n,{location:r=Q.location,distance:s=Q.distance,threshold:a=Q.threshold,findAllMatches:o=Q.findAllMatches,minMatchCharLength:i=Q.minMatchCharLength,includeMatches:l=Q.includeMatches,ignoreLocation:c=Q.ignoreLocation}={}){if(e.length>ht)throw new Error(iu(ht));const u=e.length,d=t.length,f=Math.max(0,Math.min(r,d));let y=a,S=f;const g=i>1||l,b=g?Array(d):[];let p;for(;(p=t.indexOf(e,S))>-1;){let N=tn(e,{currentLocation:p,expectedLocation:f,distance:s,ignoreLocation:c});if(y=Math.min(N,y),S=p+u,g){let B=0;for(;B=ce;_e-=1){let Ne=_e-1,Te=n[t.charAt(Ne)];if(g&&(b[Ne]=+!!Te),ae[_e]=(ae[_e+1]<<1|1)&Te,N&&(ae[_e]|=(E[_e+1]|E[_e])<<1|1|E[_e+1]),ae[_e]&P&&(I=tn(e,{errors:N,currentLocation:Ne,expectedLocation:f,distance:s,ignoreLocation:c}),I<=y)){if(y=I,S=Ne,S<=f)break;ce=Math.max(1,2*f-S)}}if(tn(e,{errors:N+1,currentLocation:f,expectedLocation:f,distance:s,ignoreLocation:c})>y)break;E=ae}const T={isMatch:S>=0,score:Math.max(.001,I)};if(g){const N=bu(b,i);N.length?l&&(T.indices=N):T.isMatch=!1}return T}function wu(t){let e={};for(let n=0,r=t.length;n{this.chunks.push({pattern:f,alphabet:wu(f),startIndex:y})},d=this.pattern.length;if(d>ht){let f=0;const y=d%ht,S=d-y;for(;f{const{isMatch:p,score:E,indices:I}=yu(e,S,g,{location:s+b,distance:a,threshold:o,findAllMatches:i,minMatchCharLength:l,includeMatches:r,ignoreLocation:c});p&&(f=!0),d+=E,p&&I&&(u=[...u,...I])});let y={isMatch:f,score:f?d/this.chunks.length:1};return f&&r&&(y.indices=u),y}}class ct{constructor(e){this.pattern=e}static isMultiMatch(e){return Ur(e,this.multiRegex)}static isSingleMatch(e){return Ur(e,this.singleRegex)}search(){}}function Ur(t,e){const n=t.match(e);return n?n[1]:null}class ku extends ct{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const n=e===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class Lu extends ct{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const n=e.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class Su extends ct{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const n=e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class Eu extends ct{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const n=!e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class Ou extends ct{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const n=e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class Cu extends ct{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const n=!e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class fa extends ct{constructor(e,{location:n=Q.location,threshold:r=Q.threshold,distance:s=Q.distance,includeMatches:a=Q.includeMatches,findAllMatches:o=Q.findAllMatches,minMatchCharLength:i=Q.minMatchCharLength,isCaseSensitive:l=Q.isCaseSensitive,ignoreLocation:c=Q.ignoreLocation}={}){super(e),this._bitapSearch=new da(e,{location:n,threshold:r,distance:s,includeMatches:a,findAllMatches:o,minMatchCharLength:i,isCaseSensitive:l,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class ha extends ct{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let n=0,r;const s=[],a=this.pattern.length;for(;(r=e.indexOf(this.pattern,n))>-1;)n=r+a,s.push([r,n-1]);const o=!!s.length;return{isMatch:o,score:o?0:1,indices:s}}}const Yn=[ku,ha,Su,Eu,Cu,Ou,Lu,fa],Br=Yn.length,Au=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Iu="|";function Mu(t,e={}){return t.split(Iu).map(n=>{let r=n.trim().split(Au).filter(a=>a&&!!a.trim()),s=[];for(let a=0,o=r.length;a!!(t[dn.AND]||t[dn.OR]),Tu=t=>!!t[qn.PATH],Fu=t=>!Ze(t)&&ia(t)&&!Jn(t),Wr=t=>({[dn.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function ma(t,e,{auto:n=!0}={}){const r=s=>{let a=Object.keys(s);const o=Tu(s);if(!o&&a.length>1&&!Jn(s))return r(Wr(s));if(Fu(s)){const l=o?s[qn.PATH]:a[0],c=o?s[qn.PATTERN]:s[l];if(!Be(c))throw new Error(ou(l));const u={keyId:Gn(l),pattern:c};return n&&(u.searcher=Xn(c,e)),u}let i={children:[],operator:a[0]};return a.forEach(l=>{const c=s[l];Ze(c)&&c.forEach(u=>{i.children.push(r(u))})}),i};return Jn(t)||(t=Wr(t)),r(t)}function Ru(t,{ignoreFieldNorm:e=Q.ignoreFieldNorm}){t.forEach(n=>{let r=1;n.matches.forEach(({key:s,norm:a,score:o})=>{const i=s?s.weight:null;r*=Math.pow(o===0&&i?Number.EPSILON:o,(i||1)*(e?1:a))}),n.score=r})}function Vu(t,e){const n=t.matches;e.matches=[],$e(n)&&n.forEach(r=>{if(!$e(r.indices)||!r.indices.length)return;const{indices:s,value:a}=r;let o={indices:s,value:a};r.key&&(o.key=r.key.src),r.idx>-1&&(o.refIndex=r.idx),e.matches.push(o)})}function Du(t,e){e.score=t.score}function Hu(t,e,{includeMatches:n=Q.includeMatches,includeScore:r=Q.includeScore}={}){const s=[];return n&&s.push(Vu),r&&s.push(Du),t.map(a=>{const{idx:o}=a,i={item:e[o],refIndex:o};return s.length&&s.forEach(l=>{l(a,i)}),i})}class _t{constructor(e,n={},r){this.options={...Q,...n},this.options.useExtendedSearch,this._keyStore=new uu(this.options.keys),this.setCollection(e,r)}setCollection(e,n){if(this._docs=e,n&&!(n instanceof kr))throw new Error(au);this._myIndex=n||ua(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){!$e(e)||(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const n=[];for(let r=0,s=this._docs.length;r-1&&(l=l.slice(0,n)),Hu(l,this._docs,{includeMatches:r,includeScore:s})}_searchStringList(e){const n=Xn(e,this.options),{records:r}=this._myIndex,s=[];return r.forEach(({v:a,i:o,n:i})=>{if(!$e(a))return;const{isMatch:l,score:c,indices:u}=n.searchIn(a);l&&s.push({item:a,idx:o,matches:[{score:c,value:a,norm:i,indices:u}]})}),s}_searchLogical(e){const n=ma(e,this.options),r=(i,l,c)=>{if(!i.children){const{keyId:d,searcher:f}=i,y=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(l,d),searcher:f});return y&&y.length?[{idx:c,item:l,matches:y}]:[]}const u=[];for(let d=0,f=i.children.length;d{if($e(i)){let c=r(n,i,l);c.length&&(a[l]||(a[l]={idx:l,item:i,matches:[]},o.push(a[l])),c.forEach(({matches:u})=>{a[l].matches.push(...u)}))}}),o}_searchObjectList(e){const n=Xn(e,this.options),{keys:r,records:s}=this._myIndex,a=[];return s.forEach(({$:o,i})=>{if(!$e(o))return;let l=[];r.forEach((c,u)=>{l.push(...this._findMatches({key:c,value:o[u],searcher:n}))}),l.length&&a.push({idx:i,item:o,matches:l})}),a}_findMatches({key:e,value:n,searcher:r}){if(!$e(n))return[];let s=[];if(Ze(n))n.forEach(({v:a,i:o,n:i})=>{if(!$e(a))return;const{isMatch:l,score:c,indices:u}=r.searchIn(a);l&&s.push({score:c,key:e,value:a,idx:o,norm:i,indices:u})});else{const{v:a,n:o}=n,{isMatch:i,score:l,indices:c}=r.searchIn(a);i&&s.push({score:l,key:e,value:a,norm:o,indices:c})}return s}}_t.version="6.6.2";_t.createIndex=ua;_t.parseIndex=gu;_t.config=Q;_t.parseQuery=ma;Pu($u);const jr=Bt({selectedNode:"",selectedGroup:"",search:"",dataValue:"",filtered:{count:0,items:new Map,groups:new Set}}),$t=()=>({isSearching:U(()=>jr.search!==""),...po(jr)});function Uu(t){return{all:t=t||new Map,on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(s){s(n)}),(r=t.get("*"))&&r.slice().map(function(s){s(e,n)})}}}const Bu=Uu(),Sn=()=>({emitter:Bu});function Wu(t,e){let n=t.nextElementSibling;for(;n;){if(n.matches(e))return n;n=n.nextElementSibling}}function ju(t,e){let n=t.previousElementSibling;for(;n;){if(n.matches(e))return n;n=n.previousElementSibling}}const xu=["command-theme"],Ku={"command-root":""},Gu=R({name:"Command"}),Yu=R({...Gu,props:{theme:{type:String,default:"default"},fuseOptions:{type:Object,default:()=>({threshold:.2,keys:["label"]})}},emits:["select-item"],setup(t,{emit:e}){const n=t,r='[command-item=""]',s="command-item-key",a='[command-group=""]',o="command-group-key",i='[command-group-heading=""]',l=`${r}:not([aria-disabled="true"])`,c=`${r}[aria-selected="true"]`,u="command-item-select",d="data-value";pr("theme",n.theme||"default");const{selectedNode:f,search:y,dataValue:S,filtered:g}=$t(),{emitter:b}=Sn(),p=X(),E=Tn(X(new Map),333),I=Tn(X(new Set),333),L=Tn(X(new Map)),P=U(()=>{const V=[];for(const[re,Y]of E.value.entries())V.push({key:re,label:Y});return V}),T=U(()=>{const V=_t.createIndex(n.fuseOptions.keys,P.value);return new _t(P.value,n.fuseOptions,V)}),N=()=>{var V,re,Y;const oe=B();oe&&(((V=oe.parentElement)==null?void 0:V.firstElementChild)===oe&&((Y=(re=oe.closest(a))==null?void 0:re.querySelector(i))==null||Y.scrollIntoView({block:"nearest"})),oe.scrollIntoView({block:"nearest"}))},B=()=>{var V;return(V=p.value)==null?void 0:V.querySelector(c)},G=(V=p.value)=>{const re=V==null?void 0:V.querySelectorAll(l);return re?Array.from(re):[]},ce=()=>{var V;const re=(V=p.value)==null?void 0:V.querySelectorAll(a);return re?Array.from(re):[]},ge=()=>{const[V]=G();V&&V.getAttribute(s)&&(f.value=V.getAttribute(s)||"")},ae=V=>{const re=G()[V];re&&(f.value=re.getAttribute(s)||"")},_e=V=>{const re=B(),Y=G(),oe=Y.findIndex(Se=>Se===re),Le=Y[oe+V];Le?f.value=Le.getAttribute(s)||"":V>0?ae(0):ae(Y.length-1)},Ne=V=>{const re=B();let Y=re==null?void 0:re.closest(a),oe=null;for(;Y&&!oe;)Y=V>0?Wu(Y,a):ju(Y,a),oe=Y==null?void 0:Y.querySelector(l);oe?f.value=oe.getAttribute(s)||"":_e(V)},Te=()=>ae(0),tt=()=>ae(G().length-1),De=V=>{V.preventDefault(),V.metaKey?tt():V.altKey?Ne(1):_e(1)},nt=V=>{V.preventDefault(),V.metaKey?Te():V.altKey?Ne(-1):_e(-1)},Ee=V=>{switch(V.key){case"n":case"j":{V.ctrlKey&&De(V);break}case"ArrowDown":{De(V);break}case"p":case"k":{V.ctrlKey&&nt(V);break}case"ArrowUp":{nt(V);break}case"Home":{Te();break}case"End":{tt();break}case"Enter":{const re=B();if(re){const Y=new Event(u);re.dispatchEvent(Y)}}}},rt=()=>{if(!y.value){g.value.count=I.value.size;return}g.value.groups=new Set("");const V=new Map,re=T.value.search(y.value).map(Y=>Y.item);for(const{key:Y,label:oe}of re)V.set(Y,oe);for(const[Y,oe]of L.value)for(const Le of oe)V.get(Le)&&g.value.groups.add(Y);Ue(()=>{g.value.count=V.size,g.value.items=V})},J=()=>{const V=G(),re=ce();for(const Y of V){const oe=Y.getAttribute(s)||"",Le=Y.getAttribute(d)||"";I.value.add(oe),E.value.set(oe,Le),g.value.count=E.value.size}for(const Y of re){const oe=G(Y),Le=Y.getAttribute(o)||"",Se=new Set("");for(const vt of oe){const Fe=vt.getAttribute(s)||"";Se.add(Fe)}L.value.set(Le,Se)}};pe(()=>f.value,V=>{V&&Ue(N)},{deep:!0}),pe(()=>y.value,V=>{rt(),Ue(ge)}),b.on("selectItem",V=>{e("select-item",V)});const te=ra(V=>{V&&(J(),Ue(ge))},100);return b.on("rerenderList",te),Ye(()=>{J(),ge()}),(V,re)=>(_(),A("div",{class:ue(t.theme),onKeydown:Ee,ref_key:"commandRef",ref:p,"command-theme":t.theme},[w("div",Ku,[C(V.$slots,"default")])],42,xu))}}),Pt=(t,e)=>{const n=t.__vccOpts||t;for(const[r,s]of e)n[r]=s;return n},Qn=Pt(Yu,[["__file","/Users/xiaoyunwei/Documents/GitHub/oss/vue-command-palette/packages/Command.vue"]]),zu={"command-dialog":""},Xu={"command-dialog-mask":""},qu={"command-dialog-wrapper":""},Ju={"command-dialog-header":""},Qu={"command-dialog-body":""},Zu={key:0,"command-dialog-footer":""},ed=R({name:"Command.Dialog"}),td=R({...ed,props:{visible:{type:Boolean,required:!0},theme:{type:String,required:!0}},emits:["select-item"],setup(t,{emit:e}){const n=t,{search:r,filtered:s}=$t(),{emitter:a}=Sn(),o=X();a.on("selectItem",l=>{e("select-item",l)});const i=()=>{r.value="",s.value.count=0,s.value.items=new Map,s.value.groups=new Set};return sa(()=>n.visible,i),kn(i),(l,c)=>(_(),K(mo,{to:"body",ref_key:"dialogRef",ref:o},[x(_n,{name:"command-dialog",appear:""},{default:M(()=>[t.visible?(_(),K(Qn,{key:0,theme:t.theme},{default:M(()=>[w("div",zu,[w("div",Xu,[w("div",qu,[w("div",Ju,[C(l.$slots,"header")]),w("div",Qu,[C(l.$slots,"body")]),l.$slots.footer?(_(),A("div",Zu,[C(l.$slots,"footer")])):j("v-if",!0)])])])]),_:3},8,["theme"])):j("v-if",!0)]),_:3})],512))}}),nd=Pt(td,[["__file","/Users/xiaoyunwei/Documents/GitHub/oss/vue-command-palette/packages/CommandDialog.vue"]]);let pa=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,n)=>(n&=63,n<36?e+=n.toString(36):n<62?e+=(n-26).toString(36).toUpperCase():n>62?e+="-":e+="_",e),"");const rd=["command-group-key","data-value"],sd={key:0,"command-group-heading":""},ad={"command-group-items":"",role:"group"},od=R({name:"Command.Group"}),id=R({...od,props:{heading:{type:String,required:!0}},setup(t){const e=U(()=>`command-group-${pa()}`),{filtered:n,isSearching:r}=$t(),s=U(()=>r.value?n.value.groups.has(e.value):!0);return(a,o)=>Gs((_(),A("div",{"command-group":"",role:"presentation",key:v(e),"command-group-key":v(e),"data-value":t.heading},[t.heading?(_(),A("div",sd,Z(t.heading),1)):j("v-if",!0),w("div",ad,[C(a.$slots,"default")])],8,rd)),[[Ys,v(s)]])}}),ld=Pt(id,[["__file","/Users/xiaoyunwei/Documents/GitHub/oss/vue-command-palette/packages/CommandGroup.vue"]]),cd=["placeholder","value"],ud=R({name:"Command.Input"}),dd=R({...ud,props:{placeholder:{type:String,required:!0},value:{type:String,required:!1}},emits:["input","update:value"],setup(t,{emit:e}){const n=X(null),{search:r}=$t(),s=U(()=>r.value),a=o=>{const i=o,l=o.target;r.value=l==null?void 0:l.value,e("input",i),e("update:value",r.value)};return it(()=>{var o;(o=n.value)==null||o.focus()}),(o,i)=>(_(),A("input",{ref_key:"inputRef",ref:n,"command-input":"","auto-focus":"","auto-complete":"off","auto-correct":"off","spell-check":!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,placeholder:t.placeholder,value:v(s),onInput:a},null,40,cd))}}),fd=Pt(dd,[["__file","/Users/xiaoyunwei/Documents/GitHub/oss/vue-command-palette/packages/CommandInput.vue"]]),hd=["aria-selected","aria-disabled","command-item-key"],md=R({name:"Command.Item"}),pd=R({...md,props:{shortcut:{type:Array,required:!1},perform:{type:null,required:!1}},emits:["select"],setup(t,{emit:e}){const n=t,r="command-item-select",s="data-value",{current:a}=zc(),{selectedNode:o,filtered:i,isSearching:l}=$t(),{emitter:c}=Sn(),u=X(),d=U(()=>`command-item-${pa()}`),f=U(()=>{const g=i.value.items.get(d.value);return l.value?g!==void 0:!0}),y=U(()=>Array.from(a)),S=()=>{var g;const b={key:d.value,value:((g=u.value)==null?void 0:g.getAttribute(s))||""};e("select",b),c.emit("selectItem",b)};return sa(y,g=>{n.shortcut&&n.shortcut.length>0&&n.shortcut.every(b=>a.has(b.toLowerCase()))&&n.perform&&n.perform()}),it(()=>{var g;(g=u.value)==null||g.addEventListener(r,S)}),kn(()=>{var g;(g=u.value)==null||g.removeEventListener(r,S)}),(g,b)=>Gs((_(),A("div",{ref_key:"itemRef",ref:u,"command-item":"",role:"option","aria-selected":v(o)===v(d),"aria-disabled":!v(f),key:v(d),"command-item-key":v(d),onClick:S},[C(g.$slots,"default")],8,hd)),[[Ys,v(f)]])}}),_d=Pt(pd,[["__file","/Users/xiaoyunwei/Documents/GitHub/oss/vue-command-palette/packages/CommandItem.vue"]]),vd=R({name:"Command.List"}),gd=R({...vd,setup(t){const{emitter:e}=Sn(),n=X(),r=X();let s=null,a;return it(()=>{a=r.value;const o=n.value;a&&o&&(s=new ResizeObserver(i=>{Ue(()=>{const l=a==null?void 0:a.offsetHeight;o==null||o.style.setProperty("--command-list-height",`${l==null?void 0:l.toFixed(1)}px`),e.emit("rerenderList",!0)})}),s.observe(a))}),kn(()=>{s!==null&&a&&s.unobserve(a)}),(o,i)=>(_(),A("div",{"command-list":"",role:"listbox","aria-label":"Suggestions",ref_key:"listRef",ref:n},[w("div",{"command-list-sizer":"",ref_key:"heightRef",ref:r},[C(o.$slots,"default")],512)],512))}}),bd=Pt(gd,[["__file","/Users/xiaoyunwei/Documents/GitHub/oss/vue-command-palette/packages/CommandList.vue"]]),yd=R({name:"Command.Empty",setup(t,{attrs:e,slots:n}){const{filtered:r}=$t(),s=U(()=>r.value.count===0);return()=>s.value?Ct("div",{"command-empty":"",role:"presentation",...e},n):Ct("div",{"command-empty":"hidden",role:"presentation",style:{display:"none"},...e})}}),wd=R({name:"Command.Loading",setup(t,{attrs:e,slots:n}){return()=>Ct("div",{"command-loading":"",role:"progressbar",...e},n)}}),kd=R({name:"Command.Separator",setup(t,{attrs:e,slots:n}){return()=>Ct("div",{"command-separator":"",role:"separator",...e})}}),wt=Object.assign(Qn,{Dialog:nd,Empty:yd,Group:ld,Input:fd,Item:_d,List:bd,Loading:wd,Separator:kd,Root:Qn});var xr;const _a=typeof window<"u",Ld=t=>typeof t=="function",Sd=t=>typeof t=="string",va=()=>{};_a&&((xr=window==null?void 0:window.navigator)!=null&&xr.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);function Lr(t){return typeof t=="function"?t():v(t)}function Ed(t,e){function n(...r){return new Promise((s,a)=>{Promise.resolve(t(()=>e.apply(this,r),{fn:e,thisArg:this,args:r})).then(s).catch(a)})}return n}const ga=t=>t();function Od(t=ga){const e=X(!0);function n(){e.value=!1}function r(){e.value=!0}const s=(...a)=>{e.value&&t(...a)};return{isActive:Ks(e),pause:n,resume:r,eventFilter:s}}function Cd(t){return t}function Ad(t){return zs()?(Xs(t),!0):!1}var Kr=Object.getOwnPropertySymbols,Id=Object.prototype.hasOwnProperty,Md=Object.prototype.propertyIsEnumerable,Nd=(t,e)=>{var n={};for(var r in t)Id.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&Kr)for(var r of Kr(t))e.indexOf(r)<0&&Md.call(t,r)&&(n[r]=t[r]);return n};function $d(t,e,n={}){const r=n,{eventFilter:s=ga}=r,a=Nd(r,["eventFilter"]);return pe(t,Ed(s,e),a)}var Pd=Object.defineProperty,Td=Object.defineProperties,Fd=Object.getOwnPropertyDescriptors,fn=Object.getOwnPropertySymbols,ba=Object.prototype.hasOwnProperty,ya=Object.prototype.propertyIsEnumerable,Gr=(t,e,n)=>e in t?Pd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Rd=(t,e)=>{for(var n in e||(e={}))ba.call(e,n)&&Gr(t,n,e[n]);if(fn)for(var n of fn(e))ya.call(e,n)&&Gr(t,n,e[n]);return t},Vd=(t,e)=>Td(t,Fd(e)),Dd=(t,e)=>{var n={};for(var r in t)ba.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&fn)for(var r of fn(t))e.indexOf(r)<0&&ya.call(t,r)&&(n[r]=t[r]);return n};function Hd(t,e,n={}){const r=n,{eventFilter:s}=r,a=Dd(r,["eventFilter"]),{eventFilter:o,pause:i,resume:l,isActive:c}=Od(s);return{stop:$d(t,e,Vd(Rd({},a),{eventFilter:o})),pause:i,resume:l,isActive:c}}function Ud(t){var e;const n=Lr(t);return(e=n==null?void 0:n.$el)!=null?e:n}const jt=_a?window:void 0;function Et(...t){let e,n,r,s;if(Sd(t[0])||Array.isArray(t[0])?([n,r,s]=t,e=jt):[e,n,r,s]=t,!e)return va;Array.isArray(n)||(n=[n]),Array.isArray(r)||(r=[r]);const a=[],o=()=>{a.forEach(u=>u()),a.length=0},i=(u,d,f,y)=>(u.addEventListener(d,f,y),()=>u.removeEventListener(d,f,y)),l=pe(()=>[Ud(e),Lr(s)],([u,d])=>{o(),u&&a.push(...n.flatMap(f=>r.map(y=>i(u,f,y,d))))},{immediate:!0,flush:"post"}),c=()=>{l(),o()};return Ad(c),c}const Zn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},er="__vueuse_ssr_handlers__";Zn[er]=Zn[er]||{};const Bd=Zn[er];function Wd(t,e){return Bd[t]||e}function jd(t){return t==null?"any":t instanceof Set?"set":t instanceof Map?"map":t instanceof Date?"date":typeof t=="boolean"?"boolean":typeof t=="string"?"string":typeof t=="object"?"object":Number.isNaN(t)?"any":"number"}var xd=Object.defineProperty,Yr=Object.getOwnPropertySymbols,Kd=Object.prototype.hasOwnProperty,Gd=Object.prototype.propertyIsEnumerable,zr=(t,e,n)=>e in t?xd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Xr=(t,e)=>{for(var n in e||(e={}))Kd.call(e,n)&&zr(t,n,e[n]);if(Yr)for(var n of Yr(e))Gd.call(e,n)&&zr(t,n,e[n]);return t};const Yd={boolean:{read:t=>t==="true",write:t=>String(t)},object:{read:t=>JSON.parse(t),write:t=>JSON.stringify(t)},number:{read:t=>Number.parseFloat(t),write:t=>String(t)},any:{read:t=>t,write:t=>String(t)},string:{read:t=>t,write:t=>String(t)},map:{read:t=>new Map(JSON.parse(t)),write:t=>JSON.stringify(Array.from(t.entries()))},set:{read:t=>new Set(JSON.parse(t)),write:t=>JSON.stringify(Array.from(t))},date:{read:t=>new Date(t),write:t=>t.toISOString()}},qr="vueuse-storage";function zd(t,e,n,r={}){var s;const{flush:a="pre",deep:o=!0,listenToStorageChanges:i=!0,writeDefaults:l=!0,mergeDefaults:c=!1,shallow:u,window:d=jt,eventFilter:f,onError:y=B=>{console.error(B)}}=r,S=(u?bn:X)(e);if(!n)try{n=Wd("getDefaultStorage",()=>{var B;return(B=jt)==null?void 0:B.localStorage})()}catch(B){y(B)}if(!n)return S;const g=Lr(e),b=jd(g),p=(s=r.serializer)!=null?s:Yd[b],{pause:E,resume:I}=Hd(S,()=>L(S.value),{flush:a,deep:o,eventFilter:f});return d&&i&&(Et(d,"storage",N),Et(d,qr,T)),N(),S;function L(B){try{if(B==null)n.removeItem(t);else{const G=p.write(B),ce=n.getItem(t);ce!==G&&(n.setItem(t,G),d&&d.dispatchEvent(new CustomEvent(qr,{detail:{key:t,oldValue:ce,newValue:G,storageArea:n}})))}}catch(G){y(G)}}function P(B){const G=B?B.newValue:n.getItem(t);if(G==null)return l&&g!==null&&n.setItem(t,p.write(g)),g;if(!B&&c){const ce=p.read(G);return Ld(c)?c(ce,g):b==="object"&&!Array.isArray(ce)?Xr(Xr({},g),ce):ce}else return typeof G!="string"?G:p.read(G)}function T(B){N(B.detail)}function N(B){if(!(B&&B.storageArea!==n)){if(B&&B.key==null){S.value=g;return}if(!(B&&B.key!==t)){E();try{S.value=P(B)}catch(G){y(G)}finally{B?Ue(I):I()}}}}}function Xd(t,e,n={}){const{window:r=jt}=n;return zd(t,e,r==null?void 0:r.localStorage,n)}const qd={ctrl:"control",command:"meta",cmd:"meta",option:"alt",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright"};function Jd(t={}){const{reactive:e=!1,target:n=jt,aliasMap:r=qd,passive:s=!0,onEventFired:a=va}=t,o=Bt(new Set),i={toJSON(){return{}},current:o},l=e?Bt(i):i,c=new Set,u=new Set;function d(g,b){g in l&&(e?l[g]=b:l[g].value=b)}function f(){o.clear();for(const g of u)d(g,!1)}function y(g,b){var p,E;const I=(p=g.key)==null?void 0:p.toLowerCase(),P=[(E=g.code)==null?void 0:E.toLowerCase(),I].filter(Boolean);I&&(b?o.add(I):o.delete(I));for(const T of P)u.add(T),d(T,b);I==="meta"&&!b?(c.forEach(T=>{o.delete(T),d(T,!1)}),c.clear()):typeof g.getModifierState=="function"&&g.getModifierState("Meta")&&b&&[...o,...P].forEach(T=>c.add(T))}Et(n,"keydown",g=>(y(g,!0),a(g)),{passive:s}),Et(n,"keyup",g=>(y(g,!1),a(g)),{passive:s}),Et("blur",f,{passive:!0}),Et("focus",f,{passive:!0});const S=new Proxy(l,{get(g,b,p){if(typeof b!="string")return Reflect.get(g,b,p);if(b=b.toLowerCase(),b in r&&(b=r[b]),!(b in l))if(/[+_-]/.test(b)){const I=b.split(/[+_-]/g).map(L=>L.trim());l[b]=U(()=>I.every(L=>v(S[L])))}else l[b]=X(!1);const E=Reflect.get(g,b,p);return e?v(E):E}});return S}var Jr;(function(t){t.UP="UP",t.RIGHT="RIGHT",t.DOWN="DOWN",t.LEFT="LEFT",t.NONE="NONE"})(Jr||(Jr={}));var Qd=Object.defineProperty,Qr=Object.getOwnPropertySymbols,Zd=Object.prototype.hasOwnProperty,ef=Object.prototype.propertyIsEnumerable,Zr=(t,e,n)=>e in t?Qd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,tf=(t,e)=>{for(var n in e||(e={}))Zd.call(e,n)&&Zr(t,n,e[n]);if(Qr)for(var n of Qr(e))ef.call(e,n)&&Zr(t,n,e[n]);return t};const nf={easeInSine:[.12,0,.39,0],easeOutSine:[.61,1,.88,1],easeInOutSine:[.37,0,.63,1],easeInQuad:[.11,0,.5,0],easeOutQuad:[.5,1,.89,1],easeInOutQuad:[.45,0,.55,1],easeInCubic:[.32,0,.67,0],easeOutCubic:[.33,1,.68,1],easeInOutCubic:[.65,0,.35,1],easeInQuart:[.5,0,.75,0],easeOutQuart:[.25,1,.5,1],easeInOutQuart:[.76,0,.24,1],easeInQuint:[.64,0,.78,0],easeOutQuint:[.22,1,.36,1],easeInOutQuint:[.83,0,.17,1],easeInExpo:[.7,0,.84,0],easeOutExpo:[.16,1,.3,1],easeInOutExpo:[.87,0,.13,1],easeInCirc:[.55,0,1,.45],easeOutCirc:[0,.55,.45,1],easeInOutCirc:[.85,0,.15,1],easeInBack:[.36,0,.66,-.56],easeOutBack:[.34,1.56,.64,1],easeInOutBack:[.68,-.6,.32,1.6]};tf({linear:Cd},nf);const rf={locales:{root:{btnPlaceholder:"Search",placeholder:"Search Docs...",emptyText:"No results",heading:"Total: {{searchResult}} search results."},zh:{customSearchQuery(t){return t.replace(/[\u4e00-\u9fa5]/g," $& ").replace(/\s+/g," ").trim()},btnPlaceholder:"搜索",placeholder:"搜索文档",emptyText:"空空如也",heading:"共:{{searchResult}} 条结果",showDate:!1}}},sf={},af={width:"594",height:"112",viewBox:"0 0 594 112",fill:"none",xmlns:"http://www.w3.org/2000/svg"};function of(t,e){return _(),A("svg",af,e[0]||(e[0]=[_o('',11)]))}const lf=q(sf,[["render",of]]);function cf(t){if(!t)return{};try{const e=decodeURIComponent(atob(t));return JSON.parse(e)}catch{return{}}}function uf(t,e=1){const{sub_results:n,anchors:r,weighted_locations:s}=t;s.sort((i,l)=>l.weight===i.weight?i.location-l.location:l.weight-i.weight);const a=[];for(const{location:i}of s){const c=n.filter(u=>{const{locations:d}=u,[f]=d||[];if(!f)return!1;const y=d.length===1?Number.POSITIVE_INFINITY:d[d.length-1];return f<=i&&i<=y}).reduce((u,d)=>u&&u.locations.length>d.locations.length?u:d,null);if(c&&(a.push(c),a.length>=e))break}a.sort((i,l)=>{const[c]=i.locations||[],[u]=l.locations||[];return!c||!u?0:c-u});const o=new Map;return a.map(i=>df(i,r,t)).filter(i=>o.has(i.meta.title)?!1:(o.set(i.meta.title,i),!0))}function df(t,e,n){const r=(t==null?void 0:t.url)||(n==null?void 0:n.url),s=(t==null?void 0:t.excerpt)||(n==null?void 0:n.excerpt),a=(e==null?void 0:e.filter(u=>t?u.location<=t.anchor.location&&u.element<=t.anchor.element:!1))||[];a.reverse();const o=a.reduce((u,d)=>(u.some(y=>y.element===d.element)||u.unshift(d),u),[]),i=o.length?o.map(u=>u.text.trim()).filter(u=>!!u).join(" > "):n.meta.title,{base64:l,...c}=n.meta;return{route:r,meta:{...cf(l),...c,title:i,description:s},result:n}}function ff(t,e="yyyy-MM-dd hh:mm:ss"){t instanceof Date||(t=new Date(t));const n={"M+":t.getMonth()+1,"d+":t.getDate(),"h+":t.getHours(),"m+":t.getMinutes(),"s+":t.getSeconds(),"q+":Math.floor((t.getMonth()+3)/3),S:t.getMilliseconds()};/(y+)/.test(e)&&(e=e.replace(RegExp.$1,`${t.getFullYear()}`.substr(4-RegExp.$1.length)));for(const r in n)new RegExp(`(${r})`).test(e)&&(e=e.replace(RegExp.$1,RegExp.$1.length===1?n[r]:`00${n[r]}`.substr(`${n[r]}`.length)));return e}function hf(t,e){const n=+new Date(t),s=+new Date-n,a=1e3,o=a*60,i=o*60,l=i*24,c=l*7,u={"zh-cn":{justNow:"刚刚",secondsAgo:"秒前",minutesAgo:"分钟前",hoursAgo:"小时前",daysAgo:"天前",weeksAgo:"周前"},"en-us":{justNow:" just now",secondsAgo:" seconds ago",minutesAgo:" minutes ago",hoursAgo:" hours ago",daysAgo:" days ago",weeksAgo:" weeks ago"}},d=u[e.toLowerCase()]||u["en-us"];return s<10?d.justNow:s{var J;return{...n,...((J=n==null?void 0:n.locales)==null?void 0:J[r.value])||{}}}),i=U(()=>{var J;return((J=o.value)==null?void 0:J.ignorePublish)??!1}),l=U(()=>{var J;return((J=o.value)==null?void 0:J.showDate)??!1}),c=U(()=>typeof o.value.showDate=="function"?o.value.showDate:hf),u=U(()=>{var J;return(J=o.value)!=null&&J.heading?o.value.heading.replace(/\{\{searchResult\}\}/,`${e.value.length}`):`Total: ${e.value.length} search results.`}),d=X("");Ye(()=>{d.value=/(Mac|iPhone|iPod|iPad)/i.test(navigator==null?void 0:navigator.platform)?"⌘":"Ctrl"});const f=X(!1);function y(){f.value=!0}function S(){f.value=!1}const g=Jd({passive:!1,onEventFired(J){J.ctrlKey&&J.key==="k"&&J.type==="keydown"&&J.preventDefault()}}),b=g["Meta+K"],p=g["Ctrl+K"],E=g.Escape;pe(b,J=>{J&&y()}),pe(p,J=>{J&&y()}),pe(E,J=>{J&&S()});const I=X("");function L(){if(!I.value){e.value=[];return}e.value=[{route:"#",meta:{title:"只在构建后才生效",description:"only support after build, only support after build"}}]}const P=/[\u4E00-\u9FA5]/g,T=(Intl==null?void 0:Intl.Segmenter)&&new Intl.Segmenter("ch",{granularity:"word"});function N(J){return T?Array.from(T==null?void 0:T.segment(J)).map(V=>V.segment).join(" "):J.replace(P," $& ").replace(/\s+/g," ").trim()}const B=U(()=>{var J;return((J=o.value)==null?void 0:J.delay)??300});pe(()=>I.value,async()=>{var te,V,re;if(!((te=window==null?void 0:window.__pagefind__)!=null&&te.search)){L();return}const J=typeof o.value.customSearchQuery=="function"?o.value.customSearchQuery(I.value):P.test(I.value)?N(I.value):I.value;await((re=(V=window==null?void 0:window.__pagefind__)==null?void 0:V.debouncedSearch)==null?void 0:re.call(V,J,{},B.value).then(async Y=>{if(Y===null)return;const Le=(await Promise.all(Y.results.map(Se=>Se.data()))).map(Se=>uf(Se,o.value.pageResultCount||1).map(Fe=>(Fe.route=Fe.route.startsWith(s.value.base)?Fe.route:vn(Fe.route),Fe))).flat().filter(Se=>i.value||Se.meta.publish!==!1);o.value.sort&&Le.sort(o.value.sort),e.value=Le.filter(o.value.filter??(()=>!0))})),Ue(()=>{document.querySelectorAll('div[aria-disabled="true"]').forEach(Y=>{Y.setAttribute("aria-disabled","false")})})});function G(J){J.target===J.currentTarget&&S()}pe(()=>f.value,J=>{var te;J?Ue(()=>{var V;(V=document.querySelector("div[command-dialog-mask]"))==null||V.addEventListener("click",G)}):(te=document.querySelector("div[command-dialog-mask]"))==null||te.removeEventListener("click",G)});const ce=X(999),ge=X(0),ae=U(()=>{const te=ge.value%Math.ceil(e.value.length/ce.value)*ce.value;return e.value.slice(te,te+ce.value)}),_e=vo(),Ne=Yt();function Te(J){S(),Ne.path!==J.value&&_e.go(J.value)}const tt=U(()=>o.value.langReload??!0);pe(()=>a.value,()=>{tt.value&&window.location.reload()});const De=X();function nt(){I.value="",Ue(()=>{De.value&&(De.value.$el.value="")})}const Ee=Xd("pagefind-search-showDetail",!1);function rt(){Ee.value=!Ee.value}return(J,te)=>{var re;const V=lt("ClientOnly");return _(),A("div",mf,[w("div",{class:"nav-search-btn-wait",onClick:te[0]||(te[0]=Y=>f.value=!0)},[te[3]||(te[3]=w("span",null,[w("svg",{width:"14",height:"14",viewBox:"0 0 20 20"},[w("path",{d:"M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z",stroke:"currentColor",fill:"none","fill-rule":"evenodd","stroke-linecap":"round","stroke-linejoin":"round"})])],-1)),w("span",pf,Z(((re=o.value)==null?void 0:re.btnPlaceholder)||"Search"),1),w("span",_f,Z(d.value)+" K ",1)]),x(V,null,{default:M(()=>[x(v(wt).Dialog,{visible:f.value,theme:"algolia"},go({header:M(()=>{var Y;return[w("div",vf,[w("div",gf,[w("button",{class:"back-button",title:"Close search",onClick:te[1]||(te[1]=oe=>f.value=!1)},te[4]||(te[4]=[w("span",{class:"vpi-arrow-left local-search-icon"},null,-1)]))]),x(v(wt).Input,{ref_key:"searchInput",ref:De,value:I.value,"onUpdate:value":te[2]||(te[2]=oe=>I.value=oe),placeholder:((Y=o.value)==null?void 0:Y.placeholder)||"Search Docs"},null,8,["value","placeholder"]),w("div",bf,[w("button",{class:ue([{active:v(Ee)},"toggle-layout-button"]),type:"button",title:"Display detailed list",onClick:rt},te[5]||(te[5]=[w("span",{class:"vpi-layout-list local-search-icon"},null,-1)]),2),w("button",{disabled:!I.value,class:"clear-button",type:"reset",title:"Reset search",onClick:nt},te[6]||(te[6]=[w("span",{class:"vpi-delete local-search-icon"},null,-1)]),8,yf)])])]}),body:M(()=>[w("div",{class:ue(["search-dialog",{"detail-list":v(Ee)}])},[x(v(wt).List,null,{default:M(()=>[e.value.length?(_(),K(v(wt).Group,{key:1,heading:u.value},{default:M(()=>[(_(!0),A(he,null,Ce(ae.value,Y=>(_(),K(v(wt).Item,{key:Y.route,"data-value":Y.route,onSelect:Te},{default:M(()=>[w("div",wf,[w("div",kf,[w("span",Lf,[Y.meta.title?(_(),A("i",Sf,"# ")):j("",!0),Ve(Z(Y.meta.title),1)]),l.value&&Y.meta.date?(_(),A("span",Ef,Z(c.value(Y.meta.date,v(a))),1)):j("",!0)]),w("div",{class:"des",innerHTML:Y.meta.description},null,8,Of)])]),_:2},1032,["data-value"]))),128))]),_:1},8,["heading"])):(_(),K(v(wt).Empty,{key:0},{default:M(()=>{var Y;return[Ve(Z(((Y=o.value)==null?void 0:Y.emptyText)||"No results found."),1)]}),_:1}))]),_:1})],2)]),_:2},[e.value.length?{name:"footer",fn:M(()=>{var Y,oe,Le,Se;return[w("div",Cf,[w("a",Af,[w("span",If,Z(((Y=o.value)==null?void 0:Y.searchBy)||"Search by"),1),x(lf,{style:{width:"77px"}})])]),w("ul",Mf,[w("li",null,[te[7]||(te[7]=w("kbd",{class:"command-palette-commands-key"},[w("svg",{width:"15",height:"15","aria-label":"Enter key",role:"img"},[w("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.2"},[w("path",{d:"M12 3.53088v3c0 1-1 2-2 2H4M7 11.53088l-3-3 3-3"})])])],-1)),w("span",Nf,Z(((oe=o.value)==null?void 0:oe.toSelect)||"to select"),1)]),w("li",null,[te[8]||(te[8]=w("kbd",{class:"command-palette-commands-key"},[w("svg",{width:"15",height:"15","aria-label":"Arrow down",role:"img"},[w("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.2"},[w("path",{d:"M7.5 3.5v8M10.5 8.5l-3 3-3-3"})])])],-1)),te[9]||(te[9]=w("kbd",{class:"command-palette-commands-key"},[w("svg",{width:"15",height:"15","aria-label":"Arrow up",role:"img"},[w("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.2"},[w("path",{d:"M7.5 11.5v-8M10.5 6.5l-3-3-3 3"})])])],-1)),w("span",$f,Z(((Le=o.value)==null?void 0:Le.toNavigate)||"to navigate"),1)]),w("li",null,[te[10]||(te[10]=w("kbd",{class:"command-palette-commands-key"},[w("svg",{width:"15",height:"15","aria-label":"Escape key",role:"img"},[w("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.2"},[w("path",{d:"M13.6167 8.936c-.1065.3583-.6883.962-1.4875.962-.7993 0-1.653-.9165-1.653-2.1258v-.5678c0-1.2548.7896-2.1016 1.653-2.1016.8634 0 1.3601.4778 1.4875 1.0724M9 6c-.1352-.4735-.7506-.9219-1.46-.8972-.7092.0246-1.344.57-1.344 1.2166s.4198.8812 1.3445.9805C8.465 7.3992 8.968 7.9337 9 8.5c.032.5663-.454 1.398-1.4595 1.398C6.6593 9.898 6 9 5.963 8.4851m-1.4748.5368c-.2635.5941-.8099.876-1.5443.876s-1.7073-.6248-1.7073-2.204v-.4603c0-1.0416.721-2.131 1.7073-2.131.9864 0 1.6425 1.031 1.5443 2.2492h-2.956"})])])],-1)),w("span",Pf,Z(((Se=o.value)==null?void 0:Se.toClose)||"to close"),1)])])]}),key:"0"}:void 0]),1032,["visible"])]),_:1})])}}}),Ff=q(Tf,[["__scopeId","data-v-fd998d3a"]]),Rf=R({__name:"VPNavBarSocialLinks",setup(t){const{theme:e}=se();return(n,r)=>v(e).socialLinks?(_(),K(wr,{key:0,class:"VPNavBarSocialLinks",links:v(e).socialLinks},null,8,["links"])):j("",!0)}}),Vf=q(Rf,[["__scopeId","data-v-f5212745"]]),Df=["href","rel","target"],Hf={key:1},Uf={key:2},Bf=R({__name:"VPNavBarTitle",setup(t){const{site:e,theme:n}=se(),{hasSidebar:r}=et(),{currentLang:s}=zt(),a=U(()=>{var l;return typeof n.value.logoLink=="string"?n.value.logoLink:(l=n.value.logoLink)==null?void 0:l.link}),o=U(()=>{var l;return typeof n.value.logoLink=="string"||(l=n.value.logoLink)==null?void 0:l.rel}),i=U(()=>{var l;return typeof n.value.logoLink=="string"||(l=n.value.logoLink)==null?void 0:l.target});return(l,c)=>(_(),A("div",{class:ue(["VPNavBarTitle",{"has-sidebar":v(r)}])},[w("a",{class:"title",href:a.value??v(_r)(v(s).link),rel:o.value,target:i.value},[C(l.$slots,"nav-bar-title-before",{},void 0,!0),v(n).logo?(_(),K(un,{key:0,class:"logo",image:v(n).logo},null,8,["image"])):j("",!0),v(n).siteTitle?(_(),A("span",Hf,Z(v(n).siteTitle),1)):v(n).siteTitle===void 0?(_(),A("span",Uf,Z(v(e).title),1)):j("",!0),C(l.$slots,"nav-bar-title-after",{},void 0,!0)],8,Df)],2))}}),Wf=q(Bf,[["__scopeId","data-v-c5769ebc"]]),jf={class:"items"},xf={class:"title"},Kf=R({__name:"VPNavBarTranslations",setup(t){const{theme:e}=se(),{localeLinks:n,currentLang:r}=zt({correspondingLink:!0});return(s,a)=>v(n).length&&v(r).label?(_(),K(yr,{key:0,class:"VPNavBarTranslations",icon:"vpi-languages",label:v(e).langMenuLabel||"Change language"},{default:M(()=>[w("div",jf,[w("p",xf,Z(v(r).label),1),(_(!0),A(he,null,Ce(v(n),o=>(_(),K(Ln,{key:o.link,item:o},null,8,["item"]))),128))])]),_:1},8,["label"])):j("",!0)}}),Gf=q(Kf,[["__scopeId","data-v-2f66930a"]]),Yf={class:"wrapper"},zf={class:"container"},Xf={class:"title"},qf={class:"content"},Jf={class:"content-body"},Qf=R({__name:"VPNavBar",props:{isScreenOpen:{type:Boolean}},emits:["toggle-screen"],setup(t){const e=t,{y:n}=xs(),{hasSidebar:r}=et(),{frontmatter:s}=se(),a=X({});return mr(()=>{a.value={"has-sidebar":r.value,home:s.value.layout==="home",top:n.value===0,"screen-open":e.isScreenOpen}}),(o,i)=>(_(),A("div",{class:ue(["VPNavBar",a.value])},[w("div",Yf,[w("div",zf,[w("div",Xf,[x(Wf,null,{"nav-bar-title-before":M(()=>[C(o.$slots,"nav-bar-title-before",{},void 0,!0)]),"nav-bar-title-after":M(()=>[C(o.$slots,"nav-bar-title-after",{},void 0,!0)]),_:3})]),w("div",qf,[w("div",Jf,[C(o.$slots,"nav-bar-content-before",{},void 0,!0),x(Ff,{class:"search"}),x(Uc,{class:"menu"}),x(Gf,{class:"translations"}),x(ql,{class:"appearance"}),x(Vf,{class:"social-links"}),x(Mc,{class:"extra"}),C(o.$slots,"nav-bar-content-after",{},void 0,!0),x(Pc,{class:"hamburger",active:o.isScreenOpen,onClick:i[0]||(i[0]=l=>o.$emit("toggle-screen"))},null,8,["active"])])])])]),i[1]||(i[1]=w("div",{class:"divider"},[w("div",{class:"divider-line"})],-1))],2))}}),Zf=q(Qf,[["__scopeId","data-v-ff85f401"]]),eh={key:0,class:"VPNavScreenAppearance"},th={class:"text"},nh=R({__name:"VPNavScreenAppearance",setup(t){const{site:e,theme:n}=se();return(r,s)=>v(e).appearance&&v(e).appearance!=="force-dark"&&v(e).appearance!=="force-auto"?(_(),A("div",eh,[w("p",th,Z(v(n).darkModeSwitchLabel||"Appearance"),1),x(gr)])):j("",!0)}}),rh=q(nh,[["__scopeId","data-v-5843b201"]]),sh=R({__name:"VPNavScreenMenuLink",props:{item:{}},setup(t){const e=Nt("close-screen");return(n,r)=>(_(),K(je,{class:"VPNavScreenMenuLink",href:n.item.link,target:n.item.target,rel:n.item.rel,onClick:v(e),innerHTML:n.item.text},null,8,["href","target","rel","onClick","innerHTML"]))}}),ah=q(sh,[["__scopeId","data-v-f4793bdd"]]),oh=R({__name:"VPNavScreenMenuGroupLink",props:{item:{}},setup(t){const e=Nt("close-screen");return(n,r)=>(_(),K(je,{class:"VPNavScreenMenuGroupLink",href:n.item.link,target:n.item.target,rel:n.item.rel,onClick:v(e)},{default:M(()=>[Ve(Z(n.item.text),1)]),_:1},8,["href","target","rel","onClick"]))}}),wa=q(oh,[["__scopeId","data-v-cd8761c3"]]),ih={class:"VPNavScreenMenuGroupSection"},lh={key:0,class:"title"},ch=R({__name:"VPNavScreenMenuGroupSection",props:{text:{},items:{}},setup(t){return(e,n)=>(_(),A("div",ih,[e.text?(_(),A("p",lh,Z(e.text),1)):j("",!0),(_(!0),A(he,null,Ce(e.items,r=>(_(),K(wa,{key:r.text,item:r},null,8,["item"]))),128))]))}}),uh=q(ch,[["__scopeId","data-v-484b10b7"]]),dh=["aria-controls","aria-expanded"],fh=["innerHTML"],hh=["id"],mh={key:0,class:"item"},ph={key:1,class:"item"},_h={key:2,class:"group"},vh=R({__name:"VPNavScreenMenuGroup",props:{text:{},items:{}},setup(t){const e=t,n=X(!1),r=U(()=>`NavScreenGroup-${e.text.replace(" ","-").toLowerCase()}`);function s(){n.value=!n.value}return(a,o)=>(_(),A("div",{class:ue(["VPNavScreenMenuGroup",{open:n.value}])},[w("button",{class:"button","aria-controls":r.value,"aria-expanded":n.value,onClick:s},[w("span",{class:"button-text",innerHTML:a.text},null,8,fh),o[0]||(o[0]=w("span",{class:"vpi-plus button-icon"},null,-1))],8,dh),w("div",{id:r.value,class:"items"},[(_(!0),A(he,null,Ce(a.items,i=>(_(),A(he,{key:JSON.stringify(i)},["link"in i?(_(),A("div",mh,[x(wa,{item:i},null,8,["item"])])):"component"in i?(_(),A("div",ph,[(_(),K(We(i.component),at({ref_for:!0},i.props,{"screen-menu":""}),null,16))])):(_(),A("div",_h,[x(uh,{text:i.text,items:i.items},null,8,["text","items"])]))],64))),128))],8,hh)],2))}}),gh=q(vh,[["__scopeId","data-v-d3f01f3b"]]),bh={key:0,class:"VPNavScreenMenu"},yh=R({__name:"VPNavScreenMenu",setup(t){const{theme:e}=se();return(n,r)=>v(e).nav?(_(),A("nav",bh,[(_(!0),A(he,null,Ce(v(e).nav,s=>(_(),A(he,{key:JSON.stringify(s)},["link"in s?(_(),K(ah,{key:0,item:s},null,8,["item"])):"component"in s?(_(),K(We(s.component),at({key:1,ref_for:!0},s.props,{"screen-menu":""}),null,16)):(_(),K(gh,{key:2,text:s.text||"",items:s.items},null,8,["text","items"]))],64))),128))])):j("",!0)}}),wh=R({__name:"VPNavScreenSocialLinks",setup(t){const{theme:e}=se();return(n,r)=>v(e).socialLinks?(_(),K(wr,{key:0,class:"VPNavScreenSocialLinks",links:v(e).socialLinks},null,8,["links"])):j("",!0)}}),kh={class:"list"},Lh=R({__name:"VPNavScreenTranslations",setup(t){const{localeLinks:e,currentLang:n}=zt({correspondingLink:!0}),r=X(!1);function s(){r.value=!r.value}return(a,o)=>v(e).length&&v(n).label?(_(),A("div",{key:0,class:ue(["VPNavScreenTranslations",{open:r.value}])},[w("button",{class:"title",onClick:s},[o[0]||(o[0]=w("span",{class:"vpi-languages icon lang"},null,-1)),Ve(" "+Z(v(n).label)+" ",1),o[1]||(o[1]=w("span",{class:"vpi-chevron-down icon chevron"},null,-1))]),w("ul",kh,[(_(!0),A(he,null,Ce(v(e),i=>(_(),A("li",{key:i.link,class:"item"},[x(je,{class:"link",href:i.link},{default:M(()=>[Ve(Z(i.text),1)]),_:2},1032,["href"])]))),128))])],2)):j("",!0)}}),Sh=q(Lh,[["__scopeId","data-v-4eae6889"]]),Eh={class:"container"},Oh=R({__name:"VPNavScreen",props:{open:{type:Boolean}},setup(t){const e=X(null),n=qs(wn?document.body:null);return(r,s)=>(_(),K(_n,{name:"fade",onEnter:s[0]||(s[0]=a=>n.value=!0),onAfterLeave:s[1]||(s[1]=a=>n.value=!1)},{default:M(()=>[r.open?(_(),A("div",{key:0,class:"VPNavScreen",ref_key:"screen",ref:e,id:"VPNavScreen"},[w("div",Eh,[C(r.$slots,"nav-screen-content-before",{},void 0,!0),x(yh,{class:"menu"}),x(Sh,{class:"translations"}),x(rh,{class:"appearance"}),x(wh,{class:"social-links"}),C(r.$slots,"nav-screen-content-after",{},void 0,!0)])],512)):j("",!0)]),_:3}))}}),Ch=q(Oh,[["__scopeId","data-v-32826b2b"]]),Ah={key:0,class:"VPNav"},Ih=R({__name:"VPNav",setup(t){const{isScreenOpen:e,closeScreen:n,toggleScreen:r}=Ul(),{frontmatter:s}=se(),a=U(()=>s.value.navbar!==!1);return pr("close-screen",n),it(()=>{wn&&document.documentElement.classList.toggle("hide-nav",!a.value)}),(o,i)=>a.value?(_(),A("header",Ah,[x(Zf,{"is-screen-open":v(e),onToggleScreen:v(r)},{"nav-bar-title-before":M(()=>[C(o.$slots,"nav-bar-title-before",{},void 0,!0)]),"nav-bar-title-after":M(()=>[C(o.$slots,"nav-bar-title-after",{},void 0,!0)]),"nav-bar-content-before":M(()=>[C(o.$slots,"nav-bar-content-before",{},void 0,!0)]),"nav-bar-content-after":M(()=>[C(o.$slots,"nav-bar-content-after",{},void 0,!0)]),_:3},8,["is-screen-open","onToggleScreen"]),x(Ch,{open:v(e)},{"nav-screen-content-before":M(()=>[C(o.$slots,"nav-screen-content-before",{},void 0,!0)]),"nav-screen-content-after":M(()=>[C(o.$slots,"nav-screen-content-after",{},void 0,!0)]),_:3},8,["open"])])):j("",!0)}}),Mh=q(Ih,[["__scopeId","data-v-44795173"]]),Nh=["role","tabindex"],$h={key:1,class:"items"},Ph=R({__name:"VPSidebarItem",props:{item:{},depth:{}},setup(t){const e=t,{collapsed:n,collapsible:r,isLink:s,isActiveLink:a,hasActiveLink:o,hasChildren:i,toggle:l}=xo(U(()=>e.item)),c=U(()=>i.value?"section":"div"),u=U(()=>s.value?"a":"div"),d=U(()=>i.value?e.depth+2===7?"p":`h${e.depth+2}`:"p"),f=U(()=>s.value?void 0:"button"),y=U(()=>[[`level-${e.depth}`],{collapsible:r.value},{collapsed:n.value},{"is-link":s.value},{"is-active":a.value},{"has-active":o.value}]);function S(b){"key"in b&&b.key!=="Enter"||!e.item.link&&l()}function g(){e.item.link&&l()}return(b,p)=>{const E=lt("VPSidebarItem",!0);return _(),K(We(c.value),{class:ue(["VPSidebarItem",y.value])},{default:M(()=>[b.item.text?(_(),A("div",at({key:0,class:"item",role:f.value},bo(b.item.items?{click:S,keydown:S}:{},!0),{tabindex:b.item.items&&0}),[p[1]||(p[1]=w("div",{class:"indicator"},null,-1)),b.item.link?(_(),K(je,{key:0,tag:u.value,class:"link",href:b.item.link,rel:b.item.rel,target:b.item.target},{default:M(()=>[(_(),K(We(d.value),{class:"text",innerHTML:b.item.text},null,8,["innerHTML"]))]),_:1},8,["tag","href","rel","target"])):(_(),K(We(d.value),{key:1,class:"text",innerHTML:b.item.text},null,8,["innerHTML"])),b.item.collapsed!=null&&b.item.items&&b.item.items.length?(_(),A("div",{key:2,class:"caret",role:"button","aria-label":"toggle section",onClick:g,onKeydown:yo(g,["enter"]),tabindex:"0"},p[0]||(p[0]=[w("span",{class:"vpi-chevron-right caret-icon"},null,-1)]),32)):j("",!0)],16,Nh)):j("",!0),b.item.items&&b.item.items.length?(_(),A("div",$h,[b.depth<5?(_(!0),A(he,{key:0},Ce(b.item.items,I=>(_(),K(E,{key:I.text,item:I,depth:b.depth+1},null,8,["item","depth"]))),128)):j("",!0)])):j("",!0)]),_:1},8,["class"])}}}),Th=q(Ph,[["__scopeId","data-v-7a8301d1"]]),Fh=R({__name:"VPSidebarGroup",props:{items:{}},setup(t){const e=X(!0);let n=null;return Ye(()=>{n=setTimeout(()=>{n=null,e.value=!1},300)}),kn(()=>{n!=null&&(clearTimeout(n),n=null)}),(r,s)=>(_(!0),A(he,null,Ce(r.items,a=>(_(),A("div",{key:a.text,class:ue(["group",{"no-transition":e.value}])},[x(Th,{item:a,depth:0},null,8,["item"])],2))),128))}}),Rh=q(Fh,[["__scopeId","data-v-8c7bf8d5"]]),Vh={class:"nav",id:"VPSidebarNav","aria-labelledby":"sidebar-aria-label",tabindex:"-1"},Dh=R({__name:"VPSidebar",props:{open:{type:Boolean}},setup(t){const{sidebarGroups:e,hasSidebar:n}=et(),r=t,s=X(null),a=qs(wn?document.body:null);pe([r,s],()=>{var i;r.open?(a.value=!0,(i=s.value)==null||i.focus()):a.value=!1},{immediate:!0,flush:"post"});const o=X(0);return pe(e,()=>{o.value+=1},{deep:!0}),(i,l)=>v(n)?(_(),A("aside",{key:0,class:ue(["VPSidebar",{open:i.open}]),ref_key:"navEl",ref:s,onClick:l[0]||(l[0]=wo(()=>{},["stop"]))},[l[2]||(l[2]=w("div",{class:"curtain"},null,-1)),w("nav",Vh,[l[1]||(l[1]=w("span",{class:"visually-hidden",id:"sidebar-aria-label"}," Sidebar Navigation ",-1)),C(i.$slots,"sidebar-nav-before",{},void 0,!0),(_(),K(Rh,{items:v(e),key:o.value},null,8,["items"])),C(i.$slots,"sidebar-nav-after",{},void 0,!0)])],2)):j("",!0)}}),Hh=q(Dh,[["__scopeId","data-v-7ad7cc6f"]]),Uh=R({__name:"VPSkipLink",setup(t){const e=Yt(),n=X();pe(()=>e.path,()=>n.value.focus());function r({target:s}){const a=document.getElementById(decodeURIComponent(s.hash).slice(1));if(a){const o=()=>{a.removeAttribute("tabindex"),a.removeEventListener("blur",o)};a.setAttribute("tabindex","-1"),a.addEventListener("blur",o),a.focus(),window.scrollTo(0,0)}}return(s,a)=>(_(),A(he,null,[w("span",{ref_key:"backToTop",ref:n,tabindex:"-1"},null,512),w("a",{href:"#VPContent",class:"VPSkipLink visually-hidden",onClick:r}," Skip to content ")],64))}}),Bh=q(Uh,[["__scopeId","data-v-cae79c10"]]),Wh=R({__name:"Layout",setup(t){const{isOpen:e,open:n,close:r}=et(),s=Yt();pe(()=>s.path,r),jo(e,r);const{frontmatter:a}=se(),o=ko(),i=U(()=>!!o["home-hero-image"]);return pr("hero-image-slot-exists",i),(l,c)=>{const u=lt("Content");return v(a).layout!==!1?(_(),A("div",{key:0,class:ue(["Layout",v(a).pageClass])},[C(l.$slots,"layout-top",{},void 0,!0),x(Bh),x(Mo,{class:"backdrop",show:v(e),onClick:v(r)},null,8,["show","onClick"]),x(Mh,null,{"nav-bar-title-before":M(()=>[C(l.$slots,"nav-bar-title-before",{},void 0,!0)]),"nav-bar-title-after":M(()=>[C(l.$slots,"nav-bar-title-after",{},void 0,!0)]),"nav-bar-content-before":M(()=>[C(l.$slots,"nav-bar-content-before",{},void 0,!0)]),"nav-bar-content-after":M(()=>[C(l.$slots,"nav-bar-content-after",{},void 0,!0)]),"nav-screen-content-before":M(()=>[C(l.$slots,"nav-screen-content-before",{},void 0,!0)]),"nav-screen-content-after":M(()=>[C(l.$slots,"nav-screen-content-after",{},void 0,!0)]),_:3}),x(Hl,{open:v(e),onOpenMenu:v(n)},null,8,["open","onOpenMenu"]),x(Hh,{open:v(e)},{"sidebar-nav-before":M(()=>[C(l.$slots,"sidebar-nav-before",{},void 0,!0)]),"sidebar-nav-after":M(()=>[C(l.$slots,"sidebar-nav-after",{},void 0,!0)]),_:3},8,["open"]),x(Ll,null,{"page-top":M(()=>[C(l.$slots,"page-top",{},void 0,!0)]),"page-bottom":M(()=>[C(l.$slots,"page-bottom",{},void 0,!0)]),"not-found":M(()=>[C(l.$slots,"not-found",{},void 0,!0)]),"home-hero-before":M(()=>[C(l.$slots,"home-hero-before",{},void 0,!0)]),"home-hero-info-before":M(()=>[C(l.$slots,"home-hero-info-before",{},void 0,!0)]),"home-hero-info":M(()=>[C(l.$slots,"home-hero-info",{},void 0,!0)]),"home-hero-info-after":M(()=>[C(l.$slots,"home-hero-info-after",{},void 0,!0)]),"home-hero-actions-after":M(()=>[C(l.$slots,"home-hero-actions-after",{},void 0,!0)]),"home-hero-image":M(()=>[C(l.$slots,"home-hero-image",{},void 0,!0)]),"home-hero-after":M(()=>[C(l.$slots,"home-hero-after",{},void 0,!0)]),"home-features-before":M(()=>[C(l.$slots,"home-features-before",{},void 0,!0)]),"home-features-after":M(()=>[C(l.$slots,"home-features-after",{},void 0,!0)]),"doc-footer-before":M(()=>[C(l.$slots,"doc-footer-before",{},void 0,!0)]),"doc-before":M(()=>[C(l.$slots,"doc-before",{},void 0,!0)]),"doc-after":M(()=>[C(l.$slots,"doc-after",{},void 0,!0)]),"doc-top":M(()=>[C(l.$slots,"doc-top",{},void 0,!0)]),"doc-bottom":M(()=>[C(l.$slots,"doc-bottom",{},void 0,!0)]),"aside-top":M(()=>[C(l.$slots,"aside-top",{},void 0,!0)]),"aside-bottom":M(()=>[C(l.$slots,"aside-bottom",{},void 0,!0)]),"aside-outline-before":M(()=>[C(l.$slots,"aside-outline-before",{},void 0,!0)]),"aside-outline-after":M(()=>[C(l.$slots,"aside-outline-after",{},void 0,!0)]),"aside-ads-before":M(()=>[C(l.$slots,"aside-ads-before",{},void 0,!0)]),"aside-ads-after":M(()=>[C(l.$slots,"aside-ads-after",{},void 0,!0)]),_:3}),x(Al),C(l.$slots,"layout-bottom",{},void 0,!0)],2)):(_(),K(u,{key:1}))}}}),jh=q(Wh,[["__scopeId","data-v-270f8e4a"]]),ka={Layout:jh,enhanceApp:({app:t})=>{t.component("Badge",Co)}};var xh=Object.defineProperty,Kh=(t,e,n)=>e in t?xh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,D=(t,e,n)=>Kh(t,typeof e!="symbol"?e+"":e,n),La=(t=>(t.IPAD="ipad",t.ANDROID="android",t.IPhONE="iphone",t.PC="pc",t))(La||{});const Sa=()=>{if(typeof window<"u"){const t=navigator.userAgent.toLowerCase();return/ipad|ipod/.test(t)?"ipad":/android/.test(t)?"android":/iphone/.test(t)?"iphone":"pc"}return"pc"},Xt=typeof window<"u",Gh=()=>Xt?window.navigator.userAgent.toLowerCase().includes("micromessenger"):!1,Yh=()=>{if(!Xt)return!1;const t=window.navigator.userAgent;return!!/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(t)},zh=()=>{if(!Xt)return!1;const t=/iphone/i.test(window.navigator.userAgent),e=window.devicePixelRatio&&window.devicePixelRatio===2,n=window.devicePixelRatio&&window.devicePixelRatio===3,r=window.screen.width===360&&window.screen.height===780,s=window.screen.width===375&&window.screen.height===812,a=window.screen.width===390&&window.screen.height===844,o=window.screen.width===414&&window.screen.height===896,i=window.screen.width===428&&window.screen.height===926;switch(!0){case(t&&n&&r):case(t&&n&&s):case(t&&n&&a):case(t&&e&&o):case(t&&n&&o):case(t&&n&&i):return!0;default:return!1}},Ea="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Oa="ARRAYBUFFER not supported by this environment",Ca="UINT8ARRAY not supported by this environment";function Xh(t,e,n,r,s){let a,o,i=0,l,c,u,d,f,y;r=r||0;const S=n||[0],g=r>>>3;if(e==="UTF8")for(f=s===-1?3:0,l=0;la?o.push(a):2048>a?(o.push(192|a>>>6),o.push(128|a&63)):55296>a||57344<=a?o.push(224|a>>>12,128|a>>>6&63,128|a&63):(l+=1,a=65536+((a&1023)<<10|t.charCodeAt(l)&1023),o.push(240|a>>>18,128|a>>>12&63,128|a>>>6&63,128|a&63)),c=0;c>>2;S.length<=u;)S.push(0);S[u]|=o[c]<<8*(f+s*(d%4)),i+=1}else for(f=s===-1?2:0,y=e==="UTF16LE"&&s!==1||e!=="UTF16LE"&&s===1,l=0;l>>8),d=i+g,u=d>>>2;S.length<=u;)S.push(0);S[u]|=a<<8*(f+s*(d%4)),i+=2}return{value:S,binLen:i*8+r}}function qh(t,e,n,r){let s,a,o,i;if(t.length%2!==0)throw new Error("String of HEX type must be in byte increments");n=n||0;const l=e||[0],c=n>>>3,u=r===-1?3:0;for(s=0;s>>1)+c,o=i>>>2;l.length<=o;)l.push(0);l[o]|=a<<8*(u+r*(i%4))}return{value:l,binLen:t.length*4+n}}function Jh(t,e,n,r){let s,a,o,i;n=n||0;const l=e||[0],c=n>>>3,u=r===-1?3:0;for(a=0;a>>2,l.length<=o&&l.push(0),l[o]|=s<<8*(u+r*(i%4));return{value:l,binLen:t.length*8+n}}function Qh(t,e,n,r){let s=0,a,o,i,l,c,u,d;n=n||0;const f=e||[0],y=n>>>3,S=r===-1?3:0,g=t.indexOf("=");if(t.search(/^[a-z\d=+/]+$/i)===-1)throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),g!==-1&&g{const[n,r]=e.toString().split(".");return r?r.length:0}),D(this,"amend",(e,n=15)=>parseFloat(Number(e).toPrecision(n))),D(this,"power",(e,n)=>Math.pow(10,Math.max(this.getDecimalLength(e),this.getDecimalLength(n))))}};D(Ge,"handleMethod",(t,e)=>{const n=new Ge,{power:r,amend:s}=n,a=r(t,e),o=s(t*a),i=s(e*a);return l=>{switch(l){case"+":return(o+i)/a;case"-":return(o-i)/a;case"*":return o*i/(a*a);case"/":return o/i}}});D(Ge,"add",(t,e)=>Ge.handleMethod(t,e)("+"));D(Ge,"divide",(t,e)=>Ge.handleMethod(t,e)("/"));D(Ge,"multiply",(t,e)=>Ge.handleMethod(t,e)("*"));D(Ge,"subtract",(t,e)=>Ge.handleMethod(t,e)("-"));var Lt=(t=>(t.NORMAL="normal",t.ERROR="error",t.WARNING="warning",t))(Lt||{}),Qt=(t=>(t.EN="en",t.ZH_CN="zh-CN",t))(Qt||{});const Da="ran_chaxus_lang",ls=[],xm={"zh-CN":{lang:"简体中文"},en:{lang:"English"}};var Ha=(t=>(t.LEGACY="legacy",t))(Ha||{});const cs="PWA_INSTALL_ID",Km="pwa-install",Gm="/ran/manifest.json",Ym=!1;Hm();const nr={isDev:Ym,locale:Qt.EN,currentDevice:Sa(),isWeiXin:Gh(),isMobile:Yh(),isBang:zh()},zm={install:t=>{t.config.globalProperties.$env=nr,t.provide("$env",nr)}};/*! + * shared v10.0.4 + * (c) 2024 kazuya kawaguchi + * Released under the MIT License. + */const mn=typeof window<"u",ut=(t,e=!1)=>e?Symbol.for(t):Symbol(t),Xm=(t,e,n)=>qm({l:t,k:e,s:n}),qm=t=>JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029").replace(/\u0027/g,"\\u0027"),we=t=>typeof t=="number"&&isFinite(t),Jm=t=>Sr(t)==="[object Date]",At=t=>Sr(t)==="[object RegExp]",On=t=>ee(t)&&Object.keys(t).length===0,ke=Object.assign;let us;const mt=()=>us||(us=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function ds(t){return t.replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}const Qm=Object.prototype.hasOwnProperty;function pn(t,e){return Qm.call(t,e)}const ve=Array.isArray,me=t=>typeof t=="function",H=t=>typeof t=="string",ie=t=>typeof t=="boolean",le=t=>t!==null&&typeof t=="object",Zm=t=>le(t)&&me(t.then)&&me(t.catch),Ua=Object.prototype.toString,Sr=t=>Ua.call(t),ee=t=>Sr(t)==="[object Object]",ep=t=>t==null?"":ve(t)||ee(t)&&t.toString===Ua?JSON.stringify(t,null,2):String(t);function Er(t,e=""){return t.reduce((n,r,s)=>s===0?n+r:n+e+r,"")}function tp(t,e){typeof console<"u"&&(console.warn("[intlify] "+t),e&&console.warn(e.stack))}const nn=t=>!le(t)||ve(t);function ln(t,e){if(nn(t)||nn(e))throw new Error("Invalid value");const n=[{src:t,des:e}];for(;n.length;){const{src:r,des:s}=n.pop();Object.keys(r).forEach(a=>{le(r[a])&&!le(s[a])&&(s[a]=Array.isArray(r[a])?[]:{}),nn(s[a])||nn(r[a])?s[a]=r[a]:n.push({src:r[a],des:s[a]})})}}/*! + * message-compiler v10.0.4 + * (c) 2024 kazuya kawaguchi + * Released under the MIT License. + */function np(t,e,n){return{line:t,column:e,offset:n}}function rr(t,e,n){return{start:t,end:e}}const de={EXPECTED_TOKEN:1,INVALID_TOKEN_IN_PLACEHOLDER:2,UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER:3,UNKNOWN_ESCAPE_SEQUENCE:4,INVALID_UNICODE_ESCAPE_SEQUENCE:5,UNBALANCED_CLOSING_BRACE:6,UNTERMINATED_CLOSING_BRACE:7,EMPTY_PLACEHOLDER:8,NOT_ALLOW_NEST_PLACEHOLDER:9,INVALID_LINKED_FORMAT:10,MUST_HAVE_MESSAGES_IN_PLURAL:11,UNEXPECTED_EMPTY_LINKED_MODIFIER:12,UNEXPECTED_EMPTY_LINKED_KEY:13,UNEXPECTED_LEXICAL_ANALYSIS:14,UNHANDLED_CODEGEN_NODE_TYPE:15,UNHANDLED_MINIFIER_NODE_TYPE:16},rp=17;function Cn(t,e,n={}){const{domain:r,messages:s,args:a}=n,o=t,i=new SyntaxError(String(o));return i.code=t,e&&(i.location=e),i.domain=r,i}function sp(t){throw t}const ze=" ",ap="\r",Ae=` +`,op="\u2028",ip="\u2029";function lp(t){const e=t;let n=0,r=1,s=1,a=0;const o=N=>e[N]===ap&&e[N+1]===Ae,i=N=>e[N]===Ae,l=N=>e[N]===ip,c=N=>e[N]===op,u=N=>o(N)||i(N)||l(N)||c(N),d=()=>n,f=()=>r,y=()=>s,S=()=>a,g=N=>o(N)||l(N)||c(N)?Ae:e[N],b=()=>g(n),p=()=>g(n+a);function E(){return a=0,u(n)&&(r++,s=0),o(n)&&n++,n++,s++,e[n]}function I(){return o(n+a)&&a++,a++,e[n+a]}function L(){n=0,r=1,s=1,a=0}function P(N=0){a=N}function T(){const N=n+a;for(;N!==n;)E();a=0}return{index:d,line:f,column:y,peekOffset:S,charAt:g,currentChar:b,currentPeek:p,next:E,peek:I,reset:L,resetPeek:P,skipToPeek:T}}const st=void 0,cp=".",fs="'",up="tokenizer";function dp(t,e={}){const n=e.location!==!1,r=lp(t),s=()=>r.index(),a=()=>np(r.line(),r.column(),r.index()),o=a(),i=s(),l={currentType:13,offset:i,startLoc:o,endLoc:o,lastType:13,lastOffset:i,lastStartLoc:o,lastEndLoc:o,braceNest:0,inLinked:!1,text:""},c=()=>l,{onError:u}=e;function d(h,m,$,...z){const be=c();if(m.column+=$,m.offset+=$,u){const ne=n?rr(be.startLoc,m):null,O=Cn(h,ne,{domain:up,args:z});u(O)}}function f(h,m,$){h.endLoc=a(),h.currentType=m;const z={type:m};return n&&(z.loc=rr(h.startLoc,h.endLoc)),$!=null&&(z.value=$),z}const y=h=>f(h,13);function S(h,m){return h.currentChar()===m?(h.next(),m):(d(de.EXPECTED_TOKEN,a(),0,m),"")}function g(h){let m="";for(;h.currentPeek()===ze||h.currentPeek()===Ae;)m+=h.currentPeek(),h.peek();return m}function b(h){const m=g(h);return h.skipToPeek(),m}function p(h){if(h===st)return!1;const m=h.charCodeAt(0);return m>=97&&m<=122||m>=65&&m<=90||m===95}function E(h){if(h===st)return!1;const m=h.charCodeAt(0);return m>=48&&m<=57}function I(h,m){const{currentType:$}=m;if($!==2)return!1;g(h);const z=p(h.currentPeek());return h.resetPeek(),z}function L(h,m){const{currentType:$}=m;if($!==2)return!1;g(h);const z=h.currentPeek()==="-"?h.peek():h.currentPeek(),be=E(z);return h.resetPeek(),be}function P(h,m){const{currentType:$}=m;if($!==2)return!1;g(h);const z=h.currentPeek()===fs;return h.resetPeek(),z}function T(h,m){const{currentType:$}=m;if($!==7)return!1;g(h);const z=h.currentPeek()===".";return h.resetPeek(),z}function N(h,m){const{currentType:$}=m;if($!==8)return!1;g(h);const z=p(h.currentPeek());return h.resetPeek(),z}function B(h,m){const{currentType:$}=m;if(!($===7||$===11))return!1;g(h);const z=h.currentPeek()===":";return h.resetPeek(),z}function G(h,m){const{currentType:$}=m;if($!==9)return!1;const z=()=>{const ne=h.currentPeek();return ne==="{"?p(h.peek()):ne==="@"||ne==="|"||ne===":"||ne==="."||ne===ze||!ne?!1:ne===Ae?(h.peek(),z()):ge(h,!1)},be=z();return h.resetPeek(),be}function ce(h){g(h);const m=h.currentPeek()==="|";return h.resetPeek(),m}function ge(h,m=!0){const $=(be=!1,ne="")=>{const O=h.currentPeek();return O==="{"||O==="@"||!O?be:O==="|"?!(ne===ze||ne===Ae):O===ze?(h.peek(),$(!0,ze)):O===Ae?(h.peek(),$(!0,Ae)):!0},z=$();return m&&h.resetPeek(),z}function ae(h,m){const $=h.currentChar();return $===st?st:m($)?(h.next(),$):null}function _e(h){const m=h.charCodeAt(0);return m>=97&&m<=122||m>=65&&m<=90||m>=48&&m<=57||m===95||m===36}function Ne(h){return ae(h,_e)}function Te(h){const m=h.charCodeAt(0);return m>=97&&m<=122||m>=65&&m<=90||m>=48&&m<=57||m===95||m===36||m===45}function tt(h){return ae(h,Te)}function De(h){const m=h.charCodeAt(0);return m>=48&&m<=57}function nt(h){return ae(h,De)}function Ee(h){const m=h.charCodeAt(0);return m>=48&&m<=57||m>=65&&m<=70||m>=97&&m<=102}function rt(h){return ae(h,Ee)}function J(h){let m="",$="";for(;m=nt(h);)$+=m;return $}function te(h){let m="";for(;;){const $=h.currentChar();if($==="{"||$==="}"||$==="@"||$==="|"||!$)break;if($===ze||$===Ae)if(ge(h))m+=$,h.next();else{if(ce(h))break;m+=$,h.next()}else m+=$,h.next()}return m}function V(h){b(h);let m="",$="";for(;m=tt(h);)$+=m;return h.currentChar()===st&&d(de.UNTERMINATED_CLOSING_BRACE,a(),0),$}function re(h){b(h);let m="";return h.currentChar()==="-"?(h.next(),m+=`-${J(h)}`):m+=J(h),h.currentChar()===st&&d(de.UNTERMINATED_CLOSING_BRACE,a(),0),m}function Y(h){return h!==fs&&h!==Ae}function oe(h){b(h),S(h,"'");let m="",$="";for(;m=ae(h,Y);)m==="\\"?$+=Le(h):$+=m;const z=h.currentChar();return z===Ae||z===st?(d(de.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,a(),0),z===Ae&&(h.next(),S(h,"'")),$):(S(h,"'"),$)}function Le(h){const m=h.currentChar();switch(m){case"\\":case"'":return h.next(),`\\${m}`;case"u":return Se(h,m,4);case"U":return Se(h,m,6);default:return d(de.UNKNOWN_ESCAPE_SEQUENCE,a(),0,m),""}}function Se(h,m,$){S(h,m);let z="";for(let be=0;be<$;be++){const ne=rt(h);if(!ne){d(de.INVALID_UNICODE_ESCAPE_SEQUENCE,a(),0,`\\${m}${z}${h.currentChar()}`);break}z+=ne}return`\\${m}${z}`}function vt(h){return h!=="{"&&h!=="}"&&h!==ze&&h!==Ae}function Fe(h){b(h);let m="",$="";for(;m=ae(h,vt);)$+=m;return $}function Mn(h){let m="",$="";for(;m=Ne(h);)$+=m;return $}function Nn(h){const m=$=>{const z=h.currentChar();return z==="{"||z==="@"||z==="|"||z==="("||z===")"||!z||z===ze?$:($+=z,h.next(),m($))};return m("")}function Ft(h){b(h);const m=S(h,"|");return b(h),m}function gt(h,m){let $=null;switch(h.currentChar()){case"{":return m.braceNest>=1&&d(de.NOT_ALLOW_NEST_PLACEHOLDER,a(),0),h.next(),$=f(m,2,"{"),b(h),m.braceNest++,$;case"}":return m.braceNest>0&&m.currentType===2&&d(de.EMPTY_PLACEHOLDER,a(),0),h.next(),$=f(m,3,"}"),m.braceNest--,m.braceNest>0&&b(h),m.inLinked&&m.braceNest===0&&(m.inLinked=!1),$;case"@":return m.braceNest>0&&d(de.UNTERMINATED_CLOSING_BRACE,a(),0),$=bt(h,m)||y(m),m.braceNest=0,$;default:{let be=!0,ne=!0,O=!0;if(ce(h))return m.braceNest>0&&d(de.UNTERMINATED_CLOSING_BRACE,a(),0),$=f(m,1,Ft(h)),m.braceNest=0,m.inLinked=!1,$;if(m.braceNest>0&&(m.currentType===4||m.currentType===5||m.currentType===6))return d(de.UNTERMINATED_CLOSING_BRACE,a(),0),m.braceNest=0,Rt(h,m);if(be=I(h,m))return $=f(m,4,V(h)),b(h),$;if(ne=L(h,m))return $=f(m,5,re(h)),b(h),$;if(O=P(h,m))return $=f(m,6,oe(h)),b(h),$;if(!be&&!ne&&!O)return $=f(m,12,Fe(h)),d(de.INVALID_TOKEN_IN_PLACEHOLDER,a(),0,$.value),b(h),$;break}}return $}function bt(h,m){const{currentType:$}=m;let z=null;const be=h.currentChar();switch(($===7||$===8||$===11||$===9)&&(be===Ae||be===ze)&&d(de.INVALID_LINKED_FORMAT,a(),0),be){case"@":return h.next(),z=f(m,7,"@"),m.inLinked=!0,z;case".":return b(h),h.next(),f(m,8,".");case":":return b(h),h.next(),f(m,9,":");default:return ce(h)?(z=f(m,1,Ft(h)),m.braceNest=0,m.inLinked=!1,z):T(h,m)||B(h,m)?(b(h),bt(h,m)):N(h,m)?(b(h),f(m,11,Mn(h))):G(h,m)?(b(h),be==="{"?gt(h,m)||z:f(m,10,Nn(h))):($===7&&d(de.INVALID_LINKED_FORMAT,a(),0),m.braceNest=0,m.inLinked=!1,Rt(h,m))}}function Rt(h,m){let $={type:13};if(m.braceNest>0)return gt(h,m)||y(m);if(m.inLinked)return bt(h,m)||y(m);switch(h.currentChar()){case"{":return gt(h,m)||y(m);case"}":return d(de.UNBALANCED_CLOSING_BRACE,a(),0),h.next(),f(m,3,"}");case"@":return bt(h,m)||y(m);default:{if(ce(h))return $=f(m,1,Ft(h)),m.braceNest=0,m.inLinked=!1,$;if(ge(h))return f(m,0,te(h));break}}return $}function $n(){const{currentType:h,offset:m,startLoc:$,endLoc:z}=l;return l.lastType=h,l.lastOffset=m,l.lastStartLoc=$,l.lastEndLoc=z,l.offset=s(),l.startLoc=a(),r.currentChar()===st?f(l,13):Rt(r,l)}return{nextToken:$n,currentOffset:s,currentPosition:a,context:c}}const fp="parser",hp=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function mp(t,e,n){switch(t){case"\\\\":return"\\";case"\\'":return"'";default:{const r=parseInt(e||n,16);return r<=55295||r>=57344?String.fromCodePoint(r):"�"}}}function pp(t={}){const e=t.location!==!1,{onError:n}=t;function r(p,E,I,L,...P){const T=p.currentPosition();if(T.offset+=L,T.column+=L,n){const N=e?rr(I,T):null,B=Cn(E,N,{domain:fp,args:P});n(B)}}function s(p,E,I){const L={type:p};return e&&(L.start=E,L.end=E,L.loc={start:I,end:I}),L}function a(p,E,I,L){e&&(p.end=E,p.loc&&(p.loc.end=I))}function o(p,E){const I=p.context(),L=s(3,I.offset,I.startLoc);return L.value=E,a(L,p.currentOffset(),p.currentPosition()),L}function i(p,E){const I=p.context(),{lastOffset:L,lastStartLoc:P}=I,T=s(5,L,P);return T.index=parseInt(E,10),p.nextToken(),a(T,p.currentOffset(),p.currentPosition()),T}function l(p,E){const I=p.context(),{lastOffset:L,lastStartLoc:P}=I,T=s(4,L,P);return T.key=E,p.nextToken(),a(T,p.currentOffset(),p.currentPosition()),T}function c(p,E){const I=p.context(),{lastOffset:L,lastStartLoc:P}=I,T=s(9,L,P);return T.value=E.replace(hp,mp),p.nextToken(),a(T,p.currentOffset(),p.currentPosition()),T}function u(p){const E=p.nextToken(),I=p.context(),{lastOffset:L,lastStartLoc:P}=I,T=s(8,L,P);return E.type!==11?(r(p,de.UNEXPECTED_EMPTY_LINKED_MODIFIER,I.lastStartLoc,0),T.value="",a(T,L,P),{nextConsumeToken:E,node:T}):(E.value==null&&r(p,de.UNEXPECTED_LEXICAL_ANALYSIS,I.lastStartLoc,0,He(E)),T.value=E.value||"",a(T,p.currentOffset(),p.currentPosition()),{node:T})}function d(p,E){const I=p.context(),L=s(7,I.offset,I.startLoc);return L.value=E,a(L,p.currentOffset(),p.currentPosition()),L}function f(p){const E=p.context(),I=s(6,E.offset,E.startLoc);let L=p.nextToken();if(L.type===8){const P=u(p);I.modifier=P.node,L=P.nextConsumeToken||p.nextToken()}switch(L.type!==9&&r(p,de.UNEXPECTED_LEXICAL_ANALYSIS,E.lastStartLoc,0,He(L)),L=p.nextToken(),L.type===2&&(L=p.nextToken()),L.type){case 10:L.value==null&&r(p,de.UNEXPECTED_LEXICAL_ANALYSIS,E.lastStartLoc,0,He(L)),I.key=d(p,L.value||"");break;case 4:L.value==null&&r(p,de.UNEXPECTED_LEXICAL_ANALYSIS,E.lastStartLoc,0,He(L)),I.key=l(p,L.value||"");break;case 5:L.value==null&&r(p,de.UNEXPECTED_LEXICAL_ANALYSIS,E.lastStartLoc,0,He(L)),I.key=i(p,L.value||"");break;case 6:L.value==null&&r(p,de.UNEXPECTED_LEXICAL_ANALYSIS,E.lastStartLoc,0,He(L)),I.key=c(p,L.value||"");break;default:{r(p,de.UNEXPECTED_EMPTY_LINKED_KEY,E.lastStartLoc,0);const P=p.context(),T=s(7,P.offset,P.startLoc);return T.value="",a(T,P.offset,P.startLoc),I.key=T,a(I,P.offset,P.startLoc),{nextConsumeToken:L,node:I}}}return a(I,p.currentOffset(),p.currentPosition()),{node:I}}function y(p){const E=p.context(),I=E.currentType===1?p.currentOffset():E.offset,L=E.currentType===1?E.endLoc:E.startLoc,P=s(2,I,L);P.items=[];let T=null;do{const G=T||p.nextToken();switch(T=null,G.type){case 0:G.value==null&&r(p,de.UNEXPECTED_LEXICAL_ANALYSIS,E.lastStartLoc,0,He(G)),P.items.push(o(p,G.value||""));break;case 5:G.value==null&&r(p,de.UNEXPECTED_LEXICAL_ANALYSIS,E.lastStartLoc,0,He(G)),P.items.push(i(p,G.value||""));break;case 4:G.value==null&&r(p,de.UNEXPECTED_LEXICAL_ANALYSIS,E.lastStartLoc,0,He(G)),P.items.push(l(p,G.value||""));break;case 6:G.value==null&&r(p,de.UNEXPECTED_LEXICAL_ANALYSIS,E.lastStartLoc,0,He(G)),P.items.push(c(p,G.value||""));break;case 7:{const ce=f(p);P.items.push(ce.node),T=ce.nextConsumeToken||null;break}}}while(E.currentType!==13&&E.currentType!==1);const N=E.currentType===1?E.lastOffset:p.currentOffset(),B=E.currentType===1?E.lastEndLoc:p.currentPosition();return a(P,N,B),P}function S(p,E,I,L){const P=p.context();let T=L.items.length===0;const N=s(1,E,I);N.cases=[],N.cases.push(L);do{const B=y(p);T||(T=B.items.length===0),N.cases.push(B)}while(P.currentType!==13);return T&&r(p,de.MUST_HAVE_MESSAGES_IN_PLURAL,I,0),a(N,p.currentOffset(),p.currentPosition()),N}function g(p){const E=p.context(),{offset:I,startLoc:L}=E,P=y(p);return E.currentType===13?P:S(p,I,L,P)}function b(p){const E=dp(p,ke({},t)),I=E.context(),L=s(0,I.offset,I.startLoc);return e&&L.loc&&(L.loc.source=p),L.body=g(E),t.onCacheKey&&(L.cacheKey=t.onCacheKey(p)),I.currentType!==13&&r(E,de.UNEXPECTED_LEXICAL_ANALYSIS,I.lastStartLoc,0,p[I.offset]||""),a(L,E.currentOffset(),E.currentPosition()),L}return{parse:b}}function He(t){if(t.type===13)return"EOF";const e=(t.value||"").replace(/\r?\n/gu,"\\n");return e.length>10?e.slice(0,9)+"…":e}function _p(t,e={}){const n={ast:t,helpers:new Set};return{context:()=>n,helper:a=>(n.helpers.add(a),a)}}function hs(t,e){for(let n=0;nms(n)),t}function ms(t){if(t.items.length===1){const e=t.items[0];(e.type===3||e.type===9)&&(t.static=e.value,delete e.value)}else{const e=[];for(let n=0;ni;function c(b,p){i.code+=b}function u(b,p=!0){const E=p?s:"";c(a?E+" ".repeat(b):E)}function d(b=!0){const p=++i.indentLevel;b&&u(p)}function f(b=!0){const p=--i.indentLevel;b&&u(p)}function y(){u(i.indentLevel)}return{context:l,push:c,indent:d,deindent:f,newline:y,helper:b=>`_${b}`,needIndent:()=>i.needIndent}}function yp(t,e){const{helper:n}=t;t.push(`${n("linked")}(`),It(t,e.key),e.modifier?(t.push(", "),It(t,e.modifier),t.push(", _type")):t.push(", undefined, _type"),t.push(")")}function wp(t,e){const{helper:n,needIndent:r}=t;t.push(`${n("normalize")}([`),t.indent(r());const s=e.items.length;for(let a=0;a1){t.push(`${n("plural")}([`),t.indent(r());const s=e.cases.length;for(let a=0;a{const n=H(e.mode)?e.mode:"normal",r=H(e.filename)?e.filename:"message.intl",s=!!e.sourceMap,a=e.breakLineCode!=null?e.breakLineCode:n==="arrow"?";":` +`,o=e.needIndent?e.needIndent:n!=="arrow",i=t.helpers||[],l=bp(t,{mode:n,filename:r,sourceMap:s,breakLineCode:a,needIndent:o});l.push(n==="normal"?"function __msg__ (ctx) {":"(ctx) => {"),l.indent(o),i.length>0&&(l.push(`const { ${Er(i.map(d=>`${d}: _${d}`),", ")} } = ctx`),l.newline()),l.push("return "),It(l,t),l.deindent(o),l.push("}"),delete t.helpers;const{code:c,map:u}=l.context();return{ast:t,code:c,map:u?u.toJSON():void 0}};function Ep(t,e={}){const n=ke({},e),r=!!n.jit,s=!!n.minify,a=n.optimize==null?!0:n.optimize,i=pp(n).parse(t);return r?(a&&gp(i),s&&St(i),{ast:i,code:""}):(vp(i,n),Sp(i,n))}/*! + * core-base v10.0.4 + * (c) 2024 kazuya kawaguchi + * Released under the MIT License. + */function Op(){typeof __INTLIFY_PROD_DEVTOOLS__!="boolean"&&(mt().__INTLIFY_PROD_DEVTOOLS__=!1),typeof __INTLIFY_DROP_MESSAGE_COMPILER__!="boolean"&&(mt().__INTLIFY_DROP_MESSAGE_COMPILER__=!1)}function Dn(t){return n=>Cp(n,t)}function Cp(t,e){const n=e.b||e.body;if((n.t||n.type)===1){const r=n,s=r.c||r.cases;return t.plural(s.reduce((a,o)=>[...a,ps(t,o)],[]))}else return ps(t,n)}function ps(t,e){const n=e.s||e.static;if(n!=null)return t.type==="text"?n:t.normalize([n]);{const r=(e.i||e.items).reduce((s,a)=>[...s,sr(t,a)],[]);return t.normalize(r)}}function sr(t,e){const n=e.t||e.type;switch(n){case 3:{const r=e;return r.v||r.value}case 9:{const r=e;return r.v||r.value}case 4:{const r=e;return t.interpolate(t.named(r.k||r.key))}case 5:{const r=e;return t.interpolate(t.list(r.i!=null?r.i:r.index))}case 6:{const r=e,s=r.m||r.modifier;return t.linked(sr(t,r.k||r.key),s?sr(t,s):void 0,t.type)}case 7:{const r=e;return r.v||r.value}case 8:{const r=e;return r.v||r.value}default:throw new Error(`unhandled node type on format message part: ${n}`)}}const Ap=t=>t;let rn=Object.create(null);const Mt=t=>le(t)&&(t.t===0||t.type===0)&&("b"in t||"body"in t);function Ip(t,e={}){let n=!1;const r=e.onError||sp;return e.onError=s=>{n=!0,r(s)},{...Ep(t,e),detectError:n}}function Mp(t,e){if(!__INTLIFY_DROP_MESSAGE_COMPILER__&&H(t)){ie(e.warnHtmlMessage)&&e.warnHtmlMessage;const r=(e.onCacheKey||Ap)(t),s=rn[r];if(s)return s;const{ast:a,detectError:o}=Ip(t,{...e,location:!1,jit:!0}),i=Dn(a);return o?i:rn[r]=i}else{const n=t.cacheKey;if(n){const r=rn[n];return r||(rn[n]=Dn(t))}else return Dn(t)}}let xt=null;function Np(t){xt=t}function $p(t,e,n){xt&&xt.emit("i18n:init",{timestamp:Date.now(),i18n:t,version:e,meta:n})}const Pp=Tp("function:translate");function Tp(t){return e=>xt&&xt.emit(t,e)}const Je={INVALID_ARGUMENT:rp,INVALID_DATE_ARGUMENT:18,INVALID_ISO_DATE_ARGUMENT:19,NOT_SUPPORT_NON_STRING_MESSAGE:20,NOT_SUPPORT_LOCALE_PROMISE_VALUE:21,NOT_SUPPORT_LOCALE_ASYNC_FUNCTION:22,NOT_SUPPORT_LOCALE_TYPE:23},Fp=24;function Qe(t){return Cn(t,null,void 0)}function Cr(t,e){return e.locale!=null?_s(e.locale):_s(t.locale)}let Hn;function _s(t){if(H(t))return t;if(me(t)){if(t.resolvedOnce&&Hn!=null)return Hn;if(t.constructor.name==="Function"){const e=t();if(Zm(e))throw Qe(Je.NOT_SUPPORT_LOCALE_PROMISE_VALUE);return Hn=e}else throw Qe(Je.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION)}else throw Qe(Je.NOT_SUPPORT_LOCALE_TYPE)}function Rp(t,e,n){return[...new Set([n,...ve(e)?e:le(e)?Object.keys(e):H(e)?[e]:[n]])]}function Ba(t,e,n){const r=H(n)?n:Kt,s=t;s.__localeChainCache||(s.__localeChainCache=new Map);let a=s.__localeChainCache.get(r);if(!a){a=[];let o=[n];for(;ve(o);)o=vs(a,o,e);const i=ve(e)||!ee(e)?e:e.default?e.default:null;o=H(i)?[i]:i,ve(o)&&vs(a,o,!1),s.__localeChainCache.set(r,a)}return a}function vs(t,e,n){let r=!0;for(let s=0;s{o===void 0?o=i:o+=i},f[1]=()=>{o!==void 0&&(e.push(o),o=void 0)},f[2]=()=>{f[0](),s++},f[3]=()=>{if(s>0)s--,r=4,f[0]();else{if(s=0,o===void 0||(o=jp(o),o===!1))return!1;f[1]()}};function y(){const S=t[n+1];if(r===5&&S==="'"||r===6&&S==='"')return n++,i="\\"+S,f[0](),!0}for(;r!==null;)if(n++,a=t[n],!(a==="\\"&&y())){if(l=Wp(a),d=dt[r],c=d[l]||d.l||8,c===8||(r=c[0],c[1]!==void 0&&(u=f[c[1]],u&&(i=a,u()===!1))))return;if(r===7)return e}}const gs=new Map;function Kp(t,e){return le(t)?t[e]:null}function Gp(t,e){if(!le(t))return null;let n=gs.get(e);if(n||(n=xp(e),n&&gs.set(e,n)),!n)return null;const r=n.length;let s=t,a=0;for(;a`${t.charAt(0).toLocaleUpperCase()}${t.substr(1)}`;function zp(){return{upper:(t,e)=>e==="text"&&H(t)?t.toUpperCase():e==="vnode"&&le(t)&&"__v_isVNode"in t?t.children.toUpperCase():t,lower:(t,e)=>e==="text"&&H(t)?t.toLowerCase():e==="vnode"&&le(t)&&"__v_isVNode"in t?t.children.toLowerCase():t,capitalize:(t,e)=>e==="text"&&H(t)?ys(t):e==="vnode"&&le(t)&&"__v_isVNode"in t?ys(t.children):t}}let Wa;function Xp(t){Wa=t}let ja;function qp(t){ja=t}let xa;function Jp(t){xa=t}let Ka=null;const Qp=t=>{Ka=t},Zp=()=>Ka;let Ga=null;const ws=t=>{Ga=t},e1=()=>Ga;let ks=0;function t1(t={}){const e=me(t.onWarn)?t.onWarn:tp,n=H(t.version)?t.version:Yp,r=H(t.locale)||me(t.locale)?t.locale:Kt,s=me(r)?Kt:r,a=ve(t.fallbackLocale)||ee(t.fallbackLocale)||H(t.fallbackLocale)||t.fallbackLocale===!1?t.fallbackLocale:s,o=ee(t.messages)?t.messages:{[s]:{}},i=ee(t.datetimeFormats)?t.datetimeFormats:{[s]:{}},l=ee(t.numberFormats)?t.numberFormats:{[s]:{}},c=ke({},t.modifiers||{},zp()),u=t.pluralRules||{},d=me(t.missing)?t.missing:null,f=ie(t.missingWarn)||At(t.missingWarn)?t.missingWarn:!0,y=ie(t.fallbackWarn)||At(t.fallbackWarn)?t.fallbackWarn:!0,S=!!t.fallbackFormat,g=!!t.unresolving,b=me(t.postTranslation)?t.postTranslation:null,p=ee(t.processor)?t.processor:null,E=ie(t.warnHtmlMessage)?t.warnHtmlMessage:!0,I=!!t.escapeParameter,L=me(t.messageCompiler)?t.messageCompiler:Wa,P=me(t.messageResolver)?t.messageResolver:ja||Kp,T=me(t.localeFallbacker)?t.localeFallbacker:xa||Rp,N=le(t.fallbackContext)?t.fallbackContext:void 0,B=t,G=le(B.__datetimeFormatters)?B.__datetimeFormatters:new Map,ce=le(B.__numberFormatters)?B.__numberFormatters:new Map,ge=le(B.__meta)?B.__meta:{};ks++;const ae={version:n,cid:ks,locale:r,fallbackLocale:a,messages:o,modifiers:c,pluralRules:u,missing:d,missingWarn:f,fallbackWarn:y,fallbackFormat:S,unresolving:g,postTranslation:b,processor:p,warnHtmlMessage:E,escapeParameter:I,messageCompiler:L,messageResolver:P,localeFallbacker:T,fallbackContext:N,onWarn:e,__meta:ge};return ae.datetimeFormats=i,ae.numberFormats=l,ae.__datetimeFormatters=G,ae.__numberFormatters=ce,__INTLIFY_PROD_DEVTOOLS__&&$p(ae,n,ge),ae}function Ar(t,e,n,r,s){const{missing:a,onWarn:o}=t;if(a!==null){const i=a(t,n,e,s);return H(i)?i:e}else return e}function Ht(t,e,n){const r=t;r.__localeChainCache=new Map,t.localeFallbacker(t,n,e)}function n1(t,e){return t===e?!1:t.split("-")[0]===e.split("-")[0]}function r1(t,e){const n=e.indexOf(t);if(n===-1)return!1;for(let r=n+1;r{Ya.includes(l)?o[l]=n[l]:a[l]=n[l]}),H(r)?a.locale=r:ee(r)&&(o=r),ee(s)&&(o=s),[a.key||"",i,a,o]}function Ss(t,e,n){const r=t;for(const s in n){const a=`${e}__${s}`;r.__datetimeFormatters.has(a)&&r.__datetimeFormatters.delete(a)}}function Es(t,...e){const{numberFormats:n,unresolving:r,fallbackLocale:s,onWarn:a,localeFallbacker:o}=t,{__numberFormatters:i}=t,[l,c,u,d]=or(...e),f=ie(u.missingWarn)?u.missingWarn:t.missingWarn;ie(u.fallbackWarn)?u.fallbackWarn:t.fallbackWarn;const y=!!u.part,S=Cr(t,u),g=o(t,s,S);if(!H(l)||l==="")return new Intl.NumberFormat(S,d).format(c);let b={},p,E=null;const I="number format";for(let T=0;T{za.includes(l)?o[l]=n[l]:a[l]=n[l]}),H(r)?a.locale=r:ee(r)&&(o=r),ee(s)&&(o=s),[a.key||"",i,a,o]}function Os(t,e,n){const r=t;for(const s in n){const a=`${e}__${s}`;r.__numberFormatters.has(a)&&r.__numberFormatters.delete(a)}}const s1=t=>t,a1=t=>"",o1="text",i1=t=>t.length===0?"":Er(t),l1=ep;function Cs(t,e){return t=Math.abs(t),e===2?t?t>1?1:0:1:t?Math.min(t,2):0}function c1(t){const e=we(t.pluralIndex)?t.pluralIndex:-1;return t.named&&(we(t.named.count)||we(t.named.n))?we(t.named.count)?t.named.count:we(t.named.n)?t.named.n:e:e}function u1(t,e){e.count||(e.count=t),e.n||(e.n=t)}function d1(t={}){const e=t.locale,n=c1(t),r=le(t.pluralRules)&&H(e)&&me(t.pluralRules[e])?t.pluralRules[e]:Cs,s=le(t.pluralRules)&&H(e)&&me(t.pluralRules[e])?Cs:void 0,a=p=>p[r(n,p.length,s)],o=t.list||[],i=p=>o[p],l=t.named||{};we(t.pluralIndex)&&u1(n,l);const c=p=>l[p];function u(p,E){const I=me(t.messages)?t.messages(p,!!E):le(t.messages)?t.messages[p]:!1;return I||(t.parent?t.parent.message(p):a1)}const d=p=>t.modifiers?t.modifiers[p]:s1,f=ee(t.processor)&&me(t.processor.normalize)?t.processor.normalize:i1,y=ee(t.processor)&&me(t.processor.interpolate)?t.processor.interpolate:l1,S=ee(t.processor)&&H(t.processor.type)?t.processor.type:o1,b={list:i,named:c,plural:a,linked:(p,...E)=>{const[I,L]=E;let P="text",T="";E.length===1?le(I)?(T=I.modifier||T,P=I.type||P):H(I)&&(T=I||T):E.length===2&&(H(I)&&(T=I||T),H(L)&&(P=L||P));const N=u(p,!0)(b),B=P==="vnode"&&ve(N)&&T?N[0]:N;return T?d(T)(B,P):B},message:u,type:S,interpolate:y,normalize:f,values:ke({},o,l)};return b}const As=()=>"",Pe=t=>me(t);function Is(t,...e){const{fallbackFormat:n,postTranslation:r,unresolving:s,messageCompiler:a,fallbackLocale:o,messages:i}=t,[l,c]=ir(...e),u=ie(c.missingWarn)?c.missingWarn:t.missingWarn,d=ie(c.fallbackWarn)?c.fallbackWarn:t.fallbackWarn,f=ie(c.escapeParameter)?c.escapeParameter:t.escapeParameter,y=!!c.resolvedMessage,S=H(c.default)||ie(c.default)?ie(c.default)?a?l:()=>l:c.default:n?a?l:()=>l:null,g=n||S!=null&&(H(S)||me(S)),b=Cr(t,c);f&&f1(c);let[p,E,I]=y?[l,b,i[b]||{}]:Xa(t,l,b,o,d,u),L=p,P=l;if(!y&&!(H(L)||Mt(L)||Pe(L))&&g&&(L=S,P=L),!y&&(!(H(L)||Mt(L)||Pe(L))||!H(E)))return s?An:l;let T=!1;const N=()=>{T=!0},B=Pe(L)?L:qa(t,l,E,L,P,N);if(T)return L;const G=p1(t,E,I,c),ce=d1(G),ge=h1(t,B,ce),ae=r?r(ge,l):ge;if(__INTLIFY_PROD_DEVTOOLS__){const _e={timestamp:Date.now(),key:H(l)?l:Pe(L)?L.key:"",locale:E||(Pe(L)?L.locale:""),format:H(L)?L:Pe(L)?L.source:"",message:ae};_e.meta=ke({},t.__meta,Zp()||{}),Pp(_e)}return ae}function f1(t){ve(t.list)?t.list=t.list.map(e=>H(e)?ds(e):e):le(t.named)&&Object.keys(t.named).forEach(e=>{H(t.named[e])&&(t.named[e]=ds(t.named[e]))})}function Xa(t,e,n,r,s,a){const{messages:o,onWarn:i,messageResolver:l,localeFallbacker:c}=t,u=c(t,r,n);let d={},f,y=null;const S="translate";for(let g=0;gr;return c.locale=n,c.key=e,c}const l=o(r,m1(t,n,s,r,i,a));return l.locale=n,l.key=e,l.source=r,l}function h1(t,e,n){return e(n)}function ir(...t){const[e,n,r]=t,s={};if(!H(e)&&!we(e)&&!Pe(e)&&!Mt(e))throw Qe(Je.INVALID_ARGUMENT);const a=we(e)?String(e):(Pe(e),e);return we(n)?s.plural=n:H(n)?s.default=n:ee(n)&&!On(n)?s.named=n:ve(n)&&(s.list=n),we(r)?s.plural=r:H(r)?s.default=r:ee(r)&&ke(s,r),[a,s]}function m1(t,e,n,r,s,a){return{locale:e,key:n,warnHtmlMessage:s,onError:o=>{throw a&&a(o),o},onCacheKey:o=>Xm(e,n,o)}}function p1(t,e,n,r){const{modifiers:s,pluralRules:a,messageResolver:o,fallbackLocale:i,fallbackWarn:l,missingWarn:c,fallbackContext:u}=t,f={locale:e,modifiers:s,pluralRules:a,messages:(y,S)=>{let g=o(n,y);if(g==null&&(u||S)){const[,,b]=Xa(u||t,y,e,i,l,c);g=o(b,y)}if(H(g)||Mt(g)){let b=!1;const E=qa(t,y,e,g,y,()=>{b=!0});return b?As:E}else return Pe(g)?g:As}};return t.processor&&(f.processor=t.processor),r.list&&(f.list=r.list),r.named&&(f.named=r.named),we(r.plural)&&(f.pluralIndex=r.plural),f}Op();/*! + * vue-i18n v10.0.4 + * (c) 2024 kazuya kawaguchi + * Released under the MIT License. + */const _1="10.0.4";function v1(){typeof __VUE_I18N_FULL_INSTALL__!="boolean"&&(mt().__VUE_I18N_FULL_INSTALL__=!0),typeof __VUE_I18N_LEGACY_API__!="boolean"&&(mt().__VUE_I18N_LEGACY_API__=!0),typeof __INTLIFY_DROP_MESSAGE_COMPILER__!="boolean"&&(mt().__INTLIFY_DROP_MESSAGE_COMPILER__=!1),typeof __INTLIFY_PROD_DEVTOOLS__!="boolean"&&(mt().__INTLIFY_PROD_DEVTOOLS__=!1)}const Ie={UNEXPECTED_RETURN_TYPE:Fp,INVALID_ARGUMENT:25,MUST_BE_CALL_SETUP_TOP:26,NOT_INSTALLED:27,REQUIRED_VALUE:28,INVALID_VALUE:29,CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN:30,NOT_INSTALLED_WITH_PROVIDE:31,UNEXPECTED_ERROR:32,NOT_COMPATIBLE_LEGACY_VUE_I18N:33,NOT_AVAILABLE_COMPOSITION_IN_LEGACY:34};function Me(t,...e){return Cn(t,null,void 0)}const lr=ut("__translateVNode"),cr=ut("__datetimeParts"),ur=ut("__numberParts"),Ja=ut("__setPluralRules"),Qa=ut("__injectWithOption"),dr=ut("__dispose");function Gt(t){if(!le(t))return t;for(const e in t)if(pn(t,e))if(!e.includes("."))le(t[e])&&Gt(t[e]);else{const n=e.split("."),r=n.length-1;let s=t,a=!1;for(let o=0;o{if("locale"in i&&"resource"in i){const{locale:l,resource:c}=i;l?(o[l]=o[l]||{},ln(c,o[l])):ln(c,o)}else H(i)&&ln(JSON.parse(i),o)}),s==null&&a)for(const i in o)pn(o,i)&&Gt(o[i]);return o}function Za(t){return t.type}function eo(t,e,n){let r=le(e.messages)?e.messages:{};"__i18nGlobal"in n&&(r=Ir(t.locale.value,{messages:r,__i18n:n.__i18nGlobal}));const s=Object.keys(r);s.length&&s.forEach(a=>{t.mergeLocaleMessage(a,r[a])});{if(le(e.datetimeFormats)){const a=Object.keys(e.datetimeFormats);a.length&&a.forEach(o=>{t.mergeDateTimeFormat(o,e.datetimeFormats[o])})}if(le(e.numberFormats)){const a=Object.keys(e.numberFormats);a.length&&a.forEach(o=>{t.mergeNumberFormat(o,e.numberFormats[o])})}}}function Ms(t){return x(Eo,null,t,0)}const Ns="__INTLIFY_META__",$s=()=>[],g1=()=>!1;let Ps=0;function Ts(t){return(e,n,r,s)=>t(n,r,Wt()||void 0,s)}const b1=()=>{const t=Wt();let e=null;return t&&(e=Za(t)[Ns])?{[Ns]:e}:null};function Mr(t={}){const{__root:e,__injectWithOption:n}=t,r=e===void 0,s=t.flatJson,a=mn?X:bn;let o=ie(t.inheritLocale)?t.inheritLocale:!0;const i=a(e&&o?e.locale.value:H(t.locale)?t.locale:Kt),l=a(e&&o?e.fallbackLocale.value:H(t.fallbackLocale)||ve(t.fallbackLocale)||ee(t.fallbackLocale)||t.fallbackLocale===!1?t.fallbackLocale:i.value),c=a(Ir(i.value,t)),u=a(ee(t.datetimeFormats)?t.datetimeFormats:{[i.value]:{}}),d=a(ee(t.numberFormats)?t.numberFormats:{[i.value]:{}});let f=e?e.missingWarn:ie(t.missingWarn)||At(t.missingWarn)?t.missingWarn:!0,y=e?e.fallbackWarn:ie(t.fallbackWarn)||At(t.fallbackWarn)?t.fallbackWarn:!0,S=e?e.fallbackRoot:ie(t.fallbackRoot)?t.fallbackRoot:!0,g=!!t.fallbackFormat,b=me(t.missing)?t.missing:null,p=me(t.missing)?Ts(t.missing):null,E=me(t.postTranslation)?t.postTranslation:null,I=e?e.warnHtmlMessage:ie(t.warnHtmlMessage)?t.warnHtmlMessage:!0,L=!!t.escapeParameter;const P=e?e.modifiers:ee(t.modifiers)?t.modifiers:{};let T=t.pluralRules||e&&e.pluralRules,N;N=(()=>{r&&ws(null);const O={version:_1,locale:i.value,fallbackLocale:l.value,messages:c.value,modifiers:P,pluralRules:T,missing:p===null?void 0:p,missingWarn:f,fallbackWarn:y,fallbackFormat:g,unresolving:!0,postTranslation:E===null?void 0:E,warnHtmlMessage:I,escapeParameter:L,messageResolver:t.messageResolver,messageCompiler:t.messageCompiler,__meta:{framework:"vue"}};O.datetimeFormats=u.value,O.numberFormats=d.value,O.__datetimeFormatters=ee(N)?N.__datetimeFormatters:void 0,O.__numberFormatters=ee(N)?N.__numberFormatters:void 0;const F=t1(O);return r&&ws(F),F})(),Ht(N,i.value,l.value);function G(){return[i.value,l.value,c.value,u.value,d.value]}const ce=U({get:()=>i.value,set:O=>{i.value=O,N.locale=i.value}}),ge=U({get:()=>l.value,set:O=>{l.value=O,N.fallbackLocale=l.value,Ht(N,i.value,O)}}),ae=U(()=>c.value),_e=U(()=>u.value),Ne=U(()=>d.value);function Te(){return me(E)?E:null}function tt(O){E=O,N.postTranslation=O}function De(){return b}function nt(O){O!==null&&(p=Ts(O)),b=O,N.missing=p}const Ee=(O,F,fe,ye,ft,Zt)=>{G();let yt;try{__INTLIFY_PROD_DEVTOOLS__,r||(N.fallbackContext=e?e1():void 0),yt=O(N)}finally{__INTLIFY_PROD_DEVTOOLS__,r||(N.fallbackContext=void 0)}if(fe!=="translate exists"&&we(yt)&&yt===An||fe==="translate exists"&&!yt){const[oo,J1]=F();return e&&S?ye(e):ft(oo)}else{if(Zt(yt))return yt;throw Me(Ie.UNEXPECTED_RETURN_TYPE)}};function rt(...O){return Ee(F=>Reflect.apply(Is,null,[F,...O]),()=>ir(...O),"translate",F=>Reflect.apply(F.t,F,[...O]),F=>F,F=>H(F))}function J(...O){const[F,fe,ye]=O;if(ye&&!le(ye))throw Me(Ie.INVALID_ARGUMENT);return rt(F,fe,ke({resolvedMessage:!0},ye||{}))}function te(...O){return Ee(F=>Reflect.apply(Ls,null,[F,...O]),()=>ar(...O),"datetime format",F=>Reflect.apply(F.d,F,[...O]),()=>bs,F=>H(F))}function V(...O){return Ee(F=>Reflect.apply(Es,null,[F,...O]),()=>or(...O),"number format",F=>Reflect.apply(F.n,F,[...O]),()=>bs,F=>H(F))}function re(O){return O.map(F=>H(F)||we(F)||ie(F)?Ms(String(F)):F)}const oe={normalize:re,interpolate:O=>O,type:"vnode"};function Le(...O){return Ee(F=>{let fe;const ye=F;try{ye.processor=oe,fe=Reflect.apply(Is,null,[ye,...O])}finally{ye.processor=null}return fe},()=>ir(...O),"translate",F=>F[lr](...O),F=>[Ms(F)],F=>ve(F))}function Se(...O){return Ee(F=>Reflect.apply(Es,null,[F,...O]),()=>or(...O),"number format",F=>F[ur](...O),$s,F=>H(F)||ve(F))}function vt(...O){return Ee(F=>Reflect.apply(Ls,null,[F,...O]),()=>ar(...O),"datetime format",F=>F[cr](...O),$s,F=>H(F)||ve(F))}function Fe(O){T=O,N.pluralRules=T}function Mn(O,F){return Ee(()=>{if(!O)return!1;const fe=H(F)?F:i.value,ye=gt(fe),ft=N.messageResolver(ye,O);return Mt(ft)||Pe(ft)||H(ft)},()=>[O],"translate exists",fe=>Reflect.apply(fe.te,fe,[O,F]),g1,fe=>ie(fe))}function Nn(O){let F=null;const fe=Ba(N,l.value,i.value);for(let ye=0;ye{o&&(i.value=O,N.locale=O,Ht(N,i.value,l.value))}),pe(e.fallbackLocale,O=>{o&&(l.value=O,N.fallbackLocale=O,Ht(N,i.value,l.value))}));const ne={id:Ps,locale:ce,fallbackLocale:ge,get inheritLocale(){return o},set inheritLocale(O){o=O,O&&e&&(i.value=e.locale.value,l.value=e.fallbackLocale.value,Ht(N,i.value,l.value))},get availableLocales(){return Object.keys(c.value).sort()},messages:ae,get modifiers(){return P},get pluralRules(){return T||{}},get isGlobal(){return r},get missingWarn(){return f},set missingWarn(O){f=O,N.missingWarn=f},get fallbackWarn(){return y},set fallbackWarn(O){y=O,N.fallbackWarn=y},get fallbackRoot(){return S},set fallbackRoot(O){S=O},get fallbackFormat(){return g},set fallbackFormat(O){g=O,N.fallbackFormat=g},get warnHtmlMessage(){return I},set warnHtmlMessage(O){I=O,N.warnHtmlMessage=O},get escapeParameter(){return L},set escapeParameter(O){L=O,N.escapeParameter=O},t:rt,getLocaleMessage:gt,setLocaleMessage:bt,mergeLocaleMessage:Rt,getPostTranslationHandler:Te,setPostTranslationHandler:tt,getMissingHandler:De,setMissingHandler:nt,[Ja]:Fe};return ne.datetimeFormats=_e,ne.numberFormats=Ne,ne.rt=J,ne.te=Mn,ne.tm=Ft,ne.d=te,ne.n=V,ne.getDateTimeFormat=$n,ne.setDateTimeFormat=h,ne.mergeDateTimeFormat=m,ne.getNumberFormat=$,ne.setNumberFormat=z,ne.mergeNumberFormat=be,ne[Qa]=n,ne[lr]=Le,ne[cr]=vt,ne[ur]=Se,ne}function y1(t){const e=H(t.locale)?t.locale:Kt,n=H(t.fallbackLocale)||ve(t.fallbackLocale)||ee(t.fallbackLocale)||t.fallbackLocale===!1?t.fallbackLocale:e,r=me(t.missing)?t.missing:void 0,s=ie(t.silentTranslationWarn)||At(t.silentTranslationWarn)?!t.silentTranslationWarn:!0,a=ie(t.silentFallbackWarn)||At(t.silentFallbackWarn)?!t.silentFallbackWarn:!0,o=ie(t.fallbackRoot)?t.fallbackRoot:!0,i=!!t.formatFallbackMessages,l=ee(t.modifiers)?t.modifiers:{},c=t.pluralizationRules,u=me(t.postTranslation)?t.postTranslation:void 0,d=H(t.warnHtmlInMessage)?t.warnHtmlInMessage!=="off":!0,f=!!t.escapeParameterHtml,y=ie(t.sync)?t.sync:!0;let S=t.messages;if(ee(t.sharedMessages)){const P=t.sharedMessages;S=Object.keys(P).reduce((N,B)=>{const G=N[B]||(N[B]={});return ke(G,P[B]),N},S||{})}const{__i18n:g,__root:b,__injectWithOption:p}=t,E=t.datetimeFormats,I=t.numberFormats,L=t.flatJson;return{locale:e,fallbackLocale:n,messages:S,flatJson:L,datetimeFormats:E,numberFormats:I,missing:r,missingWarn:s,fallbackWarn:a,fallbackRoot:o,fallbackFormat:i,modifiers:l,pluralRules:c,postTranslation:u,warnHtmlMessage:d,escapeParameter:f,messageResolver:t.messageResolver,inheritLocale:y,__i18n:g,__root:b,__injectWithOption:p}}function fr(t={}){const e=Mr(y1(t)),{__extender:n}=t,r={id:e.id,get locale(){return e.locale.value},set locale(s){e.locale.value=s},get fallbackLocale(){return e.fallbackLocale.value},set fallbackLocale(s){e.fallbackLocale.value=s},get messages(){return e.messages.value},get datetimeFormats(){return e.datetimeFormats.value},get numberFormats(){return e.numberFormats.value},get availableLocales(){return e.availableLocales},get missing(){return e.getMissingHandler()},set missing(s){e.setMissingHandler(s)},get silentTranslationWarn(){return ie(e.missingWarn)?!e.missingWarn:e.missingWarn},set silentTranslationWarn(s){e.missingWarn=ie(s)?!s:s},get silentFallbackWarn(){return ie(e.fallbackWarn)?!e.fallbackWarn:e.fallbackWarn},set silentFallbackWarn(s){e.fallbackWarn=ie(s)?!s:s},get modifiers(){return e.modifiers},get formatFallbackMessages(){return e.fallbackFormat},set formatFallbackMessages(s){e.fallbackFormat=s},get postTranslation(){return e.getPostTranslationHandler()},set postTranslation(s){e.setPostTranslationHandler(s)},get sync(){return e.inheritLocale},set sync(s){e.inheritLocale=s},get warnHtmlInMessage(){return e.warnHtmlMessage?"warn":"off"},set warnHtmlInMessage(s){e.warnHtmlMessage=s!=="off"},get escapeParameterHtml(){return e.escapeParameter},set escapeParameterHtml(s){e.escapeParameter=s},get pluralizationRules(){return e.pluralRules||{}},__composer:e,t(...s){return Reflect.apply(e.t,e,[...s])},rt(...s){return Reflect.apply(e.rt,e,[...s])},tc(...s){const[a,o,i]=s,l={plural:1};let c=null,u=null;if(!H(a))throw Me(Ie.INVALID_ARGUMENT);const d=a;return H(o)?l.locale=o:we(o)?l.plural=o:ve(o)?c=o:ee(o)&&(u=o),H(i)?l.locale=i:ve(i)?c=i:ee(i)&&(u=i),Reflect.apply(e.t,e,[d,c||u||{},l])},te(s,a){return e.te(s,a)},tm(s){return e.tm(s)},getLocaleMessage(s){return e.getLocaleMessage(s)},setLocaleMessage(s,a){e.setLocaleMessage(s,a)},mergeLocaleMessage(s,a){e.mergeLocaleMessage(s,a)},d(...s){return Reflect.apply(e.d,e,[...s])},getDateTimeFormat(s){return e.getDateTimeFormat(s)},setDateTimeFormat(s,a){e.setDateTimeFormat(s,a)},mergeDateTimeFormat(s,a){e.mergeDateTimeFormat(s,a)},n(...s){return Reflect.apply(e.n,e,[...s])},getNumberFormat(s){return e.getNumberFormat(s)},setNumberFormat(s,a){e.setNumberFormat(s,a)},mergeNumberFormat(s,a){e.mergeNumberFormat(s,a)}};return r.__extender=n,r}function w1(t,e,n){return{beforeCreate(){const r=Wt();if(!r)throw Me(Ie.UNEXPECTED_ERROR);const s=this.$options;if(s.i18n){const a=s.i18n;if(s.__i18n&&(a.__i18n=s.__i18n),a.__root=e,this===this.$root)this.$i18n=Fs(t,a);else{a.__injectWithOption=!0,a.__extender=n.__vueI18nExtend,this.$i18n=fr(a);const o=this.$i18n;o.__extender&&(o.__disposer=o.__extender(this.$i18n))}}else if(s.__i18n)if(this===this.$root)this.$i18n=Fs(t,s);else{this.$i18n=fr({__i18n:s.__i18n,__injectWithOption:!0,__extender:n.__vueI18nExtend,__root:e});const a=this.$i18n;a.__extender&&(a.__disposer=a.__extender(this.$i18n))}else this.$i18n=t;s.__i18nGlobal&&eo(e,s,s),this.$t=(...a)=>this.$i18n.t(...a),this.$rt=(...a)=>this.$i18n.rt(...a),this.$tc=(...a)=>this.$i18n.tc(...a),this.$te=(a,o)=>this.$i18n.te(a,o),this.$d=(...a)=>this.$i18n.d(...a),this.$n=(...a)=>this.$i18n.n(...a),this.$tm=a=>this.$i18n.tm(a),n.__setInstance(r,this.$i18n)},mounted(){},unmounted(){const r=Wt();if(!r)throw Me(Ie.UNEXPECTED_ERROR);const s=this.$i18n;delete this.$t,delete this.$rt,delete this.$tc,delete this.$te,delete this.$d,delete this.$n,delete this.$tm,s.__disposer&&(s.__disposer(),delete s.__disposer,delete s.__extender),n.__deleteInstance(r),delete this.$i18n}}}function Fs(t,e){t.locale=e.locale||t.locale,t.fallbackLocale=e.fallbackLocale||t.fallbackLocale,t.missing=e.missing||t.missing,t.silentTranslationWarn=e.silentTranslationWarn||t.silentFallbackWarn,t.silentFallbackWarn=e.silentFallbackWarn||t.silentFallbackWarn,t.formatFallbackMessages=e.formatFallbackMessages||t.formatFallbackMessages,t.postTranslation=e.postTranslation||t.postTranslation,t.warnHtmlInMessage=e.warnHtmlInMessage||t.warnHtmlInMessage,t.escapeParameterHtml=e.escapeParameterHtml||t.escapeParameterHtml,t.sync=e.sync||t.sync,t.__composer[Ja](e.pluralizationRules||t.pluralizationRules);const n=Ir(t.locale,{messages:e.messages,__i18n:e.__i18n});return Object.keys(n).forEach(r=>t.mergeLocaleMessage(r,n[r])),e.datetimeFormats&&Object.keys(e.datetimeFormats).forEach(r=>t.mergeDateTimeFormat(r,e.datetimeFormats[r])),e.numberFormats&&Object.keys(e.numberFormats).forEach(r=>t.mergeNumberFormat(r,e.numberFormats[r])),t}const Nr={tag:{type:[String,Object]},locale:{type:String},scope:{type:String,validator:t=>t==="parent"||t==="global",default:"parent"},i18n:{type:Object}};function k1({slots:t},e){return e.length===1&&e[0]==="default"?(t.default?t.default():[]).reduce((r,s)=>[...r,...s.type===he?s.children:[s]],[]):e.reduce((n,r)=>{const s=t[r];return s&&(n[r]=s()),n},{})}function to(){return he}const L1=R({name:"i18n-t",props:ke({keypath:{type:String,required:!0},plural:{type:[Number,String],validator:t=>we(t)||!isNaN(t)}},Nr),setup(t,e){const{slots:n,attrs:r}=e,s=t.i18n||In({useScope:t.scope,__useComponent:!0});return()=>{const a=Object.keys(n).filter(d=>d!=="_"),o={};t.locale&&(o.locale=t.locale),t.plural!==void 0&&(o.plural=H(t.plural)?+t.plural:t.plural);const i=k1(e,a),l=s[lr](t.keypath,i,o),c=ke({},r),u=H(t.tag)||le(t.tag)?t.tag:to();return Ct(u,c,l)}}}),Rs=L1;function S1(t){return ve(t)&&!H(t[0])}function no(t,e,n,r){const{slots:s,attrs:a}=e;return()=>{const o={part:!0};let i={};t.locale&&(o.locale=t.locale),H(t.format)?o.key=t.format:le(t.format)&&(H(t.format.key)&&(o.key=t.format.key),i=Object.keys(t.format).reduce((f,y)=>n.includes(y)?ke({},f,{[y]:t.format[y]}):f,{}));const l=r(t.value,o,i);let c=[o.key];ve(l)?c=l.map((f,y)=>{const S=s[f.type],g=S?S({[f.type]:f.value,index:y,parts:l}):[f.value];return S1(g)&&(g[0].key=`${f.type}-${y}`),g}):H(l)&&(c=[l]);const u=ke({},a),d=H(t.tag)||le(t.tag)?t.tag:to();return Ct(d,u,c)}}const E1=R({name:"i18n-n",props:ke({value:{type:Number,required:!0},format:{type:[String,Object]}},Nr),setup(t,e){const n=t.i18n||In({useScope:t.scope,__useComponent:!0});return no(t,e,za,(...r)=>n[ur](...r))}}),Vs=E1,O1=R({name:"i18n-d",props:ke({value:{type:[Number,Date],required:!0},format:{type:[String,Object]}},Nr),setup(t,e){const n=t.i18n||In({useScope:t.scope,__useComponent:!0});return no(t,e,Ya,(...r)=>n[cr](...r))}}),Ds=O1;function C1(t,e){const n=t;if(t.mode==="composition")return n.__getInstance(e)||t.global;{const r=n.__getInstance(e);return r!=null?r.__composer:t.global.__composer}}function A1(t){const e=o=>{const{instance:i,value:l}=o;if(!i||!i.$)throw Me(Ie.UNEXPECTED_ERROR);const c=C1(t,i.$),u=Hs(l);return[Reflect.apply(c.t,c,[...Us(u)]),c]};return{created:(o,i)=>{const[l,c]=e(i);mn&&t.global===c&&(o.__i18nWatcher=pe(c.locale,()=>{i.instance&&i.instance.$forceUpdate()})),o.__composer=c,o.textContent=l},unmounted:o=>{mn&&o.__i18nWatcher&&(o.__i18nWatcher(),o.__i18nWatcher=void 0,delete o.__i18nWatcher),o.__composer&&(o.__composer=void 0,delete o.__composer)},beforeUpdate:(o,{value:i})=>{if(o.__composer){const l=o.__composer,c=Hs(i);o.textContent=Reflect.apply(l.t,l,[...Us(c)])}},getSSRProps:o=>{const[i]=e(o);return{textContent:i}}}}function Hs(t){if(H(t))return{path:t};if(ee(t)){if(!("path"in t))throw Me(Ie.REQUIRED_VALUE,"path");return t}else throw Me(Ie.INVALID_VALUE)}function Us(t){const{path:e,locale:n,args:r,choice:s,plural:a}=t,o={},i=r||{};return H(n)&&(o.locale=n),we(s)&&(o.plural=s),we(a)&&(o.plural=a),[e,i,o]}function I1(t,e,...n){const r=ee(n[0])?n[0]:{};(ie(r.globalInstall)?r.globalInstall:!0)&&([Rs.name,"I18nT"].forEach(a=>t.component(a,Rs)),[Vs.name,"I18nN"].forEach(a=>t.component(a,Vs)),[Ds.name,"I18nD"].forEach(a=>t.component(a,Ds))),t.directive("t",A1(e))}const M1=ut("global-vue-i18n");function N1(t={},e){const n=__VUE_I18N_LEGACY_API__&&ie(t.legacy)?t.legacy:__VUE_I18N_LEGACY_API__,r=ie(t.globalInjection)?t.globalInjection:!0,s=new Map,[a,o]=$1(t,n),i=ut("");function l(f){return s.get(f)||null}function c(f,y){s.set(f,y)}function u(f){s.delete(f)}const d={get mode(){return __VUE_I18N_LEGACY_API__&&n?"legacy":"composition"},async install(f,...y){if(f.__VUE_I18N_SYMBOL__=i,f.provide(f.__VUE_I18N_SYMBOL__,d),ee(y[0])){const b=y[0];d.__composerExtend=b.__composerExtend,d.__vueI18nExtend=b.__vueI18nExtend}let S=null;!n&&r&&(S=U1(f,d.global)),__VUE_I18N_FULL_INSTALL__&&I1(f,d,...y),__VUE_I18N_LEGACY_API__&&n&&f.mixin(w1(o,o.__composer,d));const g=f.unmount;f.unmount=()=>{S&&S(),d.dispose(),g()}},get global(){return o},dispose(){a.stop()},__instances:s,__getInstance:l,__setInstance:c,__deleteInstance:u};return d}function In(t={}){const e=Wt();if(e==null)throw Me(Ie.MUST_BE_CALL_SETUP_TOP);if(!e.isCE&&e.appContext.app!=null&&!e.appContext.app.__VUE_I18N_SYMBOL__)throw Me(Ie.NOT_INSTALLED);const n=P1(e),r=F1(n),s=Za(e),a=T1(t,s);if(a==="global")return eo(r,t,s),r;if(a==="parent"){let l=R1(n,e,t.__useComponent);return l==null&&(l=r),l}const o=n;let i=o.__getInstance(e);if(i==null){const l=ke({},t);"__i18n"in s&&(l.__i18n=s.__i18n),r&&(l.__root=r),i=Mr(l),o.__composerExtend&&(i[dr]=o.__composerExtend(i)),D1(o,e,i),o.__setInstance(e,i)}return i}function $1(t,e,n){const r=Lo(),s=__VUE_I18N_LEGACY_API__&&e?r.run(()=>fr(t)):r.run(()=>Mr(t));if(s==null)throw Me(Ie.UNEXPECTED_ERROR);return[r,s]}function P1(t){const e=Nt(t.isCE?M1:t.appContext.app.__VUE_I18N_SYMBOL__);if(!e)throw Me(t.isCE?Ie.NOT_INSTALLED_WITH_PROVIDE:Ie.UNEXPECTED_ERROR);return e}function T1(t,e){return On(t)?"__i18n"in e?"local":"global":t.useScope?t.useScope:"local"}function F1(t){return t.mode==="composition"?t.global:t.global.__composer}function R1(t,e,n=!1){let r=null;const s=e.root;let a=V1(e,n);for(;a!=null;){const o=t;if(t.mode==="composition")r=o.__getInstance(a);else if(__VUE_I18N_LEGACY_API__){const i=o.__getInstance(a);i!=null&&(r=i.__composer,n&&r&&!r[Qa]&&(r=null))}if(r!=null||s===a)break;a=a.parent}return r}function V1(t,e=!1){return t==null?null:e&&t.vnode.ctx||t.parent}function D1(t,e,n){Ye(()=>{},e),gn(()=>{const r=n;t.__deleteInstance(e);const s=r[dr];s&&(s(),delete r[dr])},e)}const H1=["locale","fallbackLocale","availableLocales"],Bs=["t","rt","d","n","tm","te"];function U1(t,e){const n=Object.create(null);return H1.forEach(s=>{const a=Object.getOwnPropertyDescriptor(e,s);if(!a)throw Me(Ie.UNEXPECTED_ERROR);const o=So(a.value)?{get(){return a.value.value},set(i){a.value.value=i}}:{get(){return a.get&&a.get()}};Object.defineProperty(n,s,o)}),t.config.globalProperties.$i18n=n,Bs.forEach(s=>{const a=Object.getOwnPropertyDescriptor(e,s);if(!a||!a.value)throw Me(Ie.UNEXPECTED_ERROR);Object.defineProperty(t.config.globalProperties,`$${s}`,a)}),()=>{delete t.config.globalProperties.$i18n,Bs.forEach(s=>{delete t.config.globalProperties[`$${s}`]})}}v1();Xp(Mp);qp(Gp);Jp(Ba);if(__INTLIFY_PROD_DEVTOOLS__){const t=mt();t.__INTLIFY__=!0,Np(t.__INTLIFY_DEVTOOLS_GLOBAL_HOOK__)}const ro=()=>{const t=Nt("$env"),{t:e,locale:n}=In();return{locale:n,$env:t,t:e}},B1={class:"text-slate-600 text-base mt-2"},W1={class:"flex flex-row justify-start items-start mt-4"},j1={class:"relative h-14"},x1=["label","status"],K1={key:0,class:"absolute bottom-0 left-0 text-sm text-[#ff4d4f]"},G1={class:"text-[#3451b2] text-base"},Y1=R({__name:"TOTP",setup(t){const{t:e,$env:n,locale:r}=ro(),s=X(""),a=X(Lt.NORMAL),o=X(""),i=X({code:"",expires:""}),l=u=>{s.value=u.detail.value,a.value=Lt.NORMAL},c=()=>{if(s.value.length<=0)o.value=e("components_totp_3"),a.value=Lt.ERROR;else try{const{otp:u,expires:d}=Fm.generate(s.value);i.value.code=u,i.value.expires=Dm(d).format()}catch{o.value=e("components_totp_5"),a.value=Lt.ERROR}};return(u,d)=>(_(),A("div",null,[w("div",B1,Z(v(e)("components_totp_6")),1),w("div",W1,[w("div",j1,[w("r-input",{label:v(e)("components_totp_2"),class:"w-64 h-8 rounded-lg block text-lg",status:a.value,onInput:l},null,40,x1),a.value===v(Lt).ERROR?(_(),A("div",K1,Z(o.value),1)):j("",!0)]),w("r-button",{class:"ml-1 h-8",onClick:c},Z(v(e)("components_totp_1")),1)]),w("div",G1,[w("div",null,"code: "+Z(i.value.code),1),w("div",null,Z(v(e)("components_totp_4"))+": "+Z(i.value.expires),1)])]))}}),so=nr.locale,Ot=N1({legacy:!1,locale:so,fallbackLocale:Qt.EN,messages:xm,devtools:!1}),Un=t=>(Ot.mode===Ha.LEGACY?Ot.global.locale=t:Ot.global.locale.value=t,t),z1=(t,e=so)=>{Ot.global.mergeLocaleMessage(e,t)},ao=t=>t?Ot.global.locale===t||ls.includes(t)?Promise.resolve(Un(t)):Oo(Object.assign({"./en.json":()=>cn(()=>import("./en.Bkn4-Vvy.js"),[]),"./zh-CN.json":()=>cn(()=>import("./zh-CN.PUkQxDBJ.js"),[])}),`./${t}.json`,2).then(e=>(z1(e.default,t),ls.push(t),Un(t))):Promise.reject("lang is undefined"),X1=R({__name:"Layout",setup(t){const{$env:e,locale:n}=ro(),{lang:r}=hr(),s=()=>{const a=r.value||Qt.EN;n.value=a,e.locale=a,ao(a).catch(o=>{console.log("error",o)}),Rm(Da,a)};return it(()=>{s()}),Ye(()=>{Bm()}),(a,o)=>(_(),K(v(ka).Layout))}}),q1=()=>{cn(()=>import("./pwa-install.es.DI7OvJx5.js"),[]).then(()=>{let t=document.getElementById(cs);t||(t=document.createElement(Km),t.setAttribute("manifest-url",Gm),t.setAttribute("id",cs),document.body.appendChild(t))})},s_={extends:ka,enhanceApp({app:t,router:e,siteData:n}){cn(()=>import("./index.MWfHGcqb.js").then(s=>s.i),__vite__mapDeps([0,1])),q1(),t.use(zm);const r=Vm(Da)||Qt.EN;ao(r).then(()=>{Um("__VUE_PROD_DEVTOOLS__",!1),t.use(Ot),t.component("Layout",X1),t.component("TOTP",Y1)}).catch(s=>{console.log("error",s)})}};export{s_ as R}; diff --git a/assets/chunks/theme.FPvZ3Ede.js b/assets/chunks/theme.FPvZ3Ede.js deleted file mode 100644 index b06920374b..0000000000 --- a/assets/chunks/theme.FPvZ3Ede.js +++ /dev/null @@ -1,20 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/chunks/index.CafPLwUV.js","assets/chunks/framework.eq-HTtE3.js"])))=>i.map(i=>d[i]); -import{d as R,o as _,c as A,r as C,a as Ve,t as Z,n as ue,b as K,w as M,e as j,T as _n,_ as q,u as hr,i as io,f as lo,g as vn,h as U,j as w,k as v,l as pt,m as Bn,p as X,q as pe,s as it,v as Ye,x as gn,y as mr,z as co,A as uo,B as lt,F as he,C as Ce,D as bn,E as yn,G as x,H as Ws,I as We,J as Yt,K as at,L as Nt,M as fo,N as js,O as ho,P as Ue,Q as xs,R as wn,S as Ks,U as Bt,V as pr,W as kn,X as mo,Y as Gs,Z as Ys,$ as po,a0 as Ct,a1 as zs,a2 as Xs,a3 as _o,a4 as vo,a5 as go,a6 as qs,a7 as bo,a8 as yo,a9 as wo,aa as ko,ab as Lo,ac as So,ad as Wt,ae as Eo,af as Oo,ag as cn}from"./framework.eq-HTtE3.js";const Co=R({__name:"VPBadge",props:{text:{},type:{default:"tip"}},setup(t){return(e,n)=>(_(),A("span",{class:ue(["VPBadge",e.type])},[C(e.$slots,"default",{},()=>[Ve(Z(e.text),1)])],2))}}),Ao={key:0,class:"VPBackdrop"},Io=R({__name:"VPBackdrop",props:{show:{type:Boolean}},setup(t){return(e,n)=>(_(),K(_n,{name:"fade"},{default:M(()=>[e.show?(_(),A("div",Ao)):j("",!0)]),_:1}))}}),Mo=q(Io,[["__scopeId","data-v-aa2f5bb7"]]),se=hr;function No(t,e){let n,r=!1;return()=>{n&&clearTimeout(n),r?n=setTimeout(t,e):(t(),(r=!0)&&setTimeout(()=>r=!1,e))}}function Wn(t){return/^\//.test(t)?t:`/${t}`}function _r(t){const{pathname:e,search:n,hash:r,protocol:s}=new URL(t,"http://a.com");if(io(t)||t.startsWith("#")||!s.startsWith("http")||!lo(e))return t;const{site:a}=se(),o=e.endsWith("/")||e.endsWith(".html")?t:t.replace(/(?:(^\.+)\/)?.*$/,`$1${e.replace(/(\.md)?$/,a.value.cleanUrls?"":".html")}${n}${r}`);return vn(o)}function zt({correspondingLink:t=!1}={}){const{site:e,localeIndex:n,page:r,theme:s,hash:a}=se(),o=U(()=>{var l,c;return{label:(l=e.value.locales[n.value])==null?void 0:l.label,link:((c=e.value.locales[n.value])==null?void 0:c.link)||(n.value==="root"?"/":`/${n.value}/`)}});return{localeLinks:U(()=>Object.entries(e.value.locales).flatMap(([l,c])=>o.value.label===c.label?[]:{text:c.label,link:$o(c.link||(l==="root"?"/":`/${l}/`),s.value.i18nRouting!==!1&&t,r.value.relativePath.slice(o.value.link.length-1),!e.value.cleanUrls)+a.value})),currentLang:o}}function $o(t,e,n,r){return e?t.replace(/\/$/,"")+Wn(n.replace(/(^|\/)index\.md$/,"$1").replace(/\.md$/,r?".html":"")):t}const Po={class:"NotFound"},To={class:"code"},Fo={class:"title"},Ro={class:"quote"},Vo={class:"action"},Do=["href","aria-label"],Ho=R({__name:"NotFound",setup(t){const{theme:e}=se(),{currentLang:n}=zt();return(r,s)=>{var a,o,i,l,c;return _(),A("div",Po,[w("p",To,Z(((a=v(e).notFound)==null?void 0:a.code)??"404"),1),w("h1",Fo,Z(((o=v(e).notFound)==null?void 0:o.title)??"PAGE NOT FOUND"),1),s[0]||(s[0]=w("div",{class:"divider"},null,-1)),w("blockquote",Ro,Z(((i=v(e).notFound)==null?void 0:i.quote)??"But if you don't change your direction, and if you keep looking, you may end up where you are heading."),1),w("div",Vo,[w("a",{class:"link",href:v(vn)(v(n).link),"aria-label":((l=v(e).notFound)==null?void 0:l.linkLabel)??"go to home"},Z(((c=v(e).notFound)==null?void 0:c.linkText)??"Take me home"),9,Do)])])}}}),Uo=q(Ho,[["__scopeId","data-v-46f27357"]]);function Js(t,e){if(Array.isArray(t))return sn(t);if(t==null)return[];e=Wn(e);const n=Object.keys(t).sort((s,a)=>a.split("/").length-s.split("/").length).find(s=>e.startsWith(Wn(s))),r=n?t[n]:[];return Array.isArray(r)?sn(r):sn(r.items,r.base)}function Bo(t){const e=[];let n=0;for(const r in t){const s=t[r];if(s.items){n=e.push(s);continue}e[n]||e.push({items:[]}),e[n].items.push(s)}return e}function Wo(t){const e=[];function n(r){for(const s of r)s.text&&s.link&&e.push({text:s.text,link:s.link,docFooterText:s.docFooterText}),s.items&&n(s.items)}return n(t),e}function jn(t,e){return Array.isArray(e)?e.some(n=>jn(t,n)):pt(t,e.link)?!0:e.items?jn(t,e.items):!1}function sn(t,e){return[...t].map(n=>{const r={...n},s=r.base||e;return s&&r.link&&(r.link=s+r.link),r.items&&(r.items=sn(r.items,s)),r})}function et(){const{frontmatter:t,page:e,theme:n}=se(),r=Bn("(min-width: 960px)"),s=X(!1),a=U(()=>{const g=n.value.sidebar,b=e.value.relativePath;return g?Js(g,b):[]}),o=X(a.value);pe(a,(g,b)=>{JSON.stringify(g)!==JSON.stringify(b)&&(o.value=a.value)});const i=U(()=>t.value.sidebar!==!1&&o.value.length>0&&t.value.layout!=="home"),l=U(()=>c?t.value.aside==null?n.value.aside==="left":t.value.aside==="left":!1),c=U(()=>t.value.layout==="home"?!1:t.value.aside!=null?!!t.value.aside:n.value.aside!==!1),u=U(()=>i.value&&r.value),d=U(()=>i.value?Bo(o.value):[]);function f(){s.value=!0}function y(){s.value=!1}function S(){s.value?y():f()}return{isOpen:s,sidebar:o,sidebarGroups:d,hasSidebar:i,hasAside:c,leftAside:l,isSidebarEnabled:u,open:f,close:y,toggle:S}}function jo(t,e){let n;it(()=>{n=t.value?document.activeElement:void 0}),Ye(()=>{window.addEventListener("keyup",r)}),gn(()=>{window.removeEventListener("keyup",r)});function r(s){s.key==="Escape"&&t.value&&(e(),n==null||n.focus())}}function xo(t){const{page:e,hash:n}=se(),r=X(!1),s=U(()=>t.value.collapsed!=null),a=U(()=>!!t.value.link),o=X(!1),i=()=>{o.value=pt(e.value.relativePath,t.value.link)};pe([e,t,n],i),Ye(i);const l=U(()=>o.value?!0:t.value.items?jn(e.value.relativePath,t.value.items):!1),c=U(()=>!!(t.value.items&&t.value.items.length));it(()=>{r.value=!!(s.value&&t.value.collapsed)}),mr(()=>{(o.value||l.value)&&(r.value=!1)});function u(){s.value&&(r.value=!r.value)}return{collapsed:r,collapsible:s,isLink:a,isActiveLink:o,hasActiveLink:l,hasChildren:c,toggle:u}}function Ko(){const{hasSidebar:t}=et(),e=Bn("(min-width: 960px)"),n=Bn("(min-width: 1280px)");return{isAsideEnabled:U(()=>!n.value&&!e.value?!1:t.value?n.value:e.value)}}const xn=[];function Qs(t){return typeof t.outline=="object"&&!Array.isArray(t.outline)&&t.outline.label||t.outlineTitle||"On this page"}function vr(t){const e=[...document.querySelectorAll(".VPDoc :where(h1,h2,h3,h4,h5,h6)")].filter(n=>n.id&&n.hasChildNodes()).map(n=>{const r=Number(n.tagName[1]);return{element:n,title:Go(n),link:"#"+n.id,level:r}});return Yo(e,t)}function Go(t){let e="";for(const n of t.childNodes)if(n.nodeType===1){if(n.classList.contains("VPBadge")||n.classList.contains("header-anchor")||n.classList.contains("ignore-header"))continue;e+=n.textContent}else n.nodeType===3&&(e+=n.textContent);return e.trim()}function Yo(t,e){if(e===!1)return[];const n=(typeof e=="object"&&!Array.isArray(e)?e.level:e)||2,[r,s]=typeof n=="number"?[n,n]:n==="deep"?[2,6]:n;t=t.filter(o=>o.level>=r&&o.level<=s),xn.length=0;for(const{element:o,link:i}of t)xn.push({element:o,link:i});const a=[];e:for(let o=0;o=0;l--){const c=t[l];if(c.level{requestAnimationFrame(a),window.addEventListener("scroll",r)}),co(()=>{o(location.hash)}),gn(()=>{window.removeEventListener("scroll",r)});function a(){if(!n.value)return;const i=window.scrollY,l=window.innerHeight,c=document.body.offsetHeight,u=Math.abs(i+l-c)<1,d=xn.map(({element:y,link:S})=>({link:S,top:Xo(y)})).filter(({top:y})=>!Number.isNaN(y)).sort((y,S)=>y.top-S.top);if(!d.length){o(null);return}if(i<1){o(null);return}if(u){o(d[d.length-1].link);return}let f=null;for(const{link:y,top:S}of d){if(S>i+uo()+4)break;f=y}o(f)}function o(i){s&&s.classList.remove("active"),i==null?s=null:s=t.value.querySelector(`a[href="${decodeURIComponent(i)}"]`);const l=s;l?(l.classList.add("active"),e.value.style.top=l.offsetTop+39+"px",e.value.style.opacity="1"):(e.value.style.top="33px",e.value.style.opacity="0")}}function Xo(t){let e=0;for(;t!==document.body;){if(t===null)return NaN;e+=t.offsetTop,t=t.offsetParent}return e}const qo=["href","title"],Jo=R({__name:"VPDocOutlineItem",props:{headers:{},root:{type:Boolean}},setup(t){function e({target:n}){const r=n.href.split("#")[1],s=document.getElementById(decodeURIComponent(r));s==null||s.focus({preventScroll:!0})}return(n,r)=>{const s=lt("VPDocOutlineItem",!0);return _(),A("ul",{class:ue(["VPDocOutlineItem",n.root?"root":"nested"])},[(_(!0),A(he,null,Ce(n.headers,({children:a,link:o,title:i})=>(_(),A("li",null,[w("a",{class:"outline-link",href:o,onClick:e,title:i},Z(i),9,qo),a!=null&&a.length?(_(),K(s,{key:0,headers:a},null,8,["headers"])):j("",!0)]))),256))],2)}}}),Zs=q(Jo,[["__scopeId","data-v-fc78d431"]]),Qo={class:"content"},Zo={"aria-level":"2",class:"outline-title",id:"doc-outline-aria-label",role:"heading"},ei=R({__name:"VPDocAsideOutline",setup(t){const{frontmatter:e,theme:n}=se(),r=bn([]);yn(()=>{r.value=vr(e.value.outline??n.value.outline)});const s=X(),a=X();return zo(s,a),(o,i)=>(_(),A("nav",{"aria-labelledby":"doc-outline-aria-label",class:ue(["VPDocAsideOutline",{"has-outline":r.value.length>0}]),ref_key:"container",ref:s},[w("div",Qo,[w("div",{class:"outline-marker",ref_key:"marker",ref:a},null,512),w("div",Zo,Z(v(Qs)(v(n))),1),x(Zs,{headers:r.value,root:!0},null,8,["headers"])])],2))}}),ti=q(ei,[["__scopeId","data-v-e95709bb"]]),ni={class:"VPDocAsideCarbonAds"},ri=R({__name:"VPDocAsideCarbonAds",props:{carbonAds:{}},setup(t){const e=()=>null;return(n,r)=>(_(),A("div",ni,[x(v(e),{"carbon-ads":n.carbonAds},null,8,["carbon-ads"])]))}}),si={class:"VPDocAside"},ai=R({__name:"VPDocAside",setup(t){const{theme:e}=se();return(n,r)=>(_(),A("div",si,[C(n.$slots,"aside-top",{},void 0,!0),C(n.$slots,"aside-outline-before",{},void 0,!0),x(ti),C(n.$slots,"aside-outline-after",{},void 0,!0),r[0]||(r[0]=w("div",{class:"spacer"},null,-1)),C(n.$slots,"aside-ads-before",{},void 0,!0),v(e).carbonAds?(_(),K(ri,{key:0,"carbon-ads":v(e).carbonAds},null,8,["carbon-ads"])):j("",!0),C(n.$slots,"aside-ads-after",{},void 0,!0),C(n.$slots,"aside-bottom",{},void 0,!0)]))}}),oi=q(ai,[["__scopeId","data-v-4bbff643"]]);function ii(){const{theme:t,page:e}=se();return U(()=>{const{text:n="Edit this page",pattern:r=""}=t.value.editLink||{};let s;return typeof r=="function"?s=r(e.value):s=r.replace(/:path/g,e.value.filePath),{url:s,text:n}})}function li(){const{page:t,theme:e,frontmatter:n}=se();return U(()=>{var c,u,d,f,y,S,g,b;const r=Js(e.value.sidebar,t.value.relativePath),s=Wo(r),a=ci(s,p=>p.link.replace(/[?#].*$/,"")),o=a.findIndex(p=>pt(t.value.relativePath,p.link)),i=((c=e.value.docFooter)==null?void 0:c.prev)===!1&&!n.value.prev||n.value.prev===!1,l=((u=e.value.docFooter)==null?void 0:u.next)===!1&&!n.value.next||n.value.next===!1;return{prev:i?void 0:{text:(typeof n.value.prev=="string"?n.value.prev:typeof n.value.prev=="object"?n.value.prev.text:void 0)??((d=a[o-1])==null?void 0:d.docFooterText)??((f=a[o-1])==null?void 0:f.text),link:(typeof n.value.prev=="object"?n.value.prev.link:void 0)??((y=a[o-1])==null?void 0:y.link)},next:l?void 0:{text:(typeof n.value.next=="string"?n.value.next:typeof n.value.next=="object"?n.value.next.text:void 0)??((S=a[o+1])==null?void 0:S.docFooterText)??((g=a[o+1])==null?void 0:g.text),link:(typeof n.value.next=="object"?n.value.next.link:void 0)??((b=a[o+1])==null?void 0:b.link)}}})}function ci(t,e){const n=new Set;return t.filter(r=>{const s=e(r);return n.has(s)?!1:n.add(s)})}const je=R({__name:"VPLink",props:{tag:{},href:{},noIcon:{type:Boolean},target:{},rel:{}},setup(t){const e=t,n=U(()=>e.tag??(e.href?"a":"span")),r=U(()=>e.href&&Ws.test(e.href)||e.target==="_blank");return(s,a)=>(_(),K(We(n.value),{class:ue(["VPLink",{link:s.href,"vp-external-link-icon":r.value,"no-icon":s.noIcon}]),href:s.href?v(_r)(s.href):void 0,target:s.target??(r.value?"_blank":void 0),rel:s.rel??(r.value?"noreferrer":void 0)},{default:M(()=>[C(s.$slots,"default")]),_:3},8,["class","href","target","rel"]))}}),ui={class:"VPLastUpdated"},di=["datetime"],fi=R({__name:"VPDocFooterLastUpdated",setup(t){const{theme:e,page:n,lang:r}=se(),s=U(()=>new Date(n.value.lastUpdated)),a=U(()=>s.value.toISOString()),o=X("");return Ye(()=>{it(()=>{var i,l,c;o.value=new Intl.DateTimeFormat((l=(i=e.value.lastUpdated)==null?void 0:i.formatOptions)!=null&&l.forceLocale?r.value:void 0,((c=e.value.lastUpdated)==null?void 0:c.formatOptions)??{dateStyle:"short",timeStyle:"short"}).format(s.value)})}),(i,l)=>{var c;return _(),A("p",ui,[Ve(Z(((c=v(e).lastUpdated)==null?void 0:c.text)||v(e).lastUpdatedText||"Last updated")+": ",1),w("time",{datetime:a.value},Z(o.value),9,di)])}}}),hi=q(fi,[["__scopeId","data-v-3c231858"]]),mi={key:0,class:"VPDocFooter"},pi={key:0,class:"edit-info"},_i={key:0,class:"edit-link"},vi={key:1,class:"last-updated"},gi={key:1,class:"prev-next","aria-labelledby":"doc-footer-aria-label"},bi={class:"pager"},yi=["innerHTML"],wi=["innerHTML"],ki={class:"pager"},Li=["innerHTML"],Si=["innerHTML"],Ei=R({__name:"VPDocFooter",setup(t){const{theme:e,page:n,frontmatter:r}=se(),s=ii(),a=li(),o=U(()=>e.value.editLink&&r.value.editLink!==!1),i=U(()=>n.value.lastUpdated),l=U(()=>o.value||i.value||a.value.prev||a.value.next);return(c,u)=>{var d,f,y,S;return l.value?(_(),A("footer",mi,[C(c.$slots,"doc-footer-before",{},void 0,!0),o.value||i.value?(_(),A("div",pi,[o.value?(_(),A("div",_i,[x(je,{class:"edit-link-button",href:v(s).url,"no-icon":!0},{default:M(()=>[u[0]||(u[0]=w("span",{class:"vpi-square-pen edit-link-icon"},null,-1)),Ve(" "+Z(v(s).text),1)]),_:1},8,["href"])])):j("",!0),i.value?(_(),A("div",vi,[x(hi)])):j("",!0)])):j("",!0),(d=v(a).prev)!=null&&d.link||(f=v(a).next)!=null&&f.link?(_(),A("nav",gi,[u[1]||(u[1]=w("span",{class:"visually-hidden",id:"doc-footer-aria-label"},"Pager",-1)),w("div",bi,[(y=v(a).prev)!=null&&y.link?(_(),K(je,{key:0,class:"pager-link prev",href:v(a).prev.link},{default:M(()=>{var g;return[w("span",{class:"desc",innerHTML:((g=v(e).docFooter)==null?void 0:g.prev)||"Previous page"},null,8,yi),w("span",{class:"title",innerHTML:v(a).prev.text},null,8,wi)]}),_:1},8,["href"])):j("",!0)]),w("div",ki,[(S=v(a).next)!=null&&S.link?(_(),K(je,{key:0,class:"pager-link next",href:v(a).next.link},{default:M(()=>{var g;return[w("span",{class:"desc",innerHTML:((g=v(e).docFooter)==null?void 0:g.next)||"Next page"},null,8,Li),w("span",{class:"title",innerHTML:v(a).next.text},null,8,Si)]}),_:1},8,["href"])):j("",!0)])])):j("",!0)])):j("",!0)}}}),Oi=q(Ei,[["__scopeId","data-v-00ab7d08"]]),Ci={class:"container"},Ai={class:"aside-container"},Ii={class:"aside-content"},Mi={class:"content"},Ni={class:"content-container"},$i={class:"main"},Pi=R({__name:"VPDoc",setup(t){const{theme:e}=se(),n=Yt(),{hasSidebar:r,hasAside:s,leftAside:a}=et(),o=U(()=>n.path.replace(/[./]+/g,"_").replace(/_html$/,""));return(i,l)=>{const c=lt("Content");return _(),A("div",{class:ue(["VPDoc",{"has-sidebar":v(r),"has-aside":v(s)}])},[C(i.$slots,"doc-top",{},void 0,!0),w("div",Ci,[v(s)?(_(),A("div",{key:0,class:ue(["aside",{"left-aside":v(a)}])},[l[0]||(l[0]=w("div",{class:"aside-curtain"},null,-1)),w("div",Ai,[w("div",Ii,[x(oi,null,{"aside-top":M(()=>[C(i.$slots,"aside-top",{},void 0,!0)]),"aside-bottom":M(()=>[C(i.$slots,"aside-bottom",{},void 0,!0)]),"aside-outline-before":M(()=>[C(i.$slots,"aside-outline-before",{},void 0,!0)]),"aside-outline-after":M(()=>[C(i.$slots,"aside-outline-after",{},void 0,!0)]),"aside-ads-before":M(()=>[C(i.$slots,"aside-ads-before",{},void 0,!0)]),"aside-ads-after":M(()=>[C(i.$slots,"aside-ads-after",{},void 0,!0)]),_:3})])])],2)):j("",!0),w("div",Mi,[w("div",Ni,[C(i.$slots,"doc-before",{},void 0,!0),w("main",$i,[x(c,{class:ue(["vp-doc",[o.value,v(e).externalLinkIcon&&"external-link-icon-enabled"]])},null,8,["class"])]),x(Oi,null,{"doc-footer-before":M(()=>[C(i.$slots,"doc-footer-before",{},void 0,!0)]),_:3}),C(i.$slots,"doc-after",{},void 0,!0)])])]),C(i.$slots,"doc-bottom",{},void 0,!0)],2)}}}),Ti=q(Pi,[["__scopeId","data-v-9f8645df"]]),Fi=R({__name:"VPButton",props:{tag:{},size:{default:"medium"},theme:{default:"brand"},text:{},href:{},target:{},rel:{}},setup(t){const e=t,n=U(()=>e.href&&Ws.test(e.href)),r=U(()=>e.tag||e.href?"a":"button");return(s,a)=>(_(),K(We(r.value),{class:ue(["VPButton",[s.size,s.theme]]),href:s.href?v(_r)(s.href):void 0,target:e.target??(n.value?"_blank":void 0),rel:e.rel??(n.value?"noreferrer":void 0)},{default:M(()=>[Ve(Z(s.text),1)]),_:1},8,["class","href","target","rel"]))}}),Ri=q(Fi,[["__scopeId","data-v-bbea5d5d"]]),Vi=["src","alt"],Di=R({inheritAttrs:!1,__name:"VPImage",props:{image:{},alt:{}},setup(t){return(e,n)=>{const r=lt("VPImage",!0);return e.image?(_(),A(he,{key:0},[typeof e.image=="string"||"src"in e.image?(_(),A("img",at({key:0,class:"VPImage"},typeof e.image=="string"?e.$attrs:{...e.image,...e.$attrs},{src:v(vn)(typeof e.image=="string"?e.image:e.image.src),alt:e.alt??(typeof e.image=="string"?"":e.image.alt||"")}),null,16,Vi)):(_(),A(he,{key:1},[x(r,at({class:"dark",image:e.image.dark,alt:e.image.alt},e.$attrs),null,16,["image","alt"]),x(r,at({class:"light",image:e.image.light,alt:e.image.alt},e.$attrs),null,16,["image","alt"])],64))],64)):j("",!0)}}}),un=q(Di,[["__scopeId","data-v-7b8f395d"]]),Hi={class:"container"},Ui={class:"main"},Bi={key:0,class:"name"},Wi=["innerHTML"],ji=["innerHTML"],xi=["innerHTML"],Ki={key:0,class:"actions"},Gi={key:0,class:"image"},Yi={class:"image-container"},zi=R({__name:"VPHero",props:{name:{},text:{},tagline:{},image:{},actions:{}},setup(t){const e=Nt("hero-image-slot-exists");return(n,r)=>(_(),A("div",{class:ue(["VPHero",{"has-image":n.image||v(e)}])},[w("div",Hi,[w("div",Ui,[C(n.$slots,"home-hero-info-before",{},void 0,!0),C(n.$slots,"home-hero-info",{},()=>[n.name?(_(),A("h1",Bi,[w("span",{innerHTML:n.name,class:"clip"},null,8,Wi)])):j("",!0),n.text?(_(),A("p",{key:1,innerHTML:n.text,class:"text"},null,8,ji)):j("",!0),n.tagline?(_(),A("p",{key:2,innerHTML:n.tagline,class:"tagline"},null,8,xi)):j("",!0)],!0),C(n.$slots,"home-hero-info-after",{},void 0,!0),n.actions?(_(),A("div",Ki,[(_(!0),A(he,null,Ce(n.actions,s=>(_(),A("div",{key:s.link,class:"action"},[x(Ri,{tag:"a",size:"medium",theme:s.theme,text:s.text,href:s.link,target:s.target,rel:s.rel},null,8,["theme","text","href","target","rel"])]))),128))])):j("",!0),C(n.$slots,"home-hero-actions-after",{},void 0,!0)]),n.image||v(e)?(_(),A("div",Gi,[w("div",Yi,[r[0]||(r[0]=w("div",{class:"image-bg"},null,-1)),C(n.$slots,"home-hero-image",{},()=>[n.image?(_(),K(un,{key:0,class:"image-src",image:n.image},null,8,["image"])):j("",!0)],!0)])])):j("",!0)])],2))}}),Xi=q(zi,[["__scopeId","data-v-0313f8fa"]]),qi=R({__name:"VPHomeHero",setup(t){const{frontmatter:e}=se();return(n,r)=>v(e).hero?(_(),K(Xi,{key:0,class:"VPHomeHero",name:v(e).hero.name,text:v(e).hero.text,tagline:v(e).hero.tagline,image:v(e).hero.image,actions:v(e).hero.actions},{"home-hero-info-before":M(()=>[C(n.$slots,"home-hero-info-before")]),"home-hero-info":M(()=>[C(n.$slots,"home-hero-info")]),"home-hero-info-after":M(()=>[C(n.$slots,"home-hero-info-after")]),"home-hero-actions-after":M(()=>[C(n.$slots,"home-hero-actions-after")]),"home-hero-image":M(()=>[C(n.$slots,"home-hero-image")]),_:3},8,["name","text","tagline","image","actions"])):j("",!0)}}),Ji={class:"box"},Qi={key:0,class:"icon"},Zi=["innerHTML"],el=["innerHTML"],tl=["innerHTML"],nl={key:4,class:"link-text"},rl={class:"link-text-value"},sl=R({__name:"VPFeature",props:{icon:{},title:{},details:{},link:{},linkText:{},rel:{},target:{}},setup(t){return(e,n)=>(_(),K(je,{class:"VPFeature",href:e.link,rel:e.rel,target:e.target,"no-icon":!0,tag:e.link?"a":"div"},{default:M(()=>[w("article",Ji,[typeof e.icon=="object"&&e.icon.wrap?(_(),A("div",Qi,[x(un,{image:e.icon,alt:e.icon.alt,height:e.icon.height||48,width:e.icon.width||48},null,8,["image","alt","height","width"])])):typeof e.icon=="object"?(_(),K(un,{key:1,image:e.icon,alt:e.icon.alt,height:e.icon.height||48,width:e.icon.width||48},null,8,["image","alt","height","width"])):e.icon?(_(),A("div",{key:2,class:"icon",innerHTML:e.icon},null,8,Zi)):j("",!0),w("h2",{class:"title",innerHTML:e.title},null,8,el),e.details?(_(),A("p",{key:3,class:"details",innerHTML:e.details},null,8,tl)):j("",!0),e.linkText?(_(),A("div",nl,[w("p",rl,[Ve(Z(e.linkText)+" ",1),n[0]||(n[0]=w("span",{class:"vpi-arrow-right link-text-icon"},null,-1))])])):j("",!0)])]),_:1},8,["href","rel","target","tag"]))}}),al=q(sl,[["__scopeId","data-v-ce15ebd4"]]),ol={key:0,class:"VPFeatures"},il={class:"container"},ll={class:"items"},cl=R({__name:"VPFeatures",props:{features:{}},setup(t){const e=t,n=U(()=>{const r=e.features.length;if(r){if(r===2)return"grid-2";if(r===3)return"grid-3";if(r%3===0)return"grid-6";if(r>3)return"grid-4"}else return});return(r,s)=>r.features?(_(),A("div",ol,[w("div",il,[w("div",ll,[(_(!0),A(he,null,Ce(r.features,a=>(_(),A("div",{key:a.title,class:ue(["item",[n.value]])},[x(al,{icon:a.icon,title:a.title,details:a.details,link:a.link,"link-text":a.linkText,rel:a.rel,target:a.target},null,8,["icon","title","details","link","link-text","rel","target"])],2))),128))])])])):j("",!0)}}),ul=q(cl,[["__scopeId","data-v-b79e191c"]]),dl=R({__name:"VPHomeFeatures",setup(t){const{frontmatter:e}=se();return(n,r)=>v(e).features?(_(),K(ul,{key:0,class:"VPHomeFeatures",features:v(e).features},null,8,["features"])):j("",!0)}}),fl=R({__name:"VPHomeContent",setup(t){const{width:e}=fo({initialWidth:0,includeScrollbar:!1});return(n,r)=>(_(),A("div",{class:"vp-doc container",style:js(v(e)?{"--vp-offset":`calc(50% - ${v(e)/2}px)`}:{})},[C(n.$slots,"default",{},void 0,!0)],4))}}),hl=q(fl,[["__scopeId","data-v-269c2bad"]]),ml={class:"VPHome"},pl=R({__name:"VPHome",setup(t){const{frontmatter:e}=se();return(n,r)=>{const s=lt("Content");return _(),A("div",ml,[C(n.$slots,"home-hero-before",{},void 0,!0),x(qi,null,{"home-hero-info-before":M(()=>[C(n.$slots,"home-hero-info-before",{},void 0,!0)]),"home-hero-info":M(()=>[C(n.$slots,"home-hero-info",{},void 0,!0)]),"home-hero-info-after":M(()=>[C(n.$slots,"home-hero-info-after",{},void 0,!0)]),"home-hero-actions-after":M(()=>[C(n.$slots,"home-hero-actions-after",{},void 0,!0)]),"home-hero-image":M(()=>[C(n.$slots,"home-hero-image",{},void 0,!0)]),_:3}),C(n.$slots,"home-hero-after",{},void 0,!0),C(n.$slots,"home-features-before",{},void 0,!0),x(dl),C(n.$slots,"home-features-after",{},void 0,!0),v(e).markdownStyles!==!1?(_(),K(hl,{key:0},{default:M(()=>[x(s)]),_:1})):(_(),K(s,{key:1}))])}}}),_l=q(pl,[["__scopeId","data-v-c1e44215"]]),vl={},gl={class:"VPPage"};function bl(t,e){const n=lt("Content");return _(),A("div",gl,[C(t.$slots,"page-top"),x(n),C(t.$slots,"page-bottom")])}const yl=q(vl,[["render",bl]]),wl=R({__name:"VPContent",setup(t){const{page:e,frontmatter:n}=se(),{hasSidebar:r}=et();return(s,a)=>(_(),A("div",{class:ue(["VPContent",{"has-sidebar":v(r),"is-home":v(n).layout==="home"}]),id:"VPContent"},[v(e).isNotFound?C(s.$slots,"not-found",{key:0},()=>[x(Uo)],!0):v(n).layout==="page"?(_(),K(yl,{key:1},{"page-top":M(()=>[C(s.$slots,"page-top",{},void 0,!0)]),"page-bottom":M(()=>[C(s.$slots,"page-bottom",{},void 0,!0)]),_:3})):v(n).layout==="home"?(_(),K(_l,{key:2},{"home-hero-before":M(()=>[C(s.$slots,"home-hero-before",{},void 0,!0)]),"home-hero-info-before":M(()=>[C(s.$slots,"home-hero-info-before",{},void 0,!0)]),"home-hero-info":M(()=>[C(s.$slots,"home-hero-info",{},void 0,!0)]),"home-hero-info-after":M(()=>[C(s.$slots,"home-hero-info-after",{},void 0,!0)]),"home-hero-actions-after":M(()=>[C(s.$slots,"home-hero-actions-after",{},void 0,!0)]),"home-hero-image":M(()=>[C(s.$slots,"home-hero-image",{},void 0,!0)]),"home-hero-after":M(()=>[C(s.$slots,"home-hero-after",{},void 0,!0)]),"home-features-before":M(()=>[C(s.$slots,"home-features-before",{},void 0,!0)]),"home-features-after":M(()=>[C(s.$slots,"home-features-after",{},void 0,!0)]),_:3})):v(n).layout&&v(n).layout!=="doc"?(_(),K(We(v(n).layout),{key:3})):(_(),K(Ti,{key:4},{"doc-top":M(()=>[C(s.$slots,"doc-top",{},void 0,!0)]),"doc-bottom":M(()=>[C(s.$slots,"doc-bottom",{},void 0,!0)]),"doc-footer-before":M(()=>[C(s.$slots,"doc-footer-before",{},void 0,!0)]),"doc-before":M(()=>[C(s.$slots,"doc-before",{},void 0,!0)]),"doc-after":M(()=>[C(s.$slots,"doc-after",{},void 0,!0)]),"aside-top":M(()=>[C(s.$slots,"aside-top",{},void 0,!0)]),"aside-outline-before":M(()=>[C(s.$slots,"aside-outline-before",{},void 0,!0)]),"aside-outline-after":M(()=>[C(s.$slots,"aside-outline-after",{},void 0,!0)]),"aside-ads-before":M(()=>[C(s.$slots,"aside-ads-before",{},void 0,!0)]),"aside-ads-after":M(()=>[C(s.$slots,"aside-ads-after",{},void 0,!0)]),"aside-bottom":M(()=>[C(s.$slots,"aside-bottom",{},void 0,!0)]),_:3}))],2))}}),kl=q(wl,[["__scopeId","data-v-c575eed1"]]),Ll={class:"container"},Sl=["innerHTML"],El=["innerHTML"],Ol=R({__name:"VPFooter",setup(t){const{theme:e,frontmatter:n}=se(),{hasSidebar:r}=et();return(s,a)=>v(e).footer&&v(n).footer!==!1?(_(),A("footer",{key:0,class:ue(["VPFooter",{"has-sidebar":v(r)}])},[w("div",Ll,[v(e).footer.message?(_(),A("p",{key:0,class:"message",innerHTML:v(e).footer.message},null,8,Sl)):j("",!0),v(e).footer.copyright?(_(),A("p",{key:1,class:"copyright",innerHTML:v(e).footer.copyright},null,8,El)):j("",!0)])],2)):j("",!0)}}),Cl=q(Ol,[["__scopeId","data-v-042815a5"]]);function Al(){const{theme:t,frontmatter:e}=se(),n=bn([]),r=U(()=>n.value.length>0);return yn(()=>{n.value=vr(e.value.outline??t.value.outline)}),{headers:n,hasLocalNav:r}}const Il={class:"menu-text"},Ml={class:"header"},Nl={class:"outline"},$l=R({__name:"VPLocalNavOutlineDropdown",props:{headers:{},navHeight:{}},setup(t){const e=t,{theme:n}=se(),r=X(!1),s=X(0),a=X(),o=X();function i(d){var f;(f=a.value)!=null&&f.contains(d.target)||(r.value=!1)}pe(r,d=>{if(d){document.addEventListener("click",i);return}document.removeEventListener("click",i)}),ho("Escape",()=>{r.value=!1}),yn(()=>{r.value=!1});function l(){r.value=!r.value,s.value=window.innerHeight+Math.min(window.scrollY-e.navHeight,0)}function c(d){d.target.classList.contains("outline-link")&&(o.value&&(o.value.style.transition="none"),Ue(()=>{r.value=!1}))}function u(){r.value=!1,window.scrollTo({top:0,left:0,behavior:"smooth"})}return(d,f)=>(_(),A("div",{class:"VPLocalNavOutlineDropdown",style:js({"--vp-vh":s.value+"px"}),ref_key:"main",ref:a},[d.headers.length>0?(_(),A("button",{key:0,onClick:l,class:ue({open:r.value})},[w("span",Il,Z(v(Qs)(v(n))),1),f[0]||(f[0]=w("span",{class:"vpi-chevron-right icon"},null,-1))],2)):(_(),A("button",{key:1,onClick:u},Z(v(n).returnToTopLabel||"Return to top"),1)),x(_n,{name:"flyout"},{default:M(()=>[r.value?(_(),A("div",{key:0,ref_key:"items",ref:o,class:"items",onClick:c},[w("div",Ml,[w("a",{class:"top-link",href:"#",onClick:u},Z(v(n).returnToTopLabel||"Return to top"),1)]),w("div",Nl,[x(Zs,{headers:d.headers},null,8,["headers"])])],512)):j("",!0)]),_:1})],4))}}),Pl=q($l,[["__scopeId","data-v-fd549330"]]),Tl={class:"container"},Fl=["aria-expanded"],Rl={class:"menu-text"},Vl=R({__name:"VPLocalNav",props:{open:{type:Boolean}},emits:["open-menu"],setup(t){const{theme:e,frontmatter:n}=se(),{hasSidebar:r}=et(),{headers:s}=Al(),{y:a}=xs(),o=X(0);Ye(()=>{o.value=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--vp-nav-height"))}),yn(()=>{s.value=vr(n.value.outline??e.value.outline)});const i=U(()=>s.value.length===0),l=U(()=>i.value&&!r.value),c=U(()=>({VPLocalNav:!0,"has-sidebar":r.value,empty:i.value,fixed:l.value}));return(u,d)=>v(n).layout!=="home"&&(!l.value||v(a)>=o.value)?(_(),A("div",{key:0,class:ue(c.value)},[w("div",Tl,[v(r)?(_(),A("button",{key:0,class:"menu","aria-expanded":u.open,"aria-controls":"VPSidebarNav",onClick:d[0]||(d[0]=f=>u.$emit("open-menu"))},[d[1]||(d[1]=w("span",{class:"vpi-align-left menu-icon"},null,-1)),w("span",Rl,Z(v(e).sidebarMenuLabel||"Menu"),1)],8,Fl)):j("",!0),x(Pl,{headers:v(s),navHeight:o.value},null,8,["headers","navHeight"])])],2)):j("",!0)}}),Dl=q(Vl,[["__scopeId","data-v-6c3804f2"]]);function Hl(){const t=X(!1);function e(){t.value=!0,window.addEventListener("resize",s)}function n(){t.value=!1,window.removeEventListener("resize",s)}function r(){t.value?n():e()}function s(){window.outerWidth>=768&&n()}const a=Yt();return pe(()=>a.path,n),{isScreenOpen:t,openScreen:e,closeScreen:n,toggleScreen:r}}const Ul={},Bl={class:"VPSwitch",type:"button",role:"switch"},Wl={class:"check"},jl={key:0,class:"icon"};function xl(t,e){return _(),A("button",Bl,[w("span",Wl,[t.$slots.default?(_(),A("span",jl,[C(t.$slots,"default",{},void 0,!0)])):j("",!0)])])}const Kl=q(Ul,[["render",xl],["__scopeId","data-v-bdb57495"]]),Gl=R({__name:"VPSwitchAppearance",setup(t){const{isDark:e,theme:n}=se(),r=Nt("toggle-appearance",()=>{e.value=!e.value}),s=X("");return mr(()=>{s.value=e.value?n.value.lightModeSwitchTitle||"Switch to light theme":n.value.darkModeSwitchTitle||"Switch to dark theme"}),(a,o)=>(_(),K(Kl,{title:s.value,class:"VPSwitchAppearance","aria-checked":v(e),onClick:v(r)},{default:M(()=>o[0]||(o[0]=[w("span",{class:"vpi-sun sun"},null,-1),w("span",{class:"vpi-moon moon"},null,-1)])),_:1},8,["title","aria-checked","onClick"]))}}),gr=q(Gl,[["__scopeId","data-v-41f06fec"]]),Yl={key:0,class:"VPNavBarAppearance"},zl=R({__name:"VPNavBarAppearance",setup(t){const{site:e}=se();return(n,r)=>v(e).appearance&&v(e).appearance!=="force-dark"&&v(e).appearance!=="force-auto"?(_(),A("div",Yl,[x(gr)])):j("",!0)}}),Xl=q(zl,[["__scopeId","data-v-12ad808b"]]),br=X();let ea=!1,Pn=0;function ql(t){const e=X(!1);if(wn){!ea&&Jl(),Pn++;const n=pe(br,r=>{var s,a,o;r===t.el.value||(s=t.el.value)!=null&&s.contains(r)?(e.value=!0,(a=t.onFocus)==null||a.call(t)):(e.value=!1,(o=t.onBlur)==null||o.call(t))});gn(()=>{n(),Pn--,Pn||Ql()})}return Ks(e)}function Jl(){document.addEventListener("focusin",ta),ea=!0,br.value=document.activeElement}function Ql(){document.removeEventListener("focusin",ta)}function ta(){br.value=document.activeElement}const Zl={class:"VPMenuLink"},ec=R({__name:"VPMenuLink",props:{item:{}},setup(t){const{page:e}=se();return(n,r)=>(_(),A("div",Zl,[x(je,{class:ue({active:v(pt)(v(e).relativePath,n.item.activeMatch||n.item.link,!!n.item.activeMatch)}),href:n.item.link,target:n.item.target,rel:n.item.rel},{default:M(()=>[Ve(Z(n.item.text),1)]),_:1},8,["class","href","target","rel"])]))}}),Ln=q(ec,[["__scopeId","data-v-7e61137e"]]),tc={class:"VPMenuGroup"},nc={key:0,class:"title"},rc=R({__name:"VPMenuGroup",props:{text:{},items:{}},setup(t){return(e,n)=>(_(),A("div",tc,[e.text?(_(),A("p",nc,Z(e.text),1)):j("",!0),(_(!0),A(he,null,Ce(e.items,r=>(_(),A(he,null,["link"in r?(_(),K(Ln,{key:0,item:r},null,8,["item"])):j("",!0)],64))),256))]))}}),sc=q(rc,[["__scopeId","data-v-b7ccc091"]]),ac={class:"VPMenu"},oc={key:0,class:"items"},ic=R({__name:"VPMenu",props:{items:{}},setup(t){return(e,n)=>(_(),A("div",ac,[e.items?(_(),A("div",oc,[(_(!0),A(he,null,Ce(e.items,r=>(_(),A(he,{key:JSON.stringify(r)},["link"in r?(_(),K(Ln,{key:0,item:r},null,8,["item"])):"component"in r?(_(),K(We(r.component),at({key:1,ref_for:!0},r.props),null,16)):(_(),K(sc,{key:2,text:r.text,items:r.items},null,8,["text","items"]))],64))),128))])):j("",!0),C(e.$slots,"default",{},void 0,!0)]))}}),lc=q(ic,[["__scopeId","data-v-e8a1c26e"]]),cc=["aria-expanded","aria-label"],uc={key:0,class:"text"},dc=["innerHTML"],fc={key:1,class:"vpi-more-horizontal icon"},hc={class:"menu"},mc=R({__name:"VPFlyout",props:{icon:{},button:{},label:{},items:{}},setup(t){const e=X(!1),n=X();ql({el:n,onBlur:r});function r(){e.value=!1}return(s,a)=>(_(),A("div",{class:"VPFlyout",ref_key:"el",ref:n,onMouseenter:a[1]||(a[1]=o=>e.value=!0),onMouseleave:a[2]||(a[2]=o=>e.value=!1)},[w("button",{type:"button",class:"button","aria-haspopup":"true","aria-expanded":e.value,"aria-label":s.label,onClick:a[0]||(a[0]=o=>e.value=!e.value)},[s.button||s.icon?(_(),A("span",uc,[s.icon?(_(),A("span",{key:0,class:ue([s.icon,"option-icon"])},null,2)):j("",!0),s.button?(_(),A("span",{key:1,innerHTML:s.button},null,8,dc)):j("",!0),a[3]||(a[3]=w("span",{class:"vpi-chevron-down text-icon"},null,-1))])):(_(),A("span",fc))],8,cc),w("div",hc,[x(lc,{items:s.items},{default:M(()=>[C(s.$slots,"default",{},void 0,!0)]),_:3},8,["items"])])],544))}}),yr=q(mc,[["__scopeId","data-v-7e42a472"]]),pc=["href","aria-label","innerHTML"],_c=R({__name:"VPSocialLink",props:{icon:{},link:{},ariaLabel:{}},setup(t){const e=t,n=U(()=>typeof e.icon=="object"?e.icon.svg:``);return(r,s)=>(_(),A("a",{class:"VPSocialLink no-icon",href:r.link,"aria-label":r.ariaLabel??(typeof r.icon=="string"?r.icon:""),target:"_blank",rel:"noopener",innerHTML:n.value},null,8,pc))}}),vc=q(_c,[["__scopeId","data-v-1d65eafe"]]),gc={class:"VPSocialLinks"},bc=R({__name:"VPSocialLinks",props:{links:{}},setup(t){return(e,n)=>(_(),A("div",gc,[(_(!0),A(he,null,Ce(e.links,({link:r,icon:s,ariaLabel:a})=>(_(),K(vc,{key:r,icon:s,link:r,ariaLabel:a},null,8,["icon","link","ariaLabel"]))),128))]))}}),wr=q(bc,[["__scopeId","data-v-259de3d6"]]),yc={key:0,class:"group translations"},wc={class:"trans-title"},kc={key:1,class:"group"},Lc={class:"item appearance"},Sc={class:"label"},Ec={class:"appearance-action"},Oc={key:2,class:"group"},Cc={class:"item social-links"},Ac=R({__name:"VPNavBarExtra",setup(t){const{site:e,theme:n}=se(),{localeLinks:r,currentLang:s}=zt({correspondingLink:!0}),a=U(()=>r.value.length&&s.value.label||e.value.appearance||n.value.socialLinks);return(o,i)=>a.value?(_(),K(yr,{key:0,class:"VPNavBarExtra",label:"extra navigation"},{default:M(()=>[v(r).length&&v(s).label?(_(),A("div",yc,[w("p",wc,Z(v(s).label),1),(_(!0),A(he,null,Ce(v(r),l=>(_(),K(Ln,{key:l.link,item:l},null,8,["item"]))),128))])):j("",!0),v(e).appearance&&v(e).appearance!=="force-dark"&&v(e).appearance!=="force-auto"?(_(),A("div",kc,[w("div",Lc,[w("p",Sc,Z(v(n).darkModeSwitchLabel||"Appearance"),1),w("div",Ec,[x(gr)])])])):j("",!0),v(n).socialLinks?(_(),A("div",Oc,[w("div",Cc,[x(wr,{class:"social-links-list",links:v(n).socialLinks},null,8,["links"])])])):j("",!0)]),_:1})):j("",!0)}}),Ic=q(Ac,[["__scopeId","data-v-1b59c413"]]),Mc=["aria-expanded"],Nc=R({__name:"VPNavBarHamburger",props:{active:{type:Boolean}},emits:["click"],setup(t){return(e,n)=>(_(),A("button",{type:"button",class:ue(["VPNavBarHamburger",{active:e.active}]),"aria-label":"mobile navigation","aria-expanded":e.active,"aria-controls":"VPNavScreen",onClick:n[0]||(n[0]=r=>e.$emit("click"))},n[1]||(n[1]=[w("span",{class:"container"},[w("span",{class:"top"}),w("span",{class:"middle"}),w("span",{class:"bottom"})],-1)]),10,Mc))}}),$c=q(Nc,[["__scopeId","data-v-0fa0fd27"]]),Pc=["innerHTML"],Tc=R({__name:"VPNavBarMenuLink",props:{item:{}},setup(t){const{page:e}=se();return(n,r)=>(_(),K(je,{class:ue({VPNavBarMenuLink:!0,active:v(pt)(v(e).relativePath,n.item.activeMatch||n.item.link,!!n.item.activeMatch)}),href:n.item.link,noIcon:n.item.noIcon,target:n.item.target,rel:n.item.rel,tabindex:"0"},{default:M(()=>[w("span",{innerHTML:n.item.text},null,8,Pc)]),_:1},8,["class","href","noIcon","target","rel"]))}}),Fc=q(Tc,[["__scopeId","data-v-e692fe86"]]),Rc=R({__name:"VPNavBarMenuGroup",props:{item:{}},setup(t){const e=t,{page:n}=se(),r=a=>"component"in a?!1:"link"in a?pt(n.value.relativePath,a.link,!!e.item.activeMatch):a.items.some(r),s=U(()=>r(e.item));return(a,o)=>(_(),K(yr,{class:ue({VPNavBarMenuGroup:!0,active:v(pt)(v(n).relativePath,a.item.activeMatch,!!a.item.activeMatch)||s.value}),button:a.item.text,items:a.item.items},null,8,["class","button","items"]))}}),Vc={key:0,"aria-labelledby":"main-nav-aria-label",class:"VPNavBarMenu"},Dc=R({__name:"VPNavBarMenu",setup(t){const{theme:e}=se();return(n,r)=>v(e).nav?(_(),A("nav",Vc,[r[0]||(r[0]=w("span",{id:"main-nav-aria-label",class:"visually-hidden"}," Main Navigation ",-1)),(_(!0),A(he,null,Ce(v(e).nav,s=>(_(),A(he,{key:JSON.stringify(s)},["link"in s?(_(),K(Fc,{key:0,item:s},null,8,["item"])):"component"in s?(_(),K(We(s.component),at({key:1,ref_for:!0},s.props),null,16)):(_(),K(Rc,{key:2,item:s},null,8,["item"]))],64))),128))])):j("",!0)}}),Hc=q(Dc,[["__scopeId","data-v-30753f5b"]]);var $r;const na=typeof window<"u",Uc=t=>typeof t=="string",an=()=>{};na&&(($r=window==null?void 0:window.navigator)!=null&&$r.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);function Kn(t){return typeof t=="function"?t():v(t)}function Bc(t,e){function n(...r){t(()=>e.apply(this,r),{fn:e,thisArg:this,args:r})}return n}function Wc(t,e={}){let n,r;return s=>{const a=Kn(t),o=Kn(e.maxWait);if(n&&clearTimeout(n),a<=0||o!==void 0&&o<=0)return r&&(clearTimeout(r),r=null),s();o&&!r&&(r=setTimeout(()=>{n&&clearTimeout(n),r=null,s()},o)),n=setTimeout(()=>{r&&clearTimeout(r),r=null,s()},a)}}function jc(t){return t}function xc(t){return zs()?(Xs(t),!0):!1}function ra(t,e=200,n={}){return Bc(Wc(e,n),t)}function Tn(t,e=200,n={}){if(e<=0)return t;const r=X(t.value),s=ra(()=>{r.value=t.value},e,n);return pe(t,()=>s()),r}function sa(t,e,n){return pe(t,(r,s,a)=>{r&&e(r,s,a)},n)}function Kc(t){var e;const n=Kn(t);return(e=n==null?void 0:n.$el)!=null?e:n}const aa=na?window:void 0;function en(...t){let e,n,r,s;if(Uc(t[0])?([n,r,s]=t,e=aa):[e,n,r,s]=t,!e)return an;let a=an;const o=pe(()=>Kc(e),l=>{a(),l&&(l.addEventListener(n,r,s),a=()=>{l.removeEventListener(n,r,s),a=an})},{immediate:!0,flush:"post"}),i=()=>{o(),a()};return xc(i),i}const Pr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Tr="__vueuse_ssr_handlers__";Pr[Tr]=Pr[Tr]||{};const Gc={ctrl:"control",command:"meta",cmd:"meta",option:"alt",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright"};function Yc(t={}){const{reactive:e=!1,target:n=aa,aliasMap:r=Gc,passive:s=!0,onEventFired:a=an}=t,o=Bt(new Set),i={toJSON(){return{}},current:o},l=e?Bt(i):i,c=new Set,u=new Set;function d(g,b){g in l&&(e?l[g]=b:l[g].value=b)}function f(){for(const g of u)d(g,!1)}function y(g,b){var p,E;const I=(p=g.key)==null?void 0:p.toLowerCase(),L=[(E=g.code)==null?void 0:E.toLowerCase(),I].filter(Boolean);I&&(b?o.add(I):o.delete(I));for(const P of L)u.add(P),d(P,b);I==="meta"&&!b?(c.forEach(P=>{o.delete(P),d(P,!1)}),c.clear()):typeof g.getModifierState=="function"&&g.getModifierState("Meta")&&b&&[...o,...L].forEach(P=>c.add(P))}en(n,"keydown",g=>(y(g,!0),a(g)),{passive:s}),en(n,"keyup",g=>(y(g,!1),a(g)),{passive:s}),en("blur",f,{passive:!0}),en("focus",f,{passive:!0});const S=new Proxy(l,{get(g,b,p){if(typeof b!="string")return Reflect.get(g,b,p);if(b=b.toLowerCase(),b in r&&(b=r[b]),!(b in l))if(/[+_-]/.test(b)){const I=b.split(/[+_-]/g).map(L=>L.trim());l[b]=U(()=>I.every(L=>v(S[L])))}else l[b]=X(!1);const E=Reflect.get(g,b,p);return e?v(E):E}});return S}var Fr;(function(t){t.UP="UP",t.RIGHT="RIGHT",t.DOWN="DOWN",t.LEFT="LEFT",t.NONE="NONE"})(Fr||(Fr={}));var zc=Object.defineProperty,Rr=Object.getOwnPropertySymbols,Xc=Object.prototype.hasOwnProperty,qc=Object.prototype.propertyIsEnumerable,Vr=(t,e,n)=>e in t?zc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Jc=(t,e)=>{for(var n in e||(e={}))Xc.call(e,n)&&Vr(t,n,e[n]);if(Rr)for(var n of Rr(e))qc.call(e,n)&&Vr(t,n,e[n]);return t};const Qc={easeInSine:[.12,0,.39,0],easeOutSine:[.61,1,.88,1],easeInOutSine:[.37,0,.63,1],easeInQuad:[.11,0,.5,0],easeOutQuad:[.5,1,.89,1],easeInOutQuad:[.45,0,.55,1],easeInCubic:[.32,0,.67,0],easeOutCubic:[.33,1,.68,1],easeInOutCubic:[.65,0,.35,1],easeInQuart:[.5,0,.75,0],easeOutQuart:[.25,1,.5,1],easeInOutQuart:[.76,0,.24,1],easeInQuint:[.64,0,.78,0],easeOutQuint:[.22,1,.36,1],easeInOutQuint:[.83,0,.17,1],easeInExpo:[.7,0,.84,0],easeOutExpo:[.16,1,.3,1],easeInOutExpo:[.87,0,.13,1],easeInCirc:[.55,0,1,.45],easeOutCirc:[0,.55,.45,1],easeInOutCirc:[.85,0,.15,1],easeInBack:[.36,0,.66,-.56],easeOutBack:[.34,1.56,.64,1],easeInOutBack:[.68,-.6,.32,1.6]};Jc({linear:jc},Qc);function Ze(t){return Array.isArray?Array.isArray(t):la(t)==="[object Array]"}const Zc=1/0;function eu(t){if(typeof t=="string")return t;let e=t+"";return e=="0"&&1/t==-Zc?"-0":e}function tu(t){return t==null?"":eu(t)}function Be(t){return typeof t=="string"}function oa(t){return typeof t=="number"}function nu(t){return t===!0||t===!1||ru(t)&&la(t)=="[object Boolean]"}function ia(t){return typeof t=="object"}function ru(t){return ia(t)&&t!==null}function $e(t){return t!=null}function Fn(t){return!t.trim().length}function la(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const su="Incorrect 'index' type",au=t=>`Invalid value for key ${t}`,ou=t=>`Pattern length exceeds max of ${t}.`,iu=t=>`Missing ${t} property in key`,lu=t=>`Property 'weight' in key '${t}' must be a positive integer`,Dr=Object.prototype.hasOwnProperty;class cu{constructor(e){this._keys=[],this._keyMap={};let n=0;e.forEach(r=>{let s=ca(r);n+=s.weight,this._keys.push(s),this._keyMap[s.id]=s,n+=s.weight}),this._keys.forEach(r=>{r.weight/=n})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function ca(t){let e=null,n=null,r=null,s=1,a=null;if(Be(t)||Ze(t))r=t,e=Hr(t),n=Gn(t);else{if(!Dr.call(t,"name"))throw new Error(iu("name"));const o=t.name;if(r=o,Dr.call(t,"weight")&&(s=t.weight,s<=0))throw new Error(lu(o));e=Hr(o),n=Gn(o),a=t.getFn}return{path:e,id:n,weight:s,src:r,getFn:a}}function Hr(t){return Ze(t)?t:t.split(".")}function Gn(t){return Ze(t)?t.join("."):t}function uu(t,e){let n=[],r=!1;const s=(a,o,i)=>{if($e(a))if(!o[i])n.push(a);else{let l=o[i];const c=a[l];if(!$e(c))return;if(i===o.length-1&&(Be(c)||oa(c)||nu(c)))n.push(tu(c));else if(Ze(c)){r=!0;for(let u=0,d=c.length;ut.score===e.score?t.idx{this._keysMap[n.id]=r})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Be(this.docs[0])?this.docs.forEach((e,n)=>{this._addString(e,n)}):this.docs.forEach((e,n)=>{this._addObject(e,n)}),this.norm.clear())}add(e){const n=this.size();Be(e)?this._addString(e,n):this._addObject(e,n)}removeAt(e){this.records.splice(e,1);for(let n=e,r=this.size();n{let o=s.getFn?s.getFn(e):this.getFn(e,s.path);if($e(o)){if(Ze(o)){let i=[];const l=[{nestedArrIndex:-1,value:o}];for(;l.length;){const{nestedArrIndex:c,value:u}=l.pop();if($e(u))if(Be(u)&&!Fn(u)){let d={v:u,i:c,n:this.norm.get(u)};i.push(d)}else Ze(u)&&u.forEach((d,f)=>{l.push({nestedArrIndex:f,value:d})})}r.$[a]=i}else if(Be(o)&&!Fn(o)){let i={v:o,n:this.norm.get(o)};r.$[a]=i}}}),this.records.push(r)}toJSON(){return{keys:this.keys,records:this.records}}}function ua(t,e,{getFn:n=Q.getFn,fieldNormWeight:r=Q.fieldNormWeight}={}){const s=new kr({getFn:n,fieldNormWeight:r});return s.setKeys(t.map(ca)),s.setSources(e),s.create(),s}function vu(t,{getFn:e=Q.getFn,fieldNormWeight:n=Q.fieldNormWeight}={}){const{keys:r,records:s}=t,a=new kr({getFn:e,fieldNormWeight:n});return a.setKeys(r),a.setIndexRecords(s),a}function tn(t,{errors:e=0,currentLocation:n=0,expectedLocation:r=0,distance:s=Q.distance,ignoreLocation:a=Q.ignoreLocation}={}){const o=e/t.length;if(a)return o;const i=Math.abs(r-n);return s?o+i/s:i?1:o}function gu(t=[],e=Q.minMatchCharLength){let n=[],r=-1,s=-1,a=0;for(let o=t.length;a=e&&n.push([r,s]),r=-1)}return t[a-1]&&a-r>=e&&n.push([r,a-1]),n}const ht=32;function bu(t,e,n,{location:r=Q.location,distance:s=Q.distance,threshold:a=Q.threshold,findAllMatches:o=Q.findAllMatches,minMatchCharLength:i=Q.minMatchCharLength,includeMatches:l=Q.includeMatches,ignoreLocation:c=Q.ignoreLocation}={}){if(e.length>ht)throw new Error(ou(ht));const u=e.length,d=t.length,f=Math.max(0,Math.min(r,d));let y=a,S=f;const g=i>1||l,b=g?Array(d):[];let p;for(;(p=t.indexOf(e,S))>-1;){let N=tn(e,{currentLocation:p,expectedLocation:f,distance:s,ignoreLocation:c});if(y=Math.min(N,y),S=p+u,g){let B=0;for(;B=ce;_e-=1){let Ne=_e-1,Te=n[t.charAt(Ne)];if(g&&(b[Ne]=+!!Te),ae[_e]=(ae[_e+1]<<1|1)&Te,N&&(ae[_e]|=(E[_e+1]|E[_e])<<1|1|E[_e+1]),ae[_e]&P&&(I=tn(e,{errors:N,currentLocation:Ne,expectedLocation:f,distance:s,ignoreLocation:c}),I<=y)){if(y=I,S=Ne,S<=f)break;ce=Math.max(1,2*f-S)}}if(tn(e,{errors:N+1,currentLocation:f,expectedLocation:f,distance:s,ignoreLocation:c})>y)break;E=ae}const T={isMatch:S>=0,score:Math.max(.001,I)};if(g){const N=gu(b,i);N.length?l&&(T.indices=N):T.isMatch=!1}return T}function yu(t){let e={};for(let n=0,r=t.length;n{this.chunks.push({pattern:f,alphabet:yu(f),startIndex:y})},d=this.pattern.length;if(d>ht){let f=0;const y=d%ht,S=d-y;for(;f{const{isMatch:p,score:E,indices:I}=bu(e,S,g,{location:s+b,distance:a,threshold:o,findAllMatches:i,minMatchCharLength:l,includeMatches:r,ignoreLocation:c});p&&(f=!0),d+=E,p&&I&&(u=[...u,...I])});let y={isMatch:f,score:f?d/this.chunks.length:1};return f&&r&&(y.indices=u),y}}class ct{constructor(e){this.pattern=e}static isMultiMatch(e){return Ur(e,this.multiRegex)}static isSingleMatch(e){return Ur(e,this.singleRegex)}search(){}}function Ur(t,e){const n=t.match(e);return n?n[1]:null}class wu extends ct{constructor(e){super(e)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(e){const n=e===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class ku extends ct{constructor(e){super(e)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(e){const n=e.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class Lu extends ct{constructor(e){super(e)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(e){const n=e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class Su extends ct{constructor(e){super(e)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(e){const n=!e.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class Eu extends ct{constructor(e){super(e)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(e){const n=e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[e.length-this.pattern.length,e.length-1]}}}class Ou extends ct{constructor(e){super(e)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(e){const n=!e.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,e.length-1]}}}class fa extends ct{constructor(e,{location:n=Q.location,threshold:r=Q.threshold,distance:s=Q.distance,includeMatches:a=Q.includeMatches,findAllMatches:o=Q.findAllMatches,minMatchCharLength:i=Q.minMatchCharLength,isCaseSensitive:l=Q.isCaseSensitive,ignoreLocation:c=Q.ignoreLocation}={}){super(e),this._bitapSearch=new da(e,{location:n,threshold:r,distance:s,includeMatches:a,findAllMatches:o,minMatchCharLength:i,isCaseSensitive:l,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(e){return this._bitapSearch.searchIn(e)}}class ha extends ct{constructor(e){super(e)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(e){let n=0,r;const s=[],a=this.pattern.length;for(;(r=e.indexOf(this.pattern,n))>-1;)n=r+a,s.push([r,n-1]);const o=!!s.length;return{isMatch:o,score:o?0:1,indices:s}}}const Yn=[wu,ha,Lu,Su,Ou,Eu,ku,fa],Br=Yn.length,Cu=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Au="|";function Iu(t,e={}){return t.split(Au).map(n=>{let r=n.trim().split(Cu).filter(a=>a&&!!a.trim()),s=[];for(let a=0,o=r.length;a!!(t[dn.AND]||t[dn.OR]),Pu=t=>!!t[qn.PATH],Tu=t=>!Ze(t)&&ia(t)&&!Jn(t),Wr=t=>({[dn.AND]:Object.keys(t).map(e=>({[e]:t[e]}))});function ma(t,e,{auto:n=!0}={}){const r=s=>{let a=Object.keys(s);const o=Pu(s);if(!o&&a.length>1&&!Jn(s))return r(Wr(s));if(Tu(s)){const l=o?s[qn.PATH]:a[0],c=o?s[qn.PATTERN]:s[l];if(!Be(c))throw new Error(au(l));const u={keyId:Gn(l),pattern:c};return n&&(u.searcher=Xn(c,e)),u}let i={children:[],operator:a[0]};return a.forEach(l=>{const c=s[l];Ze(c)&&c.forEach(u=>{i.children.push(r(u))})}),i};return Jn(t)||(t=Wr(t)),r(t)}function Fu(t,{ignoreFieldNorm:e=Q.ignoreFieldNorm}){t.forEach(n=>{let r=1;n.matches.forEach(({key:s,norm:a,score:o})=>{const i=s?s.weight:null;r*=Math.pow(o===0&&i?Number.EPSILON:o,(i||1)*(e?1:a))}),n.score=r})}function Ru(t,e){const n=t.matches;e.matches=[],$e(n)&&n.forEach(r=>{if(!$e(r.indices)||!r.indices.length)return;const{indices:s,value:a}=r;let o={indices:s,value:a};r.key&&(o.key=r.key.src),r.idx>-1&&(o.refIndex=r.idx),e.matches.push(o)})}function Vu(t,e){e.score=t.score}function Du(t,e,{includeMatches:n=Q.includeMatches,includeScore:r=Q.includeScore}={}){const s=[];return n&&s.push(Ru),r&&s.push(Vu),t.map(a=>{const{idx:o}=a,i={item:e[o],refIndex:o};return s.length&&s.forEach(l=>{l(a,i)}),i})}class _t{constructor(e,n={},r){this.options={...Q,...n},this.options.useExtendedSearch,this._keyStore=new cu(this.options.keys),this.setCollection(e,r)}setCollection(e,n){if(this._docs=e,n&&!(n instanceof kr))throw new Error(su);this._myIndex=n||ua(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(e){!$e(e)||(this._docs.push(e),this._myIndex.add(e))}remove(e=()=>!1){const n=[];for(let r=0,s=this._docs.length;r-1&&(l=l.slice(0,n)),Du(l,this._docs,{includeMatches:r,includeScore:s})}_searchStringList(e){const n=Xn(e,this.options),{records:r}=this._myIndex,s=[];return r.forEach(({v:a,i:o,n:i})=>{if(!$e(a))return;const{isMatch:l,score:c,indices:u}=n.searchIn(a);l&&s.push({item:a,idx:o,matches:[{score:c,value:a,norm:i,indices:u}]})}),s}_searchLogical(e){const n=ma(e,this.options),r=(i,l,c)=>{if(!i.children){const{keyId:d,searcher:f}=i,y=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(l,d),searcher:f});return y&&y.length?[{idx:c,item:l,matches:y}]:[]}const u=[];for(let d=0,f=i.children.length;d{if($e(i)){let c=r(n,i,l);c.length&&(a[l]||(a[l]={idx:l,item:i,matches:[]},o.push(a[l])),c.forEach(({matches:u})=>{a[l].matches.push(...u)}))}}),o}_searchObjectList(e){const n=Xn(e,this.options),{keys:r,records:s}=this._myIndex,a=[];return s.forEach(({$:o,i})=>{if(!$e(o))return;let l=[];r.forEach((c,u)=>{l.push(...this._findMatches({key:c,value:o[u],searcher:n}))}),l.length&&a.push({idx:i,item:o,matches:l})}),a}_findMatches({key:e,value:n,searcher:r}){if(!$e(n))return[];let s=[];if(Ze(n))n.forEach(({v:a,i:o,n:i})=>{if(!$e(a))return;const{isMatch:l,score:c,indices:u}=r.searchIn(a);l&&s.push({score:c,key:e,value:a,idx:o,norm:i,indices:u})});else{const{v:a,n:o}=n,{isMatch:i,score:l,indices:c}=r.searchIn(a);i&&s.push({score:l,key:e,value:a,norm:o,indices:c})}return s}}_t.version="6.6.2";_t.createIndex=ua;_t.parseIndex=vu;_t.config=Q;_t.parseQuery=ma;$u(Nu);const jr=Bt({selectedNode:"",selectedGroup:"",search:"",dataValue:"",filtered:{count:0,items:new Map,groups:new Set}}),$t=()=>({isSearching:U(()=>jr.search!==""),...po(jr)});function Hu(t){return{all:t=t||new Map,on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(s){s(n)}),(r=t.get("*"))&&r.slice().map(function(s){s(e,n)})}}}const Uu=Hu(),Sn=()=>({emitter:Uu});function Bu(t,e){let n=t.nextElementSibling;for(;n;){if(n.matches(e))return n;n=n.nextElementSibling}}function Wu(t,e){let n=t.previousElementSibling;for(;n;){if(n.matches(e))return n;n=n.previousElementSibling}}const ju=["command-theme"],xu={"command-root":""},Ku=R({name:"Command"}),Gu=R({...Ku,props:{theme:{type:String,default:"default"},fuseOptions:{type:Object,default:()=>({threshold:.2,keys:["label"]})}},emits:["select-item"],setup(t,{emit:e}){const n=t,r='[command-item=""]',s="command-item-key",a='[command-group=""]',o="command-group-key",i='[command-group-heading=""]',l=`${r}:not([aria-disabled="true"])`,c=`${r}[aria-selected="true"]`,u="command-item-select",d="data-value";pr("theme",n.theme||"default");const{selectedNode:f,search:y,dataValue:S,filtered:g}=$t(),{emitter:b}=Sn(),p=X(),E=Tn(X(new Map),333),I=Tn(X(new Set),333),L=Tn(X(new Map)),P=U(()=>{const V=[];for(const[re,Y]of E.value.entries())V.push({key:re,label:Y});return V}),T=U(()=>{const V=_t.createIndex(n.fuseOptions.keys,P.value);return new _t(P.value,n.fuseOptions,V)}),N=()=>{var V,re,Y;const oe=B();oe&&(((V=oe.parentElement)==null?void 0:V.firstElementChild)===oe&&((Y=(re=oe.closest(a))==null?void 0:re.querySelector(i))==null||Y.scrollIntoView({block:"nearest"})),oe.scrollIntoView({block:"nearest"}))},B=()=>{var V;return(V=p.value)==null?void 0:V.querySelector(c)},G=(V=p.value)=>{const re=V==null?void 0:V.querySelectorAll(l);return re?Array.from(re):[]},ce=()=>{var V;const re=(V=p.value)==null?void 0:V.querySelectorAll(a);return re?Array.from(re):[]},ge=()=>{const[V]=G();V&&V.getAttribute(s)&&(f.value=V.getAttribute(s)||"")},ae=V=>{const re=G()[V];re&&(f.value=re.getAttribute(s)||"")},_e=V=>{const re=B(),Y=G(),oe=Y.findIndex(Se=>Se===re),Le=Y[oe+V];Le?f.value=Le.getAttribute(s)||"":V>0?ae(0):ae(Y.length-1)},Ne=V=>{const re=B();let Y=re==null?void 0:re.closest(a),oe=null;for(;Y&&!oe;)Y=V>0?Bu(Y,a):Wu(Y,a),oe=Y==null?void 0:Y.querySelector(l);oe?f.value=oe.getAttribute(s)||"":_e(V)},Te=()=>ae(0),tt=()=>ae(G().length-1),De=V=>{V.preventDefault(),V.metaKey?tt():V.altKey?Ne(1):_e(1)},nt=V=>{V.preventDefault(),V.metaKey?Te():V.altKey?Ne(-1):_e(-1)},Ee=V=>{switch(V.key){case"n":case"j":{V.ctrlKey&&De(V);break}case"ArrowDown":{De(V);break}case"p":case"k":{V.ctrlKey&&nt(V);break}case"ArrowUp":{nt(V);break}case"Home":{Te();break}case"End":{tt();break}case"Enter":{const re=B();if(re){const Y=new Event(u);re.dispatchEvent(Y)}}}},rt=()=>{if(!y.value){g.value.count=I.value.size;return}g.value.groups=new Set("");const V=new Map,re=T.value.search(y.value).map(Y=>Y.item);for(const{key:Y,label:oe}of re)V.set(Y,oe);for(const[Y,oe]of L.value)for(const Le of oe)V.get(Le)&&g.value.groups.add(Y);Ue(()=>{g.value.count=V.size,g.value.items=V})},J=()=>{const V=G(),re=ce();for(const Y of V){const oe=Y.getAttribute(s)||"",Le=Y.getAttribute(d)||"";I.value.add(oe),E.value.set(oe,Le),g.value.count=E.value.size}for(const Y of re){const oe=G(Y),Le=Y.getAttribute(o)||"",Se=new Set("");for(const vt of oe){const Fe=vt.getAttribute(s)||"";Se.add(Fe)}L.value.set(Le,Se)}};pe(()=>f.value,V=>{V&&Ue(N)},{deep:!0}),pe(()=>y.value,V=>{rt(),Ue(ge)}),b.on("selectItem",V=>{e("select-item",V)});const te=ra(V=>{V&&(J(),Ue(ge))},100);return b.on("rerenderList",te),Ye(()=>{J(),ge()}),(V,re)=>(_(),A("div",{class:ue(t.theme),onKeydown:Ee,ref_key:"commandRef",ref:p,"command-theme":t.theme},[w("div",xu,[C(V.$slots,"default")])],42,ju))}}),Pt=(t,e)=>{const n=t.__vccOpts||t;for(const[r,s]of e)n[r]=s;return n},Qn=Pt(Gu,[["__file","/Users/xiaoyunwei/Documents/GitHub/oss/vue-command-palette/packages/Command.vue"]]),Yu={"command-dialog":""},zu={"command-dialog-mask":""},Xu={"command-dialog-wrapper":""},qu={"command-dialog-header":""},Ju={"command-dialog-body":""},Qu={key:0,"command-dialog-footer":""},Zu=R({name:"Command.Dialog"}),ed=R({...Zu,props:{visible:{type:Boolean,required:!0},theme:{type:String,required:!0}},emits:["select-item"],setup(t,{emit:e}){const n=t,{search:r,filtered:s}=$t(),{emitter:a}=Sn(),o=X();a.on("selectItem",l=>{e("select-item",l)});const i=()=>{r.value="",s.value.count=0,s.value.items=new Map,s.value.groups=new Set};return sa(()=>n.visible,i),kn(i),(l,c)=>(_(),K(mo,{to:"body",ref_key:"dialogRef",ref:o},[x(_n,{name:"command-dialog",appear:""},{default:M(()=>[t.visible?(_(),K(Qn,{key:0,theme:t.theme},{default:M(()=>[w("div",Yu,[w("div",zu,[w("div",Xu,[w("div",qu,[C(l.$slots,"header")]),w("div",Ju,[C(l.$slots,"body")]),l.$slots.footer?(_(),A("div",Qu,[C(l.$slots,"footer")])):j("v-if",!0)])])])]),_:3},8,["theme"])):j("v-if",!0)]),_:3})],512))}}),td=Pt(ed,[["__file","/Users/xiaoyunwei/Documents/GitHub/oss/vue-command-palette/packages/CommandDialog.vue"]]);let pa=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,n)=>(n&=63,n<36?e+=n.toString(36):n<62?e+=(n-26).toString(36).toUpperCase():n>62?e+="-":e+="_",e),"");const nd=["command-group-key","data-value"],rd={key:0,"command-group-heading":""},sd={"command-group-items":"",role:"group"},ad=R({name:"Command.Group"}),od=R({...ad,props:{heading:{type:String,required:!0}},setup(t){const e=U(()=>`command-group-${pa()}`),{filtered:n,isSearching:r}=$t(),s=U(()=>r.value?n.value.groups.has(e.value):!0);return(a,o)=>Gs((_(),A("div",{"command-group":"",role:"presentation",key:v(e),"command-group-key":v(e),"data-value":t.heading},[t.heading?(_(),A("div",rd,Z(t.heading),1)):j("v-if",!0),w("div",sd,[C(a.$slots,"default")])],8,nd)),[[Ys,v(s)]])}}),id=Pt(od,[["__file","/Users/xiaoyunwei/Documents/GitHub/oss/vue-command-palette/packages/CommandGroup.vue"]]),ld=["placeholder","value"],cd=R({name:"Command.Input"}),ud=R({...cd,props:{placeholder:{type:String,required:!0},value:{type:String,required:!1}},emits:["input","update:value"],setup(t,{emit:e}){const n=X(null),{search:r}=$t(),s=U(()=>r.value),a=o=>{const i=o,l=o.target;r.value=l==null?void 0:l.value,e("input",i),e("update:value",r.value)};return it(()=>{var o;(o=n.value)==null||o.focus()}),(o,i)=>(_(),A("input",{ref_key:"inputRef",ref:n,"command-input":"","auto-focus":"","auto-complete":"off","auto-correct":"off","spell-check":!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,placeholder:t.placeholder,value:v(s),onInput:a},null,40,ld))}}),dd=Pt(ud,[["__file","/Users/xiaoyunwei/Documents/GitHub/oss/vue-command-palette/packages/CommandInput.vue"]]),fd=["aria-selected","aria-disabled","command-item-key"],hd=R({name:"Command.Item"}),md=R({...hd,props:{shortcut:{type:Array,required:!1},perform:{type:null,required:!1}},emits:["select"],setup(t,{emit:e}){const n=t,r="command-item-select",s="data-value",{current:a}=Yc(),{selectedNode:o,filtered:i,isSearching:l}=$t(),{emitter:c}=Sn(),u=X(),d=U(()=>`command-item-${pa()}`),f=U(()=>{const g=i.value.items.get(d.value);return l.value?g!==void 0:!0}),y=U(()=>Array.from(a)),S=()=>{var g;const b={key:d.value,value:((g=u.value)==null?void 0:g.getAttribute(s))||""};e("select",b),c.emit("selectItem",b)};return sa(y,g=>{n.shortcut&&n.shortcut.length>0&&n.shortcut.every(b=>a.has(b.toLowerCase()))&&n.perform&&n.perform()}),it(()=>{var g;(g=u.value)==null||g.addEventListener(r,S)}),kn(()=>{var g;(g=u.value)==null||g.removeEventListener(r,S)}),(g,b)=>Gs((_(),A("div",{ref_key:"itemRef",ref:u,"command-item":"",role:"option","aria-selected":v(o)===v(d),"aria-disabled":!v(f),key:v(d),"command-item-key":v(d),onClick:S},[C(g.$slots,"default")],8,fd)),[[Ys,v(f)]])}}),pd=Pt(md,[["__file","/Users/xiaoyunwei/Documents/GitHub/oss/vue-command-palette/packages/CommandItem.vue"]]),_d=R({name:"Command.List"}),vd=R({..._d,setup(t){const{emitter:e}=Sn(),n=X(),r=X();let s=null,a;return it(()=>{a=r.value;const o=n.value;a&&o&&(s=new ResizeObserver(i=>{Ue(()=>{const l=a==null?void 0:a.offsetHeight;o==null||o.style.setProperty("--command-list-height",`${l==null?void 0:l.toFixed(1)}px`),e.emit("rerenderList",!0)})}),s.observe(a))}),kn(()=>{s!==null&&a&&s.unobserve(a)}),(o,i)=>(_(),A("div",{"command-list":"",role:"listbox","aria-label":"Suggestions",ref_key:"listRef",ref:n},[w("div",{"command-list-sizer":"",ref_key:"heightRef",ref:r},[C(o.$slots,"default")],512)],512))}}),gd=Pt(vd,[["__file","/Users/xiaoyunwei/Documents/GitHub/oss/vue-command-palette/packages/CommandList.vue"]]),bd=R({name:"Command.Empty",setup(t,{attrs:e,slots:n}){const{filtered:r}=$t(),s=U(()=>r.value.count===0);return()=>s.value?Ct("div",{"command-empty":"",role:"presentation",...e},n):Ct("div",{"command-empty":"hidden",role:"presentation",style:{display:"none"},...e})}}),yd=R({name:"Command.Loading",setup(t,{attrs:e,slots:n}){return()=>Ct("div",{"command-loading":"",role:"progressbar",...e},n)}}),wd=R({name:"Command.Separator",setup(t,{attrs:e,slots:n}){return()=>Ct("div",{"command-separator":"",role:"separator",...e})}}),wt=Object.assign(Qn,{Dialog:td,Empty:bd,Group:id,Input:dd,Item:pd,List:gd,Loading:yd,Separator:wd,Root:Qn});var xr;const _a=typeof window<"u",kd=t=>typeof t=="function",Ld=t=>typeof t=="string",va=()=>{};_a&&((xr=window==null?void 0:window.navigator)!=null&&xr.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);function Lr(t){return typeof t=="function"?t():v(t)}function Sd(t,e){function n(...r){return new Promise((s,a)=>{Promise.resolve(t(()=>e.apply(this,r),{fn:e,thisArg:this,args:r})).then(s).catch(a)})}return n}const ga=t=>t();function Ed(t=ga){const e=X(!0);function n(){e.value=!1}function r(){e.value=!0}const s=(...a)=>{e.value&&t(...a)};return{isActive:Ks(e),pause:n,resume:r,eventFilter:s}}function Od(t){return t}function Cd(t){return zs()?(Xs(t),!0):!1}var Kr=Object.getOwnPropertySymbols,Ad=Object.prototype.hasOwnProperty,Id=Object.prototype.propertyIsEnumerable,Md=(t,e)=>{var n={};for(var r in t)Ad.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&Kr)for(var r of Kr(t))e.indexOf(r)<0&&Id.call(t,r)&&(n[r]=t[r]);return n};function Nd(t,e,n={}){const r=n,{eventFilter:s=ga}=r,a=Md(r,["eventFilter"]);return pe(t,Sd(s,e),a)}var $d=Object.defineProperty,Pd=Object.defineProperties,Td=Object.getOwnPropertyDescriptors,fn=Object.getOwnPropertySymbols,ba=Object.prototype.hasOwnProperty,ya=Object.prototype.propertyIsEnumerable,Gr=(t,e,n)=>e in t?$d(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Fd=(t,e)=>{for(var n in e||(e={}))ba.call(e,n)&&Gr(t,n,e[n]);if(fn)for(var n of fn(e))ya.call(e,n)&&Gr(t,n,e[n]);return t},Rd=(t,e)=>Pd(t,Td(e)),Vd=(t,e)=>{var n={};for(var r in t)ba.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&fn)for(var r of fn(t))e.indexOf(r)<0&&ya.call(t,r)&&(n[r]=t[r]);return n};function Dd(t,e,n={}){const r=n,{eventFilter:s}=r,a=Vd(r,["eventFilter"]),{eventFilter:o,pause:i,resume:l,isActive:c}=Ed(s);return{stop:Nd(t,e,Rd(Fd({},a),{eventFilter:o})),pause:i,resume:l,isActive:c}}function Hd(t){var e;const n=Lr(t);return(e=n==null?void 0:n.$el)!=null?e:n}const jt=_a?window:void 0;function Et(...t){let e,n,r,s;if(Ld(t[0])||Array.isArray(t[0])?([n,r,s]=t,e=jt):[e,n,r,s]=t,!e)return va;Array.isArray(n)||(n=[n]),Array.isArray(r)||(r=[r]);const a=[],o=()=>{a.forEach(u=>u()),a.length=0},i=(u,d,f,y)=>(u.addEventListener(d,f,y),()=>u.removeEventListener(d,f,y)),l=pe(()=>[Hd(e),Lr(s)],([u,d])=>{o(),u&&a.push(...n.flatMap(f=>r.map(y=>i(u,f,y,d))))},{immediate:!0,flush:"post"}),c=()=>{l(),o()};return Cd(c),c}const Zn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},er="__vueuse_ssr_handlers__";Zn[er]=Zn[er]||{};const Ud=Zn[er];function Bd(t,e){return Ud[t]||e}function Wd(t){return t==null?"any":t instanceof Set?"set":t instanceof Map?"map":t instanceof Date?"date":typeof t=="boolean"?"boolean":typeof t=="string"?"string":typeof t=="object"?"object":Number.isNaN(t)?"any":"number"}var jd=Object.defineProperty,Yr=Object.getOwnPropertySymbols,xd=Object.prototype.hasOwnProperty,Kd=Object.prototype.propertyIsEnumerable,zr=(t,e,n)=>e in t?jd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Xr=(t,e)=>{for(var n in e||(e={}))xd.call(e,n)&&zr(t,n,e[n]);if(Yr)for(var n of Yr(e))Kd.call(e,n)&&zr(t,n,e[n]);return t};const Gd={boolean:{read:t=>t==="true",write:t=>String(t)},object:{read:t=>JSON.parse(t),write:t=>JSON.stringify(t)},number:{read:t=>Number.parseFloat(t),write:t=>String(t)},any:{read:t=>t,write:t=>String(t)},string:{read:t=>t,write:t=>String(t)},map:{read:t=>new Map(JSON.parse(t)),write:t=>JSON.stringify(Array.from(t.entries()))},set:{read:t=>new Set(JSON.parse(t)),write:t=>JSON.stringify(Array.from(t))},date:{read:t=>new Date(t),write:t=>t.toISOString()}},qr="vueuse-storage";function Yd(t,e,n,r={}){var s;const{flush:a="pre",deep:o=!0,listenToStorageChanges:i=!0,writeDefaults:l=!0,mergeDefaults:c=!1,shallow:u,window:d=jt,eventFilter:f,onError:y=B=>{console.error(B)}}=r,S=(u?bn:X)(e);if(!n)try{n=Bd("getDefaultStorage",()=>{var B;return(B=jt)==null?void 0:B.localStorage})()}catch(B){y(B)}if(!n)return S;const g=Lr(e),b=Wd(g),p=(s=r.serializer)!=null?s:Gd[b],{pause:E,resume:I}=Dd(S,()=>L(S.value),{flush:a,deep:o,eventFilter:f});return d&&i&&(Et(d,"storage",N),Et(d,qr,T)),N(),S;function L(B){try{if(B==null)n.removeItem(t);else{const G=p.write(B),ce=n.getItem(t);ce!==G&&(n.setItem(t,G),d&&d.dispatchEvent(new CustomEvent(qr,{detail:{key:t,oldValue:ce,newValue:G,storageArea:n}})))}}catch(G){y(G)}}function P(B){const G=B?B.newValue:n.getItem(t);if(G==null)return l&&g!==null&&n.setItem(t,p.write(g)),g;if(!B&&c){const ce=p.read(G);return kd(c)?c(ce,g):b==="object"&&!Array.isArray(ce)?Xr(Xr({},g),ce):ce}else return typeof G!="string"?G:p.read(G)}function T(B){N(B.detail)}function N(B){if(!(B&&B.storageArea!==n)){if(B&&B.key==null){S.value=g;return}if(!(B&&B.key!==t)){E();try{S.value=P(B)}catch(G){y(G)}finally{B?Ue(I):I()}}}}}function zd(t,e,n={}){const{window:r=jt}=n;return Yd(t,e,r==null?void 0:r.localStorage,n)}const Xd={ctrl:"control",command:"meta",cmd:"meta",option:"alt",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright"};function qd(t={}){const{reactive:e=!1,target:n=jt,aliasMap:r=Xd,passive:s=!0,onEventFired:a=va}=t,o=Bt(new Set),i={toJSON(){return{}},current:o},l=e?Bt(i):i,c=new Set,u=new Set;function d(g,b){g in l&&(e?l[g]=b:l[g].value=b)}function f(){o.clear();for(const g of u)d(g,!1)}function y(g,b){var p,E;const I=(p=g.key)==null?void 0:p.toLowerCase(),P=[(E=g.code)==null?void 0:E.toLowerCase(),I].filter(Boolean);I&&(b?o.add(I):o.delete(I));for(const T of P)u.add(T),d(T,b);I==="meta"&&!b?(c.forEach(T=>{o.delete(T),d(T,!1)}),c.clear()):typeof g.getModifierState=="function"&&g.getModifierState("Meta")&&b&&[...o,...P].forEach(T=>c.add(T))}Et(n,"keydown",g=>(y(g,!0),a(g)),{passive:s}),Et(n,"keyup",g=>(y(g,!1),a(g)),{passive:s}),Et("blur",f,{passive:!0}),Et("focus",f,{passive:!0});const S=new Proxy(l,{get(g,b,p){if(typeof b!="string")return Reflect.get(g,b,p);if(b=b.toLowerCase(),b in r&&(b=r[b]),!(b in l))if(/[+_-]/.test(b)){const I=b.split(/[+_-]/g).map(L=>L.trim());l[b]=U(()=>I.every(L=>v(S[L])))}else l[b]=X(!1);const E=Reflect.get(g,b,p);return e?v(E):E}});return S}var Jr;(function(t){t.UP="UP",t.RIGHT="RIGHT",t.DOWN="DOWN",t.LEFT="LEFT",t.NONE="NONE"})(Jr||(Jr={}));var Jd=Object.defineProperty,Qr=Object.getOwnPropertySymbols,Qd=Object.prototype.hasOwnProperty,Zd=Object.prototype.propertyIsEnumerable,Zr=(t,e,n)=>e in t?Jd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ef=(t,e)=>{for(var n in e||(e={}))Qd.call(e,n)&&Zr(t,n,e[n]);if(Qr)for(var n of Qr(e))Zd.call(e,n)&&Zr(t,n,e[n]);return t};const tf={easeInSine:[.12,0,.39,0],easeOutSine:[.61,1,.88,1],easeInOutSine:[.37,0,.63,1],easeInQuad:[.11,0,.5,0],easeOutQuad:[.5,1,.89,1],easeInOutQuad:[.45,0,.55,1],easeInCubic:[.32,0,.67,0],easeOutCubic:[.33,1,.68,1],easeInOutCubic:[.65,0,.35,1],easeInQuart:[.5,0,.75,0],easeOutQuart:[.25,1,.5,1],easeInOutQuart:[.76,0,.24,1],easeInQuint:[.64,0,.78,0],easeOutQuint:[.22,1,.36,1],easeInOutQuint:[.83,0,.17,1],easeInExpo:[.7,0,.84,0],easeOutExpo:[.16,1,.3,1],easeInOutExpo:[.87,0,.13,1],easeInCirc:[.55,0,1,.45],easeOutCirc:[0,.55,.45,1],easeInOutCirc:[.85,0,.15,1],easeInBack:[.36,0,.66,-.56],easeOutBack:[.34,1.56,.64,1],easeInOutBack:[.68,-.6,.32,1.6]};ef({linear:Od},tf);const nf={locales:{root:{btnPlaceholder:"Search",placeholder:"Search Docs...",emptyText:"No results",heading:"Total: {{searchResult}} search results."},zh:{customSearchQuery(t){return t.replace(/[\u4e00-\u9fa5]/g," $& ").replace(/\s+/g," ").trim()},btnPlaceholder:"搜索",placeholder:"搜索文档",emptyText:"空空如也",heading:"共:{{searchResult}} 条结果",showDate:!1}}},rf={},sf={width:"594",height:"112",viewBox:"0 0 594 112",fill:"none",xmlns:"http://www.w3.org/2000/svg"};function af(t,e){return _(),A("svg",sf,e[0]||(e[0]=[_o('',11)]))}const of=q(rf,[["render",af]]);function lf(t){if(!t)return{};try{const e=decodeURIComponent(atob(t));return JSON.parse(e)}catch{return{}}}function cf(t,e=1){const{sub_results:n,anchors:r,weighted_locations:s}=t;s.sort((i,l)=>l.weight===i.weight?i.location-l.location:l.weight-i.weight);const a=[];for(const{location:i}of s){const c=n.filter(u=>{const{locations:d}=u,[f]=d||[];if(!f)return!1;const y=d.length===1?Number.POSITIVE_INFINITY:d[d.length-1];return f<=i&&i<=y}).reduce((u,d)=>u&&u.locations.length>d.locations.length?u:d,null);if(c&&(a.push(c),a.length>=e))break}a.sort((i,l)=>{const[c]=i.locations||[],[u]=l.locations||[];return!c||!u?0:c-u});const o=new Map;return a.map(i=>uf(i,r,t)).filter(i=>o.has(i.meta.title)?!1:(o.set(i.meta.title,i),!0))}function uf(t,e,n){const r=(t==null?void 0:t.url)||(n==null?void 0:n.url),s=(t==null?void 0:t.excerpt)||(n==null?void 0:n.excerpt),a=(e==null?void 0:e.filter(u=>t?u.location<=t.anchor.location&&u.element<=t.anchor.element:!1))||[];a.reverse();const o=a.reduce((u,d)=>(u.some(y=>y.element===d.element)||u.unshift(d),u),[]),i=o.length?o.map(u=>u.text.trim()).filter(u=>!!u).join(" > "):n.meta.title,{base64:l,...c}=n.meta;return{route:r,meta:{...lf(l),...c,title:i,description:s},result:n}}function df(t,e="yyyy-MM-dd hh:mm:ss"){t instanceof Date||(t=new Date(t));const n={"M+":t.getMonth()+1,"d+":t.getDate(),"h+":t.getHours(),"m+":t.getMinutes(),"s+":t.getSeconds(),"q+":Math.floor((t.getMonth()+3)/3),S:t.getMilliseconds()};/(y+)/.test(e)&&(e=e.replace(RegExp.$1,`${t.getFullYear()}`.substr(4-RegExp.$1.length)));for(const r in n)new RegExp(`(${r})`).test(e)&&(e=e.replace(RegExp.$1,RegExp.$1.length===1?n[r]:`00${n[r]}`.substr(`${n[r]}`.length)));return e}function ff(t,e){const n=+new Date(t),s=+new Date-n,a=1e3,o=a*60,i=o*60,l=i*24,c=l*7,u={"zh-cn":{justNow:"刚刚",secondsAgo:"秒前",minutesAgo:"分钟前",hoursAgo:"小时前",daysAgo:"天前",weeksAgo:"周前"},"en-us":{justNow:" just now",secondsAgo:" seconds ago",minutesAgo:" minutes ago",hoursAgo:" hours ago",daysAgo:" days ago",weeksAgo:" weeks ago"}},d=u[e.toLowerCase()]||u["en-us"];return s<10?d.justNow:s{var J;return{...n,...((J=n==null?void 0:n.locales)==null?void 0:J[r.value])||{}}}),i=U(()=>{var J;return((J=o.value)==null?void 0:J.ignorePublish)??!1}),l=U(()=>{var J;return((J=o.value)==null?void 0:J.showDate)??!1}),c=U(()=>typeof o.value.showDate=="function"?o.value.showDate:ff),u=U(()=>{var J;return(J=o.value)!=null&&J.heading?o.value.heading.replace(/\{\{searchResult\}\}/,`${e.value.length}`):`Total: ${e.value.length} search results.`}),d=X("");Ye(()=>{d.value=/(Mac|iPhone|iPod|iPad)/i.test(navigator==null?void 0:navigator.platform)?"⌘":"Ctrl"});const f=X(!1);function y(){f.value=!0}function S(){f.value=!1}const g=qd({passive:!1,onEventFired(J){J.ctrlKey&&J.key==="k"&&J.type==="keydown"&&J.preventDefault()}}),b=g["Meta+K"],p=g["Ctrl+K"],E=g.Escape;pe(b,J=>{J&&y()}),pe(p,J=>{J&&y()}),pe(E,J=>{J&&S()});const I=X("");function L(){if(!I.value){e.value=[];return}e.value=[{route:"#",meta:{title:"只在构建后才生效",description:"only support after build, only support after build"}}]}const P=/[\u4E00-\u9FA5]/g,T=(Intl==null?void 0:Intl.Segmenter)&&new Intl.Segmenter("ch",{granularity:"word"});function N(J){return T?Array.from(T==null?void 0:T.segment(J)).map(V=>V.segment).join(" "):J.replace(P," $& ").replace(/\s+/g," ").trim()}const B=U(()=>{var J;return((J=o.value)==null?void 0:J.delay)??300});pe(()=>I.value,async()=>{var te,V,re;if(!((te=window==null?void 0:window.__pagefind__)!=null&&te.search)){L();return}const J=typeof o.value.customSearchQuery=="function"?o.value.customSearchQuery(I.value):P.test(I.value)?N(I.value):I.value;await((re=(V=window==null?void 0:window.__pagefind__)==null?void 0:V.debouncedSearch)==null?void 0:re.call(V,J,{},B.value).then(async Y=>{if(Y===null)return;const Le=(await Promise.all(Y.results.map(Se=>Se.data()))).map(Se=>cf(Se,o.value.pageResultCount||1).map(Fe=>(Fe.route=Fe.route.startsWith(s.value.base)?Fe.route:vn(Fe.route),Fe))).flat().filter(Se=>i.value||Se.meta.publish!==!1);o.value.sort&&Le.sort(o.value.sort),e.value=Le.filter(o.value.filter??(()=>!0))})),Ue(()=>{document.querySelectorAll('div[aria-disabled="true"]').forEach(Y=>{Y.setAttribute("aria-disabled","false")})})});function G(J){J.target===J.currentTarget&&S()}pe(()=>f.value,J=>{var te;J?Ue(()=>{var V;(V=document.querySelector("div[command-dialog-mask]"))==null||V.addEventListener("click",G)}):(te=document.querySelector("div[command-dialog-mask]"))==null||te.removeEventListener("click",G)});const ce=X(999),ge=X(0),ae=U(()=>{const te=ge.value%Math.ceil(e.value.length/ce.value)*ce.value;return e.value.slice(te,te+ce.value)}),_e=vo(),Ne=Yt();function Te(J){S(),Ne.path!==J.value&&_e.go(J.value)}const tt=U(()=>o.value.langReload??!0);pe(()=>a.value,()=>{tt.value&&window.location.reload()});const De=X();function nt(){I.value="",Ue(()=>{De.value&&(De.value.$el.value="")})}const Ee=zd("pagefind-search-showDetail",!1);function rt(){Ee.value=!Ee.value}return(J,te)=>{var re;const V=lt("ClientOnly");return _(),A("div",hf,[w("div",{class:"nav-search-btn-wait",onClick:te[0]||(te[0]=Y=>f.value=!0)},[te[3]||(te[3]=w("span",null,[w("svg",{width:"14",height:"14",viewBox:"0 0 20 20"},[w("path",{d:"M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z",stroke:"currentColor",fill:"none","fill-rule":"evenodd","stroke-linecap":"round","stroke-linejoin":"round"})])],-1)),w("span",mf,Z(((re=o.value)==null?void 0:re.btnPlaceholder)||"Search"),1),w("span",pf,Z(d.value)+" K ",1)]),x(V,null,{default:M(()=>[x(v(wt).Dialog,{visible:f.value,theme:"algolia"},go({header:M(()=>{var Y;return[w("div",_f,[w("div",vf,[w("button",{class:"back-button",title:"Close search",onClick:te[1]||(te[1]=oe=>f.value=!1)},te[4]||(te[4]=[w("span",{class:"vpi-arrow-left local-search-icon"},null,-1)]))]),x(v(wt).Input,{ref_key:"searchInput",ref:De,value:I.value,"onUpdate:value":te[2]||(te[2]=oe=>I.value=oe),placeholder:((Y=o.value)==null?void 0:Y.placeholder)||"Search Docs"},null,8,["value","placeholder"]),w("div",gf,[w("button",{class:ue([{active:v(Ee)},"toggle-layout-button"]),type:"button",title:"Display detailed list",onClick:rt},te[5]||(te[5]=[w("span",{class:"vpi-layout-list local-search-icon"},null,-1)]),2),w("button",{disabled:!I.value,class:"clear-button",type:"reset",title:"Reset search",onClick:nt},te[6]||(te[6]=[w("span",{class:"vpi-delete local-search-icon"},null,-1)]),8,bf)])])]}),body:M(()=>[w("div",{class:ue(["search-dialog",{"detail-list":v(Ee)}])},[x(v(wt).List,null,{default:M(()=>[e.value.length?(_(),K(v(wt).Group,{key:1,heading:u.value},{default:M(()=>[(_(!0),A(he,null,Ce(ae.value,Y=>(_(),K(v(wt).Item,{key:Y.route,"data-value":Y.route,onSelect:Te},{default:M(()=>[w("div",yf,[w("div",wf,[w("span",kf,[Y.meta.title?(_(),A("i",Lf,"# ")):j("",!0),Ve(Z(Y.meta.title),1)]),l.value&&Y.meta.date?(_(),A("span",Sf,Z(c.value(Y.meta.date,v(a))),1)):j("",!0)]),w("div",{class:"des",innerHTML:Y.meta.description},null,8,Ef)])]),_:2},1032,["data-value"]))),128))]),_:1},8,["heading"])):(_(),K(v(wt).Empty,{key:0},{default:M(()=>{var Y;return[Ve(Z(((Y=o.value)==null?void 0:Y.emptyText)||"No results found."),1)]}),_:1}))]),_:1})],2)]),_:2},[e.value.length?{name:"footer",fn:M(()=>{var Y,oe,Le,Se;return[w("div",Of,[w("a",Cf,[w("span",Af,Z(((Y=o.value)==null?void 0:Y.searchBy)||"Search by"),1),x(of,{style:{width:"77px"}})])]),w("ul",If,[w("li",null,[te[7]||(te[7]=w("kbd",{class:"command-palette-commands-key"},[w("svg",{width:"15",height:"15","aria-label":"Enter key",role:"img"},[w("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.2"},[w("path",{d:"M12 3.53088v3c0 1-1 2-2 2H4M7 11.53088l-3-3 3-3"})])])],-1)),w("span",Mf,Z(((oe=o.value)==null?void 0:oe.toSelect)||"to select"),1)]),w("li",null,[te[8]||(te[8]=w("kbd",{class:"command-palette-commands-key"},[w("svg",{width:"15",height:"15","aria-label":"Arrow down",role:"img"},[w("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.2"},[w("path",{d:"M7.5 3.5v8M10.5 8.5l-3 3-3-3"})])])],-1)),te[9]||(te[9]=w("kbd",{class:"command-palette-commands-key"},[w("svg",{width:"15",height:"15","aria-label":"Arrow up",role:"img"},[w("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.2"},[w("path",{d:"M7.5 11.5v-8M10.5 6.5l-3-3-3 3"})])])],-1)),w("span",Nf,Z(((Le=o.value)==null?void 0:Le.toNavigate)||"to navigate"),1)]),w("li",null,[te[10]||(te[10]=w("kbd",{class:"command-palette-commands-key"},[w("svg",{width:"15",height:"15","aria-label":"Escape key",role:"img"},[w("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.2"},[w("path",{d:"M13.6167 8.936c-.1065.3583-.6883.962-1.4875.962-.7993 0-1.653-.9165-1.653-2.1258v-.5678c0-1.2548.7896-2.1016 1.653-2.1016.8634 0 1.3601.4778 1.4875 1.0724M9 6c-.1352-.4735-.7506-.9219-1.46-.8972-.7092.0246-1.344.57-1.344 1.2166s.4198.8812 1.3445.9805C8.465 7.3992 8.968 7.9337 9 8.5c.032.5663-.454 1.398-1.4595 1.398C6.6593 9.898 6 9 5.963 8.4851m-1.4748.5368c-.2635.5941-.8099.876-1.5443.876s-1.7073-.6248-1.7073-2.204v-.4603c0-1.0416.721-2.131 1.7073-2.131.9864 0 1.6425 1.031 1.5443 2.2492h-2.956"})])])],-1)),w("span",$f,Z(((Se=o.value)==null?void 0:Se.toClose)||"to close"),1)])])]}),key:"0"}:void 0]),1032,["visible"])]),_:1})])}}}),Tf=q(Pf,[["__scopeId","data-v-fd998d3a"]]),Ff=R({__name:"VPNavBarSocialLinks",setup(t){const{theme:e}=se();return(n,r)=>v(e).socialLinks?(_(),K(wr,{key:0,class:"VPNavBarSocialLinks",links:v(e).socialLinks},null,8,["links"])):j("",!0)}}),Rf=q(Ff,[["__scopeId","data-v-b7887d5a"]]),Vf=["href","rel","target"],Df={key:1},Hf={key:2},Uf=R({__name:"VPNavBarTitle",setup(t){const{site:e,theme:n}=se(),{hasSidebar:r}=et(),{currentLang:s}=zt(),a=U(()=>{var l;return typeof n.value.logoLink=="string"?n.value.logoLink:(l=n.value.logoLink)==null?void 0:l.link}),o=U(()=>{var l;return typeof n.value.logoLink=="string"||(l=n.value.logoLink)==null?void 0:l.rel}),i=U(()=>{var l;return typeof n.value.logoLink=="string"||(l=n.value.logoLink)==null?void 0:l.target});return(l,c)=>(_(),A("div",{class:ue(["VPNavBarTitle",{"has-sidebar":v(r)}])},[w("a",{class:"title",href:a.value??v(_r)(v(s).link),rel:o.value,target:i.value},[C(l.$slots,"nav-bar-title-before",{},void 0,!0),v(n).logo?(_(),K(un,{key:0,class:"logo",image:v(n).logo},null,8,["image"])):j("",!0),v(n).siteTitle?(_(),A("span",Df,Z(v(n).siteTitle),1)):v(n).siteTitle===void 0?(_(),A("span",Hf,Z(v(e).title),1)):j("",!0),C(l.$slots,"nav-bar-title-after",{},void 0,!0)],8,Vf)],2))}}),Bf=q(Uf,[["__scopeId","data-v-9f785053"]]),Wf={class:"items"},jf={class:"title"},xf=R({__name:"VPNavBarTranslations",setup(t){const{theme:e}=se(),{localeLinks:n,currentLang:r}=zt({correspondingLink:!0});return(s,a)=>v(n).length&&v(r).label?(_(),K(yr,{key:0,class:"VPNavBarTranslations",icon:"vpi-languages",label:v(e).langMenuLabel||"Change language"},{default:M(()=>[w("div",Wf,[w("p",jf,Z(v(r).label),1),(_(!0),A(he,null,Ce(v(n),o=>(_(),K(Ln,{key:o.link,item:o},null,8,["item"]))),128))])]),_:1},8,["label"])):j("",!0)}}),Kf=q(xf,[["__scopeId","data-v-d78d18d0"]]),Gf={class:"wrapper"},Yf={class:"container"},zf={class:"title"},Xf={class:"content"},qf={class:"content-body"},Jf=R({__name:"VPNavBar",props:{isScreenOpen:{type:Boolean}},emits:["toggle-screen"],setup(t){const e=t,{y:n}=xs(),{hasSidebar:r}=et(),{frontmatter:s}=se(),a=X({});return mr(()=>{a.value={"has-sidebar":r.value,home:s.value.layout==="home",top:n.value===0,"screen-open":e.isScreenOpen}}),(o,i)=>(_(),A("div",{class:ue(["VPNavBar",a.value])},[w("div",Gf,[w("div",Yf,[w("div",zf,[x(Bf,null,{"nav-bar-title-before":M(()=>[C(o.$slots,"nav-bar-title-before",{},void 0,!0)]),"nav-bar-title-after":M(()=>[C(o.$slots,"nav-bar-title-after",{},void 0,!0)]),_:3})]),w("div",Xf,[w("div",qf,[C(o.$slots,"nav-bar-content-before",{},void 0,!0),x(Tf,{class:"search"}),x(Hc,{class:"menu"}),x(Kf,{class:"translations"}),x(Xl,{class:"appearance"}),x(Rf,{class:"social-links"}),x(Ic,{class:"extra"}),C(o.$slots,"nav-bar-content-after",{},void 0,!0),x($c,{class:"hamburger",active:o.isScreenOpen,onClick:i[0]||(i[0]=l=>o.$emit("toggle-screen"))},null,8,["active"])])])])]),i[1]||(i[1]=w("div",{class:"divider"},[w("div",{class:"divider-line"})],-1))],2))}}),Qf=q(Jf,[["__scopeId","data-v-f9756f2d"]]),Zf={key:0,class:"VPNavScreenAppearance"},eh={class:"text"},th=R({__name:"VPNavScreenAppearance",setup(t){const{site:e,theme:n}=se();return(r,s)=>v(e).appearance&&v(e).appearance!=="force-dark"&&v(e).appearance!=="force-auto"?(_(),A("div",Zf,[w("p",eh,Z(v(n).darkModeSwitchLabel||"Appearance"),1),x(gr)])):j("",!0)}}),nh=q(th,[["__scopeId","data-v-f7aa697b"]]),rh=R({__name:"VPNavScreenMenuLink",props:{item:{}},setup(t){const e=Nt("close-screen");return(n,r)=>(_(),K(je,{class:"VPNavScreenMenuLink",href:n.item.link,target:n.item.target,rel:n.item.rel,onClick:v(e),innerHTML:n.item.text},null,8,["href","target","rel","onClick","innerHTML"]))}}),sh=q(rh,[["__scopeId","data-v-8f3b9429"]]),ah=R({__name:"VPNavScreenMenuGroupLink",props:{item:{}},setup(t){const e=Nt("close-screen");return(n,r)=>(_(),K(je,{class:"VPNavScreenMenuGroupLink",href:n.item.link,target:n.item.target,rel:n.item.rel,onClick:v(e)},{default:M(()=>[Ve(Z(n.item.text),1)]),_:1},8,["href","target","rel","onClick"]))}}),wa=q(ah,[["__scopeId","data-v-7b9fb56c"]]),oh={class:"VPNavScreenMenuGroupSection"},ih={key:0,class:"title"},lh=R({__name:"VPNavScreenMenuGroupSection",props:{text:{},items:{}},setup(t){return(e,n)=>(_(),A("div",oh,[e.text?(_(),A("p",ih,Z(e.text),1)):j("",!0),(_(!0),A(he,null,Ce(e.items,r=>(_(),K(wa,{key:r.text,item:r},null,8,["item"]))),128))]))}}),ch=q(lh,[["__scopeId","data-v-4af57996"]]),uh=["aria-controls","aria-expanded"],dh=["innerHTML"],fh=["id"],hh={key:0,class:"item"},mh={key:1,class:"item"},ph={key:2,class:"group"},_h=R({__name:"VPNavScreenMenuGroup",props:{text:{},items:{}},setup(t){const e=t,n=X(!1),r=U(()=>`NavScreenGroup-${e.text.replace(" ","-").toLowerCase()}`);function s(){n.value=!n.value}return(a,o)=>(_(),A("div",{class:ue(["VPNavScreenMenuGroup",{open:n.value}])},[w("button",{class:"button","aria-controls":r.value,"aria-expanded":n.value,onClick:s},[w("span",{class:"button-text",innerHTML:a.text},null,8,dh),o[0]||(o[0]=w("span",{class:"vpi-plus button-icon"},null,-1))],8,uh),w("div",{id:r.value,class:"items"},[(_(!0),A(he,null,Ce(a.items,i=>(_(),A(he,{key:JSON.stringify(i)},["link"in i?(_(),A("div",hh,[x(wa,{item:i},null,8,["item"])])):"component"in i?(_(),A("div",mh,[(_(),K(We(i.component),at({ref_for:!0},i.props,{"screen-menu":""}),null,16))])):(_(),A("div",ph,[x(ch,{text:i.text,items:i.items},null,8,["text","items"])]))],64))),128))],8,fh)],2))}}),vh=q(_h,[["__scopeId","data-v-9e6433b0"]]),gh={key:0,class:"VPNavScreenMenu"},bh=R({__name:"VPNavScreenMenu",setup(t){const{theme:e}=se();return(n,r)=>v(e).nav?(_(),A("nav",gh,[(_(!0),A(he,null,Ce(v(e).nav,s=>(_(),A(he,{key:JSON.stringify(s)},["link"in s?(_(),K(sh,{key:0,item:s},null,8,["item"])):"component"in s?(_(),K(We(s.component),at({key:1,ref_for:!0},s.props,{"screen-menu":""}),null,16)):(_(),K(vh,{key:2,text:s.text||"",items:s.items},null,8,["text","items"]))],64))),128))])):j("",!0)}}),yh=R({__name:"VPNavScreenSocialLinks",setup(t){const{theme:e}=se();return(n,r)=>v(e).socialLinks?(_(),K(wr,{key:0,class:"VPNavScreenSocialLinks",links:v(e).socialLinks},null,8,["links"])):j("",!0)}}),wh={class:"list"},kh=R({__name:"VPNavScreenTranslations",setup(t){const{localeLinks:e,currentLang:n}=zt({correspondingLink:!0}),r=X(!1);function s(){r.value=!r.value}return(a,o)=>v(e).length&&v(n).label?(_(),A("div",{key:0,class:ue(["VPNavScreenTranslations",{open:r.value}])},[w("button",{class:"title",onClick:s},[o[0]||(o[0]=w("span",{class:"vpi-languages icon lang"},null,-1)),Ve(" "+Z(v(n).label)+" ",1),o[1]||(o[1]=w("span",{class:"vpi-chevron-down icon chevron"},null,-1))]),w("ul",wh,[(_(!0),A(he,null,Ce(v(e),i=>(_(),A("li",{key:i.link,class:"item"},[x(je,{class:"link",href:i.link},{default:M(()=>[Ve(Z(i.text),1)]),_:2},1032,["href"])]))),128))])],2)):j("",!0)}}),Lh=q(kh,[["__scopeId","data-v-642b9e57"]]),Sh={class:"container"},Eh=R({__name:"VPNavScreen",props:{open:{type:Boolean}},setup(t){const e=X(null),n=qs(wn?document.body:null);return(r,s)=>(_(),K(_n,{name:"fade",onEnter:s[0]||(s[0]=a=>n.value=!0),onAfterLeave:s[1]||(s[1]=a=>n.value=!1)},{default:M(()=>[r.open?(_(),A("div",{key:0,class:"VPNavScreen",ref_key:"screen",ref:e,id:"VPNavScreen"},[w("div",Sh,[C(r.$slots,"nav-screen-content-before",{},void 0,!0),x(bh,{class:"menu"}),x(Lh,{class:"translations"}),x(nh,{class:"appearance"}),x(yh,{class:"social-links"}),C(r.$slots,"nav-screen-content-after",{},void 0,!0)])],512)):j("",!0)]),_:3}))}}),Oh=q(Eh,[["__scopeId","data-v-1b440f23"]]),Ch={key:0,class:"VPNav"},Ah=R({__name:"VPNav",setup(t){const{isScreenOpen:e,closeScreen:n,toggleScreen:r}=Hl(),{frontmatter:s}=se(),a=U(()=>s.value.navbar!==!1);return pr("close-screen",n),it(()=>{wn&&document.documentElement.classList.toggle("hide-nav",!a.value)}),(o,i)=>a.value?(_(),A("header",Ch,[x(Qf,{"is-screen-open":v(e),onToggleScreen:v(r)},{"nav-bar-title-before":M(()=>[C(o.$slots,"nav-bar-title-before",{},void 0,!0)]),"nav-bar-title-after":M(()=>[C(o.$slots,"nav-bar-title-after",{},void 0,!0)]),"nav-bar-content-before":M(()=>[C(o.$slots,"nav-bar-content-before",{},void 0,!0)]),"nav-bar-content-after":M(()=>[C(o.$slots,"nav-bar-content-after",{},void 0,!0)]),_:3},8,["is-screen-open","onToggleScreen"]),x(Oh,{open:v(e)},{"nav-screen-content-before":M(()=>[C(o.$slots,"nav-screen-content-before",{},void 0,!0)]),"nav-screen-content-after":M(()=>[C(o.$slots,"nav-screen-content-after",{},void 0,!0)]),_:3},8,["open"])])):j("",!0)}}),Ih=q(Ah,[["__scopeId","data-v-a62deceb"]]),Mh=["role","tabindex"],Nh={key:1,class:"items"},$h=R({__name:"VPSidebarItem",props:{item:{},depth:{}},setup(t){const e=t,{collapsed:n,collapsible:r,isLink:s,isActiveLink:a,hasActiveLink:o,hasChildren:i,toggle:l}=xo(U(()=>e.item)),c=U(()=>i.value?"section":"div"),u=U(()=>s.value?"a":"div"),d=U(()=>i.value?e.depth+2===7?"p":`h${e.depth+2}`:"p"),f=U(()=>s.value?void 0:"button"),y=U(()=>[[`level-${e.depth}`],{collapsible:r.value},{collapsed:n.value},{"is-link":s.value},{"is-active":a.value},{"has-active":o.value}]);function S(b){"key"in b&&b.key!=="Enter"||!e.item.link&&l()}function g(){e.item.link&&l()}return(b,p)=>{const E=lt("VPSidebarItem",!0);return _(),K(We(c.value),{class:ue(["VPSidebarItem",y.value])},{default:M(()=>[b.item.text?(_(),A("div",at({key:0,class:"item",role:f.value},bo(b.item.items?{click:S,keydown:S}:{},!0),{tabindex:b.item.items&&0}),[p[1]||(p[1]=w("div",{class:"indicator"},null,-1)),b.item.link?(_(),K(je,{key:0,tag:u.value,class:"link",href:b.item.link,rel:b.item.rel,target:b.item.target},{default:M(()=>[(_(),K(We(d.value),{class:"text",innerHTML:b.item.text},null,8,["innerHTML"]))]),_:1},8,["tag","href","rel","target"])):(_(),K(We(d.value),{key:1,class:"text",innerHTML:b.item.text},null,8,["innerHTML"])),b.item.collapsed!=null&&b.item.items&&b.item.items.length?(_(),A("div",{key:2,class:"caret",role:"button","aria-label":"toggle section",onClick:g,onKeydown:yo(g,["enter"]),tabindex:"0"},p[0]||(p[0]=[w("span",{class:"vpi-chevron-right caret-icon"},null,-1)]),32)):j("",!0)],16,Mh)):j("",!0),b.item.items&&b.item.items.length?(_(),A("div",Nh,[b.depth<5?(_(!0),A(he,{key:0},Ce(b.item.items,I=>(_(),K(E,{key:I.text,item:I,depth:b.depth+1},null,8,["item","depth"]))),128)):j("",!0)])):j("",!0)]),_:1},8,["class"])}}}),Ph=q($h,[["__scopeId","data-v-3d6ff150"]]),Th=R({__name:"VPSidebarGroup",props:{items:{}},setup(t){const e=X(!0);let n=null;return Ye(()=>{n=setTimeout(()=>{n=null,e.value=!1},300)}),kn(()=>{n!=null&&(clearTimeout(n),n=null)}),(r,s)=>(_(!0),A(he,null,Ce(r.items,a=>(_(),A("div",{key:a.text,class:ue(["group",{"no-transition":e.value}])},[x(Ph,{item:a,depth:0},null,8,["item"])],2))),128))}}),Fh=q(Th,[["__scopeId","data-v-1952544a"]]),Rh={class:"nav",id:"VPSidebarNav","aria-labelledby":"sidebar-aria-label",tabindex:"-1"},Vh=R({__name:"VPSidebar",props:{open:{type:Boolean}},setup(t){const{sidebarGroups:e,hasSidebar:n}=et(),r=t,s=X(null),a=qs(wn?document.body:null);pe([r,s],()=>{var i;r.open?(a.value=!0,(i=s.value)==null||i.focus()):a.value=!1},{immediate:!0,flush:"post"});const o=X(0);return pe(e,()=>{o.value+=1},{deep:!0}),(i,l)=>v(n)?(_(),A("aside",{key:0,class:ue(["VPSidebar",{open:i.open}]),ref_key:"navEl",ref:s,onClick:l[0]||(l[0]=wo(()=>{},["stop"]))},[l[2]||(l[2]=w("div",{class:"curtain"},null,-1)),w("nav",Rh,[l[1]||(l[1]=w("span",{class:"visually-hidden",id:"sidebar-aria-label"}," Sidebar Navigation ",-1)),C(i.$slots,"sidebar-nav-before",{},void 0,!0),(_(),K(Fh,{items:v(e),key:o.value},null,8,["items"])),C(i.$slots,"sidebar-nav-after",{},void 0,!0)])],2)):j("",!0)}}),Dh=q(Vh,[["__scopeId","data-v-452d748b"]]),Hh=R({__name:"VPSkipLink",setup(t){const e=Yt(),n=X();pe(()=>e.path,()=>n.value.focus());function r({target:s}){const a=document.getElementById(decodeURIComponent(s.hash).slice(1));if(a){const o=()=>{a.removeAttribute("tabindex"),a.removeEventListener("blur",o)};a.setAttribute("tabindex","-1"),a.addEventListener("blur",o),a.focus(),window.scrollTo(0,0)}}return(s,a)=>(_(),A(he,null,[w("span",{ref_key:"backToTop",ref:n,tabindex:"-1"},null,512),w("a",{href:"#VPContent",class:"VPSkipLink visually-hidden",onClick:r}," Skip to content ")],64))}}),Uh=q(Hh,[["__scopeId","data-v-e8369309"]]),Bh=R({__name:"Layout",setup(t){const{isOpen:e,open:n,close:r}=et(),s=Yt();pe(()=>s.path,r),jo(e,r);const{frontmatter:a}=se(),o=ko(),i=U(()=>!!o["home-hero-image"]);return pr("hero-image-slot-exists",i),(l,c)=>{const u=lt("Content");return v(a).layout!==!1?(_(),A("div",{key:0,class:ue(["Layout",v(a).pageClass])},[C(l.$slots,"layout-top",{},void 0,!0),x(Uh),x(Mo,{class:"backdrop",show:v(e),onClick:v(r)},null,8,["show","onClick"]),x(Ih,null,{"nav-bar-title-before":M(()=>[C(l.$slots,"nav-bar-title-before",{},void 0,!0)]),"nav-bar-title-after":M(()=>[C(l.$slots,"nav-bar-title-after",{},void 0,!0)]),"nav-bar-content-before":M(()=>[C(l.$slots,"nav-bar-content-before",{},void 0,!0)]),"nav-bar-content-after":M(()=>[C(l.$slots,"nav-bar-content-after",{},void 0,!0)]),"nav-screen-content-before":M(()=>[C(l.$slots,"nav-screen-content-before",{},void 0,!0)]),"nav-screen-content-after":M(()=>[C(l.$slots,"nav-screen-content-after",{},void 0,!0)]),_:3}),x(Dl,{open:v(e),onOpenMenu:v(n)},null,8,["open","onOpenMenu"]),x(Dh,{open:v(e)},{"sidebar-nav-before":M(()=>[C(l.$slots,"sidebar-nav-before",{},void 0,!0)]),"sidebar-nav-after":M(()=>[C(l.$slots,"sidebar-nav-after",{},void 0,!0)]),_:3},8,["open"]),x(kl,null,{"page-top":M(()=>[C(l.$slots,"page-top",{},void 0,!0)]),"page-bottom":M(()=>[C(l.$slots,"page-bottom",{},void 0,!0)]),"not-found":M(()=>[C(l.$slots,"not-found",{},void 0,!0)]),"home-hero-before":M(()=>[C(l.$slots,"home-hero-before",{},void 0,!0)]),"home-hero-info-before":M(()=>[C(l.$slots,"home-hero-info-before",{},void 0,!0)]),"home-hero-info":M(()=>[C(l.$slots,"home-hero-info",{},void 0,!0)]),"home-hero-info-after":M(()=>[C(l.$slots,"home-hero-info-after",{},void 0,!0)]),"home-hero-actions-after":M(()=>[C(l.$slots,"home-hero-actions-after",{},void 0,!0)]),"home-hero-image":M(()=>[C(l.$slots,"home-hero-image",{},void 0,!0)]),"home-hero-after":M(()=>[C(l.$slots,"home-hero-after",{},void 0,!0)]),"home-features-before":M(()=>[C(l.$slots,"home-features-before",{},void 0,!0)]),"home-features-after":M(()=>[C(l.$slots,"home-features-after",{},void 0,!0)]),"doc-footer-before":M(()=>[C(l.$slots,"doc-footer-before",{},void 0,!0)]),"doc-before":M(()=>[C(l.$slots,"doc-before",{},void 0,!0)]),"doc-after":M(()=>[C(l.$slots,"doc-after",{},void 0,!0)]),"doc-top":M(()=>[C(l.$slots,"doc-top",{},void 0,!0)]),"doc-bottom":M(()=>[C(l.$slots,"doc-bottom",{},void 0,!0)]),"aside-top":M(()=>[C(l.$slots,"aside-top",{},void 0,!0)]),"aside-bottom":M(()=>[C(l.$slots,"aside-bottom",{},void 0,!0)]),"aside-outline-before":M(()=>[C(l.$slots,"aside-outline-before",{},void 0,!0)]),"aside-outline-after":M(()=>[C(l.$slots,"aside-outline-after",{},void 0,!0)]),"aside-ads-before":M(()=>[C(l.$slots,"aside-ads-before",{},void 0,!0)]),"aside-ads-after":M(()=>[C(l.$slots,"aside-ads-after",{},void 0,!0)]),_:3}),x(Cl),C(l.$slots,"layout-bottom",{},void 0,!0)],2)):(_(),K(u,{key:1}))}}}),Wh=q(Bh,[["__scopeId","data-v-1e8cdb3b"]]),ka={Layout:Wh,enhanceApp:({app:t})=>{t.component("Badge",Co)}};var jh=Object.defineProperty,xh=(t,e,n)=>e in t?jh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,D=(t,e,n)=>xh(t,typeof e!="symbol"?e+"":e,n),La=(t=>(t.IPAD="ipad",t.ANDROID="android",t.IPhONE="iphone",t.PC="pc",t))(La||{});const Sa=()=>{if(typeof window<"u"){const t=navigator.userAgent.toLowerCase();return/ipad|ipod/.test(t)?"ipad":/android/.test(t)?"android":/iphone/.test(t)?"iphone":"pc"}return"pc"},Xt=typeof window<"u",Kh=()=>Xt?window.navigator.userAgent.toLowerCase().includes("micromessenger"):!1,Gh=()=>{if(!Xt)return!1;const t=window.navigator.userAgent;return!!/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(t)},Yh=()=>{if(!Xt)return!1;const t=/iphone/i.test(window.navigator.userAgent),e=window.devicePixelRatio&&window.devicePixelRatio===2,n=window.devicePixelRatio&&window.devicePixelRatio===3,r=window.screen.width===360&&window.screen.height===780,s=window.screen.width===375&&window.screen.height===812,a=window.screen.width===390&&window.screen.height===844,o=window.screen.width===414&&window.screen.height===896,i=window.screen.width===428&&window.screen.height===926;switch(!0){case(t&&n&&r):case(t&&n&&s):case(t&&n&&a):case(t&&e&&o):case(t&&n&&o):case(t&&n&&i):return!0;default:return!1}},Ea="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Oa="ARRAYBUFFER not supported by this environment",Ca="UINT8ARRAY not supported by this environment";function zh(t,e,n,r,s){let a,o,i=0,l,c,u,d,f,y;r=r||0;const S=n||[0],g=r>>>3;if(e==="UTF8")for(f=s===-1?3:0,l=0;la?o.push(a):2048>a?(o.push(192|a>>>6),o.push(128|a&63)):55296>a||57344<=a?o.push(224|a>>>12,128|a>>>6&63,128|a&63):(l+=1,a=65536+((a&1023)<<10|t.charCodeAt(l)&1023),o.push(240|a>>>18,128|a>>>12&63,128|a>>>6&63,128|a&63)),c=0;c>>2;S.length<=u;)S.push(0);S[u]|=o[c]<<8*(f+s*(d%4)),i+=1}else for(f=s===-1?2:0,y=e==="UTF16LE"&&s!==1||e!=="UTF16LE"&&s===1,l=0;l>>8),d=i+g,u=d>>>2;S.length<=u;)S.push(0);S[u]|=a<<8*(f+s*(d%4)),i+=2}return{value:S,binLen:i*8+r}}function Xh(t,e,n,r){let s,a,o,i;if(t.length%2!==0)throw new Error("String of HEX type must be in byte increments");n=n||0;const l=e||[0],c=n>>>3,u=r===-1?3:0;for(s=0;s>>1)+c,o=i>>>2;l.length<=o;)l.push(0);l[o]|=a<<8*(u+r*(i%4))}return{value:l,binLen:t.length*4+n}}function qh(t,e,n,r){let s,a,o,i;n=n||0;const l=e||[0],c=n>>>3,u=r===-1?3:0;for(a=0;a>>2,l.length<=o&&l.push(0),l[o]|=s<<8*(u+r*(i%4));return{value:l,binLen:t.length*8+n}}function Jh(t,e,n,r){let s=0,a,o,i,l,c,u,d;n=n||0;const f=e||[0],y=n>>>3,S=r===-1?3:0,g=t.indexOf("=");if(t.search(/^[a-z\d=+/]+$/i)===-1)throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),g!==-1&&g{const[n,r]=e.toString().split(".");return r?r.length:0}),D(this,"amend",(e,n=15)=>parseFloat(Number(e).toPrecision(n))),D(this,"power",(e,n)=>Math.pow(10,Math.max(this.getDecimalLength(e),this.getDecimalLength(n))))}};D(Ge,"handleMethod",(t,e)=>{const n=new Ge,{power:r,amend:s}=n,a=r(t,e),o=s(t*a),i=s(e*a);return l=>{switch(l){case"+":return(o+i)/a;case"-":return(o-i)/a;case"*":return o*i/(a*a);case"/":return o/i}}});D(Ge,"add",(t,e)=>Ge.handleMethod(t,e)("+"));D(Ge,"divide",(t,e)=>Ge.handleMethod(t,e)("/"));D(Ge,"multiply",(t,e)=>Ge.handleMethod(t,e)("*"));D(Ge,"subtract",(t,e)=>Ge.handleMethod(t,e)("-"));var Lt=(t=>(t.NORMAL="normal",t.ERROR="error",t.WARNING="warning",t))(Lt||{}),Qt=(t=>(t.EN="en",t.ZH_CN="zh-CN",t))(Qt||{});const Da="ran_chaxus_lang",ls=[],jm={"zh-CN":{lang:"简体中文"},en:{lang:"English"}};var Ha=(t=>(t.LEGACY="legacy",t))(Ha||{});const cs="PWA_INSTALL_ID",xm="pwa-install",Km="/ran/manifest.json",Gm=!1;Dm();const nr={isDev:Gm,locale:Qt.EN,currentDevice:Sa(),isWeiXin:Kh(),isMobile:Gh(),isBang:Yh()},Ym={install:t=>{t.config.globalProperties.$env=nr,t.provide("$env",nr)}};/*! - * shared v10.0.4 - * (c) 2024 kazuya kawaguchi - * Released under the MIT License. - */const mn=typeof window<"u",ut=(t,e=!1)=>e?Symbol.for(t):Symbol(t),zm=(t,e,n)=>Xm({l:t,k:e,s:n}),Xm=t=>JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029").replace(/\u0027/g,"\\u0027"),we=t=>typeof t=="number"&&isFinite(t),qm=t=>Sr(t)==="[object Date]",At=t=>Sr(t)==="[object RegExp]",On=t=>ee(t)&&Object.keys(t).length===0,ke=Object.assign;let us;const mt=()=>us||(us=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function ds(t){return t.replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}const Jm=Object.prototype.hasOwnProperty;function pn(t,e){return Jm.call(t,e)}const ve=Array.isArray,me=t=>typeof t=="function",H=t=>typeof t=="string",ie=t=>typeof t=="boolean",le=t=>t!==null&&typeof t=="object",Qm=t=>le(t)&&me(t.then)&&me(t.catch),Ua=Object.prototype.toString,Sr=t=>Ua.call(t),ee=t=>Sr(t)==="[object Object]",Zm=t=>t==null?"":ve(t)||ee(t)&&t.toString===Ua?JSON.stringify(t,null,2):String(t);function Er(t,e=""){return t.reduce((n,r,s)=>s===0?n+r:n+e+r,"")}function ep(t,e){typeof console<"u"&&(console.warn("[intlify] "+t),e&&console.warn(e.stack))}const nn=t=>!le(t)||ve(t);function ln(t,e){if(nn(t)||nn(e))throw new Error("Invalid value");const n=[{src:t,des:e}];for(;n.length;){const{src:r,des:s}=n.pop();Object.keys(r).forEach(a=>{le(r[a])&&!le(s[a])&&(s[a]=Array.isArray(r[a])?[]:{}),nn(s[a])||nn(r[a])?s[a]=r[a]:n.push({src:r[a],des:s[a]})})}}/*! - * message-compiler v10.0.4 - * (c) 2024 kazuya kawaguchi - * Released under the MIT License. - */function tp(t,e,n){return{line:t,column:e,offset:n}}function rr(t,e,n){return{start:t,end:e}}const de={EXPECTED_TOKEN:1,INVALID_TOKEN_IN_PLACEHOLDER:2,UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER:3,UNKNOWN_ESCAPE_SEQUENCE:4,INVALID_UNICODE_ESCAPE_SEQUENCE:5,UNBALANCED_CLOSING_BRACE:6,UNTERMINATED_CLOSING_BRACE:7,EMPTY_PLACEHOLDER:8,NOT_ALLOW_NEST_PLACEHOLDER:9,INVALID_LINKED_FORMAT:10,MUST_HAVE_MESSAGES_IN_PLURAL:11,UNEXPECTED_EMPTY_LINKED_MODIFIER:12,UNEXPECTED_EMPTY_LINKED_KEY:13,UNEXPECTED_LEXICAL_ANALYSIS:14,UNHANDLED_CODEGEN_NODE_TYPE:15,UNHANDLED_MINIFIER_NODE_TYPE:16},np=17;function Cn(t,e,n={}){const{domain:r,messages:s,args:a}=n,o=t,i=new SyntaxError(String(o));return i.code=t,e&&(i.location=e),i.domain=r,i}function rp(t){throw t}const ze=" ",sp="\r",Ae=` -`,ap="\u2028",op="\u2029";function ip(t){const e=t;let n=0,r=1,s=1,a=0;const o=N=>e[N]===sp&&e[N+1]===Ae,i=N=>e[N]===Ae,l=N=>e[N]===op,c=N=>e[N]===ap,u=N=>o(N)||i(N)||l(N)||c(N),d=()=>n,f=()=>r,y=()=>s,S=()=>a,g=N=>o(N)||l(N)||c(N)?Ae:e[N],b=()=>g(n),p=()=>g(n+a);function E(){return a=0,u(n)&&(r++,s=0),o(n)&&n++,n++,s++,e[n]}function I(){return o(n+a)&&a++,a++,e[n+a]}function L(){n=0,r=1,s=1,a=0}function P(N=0){a=N}function T(){const N=n+a;for(;N!==n;)E();a=0}return{index:d,line:f,column:y,peekOffset:S,charAt:g,currentChar:b,currentPeek:p,next:E,peek:I,reset:L,resetPeek:P,skipToPeek:T}}const st=void 0,lp=".",fs="'",cp="tokenizer";function up(t,e={}){const n=e.location!==!1,r=ip(t),s=()=>r.index(),a=()=>tp(r.line(),r.column(),r.index()),o=a(),i=s(),l={currentType:13,offset:i,startLoc:o,endLoc:o,lastType:13,lastOffset:i,lastStartLoc:o,lastEndLoc:o,braceNest:0,inLinked:!1,text:""},c=()=>l,{onError:u}=e;function d(h,m,$,...z){const be=c();if(m.column+=$,m.offset+=$,u){const ne=n?rr(be.startLoc,m):null,O=Cn(h,ne,{domain:cp,args:z});u(O)}}function f(h,m,$){h.endLoc=a(),h.currentType=m;const z={type:m};return n&&(z.loc=rr(h.startLoc,h.endLoc)),$!=null&&(z.value=$),z}const y=h=>f(h,13);function S(h,m){return h.currentChar()===m?(h.next(),m):(d(de.EXPECTED_TOKEN,a(),0,m),"")}function g(h){let m="";for(;h.currentPeek()===ze||h.currentPeek()===Ae;)m+=h.currentPeek(),h.peek();return m}function b(h){const m=g(h);return h.skipToPeek(),m}function p(h){if(h===st)return!1;const m=h.charCodeAt(0);return m>=97&&m<=122||m>=65&&m<=90||m===95}function E(h){if(h===st)return!1;const m=h.charCodeAt(0);return m>=48&&m<=57}function I(h,m){const{currentType:$}=m;if($!==2)return!1;g(h);const z=p(h.currentPeek());return h.resetPeek(),z}function L(h,m){const{currentType:$}=m;if($!==2)return!1;g(h);const z=h.currentPeek()==="-"?h.peek():h.currentPeek(),be=E(z);return h.resetPeek(),be}function P(h,m){const{currentType:$}=m;if($!==2)return!1;g(h);const z=h.currentPeek()===fs;return h.resetPeek(),z}function T(h,m){const{currentType:$}=m;if($!==7)return!1;g(h);const z=h.currentPeek()===".";return h.resetPeek(),z}function N(h,m){const{currentType:$}=m;if($!==8)return!1;g(h);const z=p(h.currentPeek());return h.resetPeek(),z}function B(h,m){const{currentType:$}=m;if(!($===7||$===11))return!1;g(h);const z=h.currentPeek()===":";return h.resetPeek(),z}function G(h,m){const{currentType:$}=m;if($!==9)return!1;const z=()=>{const ne=h.currentPeek();return ne==="{"?p(h.peek()):ne==="@"||ne==="|"||ne===":"||ne==="."||ne===ze||!ne?!1:ne===Ae?(h.peek(),z()):ge(h,!1)},be=z();return h.resetPeek(),be}function ce(h){g(h);const m=h.currentPeek()==="|";return h.resetPeek(),m}function ge(h,m=!0){const $=(be=!1,ne="")=>{const O=h.currentPeek();return O==="{"||O==="@"||!O?be:O==="|"?!(ne===ze||ne===Ae):O===ze?(h.peek(),$(!0,ze)):O===Ae?(h.peek(),$(!0,Ae)):!0},z=$();return m&&h.resetPeek(),z}function ae(h,m){const $=h.currentChar();return $===st?st:m($)?(h.next(),$):null}function _e(h){const m=h.charCodeAt(0);return m>=97&&m<=122||m>=65&&m<=90||m>=48&&m<=57||m===95||m===36}function Ne(h){return ae(h,_e)}function Te(h){const m=h.charCodeAt(0);return m>=97&&m<=122||m>=65&&m<=90||m>=48&&m<=57||m===95||m===36||m===45}function tt(h){return ae(h,Te)}function De(h){const m=h.charCodeAt(0);return m>=48&&m<=57}function nt(h){return ae(h,De)}function Ee(h){const m=h.charCodeAt(0);return m>=48&&m<=57||m>=65&&m<=70||m>=97&&m<=102}function rt(h){return ae(h,Ee)}function J(h){let m="",$="";for(;m=nt(h);)$+=m;return $}function te(h){let m="";for(;;){const $=h.currentChar();if($==="{"||$==="}"||$==="@"||$==="|"||!$)break;if($===ze||$===Ae)if(ge(h))m+=$,h.next();else{if(ce(h))break;m+=$,h.next()}else m+=$,h.next()}return m}function V(h){b(h);let m="",$="";for(;m=tt(h);)$+=m;return h.currentChar()===st&&d(de.UNTERMINATED_CLOSING_BRACE,a(),0),$}function re(h){b(h);let m="";return h.currentChar()==="-"?(h.next(),m+=`-${J(h)}`):m+=J(h),h.currentChar()===st&&d(de.UNTERMINATED_CLOSING_BRACE,a(),0),m}function Y(h){return h!==fs&&h!==Ae}function oe(h){b(h),S(h,"'");let m="",$="";for(;m=ae(h,Y);)m==="\\"?$+=Le(h):$+=m;const z=h.currentChar();return z===Ae||z===st?(d(de.UNTERMINATED_SINGLE_QUOTE_IN_PLACEHOLDER,a(),0),z===Ae&&(h.next(),S(h,"'")),$):(S(h,"'"),$)}function Le(h){const m=h.currentChar();switch(m){case"\\":case"'":return h.next(),`\\${m}`;case"u":return Se(h,m,4);case"U":return Se(h,m,6);default:return d(de.UNKNOWN_ESCAPE_SEQUENCE,a(),0,m),""}}function Se(h,m,$){S(h,m);let z="";for(let be=0;be<$;be++){const ne=rt(h);if(!ne){d(de.INVALID_UNICODE_ESCAPE_SEQUENCE,a(),0,`\\${m}${z}${h.currentChar()}`);break}z+=ne}return`\\${m}${z}`}function vt(h){return h!=="{"&&h!=="}"&&h!==ze&&h!==Ae}function Fe(h){b(h);let m="",$="";for(;m=ae(h,vt);)$+=m;return $}function Mn(h){let m="",$="";for(;m=Ne(h);)$+=m;return $}function Nn(h){const m=$=>{const z=h.currentChar();return z==="{"||z==="@"||z==="|"||z==="("||z===")"||!z||z===ze?$:($+=z,h.next(),m($))};return m("")}function Ft(h){b(h);const m=S(h,"|");return b(h),m}function gt(h,m){let $=null;switch(h.currentChar()){case"{":return m.braceNest>=1&&d(de.NOT_ALLOW_NEST_PLACEHOLDER,a(),0),h.next(),$=f(m,2,"{"),b(h),m.braceNest++,$;case"}":return m.braceNest>0&&m.currentType===2&&d(de.EMPTY_PLACEHOLDER,a(),0),h.next(),$=f(m,3,"}"),m.braceNest--,m.braceNest>0&&b(h),m.inLinked&&m.braceNest===0&&(m.inLinked=!1),$;case"@":return m.braceNest>0&&d(de.UNTERMINATED_CLOSING_BRACE,a(),0),$=bt(h,m)||y(m),m.braceNest=0,$;default:{let be=!0,ne=!0,O=!0;if(ce(h))return m.braceNest>0&&d(de.UNTERMINATED_CLOSING_BRACE,a(),0),$=f(m,1,Ft(h)),m.braceNest=0,m.inLinked=!1,$;if(m.braceNest>0&&(m.currentType===4||m.currentType===5||m.currentType===6))return d(de.UNTERMINATED_CLOSING_BRACE,a(),0),m.braceNest=0,Rt(h,m);if(be=I(h,m))return $=f(m,4,V(h)),b(h),$;if(ne=L(h,m))return $=f(m,5,re(h)),b(h),$;if(O=P(h,m))return $=f(m,6,oe(h)),b(h),$;if(!be&&!ne&&!O)return $=f(m,12,Fe(h)),d(de.INVALID_TOKEN_IN_PLACEHOLDER,a(),0,$.value),b(h),$;break}}return $}function bt(h,m){const{currentType:$}=m;let z=null;const be=h.currentChar();switch(($===7||$===8||$===11||$===9)&&(be===Ae||be===ze)&&d(de.INVALID_LINKED_FORMAT,a(),0),be){case"@":return h.next(),z=f(m,7,"@"),m.inLinked=!0,z;case".":return b(h),h.next(),f(m,8,".");case":":return b(h),h.next(),f(m,9,":");default:return ce(h)?(z=f(m,1,Ft(h)),m.braceNest=0,m.inLinked=!1,z):T(h,m)||B(h,m)?(b(h),bt(h,m)):N(h,m)?(b(h),f(m,11,Mn(h))):G(h,m)?(b(h),be==="{"?gt(h,m)||z:f(m,10,Nn(h))):($===7&&d(de.INVALID_LINKED_FORMAT,a(),0),m.braceNest=0,m.inLinked=!1,Rt(h,m))}}function Rt(h,m){let $={type:13};if(m.braceNest>0)return gt(h,m)||y(m);if(m.inLinked)return bt(h,m)||y(m);switch(h.currentChar()){case"{":return gt(h,m)||y(m);case"}":return d(de.UNBALANCED_CLOSING_BRACE,a(),0),h.next(),f(m,3,"}");case"@":return bt(h,m)||y(m);default:{if(ce(h))return $=f(m,1,Ft(h)),m.braceNest=0,m.inLinked=!1,$;if(ge(h))return f(m,0,te(h));break}}return $}function $n(){const{currentType:h,offset:m,startLoc:$,endLoc:z}=l;return l.lastType=h,l.lastOffset=m,l.lastStartLoc=$,l.lastEndLoc=z,l.offset=s(),l.startLoc=a(),r.currentChar()===st?f(l,13):Rt(r,l)}return{nextToken:$n,currentOffset:s,currentPosition:a,context:c}}const dp="parser",fp=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function hp(t,e,n){switch(t){case"\\\\":return"\\";case"\\'":return"'";default:{const r=parseInt(e||n,16);return r<=55295||r>=57344?String.fromCodePoint(r):"�"}}}function mp(t={}){const e=t.location!==!1,{onError:n}=t;function r(p,E,I,L,...P){const T=p.currentPosition();if(T.offset+=L,T.column+=L,n){const N=e?rr(I,T):null,B=Cn(E,N,{domain:dp,args:P});n(B)}}function s(p,E,I){const L={type:p};return e&&(L.start=E,L.end=E,L.loc={start:I,end:I}),L}function a(p,E,I,L){e&&(p.end=E,p.loc&&(p.loc.end=I))}function o(p,E){const I=p.context(),L=s(3,I.offset,I.startLoc);return L.value=E,a(L,p.currentOffset(),p.currentPosition()),L}function i(p,E){const I=p.context(),{lastOffset:L,lastStartLoc:P}=I,T=s(5,L,P);return T.index=parseInt(E,10),p.nextToken(),a(T,p.currentOffset(),p.currentPosition()),T}function l(p,E){const I=p.context(),{lastOffset:L,lastStartLoc:P}=I,T=s(4,L,P);return T.key=E,p.nextToken(),a(T,p.currentOffset(),p.currentPosition()),T}function c(p,E){const I=p.context(),{lastOffset:L,lastStartLoc:P}=I,T=s(9,L,P);return T.value=E.replace(fp,hp),p.nextToken(),a(T,p.currentOffset(),p.currentPosition()),T}function u(p){const E=p.nextToken(),I=p.context(),{lastOffset:L,lastStartLoc:P}=I,T=s(8,L,P);return E.type!==11?(r(p,de.UNEXPECTED_EMPTY_LINKED_MODIFIER,I.lastStartLoc,0),T.value="",a(T,L,P),{nextConsumeToken:E,node:T}):(E.value==null&&r(p,de.UNEXPECTED_LEXICAL_ANALYSIS,I.lastStartLoc,0,He(E)),T.value=E.value||"",a(T,p.currentOffset(),p.currentPosition()),{node:T})}function d(p,E){const I=p.context(),L=s(7,I.offset,I.startLoc);return L.value=E,a(L,p.currentOffset(),p.currentPosition()),L}function f(p){const E=p.context(),I=s(6,E.offset,E.startLoc);let L=p.nextToken();if(L.type===8){const P=u(p);I.modifier=P.node,L=P.nextConsumeToken||p.nextToken()}switch(L.type!==9&&r(p,de.UNEXPECTED_LEXICAL_ANALYSIS,E.lastStartLoc,0,He(L)),L=p.nextToken(),L.type===2&&(L=p.nextToken()),L.type){case 10:L.value==null&&r(p,de.UNEXPECTED_LEXICAL_ANALYSIS,E.lastStartLoc,0,He(L)),I.key=d(p,L.value||"");break;case 4:L.value==null&&r(p,de.UNEXPECTED_LEXICAL_ANALYSIS,E.lastStartLoc,0,He(L)),I.key=l(p,L.value||"");break;case 5:L.value==null&&r(p,de.UNEXPECTED_LEXICAL_ANALYSIS,E.lastStartLoc,0,He(L)),I.key=i(p,L.value||"");break;case 6:L.value==null&&r(p,de.UNEXPECTED_LEXICAL_ANALYSIS,E.lastStartLoc,0,He(L)),I.key=c(p,L.value||"");break;default:{r(p,de.UNEXPECTED_EMPTY_LINKED_KEY,E.lastStartLoc,0);const P=p.context(),T=s(7,P.offset,P.startLoc);return T.value="",a(T,P.offset,P.startLoc),I.key=T,a(I,P.offset,P.startLoc),{nextConsumeToken:L,node:I}}}return a(I,p.currentOffset(),p.currentPosition()),{node:I}}function y(p){const E=p.context(),I=E.currentType===1?p.currentOffset():E.offset,L=E.currentType===1?E.endLoc:E.startLoc,P=s(2,I,L);P.items=[];let T=null;do{const G=T||p.nextToken();switch(T=null,G.type){case 0:G.value==null&&r(p,de.UNEXPECTED_LEXICAL_ANALYSIS,E.lastStartLoc,0,He(G)),P.items.push(o(p,G.value||""));break;case 5:G.value==null&&r(p,de.UNEXPECTED_LEXICAL_ANALYSIS,E.lastStartLoc,0,He(G)),P.items.push(i(p,G.value||""));break;case 4:G.value==null&&r(p,de.UNEXPECTED_LEXICAL_ANALYSIS,E.lastStartLoc,0,He(G)),P.items.push(l(p,G.value||""));break;case 6:G.value==null&&r(p,de.UNEXPECTED_LEXICAL_ANALYSIS,E.lastStartLoc,0,He(G)),P.items.push(c(p,G.value||""));break;case 7:{const ce=f(p);P.items.push(ce.node),T=ce.nextConsumeToken||null;break}}}while(E.currentType!==13&&E.currentType!==1);const N=E.currentType===1?E.lastOffset:p.currentOffset(),B=E.currentType===1?E.lastEndLoc:p.currentPosition();return a(P,N,B),P}function S(p,E,I,L){const P=p.context();let T=L.items.length===0;const N=s(1,E,I);N.cases=[],N.cases.push(L);do{const B=y(p);T||(T=B.items.length===0),N.cases.push(B)}while(P.currentType!==13);return T&&r(p,de.MUST_HAVE_MESSAGES_IN_PLURAL,I,0),a(N,p.currentOffset(),p.currentPosition()),N}function g(p){const E=p.context(),{offset:I,startLoc:L}=E,P=y(p);return E.currentType===13?P:S(p,I,L,P)}function b(p){const E=up(p,ke({},t)),I=E.context(),L=s(0,I.offset,I.startLoc);return e&&L.loc&&(L.loc.source=p),L.body=g(E),t.onCacheKey&&(L.cacheKey=t.onCacheKey(p)),I.currentType!==13&&r(E,de.UNEXPECTED_LEXICAL_ANALYSIS,I.lastStartLoc,0,p[I.offset]||""),a(L,E.currentOffset(),E.currentPosition()),L}return{parse:b}}function He(t){if(t.type===13)return"EOF";const e=(t.value||"").replace(/\r?\n/gu,"\\n");return e.length>10?e.slice(0,9)+"…":e}function pp(t,e={}){const n={ast:t,helpers:new Set};return{context:()=>n,helper:a=>(n.helpers.add(a),a)}}function hs(t,e){for(let n=0;nms(n)),t}function ms(t){if(t.items.length===1){const e=t.items[0];(e.type===3||e.type===9)&&(t.static=e.value,delete e.value)}else{const e=[];for(let n=0;ni;function c(b,p){i.code+=b}function u(b,p=!0){const E=p?s:"";c(a?E+" ".repeat(b):E)}function d(b=!0){const p=++i.indentLevel;b&&u(p)}function f(b=!0){const p=--i.indentLevel;b&&u(p)}function y(){u(i.indentLevel)}return{context:l,push:c,indent:d,deindent:f,newline:y,helper:b=>`_${b}`,needIndent:()=>i.needIndent}}function bp(t,e){const{helper:n}=t;t.push(`${n("linked")}(`),It(t,e.key),e.modifier?(t.push(", "),It(t,e.modifier),t.push(", _type")):t.push(", undefined, _type"),t.push(")")}function yp(t,e){const{helper:n,needIndent:r}=t;t.push(`${n("normalize")}([`),t.indent(r());const s=e.items.length;for(let a=0;a1){t.push(`${n("plural")}([`),t.indent(r());const s=e.cases.length;for(let a=0;a{const n=H(e.mode)?e.mode:"normal",r=H(e.filename)?e.filename:"message.intl",s=!!e.sourceMap,a=e.breakLineCode!=null?e.breakLineCode:n==="arrow"?";":` -`,o=e.needIndent?e.needIndent:n!=="arrow",i=t.helpers||[],l=gp(t,{mode:n,filename:r,sourceMap:s,breakLineCode:a,needIndent:o});l.push(n==="normal"?"function __msg__ (ctx) {":"(ctx) => {"),l.indent(o),i.length>0&&(l.push(`const { ${Er(i.map(d=>`${d}: _${d}`),", ")} } = ctx`),l.newline()),l.push("return "),It(l,t),l.deindent(o),l.push("}"),delete t.helpers;const{code:c,map:u}=l.context();return{ast:t,code:c,map:u?u.toJSON():void 0}};function Sp(t,e={}){const n=ke({},e),r=!!n.jit,s=!!n.minify,a=n.optimize==null?!0:n.optimize,i=mp(n).parse(t);return r?(a&&vp(i),s&&St(i),{ast:i,code:""}):(_p(i,n),Lp(i,n))}/*! - * core-base v10.0.4 - * (c) 2024 kazuya kawaguchi - * Released under the MIT License. - */function Ep(){typeof __INTLIFY_PROD_DEVTOOLS__!="boolean"&&(mt().__INTLIFY_PROD_DEVTOOLS__=!1),typeof __INTLIFY_DROP_MESSAGE_COMPILER__!="boolean"&&(mt().__INTLIFY_DROP_MESSAGE_COMPILER__=!1)}function Dn(t){return n=>Op(n,t)}function Op(t,e){const n=e.b||e.body;if((n.t||n.type)===1){const r=n,s=r.c||r.cases;return t.plural(s.reduce((a,o)=>[...a,ps(t,o)],[]))}else return ps(t,n)}function ps(t,e){const n=e.s||e.static;if(n!=null)return t.type==="text"?n:t.normalize([n]);{const r=(e.i||e.items).reduce((s,a)=>[...s,sr(t,a)],[]);return t.normalize(r)}}function sr(t,e){const n=e.t||e.type;switch(n){case 3:{const r=e;return r.v||r.value}case 9:{const r=e;return r.v||r.value}case 4:{const r=e;return t.interpolate(t.named(r.k||r.key))}case 5:{const r=e;return t.interpolate(t.list(r.i!=null?r.i:r.index))}case 6:{const r=e,s=r.m||r.modifier;return t.linked(sr(t,r.k||r.key),s?sr(t,s):void 0,t.type)}case 7:{const r=e;return r.v||r.value}case 8:{const r=e;return r.v||r.value}default:throw new Error(`unhandled node type on format message part: ${n}`)}}const Cp=t=>t;let rn=Object.create(null);const Mt=t=>le(t)&&(t.t===0||t.type===0)&&("b"in t||"body"in t);function Ap(t,e={}){let n=!1;const r=e.onError||rp;return e.onError=s=>{n=!0,r(s)},{...Sp(t,e),detectError:n}}function Ip(t,e){if(!__INTLIFY_DROP_MESSAGE_COMPILER__&&H(t)){ie(e.warnHtmlMessage)&&e.warnHtmlMessage;const r=(e.onCacheKey||Cp)(t),s=rn[r];if(s)return s;const{ast:a,detectError:o}=Ap(t,{...e,location:!1,jit:!0}),i=Dn(a);return o?i:rn[r]=i}else{const n=t.cacheKey;if(n){const r=rn[n];return r||(rn[n]=Dn(t))}else return Dn(t)}}let xt=null;function Mp(t){xt=t}function Np(t,e,n){xt&&xt.emit("i18n:init",{timestamp:Date.now(),i18n:t,version:e,meta:n})}const $p=Pp("function:translate");function Pp(t){return e=>xt&&xt.emit(t,e)}const Je={INVALID_ARGUMENT:np,INVALID_DATE_ARGUMENT:18,INVALID_ISO_DATE_ARGUMENT:19,NOT_SUPPORT_NON_STRING_MESSAGE:20,NOT_SUPPORT_LOCALE_PROMISE_VALUE:21,NOT_SUPPORT_LOCALE_ASYNC_FUNCTION:22,NOT_SUPPORT_LOCALE_TYPE:23},Tp=24;function Qe(t){return Cn(t,null,void 0)}function Cr(t,e){return e.locale!=null?_s(e.locale):_s(t.locale)}let Hn;function _s(t){if(H(t))return t;if(me(t)){if(t.resolvedOnce&&Hn!=null)return Hn;if(t.constructor.name==="Function"){const e=t();if(Qm(e))throw Qe(Je.NOT_SUPPORT_LOCALE_PROMISE_VALUE);return Hn=e}else throw Qe(Je.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION)}else throw Qe(Je.NOT_SUPPORT_LOCALE_TYPE)}function Fp(t,e,n){return[...new Set([n,...ve(e)?e:le(e)?Object.keys(e):H(e)?[e]:[n]])]}function Ba(t,e,n){const r=H(n)?n:Kt,s=t;s.__localeChainCache||(s.__localeChainCache=new Map);let a=s.__localeChainCache.get(r);if(!a){a=[];let o=[n];for(;ve(o);)o=vs(a,o,e);const i=ve(e)||!ee(e)?e:e.default?e.default:null;o=H(i)?[i]:i,ve(o)&&vs(a,o,!1),s.__localeChainCache.set(r,a)}return a}function vs(t,e,n){let r=!0;for(let s=0;s{o===void 0?o=i:o+=i},f[1]=()=>{o!==void 0&&(e.push(o),o=void 0)},f[2]=()=>{f[0](),s++},f[3]=()=>{if(s>0)s--,r=4,f[0]();else{if(s=0,o===void 0||(o=Wp(o),o===!1))return!1;f[1]()}};function y(){const S=t[n+1];if(r===5&&S==="'"||r===6&&S==='"')return n++,i="\\"+S,f[0](),!0}for(;r!==null;)if(n++,a=t[n],!(a==="\\"&&y())){if(l=Bp(a),d=dt[r],c=d[l]||d.l||8,c===8||(r=c[0],c[1]!==void 0&&(u=f[c[1]],u&&(i=a,u()===!1))))return;if(r===7)return e}}const gs=new Map;function xp(t,e){return le(t)?t[e]:null}function Kp(t,e){if(!le(t))return null;let n=gs.get(e);if(n||(n=jp(e),n&&gs.set(e,n)),!n)return null;const r=n.length;let s=t,a=0;for(;a`${t.charAt(0).toLocaleUpperCase()}${t.substr(1)}`;function Yp(){return{upper:(t,e)=>e==="text"&&H(t)?t.toUpperCase():e==="vnode"&&le(t)&&"__v_isVNode"in t?t.children.toUpperCase():t,lower:(t,e)=>e==="text"&&H(t)?t.toLowerCase():e==="vnode"&&le(t)&&"__v_isVNode"in t?t.children.toLowerCase():t,capitalize:(t,e)=>e==="text"&&H(t)?ys(t):e==="vnode"&&le(t)&&"__v_isVNode"in t?ys(t.children):t}}let Wa;function zp(t){Wa=t}let ja;function Xp(t){ja=t}let xa;function qp(t){xa=t}let Ka=null;const Jp=t=>{Ka=t},Qp=()=>Ka;let Ga=null;const ws=t=>{Ga=t},Zp=()=>Ga;let ks=0;function e1(t={}){const e=me(t.onWarn)?t.onWarn:ep,n=H(t.version)?t.version:Gp,r=H(t.locale)||me(t.locale)?t.locale:Kt,s=me(r)?Kt:r,a=ve(t.fallbackLocale)||ee(t.fallbackLocale)||H(t.fallbackLocale)||t.fallbackLocale===!1?t.fallbackLocale:s,o=ee(t.messages)?t.messages:{[s]:{}},i=ee(t.datetimeFormats)?t.datetimeFormats:{[s]:{}},l=ee(t.numberFormats)?t.numberFormats:{[s]:{}},c=ke({},t.modifiers||{},Yp()),u=t.pluralRules||{},d=me(t.missing)?t.missing:null,f=ie(t.missingWarn)||At(t.missingWarn)?t.missingWarn:!0,y=ie(t.fallbackWarn)||At(t.fallbackWarn)?t.fallbackWarn:!0,S=!!t.fallbackFormat,g=!!t.unresolving,b=me(t.postTranslation)?t.postTranslation:null,p=ee(t.processor)?t.processor:null,E=ie(t.warnHtmlMessage)?t.warnHtmlMessage:!0,I=!!t.escapeParameter,L=me(t.messageCompiler)?t.messageCompiler:Wa,P=me(t.messageResolver)?t.messageResolver:ja||xp,T=me(t.localeFallbacker)?t.localeFallbacker:xa||Fp,N=le(t.fallbackContext)?t.fallbackContext:void 0,B=t,G=le(B.__datetimeFormatters)?B.__datetimeFormatters:new Map,ce=le(B.__numberFormatters)?B.__numberFormatters:new Map,ge=le(B.__meta)?B.__meta:{};ks++;const ae={version:n,cid:ks,locale:r,fallbackLocale:a,messages:o,modifiers:c,pluralRules:u,missing:d,missingWarn:f,fallbackWarn:y,fallbackFormat:S,unresolving:g,postTranslation:b,processor:p,warnHtmlMessage:E,escapeParameter:I,messageCompiler:L,messageResolver:P,localeFallbacker:T,fallbackContext:N,onWarn:e,__meta:ge};return ae.datetimeFormats=i,ae.numberFormats=l,ae.__datetimeFormatters=G,ae.__numberFormatters=ce,__INTLIFY_PROD_DEVTOOLS__&&Np(ae,n,ge),ae}function Ar(t,e,n,r,s){const{missing:a,onWarn:o}=t;if(a!==null){const i=a(t,n,e,s);return H(i)?i:e}else return e}function Ht(t,e,n){const r=t;r.__localeChainCache=new Map,t.localeFallbacker(t,n,e)}function t1(t,e){return t===e?!1:t.split("-")[0]===e.split("-")[0]}function n1(t,e){const n=e.indexOf(t);if(n===-1)return!1;for(let r=n+1;r{Ya.includes(l)?o[l]=n[l]:a[l]=n[l]}),H(r)?a.locale=r:ee(r)&&(o=r),ee(s)&&(o=s),[a.key||"",i,a,o]}function Ss(t,e,n){const r=t;for(const s in n){const a=`${e}__${s}`;r.__datetimeFormatters.has(a)&&r.__datetimeFormatters.delete(a)}}function Es(t,...e){const{numberFormats:n,unresolving:r,fallbackLocale:s,onWarn:a,localeFallbacker:o}=t,{__numberFormatters:i}=t,[l,c,u,d]=or(...e),f=ie(u.missingWarn)?u.missingWarn:t.missingWarn;ie(u.fallbackWarn)?u.fallbackWarn:t.fallbackWarn;const y=!!u.part,S=Cr(t,u),g=o(t,s,S);if(!H(l)||l==="")return new Intl.NumberFormat(S,d).format(c);let b={},p,E=null;const I="number format";for(let T=0;T{za.includes(l)?o[l]=n[l]:a[l]=n[l]}),H(r)?a.locale=r:ee(r)&&(o=r),ee(s)&&(o=s),[a.key||"",i,a,o]}function Os(t,e,n){const r=t;for(const s in n){const a=`${e}__${s}`;r.__numberFormatters.has(a)&&r.__numberFormatters.delete(a)}}const r1=t=>t,s1=t=>"",a1="text",o1=t=>t.length===0?"":Er(t),i1=Zm;function Cs(t,e){return t=Math.abs(t),e===2?t?t>1?1:0:1:t?Math.min(t,2):0}function l1(t){const e=we(t.pluralIndex)?t.pluralIndex:-1;return t.named&&(we(t.named.count)||we(t.named.n))?we(t.named.count)?t.named.count:we(t.named.n)?t.named.n:e:e}function c1(t,e){e.count||(e.count=t),e.n||(e.n=t)}function u1(t={}){const e=t.locale,n=l1(t),r=le(t.pluralRules)&&H(e)&&me(t.pluralRules[e])?t.pluralRules[e]:Cs,s=le(t.pluralRules)&&H(e)&&me(t.pluralRules[e])?Cs:void 0,a=p=>p[r(n,p.length,s)],o=t.list||[],i=p=>o[p],l=t.named||{};we(t.pluralIndex)&&c1(n,l);const c=p=>l[p];function u(p,E){const I=me(t.messages)?t.messages(p,!!E):le(t.messages)?t.messages[p]:!1;return I||(t.parent?t.parent.message(p):s1)}const d=p=>t.modifiers?t.modifiers[p]:r1,f=ee(t.processor)&&me(t.processor.normalize)?t.processor.normalize:o1,y=ee(t.processor)&&me(t.processor.interpolate)?t.processor.interpolate:i1,S=ee(t.processor)&&H(t.processor.type)?t.processor.type:a1,b={list:i,named:c,plural:a,linked:(p,...E)=>{const[I,L]=E;let P="text",T="";E.length===1?le(I)?(T=I.modifier||T,P=I.type||P):H(I)&&(T=I||T):E.length===2&&(H(I)&&(T=I||T),H(L)&&(P=L||P));const N=u(p,!0)(b),B=P==="vnode"&&ve(N)&&T?N[0]:N;return T?d(T)(B,P):B},message:u,type:S,interpolate:y,normalize:f,values:ke({},o,l)};return b}const As=()=>"",Pe=t=>me(t);function Is(t,...e){const{fallbackFormat:n,postTranslation:r,unresolving:s,messageCompiler:a,fallbackLocale:o,messages:i}=t,[l,c]=ir(...e),u=ie(c.missingWarn)?c.missingWarn:t.missingWarn,d=ie(c.fallbackWarn)?c.fallbackWarn:t.fallbackWarn,f=ie(c.escapeParameter)?c.escapeParameter:t.escapeParameter,y=!!c.resolvedMessage,S=H(c.default)||ie(c.default)?ie(c.default)?a?l:()=>l:c.default:n?a?l:()=>l:null,g=n||S!=null&&(H(S)||me(S)),b=Cr(t,c);f&&d1(c);let[p,E,I]=y?[l,b,i[b]||{}]:Xa(t,l,b,o,d,u),L=p,P=l;if(!y&&!(H(L)||Mt(L)||Pe(L))&&g&&(L=S,P=L),!y&&(!(H(L)||Mt(L)||Pe(L))||!H(E)))return s?An:l;let T=!1;const N=()=>{T=!0},B=Pe(L)?L:qa(t,l,E,L,P,N);if(T)return L;const G=m1(t,E,I,c),ce=u1(G),ge=f1(t,B,ce),ae=r?r(ge,l):ge;if(__INTLIFY_PROD_DEVTOOLS__){const _e={timestamp:Date.now(),key:H(l)?l:Pe(L)?L.key:"",locale:E||(Pe(L)?L.locale:""),format:H(L)?L:Pe(L)?L.source:"",message:ae};_e.meta=ke({},t.__meta,Qp()||{}),$p(_e)}return ae}function d1(t){ve(t.list)?t.list=t.list.map(e=>H(e)?ds(e):e):le(t.named)&&Object.keys(t.named).forEach(e=>{H(t.named[e])&&(t.named[e]=ds(t.named[e]))})}function Xa(t,e,n,r,s,a){const{messages:o,onWarn:i,messageResolver:l,localeFallbacker:c}=t,u=c(t,r,n);let d={},f,y=null;const S="translate";for(let g=0;gr;return c.locale=n,c.key=e,c}const l=o(r,h1(t,n,s,r,i,a));return l.locale=n,l.key=e,l.source=r,l}function f1(t,e,n){return e(n)}function ir(...t){const[e,n,r]=t,s={};if(!H(e)&&!we(e)&&!Pe(e)&&!Mt(e))throw Qe(Je.INVALID_ARGUMENT);const a=we(e)?String(e):(Pe(e),e);return we(n)?s.plural=n:H(n)?s.default=n:ee(n)&&!On(n)?s.named=n:ve(n)&&(s.list=n),we(r)?s.plural=r:H(r)?s.default=r:ee(r)&&ke(s,r),[a,s]}function h1(t,e,n,r,s,a){return{locale:e,key:n,warnHtmlMessage:s,onError:o=>{throw a&&a(o),o},onCacheKey:o=>zm(e,n,o)}}function m1(t,e,n,r){const{modifiers:s,pluralRules:a,messageResolver:o,fallbackLocale:i,fallbackWarn:l,missingWarn:c,fallbackContext:u}=t,f={locale:e,modifiers:s,pluralRules:a,messages:(y,S)=>{let g=o(n,y);if(g==null&&(u||S)){const[,,b]=Xa(u||t,y,e,i,l,c);g=o(b,y)}if(H(g)||Mt(g)){let b=!1;const E=qa(t,y,e,g,y,()=>{b=!0});return b?As:E}else return Pe(g)?g:As}};return t.processor&&(f.processor=t.processor),r.list&&(f.list=r.list),r.named&&(f.named=r.named),we(r.plural)&&(f.pluralIndex=r.plural),f}Ep();/*! - * vue-i18n v10.0.4 - * (c) 2024 kazuya kawaguchi - * Released under the MIT License. - */const p1="10.0.4";function _1(){typeof __VUE_I18N_FULL_INSTALL__!="boolean"&&(mt().__VUE_I18N_FULL_INSTALL__=!0),typeof __VUE_I18N_LEGACY_API__!="boolean"&&(mt().__VUE_I18N_LEGACY_API__=!0),typeof __INTLIFY_DROP_MESSAGE_COMPILER__!="boolean"&&(mt().__INTLIFY_DROP_MESSAGE_COMPILER__=!1),typeof __INTLIFY_PROD_DEVTOOLS__!="boolean"&&(mt().__INTLIFY_PROD_DEVTOOLS__=!1)}const Ie={UNEXPECTED_RETURN_TYPE:Tp,INVALID_ARGUMENT:25,MUST_BE_CALL_SETUP_TOP:26,NOT_INSTALLED:27,REQUIRED_VALUE:28,INVALID_VALUE:29,CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN:30,NOT_INSTALLED_WITH_PROVIDE:31,UNEXPECTED_ERROR:32,NOT_COMPATIBLE_LEGACY_VUE_I18N:33,NOT_AVAILABLE_COMPOSITION_IN_LEGACY:34};function Me(t,...e){return Cn(t,null,void 0)}const lr=ut("__translateVNode"),cr=ut("__datetimeParts"),ur=ut("__numberParts"),Ja=ut("__setPluralRules"),Qa=ut("__injectWithOption"),dr=ut("__dispose");function Gt(t){if(!le(t))return t;for(const e in t)if(pn(t,e))if(!e.includes("."))le(t[e])&&Gt(t[e]);else{const n=e.split("."),r=n.length-1;let s=t,a=!1;for(let o=0;o{if("locale"in i&&"resource"in i){const{locale:l,resource:c}=i;l?(o[l]=o[l]||{},ln(c,o[l])):ln(c,o)}else H(i)&&ln(JSON.parse(i),o)}),s==null&&a)for(const i in o)pn(o,i)&&Gt(o[i]);return o}function Za(t){return t.type}function eo(t,e,n){let r=le(e.messages)?e.messages:{};"__i18nGlobal"in n&&(r=Ir(t.locale.value,{messages:r,__i18n:n.__i18nGlobal}));const s=Object.keys(r);s.length&&s.forEach(a=>{t.mergeLocaleMessage(a,r[a])});{if(le(e.datetimeFormats)){const a=Object.keys(e.datetimeFormats);a.length&&a.forEach(o=>{t.mergeDateTimeFormat(o,e.datetimeFormats[o])})}if(le(e.numberFormats)){const a=Object.keys(e.numberFormats);a.length&&a.forEach(o=>{t.mergeNumberFormat(o,e.numberFormats[o])})}}}function Ms(t){return x(Eo,null,t,0)}const Ns="__INTLIFY_META__",$s=()=>[],v1=()=>!1;let Ps=0;function Ts(t){return(e,n,r,s)=>t(n,r,Wt()||void 0,s)}const g1=()=>{const t=Wt();let e=null;return t&&(e=Za(t)[Ns])?{[Ns]:e}:null};function Mr(t={}){const{__root:e,__injectWithOption:n}=t,r=e===void 0,s=t.flatJson,a=mn?X:bn;let o=ie(t.inheritLocale)?t.inheritLocale:!0;const i=a(e&&o?e.locale.value:H(t.locale)?t.locale:Kt),l=a(e&&o?e.fallbackLocale.value:H(t.fallbackLocale)||ve(t.fallbackLocale)||ee(t.fallbackLocale)||t.fallbackLocale===!1?t.fallbackLocale:i.value),c=a(Ir(i.value,t)),u=a(ee(t.datetimeFormats)?t.datetimeFormats:{[i.value]:{}}),d=a(ee(t.numberFormats)?t.numberFormats:{[i.value]:{}});let f=e?e.missingWarn:ie(t.missingWarn)||At(t.missingWarn)?t.missingWarn:!0,y=e?e.fallbackWarn:ie(t.fallbackWarn)||At(t.fallbackWarn)?t.fallbackWarn:!0,S=e?e.fallbackRoot:ie(t.fallbackRoot)?t.fallbackRoot:!0,g=!!t.fallbackFormat,b=me(t.missing)?t.missing:null,p=me(t.missing)?Ts(t.missing):null,E=me(t.postTranslation)?t.postTranslation:null,I=e?e.warnHtmlMessage:ie(t.warnHtmlMessage)?t.warnHtmlMessage:!0,L=!!t.escapeParameter;const P=e?e.modifiers:ee(t.modifiers)?t.modifiers:{};let T=t.pluralRules||e&&e.pluralRules,N;N=(()=>{r&&ws(null);const O={version:p1,locale:i.value,fallbackLocale:l.value,messages:c.value,modifiers:P,pluralRules:T,missing:p===null?void 0:p,missingWarn:f,fallbackWarn:y,fallbackFormat:g,unresolving:!0,postTranslation:E===null?void 0:E,warnHtmlMessage:I,escapeParameter:L,messageResolver:t.messageResolver,messageCompiler:t.messageCompiler,__meta:{framework:"vue"}};O.datetimeFormats=u.value,O.numberFormats=d.value,O.__datetimeFormatters=ee(N)?N.__datetimeFormatters:void 0,O.__numberFormatters=ee(N)?N.__numberFormatters:void 0;const F=e1(O);return r&&ws(F),F})(),Ht(N,i.value,l.value);function G(){return[i.value,l.value,c.value,u.value,d.value]}const ce=U({get:()=>i.value,set:O=>{i.value=O,N.locale=i.value}}),ge=U({get:()=>l.value,set:O=>{l.value=O,N.fallbackLocale=l.value,Ht(N,i.value,O)}}),ae=U(()=>c.value),_e=U(()=>u.value),Ne=U(()=>d.value);function Te(){return me(E)?E:null}function tt(O){E=O,N.postTranslation=O}function De(){return b}function nt(O){O!==null&&(p=Ts(O)),b=O,N.missing=p}const Ee=(O,F,fe,ye,ft,Zt)=>{G();let yt;try{__INTLIFY_PROD_DEVTOOLS__,r||(N.fallbackContext=e?Zp():void 0),yt=O(N)}finally{__INTLIFY_PROD_DEVTOOLS__,r||(N.fallbackContext=void 0)}if(fe!=="translate exists"&&we(yt)&&yt===An||fe==="translate exists"&&!yt){const[oo,q1]=F();return e&&S?ye(e):ft(oo)}else{if(Zt(yt))return yt;throw Me(Ie.UNEXPECTED_RETURN_TYPE)}};function rt(...O){return Ee(F=>Reflect.apply(Is,null,[F,...O]),()=>ir(...O),"translate",F=>Reflect.apply(F.t,F,[...O]),F=>F,F=>H(F))}function J(...O){const[F,fe,ye]=O;if(ye&&!le(ye))throw Me(Ie.INVALID_ARGUMENT);return rt(F,fe,ke({resolvedMessage:!0},ye||{}))}function te(...O){return Ee(F=>Reflect.apply(Ls,null,[F,...O]),()=>ar(...O),"datetime format",F=>Reflect.apply(F.d,F,[...O]),()=>bs,F=>H(F))}function V(...O){return Ee(F=>Reflect.apply(Es,null,[F,...O]),()=>or(...O),"number format",F=>Reflect.apply(F.n,F,[...O]),()=>bs,F=>H(F))}function re(O){return O.map(F=>H(F)||we(F)||ie(F)?Ms(String(F)):F)}const oe={normalize:re,interpolate:O=>O,type:"vnode"};function Le(...O){return Ee(F=>{let fe;const ye=F;try{ye.processor=oe,fe=Reflect.apply(Is,null,[ye,...O])}finally{ye.processor=null}return fe},()=>ir(...O),"translate",F=>F[lr](...O),F=>[Ms(F)],F=>ve(F))}function Se(...O){return Ee(F=>Reflect.apply(Es,null,[F,...O]),()=>or(...O),"number format",F=>F[ur](...O),$s,F=>H(F)||ve(F))}function vt(...O){return Ee(F=>Reflect.apply(Ls,null,[F,...O]),()=>ar(...O),"datetime format",F=>F[cr](...O),$s,F=>H(F)||ve(F))}function Fe(O){T=O,N.pluralRules=T}function Mn(O,F){return Ee(()=>{if(!O)return!1;const fe=H(F)?F:i.value,ye=gt(fe),ft=N.messageResolver(ye,O);return Mt(ft)||Pe(ft)||H(ft)},()=>[O],"translate exists",fe=>Reflect.apply(fe.te,fe,[O,F]),v1,fe=>ie(fe))}function Nn(O){let F=null;const fe=Ba(N,l.value,i.value);for(let ye=0;ye{o&&(i.value=O,N.locale=O,Ht(N,i.value,l.value))}),pe(e.fallbackLocale,O=>{o&&(l.value=O,N.fallbackLocale=O,Ht(N,i.value,l.value))}));const ne={id:Ps,locale:ce,fallbackLocale:ge,get inheritLocale(){return o},set inheritLocale(O){o=O,O&&e&&(i.value=e.locale.value,l.value=e.fallbackLocale.value,Ht(N,i.value,l.value))},get availableLocales(){return Object.keys(c.value).sort()},messages:ae,get modifiers(){return P},get pluralRules(){return T||{}},get isGlobal(){return r},get missingWarn(){return f},set missingWarn(O){f=O,N.missingWarn=f},get fallbackWarn(){return y},set fallbackWarn(O){y=O,N.fallbackWarn=y},get fallbackRoot(){return S},set fallbackRoot(O){S=O},get fallbackFormat(){return g},set fallbackFormat(O){g=O,N.fallbackFormat=g},get warnHtmlMessage(){return I},set warnHtmlMessage(O){I=O,N.warnHtmlMessage=O},get escapeParameter(){return L},set escapeParameter(O){L=O,N.escapeParameter=O},t:rt,getLocaleMessage:gt,setLocaleMessage:bt,mergeLocaleMessage:Rt,getPostTranslationHandler:Te,setPostTranslationHandler:tt,getMissingHandler:De,setMissingHandler:nt,[Ja]:Fe};return ne.datetimeFormats=_e,ne.numberFormats=Ne,ne.rt=J,ne.te=Mn,ne.tm=Ft,ne.d=te,ne.n=V,ne.getDateTimeFormat=$n,ne.setDateTimeFormat=h,ne.mergeDateTimeFormat=m,ne.getNumberFormat=$,ne.setNumberFormat=z,ne.mergeNumberFormat=be,ne[Qa]=n,ne[lr]=Le,ne[cr]=vt,ne[ur]=Se,ne}function b1(t){const e=H(t.locale)?t.locale:Kt,n=H(t.fallbackLocale)||ve(t.fallbackLocale)||ee(t.fallbackLocale)||t.fallbackLocale===!1?t.fallbackLocale:e,r=me(t.missing)?t.missing:void 0,s=ie(t.silentTranslationWarn)||At(t.silentTranslationWarn)?!t.silentTranslationWarn:!0,a=ie(t.silentFallbackWarn)||At(t.silentFallbackWarn)?!t.silentFallbackWarn:!0,o=ie(t.fallbackRoot)?t.fallbackRoot:!0,i=!!t.formatFallbackMessages,l=ee(t.modifiers)?t.modifiers:{},c=t.pluralizationRules,u=me(t.postTranslation)?t.postTranslation:void 0,d=H(t.warnHtmlInMessage)?t.warnHtmlInMessage!=="off":!0,f=!!t.escapeParameterHtml,y=ie(t.sync)?t.sync:!0;let S=t.messages;if(ee(t.sharedMessages)){const P=t.sharedMessages;S=Object.keys(P).reduce((N,B)=>{const G=N[B]||(N[B]={});return ke(G,P[B]),N},S||{})}const{__i18n:g,__root:b,__injectWithOption:p}=t,E=t.datetimeFormats,I=t.numberFormats,L=t.flatJson;return{locale:e,fallbackLocale:n,messages:S,flatJson:L,datetimeFormats:E,numberFormats:I,missing:r,missingWarn:s,fallbackWarn:a,fallbackRoot:o,fallbackFormat:i,modifiers:l,pluralRules:c,postTranslation:u,warnHtmlMessage:d,escapeParameter:f,messageResolver:t.messageResolver,inheritLocale:y,__i18n:g,__root:b,__injectWithOption:p}}function fr(t={}){const e=Mr(b1(t)),{__extender:n}=t,r={id:e.id,get locale(){return e.locale.value},set locale(s){e.locale.value=s},get fallbackLocale(){return e.fallbackLocale.value},set fallbackLocale(s){e.fallbackLocale.value=s},get messages(){return e.messages.value},get datetimeFormats(){return e.datetimeFormats.value},get numberFormats(){return e.numberFormats.value},get availableLocales(){return e.availableLocales},get missing(){return e.getMissingHandler()},set missing(s){e.setMissingHandler(s)},get silentTranslationWarn(){return ie(e.missingWarn)?!e.missingWarn:e.missingWarn},set silentTranslationWarn(s){e.missingWarn=ie(s)?!s:s},get silentFallbackWarn(){return ie(e.fallbackWarn)?!e.fallbackWarn:e.fallbackWarn},set silentFallbackWarn(s){e.fallbackWarn=ie(s)?!s:s},get modifiers(){return e.modifiers},get formatFallbackMessages(){return e.fallbackFormat},set formatFallbackMessages(s){e.fallbackFormat=s},get postTranslation(){return e.getPostTranslationHandler()},set postTranslation(s){e.setPostTranslationHandler(s)},get sync(){return e.inheritLocale},set sync(s){e.inheritLocale=s},get warnHtmlInMessage(){return e.warnHtmlMessage?"warn":"off"},set warnHtmlInMessage(s){e.warnHtmlMessage=s!=="off"},get escapeParameterHtml(){return e.escapeParameter},set escapeParameterHtml(s){e.escapeParameter=s},get pluralizationRules(){return e.pluralRules||{}},__composer:e,t(...s){return Reflect.apply(e.t,e,[...s])},rt(...s){return Reflect.apply(e.rt,e,[...s])},tc(...s){const[a,o,i]=s,l={plural:1};let c=null,u=null;if(!H(a))throw Me(Ie.INVALID_ARGUMENT);const d=a;return H(o)?l.locale=o:we(o)?l.plural=o:ve(o)?c=o:ee(o)&&(u=o),H(i)?l.locale=i:ve(i)?c=i:ee(i)&&(u=i),Reflect.apply(e.t,e,[d,c||u||{},l])},te(s,a){return e.te(s,a)},tm(s){return e.tm(s)},getLocaleMessage(s){return e.getLocaleMessage(s)},setLocaleMessage(s,a){e.setLocaleMessage(s,a)},mergeLocaleMessage(s,a){e.mergeLocaleMessage(s,a)},d(...s){return Reflect.apply(e.d,e,[...s])},getDateTimeFormat(s){return e.getDateTimeFormat(s)},setDateTimeFormat(s,a){e.setDateTimeFormat(s,a)},mergeDateTimeFormat(s,a){e.mergeDateTimeFormat(s,a)},n(...s){return Reflect.apply(e.n,e,[...s])},getNumberFormat(s){return e.getNumberFormat(s)},setNumberFormat(s,a){e.setNumberFormat(s,a)},mergeNumberFormat(s,a){e.mergeNumberFormat(s,a)}};return r.__extender=n,r}function y1(t,e,n){return{beforeCreate(){const r=Wt();if(!r)throw Me(Ie.UNEXPECTED_ERROR);const s=this.$options;if(s.i18n){const a=s.i18n;if(s.__i18n&&(a.__i18n=s.__i18n),a.__root=e,this===this.$root)this.$i18n=Fs(t,a);else{a.__injectWithOption=!0,a.__extender=n.__vueI18nExtend,this.$i18n=fr(a);const o=this.$i18n;o.__extender&&(o.__disposer=o.__extender(this.$i18n))}}else if(s.__i18n)if(this===this.$root)this.$i18n=Fs(t,s);else{this.$i18n=fr({__i18n:s.__i18n,__injectWithOption:!0,__extender:n.__vueI18nExtend,__root:e});const a=this.$i18n;a.__extender&&(a.__disposer=a.__extender(this.$i18n))}else this.$i18n=t;s.__i18nGlobal&&eo(e,s,s),this.$t=(...a)=>this.$i18n.t(...a),this.$rt=(...a)=>this.$i18n.rt(...a),this.$tc=(...a)=>this.$i18n.tc(...a),this.$te=(a,o)=>this.$i18n.te(a,o),this.$d=(...a)=>this.$i18n.d(...a),this.$n=(...a)=>this.$i18n.n(...a),this.$tm=a=>this.$i18n.tm(a),n.__setInstance(r,this.$i18n)},mounted(){},unmounted(){const r=Wt();if(!r)throw Me(Ie.UNEXPECTED_ERROR);const s=this.$i18n;delete this.$t,delete this.$rt,delete this.$tc,delete this.$te,delete this.$d,delete this.$n,delete this.$tm,s.__disposer&&(s.__disposer(),delete s.__disposer,delete s.__extender),n.__deleteInstance(r),delete this.$i18n}}}function Fs(t,e){t.locale=e.locale||t.locale,t.fallbackLocale=e.fallbackLocale||t.fallbackLocale,t.missing=e.missing||t.missing,t.silentTranslationWarn=e.silentTranslationWarn||t.silentFallbackWarn,t.silentFallbackWarn=e.silentFallbackWarn||t.silentFallbackWarn,t.formatFallbackMessages=e.formatFallbackMessages||t.formatFallbackMessages,t.postTranslation=e.postTranslation||t.postTranslation,t.warnHtmlInMessage=e.warnHtmlInMessage||t.warnHtmlInMessage,t.escapeParameterHtml=e.escapeParameterHtml||t.escapeParameterHtml,t.sync=e.sync||t.sync,t.__composer[Ja](e.pluralizationRules||t.pluralizationRules);const n=Ir(t.locale,{messages:e.messages,__i18n:e.__i18n});return Object.keys(n).forEach(r=>t.mergeLocaleMessage(r,n[r])),e.datetimeFormats&&Object.keys(e.datetimeFormats).forEach(r=>t.mergeDateTimeFormat(r,e.datetimeFormats[r])),e.numberFormats&&Object.keys(e.numberFormats).forEach(r=>t.mergeNumberFormat(r,e.numberFormats[r])),t}const Nr={tag:{type:[String,Object]},locale:{type:String},scope:{type:String,validator:t=>t==="parent"||t==="global",default:"parent"},i18n:{type:Object}};function w1({slots:t},e){return e.length===1&&e[0]==="default"?(t.default?t.default():[]).reduce((r,s)=>[...r,...s.type===he?s.children:[s]],[]):e.reduce((n,r)=>{const s=t[r];return s&&(n[r]=s()),n},{})}function to(){return he}const k1=R({name:"i18n-t",props:ke({keypath:{type:String,required:!0},plural:{type:[Number,String],validator:t=>we(t)||!isNaN(t)}},Nr),setup(t,e){const{slots:n,attrs:r}=e,s=t.i18n||In({useScope:t.scope,__useComponent:!0});return()=>{const a=Object.keys(n).filter(d=>d!=="_"),o={};t.locale&&(o.locale=t.locale),t.plural!==void 0&&(o.plural=H(t.plural)?+t.plural:t.plural);const i=w1(e,a),l=s[lr](t.keypath,i,o),c=ke({},r),u=H(t.tag)||le(t.tag)?t.tag:to();return Ct(u,c,l)}}}),Rs=k1;function L1(t){return ve(t)&&!H(t[0])}function no(t,e,n,r){const{slots:s,attrs:a}=e;return()=>{const o={part:!0};let i={};t.locale&&(o.locale=t.locale),H(t.format)?o.key=t.format:le(t.format)&&(H(t.format.key)&&(o.key=t.format.key),i=Object.keys(t.format).reduce((f,y)=>n.includes(y)?ke({},f,{[y]:t.format[y]}):f,{}));const l=r(t.value,o,i);let c=[o.key];ve(l)?c=l.map((f,y)=>{const S=s[f.type],g=S?S({[f.type]:f.value,index:y,parts:l}):[f.value];return L1(g)&&(g[0].key=`${f.type}-${y}`),g}):H(l)&&(c=[l]);const u=ke({},a),d=H(t.tag)||le(t.tag)?t.tag:to();return Ct(d,u,c)}}const S1=R({name:"i18n-n",props:ke({value:{type:Number,required:!0},format:{type:[String,Object]}},Nr),setup(t,e){const n=t.i18n||In({useScope:t.scope,__useComponent:!0});return no(t,e,za,(...r)=>n[ur](...r))}}),Vs=S1,E1=R({name:"i18n-d",props:ke({value:{type:[Number,Date],required:!0},format:{type:[String,Object]}},Nr),setup(t,e){const n=t.i18n||In({useScope:t.scope,__useComponent:!0});return no(t,e,Ya,(...r)=>n[cr](...r))}}),Ds=E1;function O1(t,e){const n=t;if(t.mode==="composition")return n.__getInstance(e)||t.global;{const r=n.__getInstance(e);return r!=null?r.__composer:t.global.__composer}}function C1(t){const e=o=>{const{instance:i,value:l}=o;if(!i||!i.$)throw Me(Ie.UNEXPECTED_ERROR);const c=O1(t,i.$),u=Hs(l);return[Reflect.apply(c.t,c,[...Us(u)]),c]};return{created:(o,i)=>{const[l,c]=e(i);mn&&t.global===c&&(o.__i18nWatcher=pe(c.locale,()=>{i.instance&&i.instance.$forceUpdate()})),o.__composer=c,o.textContent=l},unmounted:o=>{mn&&o.__i18nWatcher&&(o.__i18nWatcher(),o.__i18nWatcher=void 0,delete o.__i18nWatcher),o.__composer&&(o.__composer=void 0,delete o.__composer)},beforeUpdate:(o,{value:i})=>{if(o.__composer){const l=o.__composer,c=Hs(i);o.textContent=Reflect.apply(l.t,l,[...Us(c)])}},getSSRProps:o=>{const[i]=e(o);return{textContent:i}}}}function Hs(t){if(H(t))return{path:t};if(ee(t)){if(!("path"in t))throw Me(Ie.REQUIRED_VALUE,"path");return t}else throw Me(Ie.INVALID_VALUE)}function Us(t){const{path:e,locale:n,args:r,choice:s,plural:a}=t,o={},i=r||{};return H(n)&&(o.locale=n),we(s)&&(o.plural=s),we(a)&&(o.plural=a),[e,i,o]}function A1(t,e,...n){const r=ee(n[0])?n[0]:{};(ie(r.globalInstall)?r.globalInstall:!0)&&([Rs.name,"I18nT"].forEach(a=>t.component(a,Rs)),[Vs.name,"I18nN"].forEach(a=>t.component(a,Vs)),[Ds.name,"I18nD"].forEach(a=>t.component(a,Ds))),t.directive("t",C1(e))}const I1=ut("global-vue-i18n");function M1(t={},e){const n=__VUE_I18N_LEGACY_API__&&ie(t.legacy)?t.legacy:__VUE_I18N_LEGACY_API__,r=ie(t.globalInjection)?t.globalInjection:!0,s=new Map,[a,o]=N1(t,n),i=ut("");function l(f){return s.get(f)||null}function c(f,y){s.set(f,y)}function u(f){s.delete(f)}const d={get mode(){return __VUE_I18N_LEGACY_API__&&n?"legacy":"composition"},async install(f,...y){if(f.__VUE_I18N_SYMBOL__=i,f.provide(f.__VUE_I18N_SYMBOL__,d),ee(y[0])){const b=y[0];d.__composerExtend=b.__composerExtend,d.__vueI18nExtend=b.__vueI18nExtend}let S=null;!n&&r&&(S=H1(f,d.global)),__VUE_I18N_FULL_INSTALL__&&A1(f,d,...y),__VUE_I18N_LEGACY_API__&&n&&f.mixin(y1(o,o.__composer,d));const g=f.unmount;f.unmount=()=>{S&&S(),d.dispose(),g()}},get global(){return o},dispose(){a.stop()},__instances:s,__getInstance:l,__setInstance:c,__deleteInstance:u};return d}function In(t={}){const e=Wt();if(e==null)throw Me(Ie.MUST_BE_CALL_SETUP_TOP);if(!e.isCE&&e.appContext.app!=null&&!e.appContext.app.__VUE_I18N_SYMBOL__)throw Me(Ie.NOT_INSTALLED);const n=$1(e),r=T1(n),s=Za(e),a=P1(t,s);if(a==="global")return eo(r,t,s),r;if(a==="parent"){let l=F1(n,e,t.__useComponent);return l==null&&(l=r),l}const o=n;let i=o.__getInstance(e);if(i==null){const l=ke({},t);"__i18n"in s&&(l.__i18n=s.__i18n),r&&(l.__root=r),i=Mr(l),o.__composerExtend&&(i[dr]=o.__composerExtend(i)),V1(o,e,i),o.__setInstance(e,i)}return i}function N1(t,e,n){const r=Lo(),s=__VUE_I18N_LEGACY_API__&&e?r.run(()=>fr(t)):r.run(()=>Mr(t));if(s==null)throw Me(Ie.UNEXPECTED_ERROR);return[r,s]}function $1(t){const e=Nt(t.isCE?I1:t.appContext.app.__VUE_I18N_SYMBOL__);if(!e)throw Me(t.isCE?Ie.NOT_INSTALLED_WITH_PROVIDE:Ie.UNEXPECTED_ERROR);return e}function P1(t,e){return On(t)?"__i18n"in e?"local":"global":t.useScope?t.useScope:"local"}function T1(t){return t.mode==="composition"?t.global:t.global.__composer}function F1(t,e,n=!1){let r=null;const s=e.root;let a=R1(e,n);for(;a!=null;){const o=t;if(t.mode==="composition")r=o.__getInstance(a);else if(__VUE_I18N_LEGACY_API__){const i=o.__getInstance(a);i!=null&&(r=i.__composer,n&&r&&!r[Qa]&&(r=null))}if(r!=null||s===a)break;a=a.parent}return r}function R1(t,e=!1){return t==null?null:e&&t.vnode.ctx||t.parent}function V1(t,e,n){Ye(()=>{},e),gn(()=>{const r=n;t.__deleteInstance(e);const s=r[dr];s&&(s(),delete r[dr])},e)}const D1=["locale","fallbackLocale","availableLocales"],Bs=["t","rt","d","n","tm","te"];function H1(t,e){const n=Object.create(null);return D1.forEach(s=>{const a=Object.getOwnPropertyDescriptor(e,s);if(!a)throw Me(Ie.UNEXPECTED_ERROR);const o=So(a.value)?{get(){return a.value.value},set(i){a.value.value=i}}:{get(){return a.get&&a.get()}};Object.defineProperty(n,s,o)}),t.config.globalProperties.$i18n=n,Bs.forEach(s=>{const a=Object.getOwnPropertyDescriptor(e,s);if(!a||!a.value)throw Me(Ie.UNEXPECTED_ERROR);Object.defineProperty(t.config.globalProperties,`$${s}`,a)}),()=>{delete t.config.globalProperties.$i18n,Bs.forEach(s=>{delete t.config.globalProperties[`$${s}`]})}}_1();zp(Ip);Xp(Kp);qp(Ba);if(__INTLIFY_PROD_DEVTOOLS__){const t=mt();t.__INTLIFY__=!0,Mp(t.__INTLIFY_DEVTOOLS_GLOBAL_HOOK__)}const ro=()=>{const t=Nt("$env"),{t:e,locale:n}=In();return{locale:n,$env:t,t:e}},U1={class:"text-slate-600 text-base mt-2"},B1={class:"flex flex-row justify-start items-start mt-4"},W1={class:"relative h-14"},j1=["label","status"],x1={key:0,class:"absolute bottom-0 left-0 text-sm text-[#ff4d4f]"},K1={class:"text-[#3451b2] text-base"},G1=R({__name:"TOTP",setup(t){const{t:e,$env:n,locale:r}=ro(),s=X(""),a=X(Lt.NORMAL),o=X(""),i=X({code:"",expires:""}),l=u=>{s.value=u.detail.value,a.value=Lt.NORMAL},c=()=>{if(s.value.length<=0)o.value=e("components_totp_3"),a.value=Lt.ERROR;else try{const{otp:u,expires:d}=Tm.generate(s.value);i.value.code=u,i.value.expires=Vm(d).format()}catch{o.value=e("components_totp_5"),a.value=Lt.ERROR}};return(u,d)=>(_(),A("div",null,[w("div",U1,Z(v(e)("components_totp_6")),1),w("div",B1,[w("div",W1,[w("r-input",{label:v(e)("components_totp_2"),class:"w-64 h-8 rounded-lg block text-lg",status:a.value,onInput:l},null,40,j1),a.value===v(Lt).ERROR?(_(),A("div",x1,Z(o.value),1)):j("",!0)]),w("r-button",{class:"ml-1 h-8",onClick:c},Z(v(e)("components_totp_1")),1)]),w("div",K1,[w("div",null,"code: "+Z(i.value.code),1),w("div",null,Z(v(e)("components_totp_4"))+": "+Z(i.value.expires),1)])]))}}),so=nr.locale,Ot=M1({legacy:!1,locale:so,fallbackLocale:Qt.EN,messages:jm,devtools:!1}),Un=t=>(Ot.mode===Ha.LEGACY?Ot.global.locale=t:Ot.global.locale.value=t,t),Y1=(t,e=so)=>{Ot.global.mergeLocaleMessage(e,t)},ao=t=>t?Ot.global.locale===t||ls.includes(t)?Promise.resolve(Un(t)):Oo(Object.assign({"./en.json":()=>cn(()=>import("./en.Bkn4-Vvy.js"),[]),"./zh-CN.json":()=>cn(()=>import("./zh-CN.PUkQxDBJ.js"),[])}),`./${t}.json`,2).then(e=>(Y1(e.default,t),ls.push(t),Un(t))):Promise.reject("lang is undefined"),z1=R({__name:"Layout",setup(t){const{$env:e,locale:n}=ro(),{lang:r}=hr(),s=()=>{const a=r.value||Qt.EN;n.value=a,e.locale=a,ao(a).catch(o=>{console.log("error",o)}),Fm(Da,a)};return it(()=>{s()}),Ye(()=>{Um()}),(a,o)=>(_(),K(v(ka).Layout))}}),X1=()=>{cn(()=>import("./pwa-install.es.DuMXkPrI.js"),[]).then(()=>{let t=document.getElementById(cs);t||(t=document.createElement(xm),t.setAttribute("manifest-url",Km),t.setAttribute("id",cs),document.body.appendChild(t))})},r_={extends:ka,enhanceApp({app:t,router:e,siteData:n}){cn(()=>import("./index.CafPLwUV.js").then(s=>s.i),__vite__mapDeps([0,1])),X1(),t.use(Ym);const r=Rm(Da)||Qt.EN;ao(r).then(()=>{Hm("__VUE_PROD_DEVTOOLS__",!1),t.use(Ot),t.component("Layout",z1),t.component("TOTP",G1)}).catch(s=>{console.log("error",s)})}};export{r_ as R}; diff --git a/assets/cn_index.md.2fj_5uQF.js b/assets/cn_index.md.0kzgXyFr.js similarity index 87% rename from assets/cn_index.md.2fj_5uQF.js rename to assets/cn_index.md.0kzgXyFr.js index 547eb90113..2e4b94d3d1 100644 --- a/assets/cn_index.md.2fj_5uQF.js +++ b/assets/cn_index.md.0kzgXyFr.js @@ -1 +1 @@ -import{_ as t,o as e,c as a}from"./chunks/framework.eq-HTtE3.js";const m=JSON.parse('{"title":"Home","description":"","frontmatter":{"layout":"home","title":"Home","hero":{"name":"ran","text":"风起于青萍之末","tagline":"A ship in harbor is safe, but that is not what ships are built for.","image":{"src":"/home.svg","alt":"logo"},"actions":[{"theme":"alt","text":"更多详情","link":"https://github.com/chaxus/ran"},{"theme":"alt","text":"访问我的 GitHub","link":"https://github.com/chaxus/ran"}]},"features":[{"icon":"⚡️","title":"记录","details":"每段旅程都有终点"},{"icon":"🛠️","title":"解决","details":"无法衡量,无法改进"},{"icon":"🖖","title":"分享","details":"一个人可以走得很快,一群人可以走的很远"}]},"headers":[],"relativePath":"cn/index.md","filePath":"cn/index.md","lastUpdated":1728205581000}'),i={name:"cn/index.md"};function n(o,s,r,c,l,h){return e(),a("div")}const p=t(i,[["render",n]]);export{m as __pageData,p as default}; +import{_ as t,o as e,c as a}from"./chunks/framework.CHSXtLMd.js";const m=JSON.parse('{"title":"Home","description":"","frontmatter":{"layout":"home","title":"Home","hero":{"name":"ran","text":"风起于青萍之末","tagline":"A ship in harbor is safe, but that is not what ships are built for.","image":{"src":"/home.svg","alt":"logo"},"actions":[{"theme":"alt","text":"更多详情","link":"https://github.com/chaxus/ran"},{"theme":"alt","text":"访问我的 GitHub","link":"https://github.com/chaxus/ran"}]},"features":[{"icon":"⚡️","title":"记录","details":"每段旅程都有终点"},{"icon":"🛠️","title":"解决","details":"无法衡量,无法改进"},{"icon":"🖖","title":"分享","details":"一个人可以走得很快,一群人可以走的很远"}]},"headers":[],"relativePath":"cn/index.md","filePath":"cn/index.md","lastUpdated":1728702757000}'),i={name:"cn/index.md"};function n(o,s,r,c,l,h){return e(),a("div")}const p=t(i,[["render",n]]);export{m as __pageData,p as default}; diff --git a/assets/cn_index.md.2fj_5uQF.lean.js b/assets/cn_index.md.0kzgXyFr.lean.js similarity index 87% rename from assets/cn_index.md.2fj_5uQF.lean.js rename to assets/cn_index.md.0kzgXyFr.lean.js index 547eb90113..2e4b94d3d1 100644 --- a/assets/cn_index.md.2fj_5uQF.lean.js +++ b/assets/cn_index.md.0kzgXyFr.lean.js @@ -1 +1 @@ -import{_ as t,o as e,c as a}from"./chunks/framework.eq-HTtE3.js";const m=JSON.parse('{"title":"Home","description":"","frontmatter":{"layout":"home","title":"Home","hero":{"name":"ran","text":"风起于青萍之末","tagline":"A ship in harbor is safe, but that is not what ships are built for.","image":{"src":"/home.svg","alt":"logo"},"actions":[{"theme":"alt","text":"更多详情","link":"https://github.com/chaxus/ran"},{"theme":"alt","text":"访问我的 GitHub","link":"https://github.com/chaxus/ran"}]},"features":[{"icon":"⚡️","title":"记录","details":"每段旅程都有终点"},{"icon":"🛠️","title":"解决","details":"无法衡量,无法改进"},{"icon":"🖖","title":"分享","details":"一个人可以走得很快,一群人可以走的很远"}]},"headers":[],"relativePath":"cn/index.md","filePath":"cn/index.md","lastUpdated":1728205581000}'),i={name:"cn/index.md"};function n(o,s,r,c,l,h){return e(),a("div")}const p=t(i,[["render",n]]);export{m as __pageData,p as default}; +import{_ as t,o as e,c as a}from"./chunks/framework.CHSXtLMd.js";const m=JSON.parse('{"title":"Home","description":"","frontmatter":{"layout":"home","title":"Home","hero":{"name":"ran","text":"风起于青萍之末","tagline":"A ship in harbor is safe, but that is not what ships are built for.","image":{"src":"/home.svg","alt":"logo"},"actions":[{"theme":"alt","text":"更多详情","link":"https://github.com/chaxus/ran"},{"theme":"alt","text":"访问我的 GitHub","link":"https://github.com/chaxus/ran"}]},"features":[{"icon":"⚡️","title":"记录","details":"每段旅程都有终点"},{"icon":"🛠️","title":"解决","details":"无法衡量,无法改进"},{"icon":"🖖","title":"分享","details":"一个人可以走得很快,一群人可以走的很远"}]},"headers":[],"relativePath":"cn/index.md","filePath":"cn/index.md","lastUpdated":1728702757000}'),i={name:"cn/index.md"};function n(o,s,r,c,l,h){return e(),a("div")}const p=t(i,[["render",n]]);export{m as __pageData,p as default}; diff --git a/assets/cn_src_article_astParse_tokenizer.md.C-WQQige.js b/assets/cn_src_article_astParse_tokenizer.md.Be5lTQKA.js similarity index 99% rename from assets/cn_src_article_astParse_tokenizer.md.C-WQQige.js rename to assets/cn_src_article_astParse_tokenizer.md.Be5lTQKA.js index fb107b5c6f..8a21d8a788 100644 --- a/assets/cn_src_article_astParse_tokenizer.md.C-WQQige.js +++ b/assets/cn_src_article_astParse_tokenizer.md.Be5lTQKA.js @@ -1,4 +1,4 @@ -import{_ as a,a as n,b as h,c as p,d as k,e as t,f as l,g as e,h as d,i as E,j as r,k as g,l as c,m as i,n as y}from"./chunks/extra.Cu56q3CZ.js";import{_ as o,o as F,c as C,a3 as A}from"./chunks/framework.eq-HTtE3.js";const S=JSON.parse('{"title":"Abstract Syntax Tree","description":"","frontmatter":{},"headers":[],"relativePath":"cn/src/article/astParse/tokenizer.md","filePath":"cn/src/article/astParse/tokenizer.md","lastUpdated":1728205581000}'),u={name:"cn/src/article/astParse/tokenizer.md"};function D(B,s,m,b,v,T){return F(),C("div",{"data-pagefind-body":!0},s[0]||(s[0]=[A('

Abstract Syntax Tree

一.(abstract syntax tree)抽象语法树的作用

源码是一串按照语法格式来组织的字符串,人能够认识,但是计算机并不认识,想让计算机认识就要转成一种数据结构,通过不同的对象来保存不同的数据,并且按照依赖关系组织起来,这种数据结构就是抽象语法树(abstract syntax tree)。

之所以叫“抽象”语法树是因为数据结构中省略掉了一些无具体意义的分隔符比如 ; { } 等。

有了 AST,计算机就能理解源码字符串的意思,而理解是能够转换的前提,所以编译的第一步需要把源码 parseAST

转成 AST 之后就可以通过修改 AST ,分析 AST 的方式来修改和分析代码,比如 babel 就通过这种方式进行代码的转换,比如 rollupTree Shaking ,就是通过分析 AST的 导入导出语法,从而分析出没有使用的代码,进行去除。

二。常见的 AST 节点

常见的 AST 节点 AST 是对源码的抽象,字面量、标识符、表达式、语句、模块语法、class 语法都有各自的 AST。

我们分别来了解一下:

Literal

Literal 是字面量的意思,比如 let name = 'value'中,'value'就是一个字符串字面量 StringLiteral,相应的还有数字字面量 NumericLiteral,布尔字面量 BooleanLiteral,字符串字面量 StringLiteral,正则表达式字面量 RegExpLiteral 等。

下面这些字面量都有对应的 Literal 节点:

代码中的字面量很多,babel 就是通过 xxLiteral 来抽象这部分内容的。

Identifier

Identifer 是标识符的意思,变量名、属性名、参数名等各种声明和引用的名字,都是Identifer

我们知道, JS 中的标识符只能包含字母或数字或下划线 (“_”) 或美元符号 (“$”) ,且不能以数字开头。这是 Identifier 的词法特点。

尝试分析一下,下面这一段代码里面有多少 Identifier 呢?

js
const name = 'value';
+import{_ as a,a as n,b as h,c as p,d as k,e as t,f as l,g as e,h as d,i as E,j as r,k as g,l as c,m as i,n as y}from"./chunks/extra.Cu56q3CZ.js";import{_ as o,o as F,c as C,a3 as A}from"./chunks/framework.CHSXtLMd.js";const S=JSON.parse('{"title":"Abstract Syntax Tree","description":"","frontmatter":{},"headers":[],"relativePath":"cn/src/article/astParse/tokenizer.md","filePath":"cn/src/article/astParse/tokenizer.md","lastUpdated":1728702757000}'),u={name:"cn/src/article/astParse/tokenizer.md"};function D(B,s,m,b,v,T){return F(),C("div",{"data-pagefind-body":!0},s[0]||(s[0]=[A('

Abstract Syntax Tree

一.(abstract syntax tree)抽象语法树的作用

源码是一串按照语法格式来组织的字符串,人能够认识,但是计算机并不认识,想让计算机认识就要转成一种数据结构,通过不同的对象来保存不同的数据,并且按照依赖关系组织起来,这种数据结构就是抽象语法树(abstract syntax tree)。

之所以叫“抽象”语法树是因为数据结构中省略掉了一些无具体意义的分隔符比如 ; { } 等。

有了 AST,计算机就能理解源码字符串的意思,而理解是能够转换的前提,所以编译的第一步需要把源码 parseAST

转成 AST 之后就可以通过修改 AST ,分析 AST 的方式来修改和分析代码,比如 babel 就通过这种方式进行代码的转换,比如 rollupTree Shaking ,就是通过分析 AST的 导入导出语法,从而分析出没有使用的代码,进行去除。

二。常见的 AST 节点

常见的 AST 节点 AST 是对源码的抽象,字面量、标识符、表达式、语句、模块语法、class 语法都有各自的 AST。

我们分别来了解一下:

Literal

Literal 是字面量的意思,比如 let name = 'value'中,'value'就是一个字符串字面量 StringLiteral,相应的还有数字字面量 NumericLiteral,布尔字面量 BooleanLiteral,字符串字面量 StringLiteral,正则表达式字面量 RegExpLiteral 等。

下面这些字面量都有对应的 Literal 节点:

代码中的字面量很多,babel 就是通过 xxLiteral 来抽象这部分内容的。

Identifier

Identifer 是标识符的意思,变量名、属性名、参数名等各种声明和引用的名字,都是Identifer

我们知道, JS 中的标识符只能包含字母或数字或下划线 (“_”) 或美元符号 (“$”) ,且不能以数字开头。这是 Identifier 的词法特点。

尝试分析一下,下面这一段代码里面有多少 Identifier 呢?

js
const name = 'value';
 
 function say(name) {
   console.log(name);
diff --git a/assets/cn_src_article_astParse_tokenizer.md.C-WQQige.lean.js b/assets/cn_src_article_astParse_tokenizer.md.Be5lTQKA.lean.js
similarity index 99%
rename from assets/cn_src_article_astParse_tokenizer.md.C-WQQige.lean.js
rename to assets/cn_src_article_astParse_tokenizer.md.Be5lTQKA.lean.js
index fb107b5c6f..8a21d8a788 100644
--- a/assets/cn_src_article_astParse_tokenizer.md.C-WQQige.lean.js
+++ b/assets/cn_src_article_astParse_tokenizer.md.Be5lTQKA.lean.js
@@ -1,4 +1,4 @@
-import{_ as a,a as n,b as h,c as p,d as k,e as t,f as l,g as e,h as d,i as E,j as r,k as g,l as c,m as i,n as y}from"./chunks/extra.Cu56q3CZ.js";import{_ as o,o as F,c as C,a3 as A}from"./chunks/framework.eq-HTtE3.js";const S=JSON.parse('{"title":"Abstract Syntax Tree","description":"","frontmatter":{},"headers":[],"relativePath":"cn/src/article/astParse/tokenizer.md","filePath":"cn/src/article/astParse/tokenizer.md","lastUpdated":1728205581000}'),u={name:"cn/src/article/astParse/tokenizer.md"};function D(B,s,m,b,v,T){return F(),C("div",{"data-pagefind-body":!0},s[0]||(s[0]=[A('

Abstract Syntax Tree

一.(abstract syntax tree)抽象语法树的作用

源码是一串按照语法格式来组织的字符串,人能够认识,但是计算机并不认识,想让计算机认识就要转成一种数据结构,通过不同的对象来保存不同的数据,并且按照依赖关系组织起来,这种数据结构就是抽象语法树(abstract syntax tree)。

之所以叫“抽象”语法树是因为数据结构中省略掉了一些无具体意义的分隔符比如 ; { } 等。

有了 AST,计算机就能理解源码字符串的意思,而理解是能够转换的前提,所以编译的第一步需要把源码 parseAST

转成 AST 之后就可以通过修改 AST ,分析 AST 的方式来修改和分析代码,比如 babel 就通过这种方式进行代码的转换,比如 rollupTree Shaking ,就是通过分析 AST的 导入导出语法,从而分析出没有使用的代码,进行去除。

二。常见的 AST 节点

常见的 AST 节点 AST 是对源码的抽象,字面量、标识符、表达式、语句、模块语法、class 语法都有各自的 AST。

我们分别来了解一下:

Literal

Literal 是字面量的意思,比如 let name = 'value'中,'value'就是一个字符串字面量 StringLiteral,相应的还有数字字面量 NumericLiteral,布尔字面量 BooleanLiteral,字符串字面量 StringLiteral,正则表达式字面量 RegExpLiteral 等。

下面这些字面量都有对应的 Literal 节点:

代码中的字面量很多,babel 就是通过 xxLiteral 来抽象这部分内容的。

Identifier

Identifer 是标识符的意思,变量名、属性名、参数名等各种声明和引用的名字,都是Identifer

我们知道, JS 中的标识符只能包含字母或数字或下划线 (“_”) 或美元符号 (“$”) ,且不能以数字开头。这是 Identifier 的词法特点。

尝试分析一下,下面这一段代码里面有多少 Identifier 呢?

js
const name = 'value';
+import{_ as a,a as n,b as h,c as p,d as k,e as t,f as l,g as e,h as d,i as E,j as r,k as g,l as c,m as i,n as y}from"./chunks/extra.Cu56q3CZ.js";import{_ as o,o as F,c as C,a3 as A}from"./chunks/framework.CHSXtLMd.js";const S=JSON.parse('{"title":"Abstract Syntax Tree","description":"","frontmatter":{},"headers":[],"relativePath":"cn/src/article/astParse/tokenizer.md","filePath":"cn/src/article/astParse/tokenizer.md","lastUpdated":1728702757000}'),u={name:"cn/src/article/astParse/tokenizer.md"};function D(B,s,m,b,v,T){return F(),C("div",{"data-pagefind-body":!0},s[0]||(s[0]=[A('

Abstract Syntax Tree

一.(abstract syntax tree)抽象语法树的作用

源码是一串按照语法格式来组织的字符串,人能够认识,但是计算机并不认识,想让计算机认识就要转成一种数据结构,通过不同的对象来保存不同的数据,并且按照依赖关系组织起来,这种数据结构就是抽象语法树(abstract syntax tree)。

之所以叫“抽象”语法树是因为数据结构中省略掉了一些无具体意义的分隔符比如 ; { } 等。

有了 AST,计算机就能理解源码字符串的意思,而理解是能够转换的前提,所以编译的第一步需要把源码 parseAST

转成 AST 之后就可以通过修改 AST ,分析 AST 的方式来修改和分析代码,比如 babel 就通过这种方式进行代码的转换,比如 rollupTree Shaking ,就是通过分析 AST的 导入导出语法,从而分析出没有使用的代码,进行去除。

二。常见的 AST 节点

常见的 AST 节点 AST 是对源码的抽象,字面量、标识符、表达式、语句、模块语法、class 语法都有各自的 AST。

我们分别来了解一下:

Literal

Literal 是字面量的意思,比如 let name = 'value'中,'value'就是一个字符串字面量 StringLiteral,相应的还有数字字面量 NumericLiteral,布尔字面量 BooleanLiteral,字符串字面量 StringLiteral,正则表达式字面量 RegExpLiteral 等。

下面这些字面量都有对应的 Literal 节点:

代码中的字面量很多,babel 就是通过 xxLiteral 来抽象这部分内容的。

Identifier

Identifer 是标识符的意思,变量名、属性名、参数名等各种声明和引用的名字,都是Identifer

我们知道, JS 中的标识符只能包含字母或数字或下划线 (“_”) 或美元符号 (“$”) ,且不能以数字开头。这是 Identifier 的词法特点。

尝试分析一下,下面这一段代码里面有多少 Identifier 呢?

js
const name = 'value';
 
 function say(name) {
   console.log(name);
diff --git a/assets/cn_src_article_babel.md.xL16z9Xt.js b/assets/cn_src_article_babel.md.rAspsh5G.js
similarity index 82%
rename from assets/cn_src_article_babel.md.xL16z9Xt.js
rename to assets/cn_src_article_babel.md.rAspsh5G.js
index 8a52b1108d..415fe7670e 100644
--- a/assets/cn_src_article_babel.md.xL16z9Xt.js
+++ b/assets/cn_src_article_babel.md.rAspsh5G.js
@@ -1 +1 @@
-import{_ as a,o as t,c as l,a3 as r}from"./chunks/framework.eq-HTtE3.js";const m=JSON.parse('{"title":"Babel","description":"","frontmatter":{},"headers":[],"relativePath":"cn/src/article/babel.md","filePath":"cn/src/article/babel.md","lastUpdated":1728205581000}'),i={name:"cn/src/article/babel.md"};function s(b,e,o,c,p,n){return t(),l("div",{"data-pagefind-body":!0},e[0]||(e[0]=[r('

Babel

babel 核心库主要是:

  • @babel/parser 对源码进行 parse,可以通过 plugins、sourceType 等来指定 parse 语法,功能是把源码转成 AST。
  • @babel/traverse 通过 visitor 函数对遍历到的 ast 进行处理,分为 enter 和 exit 两个阶段,具体操作 AST 使用 path 的 api,还可以通过 state 来在遍历过程中传递一些数据
  • @babel/types 用于创建、判断 AST 节点,提供了 xxx、isXxx、assertXxx 的 api
  • @babel/template 当需要批量创建 AST 的时候可以使用 @babel/template 来简化 AST 创建逻辑。
  • @babel/code-frame 可以创建友好的报错信息
  • @babel/generator 打印 AST 成目标代码字符串,支持 comments、minified、sourceMaps 等选项。
  • @babel/core 基于上面的包来完成 babel 的编译流程,并应用 plugin 和 preset。
',3)]))}const u=a(i,[["render",s]]);export{m as __pageData,u as default}; +import{_ as a,o as t,c as l,a3 as r}from"./chunks/framework.CHSXtLMd.js";const m=JSON.parse('{"title":"Babel","description":"","frontmatter":{},"headers":[],"relativePath":"cn/src/article/babel.md","filePath":"cn/src/article/babel.md","lastUpdated":1728702757000}'),i={name:"cn/src/article/babel.md"};function s(b,e,o,c,p,n){return t(),l("div",{"data-pagefind-body":!0},e[0]||(e[0]=[r('

Babel

babel 核心库主要是:

  • @babel/parser 对源码进行 parse,可以通过 plugins、sourceType 等来指定 parse 语法,功能是把源码转成 AST。
  • @babel/traverse 通过 visitor 函数对遍历到的 ast 进行处理,分为 enter 和 exit 两个阶段,具体操作 AST 使用 path 的 api,还可以通过 state 来在遍历过程中传递一些数据
  • @babel/types 用于创建、判断 AST 节点,提供了 xxx、isXxx、assertXxx 的 api
  • @babel/template 当需要批量创建 AST 的时候可以使用 @babel/template 来简化 AST 创建逻辑。
  • @babel/code-frame 可以创建友好的报错信息
  • @babel/generator 打印 AST 成目标代码字符串,支持 comments、minified、sourceMaps 等选项。
  • @babel/core 基于上面的包来完成 babel 的编译流程,并应用 plugin 和 preset。
',3)]))}const u=a(i,[["render",s]]);export{m as __pageData,u as default}; diff --git a/assets/cn_src_article_babel.md.xL16z9Xt.lean.js b/assets/cn_src_article_babel.md.rAspsh5G.lean.js similarity index 82% rename from assets/cn_src_article_babel.md.xL16z9Xt.lean.js rename to assets/cn_src_article_babel.md.rAspsh5G.lean.js index 8a52b1108d..415fe7670e 100644 --- a/assets/cn_src_article_babel.md.xL16z9Xt.lean.js +++ b/assets/cn_src_article_babel.md.rAspsh5G.lean.js @@ -1 +1 @@ -import{_ as a,o as t,c as l,a3 as r}from"./chunks/framework.eq-HTtE3.js";const m=JSON.parse('{"title":"Babel","description":"","frontmatter":{},"headers":[],"relativePath":"cn/src/article/babel.md","filePath":"cn/src/article/babel.md","lastUpdated":1728205581000}'),i={name:"cn/src/article/babel.md"};function s(b,e,o,c,p,n){return t(),l("div",{"data-pagefind-body":!0},e[0]||(e[0]=[r('

Babel

babel 核心库主要是:

  • @babel/parser 对源码进行 parse,可以通过 plugins、sourceType 等来指定 parse 语法,功能是把源码转成 AST。
  • @babel/traverse 通过 visitor 函数对遍历到的 ast 进行处理,分为 enter 和 exit 两个阶段,具体操作 AST 使用 path 的 api,还可以通过 state 来在遍历过程中传递一些数据
  • @babel/types 用于创建、判断 AST 节点,提供了 xxx、isXxx、assertXxx 的 api
  • @babel/template 当需要批量创建 AST 的时候可以使用 @babel/template 来简化 AST 创建逻辑。
  • @babel/code-frame 可以创建友好的报错信息
  • @babel/generator 打印 AST 成目标代码字符串,支持 comments、minified、sourceMaps 等选项。
  • @babel/core 基于上面的包来完成 babel 的编译流程,并应用 plugin 和 preset。
',3)]))}const u=a(i,[["render",s]]);export{m as __pageData,u as default}; +import{_ as a,o as t,c as l,a3 as r}from"./chunks/framework.CHSXtLMd.js";const m=JSON.parse('{"title":"Babel","description":"","frontmatter":{},"headers":[],"relativePath":"cn/src/article/babel.md","filePath":"cn/src/article/babel.md","lastUpdated":1728702757000}'),i={name:"cn/src/article/babel.md"};function s(b,e,o,c,p,n){return t(),l("div",{"data-pagefind-body":!0},e[0]||(e[0]=[r('

Babel

babel 核心库主要是:

  • @babel/parser 对源码进行 parse,可以通过 plugins、sourceType 等来指定 parse 语法,功能是把源码转成 AST。
  • @babel/traverse 通过 visitor 函数对遍历到的 ast 进行处理,分为 enter 和 exit 两个阶段,具体操作 AST 使用 path 的 api,还可以通过 state 来在遍历过程中传递一些数据
  • @babel/types 用于创建、判断 AST 节点,提供了 xxx、isXxx、assertXxx 的 api
  • @babel/template 当需要批量创建 AST 的时候可以使用 @babel/template 来简化 AST 创建逻辑。
  • @babel/code-frame 可以创建友好的报错信息
  • @babel/generator 打印 AST 成目标代码字符串,支持 comments、minified、sourceMaps 等选项。
  • @babel/core 基于上面的包来完成 babel 的编译流程,并应用 plugin 和 preset。
',3)]))}const u=a(i,[["render",s]]);export{m as __pageData,u as default}; diff --git a/assets/cn_src_article_bundle.md.DBdY72dw.js b/assets/cn_src_article_bundle.md.65R3DvSm.js similarity index 88% rename from assets/cn_src_article_bundle.md.DBdY72dw.js rename to assets/cn_src_article_bundle.md.65R3DvSm.js index 97b9780eb5..4eba6003b9 100644 --- a/assets/cn_src_article_bundle.md.DBdY72dw.js +++ b/assets/cn_src_article_bundle.md.65R3DvSm.js @@ -1 +1 @@ -import{_ as a,o as n,c as t,j as e,a as r}from"./chunks/framework.eq-HTtE3.js";const f=JSON.parse('{"title":"Bundle","description":"","frontmatter":{},"headers":[],"relativePath":"cn/src/article/bundle.md","filePath":"cn/src/article/bundle.md","lastUpdated":1728205581000}'),d={name:"cn/src/article/bundle.md"};function c(s,l,i,o,u,p){return n(),t("div",{"data-pagefind-body":!0},l[0]||(l[0]=[e("h1",{id:"bundle",tabindex:"-1"},[r("Bundle "),e("a",{class:"header-anchor",href:"#bundle","aria-label":'Permalink to "Bundle"'},"​")],-1),e("p",null,"Bundle 的本质就是输入,转换,输出。在机器上直接运行的代码,往往都难以维护和理解,我们需要将开发者方便理解和维护的代码,通过打包等工具转换成方便机器或者程序使用的代码。对于 web 前端来说,打包工具,至少需要以下功能:",-1),e("ul",null,[e("li",null,"编译能力"),e("li",null,"插件机制"),e("li",null,"HMR"),e("li",null,"cli 和命令行能力")],-1)]))}const m=a(d,[["render",c]]);export{f as __pageData,m as default}; +import{_ as a,o as n,c as t,j as e,a as r}from"./chunks/framework.CHSXtLMd.js";const f=JSON.parse('{"title":"Bundle","description":"","frontmatter":{},"headers":[],"relativePath":"cn/src/article/bundle.md","filePath":"cn/src/article/bundle.md","lastUpdated":1728702757000}'),d={name:"cn/src/article/bundle.md"};function c(s,l,i,o,u,p){return n(),t("div",{"data-pagefind-body":!0},l[0]||(l[0]=[e("h1",{id:"bundle",tabindex:"-1"},[r("Bundle "),e("a",{class:"header-anchor",href:"#bundle","aria-label":'Permalink to "Bundle"'},"​")],-1),e("p",null,"Bundle 的本质就是输入,转换,输出。在机器上直接运行的代码,往往都难以维护和理解,我们需要将开发者方便理解和维护的代码,通过打包等工具转换成方便机器或者程序使用的代码。对于 web 前端来说,打包工具,至少需要以下功能:",-1),e("ul",null,[e("li",null,"编译能力"),e("li",null,"插件机制"),e("li",null,"HMR"),e("li",null,"cli 和命令行能力")],-1)]))}const m=a(d,[["render",c]]);export{f as __pageData,m as default}; diff --git a/assets/cn_src_article_bundle.md.DBdY72dw.lean.js b/assets/cn_src_article_bundle.md.65R3DvSm.lean.js similarity index 88% rename from assets/cn_src_article_bundle.md.DBdY72dw.lean.js rename to assets/cn_src_article_bundle.md.65R3DvSm.lean.js index 97b9780eb5..4eba6003b9 100644 --- a/assets/cn_src_article_bundle.md.DBdY72dw.lean.js +++ b/assets/cn_src_article_bundle.md.65R3DvSm.lean.js @@ -1 +1 @@ -import{_ as a,o as n,c as t,j as e,a as r}from"./chunks/framework.eq-HTtE3.js";const f=JSON.parse('{"title":"Bundle","description":"","frontmatter":{},"headers":[],"relativePath":"cn/src/article/bundle.md","filePath":"cn/src/article/bundle.md","lastUpdated":1728205581000}'),d={name:"cn/src/article/bundle.md"};function c(s,l,i,o,u,p){return n(),t("div",{"data-pagefind-body":!0},l[0]||(l[0]=[e("h1",{id:"bundle",tabindex:"-1"},[r("Bundle "),e("a",{class:"header-anchor",href:"#bundle","aria-label":'Permalink to "Bundle"'},"​")],-1),e("p",null,"Bundle 的本质就是输入,转换,输出。在机器上直接运行的代码,往往都难以维护和理解,我们需要将开发者方便理解和维护的代码,通过打包等工具转换成方便机器或者程序使用的代码。对于 web 前端来说,打包工具,至少需要以下功能:",-1),e("ul",null,[e("li",null,"编译能力"),e("li",null,"插件机制"),e("li",null,"HMR"),e("li",null,"cli 和命令行能力")],-1)]))}const m=a(d,[["render",c]]);export{f as __pageData,m as default}; +import{_ as a,o as n,c as t,j as e,a as r}from"./chunks/framework.CHSXtLMd.js";const f=JSON.parse('{"title":"Bundle","description":"","frontmatter":{},"headers":[],"relativePath":"cn/src/article/bundle.md","filePath":"cn/src/article/bundle.md","lastUpdated":1728702757000}'),d={name:"cn/src/article/bundle.md"};function c(s,l,i,o,u,p){return n(),t("div",{"data-pagefind-body":!0},l[0]||(l[0]=[e("h1",{id:"bundle",tabindex:"-1"},[r("Bundle "),e("a",{class:"header-anchor",href:"#bundle","aria-label":'Permalink to "Bundle"'},"​")],-1),e("p",null,"Bundle 的本质就是输入,转换,输出。在机器上直接运行的代码,往往都难以维护和理解,我们需要将开发者方便理解和维护的代码,通过打包等工具转换成方便机器或者程序使用的代码。对于 web 前端来说,打包工具,至少需要以下功能:",-1),e("ul",null,[e("li",null,"编译能力"),e("li",null,"插件机制"),e("li",null,"HMR"),e("li",null,"cli 和命令行能力")],-1)]))}const m=a(d,[["render",c]]);export{f as __pageData,m as default}; diff --git a/assets/cn_src_article_designMode.md.BtsBYMyP.js b/assets/cn_src_article_designMode.md.BqNiAb_Y.js similarity index 99% rename from assets/cn_src_article_designMode.md.BtsBYMyP.js rename to assets/cn_src_article_designMode.md.BqNiAb_Y.js index db58ebc786..9d7fcafff3 100644 --- a/assets/cn_src_article_designMode.md.BtsBYMyP.js +++ b/assets/cn_src_article_designMode.md.BqNiAb_Y.js @@ -1,4 +1,4 @@ -import{_ as i,a,b as n,c as h,d as l,e as k,f as p,g as t,h as e,i as E,j as r,k as d,l as g,m as y,n as F,o as c,p as o,q as C,r as B,s as A,t as D,u,v as b,w as m,x as v,y as f,z as x,A as _,B as q}from"./chunks/访问者._0swtoJg.js";import{_ as P,o as w,c as j,a3 as M}from"./chunks/framework.eq-HTtE3.js";const W=JSON.parse('{"title":"23 种经典设计模式","description":"","frontmatter":{},"headers":[],"relativePath":"cn/src/article/designMode.md","filePath":"cn/src/article/designMode.md","lastUpdated":1728205581000}'),S={name:"cn/src/article/designMode.md"};function T(L,s,V,I,N,O){return w(),j("div",{"data-pagefind-body":!0},s[0]||(s[0]=[M(`

23 种经典设计模式

设计模式 Design Pattern 是一套被反复使用、多数人知晓的、经过分类编目的、代码设计经验的总结,使用设计模式是为了可重用代码、让代码更容易被他人理解并且保证代码可靠性。。

在《设计模式:可复用面向对象软件的基础》一书中所介绍的 23 种经典设计模式,不过设计模式并不仅仅只有这 23 种,随着软件开发行业的发展,越来越多的新模式不断诞生并得以应用。有经验的开发者在学习设计模式可以和过往的经验互相印证,更容易理解这些设计模式。

设计模式一般包含模式名称、问题、目的、解决方案、效果等组成要素。问题描述了应该在何时使用模式,它包含了设计中存在的问题以及问题存在的原因。解决方案描述了一个设计模式的组成成分,以及这些组成成分之间的相互关系,各自的职责和协作方式,通常解决方案通过 UML 类图和核心代码来进行描述。效果描述了模式的优缺点以及在使用模式时应权衡的问题。

为什么要学习设计模式:

  • 设计模式来源众多专家的经验和智慧,它们是从许多优秀的软件系统中总结出的成功的、能够实现可维护性复用的设计方案,使用这些方案将可以让我们避免做一些重复性的工作

  • 设计模式提供了一套通用的设计词汇和一种通用的形式来方便开发人员之间沟通和交流,使得设计方案更加通俗易懂

  • 大部分设计模式都兼顾了系统的可重用性和可扩展性,这使得我们可以更好地重用一些已有的设计方案、功能模块甚至一个完整的软件系统,避免我们经常做一些重复的设计、编写一些重复的代码

  • 合理使用设计模式并对设计模式的使用情况进行文档化,将有助于别人更快地理解系统

  • 学习设计模式将有助于初学者更加深入地理解面向对象思想

储备知识