@monkey2582/thinconsole 1.4.2 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/en.thinConsole.min.js +1 -1
- package/package.json +1 -1
- package/thinConsole.d.ts +3 -1
- package/thinConsole.min.js +1 -1
package/thinConsole.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):t.thinConsole=e()}("undefined"!=typeof self?self:this,function(){let t={"angle-down":"0 0 384 512|M169.4 374.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 306.7 54.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z","angle-right":"0 0 256 512|M247.1 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L179.2 256 41.9 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z","arrow-left":"0 0 512 512|M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.3 288H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H109.3l105.4-105.4c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z",ban:"0 0 512 512|M367.2 412.5 99.5 144.8C77.1 176.2 64 214.6 64 256c0 106 86 192 192 192 41.5 0 79.9-13.1 111.2-35.5m45.3-45.3C434.9 335.8 448 297.4 448 256c0-106-86-192-192-192-41.5 0-79.9 13.1-111.2 35.5zM0 256a256 256 0 1 1 512 0 256 256 0 1 1-512 0",check:"0 0 448 512|M434.8 70.1c14.3 10.4 17.5 30.4 7.1 44.7l-256 352c-5.5 7.6-14 12.3-23.4 13.1s-18.5-2.7-25.1-9.3l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l101.5 101.5 234-321.7c10.4-14.3 30.4-17.5 44.7-7.1z","check-circle":"0 0 512 512|M256 512a256 256 0 1 1 0-512 256 256 0 1 1 0 512m118-366.3c-10.7-7.8-25.7-5.4-33.5 5.3L221.1 315.2 169 263.1c-9.4-9.4-24.6-9.4-33.9 0s-9.4 24.6 0 33.9l72 72c5 5 11.8 7.5 18.8 7s13.4-4.1 17.5-9.8l135.9-187c7.8-10.7 5.4-25.7-5.3-33.5","chevron-down":"0 0 448 512|M201.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 338.7 54.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z","chevron-up":"0 0 448 512|M201.4 105.4c12.5-12.5 32.8-12.5 45.3 0l192 192c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L224 173.3 54.6 342.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l192-192z",code:"0 0 576 512|M360.8 1.2c-17-4.9-34.7 5-39.6 22l-128 448c-4.9 17 5 34.7 22 39.6s34.7-5 39.6-22l128-448c4.9-17-5-34.7-22-39.6m64.6 136.1c-12.5 12.5-12.5 32.8 0 45.3l73.4 73.4-73.4 73.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l96-96c12.5-12.5 12.5-32.8 0-45.3l-96-96c-12.5-12.5-32.8-12.5-45.3 0zm-274.7 0c-12.5-12.5-32.8-12.5-45.3 0l-96 96c-12.5 12.5-12.5 32.8 0 45.3l96 96c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l73.3-73.4c12.5-12.5 12.5-32.8 0-45.3z",copy:"0 0 448 512|M192 0c-35.3 0-64 28.7-64 64v256c0 35.3 28.7 64 64 64h192c35.3 0 64-28.7 64-64V119.4c0-17.4-7.1-34.1-19.7-46.2l-57.7-55.4A64.1 64.1 0 0 0 326.3 0zM64 128c-35.3 0-64 28.7-64 64v256c0 35.3 28.7 64 64 64h192c35.3 0 64-28.7 64-64v-16h-64v16H64V192h16v-64z",database:"0 0 448 512|M448 205.8c-14.8 9.8-31.8 17.7-49.5 24-47 16.8-108.7 26.2-174.5 26.2s-127.6-9.5-174.5-26.2c-17.6-6.3-34.7-14.2-49.5-24V288c0 44.2 100.3 80 224 80s224-35.8 224-80zm0-77.8V80c0-44.2-100.3-80-224-80S0 35.8 0 80v48c0 44.2 100.3 80 224 80s224-35.8 224-80m-49.5 261.8C351.6 406.5 289.9 416 224 416s-127.6-9.5-174.5-26.2c-17.6-6.3-34.7-14.2-49.5-24V432c0 44.2 100.3 80 224 80s224-35.8 224-80v-66.2c-14.8 9.8-31.8 17.7-49.5 24",download:"0 0 448 512|M256 32c0-17.7-14.3-32-32-32s-32 14.3-32 32v210.7l-41.4-41.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l96 96c12.5 12.5 32.8 12.5 45.3 0l96-96c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 242.7zM64 320c-35.3 0-64 28.7-64 64v32c0 35.3 28.7 64 64 64h320c35.3 0 64-28.7 64-64v-32c0-35.3-28.7-64-64-64h-46.9l-56.6 56.6c-31.2 31.2-81.9 31.2-113.1 0L110.9 320zm304 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48",edit:"0 0 512 512|M471.6 21.7c-21.9-21.9-57.3-21.9-79.2 0L368 46.1l97.9 97.9 24.4-24.4c21.9-21.9 21.9-57.3 0-79.2zm-299.2 220c-6.1 6.1-10.8 13.6-13.5 21.9l-29.6 88.8c-2.9 8.6-.6 18.1 5.8 24.6s15.9 8.7 24.6 5.8l88.8-29.6c8.2-2.7 15.7-7.4 21.9-13.5L432 177.9 334.1 80zM96 64c-53 0-96 43-96 96v256c0 53 43 96 96 96h256c53 0 96-43 96-96v-96c0-17.7-14.3-32-32-32s-32 14.3-32 32v96c0 17.7-14.3 32-32 32H96c-17.7 0-32-14.3-32-32V160c0-17.7 14.3-32 32-32h96c17.7 0 32-14.3 32-32s-14.3-32-32-32z",exclamation:"0 0 128 512|M64 432c22.1 0 40 17.9 40 40s-17.9 40-40 40-40-17.9-40-40 17.9-40 40-40M64 0c26.5 0 48 21.5 48 48v1.7l-16 304c-.9 17-15 30.3-32 30.3s-31-13.3-32-30.3l-16-304V48C16 21.5 37.5 0 64 0","exclamation-triangle":"0 0 512 512|M256 0c14.7 0 28.2 8.1 35.2 21l216 400c6.7 12.4 6.4 27.4-.8 39.5S486.1 480 472 480H40c-14.1 0-27.2-7.4-34.4-19.5s-7.5-27.1-.8-39.5l216-400c7-12.9 20.5-21 35.2-21m0 352a32 32 0 1 0 0 64 32 32 0 1 0 0-64m0-192c-18.2 0-32.7 15.5-31.4 33.7l7.4 104c.9 12.5 11.4 22.3 23.9 22.3 12.6 0 23-9.7 23.9-22.3l7.4-104c1.3-18.2-13.1-33.7-31.4-33.7z",eye:"0 0 576 512|M288 32c-80.8 0-145.5 36.8-192.6 80.6-46.8 43.5-78.1 95.4-93 131.1-3.3 7.9-3.3 16.7 0 24.6 14.9 35.7 46.2 87.7 93 131.1C142.5 443.1 207.2 480 288 480s145.5-36.8 192.6-80.6c46.8-43.5 78.1-95.4 93-131.1 3.3-7.9 3.3-16.7 0-24.6-14.9-35.7-46.2-87.7-93-131.1C433.5 68.9 368.8 32 288 32M144 256a144 144 0 1 1 288 0 144 144 0 1 1-288 0m144-64c0 35.3-28.7 64-64 64-11.5 0-22.3-3-31.7-8.4-1 10.9-.1 22.1 2.9 33.2 13.7 51.2 66.4 81.6 117.6 67.9s81.6-66.4 67.9-117.6c-12.2-45.7-55.5-74.8-101.1-70.8 5.3 9.3 8.4 20.1 8.4 31.7",info:"0 0 192 512|M48 48a48 48 0 1 1 96 0 48 48 0 1 1-96 0M0 192c0-17.7 14.3-32 32-32h64c17.7 0 32 14.3 32 32v256h32c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32h32V224H32c-17.7 0-32-14.3-32-32","info-circle":"0 0 512 512|M256 512a256 256 0 1 0 0-512 256 256 0 1 0 0 512m-32-352a32 32 0 1 1 64 0 32 32 0 1 1-64 0m-8 64h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24h-80c-13.3 0-24-10.7-24-24s10.7-24 24-24h24v-64h-24c-13.3 0-24-10.7-24-24s10.7-24 24-24",list:"0 0 512 512|M40 48c-13.3 0-24 10.7-24 24v48c0 13.3 10.7 24 24 24h48c13.3 0 24-10.7 24-24V72c0-13.3-10.7-24-24-24zm152 16c-17.7 0-32 14.3-32 32s14.3 32 32 32h288c17.7 0 32-14.3 32-32s-14.3-32-32-32zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32h288c17.7 0 32-14.3 32-32s-14.3-32-32-32zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32h288c17.7 0 32-14.3 32-32s-14.3-32-32-32zM16 232v48c0 13.3 10.7 24 24 24h48c13.3 0 24-10.7 24-24v-48c0-13.3-10.7-24-24-24H40c-13.3 0-24 10.7-24 24m24 136c-13.3 0-24 10.7-24 24v48c0 13.3 10.7 24 24 24h48c13.3 0 24-10.7 24-24v-48c0-13.3-10.7-24-24-24z","mouse-pointer":"0 0 448 512|M77.3 2.5c8.1-4.1 17.9-3.2 25.1 2.3l320 239.9c8.3 6.2 11.6 17 8.4 26.8s-12.4 16.4-22.8 16.4H255.7l88.9 177.7c7.9 15.8 1.5 35-14.3 42.9s-35 1.5-42.9-14.3l-88.9-177.7-91.3 121.8c-6.2 8.3-17 11.6-26.8 8.4S64 434.3 64 424V24c0-9.1 5.1-17.4 13.3-21.5","paper-plane":"0 0 576 512|M536.4-26.3c9.8-3.5 20.6-1 28 6.3s9.8 18.2 6.3 28l-178 496.9c-5 13.9-18.1 23.1-32.8 23.1-14.2 0-27-8.6-32.3-21.7l-64.2-158c-4.5-11-2.5-23.6 5.2-32.6l94.5-112.4c5.1-6.1 4.7-15-.9-20.6s-14.6-6-20.6-.9l-112.4 94.3c-9.1 7.6-21.6 9.6-32.6 5.2L38.1 216.8c-13.1-5.3-21.7-18.1-21.7-32.3 0-14.7 9.2-27.8 23.1-32.8z",pen:"0 0 512 512|M352.9 21.2 308 66.1 445.9 204l44.9-44.9c13.6-13.5 21.2-31.9 21.2-51.1s-7.6-37.6-21.2-51.1l-35.7-35.7C441.6 7.6 423.2 0 404 0s-37.6 7.6-51.1 21.2M274.1 100 58.9 315.1c-10.7 10.7-18.5 24.1-22.6 38.7L.9 481.6c-2.3 8.3 0 17.3 6.2 23.4s15.1 8.5 23.4 6.2l127.8-35.5c14.6-4.1 27.9-11.8 38.7-22.6l215-215.2z",plug:"0 0 448 512|M128-32c17.7 0 32 14.3 32 32v96h128V0c0-17.7 14.3-32 32-32s32 14.3 32 32v96h64c17.7 0 32 14.3 32 32s-14.3 32-32 32v64c0 95.1-69.2 174.1-160 189.3V480c0 17.7-14.3 32-32 32s-32-14.3-32-32v-66.7C101.2 398.1 32 319.1 32 224v-64c-17.7 0-32-14.3-32-32s14.3-32 32-32h64V0c0-17.7 14.3-32 32-32",plus:"0 0 448 512|M256 64c0-17.7-14.3-32-32-32s-32 14.3-32 32v160H32c-17.7 0-32 14.3-32 32s14.3 32 32 32h160v160c0 17.7 14.3 32 32 32s32-14.3 32-32V288h160c17.7 0 32-14.3 32-32s-14.3-32-32-32H256z",redo:"0 0 512 512|M488 192H344c-9.7 0-18.5-5.8-22.2-14.8s-1.7-19.3 5.2-26.2l46.7-46.7C298.4 45.7 189.4 51 120.2 120.2c-75 75-75 196.5 0 271.5s196.5 75 271.5 0q12.3-12.3 21.9-26.1c10.1-14.5 30.1-18 44.6-7.9s18 30.1 7.9 44.6c-8.5 12.2-18.2 23.8-29.1 34.7-100 100-262.1 100-362 0S-25 175 75 75c94.3-94.3 243.7-99.6 344.3-16.2L471 7c6.9-6.9 17.2-8.9 26.2-5.2S512 14.3 512 24v144c0 13.3-10.7 24-24 24",search:"0 0 512 512|M416 208c0 45.9-14.9 88.3-40 122.7l126.6 126.7c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.1-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0s208 93.1 208 208M208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288",table:"0 0 448 512|M384 32c35.3 0 64 28.7 64 64v320c0 35.3-28.7 64-64 64H64l-6.5-.3C25.2 476.4 0 449.1 0 416V96c0-35.3 28.7-64 64-64zM64 320v96h128v-96zm192 0v96h128v-96zM64 256h128v-96H64zm192 0h128v-96H256z",terminal:"0 0 512 512|M9.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L146.7 256zM224 384h256c17.7 0 32 14.3 32 32s-14.3 32-32 32H224c-17.7 0-32-14.3-32-32s14.3-32 32-32",times:"0 0 384 512|M55.1 73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L147.2 256 9.9 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l137.3-137.4 137.4 137.3c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.8 256l137.3-137.4c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192.5 210.7z","times-circle":"0 0 512 512|M256 512a256 256 0 1 0 0-512 256 256 0 1 0 0 512m-89-345c9.4-9.4 24.6-9.4 33.9 0l55 55 55-55c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-55 55 55 55c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-55-55-55 55c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l55-55-55-55c-9.4-9.4-9.4-24.6 0-33.9",tool:"0 0 576 512|M70.8-6.7c5.4-5.4 13.8-6.2 20.2-2l118.9 79.2c8.9 5.9 14.2 15.9 14.2 26.6v49.6l90.8 90.8c33.3-15 73.9-8.9 101.2 18.5l126.1 126.1c18.7 18.7 18.7 49.1 0 67.9l-60.1 60.1c-18.7 18.7-49.1 18.7-67.9 0L288.1 384c-27.4-27.4-33.5-67.9-18.5-101.2L178.8 192h-49.6c-10.7 0-20.7-5.3-26.6-14.2L23.4 58.9c-4.2-6.3-3.4-14.8 2-20.2zm145 303.5c-6.3 36.9 2.3 75.9 26.2 107.2l-94.9 95c-28.1 28.1-73.7 28.1-101.8 0s-28.1-73.7 0-101.8l135.4-135.5 35.2 35.1zM384.1 0c20.1 0 39.4 3.7 57.1 10.5 10 3.8 11.8 16.5 4.3 24.1l-56.7 56.7c-3 3-4.7 7.1-4.7 11.3V144c0 8.8 7.2 16 16 16h41.4c4.2 0 8.3-1.7 11.3-4.7l56.7-56.7c7.6-7.5 20.3-5.7 24.1 4.3 6.8 17.7 10.5 37 10.5 57.1 0 43.2-17.2 82.3-45 111.1L450 222c-33.1-33-78.5-45.7-121.1-38.4l-56.8-56.8V97.1l-.2-5c-.8-12.4-4.4-24.3-10.5-34.9C290.8 22.2 334.8 0 384.1-.1z",trash:"0 0 448 512|M136.7 5.9 128 32H32C14.3 32 0 46.3 0 64s14.3 32 32 32h384c17.7 0 32-14.3 32-32s-14.3-32-32-32h-96l-8.7-26.1C306.9-7.2 294.7-16 280.9-16H167.1c-13.8 0-26 8.8-30.4 21.9M416 144H32l21.1 323.1C54.7 492.4 75.7 512 101 512h246c25.3 0 46.3-19.6 47.9-44.9z",upload:"0 0 448 512|M256 109.3V320c0 17.7-14.3 32-32 32s-32-14.3-32-32V109.3l-41.4 41.4c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l96-96c12.5-12.5 32.8-12.5 45.3 0l96 96c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0zM224 400c44.2 0 80-35.8 80-80h80c35.3 0 64 28.7 64 64v32c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64v-32c0-35.3 28.7-64 64-64h80c0 44.2 35.8 80 80 80m144 24a24 24 0 1 0 0-48 24 24 0 1 0 0 48",wifi:"0 0 576 512|M288 96c-90.9 0-173.2 36-233.7 94.6-12.7 12.3-33 12-45.2-.7s-12-33 .7-45.2C81.7 74.9 179.9 32 288 32s206.3 42.9 278.3 112.7c12.7 12.3 13 32.6.7 45.2s-32.6 13-45.2.7C461.2 132 378.9 96 288 96m-48 336a48 48 0 1 1 96 0 48 48 0 1 1-96 0m-72-105.8c-11.7 13.3-31.9 14.5-45.2 2.8s-14.5-31.9-2.8-45.2c41-46.4 101.1-75.8 168-75.8s127 29.4 168 75.8c11.7 13.3 10.4 33.5-2.8 45.2s-33.5 10.4-45.2-2.8c-29.4-33.3-72.2-54.2-120-54.2s-90.6 20.9-120 54.2","window-restore":"0 0 576 512|M512 96H160c0-35.3 28.7-64 64-64h288c35.3 0 64 28.7 64 64v192c0 35.3-28.7 64-64 64h-48v-64h48zM0 224c0-35.3 28.7-64 64-64h288c35.3 0 64 28.7 64 64v192c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64zm64 40c0 13.3 10.7 24 24 24h240c13.3 0 24-10.7 24-24s-10.7-24-24-24H88c-13.3 0-24 10.7-24 24","cookie-bite":"0 0 512 512|M257.5 27.6c-.8-5.4-4.9-9.8-10.3-10.6-22.1-3.1-44.6.9-64.4 11.4l-74 39.5c-19.7 10.5-35.6 27-45.4 47.1l-36.7 75.6c-9.8 20.1-13 42.9-9.1 64.9l14.5 82.8c3.9 22.1 14.6 42.3 30.7 57.9l60.3 58.4c16.1 15.6 36.6 25.6 58.7 28.7l83 11.7c22.1 3.1 44.6-.9 64.4-11.4l74-39.5c19.7-10.5 35.6-27 45.4-47.2l36.7-75.5c9.8-20.1 13-42.9 9.1-64.9-.9-5.3-5.3-9.3-10.6-10.1-51.5-8.2-92.8-47.1-104.5-97.4-1.8-7.6-8-13.4-15.7-14.6-54.6-8.7-97.7-52-106.2-106.8zM208 144a32 32 0 1 1 0 64 32 32 0 1 1 0-64m-64 192a32 32 0 1 1 64 0 32 32 0 1 1-64 0m224-64a32 32 0 1 1 0 64 32 32 0 1 1 0-64"};class e{constructor(t={}){if(e.tC)return console.warn("[thinConsole] thinConsole实例已存在"),e.tC;switch(e.tC=this,this.version="1.4.2",this.options=this.sanitizeOptions(t),this.options.theme){case"light":this.currentTheme="light";break;case"dark":this.currentTheme="dark";break;default:if(e.themes[this.options.theme])this.currentTheme=this.options.theme;else{let t=()=>window.matchMedia("(prefers-color-scheme:dark)").matches?"dark":"light";this.currentTheme=t(),this.mediaQuery=window.matchMedia("(prefers-color-scheme:dark)"),this.themeChangeHandler=t=>{this.currentTheme=t.matches?"dark":"light",this.overlay&&this.overlay.classList.contains("active")&&(this.overlay.className="overlay active theme-"+this.currentTheme)},this.mediaQuery.addEventListener("change",this.themeChangeHandler)}}this.currentTab="console",this.searchExpanded=!1,this.activeLSFilter="local",this.selectedElement=null,this.selectedShadowHostId=null,this.expandedElements=new WeakSet,this.mutedLogs=!1,this.mutedFilters={},this.netSending=!1,this.netNewVisible=!1,this.editorState={visible:!1,mode:"ls",key:"",oldKey:"",value:""},void 0===t.pos?.x&&void 0===t.pos?.y&&(this.options.pos=this.getSavedBtnPos()||{x:30,y:30}),this.pluginEnabled=this.options.plugins,this.disabledPlugins=this.options.disabledPlugins,this.plugins={},this.pluginTabs={},this.pluginViewContainers={},this.logs=[],this.lastLog=null,this.maxLog=this.options.maxLog,this.maxNetwork=this.options.maxNetwork,this.selectedLogId=null,this.customTabCount=0,this.treeNodeRegistry=new Map,this.treeNodeRegId=0,this.expandedTreePaths=new Set,this.timerMap=new Map,this.countMap=new Map,this.networkRequests=[],this._netReqId=0,this.activeNetFilter="all",this.netDisabled=!1,this.netDisabledTypes=new Set,this.netDetailId=null,this.originalXHR=null,this.originalFetch=null,this.closedShadowRoots=new Map,this.interceptShadowRoot(),this.initShadow(),this.createStyles(),this.createButton(),this.captureConsoleLogs(),this.createNotificationElement(),this.createOverlayElement(),this._applyCustomThemeCSS(),this._injectHeaderButtons(),e.themes[this.currentTheme]&&this.applyIcon(e.themes[this.currentTheme].icons),this.setupGlobalEventHandlers(),this.setupSelfProtection(),this.renderContent()}interceptShadowRoot(){if(window.__tcShadowIntercepted)return;window.__tcShadowIntercepted=!0;let t=this,e=Element.prototype.attachShadow;Element.prototype.attachShadow=function(s){let i=e.call(this,s);return t.closedShadowRoots.set(this,{root:i,mode:s.mode||"open"}),i}}initShadow(){this.host&&this.host.remove(),this.host=document.createElement("div"),this.host.id="_thinConsole",this.host.setAttribute("tc-lock",""),this.host.style.cssText="position:absolute;top:0;left:0;width:0;height:0;z-index:2147483647",this.shadowRoot=this.host.attachShadow({mode:"open"}),document.documentElement.appendChild(this.host)}getShadowRoot(t){return t.shadowRoot?{root:t.shadowRoot,mode:"open"}:this.closedShadowRoots.get(t)||null}getSavedBtnPos(){let t=localStorage.getItem("tC-Button-pos");if(!t)return this.saveBtnPos({x:30,y:30}),null;let e=t.match(/^x:(.+?)\,y:(.+)$/);if(!e)return this.saveBtnPos({x:30,y:30}),null;let s=Number(e[1]),i=Number(e[2]);return isNaN(s)||isNaN(i)?(this.saveBtnPos({x:30,y:30}),null):{x:s,y:i}}saveBtnPos({x:t,y:e}){t=isNaN(Number(t))?30:Number(t),e=isNaN(Number(e))?30:Number(e),localStorage.setItem("tC-Button-pos",`x:${t},y:${e}`)}sanitizeOptions(t){let e={text:"thinConsole",color:"#007aff",width:"auto",height:"auto",theme:"auto",plugins:!0,disabledPlugins:[],jsExecute:!0,pos:null,maxLog:1e5,maxNetwork:1e3,pluginOption:{},filters:null,showComments:!0};if(!t||"object"!=typeof t)return{...e};let s={...e},i=(t,e=200)=>"string"==typeof t&&t.length<=e&&!/[<>"&]/.test(t)?t:void 0;for(let n of Object.keys(t)){if(!(n in e))continue;let o=t[n];switch(n){case"text":case"color":case"width":case"height":case"theme":{let t=i(o);void 0!==t&&(s[n]=t);break}case"plugins":case"jsExecute":case"showComments":"boolean"==typeof o&&(s[n]=o);break;case"disabledPlugins":Array.isArray(o)&&o.every(t=>"string"==typeof t)&&(s[n]=o.slice(0,100));break;case"pos":o&&"object"==typeof o&&"number"==typeof o.x&&"number"==typeof o.y&&(s.pos={x:o.x,y:o.y});break;case"maxLog":{let e=Number(t[n]);!isNaN(e)&&e>0&&(s[n]=Math.floor(e));break}case"maxNetwork":{let e=Number(t[n]);!isNaN(e)&&e>0&&(s[n]=Math.floor(e));break}case"pluginOption":o&&"object"==typeof o&&(s[n]=o);break;case"filters":Array.isArray(o)&&o.every(t=>t&&"string"==typeof t.id&&"string"==typeof t.name)&&(s[n]=o)}}return s}createButton(){this.btn=document.createElement("button"),this.btn.id="thinConsole-btn",this.btn.className="floating-console-btn",this.btn.textContent=this.options.text.slice(0,11),this.btn.style.background=this.options.color,this.btn.style.width=this.options.width,this.btn.style.height=this.options.height,this.btn.style.bottom=(Number(this.options.pos.y)||30)+"px",this.btn.style.right=(Number(this.options.pos.x)||30)+"px",this.btn.title=this.options.text.slice(0,11),this.shadowRoot.append(this.btn),this.btn.style.transition="none",requestAnimationFrame(()=>requestAnimationFrame(()=>{this.btn.style.transition=""}));let t=!1,e=0,s=0,i=0,n=0,o=0,r=0,l=null,a=null,c=0,d=0,h=()=>{l&&(clearTimeout(l),l=null)},p=()=>{if(!t)return;let e=c-i,s=d-n;this.btn.style.transition="none",this.btn.style.transform=`translate3d(${e}px,${s}px,0)`,a=requestAnimationFrame(p)},u=l=>{if(!t)return;let a=l.touches?l.touches[0]:l,h=a.clientX-e,p=a.clientY-s;c=Math.max(o/2,Math.min(innerWidth-o/2,i+h)),d=Math.max(r/2,Math.min(innerHeight-r/2,n+p)),l.preventDefault()},g=()=>{if(h(),!t)return;t=!1,cancelAnimationFrame(a);let e=this.btn.getBoundingClientRect(),s=Math.round(innerWidth-e.right),i=Math.round(innerHeight-e.bottom);this.btn.style.right=Math.max(0,s)+"px",this.btn.style.bottom=Math.max(0,i)+"px",this.saveBtnPos({x:Math.max(0,s),y:Math.max(0,i)}),this.btn.style.transition="all 0.3s ease",this.btn.style.transform="",this.btn.dataset.right=Math.max(0,s),this.btn.dataset.bottom=Math.max(0,i),this.btn.removeEventListener("touchmove",u,{passive:!1}),this.btn.removeEventListener("touchend",g),this.btn.removeEventListener("mousemove",u),this.btn.removeEventListener("mouseup",g)},f=a=>{let h=a.touches?a.touches[0]:a;e=h.clientX,s=h.clientY;let f=this.btn.getBoundingClientRect();o=f.width,r=f.height,i=f.left+o/2,n=f.top+r/2,l=setTimeout(()=>{t=!0,c=i,d=n,p(),this.btn.addEventListener("touchmove",u,{passive:!1}),this.btn.addEventListener("touchend",g),this.btn.addEventListener("mousemove",u),this.btn.addEventListener("mouseup",g)},500)};this.btn.addEventListener("touchstart",f,{passive:!1}),this.btn.addEventListener("mousedown",f),this.btn.addEventListener("touchend",h),this.btn.addEventListener("mouseup",h),this.btn.addEventListener("mouseleave",h),this.btn.addEventListener("click",()=>{this.triggerGlobalHook("beforeOpen"),this.overlay.className="overlay active theme-"+this.currentTheme,this.renderContent(),this.triggerGlobalHook("afterOpen")})}createOverlayElement(){this.overlay=document.createElement("div"),this.overlay.id="consoleOverlay",this.overlay.className="overlay no-anim";let t=`<div class="splitter" id="splitter"></div><div class="console-container"><div class="console-header" id="consoleHeader"><div class="console-title" id="consoleTitle">${this.icon("terminal")}${this.options.text.slice(0,11)}</div><div class="header-actions"><button class="header-icon-btn el-header-btn" id="elementPickBtn" title="选择元素" style="display:none">${this.icon("mouse-pointer")}</button><button class="header-icon-btn el-header-btn" id="elCopyBtn" title="复制元素" style="display:none">${this.icon("copy")}</button><button class="header-icon-btn el-header-btn el-delete-btn" id="elDeleteBtn" title="删除元素" style="display:none">${this.icon("trash")}</button><button class="header-icon-btn" id="logCopyBtn" title="复制选中日志" style="display:none">${this.icon("copy")}</button><button class="header-icon-btn ls-add-btn" id="lsAddBtn" title="新建" style="display:none">${this.icon("plus")}</button><button class="header-icon-btn" id="netNewBtn" title="新建请求" style="display:none">${this.icon("plus")}</button><button class="header-icon-btn" id="searchToggleBtn" title="搜索">${this.icon("search")}</button><button class="clear-all-btn" title="清除" id="clearLogsBtn">${this.icon("trash")}</button><button class="close-btn" title="关闭" id="closeConsoleBtn">${this.icon("times")}</button></div></div><div class="search-bar" id="searchBar" style="display:none"><div class="search-input-wrap">${this.icon("search","search-bar-icon")}<input type="text" id="searchInput" placeholder="搜索..."></div></div><div class="tabs" id="tabsContainer"></div><div class="console-content" id="contentArea"><div class="controls" id="consoleControls"><div class="filters" id="filtersContainer"></div><div class="filters ls-filters" id="lsFiltersContainer" style="display:none"><button class="filter-btn active" title="本地存储" data-ls-type="local" data-orig="本地存储" data-icon="database">${this.icon("database")}本地存储</button><button class="filter-btn" title="会话存储" data-ls-type="session" data-orig="会话存储" data-icon="window-restore">${this.icon("window-restore")}会话存储</button><button class="filter-btn" title="Cookies" data-ls-type="cookie" data-orig="Cookies" data-icon="cookie-bite">${this.icon("cookie-bite")}Cookies</button></div><button class="mute-btn" id="muteBtn" title="屏蔽后续日志">${this.icon("ban")}</button></div><div class="console-output" id="consoleOutput"></div><div class="localstorage-view" id="localstorageView" style="display:none"><div class="ls-items" id="lsItems"></div></div><div class="elements-view" id="elementsView" style="display:none"><div class="elements-tree" id="elementsTree"></div></div><div class="network-view" id="networkView" style="display:none"><div class="network-controls"><div class="network-filters" id="netFilters"></div><button class="net-disable-btn" id="netDisableBtn" title="禁用">${this.icon("ban")}</button></div><div class="network-items" id="networkItems"></div><div class="net-detail-overlay" id="netDetailOverlay"><div class="net-detail-header"><button class="net-back-btn" id="netBackBtn" title="返回">${this.icon("arrow-left")}</button><div class="net-detail-header-actions"><button class="net-copy-icon-btn" id="netCopyIconBtn" title="复制">${this.icon("copy")}</button><button class="net-resend-icon-btn" id="netResendIconBtn" title="重发">${this.icon("redo")}</button></div></div><div class="net-detail-body" id="netDetailBody"></div></div><div class="net-new-overlay" id="netNewOverlay"><div class="net-new-header"><button class="net-back-btn" id="netNewBackBtn">${this.icon("arrow-left")}</button><div class="net-new-title">新建请求</div></div><div class="net-new-body"><div class="net-form-group"><label class="net-form-label">网址</label><input type="text" class="net-form-input" id="netNewUrl" placeholder="https://..." spellcheck="false"></div><div class="net-form-group"><label class="net-form-label">类型</label><select class="net-form-select" id="netNewMethod"><option value="GET">GET</option><option value="POST">POST</option><option value="PUT">PUT</option><option value="PATCH">PATCH</option><option value="DELETE">DELETE</option><option value="HEAD">HEAD</option><option value="OPTIONS">OPTIONS</option></select></div><div class="net-form-group"><label class="net-form-label">请求内容 (可选)</label><textarea class="net-form-textarea" id="netNewBody" placeholder='{"key":"value"}' spellcheck="false"></textarea></div><div class="net-form-group"><label class="net-form-label">请求头 (可选, 每行一个)</label><textarea class="net-form-textarea" id="netNewHeaders" placeholder="Content-Type: application/json" spellcheck="false"></textarea></div><button class="net-send-btn" id="netSendBtn">${this.icon("paper-plane")} 发送请求</button></div></div></div><div class="ls-editor-overlay" id="lsEditorOverlay" style="display:none"><div class="ls-editor-header"><div class="ls-editor-header-row"><input type="text" class="ls-editor-key-input" id="lsEditorKeyInput" placeholder="键名..." spellcheck="false"><span class="ls-editor-title" id="lsEditorTitle"></span></div></div><div class="ls-editor-body"><textarea id="lsEditorInput" placeholder="输入值..." spellcheck="false"></textarea></div><div class="ls-editor-footer"><button class="ls-editor-btn cancel" id="lsEditorCancel">取消</button><button class="ls-editor-btn save" id="lsEditorSave">保存</button></div></div></div></div>`;this.overlay.innerHTML=t,this.shadowRoot.appendChild(this.overlay),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.overlay.classList.remove("no-anim")})});let $=this.overlay.querySelector.bind(this.overlay);this.tabButtonsContainer=$("#tabsContainer"),this.createBuiltinTabs(),this.closeConsoleBtn=$("#closeConsoleBtn"),this.consoleOutput=$("#consoleOutput"),this.title=$("#consoleTitle"),this.localstorageView=$("#localstorageView"),this.lsItems=$("#lsItems"),this.contentArea=$("#contentArea"),this.consoleContainer=$(".console-container"),this.renderFilters(),this.filterButtons=this.overlay.querySelectorAll("#filtersContainer .filter-btn"),this.searchInput=$("#searchInput"),this.clearLogsBtn=$("#clearLogsBtn"),this.tabButtons=this.overlay.querySelectorAll(".tab-btn"),this.consoleControls=$("#consoleControls"),this.searchToggleBtn=$("#searchToggleBtn"),this.searchBar=$("#searchBar"),this.consoleHeader=$("#consoleHeader"),this.lsEditorOverlay=$("#lsEditorOverlay"),this.lsEditorTitle=$("#lsEditorTitle"),this.lsEditorKeyInput=$("#lsEditorKeyInput"),this.lsEditorInput=$("#lsEditorInput"),this.lsEditorCancel=$("#lsEditorCancel"),this.lsEditorSave=$("#lsEditorSave"),this.muteBtn=$("#muteBtn"),this.lsFiltersContainer=$("#lsFiltersContainer"),this.lsAddBtn=$("#lsAddBtn"),this.logCopyBtn=$("#logCopyBtn"),this.elementsView=$("#elementsView"),this.elementsTree=$("#elementsTree"),this.networkView=$("#networkView"),this.networkItems=$("#networkItems"),this.netFiltersEl=$("#netFilters"),this.netDisableBtn=$("#netDisableBtn"),this.netDetailOverlay=$("#netDetailOverlay"),this.netDetailBody=$("#netDetailBody"),this.netNewOverlay=$("#netNewOverlay"),this.netNewUrl=$("#netNewUrl"),this.netNewMethod=$("#netNewMethod"),this.netNewBody=$("#netNewBody"),this.netNewHeaders=$("#netNewHeaders"),this.netSendBtn=$("#netSendBtn"),this.netBackBtn=$("#netBackBtn"),this.netNewBackBtn=$("#netNewBackBtn"),this.netNewBtn=$("#netNewBtn"),this.elementPickBtn=$("#elementPickBtn"),this.splitter=$("#splitter"),this.splitter&&this.setupSplitter(),this.elementPickBtn.addEventListener("click",()=>this.startElementPicker()),this.elCopyBtn=$("#elCopyBtn"),this.elCopyBtn.addEventListener("click",()=>{this.selectedElement?this.copyElementHTML(this.selectedElement):this.showNotification("请先选择一个元素","warning")}),this.elDeleteBtn=$("#elDeleteBtn"),this.elDeleteBtn.addEventListener("click",()=>{this.selectedElement?this.deleteElement(this.selectedElement):this.showNotification("请先选择一个元素","warning")}),this.netDisableBtn&&this.netDisableBtn.addEventListener("click",()=>this.toggleNetDisable()),this.netBackBtn&&this.netBackBtn.addEventListener("click",()=>{this.netDetailOverlay.style.display="none",this.netDetailId=null}),this.netNewBackBtn&&this.netNewBackBtn.addEventListener("click",()=>{this.netNewVisible=!1,this.netNewOverlay.style.display="none"}),this.netNewBtn&&this.netNewBtn.addEventListener("click",()=>{if(this.editorState.visible){let t=this.editorState.mode;if("code"===t)return void this.showNotification("正在运行代码,无法发送请求","warning");if("ls"===t)return void this.showNotification("正在保存键值,无法发送请求","warning")}this.netNewVisible=!0,this.netNewOverlay.style.display="flex"}),this.netSendBtn&&this.netSendBtn.addEventListener("click",()=>this.sendNewRequest()),this.networkItems&&this.networkItems.addEventListener("click",t=>{let e=t.target.closest(".net-item");if(!e)return;let s=parseInt(e.dataset.reqId);if(t.target.closest("[data-action=copy]")){t.stopPropagation(),t.preventDefault();let e=this.networkRequests.find(t=>t.id===s);if(e){let t=this._fmtNetReq(e);navigator.clipboard.writeText(t.ct).then(()=>this.showNotification("已复制完整请求信息")).catch(()=>{})}return}return t.target.closest("[data-action=detail]")?(t.stopPropagation(),t.preventDefault(),void this.showNetDetail(s)):void 0}),this.captureNetworkRequests(),this.closeConsoleBtn.addEventListener("click",()=>{this.triggerGlobalHook("beforeClose"),this.overlay.classList.remove("active"),this.triggerGlobalHook("afterClose")}),[this.consoleOutput,this.lsItems,this.networkItems].forEach(t=>this.vsInit(t)),this.lsItems.addEventListener("click",t=>{let e=t.target.closest(".ls-action-btn");if(!e)return;let s=e.dataset.action,i=e.dataset.key;switch(s){case"edit":this.openLSEditor(i);break;case"copy":this.copyLog(i,"",!0);break;case"remove":this.removeLSItem(i)}}),this.title.title="运行代码功能已被禁用",this.title.style.cursor="not-allowed",this.options.jsExecute&&(this.title.title="点击标题以输入代码执行",this.title.style.cursor="pointer",this.title.addEventListener("click",()=>this.onTitleClick())),this.overlay.addEventListener("click",t=>{let s=t.target.closest(".tree-load-more");s&&this.loadMoreTreeChildren(s);let i=t.target.closest(".elements-tree .tree-label");if(i){let t=i.closest(".tree-node[data-el-id]"),e=t?parseInt(t.dataset.elId):null,s=null!==e&&this.elRefMap?this.elRefMap.get(e):null;s&&(this.selectedElement=s,this.selectedShadowHostId=t.dataset.shadowHost?parseInt(t.dataset.shadowHost):null,this.elementsTree.querySelectorAll(".el-selected").forEach(t=>t.classList.remove("el-selected")),this.elementsTree.querySelectorAll(".el-highlight").forEach(t=>t.classList.remove("el-highlight")),t.classList.add("el-selected"),t.classList.add("el-highlight"),setTimeout(()=>t.classList.remove("el-highlight"),3e3),this.updateControlsVisibility())}else"elements"!==this.currentTab||t.target.closest(".tree-label")||t.target.closest(".tree-toggle")||t.target.closest(".el-header-btn")||t.target.closest(".close-btn")||t.target.closest(".header-icon-btn")||t.target.closest(".console-header")||t.target.closest(".tabs")||t.target.closest(".controls")||t.target.closest(".search-bar")||(this.selectedElement=null,this.selectedShadowHostId=null,this.elementsTree&&(this.elementsTree.querySelectorAll(".el-selected").forEach(t=>t.classList.remove("el-selected")),this.elementsTree.querySelectorAll(".el-highlight").forEach(t=>t.classList.remove("el-highlight"))),this.updateControlsVisibility());let n=t.target.closest(".tree-toggle")||("elements"===this.currentTab||t.target.closest(".tree-close")?null:t.target.closest(".tree-node"));if(n){let t=n.closest(".tree-node");if(t){let e=t.dataset.elId,s=e&&this.elRefMap?this.elRefMap.get(parseInt(e)):null;if(t.classList.contains("collapsed")){t.classList.remove("collapsed"),t.classList.add("expanded");let e=t.dataset.treePath;e&&this.expandedTreePaths.add(e),s&&this.expandedElements.add(s);let i=t.querySelector(":scope > .tree-children");if(i&&i.dataset.lazyId){let t=parseInt(i.dataset.lazyId),e=this.treeNodeRegistry.get(t);if(e){let s="";if("html"===e.type)s=this.renderDomChildrenLazy(e.children,(t,s,i)=>this.renderHTMLTree(t,"",e.path+"."+s,i),e.depth||0,"html",{path:e.path}),e.shadow&&(s+=this.buildShadowLazy(e.shadow,"html",e.path,e.depth||0));else if("html-shadow"===e.type)s=this.renderDomChildrenLazy(e.children,(t,s,i)=>this.renderHTMLTree(t,"",e.path+".shadow."+s,i),e.depth||0,"html-shadow",{});else if("element"===e.type)s=this.renderDomChildrenLazy(e.children,(t,e,s)=>this.renderElementTree(t,s),e.depth||0,"element",{}),e.shadow&&(s+=this.buildShadowLazy(e.shadow,"element",null,e.depth||0,e.elId));else if("element-shadow"===e.type)s=this.renderDomChildrenLazy(e.children,(t,e,s)=>this.renderElementTree(t,s),e.depth||0,"element-shadow",{});else if(e.isJsonValue)s=this.renderJSONValueChildren(e.children);else{let t=new WeakSet;e.chain.forEach(e=>t.add(e)),t.add(e.obj);let i=e.children;if(i.length>200){let n=this.treeNodeRegId++;this.treeNodeRegistry.set(n,{children:i,chain:e.chain.concat([e.obj]),noProto:e.noProto}),s=this.renderTreeChildrenBatch(i,t,0,200,e.chain.concat([e.obj]),e.path||"",1,e.noProto)+'<div class="tree-load-more" data-reg-id="'+n+'" data-offset="200">'+this.icon("angle-down")+" 展开更多 (剩余 "+(i.length-200)+" 项)</div>"}else s=this.renderTreeChildrenBatch(i,t,0,i.length,e.chain.concat([e.obj]),e.path||"",1,e.noProto)}i.innerHTML=s,delete i.dataset.lazyId,this.treeNodeRegistry.delete(t)}}}else{t.classList.remove("expanded"),t.classList.add("collapsed");let e=t.dataset.treePath;e&&this.expandedTreePaths.delete(e),s&&this.expandedElements.delete(s)}let i=n.closest(".console-output, .ls-items");i&&this.vsRender(i)}}t.target===this.overlay&&window.innerWidth<=768&&(this.triggerGlobalHook("beforeClose"),this.overlay.classList.remove("active"),this.triggerGlobalHook("afterClose"))}),this.filterButtons.forEach(t=>{t.addEventListener("click",()=>{this.filterButtons.forEach(t=>t.classList.remove("active")),t.classList.add("active"),this.activeFilter=t.dataset.type,this.updateFilterCounts(),this.renderContent(),this.scrollFilterIntoView(this.filtersContainerEl,t)})}),this.lsFiltersContainer&&this.lsFiltersContainer.querySelectorAll(".filter-btn").forEach(t=>{t.addEventListener("click",()=>{this.lsFiltersContainer.querySelectorAll(".filter-btn").forEach(t=>t.classList.remove("active")),t.classList.add("active"),this.activeLSFilter=t.dataset.lsType,this.renderContent(),this.scrollFilterIntoView(this.lsFiltersContainer,t)})}),this.lsAddBtn&&this.lsAddBtn.addEventListener("click",()=>this.onAddLSClick()),this.logCopyBtn&&this.logCopyBtn.addEventListener("click",()=>{null!==this.selectedLogId?this.copyLog(this.selectedLogId,!1):this.showNotification("请先选中一条日志","warning")}),this.consoleOutput&&this.consoleOutput.addEventListener("click",t=>{let e=t.target.closest(".log-item");if(!e)return this.selectedLogId=null,this.consoleOutput.querySelectorAll(".log-item.selected").forEach(t=>t.classList.remove("selected")),void(this.logCopyBtn&&(this.logCopyBtn.style.display="none"));let s=parseInt(e.id.replace("log-item-",""));this.selectedLogId=s,this.consoleOutput.querySelectorAll(".log-item.selected").forEach(t=>t.classList.remove("selected")),e.classList.add("selected"),this.logCopyBtn&&(this.logCopyBtn.style.display="flex")}),this.searchInput.addEventListener("input",(t=>e=>{clearTimeout(t),t=setTimeout(()=>{if(this.searchQuery=e.target.value,"network"===this.currentTab)return this.renderNetworkList().trim(),this.renderContent()},300)})(0)),this.clearLogsBtn.addEventListener("click",()=>this.clearAllLogs()),this.searchToggleBtn.addEventListener("click",()=>this.toggleSearch()),this.lsEditorCancel.addEventListener("click",()=>this.closeLSEditor()),this.lsEditorSave.addEventListener("click",()=>this.onEditorSave()),this.muteBtn.addEventListener("click",()=>this.toggleMute()),this.lsEditorInput.addEventListener("input",()=>{this.editorState.value=this.lsEditorInput.value}),this.lsEditorKeyInput&&this.lsEditorKeyInput.addEventListener("input",()=>{this.editorState.key=this.lsEditorKeyInput.value.trim()}),this.setupFilterShadow(this.filtersContainerEl),this.setupFilterShadow(this.lsFiltersContainer),this.setupFilterShadow(this.netFiltersEl),this.setupGestures(),this.tabButtons.forEach(t=>{t.addEventListener("click",()=>{this.tabButtons.forEach(t=>t.classList.remove("active")),t.classList.add("active"),this.currentTab=t.dataset.tab,this.renderContent()})})}renderFilters(){let t=this.overlay.querySelector("#filtersContainer");if(!t)return;this.filtersContainerEl=t;let e=this.options.filters;e&&e.length||(e=[{id:"all",name:"全部",icon:"list"},{id:"log",name:"日志",icon:"info"},{id:"info",name:"信息",icon:"info-circle"},{id:"warn",name:"警告",icon:"exclamation-triangle"},{id:"error",name:"错误",icon:"times-circle"}]),t.innerHTML=e.map((t,e)=>`<button class="filter-btn${0===e?" active":""}" title="${this.escapeHtml(t.name)}" data-type="${this.escapeHtml(t.id)}" data-icon="${this.escapeHtml(t.icon||"")}">${t.icon?this.icon(t.icon):""}${this.escapeHtml(t.name)}</button>`).join(""),t.querySelectorAll(".filter-btn").forEach(e=>{e.addEventListener("click",()=>{t.querySelectorAll(".filter-btn").forEach(t=>t.classList.remove("active")),e.classList.add("active"),this.activeFilter=e.dataset.type,this.updateFilterCounts(),this.renderContent()})})}createBuiltinTabs(){[{id:"console",name:"控制台",icon:"terminal"},{id:"network",name:"网络",icon:"wifi"},{id:"localstorage",name:"存储",icon:"database"},{id:"elements",name:"元素",icon:"code"}].forEach(t=>{let e=document.createElement("button");e.className="tab-btn",e.dataset.tab=t.id,e.title=t.name,e.innerHTML=this.icon(t.icon)+t.name,t.id===this.currentTab&&e.classList.add("active"),e.addEventListener("click",()=>{this.tabButtons=this.overlay.querySelectorAll(".tab-btn"),this.tabButtons.forEach(t=>t.classList.remove("active")),e.classList.add("active"),this.currentTab=t.id,this.renderContent()}),this.tabButtonsContainer.appendChild(e)})}createPluginTab(t){let e=document.createElement("button");e.className="tab-btn",e.dataset.tab=t.id?t.id:"newTab",t.title=t.name?t.name:"新的插件",e.innerHTML=this.icon(t.icon||"plug")+(t.name||"新的插件"),this.tabButtonsContainer.appendChild(e),e.addEventListener("click",()=>{this.tabButtons=this.overlay.querySelectorAll(".tab-btn"),this.tabButtons.forEach(t=>t.classList.remove("active")),e.classList.add("active"),this.currentTab=t.id,this.renderContent()});let s=document.createElement("div");s.id=`${t.id}View`,s.innerHTML="无插件视图",s.className="plug-view",s.style.display="none",this.contentArea.appendChild(s),this.pluginViewContainers[t.id]=s}createNotificationElement(){this.notification=document.createElement("div"),this.notification.id="notification",this.notification.className="notification",this.notification.style.display="none",this.shadowRoot.appendChild(this.notification)}createStyles(){let t=document.createElement("style");t.innerHTML=":host{all:initial}*{margin:0;padding:0;box-sizing:border-box}.floating-console-btn{position:fixed;z-index:99997;touch-action:none;will-change:transform;padding:15px 25px;backdrop-filter:blur(5px);border-radius:5px;border:none;background:#007aff;color:#fff;font-size:1rem;cursor:move;display:flex;align-items:center;gap:10px;font-weight:500;box-shadow:0 8px 20px rgba(0,0,0,.4);transition:all .3s ease;user-select:none}.floating-console-btn:active{transform:scale(.98)}.floating-console-btn .ico{font-size:1.2rem}.overlay{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.85);display:flex;align-items:center;justify-content:center;z-index:99998;opacity:0;visibility:hidden;transition:all .4s ease;backdrop-filter:blur(5px)}.overlay.active{opacity:1;visibility:visible}.theme-dark{--selected-bg:rgba(74,74,230,.15);--console-bg:#1e1e1e;--header-bg:#252526;--text-color:#d4d4d4;--controls-bg:#2d2d2d;--border-color:rgba(255,255,255,0.05);--log-bg:#191919;--log-border-light:3px solid;--filter-active:#4a4ae6;--search-bg:#3e3e42;--json-bg:rgba(40,40,40,0.7);--json-key:#6aaeff;--json-tag:#5dade2;--json-string:#98c379;--json-number:#d19a66;--json-boolean:#56b6c2;--json-null:#be5046;--json-cmt:#707070;--action-bg:rgba(106,174,255,0.3);--action-hover:rgba(106,174,255,0.5);--log-icon-info:#4a4ae6;--log-bg-warn:rgba(255,193,7,0.1);--log-icon-warn:#d9a40d;--log-icon-error:#ff3b30;--clear-btn-color:#ff6b6b;--clear-btn-hover:#ff5252;--tab-bg:#333;--tab-active:#444;--tab-color:#ddd}.theme-light{--selected-bg:rgba(30,107,184,.08);--console-bg:#ffffff;--header-bg:#f0f0f0;--text-color:#333;--controls-bg:#e0e0e0;--border-color:rgba(0,0,0,0.1);--log-bg:#f3f3f3;--log-border-light:3px solid;--filter-active:#4a4ae6;--search-bg:#f0f0f0;--json-bg:rgba(240,240,240,0.9);--json-key:#1e6bb8;--json-tag:#2980b9;--json-string:#22863a;--json-number:#d73a49;--json-boolean:#005cc5;--json-null:#6f42c1;--json-cmt:#707070;--action-bg:rgba(30,107,184,0.1);--action-hover:rgba(30,107,184,0.2);--log-bg-warn:rgba(255,243,205,0.75);--log-icon-info:#1e6bb8;--log-icon-warn:#e36209;--log-icon-error:#d73a49;--clear-btn-color:#ff5252;--clear-btn-hover:#ff3b30;--tab-bg:#e5e5e5;--tab-active:#ddd;--tab-color:#333}.console-container *{outline:0;-webkit-tap-highlight-color:transparent}.console-container{background:var(--console-bg);display:flex;flex-direction:column;box-shadow:0 15px 35px rgba(0,0,0,.3);position:fixed;z-index:99999;left:0;bottom:0;width:100%;height:90vh;transform:translateY(100%);transition:transform .4s cubic-bezier(.25,.8,.25,1)}.overlay.active .console-container{transform:translateY(0)}.overlay.no-anim .console-container{transition:none!important}.network-view{display:none;flex:1;overflow:hidden;flex-direction:column;position:relative}.net-disable-btn{display:inline-flex;align-items:center;justify-content:center;border:none;background:0 0;color:var(--text-color);cursor:pointer;font-size:14px;padding:5px 10px;border-radius:5px;white-space:nowrap;transition:all .2s;opacity:.55;flex-shrink:0;margin-left:auto}.net-disable-btn:hover{opacity:1}.net-disable-btn.disabled{opacity:1;color:var(--text-color);filter:none}.network-items{flex:1;overflow-y:auto;padding:8px 12px}.net-item{padding:12px 14px;margin-bottom:8px;background:var(--log-bg);border-left:3px solid var(--json-boolean);border-radius:6px;cursor:default;transition:background .2s}.net-item:hover{background:var(--selected-bg)}.net-item.net-failed{border-left-color:#ff5252}.net-item.net-success{border-left-color:#98c379}.net-row1{display:flex;align-items:center;gap:8px;margin-bottom:4px}.net-row2{display:flex;align-items:center;gap:8px;margin-bottom:6px}.net-row3{display:flex;gap:8px;align-items:center}.net-copy-btn,.net-detail-btn{display:inline-flex;align-items:center;gap:4px;padding:4px 10px;border:none;border-radius:4px;font-size:11px;cursor:pointer;transition:all .2s}.net-copy-btn{background:var(--action-bg);color:var(--json-key)}.net-copy-btn:hover,.net-detail-btn:hover{background:var(--action-hover)}.net-detail-btn{background:var(--action-bg);color:var(--json-key)}.net-method{font-size:10px;font-weight:700;padding:2px 6px;border-radius:3px;text-transform:uppercase}.net-method-GET{background:rgba(106,174,255,.2);color:var(--json-key)}.net-method-POST{background:rgba(152,195,121,.2);color:var(--json-string)}.net-method-PUT{background:rgba(255,193,7,.2);color:#ffc107}.net-method-DELETE{background:rgba(255,82,82,.2);color:#ff5252}.net-method-PATCH{background:rgba(255,152,0,.2);color:#ff9800}.net-method-HEAD{background:rgba(190,80,70,.2);color:var(--json-null)}.net-method-OPTIONS{background:rgba(112,112,112,.2);color:var(--json-cmt)}.net-url{flex:1;font-size:12px;color:var(--text-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:100px}.net-status{font-size:11px;font-weight:700;padding:2px 6px;border-radius:3px}.net-status-2xx{background:rgba(152,195,121,.2);color:#98c379}.net-status-3xx{background:rgba(106,174,255,.2);color:var(--json-key)}.net-status-4xx{background:rgba(255,152,0,.2);color:#ff9800}.net-status-5xx{background:rgba(255,82,82,.2);color:#ff5252}.net-status-pending{background:rgba(112,112,112,.2);color:var(--json-cmt)}.net-time{font-size:11px;color:var(--json-cmt);white-space:nowrap}.net-back-btn{background:0 0;border:none;color:var(--text-color);cursor:pointer;font-size:16px;padding:4px 8px;border-radius:4px}.net-back-btn:hover{background:var(--action-bg)}.net-detail-overlay,.net-new-overlay{position:absolute;top:0;left:0;right:0;bottom:0;background:var(--console-bg);z-index:100;display:none;flex-direction:column}.net-detail-header,.net-new-header{display:flex;align-items:center;gap:8px;padding:3px 12px;background:var(--header-bg);border-bottom:1px solid var(--border-color)}.net-detail-body{flex:1;overflow-y:auto;padding:12px}.net-detail-section{margin-bottom:16px}.net-detail-label{font-size:11px;color:var(--json-cmt);text-transform:uppercase;margin-bottom:4px}.net-detail-value{font-size:13px;color:var(--text-color);word-break:break-all;background:var(--log-bg);padding:8px 10px;border-radius:4px;max-height:400px;overflow-y:auto}.net-detail-value textarea{width:100%;min-height:80px;background:var(--log-bg);border:1px solid var(--border-color);color:var(--text-color);border-radius:4px;padding:8px;font-size:12px;font-family:monospace;resize:vertical}.net-new-title{flex:1;font-size:14px;color:var(--text-color)}.net-new-body{flex:1;overflow-y:auto;padding:16px}.net-form-group{margin-bottom:14px}.net-form-label{font-size:12px;color:var(--json-cmt);margin-bottom:4px;display:block}.net-form-input,.net-form-select,.net-form-textarea{width:100%;background:var(--log-bg);border:1px solid var(--border-color);color:var(--text-color);border-radius:4px;padding:8px 10px;font-size:13px;font-family:monospace;outline:0;transition:border-color .2s}.net-form-input:focus,.net-form-select:focus,.net-form-textarea:focus{border-color:var(--filter-active)}.net-form-textarea{min-height:100px;resize:none}.net-form-select{cursor:pointer}.net-send-btn{padding:8px 20px;border:none;background:var(--filter-active);color:#fff;cursor:pointer;border-radius:4px;font-size:13px;transition:all .2s;margin-left:auto;display:block}.net-send-btn:hover{opacity:.85}.nolog{text-align:center;font-size:18px;color:var(--json-cmt);padding:40px 0;display:flex;align-items:center;justify-content:center;gap:5px}.nolog>.ico{font-size:1em;flex-shrink:0}.net-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--json-cmt);font-size:18px;gap:5px}.net-detail-section-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:4px}.net-detail-copy-section{background:0 0;border:none;color:var(--json-cmt);cursor:pointer;font-size:13px;padding:2px 6px;border-radius:3px;transition:all .2s}.net-detail-copy-section:hover{background:var(--action-bg);color:var(--json-key)}.net-detail-empty{color:var(--json-cmt);opacity:.5;font-style:italic}.net-detail-value.net-detail-code{font-family:monospace;white-space:pre-wrap;word-break:break-all;overflow-x:auto;max-height:400px}.net-detail-header-actions{display:flex;align-items:center;gap:4px;margin-left:auto}.net-resend-icon-btn,.net-copy-icon-btn{background:0 0;border:none;color:var(--text-color);cursor:pointer;font-size:16px;padding:4px 8px;border-radius:4px;transition:all .2s}.net-resend-icon-btn:hover,.net-copy-icon-btn:hover{background:var(--action-bg);color:var(--json-key)}.filters,.network-filters,.plug-view .filters{display:flex;flex-wrap:nowrap;gap:2px;margin-left:0;overflow-x:auto;overflow-y:hidden;scrollbar-width:thin;position:relative;padding-bottom:2px;min-width:0;flex:0 1 auto;-webkit-overflow-scrolling:touch}.network-filters{flex:1 1 auto}.filter-btn,.net-filter-btn{position:relative;padding:5px 10px;border:none;background:0 0;color:var(--text-color);cursor:pointer;font-size:12px;display:flex;width:auto;white-space:nowrap;border-radius:4px;opacity:.55;transition:opacity .2s,background .2s;flex-shrink:0}.filter-btn>.ico,.net-filter-btn>.ico{margin-right:5px;margin-top:2px}.filter-btn:hover,.net-filter-btn:hover{opacity:1;background:rgba(127,127,127,.14)}.filter-btn.active,.net-filter-btn.active{opacity:1;font-weight:600;background:transparent}.filter-btn.active::after,.net-filter-btn.active::after{content:'';position:absolute;width:80%;left:10%;right:auto;top:auto;height:2px;bottom:0;border-radius:3px;background:var(--filter-active)}@media(min-width:769px){.overlay{flex-direction:row;align-items:stretch;justify-content:flex-end;background:transparent;backdrop-filter:none;opacity:1;pointer-events:none}.console-container{position:relative;left:auto;bottom:auto;width:50%;height:100%;transform:translateX(100%);flex-shrink:0;pointer-events:auto}.overlay.active .console-container{transform:translateX(0)}.overlay::before{content:'';flex:1;cursor:default;pointer-events:none}.splitter{display:block;width:4px;background:var(--border-color);cursor:col-resize;flex-shrink:0;z-index:100001;position:relative;pointer-events:auto;transform:translateX(100%);transition:transform .4s cubic-bezier(.25,.8,.25,1)}.overlay.active .splitter{transform:translateX(0)}.overlay.no-anim .splitter{transition:none!important}.splitter:hover,.splitter.dragging{background:var(--filter-active)}.console-header{padding:6px 15px}.console-title{font-size:16px}.header-icon-btn,.close-btn,.clear-all-btn{width:34px;height:34px;font-size:17px}.tabs{padding:2px 10px 0}.tab-btn{padding:8px 14px;font-size:14px}.controls{padding:4px 12px;flex-wrap:nowrap}.network-controls{padding:4px 12px;flex-wrap:nowrap}}@media(max-width:768px){.splitter{display:none}}@media(max-width:768px){.overlay{flex-direction:column;align-items:center;justify-content:center}.console-container{transform:translateY(100%)!important}.overlay.active .console-container{transform:translateY(0)!important}}.console-header{display:flex;justify-content:space-between;align-items:center;padding:8px 25px;background:var(--header-bg);border-bottom:1px solid var(--border-color);position:relative}.console-title{color:var(--text-color);gap:10px;display:flex;align-items:center;font-size:18px}.header-actions{display:flex;align-items:center;gap:2px}.header-icon-btn{background:0 0;border:none;color:var(--text-color);font-size:18px;cursor:pointer;width:40px;height:40px;display:flex;align-items:center;justify-content:center;border-radius:5px;transition:all .3s}.header-icon-btn:hover{background:rgba(106,174,255,0.2);color:var(--json-key)}.close-btn{background:0 0;border:none;color:var(--text-color);font-size:20px;cursor:pointer;width:40px;height:40px;display:flex;align-items:center;justify-content:center;border-radius:5px;transition:all .3s}.close-btn:hover{background:rgba(255,100,100,.2);color:#ff6464;transform:scale(1.1)}.clear-all-btn{background:0 0;border:none;color:var(--text-color);font-size:20px;cursor:pointer;width:40px;height:40px;display:flex;align-items:center;justify-content:center;border-radius:5px;transition:all .3s}.clear-all-btn:hover,.clear-all-btn:active{background:rgba(255,100,100,.2);color:var(--clear-btn-hover)}.tabs{display:block;white-space:nowrap;overflow-x:auto;background:var(--tab-bg);padding:5px 10px 0;border-bottom:1px solid var(--border-color)}.tab-btn{padding:12px 20px;background:0 0;border-radius:5px 5px 0 0;border:none;color:var(--tab-color);cursor:pointer;position:relative;display:inline-flex;align-items:center;gap:8px}.tab-btn.active{color:var(--text-color);font-weight:600}.tab-btn.active::after{content:'';position:absolute;bottom:0;left:0;width:100%;height:2px;border-radius:3px;background:var(--filter-active)}.tab-btn:hover:not(.active){background:rgba(255,255,255,.05)}.controls{display:flex;padding:6px 15px;background:var(--controls-bg);gap:10px;flex-wrap:nowrap;border-bottom:1px solid var(--border-color);align-items:center;overflow-x:auto}.network-controls{display:flex;align-items:center;gap:8px;padding:6px 15px;background:var(--controls-bg);border-bottom:1px solid var(--border-color);flex-wrap:nowrap}.search-bar{display:flex;align-items:center;gap:8px;padding:10px 20px;background:var(--controls-bg);border-bottom:1px solid var(--border-color)}.search-input-wrap{display:flex;align-items:center;flex:1;position:relative}.search-bar-icon{position:absolute;left:10px;color:var(--text-color);opacity:.6;font-size:14px;pointer-events:none}.search-bar input{flex:1;padding:8px 10px 8px 35px;border-radius:5px;border:none;background:var(--search-bg);color:var(--text-color);transition:all .3s ease;font-size:14px;border:1px solid var(--border-color)}.search-bar input:focus{outline:0;border-color:#4a4ae6}.search-bar-close{background:0 0;border:none;color:var(--text-color);font-size:16px;cursor:pointer;padding:4px 8px;border-radius:5px;opacity:.6;transition:all .3s}.search-bar-close:hover{opacity:1;background:rgba(255,255,255,.1)}.console-content{flex:1;overflow:auto;display:flex;flex-direction:column;position:relative}.console-output{flex:1;overflow-y:auto;padding:20px;font-family:monospace;font-size:.95rem}.localstorage-view{flex:1;padding:20px;font-family:monospace;font-size:.95rem;position:relative;overflow:hidden}.ls-items{position:absolute;inset:0;overflow-y:auto;padding:20px}.log-item{padding:8px 12px;margin-bottom:6px;display:flex;flex-direction:column;border-left:3px solid #4a4ae6;background:var(--log-bg);border-radius:5px;cursor:pointer;transition:background .2s;color:var(--text-color);user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}.log-item .log-icon .ico{color:inherit}.log-item.selected{border-left-color:var(--json-key);background:var(--selected-bg)}.log-item.log{border-left-color:#4a4ae6}.log-item.info{border-left-color:var(--log-icon-info)}.log-item.warn{border-left-color:var(--log-icon-warn);background:var(--log-bg-warn)}.log-item.error{border-left-color:var(--log-icon-error);background:rgba(255,59,48,.15)}.log-item.warn.selected,.log-item.error.selected{border-left-color:var(--json-key);background:var(--selected-bg)}.log-count{background:#4a4ae6;color:#fff;border-radius:4px;min-width:20px;height:20px;display:inline-flex;align-items:center;justify-content:center;font-size:11px;margin-right:4px;padding:0 5px;flex-shrink:0}.log-icon{flex-shrink:0;display:flex;align-items:center;font-size:13px;margin-right:2px}.log-header{display:flex;align-items:center;gap:0;margin-bottom:2px}.log-content{width:100%;font-size:13px;max-height:300px;overflow-y:auto;margin-top:4px;word-break:break-word;line-height:1.5;user-select:text;-webkit-user-select:text}.timestamp{color:var(--json-cmt);font-size:11px;margin-left:4px;white-space:nowrap}.json-preview{font-family:monospace;padding:10px;margin-top:5px;background:var(--json-bg);border-radius:5px;white-space:pre!important;max-height:400px;overflow:auto}.json-tree-container{font-family:monospace;padding:2px 0;margin-top:2px;background:0 0;border-radius:0;max-height:300px;overflow:auto;font-size:12px;line-height:1.6}.tree-node{position:relative;cursor:pointer;-webkit-tap-highlight-color:transparent}.tree-node.collapsed>.tree-children{display:none}.tree-toggle{display:inline-block;width:9px;color:var(--json-cmt);text-align:center}.ico{display:inline-block;width:1em;height:1em;fill:currentColor;vertical-align:middle;flex-shrink:0}.tree-toggle>.ico{width:9px;height:9px}.tree-node.collapsed>.tree-toggle .ico-angle-down{display:none}.tree-node.expanded>.tree-toggle .ico-angle-right{display:none}.tree-spacer{display:inline-block;width:9px}.tree-leaf{white-space:pre}.tree-leaf-text{white-space:pre-wrap;word-break:break-all;max-height:8em;overflow-y:auto}.tree-label{color:var(--json-cmt)}.tree-children{margin-left:16px;padding-left:4px}.tree-brace{color:var(--json-cmt)}.tree-ellipsis{color:var(--json-cmt)}.tree-load-more{color:var(--json-cmt);cursor:pointer;padding:4px 0;user-select:none;font-size:11px}.tree-node.collapsed>.tree-open{display:none}.tree-node.collapsed>.tree-close{display:none}.tree-node.expanded>.tree-close{display:block;padding-left:16px}.tree-node.expanded>.tree-collapsed{display:none}.tree-node.collapsed>.tree-ellipsis{display:inline}.tree-node.expanded>.tree-ellipsis{display:none}.tree-node.collapsed>.tree-close-tag{display:inline}.tree-node.expanded>.tree-close-tag{display:inline}.json-number{color:var(--json-number)}.json-boolean{color:var(--json-boolean)}.json-key{color:var(--json-key)}.json-tag{color:var(--json-tag)}.json-null{color:var(--json-null)}.json-string{color:var(--json-string)}.json-cmt{color:var(--json-cmt)}.log-actions{margin-top:8px;display:flex;gap:10px;font-size:10px}.log-action{color:var(--json-key);cursor:pointer;padding:5px 10px;background:var(--action-bg);transition:all .2s;display:inline-flex;align-items:center;gap:5px;border-radius:5px}.log-action:hover{background:var(--action-hover)}.error-stack{font-family:monospace;padding:10px;margin-top:10px;background:rgba(255,59,48,.2);border-radius:5px;white-space:nowrap;font-size:.85rem;overflow:auto;max-height:400px}.object-preview{font-family:monospace;padding:10px;margin-top:5px;background:var(--json-bg);color:var(--json-number);border-radius:5px;white-space:pre;max-height:600px;overflow:auto}.function-preview{font-family:monospace;padding:10px;margin-top:5px;background:var(--json-bg);color:var(--json-boolean);border-radius:5px;white-space:pre;word-break:break-all;overflow-x:auto}.ls-item{background:var(--log-bg);padding:15px;margin-bottom:15px;border-radius:8px}.ls-key-row{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;border-bottom:1px solid var(--border-color);padding-bottom:10px}.ls-key{color:var(--json-key);font-size:16px;max-width:60%;overflow-x:auto;white-space:nowrap}.ls-actions{display:flex;gap:8px}.ls-action-btn{background:var(--action-bg);border:none;color:var(--text-color);padding:5px 10px;border-radius:5px;cursor:pointer;transition:all .2s;display:flex;align-items:center;gap:5px}.ls-action-btn:hover{background:var(--action-hover)}.ls-value{white-space:normal;word-break:break-all;padding:10px;background:var(--json-bg);border-radius:5px;font-family:monospace;max-height:200px;overflow-y:auto;color:var(--text-color);font-size:13px}.ls-value-type{font-size:8px;opacity:.7;margin-top:5px;color:var(--text-color)}.vs-spacer{width:100%;flex-shrink:0}.ls-editor-overlay{position:absolute;inset:0;z-index:100;display:flex;flex-direction:column;background:var(--console-bg)}.ls-editor-header{padding:12px 20px;background:var(--header-bg);border-bottom:1px solid var(--border-color)}.ls-editor-header-row{display:flex;align-items:center;gap:10px}.ls-editor-key-input{flex:1;padding:8px 12px;border:1px solid var(--border-color);border-radius:6px;background:var(--search-bg);color:var(--json-key);font-size:14px;font-family:monospace;outline:0;transition:border .2s}.ls-editor-key-input:focus{border-color:var(--filter-active)}.ls-editor-title{color:var(--text-color);font-size:15px;font-weight:600;white-space:nowrap}.ls-editor-body{flex:1;padding:15px 20px;overflow:hidden;display:flex}.ls-editor-body textarea{flex:1;width:100%;padding:12px;background:var(--search-bg);border:1px solid var(--border-color);border-radius:8px;color:var(--text-color);font-family:monospace;font-size:14px;resize:none;outline:0;transition:border .2s;line-height:1.5}.ls-editor-body textarea:focus{border-color:var(--filter-active)}.ls-editor-footer{display:flex;gap:10px;justify-content:flex-end;padding:12px 20px;background:var(--header-bg);border-top:1px solid var(--border-color)}.ls-editor-btn{padding:8px 24px;border:none;border-radius:6px;font-size:14px;cursor:pointer;transition:all .2s;font-weight:500}.ls-editor-btn.cancel{background:var(--controls-bg);color:var(--text-color)}.ls-editor-btn.cancel:hover{background:var(--action-hover)}.ls-editor-btn.save{background:var(--filter-active);color:#fff}.ls-editor-btn.save:hover{opacity:.85}.ls-editor-btn.run{background:var(--filter-active);color:#fff}.ls-editor-btn.run:hover{opacity:.85}.console-table-wrap{overflow-x:auto;margin-top:5px;-webkit-overflow-scrolling:touch;border-radius:8px;border:1px solid rgba(128,128,128,0.25)}.console-table{border-collapse:separate;border-spacing:0;width:100%;font-size:12px;font-family:monospace;overflow:hidden}.console-table th{background:var(--controls-bg);color:var(--json-key);padding:6px 10px;text-align:left;border-bottom:1px solid rgba(128,128,128,0.25);border-right:1px solid rgba(128,128,128,0.25);white-space:nowrap;position:sticky;top:0}.console-table td{padding:5px 10px;border-bottom:1px solid rgba(128,128,128,0.25);border-right:1px solid rgba(128,128,128,0.25);color:var(--text-color);white-space:nowrap;max-width:200px;overflow:hidden;text-overflow:ellipsis}.console-table tbody tr:nth-child(even){background:var(--log-bg)}.console-table tbody tr:hover{background:var(--action-bg)}.console-table th:last-child,.console-table td:last-child{border-right:none}.console-table tbody tr:last-child td{border-bottom:none}.ls-add-btn{font-size:18px!important;opacity:1!important;width:40px!important;height:40px!important;padding:0!important;margin-left:0!important}.mute-btn{background:0 0;border:none;color:var(--text-color);font-size:14px;cursor:pointer;padding:5px 8px;border-radius:5px;opacity:.6;transition:opacity .2s;margin-left:auto;flex-shrink:0}.mute-btn:hover{opacity:1}.mute-btn.muted{opacity:1;filter:saturate(2)}.elements-view{flex:1;overflow-y:auto;padding:10px;font-family:monospace;font-size:12px;line-height:1.6}.elements-tree .tree-node{white-space:normal;word-break:break-all}.el-header-btn{width:40px!important;height:40px!important;font-size:18px!important}.el-header-btn.el-delete-btn:hover{color:var(--clear-btn-color);background:rgba(255,100,100,.15)}.tree-node.el-highlight>.tree-label{display:inline-block!important;background:var(--action-hover)!important;border-radius:3px;padding:1px 4px}.tree-node.el-selected>.tree-label{display:inline-block!important;background:rgba(106,174,255,0.4);border-radius:3px;padding:1px 4px}.element-picker-overlay{position:fixed;top:0;left:0;width:100%;height:100%;z-index:100000;cursor:crosshair;background:transparent;pointer-events:none}@media(max-width:768px){.controls{flex-direction:row;align-items:center;padding:5px 10px;overflow-x:auto;flex-wrap:nowrap}.log-item{flex-wrap:nowrap}.log-actions{flex-wrap:wrap}.floating-console-btn{padding:12px 20px;font-size:.9rem;right:20px;bottom:20px}.tab-btn{padding:8px 12px;font-size:14px}.notification{position:fixed;top:20px;right:20px;padding:12px 20px;background:rgba(76,175,80,.6);backdrop-filter:blur(12px);color:#fff;border-radius:5px;box-shadow:0 2px 10px rgba(0,0,0,.2);z-index:99999;display:none;transform:translateX(150%);max-height:48px;max-width:calc(100vw - 40px);transition:transform .3s ease;font-size:15px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.notification.show{transform:translateX(0)}.notification.warning{background:rgba(255,152,0,.6);backdrop-filter:blur(12px)}.elements-tree .tree-leaf-text{max-height:12em}.nolog{text-align:center;font-size:20px;color:var(--json-cmt);padding:40px 0;display:flex;align-items:center;justify-content:center;gap:5px}}.network-controls{padding:5px 10px}}.overflow-scroll.overflow-start:not(.overflow-end){-webkit-mask-image:linear-gradient(to right,transparent,#000 40px);mask-image:linear-gradient(to right,transparent,#000 40px)}.overflow-scroll.overflow-end:not(.overflow-start){-webkit-mask-image:linear-gradient(to left,transparent,#000 40px);mask-image:linear-gradient(to left,transparent,#000 40px)}.overflow-scroll.overflow-start.overflow-end{-webkit-mask-image:linear-gradient(to right,transparent,#000 40px,#000 calc(100% - 40px),transparent);mask-image:linear-gradient(to right,transparent,#000 40px,#000 calc(100% - 40px),transparent)}.tree-toggle>.ico{font-size:10px;color:var(--json-cmt);transition:transform .2s;cursor:pointer;width:9px;height:9px;text-align:center;display:inline-block}.network-view{display:none;flex:1;overflow:hidden;flex-direction:column;position:relative}",t.setAttribute("tcstyle",""),t.setAttribute("tc-lock",""),this.shadowRoot.append(t)}setupSplitter(){let t=!1,e=0,s=0,i=()=>{t=!1,this.splitter.classList.remove("dragging"),document.body.style.cursor="",document.body.style.userSelect=""};this.splitter.addEventListener("mousedown",i=>{i.preventDefault(),t=!0,e=i.clientX,s=this.consoleContainer.offsetWidth||.5*window.innerWidth,this.splitter.classList.add("dragging"),document.body.style.cursor="col-resize",document.body.style.userSelect="none"}),document.addEventListener("mousemove",i=>{if(!t)return;let n=i.clientX,o=window.innerWidth-(s+(e-n));o=Math.max(200,Math.min(window.innerWidth-50,o)),this.consoleContainer&&(this.consoleContainer.style.width=o+"px",this.consoleContainer.style.flex="none")}),document.addEventListener("mouseup",i),this.splitter.addEventListener("touchstart",e=>{e.preventDefault(),t=!0,s=this.consoleContainer.offsetWidth||.5*window.innerWidth,e.touches[0],this.splitter.classList.add("dragging")}),document.addEventListener("touchmove",e=>{if(!t)return;let s=e.touches[0],i=window.innerWidth-s.clientX;i=Math.max(200,Math.min(window.innerWidth-50,i)),this.consoleContainer&&(this.consoleContainer.style.width=i+"px",this.consoleContainer.style.flex="none")}),document.addEventListener("touchend",i)}showNotification(t,e=""){this.notification.innerHTML='<span style="display:inline-block;vertical-align:middle;margin-right:8px">'+this.icon("warning"==e?"exclamation":"check")+"</span>"+t.replace(/</,"<").replace(/>/,">"),this.notification.className="notification","warning"===e&&this.notification.classList.add("warning"),this.notification.style.display="block",this.notification.offsetHeight,this.notification.classList.add("show"),clearTimeout(this._notifTimer),this._notifTimer=setTimeout(()=>{this.notification.classList.remove("show"),setTimeout(()=>{this.notification.style.display="none"},300)},3e3)}captureConsoleLogs(){this.originalConsole={log:console.log,info:console.info,warn:console.warn,error:console.error,debug:console.debug,time:console.time,timeEnd:console.timeEnd,count:console.count,countReset:console.countReset,assert:console.assert,trace:console.trace,group:console.group,groupEnd:console.groupEnd,clear:console.clear,table:console.table},console.log=(...t)=>(this.captureConsole("log",...t),console),console.info=(...t)=>(this.captureConsole("info",...t),console),console.warn=(...t)=>(this.captureConsole("warn",...t),console),console.error=(...t)=>(this.captureConsole("error",...t),console),console.debug=(...t)=>(this.captureConsole("log",...t),console),console.table=(t,e)=>(this._captureSubType="table",this._captureExtra={columns:e},this.captureConsole("log",t),this._captureSubType=null,this._captureExtra=null,console),console.time=(t="time")=>{t=String(t);let e=performance.now();this.timerMap.has(t)&&clearTimeout(this.timerMap.get(t).timeoutId);let s=setTimeout(()=>{if(!this.timerMap.has(t))return;let{start:e}=this.timerMap.get(t);this.timerMap.delete(t),console.info(`[time] "${t}"用时: ${(performance.now()-e).toFixed(1)}ms(已超时)`)},3e5);this.timerMap.set(t,{start:e,timeoutId:s}),console},console.timeEnd=(t="time")=>{t=String(t);let e=this.timerMap.get(t);if(!e)return void console.error(`[timeEnd] 标签"${t}"不存在`);e.timeoutId&&clearTimeout(e.timeoutId);let s=performance.now()-e.start;this.timerMap.delete(t),console.info(`[time] "${t}"用时: ${s.toFixed(1)}ms`),console},console.count=(t="count")=>{t=String(t);let e=(this.countMap.get(t)||0)+1;this.countMap.set(t,e),console.info(`[count] 标签"${t}"被调用了${e}次`),console},console.countReset=(t="count")=>{t=String(t),this.countMap.has(t)?this.countMap.delete(t):console.error(`[countReset] 标签"${t}"不存在`),console},console.assert=(t,...e)=>{t||console.error("[assertion failed] ",...e),console},console.trace=(...t)=>{let e=(new Error).stack.split("\n").slice(2).join("\n");console.warn("[trace] ",...t,"\n"+e),console},console.group=t=>(this.captureConsole("log",`[Group ${t}]`),console),console.groupEnd=()=>(this.captureConsole("log","[GroupEnd]"),console),console.clear=()=>(this.clearAllLogs(!0),console)}isClass(t){return"function"==typeof t&&t.prototype&&t.prototype.constructor===t&&!1===Object.getOwnPropertyDescriptor(t,"prototype").writable}renderFunctionInline(t){let e=t.name||"anonymous",s=this.getParams(t);return'<span class="json-boolean">ƒ '+this.escapeHtml(e)+'</span><span class="json-cmt">('+this.escapeHtml(s)+")</span>"}renderFunctionCollapsed(t){let e=t.name||"anonymous",s=this.getParams(t);return'<span class="json-boolean">ƒ '+this.escapeHtml(e)+'</span><span class="json-cmt">('+this.escapeHtml(s)+")</span>"}safeStringify(t,s=2,i=!0){let n=new WeakSet,o=(t,e=new WeakSet)=>null===t||"object"!=typeof t?"bigint"==typeof t?""+t.toString()+"n":t:e.has(t)?"[循环引用]":(e.add(t),t instanceof RegExp?""+t.toString():t instanceof Date?""+t.toISOString():"function"==typeof t?this.isClass(t)?"[Class "+(t.name||"anonymous")+"]":"ƒ "+(t.name||"anonymous")+"("+this.getParams(t)+")":t instanceof Error?"[Error: "+t.message+"]":t instanceof ArrayBuffer?"[ArrayBuffer "+t.byteLength+" bytes]":t instanceof WeakMap?"[WeakMap]":t instanceof WeakSet?"[WeakSet]":t instanceof Map?"[Map "+t.size+"]":t instanceof Set?"[Set "+t.size+"]":Array.isArray(t)?t.map(t=>o(t,e)):(()=>{let s={};try{Reflect.ownKeys(t).forEach(i=>{let n=Object.getOwnPropertyDescriptor(t,i);if(n){let r="symbol"==typeof i?"["+i.toString()+"]":String(i);if("value"in n)s[r]=o(n.value,e);else if(n.get)try{s[r]=o(n.get.call(t),e)}catch{s[r]="[getter]"}}})}catch{}let n=Object.getPrototypeOf(t);return i&&n&&null!==n&&(s["[[Prototype]]"]=o(n,e)),s})());return t=o(t),JSON.stringify(t,function(t,s){if(void 0===s)return"undefined";if("number"==typeof s){if(Number.isNaN(s))return"NaN";if(!isFinite(s))return""+(s>0?"Infinity":"-Infinity")}if("object"==typeof s&&null!==s){if(n.has(s))return"[循环引用]";if(n.add(s),!Array.isArray(s)&&s.constructor===Object)return Object.keys(s).sort((t,e)=>{let s="[[Prototype]]"===t,i="[[Prototype]]"===e,n=t.endsWith("[[Prototype]]")&&"[[Prototype]]"!==t,o=e.endsWith("[[Prototype]]")&&"[[Prototype]]"!==e;if(s&&!i)return 1;if(!s&&i)return-1;if(n&&!o)return 1;if(!n&&o)return-1;let r=t.match(/^(_*)/)[0].length,l=e.match(/^(_*)/)[0].length;return r!==l?r-l:t.localeCompare(e,void 0,{numeric:!0,sensitivity:"base"})}).reduce((t,e)=>(t[e]=s[e],t),{});if(s instanceof Error)return{"名称":s.name,"信息":s.message,"堆栈":s.stack};if(s instanceof Date)return s.toISOString();if(s instanceof HTMLElement)return`<${s.tagName.toLowerCase()}>${s.tagName.toLowerCase()}元素</${s.tagName.toLowerCase()}>`}return"string"==typeof s?s.startsWith("")?s:""+s:"function"==typeof s?""+(e.tC.isClass(s)?`[Class ${s.name||"anonymous"}]`:`ƒ ${s.name||"anonymous"}(${e.tC.getParams(s)})`):s},s)}formatArgsForPlainText(t){return Array.from(t).map(t=>{if("function"==typeof t)return this.isClass(t)?`[Class ${t.name||"anonymous"}]`:`ƒ ${t.name||"anonymous"}(${this.getParams(t)})`;if("object"==typeof t&&null!==t)try{return this.safeStringify(t).replace(/\\u000[23]/g,"")}catch{return"无法序列化]"}return String(t)}).join(" ")}captureConsole(t,...e){if(this._capturing)this.originalConsole[t].apply(console,e);else{this._capturing=!0;try{this.triggerGlobalHook("beforeLog",t,...e);let s=!1;if(this.mutedFilters.console&&(this.mutedFilters.console.all||this.mutedFilters.console[t])&&(s=!0),this.mutedLogs||s)return void this.originalConsole[t].apply(console,e);let i=new Date,n=e.map(t=>{if("object"==typeof t&&null!==t)try{if(t instanceof HTMLElement)return`el:<${t.tagName.toLowerCase()}>`;if(t instanceof Date)return`d:${t.getTime()}`;if(t instanceof RegExp)return`re:${t.toString()}`;if(t instanceof Error)return`e:${t.message}`;let e=Object.entries(t).reduce((t,[e,s])=>{if("then"===e&&"function"==typeof s)return t;if("object"==typeof s&&null!==s)try{t[e]=JSON.stringify(s)}catch{t[e]="NestedObject"}else t[e]=s;return t},{});return`o:${JSON.stringify(e)}`}catch{return`u:${Math.random().toString(36).substring(2,10)}`}return`${typeof t}:${String(t)}`}).join("|");if(this.lastLog&&this.lastLog.type===t&&this.lastLog.contentSign===n&&(this.lastLog.subType||null)===(this._captureSubType||null)&&!e.some(t=>"object"==typeof t&&null!==t)){this.lastLog.args=[...e],this.lastLog.timestamp=new Date,this.lastLog.count++;let s=this.shadowRoot.getElementById(`log-item-${this.lastLog.id}`);if(s){let t=s.querySelector(".log-count");if(t)t.textContent=this.lastLog.count;else{let t=s.querySelector(".log-header");if(t){let e=document.createElement("div");e.className="log-count",e.textContent=this.lastLog.count;let s=t.querySelector(".log-icon");s?t.insertBefore(e,s):t.appendChild(e)}}}return this.originalConsole[t].apply(console,e),void this.updateFilterCounts()}{let s={id:this.logs.length,type:t,args:[...e],content:this.formatArgsForPlainText(e),timestamp:i,count:1,expandedJson:!1,contentSign:n,hasObject:e.some(t=>"function"==typeof t),isError:"error"===t||e.some(t=>t instanceof Error),subType:this._captureSubType||null,subTypeData:this._captureExtra||null};this.logs.push(s),this.lastLog=s,this.triggerGlobalHook("afterLog",s)}this.originalConsole[t].apply(console,e),this.overlay?.classList.contains("active")&&"console"===this.currentTab&&(this.updateFilterCounts(),this.renderLogList(this.logs,!1)),this.logs.length>this.maxLog&&this.logs.splice(0,this.logs.length-this.maxLog)}finally{this._capturing=!1}}}formatArgs(t,e){let s=e||"x",i=Array.from(t),n=i.map(t=>"function"==typeof t?`<div class="function-preview">${this.escapeHtml(t.toString())}</div>`:t instanceof Error?`<div class="error-stack"><strong>${t.name}:</strong>${t.message}<div>${t.stack||"无堆栈信息"}</div></div>`:t instanceof HTMLElement?'<div class="json-tree-container">'+this.renderHTMLTree(t,"",s+":html")+"</div>":t instanceof Date?`<div class="json-preview"><span class="json-string">${t.toISOString()}</span></div>`:t instanceof RegExp?`<div class="json-preview"><span class="json-number">${t.toString()}</span></div>`:t instanceof Map?`<div class="json-preview"><span class="json-boolean">[Map ${t.size}]</span></div>`:t instanceof Set?`<div class="json-preview"><span class="json-boolean">[Set ${t.size}]</span></div>`:t instanceof WeakMap?'<div class="json-preview"><span class="json-boolean">[WeakMap]</span></div>':t instanceof WeakSet?'<div class="json-preview"><span class="json-boolean">[WeakSet]</span></div>':t instanceof ArrayBuffer?`<div class="json-preview"><span class="json-boolean">[ArrayBuffer ${t.byteLength} bytes]</span></div>`:this.fmtVal(t,s,0));return i.splice(0,1),n.join(" ")}fmtVal(t,s,i){return"bigint"==typeof t?`<span class="json-number">${t.toString()}n</span>`:t&&"object"==typeof t?'<div class="json-tree-container">'+this.renderJSONTree(t,"",null,null,s+(i?":r:":":"),0)+"</div>":"number"==typeof t?Number.isNaN(t)?'<span class="json-cmt">NaN</span>':isFinite(t)?`<span class="json-number">${t}</span>`:`<span class="json-cmt">${t>0?"Infinity":"-Infinity"}</span>`:"boolean"==typeof t?`<span class="json-boolean">${t}</span>`:String(t).replace(/</g,"<").replace(/>/g,">").replace(/\n/g,"<br>")}highlightHTML(t){let e=t.outerHTML.replace(/</g,"<").replace(/>/g,">").replace(/<br>/g,"<br>"),s="",i=0;for(;i<e.length;)if(e.startsWith("<",i)){let t=e[i+4];if(t&&("/"===t||/[a-zA-Z]/.test(t))){let t=e.indexOf(">",i);if(-1!==t){let n=e.slice(i,t+4);n=n.replace(/([\w-]+)(=)("[^"]*")/g,'<span class="json-tag">$1</span><span class="json-boolean">$2</span><span class="json-string">$3</span>'),n=n.replace(/^(<\/?)([\w-]+)/,'<span class="json-tag">$1</span><span class="json-tag">$2</span>'),n=n.replace(/(>)$/,'<span class="json-tag">$1</span>'),s+=n,i=t+4;continue}}let n=e.indexOf("<",i+4);-1===n&&(n=e.length);let o=e.slice(i,n);s+=o.trim()?`<span class="json-cmt">${o}</span>`:o,i=n}else if(e.startsWith("<br>",i))s+="<br>",i+=4;else{let t=e.indexOf("<",i);-1===t&&(t=e.length);let n=e.slice(i,t);s+=n.trim()?`<span class="json-cmt">${n}</span>`:n,i=t}return s}highlightJson=t=>t&&t.replace(/("(?:\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(?:\s*:)?|\b(?:true|false|null)\b|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b|[\{\}\[\],.:])/g,t=>{let e="json-cmt";if("true"===t||"false"===t)e="json-boolean";else if("null"===t)e="json-null";else if(/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(t))e="json-number";else if(t.endsWith(":"))e="json-key";else if(t.startsWith('"')){let s=t.slice(1,-1);if(/^\\u0002/.test(s))return`<span class="json-string">"${s.slice(6)}"</span>`;if(/^\\u0003/.test(s)){let t=s.slice(6);if(/^-?\d+n$/.test(t))return`<span class="json-number">${t}</span>`;if(/^\u0192\s/.test(t)){let e=t.match(/^(\u0192\s+\S+)(\(.*\))$/);return e?`<span class="json-boolean">${e[1]}</span><span class="json-cmt">${e[2]}</span>`:`<span class="json-boolean">${t}</span>`}return/^\[(?:Class|ArrayBuffer|Map|Set|WeakMap|WeakSet|Error)/.test(t)?`<span class="json-boolean">${t}</span>`:/^\/.*\/[gimsuy]*$/.test(t)?`<span class="json-number">${t}</span>`:/^\d{4}-\d{2}-\d{2}T/.test(t)?`<span class="json-string">${t}</span>`:/^(?:undefined|NaN|Infinity|-Infinity)$/.test(t)?`<span class="json-null">${t}</span>`:`<span class="json-string">${t}</span>`}e="json-string"}return`<span class="${e}">${t}</span>`})||"";renderJSONValue(t,e){if(null===t)return'<span class="json-null">null</span>';if(void 0===t)return'<span class="json-null">undefined</span>';if("string"==typeof t)return'<span class="json-string">"'+this.escapeHtml(t)+'"</span>';if("number"==typeof t)return'<span class="json-number">'+t+"</span>";if("boolean"==typeof t)return'<span class="json-boolean">'+t+"</span>";if("function"==typeof t){if(this.isClass(t)){let e=t.name||"anonymous";return'<span class="json-boolean">[Class '+this.escapeHtml(e)+"]</span>"}return this.renderFunctionInline(t)}if(t instanceof HTMLElement){let e=t.tagName.toLowerCase();return'<span class="json-tag"><'+e+">...</"+e+"></span>"}let s=Array.isArray(t),i=s?"Array("+t.length+")":"Object",n=s?t.map((t,e)=>({name:String(e),value:t})):Object.keys(t).map(e=>({name:e,value:t[e]}));if(0===n.length)return'<span class="json-cmt">'+(e?this.escapeHtml(e)+": ":"")+(s?"[]":"{}")+"</span>";let o='<div class="tree-node collapsed">';o+=this.treeToggleHtml(),e&&(o+='<span class="json-key">'+this.escapeHtml(e)+":</span> "),o+='<span class="tree-label">'+this.escapeHtml(i)+"</span>",o+='<span class="tree-brace tree-open">{</span><span class="tree-brace tree-collapsed">{...}</span>';let r=++this.treeNodeRegId;return this.treeNodeRegistry.set(r,{obj:t,children:n,isJsonValue:!0}),o+='<div class="tree-children" data-lazy-id="'+r+'"></div>',o+='<span class="tree-brace tree-close">}</span>',o+="</div>",o}renderJSONValueChildren(t,e){let s="";for(let e of t){let t=e.value;s+=null===t||"object"!=typeof t?'<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-key">'+this.escapeHtml(e.name)+":</span> "+this.renderJSONValue(t,"")+"</div>":"<div>"+this.renderJSONValue(t,e.name)+"</div>"}return s}toggleExpandJson(t){let e=this.logs.find(e=>e.id===t);e&&(e.expandedJson=!e.expandedJson,this.updateLogItem(t,!1))}updateLogItem(t,e=!1){let s=this.logs.find(e=>e.id===t);if(!s)return;let i=this.shadowRoot.getElementById(`log-item-${t}`);if(!i)return;let n={info:"info-circle",warn:"exclamation-triangle",error:"times-circle",log:"info"}[s.type]||"info",o=s.timestamp.toLocaleTimeString(),r=s.expandedJson?this.formatArgs(s.args,s.id):this.renderLogContent(s);i.innerHTML=`<div class="log-header">${s.count>1?`<div class="log-count">${s.count}</div>`:""}<div class="log-icon">${this.icon(n)}</div><div class="timestamp">${o}</div></div><div class="log-content">${r}</div>${s.hasObject?`<div class="log-actions"><div class="log-action expand-btn" title="${s.expandedJson?"收起":"展开"}" onclick="thinConsole.tC.toggleExpandJson(${s.id})">${this.icon(s.expandedJson?"chevron-up":"chevron-down")}${s.expandedJson?"收起":"展开"}</div></div>`:""}</div>`}updateControlsVisibility(){let c=this.currentTab,e="console"===c,s="localstorage"===c,i="network"===c,l="elements"===c,_=(t,v)=>{t&&(t.style.display=v)};_(this.consoleControls,e||s?"flex":"none"),_(this.filtersContainerEl,e?"flex":"none"),_(this.lsFiltersContainer,s?"flex":"none"),_(this.muteBtn,e?"flex":"none"),_(this.logCopyBtn,e&&null!==this.selectedLogId?"flex":"none"),_(this.lsAddBtn,s?"flex":"none"),_(this.netNewBtn,i?"flex":"none"),_(this.elementPickBtn,l?"flex":"none"),_(this.elCopyBtn,l&&this.selectedElement?"flex":"none"),_(this.elDeleteBtn,l&&this.selectedElement?"flex":"none"),_(this.searchBar,l?"none":this.searchExpanded?"flex":"none"),_(this.searchToggleBtn,l?"none":"flex"),this.updateEditorVisibility()}updateEditorVisibility(){if(!this.lsEditorOverlay)return;let t=this.editorState.visible;if(t&&"ls"===this.editorState.mode&&"localstorage"!==this.currentTab&&(t=!1),this.lsEditorOverlay.style.display=t?"flex":"none",t){let t="code"===this.editorState.mode;this.lsEditorKeyInput&&(this.lsEditorKeyInput.style.display=t?"none":"block"),this.lsEditorTitle.textContent=t?"运行代码":"",this.lsEditorInput.placeholder=t?"输入要执行的代码...":"输入值...",this.lsEditorSave.textContent=t?"运行":"保存",this.lsEditorSave.className="ls-editor-btn "+(t?"run":"save"),this.lsEditorInput.value!==this.editorState.value&&(this.lsEditorInput.value=this.editorState.value),!t&&this.lsEditorKeyInput&&this.lsEditorKeyInput.value!==this.editorState.key&&(this.lsEditorKeyInput.value=this.editorState.key)}}vsInit(t){if(!t)return;t._vs={items:[],renderItem:null,afterRender:null,avgHeight:70,estHeight:70,heights:new Map,lastStart:-1,lastEnd:-1,rafId:null,isAtBottom:!0,contentEl:null,topSpacer:null,bottomSpacer:null,fakeEl:null,hasStructure:!1,topSpaceHeight:0,lastScrollTop:0,lastTimestamp:0,speedToleranceFactor:100,maxSpeedTolerance:2e3,minSpeedTolerance:100};let e=document.createElement("div");e.className="vs-spacer",e.style.cssText="width:100%;flex-shrink:0;height:0";let s=document.createElement("div");s.className="vs-content",s.style.cssText="width:100%";let i=document.createElement("div");i.className="vs-spacer",i.style.cssText="width:100%;flex-shrink:0;height:0";let n=document.createElement("div");n.style.cssText="position:absolute;visibility:hidden;left:0;top:0;width:100%;pointer-events:none",t.innerHTML="",t.appendChild(e),t.appendChild(s),t.appendChild(i),t.appendChild(n),t._vs.topSpacer=e,t._vs.contentEl=s,t._vs.bottomSpacer=i,t._vs.fakeEl=n,t._vs.hasStructure=!0,t._vs.scrollHandler=()=>{let e=t._vs;if(!e)return;let s=t.scrollHeight,i=t.clientHeight,n=t.scrollTop;e.isAtBottom=Math.abs(s-i-n)<2;let o,r,l=Date.now(),a=l-e.lastTimestamp,c=n-e.lastScrollTop,d=Math.abs(c/(a||1))*e.speedToleranceFactor;a>1e3&&(d=1e3),d>e.maxSpeedTolerance&&(d=e.maxSpeedTolerance),d<e.minSpeedTolerance&&(d=e.minSpeedTolerance),e.lastScrollTop=n,e.lastTimestamp=l,e.lastScrollTop<n?(o=e.minSpeedTolerance,r=d):(o=d,r=e.minSpeedTolerance),e.topSpaceHeight<n-o&&e.topSpaceHeight+e.contentEl.offsetHeight>n+i+r||e.rafId||(e.rafId=requestAnimationFrame(()=>{e.rafId=null,this.vsRender(t)}))},t.addEventListener("scroll",t._vs.scrollHandler,{passive:!0})}vsRender(t){let e=t._vs;if(!e||!e.contentEl)return;if(!e.items||!e.items.length)return;let ch=e.contentEl.children;if(ch.length>0){let ct=0;for(let ci=0;ci<ch.length;ci++){let ch2=ch[ci].offsetHeight+10;e.heights.set(e.lastStart+ci,ch2),ct+=ch2}let ca=ct/ch.length;ca>20&&ca<2e3&&(e.avgHeight=Math.round(.5*e.avgHeight+.5*ca))}let s=t.clientHeight||400,i=t.scrollTop,n=e.avgHeight||70;n<10&&(n=70);let o=600,r=i-o,l=i+s+o,a=0,c=0,d=0,h=e.items.length,p=!1;for(let t=0;t<e.items.length;t++){let s=e.heights.get(t)||n;if(!p&&a+s>=r&&(d=t,p=!0),a>=l){h=t;break}a+=s}if(p){if(h===e.items.length){h=e.items.length;let t=h;for(;t>d&&c<s+o;)t--,c+=e.heights.get(t)||n;d=Math.max(0,Math.min(d,t))}}else d=0;let u=!1;for(let t=d;t<h;t++)if(!e.heights.has(t)){u=!0;break}if(u&&e.fakeEl){let s=e.fakeEl,i=t.clientWidth;i>0&&(s.style.width=i+"px");for(let t=d;t<h;t++)if(!e.heights.has(t)){s.innerHTML=e.renderItem(e.items[t],t);let i=0;s.firstChild&&(i=s.firstChild.offsetHeight+10),i<10&&(i=n),e.heights.set(t,i)}s.innerHTML=""}a=0,c=0,d=0,h=e.items.length,p=!1;for(let t=0;t<e.items.length;t++){let s=e.heights.get(t)||n;if(!p&&a+s>=r&&(d=t,p=!0),a>=l){h=t;break}a+=s}if(p){if(h===e.items.length){h=e.items.length;let t=h;for(;t>d&&c<s+o;)t--,c+=e.heights.get(t)||n;d=Math.max(0,Math.min(d,t))}}else d=0;if(d===e.lastStart&&h===e.lastEnd){let th=0;for(let ti=0;ti<d;ti++)th+=e.heights.get(ti)||n;let bh=0;for(let bi=h;bi<e.items.length;bi++)bh+=e.heights.get(bi)||n;return e.topSpacer.style.height=th+"px",e.bottomSpacer.style.height=bh+"px",e.topSpaceHeight=th,void(0===bh&&e.isAtBottom&&(t.scrollTop=1e7))}e.lastStart=d,e.lastEnd=h;let g=0;for(let t=0;t<d;t++)g+=e.heights.get(t)||n;let f=0;for(let t=h;t<e.items.length;t++)f+=e.heights.get(t)||n;let m=t.scrollTop;e.topSpacer.style.height=g+"px",e.bottomSpacer.style.height=f+"px",e.topSpaceHeight=g;let b=document.createDocumentFragment();for(let t=d;t<h;t++){let s=document.createElement("div");for(s.innerHTML=e.renderItem(e.items[t],t);s.firstChild;)b.appendChild(s.firstChild)}e.contentEl.replaceChildren?e.contentEl.replaceChildren(b):(e.contentEl.innerHTML="",e.contentEl.appendChild(b));let y=e.contentEl.children;if(y.length>=1){let t=0;for(let s=0;s<y.length;s++){let i=y[s].offsetHeight+10;t+=i,Math.abs(i-(e.heights.get(d+s)||n))>5&&e.heights.set(d+s,i)}let s=Math.round(t/y.length);s>20&&s<2e3&&(e.avgHeight=Math.round(.5*e.avgHeight+.5*s))}if(0===f&&y.length>0){let t=0;for(let e=0;e<y.length;e++)t+=y[e].offsetHeight+10;if(t<s&&d>0){let i=Math.ceil((s-t)/n)+2,o=Math.max(0,d-i);if(o<d){d=o,e.lastStart=d;let t=0;for(let s=0;s<d;s++)t+=e.heights.get(s)||n;e.topSpacer.style.height=t+"px",e.topSpaceHeight=t;let s=document.createDocumentFragment();for(let t=d;t<h;t++){let i=document.createElement("div");for(i.innerHTML=e.renderItem(e.items[t],t);i.firstChild;)s.appendChild(i.firstChild)}e.contentEl.replaceChildren?e.contentEl.replaceChildren(s):(e.contentEl.innerHTML="",e.contentEl.appendChild(s));let i=e.contentEl.children;if(i.length>=1){let t=0;for(let s=0;s<i.length;s++){let o=i[s].offsetHeight+10;t+=o,Math.abs(o-(e.heights.get(d+s)||n))>5&&e.heights.set(d+s,o)}let s=Math.round(t/i.length);s>20&&s<2e3&&(e.avgHeight=Math.round(.5*e.avgHeight+.5*s))}}}}let v=0;for(let t=0;t<d;t++)v+=e.heights.get(t)||n;let x=0;for(let t=h;t<e.items.length;t++)x+=e.heights.get(t)||n;e.topSpacer.style.height=v+"px",e.bottomSpacer.style.height=x+"px",e.topSpaceHeight=v,e.isAtBottom||m===t.scrollTop||(t.scrollTop=m),e.afterRender&&e.afterRender()}vsUpdate(t,e,s,i,n){let o=t._vs;if(!o)return;o.rafId&&(cancelAnimationFrame(o.rafId),o.rafId=null);let g=n&&n.trackBy?o.trackBy=n.trackBy:o.trackBy||(t=>t.id);if(!e||!e.length)return o.items=[],o.heights=new Map,o.lastStart=-1,o.lastEnd=-1,void(o.contentEl?(o.topSpacer.style.height="0",o.bottomSpacer.style.height="0",o.topSpaceHeight=0,o.contentEl.innerHTML=n&&n.emptyHTML||"",!(n&&n.preserveScroll)&&(t.scrollTop=0),o.isAtBottom=!0):t.innerHTML=n&&n.emptyHTML||"");let r=(!n||!n.force&&!n.preserveScroll)&&(o.isAtBottom=Math.abs(t.scrollHeight-t.clientHeight-t.scrollTop)<2),l=o.items?o.items.length:0,a=l>0&&o.items[0]&&e[0]&&g(o.items[0])!==g(e[0]);if(o.items=e,o.renderItem=s,n&&n.force?(o.avgHeight=i||70,o.isAtBottom=!1):o.avgHeight<10&&(o.avgHeight=i||100),o.afterRender=null,r)o.heights=new Map,o.lastStart=-1,o.lastEnd=-1,this.vsRender(t),o.isAtBottom&&(t.scrollTop=t.scrollHeight);else if((!n||!n.force)&&l>0&&e.length>=l&&!a&&o.lastEnd>=0){let h=0;for(let m=o.lastEnd;m<e.length;m++)h+=o.heights.get(m)||o.avgHeight;o.bottomSpacer.style.height=h+"px"}else o.heights=new Map,o.lastStart=-1,o.lastEnd=-1,n&&n.force&&!(n&&n.preserveScroll)&&(t.scrollTop=0),this.vsRender(t)}renderSubTypeContent(t){let e=t.args&&t.args.length>0?t.args[0]:void 0;return"table"===t.subType?this.renderTableHTML(e,t.subTypeData?.columns):""}_treeNodeOpen(t,e,s,i){let n="tree-node "+(t?"expanded":"collapsed"),o=e+'="'+this.escapeHtml(s)+'"';return i&&(o+=" "+i),'<div class="'+n+'" '+o+">"}_treeNodeChildrenLazy(t,e){return this.treeNodeRegistry.set(t,e),'<div class="tree-children" data-lazy-id="'+t+'"></div>'}_treeShadowNode(t,e,s,i,n,o){let r="tree-node "+(t?"expanded":"collapsed"),l=e+'="'+this.escapeHtml(String(s))+'"';return o&&(l+=" "+o),'<div class="'+r+'" '+l+">"+this.treeToggleHtml()+'<span class="tree-label json-null">#shadow('+i+')</span><span class="tree-ellipsis">...</span><div class="tree-children">'+n+"</div></div>"}renderJSONTree(t,e,s,i,n,o,r){if("string"==typeof t&&!s)try{let p=JSON.parse(t);return null==p||"object"!=typeof p?this.highlightJson(this.escapeHtml(t)):'<div class="json-tree-container">'+this.renderJSONTree(p,"",0,0,n,0,!0)+"</div>"}catch{return'<span style="color:var(--json-cmt);white-space:pre-wrap;word-break:break-all">'+this.escapeHtml(t)+"</span>"}if(s||(s=new WeakSet),i||(i=[]),o=o||0,null===t)return'<span class="json-null">null</span>';if(void 0===t)return'<span class="json-null">undefined</span>';if("string"==typeof t)return'<span class="json-string">"'+this.escapeHtml(t)+'"</span>';if("number"==typeof t)return'<span class="json-number">'+t+"</span>";if("boolean"==typeof t)return'<span class="json-boolean">'+t+"</span>";if("bigint"==typeof t)return'<span class="json-number">'+t.toString()+"n</span>";if("symbol"==typeof t){let e=Object.create(Object.getPrototypeOf(Object(t)));Object.defineProperty(e,"value",{value:t.toString(),enumerable:!0,writable:!0,configurable:!0}),Object.defineProperty(e,"description",{value:t.description,enumerable:!0,writable:!0,configurable:!0}),t=e}if("function"==typeof t){if(this.isClass(t)){let e=t.name||"anonymous";return'<span class="json-boolean">[Class '+this.escapeHtml(e)+"]</span>"}return this.renderFunctionInline(t)}if(t instanceof Date)return'<span class="json-string">'+t.toISOString()+"</span>";if(t instanceof RegExp)return'<span class="json-number">'+t.toString()+"</span>";if(t instanceof Map)return'<span class="json-boolean">[Map '+t.size+"]</span>";if(t instanceof Set)return'<span class="json-boolean">[Set '+t.size+"]</span>";if(t instanceof WeakMap)return'<span class="json-boolean">[WeakMap]</span>';if(t instanceof WeakSet)return'<span class="json-boolean">[WeakSet]</span>';if(t instanceof ArrayBuffer)return'<span class="json-boolean">[ArrayBuffer '+t.byteLength+" bytes]</span>";if(t instanceof Error)return'<span class="json-boolean">[Error: '+this.escapeHtml(t.message)+"]</span>";if(t instanceof HTMLElement){let e=t.tagName.toLowerCase();return'<span class="json-tag"><'+e+">...</"+e+"></span>"}if(s.has(t))return'<span class="json-cmt">[循环引用]</span>';s.add(t);let l=i.concat([t]),a=Array.isArray(t),c=a?"Array("+t.length+")":t.constructor&&t.constructor.name?t.constructor.name:"Object",d=[];try{Reflect.ownKeys(t).forEach(e=>{let s=Object.getOwnPropertyDescriptor(t,e);s&&d.push({name:String(e),desc:s})})}catch(e){try{Object.keys(t).forEach(e=>{let s=Object.getOwnPropertyDescriptor(t,e);s&&d.push({name:String(e),desc:s})})}catch(e){return s.delete(t),'<span class="json-boolean">['+this.escapeHtml(c)+"]</span>"}}let h=Object.getPrototypeOf(t);if(!r&&h&&null!==h&&d.push({name:"[[Prototype]]",desc:{value:h,enumerable:!0,writable:!0,configurable:!0}}),0===d.length)return s.delete(t),a?'<span class="json-cmt">'+(e?this.escapeHtml(e)+": ":"")+"[]</span>":'<span class="json-cmt">'+(e?this.escapeHtml(e)+": ":"")+"{}</span>";a||d.sort((t,e)=>{if("[[Prototype]]"===t.name)return 1;if("[[Prototype]]"===e.name)return-1;let s=!(!t.desc.get&&!t.desc.set),i=!(!e.desc.get&&!e.desc.set);if(s&&!i)return 1;if(!s&&i)return-1;let n=(t.name.match(/^(_*)/)||[""])[0].length,o=(e.name.match(/^(_*)/)||[""])[0].length;if(n!==o)return n-o;let r=/^[A-Z]/.test(t.name),l=/^[A-Z]/.test(e.name);return r&&!l?1:!r&&l?-1:t.name.localeCompare(e.name,void 0,{numeric:!0,sensitivity:"base"})});let p=n||"",u=this.expandedTreePaths.has(p),g=this._treeNodeOpen(u,"data-tree-path",p);if(g+=this.treeToggleHtml(),e&&(g+='<span class="json-key">'+this.escapeHtml(e)+":</span> "),g+='<span class="tree-label">'+this.escapeHtml(c)+"</span>",g+='<span class="tree-brace tree-open">{</span><span class="tree-brace tree-collapsed">{...}</span>',u){g+='<div class="tree-children">';let t=200;if(d.length>t){let e=this.treeNodeRegId++;this.treeNodeRegistry.set(e,{children:d,chain:l,noProto:r}),g+=this.renderTreeChildrenBatch(d,s,0,t,l,p,o+1,r),g+='<div class="tree-load-more" data-reg-id="'+e+'" data-offset="'+t+'">'+this.icon("angle-down")+" 展开更多 (剩余 "+(d.length-t)+" 项)</div>"}else g+=this.renderTreeChildrenBatch(d,s,0,d.length,l,p,o+1,r);g+="</div>"}else{let e=this.treeNodeRegId++;g+=this._treeNodeChildrenLazy(e,{obj:t,children:d,chain:i,path:p,noProto:r})}return g+='<span class="tree-brace tree-close">}</span>',g+="</div>",s.delete(t),g}renderTreeChildrenBatch(t,e,s,i,n,o,r,l){r=r||0;let a="";for(let c=s;c<i&&c<t.length;c++){let s=t[c];if(s.desc.get||s.desc.set)s.desc.get&&(a+='<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-key">get '+this.escapeHtml(s.name)+":</span> "+this.renderJSONTree(s.desc.get,"",e,n,o+"."+s.name,r+1,l)+"</div>"),s.desc.set&&(a+='<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-key">set '+this.escapeHtml(s.name)+":</span> "+this.renderJSONTree(s.desc.set,"",e,n,o+"."+s.name,r+1,l)+"</div>");else{let t=s.desc.value;null===t||"object"!=typeof t||t instanceof Date||t instanceof RegExp||t instanceof Map||t instanceof Set||t instanceof WeakMap||t instanceof WeakSet||t instanceof ArrayBuffer||t instanceof Error||t instanceof HTMLElement||"function"==typeof t?a+='<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-key">'+this.escapeHtml(s.name)+":</span> "+this.renderJSONTree(t,"",e,n,o+"."+s.name,r+1,l)+"</div>":e.has(t)?a+='<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-key">'+this.escapeHtml(s.name)+':</span> <span class="json-cmt">[循环引用]</span></div>':a+="<div>"+this.renderJSONTree(t,s.name,e,n,o+"."+s.name,r+1,l)+"</div>"}}return a}renderDomChild(t,e,s,i){return 1===t.nodeType?"<div>"+e(t,s,i)+"</div>":3===t.nodeType?'<div class="tree-leaf tree-leaf-text"><span class="tree-spacer"></span><span class="json-cmt">'+this.escapeHtml(t.textContent.trim())+"</span></div>":8===t.nodeType?'<div class="tree-leaf tree-leaf-text"><span class="tree-spacer"></span><span class="json-cmt"><!--'+this.escapeHtml(t.textContent)+'--></span></div>':""}renderDomChildrenLazy(t,e,s,i,n){let o="";if(t.length>200){let r=this.treeNodeRegId++;this.treeNodeRegistry.set(r,Object.assign({type:i,children:t,depth:s},n));for(let i=0;i<200;i++)o+=this.renderDomChild(t[i],e,i,s+1);o+='<div class="tree-load-more" data-reg-id="'+r+'" data-offset="200">'+this.icon("angle-down")+" 展开更多 ("+(t.length-200)+")</div>"}else{let i=0;for(let n of t)o+=this.renderDomChild(n,e,i,s+1),1===n.nodeType&&i++}return o}buildShadowLazy(t,e,s,i,n){let o='<div class="tree-node collapsed" ';if("element"===e){let e=++this.elRefId;this.elRefMap.set(e,t.root),o+='data-el-id="'+e+'" data-shadow-host="'+n+'"'}else o+='data-tree-path="'+this.escapeHtml(s+".shadow")+'" data-shadow-root="1"';o+=">"+this.treeToggleHtml()+'<span class="tree-label json-null">#shadow('+t.mode+")</span>";let r=Array.from(t.root.childNodes).filter((t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()||this.options.showComments&&8===t.nodeType));if(r.length>0){let n=this.treeNodeRegId++;this.treeNodeRegistry.set(n,{type:e+"-shadow",shadowInfo:t,path:s,depth:i,children:r}),o+='<span class="tree-ellipsis">...</span><div class="tree-children" data-lazy-id="'+n+'"></div>'}return o+"</div>"}loadMoreTreeChildren(t){let e=parseInt(t.dataset.regId),s=parseInt(t.dataset.offset),i=this.treeNodeRegistry.get(e);if(!i)return;let n=t.closest(".console-output, .ls-items, .elements-tree");if("html"===i.type){let e=Math.min(s+200,i.children.length),n="";for(let t=s;t<e;t++)n+=this.renderDomChild(i.children[t],(t,e)=>this.renderHTMLTree(t,"",i.path+"."+e,(i.depth||0)+1),t,0);t.insertAdjacentHTML("beforebegin",n)}else if("element"===i.type){let e=Math.min(s+200,i.children.length),n="";for(let t=s;t<e;t++)n+=this.renderDomChild(i.children[t],t=>this.renderElementTree(t,(i.depth||0)+1),t,0);t.insertAdjacentHTML("beforebegin",n)}else if("html-shadow"===i.type){let e=Math.min(s+200,i.children.length),n="";for(let t=s;t<e;t++)n+=this.renderDomChild(i.children[t],(t,e)=>this.renderHTMLTree(t,"",i.path+".shadow."+e,(i.depth||0)+1),t,0);t.insertAdjacentHTML("beforebegin",n)}else if("element-shadow"===i.type){let e=Math.min(s+200,i.children.length),n="";for(let t=s;t<e;t++)n+=this.renderDomChild(i.children[t],t=>this.renderElementTree(t,(i.depth||0)+1),t,0);t.insertAdjacentHTML("beforebegin",n)}else{let e=new WeakSet;i.chain.forEach(t=>e.add(t)),t.insertAdjacentHTML("beforebegin",this.renderTreeChildrenBatch(i.children,e,s,Math.min(s+200,i.children.length),i.chain,i.path||"",1,i.noProto))}let o=s+200;o<i.children.length?(t.dataset.offset=o,t.innerHTML=this.icon("angle-down")+" 展开更多 ("+(i.children.length-o)+")"):(t.remove(),this.treeNodeRegistry.delete(e)),n&&this.vsRender(n)}fmtAttrs(t){let s="";for(let e of t.attributes)s+=e.value?' <span class="json-tag">'+this.escapeHtml(e.name)+'</span><span class="json-boolean">=</span><span class="json-string">"'+this.escapeHtml(e.value)+'"</span>':' <span class="json-tag">'+this.escapeHtml(e.name)+"</span>";return s}renderHTMLTree(t,e,s,i){if((i=i||0)>30)return'<span class="json-cmt">[depth limit]</span>';s=s||"";let n=t.tagName.toLowerCase(),o="";o=this.fmtAttrs(t);let r=Array.from(t.childNodes),l=this.getShadowRoot(t),a=l&&Array.from(l.root.childNodes).some(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()||this.options.showComments&&8===t.nodeType),c=l&&(a||l.mode&&"closed"===l.mode),d=r.some(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()||this.options.showComments&&8===t.nodeType)||!!c,h=this.expandedTreePaths.has(s),p=this._treeNodeOpen(h,"data-tree-path",s);if(p+=d?this.treeToggleHtml():'<span class="tree-spacer"></span>',e&&(p+='<span class="json-key">'+this.escapeHtml(e)+":</span> "),p+='<span class="tree-label json-boolean"><'+n+o+"></span>",d){if(p+='<span class="tree-ellipsis">...</span>',h){p+='<div class="tree-children">';let t=r.filter(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()||this.options.showComments&&8===t.nodeType);if(p+=this.renderDomChildrenLazy(t,(t,e,i)=>this.renderHTMLTree(t,"",s+"."+e,i),i,"html",{path:s}),c)if(this.expandedTreePaths.has(s+".shadow")){let t=Array.from(l.root.childNodes).filter(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()||this.options.showComments&&8===t.nodeType);p+=this._treeShadowNode(!0,"data-tree-path",s+".shadow",l.mode,this.renderDomChildrenLazy(t,(t,e,i)=>this.renderHTMLTree(t,"",s+".shadow."+e,i),i,"html-shadow",{shadowInfo:l,path:s}),'data-shadow-root="1"')}else p+=this.buildShadowLazy(l,"html",s,i);p+="</div>"}else{let t=r.filter(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()||this.options.showComments&&8===t.nodeType),e=this.treeNodeRegId++;p+=this._treeNodeChildrenLazy(e,{type:"html",children:t,path:s,depth:i,shadow:c?l:null})}p+='<span class="tree-label json-boolean tree-close-tag"></'+n+"></span>"}else p+='<span class="tree-label json-boolean tree-close-tag"></'+n+"></span>";return p+="</div>",p}renderElementsView(){if(!this.elementsTree)return;let t=document.documentElement;this.elRefMap=new Map,this.elRefId=0;let e=this.renderElementTree(t,0);this.elementsTree.innerHTML=e,this.pendingHighlight?this.expandToElement(this.pendingHighlight):this.selectedElement&&this.restoreElementSelection()}restoreElementSelection(){if(!this.selectedElement||!this.elementsTree)return;let t=null;for(let[e,s]of this.elRefMap)if(s===this.selectedElement){t=e;break}if(null===t)return;let e=this.elementsTree.querySelector('.tree-node[data-el-id="'+t+'"]');if(!e)return;let s=e;for(;s&&s!==this.elementsTree;)s.classList.contains("tree-node")&&(s.classList.remove("collapsed"),s.classList.add("expanded"),s.dataset.elId&&this.elRefMap&&this.elRefMap.get(parseInt(s.dataset.elId))&&this.expandedElements.add(this.elRefMap.get(parseInt(s.dataset.elId)))),s=s.parentElement;this.elementsTree.querySelectorAll(".el-selected").forEach(t=>t.classList.remove("el-selected")),e.classList.add("el-selected"),e.classList.add("el-highlight"),requestAnimationFrame(()=>{e.scrollIntoView({behavior:"auto",block:"center"}),setTimeout(()=>e.classList.remove("el-highlight"),3e3)})}renderElementTree(t,e){if(t.nodeType&&3===t.nodeType){let e=t.textContent.trim();return e?'<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-cmt">'+this.escapeHtml(e)+"</span></div>":""}if(1!==t.nodeType)return"";let s=t.tagName.toLowerCase(),i="";i=this.fmtAttrs(t);let n=Array.from(t.childNodes).filter(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()||this.options.showComments&&8===t.nodeType),o=this.getShadowRoot(t),r=o&&Array.from(o.root.childNodes).some(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()||this.options.showComments&&8===t.nodeType),l=o&&(r||o.mode&&"closed"===o.mode),a=n.length>0||!!l,c=0===e||this.expandedElements.has(t),d=++this.elRefId;this.elRefMap.set(d,t);let h=this._treeNodeOpen(c,"data-el-id",d,'data-depth="'+e+'"');if(h+=a?this.treeToggleHtml():'<span class="tree-spacer"></span>',h+='<span class="tree-label json-boolean"><'+s+i+"></span>",a){if(h+='<span class="tree-ellipsis">...</span>',c){if(h+='<div class="tree-children">',h+=this.renderDomChildrenLazy(n,(t,e,s)=>this.renderElementTree(t,s),e,"element",{}),l)if(this.expandedElements.has(o.root)||0===e){let t=Array.from(o.root.childNodes).filter(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()||this.options.showComments&&8===t.nodeType),s=++this.elRefId;this.elRefMap.set(s,o.root),h+=this._treeShadowNode(!0,"data-el-id",s,o.mode,this.renderDomChildrenLazy(t,(t,e,s)=>this.renderElementTree(t,s),e,"element-shadow",{}),'data-shadow-host="'+d+'"')}else h+=this.buildShadowLazy(o,"element",null,e,d);h+="</div>"}else{let t=this.treeNodeRegId++;h+=this._treeNodeChildrenLazy(t,{type:"element",children:n,depth:e,shadow:l?o:null,elId:d})}h+='<span class="tree-label json-boolean tree-close-tag"></'+s+"></span>"}else h+='<span class="tree-label json-boolean tree-close-tag"></'+s+"></span>";return h+="</div>",h}startElementPicker(){this.elementPickBtn&&this.elementPickBtn.classList.add("active"),this.triggerGlobalHook("beforeClose"),this.overlay.classList.remove("active"),this.triggerGlobalHook("afterClose");let t=document.createElement("div");t.className="element-picker-overlay",t.style.pointerEvents="none";let e=!1,s=n=>{if(e)return;e=!0,n.preventDefault(),n.stopPropagation();let o=n.target;t.remove(),document.removeEventListener("click",s,!0),document.removeEventListener("keydown",i,!0),this.pendingHighlight=o,this.switchTab("elements"),this.triggerGlobalHook("beforeOpen"),this.overlay.classList.add("active","theme-"+this.currentTheme),this.triggerGlobalHook("afterOpen"),this.elementPickBtn&&this.elementPickBtn.classList.remove("active")},i=n=>{"Escape"!==n.key||e||(e=!0,t.remove(),document.removeEventListener("click",s,!0),document.removeEventListener("keydown",i,!0),this.triggerGlobalHook("beforeOpen"),this.overlay.classList.add("active","theme-"+this.currentTheme),this.triggerGlobalHook("afterOpen"),this.elementPickBtn&&this.elementPickBtn.classList.remove("active"))};document.body.appendChild(t),setTimeout(()=>{document.addEventListener("click",s,!0),document.addEventListener("keydown",i,!0)},200)}expandToElement(t){if(!t||!this.elementsTree)return;this.pendingHighlight=null,this.selectedElement=t;let e=[],s=t;for(;s&&s!==document.documentElement&&s!==document;)e.unshift(s),s=s.parentNode;for(let t of e){let e=null;for(let[s,i]of this.elRefMap)if(i===t){e=s;break}if(null===e)continue;let s=this.elementsTree.querySelector('.tree-node[data-el-id="'+e+'"]');if(!s||!s.classList.contains("collapsed"))continue;s.classList.remove("collapsed"),s.classList.add("expanded");let i=this.elRefMap.get(parseInt(s.dataset.elId));i&&this.expandedElements.add(i);let n=s.querySelector(":scope > .tree-children[data-lazy-id]");if(n){let t=parseInt(n.dataset.lazyId),e=this.treeNodeRegistry.get(t);if(e){let s="";"element"===e.type?(s=this.renderDomChildrenLazy(e.children,(t,e,s)=>this.renderElementTree(t,s),e.depth||0,"element",{}),e.shadow&&(s+=this.buildShadowLazy(e.shadow,"element",null,e.depth||0,e.elId))):"element-shadow"===e.type&&(s=this.renderDomChildrenLazy(e.children,(t,e,s)=>this.renderElementTree(t,s),e.depth||0,"element-shadow",{})),n.innerHTML=s,delete n.dataset.lazyId,this.treeNodeRegistry.delete(t)}}}let i=null;for(let[e,s]of this.elRefMap)if(s===t){i=e;break}if(null===i)return;let n=this.elementsTree.querySelector('.tree-node[data-el-id="'+i+'"]');n&&(this.elementsTree.querySelectorAll(".el-selected").forEach(t=>t.classList.remove("el-selected")),n.classList.add("el-selected"),n.classList.add("el-highlight"),requestAnimationFrame(()=>{n.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(()=>n.classList.remove("el-highlight"),3e3)}))}serializeNodeWithShadow(t){if(t instanceof ShadowRoot||t instanceof DocumentFragment)return Array.from(t.childNodes).map(t=>this.serializeNodeWithShadow(t)).join("");if(1===t.nodeType){let e=t.tagName.toLowerCase(),s="";for(let e of t.attributes)s+=null!=e.value&&void 0!==e.value?" "+e.name+'="'+this.escapeHtml(e.value)+'"':" "+e.name;let i=this.getShadowRoot(t),n="";return i&&(n+="\x3c!-- #shadow("+i.mode+") --\x3e",n+=Array.from(i.root.childNodes).map(t=>this.serializeNodeWithShadow(t)).join("")),n+=Array.from(t.childNodes).map(t=>this.serializeNodeWithShadow(t)).join(""),["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"].includes(e)?"<"+e+s+">":"<"+e+s+">"+n+"</"+e+">"}return 3===t.nodeType?t.textContent:8===t.nodeType?"\x3c!--"+t.textContent+"--\x3e":""}copyElementHTML(t){let e=this.serializeNodeWithShadow(t);navigator.clipboard?navigator.clipboard.writeText(e).then(()=>this.showNotification("已复制元素")).catch(()=>this.fallbackCopy(e)):this.fallbackCopy(e)}fallbackCopy(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select();try{document.execCommand("copy"),this.showNotification("已复制元素")}catch(e){this.showNotification("复制失败","warning")}e.remove()}deleteElement(t){if(t)if(null!==this.selectedShadowHostId){let t=this.elRefMap.get(this.selectedShadowHostId);if(t){let e=this.getShadowRoot(t);if(e){if("closed"===e.mode)return void this.showNotification("无法删除closed模式的ShadowDOM","warning");try{for(t.shadowRoot&&(t.shadowRoot.innerHTML="");e.root.firstChild;)e.root.removeChild(e.root.lastChild)}catch{}this.selectedElement=null,this.selectedShadowHostId=null,this.showNotification("ShadowDOM已删除"),this.renderElementsView()}else this.showNotification("ShadowDOM已不存在","warning")}else this.showNotification("无法删除此元素","warning")}else t.parentNode?(t.parentNode.removeChild(t),this.showNotification("元素已删除"),this.selectedElement===t&&(this.selectedElement=null),this.renderElementsView()):t.parentElement?(t.parentElement.removeChild(t),this.showNotification("元素已删除"),this.selectedElement===t&&(this.selectedElement=null),this.renderElementsView()):this.showNotification("无法删除此元素","warning")}renderTableHTML(t,e){if(!t||"object"!=typeof t)return`<div class="console-table-wrap"><span class="json-cmt">非表格数据: ${this.escapeHtml(String(t))}</span></div>`;let s,i;s=Array.isArray(t)?t.map((t,e)=>{let s={"(idx)":e};return t&&"object"==typeof t?Object.assign(s,t):s.value=t,s}):Object.entries(t).map(([t,e])=>{let s={"(idx)":t};return e&&"object"==typeof e?Object.assign(s,e):s.value=e,s});let n=new Set;s.forEach(t=>Object.keys(t).forEach(t=>n.add(t))),i=["(idx)",...Array.from(n).filter(t=>"(idx)"!==t)],e&&Array.isArray(e)&&e.length&&(i=["(idx)",...e.filter(t=>"(idx)"!==t)]);let o=t=>{if(void 0===t)return"";if(null===t)return'<span class="json-null">null</span>';if("string"==typeof t)return`<span class="json-string">"${this.escapeHtml(t.substring(0,100))}"</span>`;if("number"==typeof t)return`<span class="json-number">${t}</span>`;if("boolean"==typeof t)return`<span class="json-boolean">${t}</span>`;if("function"==typeof t)return this.isClass(t)?`<span class="json-boolean">[Class ${t.name||"anonymous"}]</span>`:`<span class="json-boolean">ƒ ${t.name||"anonymous"}</span>`;if("object"==typeof t)try{let e=this.safeStringify(t);return`<span class="json-cmt">${this.escapeHtml(e.length>50?e.substring(0,50)+"…":e)}</span>`}catch{return'<span class="json-cmt">{Object}</span>'}return this.escapeHtml(String(t))},r='<div class="console-table-wrap"><table class="console-table"><thead><tr>';return i.forEach(t=>r+=`<th>${this.escapeHtml(String(t))}</th>`),r+="</tr></thead><tbody>",s.forEach(t=>{r+="<tr>",i.forEach(e=>r+=`<td>${o(t[e])}</td>`),r+="</tr>"}),r+="</tbody></table></div>",r}renderLogItemHTML(t,e){if(t.subType){let e="table",s=t.timestamp.toLocaleTimeString(),i=this.renderSubTypeContent(t);return`<div class="log-item ${t.type}${this.selectedLogId===t.id?" selected":""}" id="log-item-${t.id}"><div class="log-header">${t.count>1?`<div class="log-count">${t.count}</div>`:""}<div class="log-icon">${this.icon(e)}</div><div class="timestamp">${s}</div></div><div class="log-content">${i}</div></div>`}let s;switch(t.type){case"info":s="info-circle";break;case"warn":s="exclamation-triangle";break;case"error":s="times-circle";break;default:s="info"}let i=t.timestamp.toLocaleTimeString(),n=t.expandedJson?this.formatArgs(t.args,t.id):this.renderLogContent(t);return`<div class="log-item ${t.type}${this.selectedLogId===t.id?" selected":""}" id="log-item-${t.id}"><div class="log-header">${t.count>1?`<div class="log-count">${t.count}</div>`:""}<div class="log-icon">${this.icon(s)}</div><div class="timestamp">${i}</div></div><div class="log-content">${n}</div>${t.hasObject?`<div class="log-actions"><div class="log-action expand-btn" title="${t.expandedJson?"收起":"展开"}" onclick="thinConsole.tC.toggleExpandJson(${t.id})">${this.icon(t.expandedJson?"chevron-up":"chevron-down")}${t.expandedJson?"收起":"展开"}</div></div>`:""}</div>`}renderLSItemHTML(t,e){let s=this.escapeHtml(t),{displayValue:i,valueType:n,isJSON:o}=this.parseAndTypeCheck(e),r=o?this.highlightJson(i):this.escapeHtml(i),l="";if(o){let t=JSON.parse(e);l=`<div class="ls-value json-tree-container">${this.renderJSONValue(t,"")}</div>`}else l=`<div class="ls-value" title="${this.escapeHtml(i)}"><span class="json-${n}">${"string"===n?'"':""}${r}${"string"===n?'"':""}</span></div>`;return`<div class="ls-item" data-key="${s}"><div class="ls-key-row"><div class="ls-key" title="${s}">${s}</div><div class="ls-actions"><button class="ls-action-btn" data-action="edit" data-key="${s}" title="编辑">${this.icon("edit")}</button><button class="ls-action-btn" data-action="copy" data-key="${s}" title="复制">${this.icon("copy")}</button><button class="ls-action-btn" data-action="remove" data-key="${s}" title="删除">${this.icon("trash")}</button></div></div>${l}<div class="ls-value-type" title="${n}">类型:${n}</div></div>`}toggleSearch(t){let e=void 0!==t?t:!this.searchExpanded;this.searchExpanded=e,this.searchBar&&(this.searchBar.style.display=e?"flex":"none"),e&&this.searchInput?this.searchInput.focus():e||(this.searchQuery="",this.searchInput&&(this.searchInput.value=""),this.renderContent())}onAddLSClick(){this.netSending=!1,this.netNewVisible=!1,this.editorState={visible:!0,mode:"ls",key:"",oldKey:"",value:""},this.updateEditorVisibility(),this.lsEditorKeyInput&&(this.lsEditorKeyInput.value="",this.lsEditorKeyInput.focus())}openLSEditor(t){if(this.netSending||this.netNewVisible)return void this.showNotification("正在发送请求,无法保存键值","warning");let e=this.activeLSFilter||"local",s=this.storage[e].get(t)||"";this.netSending=!1,this.netNewVisible=!1,this.editorState={visible:!0,mode:"ls",key:t,oldKey:t,value:s},this.updateEditorVisibility(),this.lsEditorInput&&this.lsEditorInput.focus()}closeLSEditor(){this.editorState.visible=!1,this.editorState.value="",this.updateEditorVisibility()}onEditorSave(){"code"===this.editorState.mode?this.runCode():this.saveLSFromEditor()}saveLSFromEditor(){if(this.netSending||this.netNewVisible)return void this.showNotification("正在发送请求,无法保存键值","warning");let t,e=this.lsEditorKeyInput?this.lsEditorKeyInput.value.trim():this.editorState.key,s=this.editorState.oldKey,i=this.lsEditorInput?this.lsEditorInput.value:this.editorState.value;if(!e)return void this.showNotification("键名不能为空","warning");try{t=JSON.stringify(JSON.parse(this.fixKeysOnly(i)))}catch{t=i}let n=this.activeLSFilter||"local",o=this.storage[n];if("cookie"===n)return o.set(e,t),this.closeLSEditor(),this.renderLocalStorage(),void this.showNotification('已保存Cookie"'+e+'"');if(s&&s!==e){if(null!==o.get(e))return void this.showNotification('键名"'+e+'"已存在!',"warning");o.remove(s)}else if(!s&&null!==o.get(e))return void this.showNotification('键名"'+e+'"已存在!',"warning");o.set(e,t),this.closeLSEditor(),this.renderLocalStorage(),this.showNotification('已保存键"'+e+'"')}onTitleClick(){this.netSending||this.netNewVisible?this.showNotification("正在发送请求,无法运行代码","warning"):this.editorState.visible&&"ls"===this.editorState.mode?this.showNotification("正在保存键值,无法运行代码","warning"):(this.editorState.visible=!0,this.editorState.mode="code",this.updateEditorVisibility(),this.lsEditorInput&&this.lsEditorInput.focus())}toggleMute(){let t="console",e=this.activeFilter||"all";this.mutedFilters[t]||(this.mutedFilters[t]={}),this.mutedFilters[t][e]=!this.mutedFilters[t][e];let s=this.mutedFilters[t][e],i="all"===e?"所有日志":e+"类型日志";this.showNotification(s?i+"已屏蔽":i+"已恢复",s?"warning":""),this.updateMuteBtnState()}updateMuteBtnState(){if(!this.muteBtn)return;let t="console",e=this.activeFilter||"all";this.mutedFilters[t]&&this.mutedFilters[t][e]?(this.muteBtn.classList.add("muted"),this.muteBtn.title="恢复日志"):(this.muteBtn.classList.remove("muted"),this.muteBtn.title="屏蔽"+("all"===e?"后续日志":e+"类型日志"))}runCode(){let t=this.lsEditorInput?this.lsEditorInput.value:"";if(t.trim())try{let e=window.eval(t);console.log(t+"\n> ",e),this.showNotification("代码已执行"),this.closeLSEditor()}catch(e){console.error(t+"\n> 执行失败:"+e),this.showNotification("代码执行失败","warning"),this.closeLSEditor()}}setupGestures(){if(!this.contentArea||!this.consoleHeader)return;let t=this.contentArea,e=this.consoleHeader,s=null,i=0,n=0,o=0,r=0,l=!1,a=null,c=0,d=0,h=0,p=!1,u=()=>{let t=this.overlay.querySelectorAll(".tab-btn");return Array.from(t).map(t=>t.dataset.tab)},g=()=>{if("console"===this.currentTab)return["all","log","info","warn","error"];if("network"===this.currentTab)return["all","get","post","put","success","failed"];if("localstorage"===this.currentTab)return["local","session","cookie"];let t=this.pluginViewContainers[this.currentTab];return t&&t.querySelectorAll(".filter-btn").length>1?Array.from(t.querySelectorAll(".filter-btn")).map(t=>t.dataset.type||t.dataset.filter||t.textContent.trim()):null},f=t=>{let e=u(),s=e.indexOf(this.currentTab),i=g();if(i)if("localstorage"===this.currentTab){let e=i.indexOf(this.activeLSFilter||"local")+t;if(e>=0&&e<i.length){this.activeLSFilter=i[e],this.lsFiltersContainer&&this.lsFiltersContainer.querySelectorAll(".filter-btn").forEach(t=>t.classList.toggle("active",t.dataset.lsType===this.activeLSFilter)),this.renderContent();let t=this.lsFiltersContainer&&this.lsFiltersContainer.querySelector('.filter-btn[data-ls-type="'+this.activeLSFilter+'"]');return void this.scrollFilterIntoView(this.lsFiltersContainer,t)}}else if("console"===this.currentTab){let e=i.indexOf(this.activeFilter||"all")+t;if(e>=0&&e<i.length)return this.activeFilter=i[e],this.filterButtons.forEach(t=>t.classList.toggle("active",t.dataset.type===this.activeFilter)),this.updateFilterCounts(),this.renderContent(),void this.scrollFilterIntoView(this.filtersContainerEl,this.filterButtons[e])}else{if("network"!==this.currentTab){let e=this.pluginViewContainers[this.currentTab];if(e){this.enhanceFilterContainers(e);let s=e.querySelectorAll(".filter-btn");if(s.length>1){let e=-1;s.forEach((t,s)=>{t.classList.contains("active")&&(e=s)});let i=e+t;i>=0&&i<s.length&&(s.forEach(t=>t.classList.remove("active")),s[i].classList.add("active"),s[i].click(),this.scrollFilterIntoView(s[i].parentElement,s[i]))}}return}{let e=i.indexOf(this.activeNetFilter||"all")+t;if(e>=0&&e<i.length){this.activeNetFilter=i[e],this.netFiltersEl&&this.netFiltersEl.querySelectorAll(".net-filter-btn").forEach(t=>t.classList.toggle("active",t.dataset.netFilter===this.activeNetFilter)),this.renderNetworkList(),this.updateNetDisableBtn(),this.updateNetFilterCounts();let t=this.netFiltersEl&&this.netFiltersEl.querySelector('.net-filter-btn[data-net-filter="'+this.activeNetFilter+'"]');return void this.scrollFilterIntoView(this.netFiltersEl,t)}}}let n=s+t;if(n>=0&&n<e.length){let t=e[n];"console"===t?(this.activeFilter="all",this.filterButtons&&this.filterButtons.forEach(t=>t.classList.toggle("active","all"===t.dataset.type))):"localstorage"===t&&(this.activeLSFilter="local",this.lsFiltersContainer&&this.lsFiltersContainer.querySelectorAll(".filter-btn").forEach(t=>t.classList.toggle("active","local"===t.dataset.lsType)));let s=this.overlay.querySelector(`.tab-btn[data-tab="${t}"]`);s&&s.click()}};t.addEventListener("touchstart",t=>{if(1!==t.touches.length)return;if(this.editorState.visible)return;let e=t.target.closest(".json-tree-container,.json-preview,.log-content,.console-table-wrap,.system-log-content,.ls-value,.object-preview,.error-stack,.function-preview,.elements-tree,.filters,.network-filters");e&&(e.matches(".filters,.network-filters")||e.scrollWidth>e.clientWidth)?s=null:(s=t.touches[0],i=s.clientX,n=s.clientY,o=0,r=0,l=!1)},{passive:!0}),t.addEventListener("touchmove",t=>{if(!s||1!==t.touches.length)return;let e=t.touches[0];o=e.clientX-i,r=e.clientY-n,!l&&Math.abs(o)>15&&Math.abs(o)>1.5*Math.abs(r)&&(l=!0),l&&t.preventDefault()},{passive:!1}),t.addEventListener("touchend",()=>{if(s){if(l){let t=60;o<-t?f(1):o>t&&f(-1)}s=null,l=!1}}),e.addEventListener("touchstart",t=>{window.innerWidth>768||1===t.touches.length&&(a=t.touches[0],c=a.clientX,d=a.clientY,h=0,p=!1)},{passive:!0}),e.addEventListener("touchmove",t=>{if(window.innerWidth>768)return;if(!a||1!==t.touches.length)return;let e=t.touches[0];if(h=e.clientY-d,!p&&h>15&&h>1.5*Math.abs(e.clientX-c)&&(p=!0),p){t.preventDefault();let e=this.overlay.querySelector(".console-container");e&&(e.style.transition="none",e.style.transform=`translateY(${h}px)`)}},{passive:!1}),e.addEventListener("touchend",()=>{if(!(window.innerWidth>768)&&a){if(p){let t=this.overlay.querySelector(".console-container");h>80?(t&&(t.style.transition="transform .3s ease",t.style.transform="translateY(100%)"),setTimeout(()=>{this.triggerGlobalHook("beforeClose"),this.overlay.classList.remove("active"),t&&(t.style.transition="",t.style.transform=""),this.triggerGlobalHook("afterClose")},300)):t&&(t.style.transition="transform .25s ease",t.style.transform="")}a=null,p=!1}})}updateFilterShadow(t){if(!t)return;let e=t.scrollWidth-t.clientWidth>1;t.classList.toggle("overflow-start",e&&t.scrollLeft>1),t.classList.toggle("overflow-end",e&&t.scrollLeft+t.clientWidth<t.scrollWidth-1)}setupFilterShadow(t){if(!t||t._tcFilterShadow)return;t._tcFilterShadow=!0,t.classList.add("overflow-scroll");let e=()=>this.updateFilterShadow(t);if(t.addEventListener("scroll",e,{passive:!0}),window.ResizeObserver){let s=new ResizeObserver(e);s.observe(t),t._tcFilterRO=s,t.setAttribute("data-filter-ro","1")}if(window.MutationObserver){let s=new MutationObserver(e);s.observe(t,{childList:!0,subtree:!0}),t._tcFilterMO=s}e()}scrollFilterIntoView(t,e){if(!t||!e)return;if(t.scrollWidth<=t.clientWidth)return void this.updateFilterShadow(t);let s=e.offsetLeft-(t.clientWidth-e.offsetWidth)/2;s=Math.max(0,Math.min(s,t.scrollWidth-t.clientWidth));try{t.scrollTo({left:s,behavior:"smooth"})}catch(t){}t.scrollLeft!==s&&(t.scrollLeft=s),this.updateFilterShadow(t),setTimeout(()=>this.updateFilterShadow(t),300)}enhanceFilterContainers(t){if(!t)return;let e=new Map;t.querySelectorAll(".filter-btn").forEach(t=>{let s=t.parentElement;s&&!s.dataset.tcFilterEnhanced&&(e.has(s)||e.set(s,[]),e.get(s).push(t))}),e.forEach((t,e)=>{if(t.length>1){e.classList.contains("filters")||e.classList.contains("network-filters")||e.classList.add("filters"),e.dataset.tcFilterEnhanced="1",this.setupFilterShadow(e);let s=e;t.forEach(t=>{t.dataset.orig||(t.dataset.orig=t.textContent.trim()),t.addEventListener("click",()=>this.scrollFilterIntoView(s,t))})}})}_fmtCount(n,p){if(n<1e3)return{filterCount:n,exactCount:n};let k=n/1e3;if(n>=1e5)return{filterCount:Math.floor(k)+"K+",exactCount:n};let s=Math.round(10*k)/10;return{filterCount:(Number.isInteger(s)?s:s.toFixed(1))+"K"+(p?"+":""),exactCount:n}}_updateFilterBtns(t,e,s,i){t&&t.querySelectorAll(".filter-btn, .net-filter-btn").forEach(t=>{let n=t.dataset[s],o=e[n]||0,r=t.classList.contains("active");t.innerHTML=i(t,o,r)})}updateFilterCounts(){this.filterButtons&&(this._updateFilterRaf||(this._updateFilterRaf=requestAnimationFrame(()=>{this._updateFilterRaf=null;let t=[];"console"===this.currentTab&&(t=this.logs);let e=(t,e)=>t.reduce((t,s)=>s.type===e?t+(s.count||1):t,0),s={all:t.reduce((t,e)=>t+(e.count||1),0),log:e(t,"log"),info:e(t,"info"),warn:e(t,"warn"),error:e(t,"error")};this._updateFilterCounts(this.filterButtons,s,!1)})))}_updateFilterCounts(e,t,s){e&&(s?e.querySelectorAll(".filter-btn[data-orig]"):e).forEach(i=>{let a,n=s?i.dataset.orig:i.dataset.type,o=t[i.dataset.type||i.dataset.filter||n]||0,r=i.classList.contains("active");a="object"==typeof o&&null!==o?o:this._fmtCount(o,!1),s?i.innerHTML=(i.dataset.icon?this.icon(i.dataset.icon)+" ":"")+n+(r?" ("+a.filterCount+")":""):(i.dataset.originalHtml||(i.dataset.originalHtml=i.innerHTML),i.innerHTML=r?`${i.dataset.originalHtml} (${a.filterCount})`:i.dataset.originalHtml),i.title=r&&void 0!==a.exactCount?""+a.exactCount:""})}renderContent(){if(this.triggerGlobalHook("beforeRender",this.currentTab),this.updateControlsVisibility(),this.updateMuteBtnState(),this.consoleOutput.style.display="none",this.localstorageView.style.display="none",this.elementsView.style.display="none",this.networkView&&(this.networkView.style.display="none"),this.netDetailOverlay&&(this.netDetailOverlay.style.display="none"),this.netNewOverlay&&(this.netNewOverlay.style.display=this.netNewVisible?"flex":"none"),this.clearLogsBtn.style.display="none",this._elementObserver&&this.stopElementObserver&&this.stopElementObserver(),Object.values(this.pluginViewContainers).forEach(t=>{t.style.display="none"}),["console","network","localstorage","elements"].includes(this.currentTab))switch(this.clearLogsBtn.style.display="block",this.currentTab){case"console":this.consoleOutput.style.display="block",this.renderLogList(this.logs,!1),this.updateFilterCounts();break;case"network":this.clearLogsBtn.style.display="block",this.networkView&&(this.networkView.style.display="flex"),this.renderNetworkPanel();break;case"localstorage":this.localstorageView.style.display="block",this.renderLocalStorage();break;case"elements":this.clearLogsBtn.style.display="none",this.elementsView.style.display="block",this.renderElementsView(),this.startElementObserver()}else if(this.pluginViewContainers[this.currentTab]){this.consoleControls.style.display="none";let t=this.pluginViewContainers[this.currentTab];t.style.display="block";let e=Object.keys(this.pluginTabs).find(t=>this.pluginTabs[t].id===this.currentTab);if(e){let s=this.plugins[e];s&&"function"==typeof s.onShow&&s.onShow(),s&&"function"==typeof s.render&&s.render(t),this.enhanceFilterContainers(t)}else{let t=this.pluginTabs[this.currentTab];t&&"function"==typeof t.onShow&&t.onShow()}}this.triggerGlobalHook("afterRender",this.currentTab)}renderLogList(t,e){let s=this.consoleOutput,i="日志记录";if(!s)return;if(0===t.length)return void this.vsUpdate(s,[],null,0,{emptyHTML:`<div class="nolog">${this.icon("info-circle")}无${i}</div>`});let n=[...t];if(this.activeFilter&&"all"!==this.activeFilter&&(n=n.filter(t=>t.type===this.activeFilter)),this.searchQuery){let t,e=this.searchQuery.trim(),s=!1;if(e.startsWith("/")&&e.endsWith("/"))try{let i=e.slice(1,-1),n=i.lastIndexOf("/"),o="";n>0?(o=i.slice(n+1),t=new RegExp(i.slice(0,n),o)):t=new RegExp(i),s=!0}catch{this.showNotification("无效的正则表达式:"+e),s=!1}let i=s?e:e.toLowerCase();n=n.filter(e=>e.args.some(e=>{let n;return n=e instanceof Error?"[error]":null==e?"null":void 0===e?"undefined":"object"==typeof e?'<span class="json-cmt">{Object}</span>':String(e),s&&t?t.test(n):n.toLowerCase().includes(i.toLowerCase())}))}0!==n.length?this.vsUpdate(s,n,t=>this.renderLogItemHTML(t,e),80):this.vsUpdate(s,[],null,0,{emptyHTML:`<div class="nolog">${this.icon("search")}无匹配的${i}</div>`})}getParams(t){let e=t.toString(),s=t=>{let e=t.indexOf("(");if(-1===e)return"";let s=1,i=e+1;for(;i<t.length;i++)if("("===t[i])s++;else if(")"===t[i]&&0===--s)break;return t.slice(e+1,i).replace(/\s+/g,"")};if(/^\s*(?:class|function|async\s+function)/.test(e))return s(e);let i=e.indexOf("=>"),n=e.indexOf("{");if(i>0&&(-1===n||i<n)){let t=e.slice(0,i).trim().replace(/^async\s+/,"");if(t.startsWith("(")){let e=1,s=1;for(;s<t.length&&e>0;s++)"("===t[s]?e++:")"===t[s]&&e--;return t.slice(1,s-1).replace(/\s+/g,"")}return t.replace(/\s+/g,"")}return e.indexOf("(")>0?s(e):""}renderLogContent(t){let e=[...t.args],s=t.id;if(!e.length)return"";let i=[],n=[],o=0,r=(t=>null===t?'<span class="json-null">null</span>':void 0===t?'<span class="json-null">undefined</span>':t instanceof HTMLElement?'<div class="json-tree-container">'+this.renderHTMLTree(t,"",s+":html")+"</div>":t instanceof Date?t.toISOString():t instanceof Error?`<strong>${t.name}:</strong>${t.message}`:t instanceof RegExp?`<span class="json-number">${t.toString()}</span>`:"function"==typeof t?this.isClass(t)?`<span class='json-boolean'>[Class ${t.name||"anonymous"}]</span>`:this.renderFunctionCollapsed(t):t instanceof Map?`<span class="json-boolean">[Map ${t.size}]</span>`:t instanceof Set?`<span class="json-boolean">[Set ${t.size}]</span>`:t instanceof WeakMap?'<span class="json-boolean">[WeakMap]</span>':t instanceof WeakSet?'<span class="json-boolean">[WeakSet]</span>':t instanceof ArrayBuffer?`<span class="json-boolean">[ArrayBuffer ${t.byteLength} bytes]</span>`:this.fmtVal(t,s,0))(e.length>0?e[0]:"").replace(/%%/g,"").replace(/%([dfsioO%])/g,(t,s)=>{if("%"===s)return"%";if("o"===s||"O"===s)return"";let n=e[++o];if(null==n)return t;let r="d"===s||"i"===s?parseInt(n,10)||0:"f"===s?parseFloat(n)||0:String(n);return i.push(r),`{{v${i.length-1}}}`}).replace(/%c/g,()=>(n.push(String(e[++o]||"")),`{{c${n.length-1}}}`)).replace(/\x01/g,"%");i.forEach((t,e)=>r=r.replace(`{{v${e}}}`,t));let l=r.split(/{{c\d+}}/);r=l.map((t,e)=>{if(!e)return t;let s=n[e-1].replace(/"/g,"").split(/\s*;\s*/).filter(t=>t.trim()&&!/\b(position|fixed|absolute|sticky|relative|static|z-index|transform|top|left|right|bottom)\s*:/i.test(t)).join("; ");return s?`<span style="${s}">${t}</span>`:t}).join("");let a=e.slice(o+1);return r+=(r?" ":"")+a.map(t=>null===t?'<span class="json-null">null</span>':void 0===t?'<span class="json-null">undefined</span>':"function"==typeof t?this.isClass(t)?`<span class='json-boolean'>[Class ${t.name||"anonymous"}]</span>`:this.renderFunctionCollapsed(t):t instanceof Error?`<strong>${t.name}:</strong>${t.message}`:t instanceof HTMLElement?'<div class="json-tree-container">'+this.renderHTMLTree(t,"",s+":r:html")+"</div>":t instanceof Date?`<span class="json-string">${t.toISOString()}</span>`:t instanceof RegExp?`<span class="json-number">${t.toString()}</span>`:t instanceof Map?`<span class="json-boolean">[Map ${t.size}]</span>`:t instanceof Set?`<span class="json-boolean">[Set ${t.size}]</span>`:t instanceof WeakMap?'<span class="json-boolean">[WeakMap]</span>':t instanceof WeakSet?'<span class="json-boolean">[WeakSet]</span>':t instanceof ArrayBuffer?`<span class="json-boolean">[ArrayBuffer ${t.byteLength} bytes]</span>`:this.fmtVal(t,s,1)).join("")}copyLog(t,e=!1,s=!1){if(s){let e=this.activeLSFilter||"local",s=this.storage[e].get(t);if(s)return navigator.clipboard.writeText(s).then(()=>this.showNotification(`已复制"${t}"的值`)).catch(t=>console.error("复制失败:",t))}let i=this.logs.find(e=>e.id===t);if(!i)return;let n="";i.count>1&&(n+=`[重复${i.count}次] `),i.args.forEach((t,e)=>{e>0&&(n+=" ");try{t instanceof HTMLElement?n+=t.outerHTML.replace(/>/g,">\n"):n+=null!==t&&"object"==typeof t?this.safeStringify(t).replace(/\\u000[23]/g,""):"function"==typeof t?this.isClass(t)?`[Class ${t.name||"anonymous"}]`:`ƒ ${t.name||"anonymous"}(${this.getParams(t)})`:null===t?"null":void 0===t?"undefined":String(t)}catch{n+="{object}"}}),navigator.clipboard.writeText(n).then(()=>this.showNotification("已复制到剪贴板")).catch(t=>console.error("复制失败:",t))}clearAllLogs(t=!1){if(this.triggerGlobalHook("beforeClear"),"network"!==this.currentTab){if(t)return this.logs=[],this.lastLog=null,this.renderContent(),void this.updateFilterCounts();if("localstorage"==this.currentTab){let t=this.activeLSFilter||"local";return void(confirm("确定要清除所有"+("local"===t?"本地存储":"session"===t?"会话存储":"Cookie")+"吗?此操作不可撤销。")&&(this.storage[t].clear(),this.renderLocalStorage()))}confirm("确定要清除所有日志吗?此操作不可撤销。")&&(this.logs=[],this.lastLog=null,this.renderContent(),this.updateFilterCounts(),this.showNotification("所有日志已清除","warning"),this.triggerGlobalHook("afterClear"))}else this.clearNetworkRequests()}updateLSFilterCounts(){if(!this.lsFiltersContainer)return;let t={local:this.storage.local.length(),session:this.storage.session.length(),cookie:this.storage.cookie.length()};this._updateFilterBtns(this.lsFiltersContainer,t,"lsType",(t,e,s)=>{let i=t.dataset.orig,n=t.dataset.icon||"",f=this._fmtCount(e,!0);return t.title=s?""+f.exactCount:"",this.icon(n)+i+(s?" ("+f.filterCount+")":"")})}renderLocalStorage(){this.updateLSFilterCounts();let t=this.activeLSFilter||"local",e=[],s="local"===t?"无本地存储":"session"===t?"无会话存储":"无Cookies",i=this.storage[t],n="local"===t?"database":"session"===t?"window-restore":"cookie-bite";if(i.length()){for(let t=0;t<i.length();t++){let s=i.key(t);null!==s&&e.push({key:s,value:i.get(s)||""})}if(e.sort((t,e)=>t.key.localeCompare(e.key,void 0,{numeric:!0,sensitivity:"base"})),this.searchQuery){let t=this.searchQuery.toLowerCase();e=e.filter(e=>e.key.toLowerCase().includes(t)||(e.value||"").toLowerCase().includes(t))}this.vsUpdate(this.lsItems,e,t=>this.renderLSItemHTML(t.key,t.value),130,{force:!0,emptyHTML:'<div class="nolog">'+this.icon("search")+"无匹配的本地存储数据</div>"})}else this.vsUpdate(this.lsItems,[],null,0,{emptyHTML:'<div class="nolog">'+this.icon(n)+s+"</div>"})}addLSItemToDOM(t,e){this.renderLocalStorage()}parseAndTypeCheck(t){try{let e=JSON.parse(t);return"object"==typeof e&&null!==e?{displayValue:this.safeStringify(e,2).replace(/</g,"<").replace(/>/g,">"),valueType:Array.isArray(e)?"array":"object",isJSON:!0}:null==e?{displayValue:null,valueType:null,isJSON:!1}:{displayValue:t,valueType:typeof e,isJSON:!1}}catch{return{displayValue:t,valueType:"string",isJSON:!1}}}isLSEmpty(){let t=this.activeLSFilter||"local";return 0===this.storage[t].length()}escapeHtml(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}editLSItem(t){this.openLSEditor(t)}fixKeysOnly(t){try{return JSON.parse(t),t}catch{return t.replace(/([{,])\s*([a-zA-Z_]\w*)\s*:/g,'$1"$2":').replace(/(":)\s*(?!true|false|null|\d+(\.\d+)?)([^\s,"{[}\]]+?)\s*(?=,|})/gs,'$1"$3"')}}removeLSItem(t){let e=this.activeLSFilter||"local";confirm("是否删除"+("local"===e?"本地存储":"session"===e?"会话存储":"Cookie")+'键名 "'+t+'"?')&&(this.storage[e].remove(t),this.renderLocalStorage(),this.showNotification('已删除"'+t+'"'))}findLSItem(t){return this.overlay.querySelector(`.ls-item[data-key="${t}"]`)}updateLSItemView(t){let e=this.findLSItem(t);if(!e)return;let s=this.activeLSFilter||"local",i=this.storage[s].get(t);if(null===i)return void e.remove();let{displayValue:n,valueType:o,isJSON:r}=this.parseAndTypeCheck(i),l=r?this.highlightJson(n):this.escapeHtml(n),a="";if(r){let t=JSON.parse(i);a=`<div class="ls-value json-tree-container">${this.renderJSONValue(t,"")}</div>`}else a=`<div class="ls-value" title="${this.escapeHtml(n)}"><span class="json-${o}">${"string"===o?'"':""}${l}${"string"===o?'"':""}</span></div>`;let c=this.escapeHtml(t);e.innerHTML=`<div class="ls-key-row"><div class="ls-key" title="${c}">${c}</div><div class="ls-actions"><button class="ls-action-btn" data-action="edit" data-key="${c}" title="编辑">${this.icon("edit")}</button><button class="ls-action-btn" data-action="copy" data-key="${c}" title="复制">${this.icon("copy")}</button><button class="ls-action-btn" data-action="remove" data-key="${c}" title="删除">${this.icon("trash")}</button></div></div>${a}<div class="ls-value-type" title="${o}">类型:${o}</div>`}setupGlobalEventHandlers(){this.activeFilter="all",this.searchQuery="",this.tCError=t=>{""!==t.filename||0!==t.lineno||0!==t.colno?(console.error(t.error.toString(),{"错误信息":t.message||"无信息","文件名":t.filename||"未知","位置":`${t.lineno}:${t.colno}`||"0:0","是否可信":t.isTrusted||!0,"类型":t.type||"error"}),t.preventDefault()):console.error("脚本错误")},this.tCUR=t=>{console.error("未处理的Promise异常",t.reason),t.preventDefault()},this.RSError=t=>{let e=new Set(["IMG","SCRIPT","LINK","VIDEO","AUDIO","SOURCE","TRACK"]),s=t.target;if(!e.has(s.tagName))return;let i=s.src||s.href||s.currentSrc||"[未知路径]";console.error(`[资源错误] <${s.tagName.toLowerCase()}>加载失败:${i}`)},document.addEventListener("error",this.RSError,!0),window.addEventListener("error",this.tCError),window.addEventListener("unhandledrejection",this.tCUR),window.addEventListener("resize",()=>{if(window.innerWidth<=768&&this.consoleContainer&&(this.consoleContainer.style.width="",this.consoleContainer.style.flex="",this.consoleContainer.style.transform="",this.consoleContainer.style.transition=""),window.innerWidth>768&&!window.matchMedia("(pointer:fine)").matches&&"network"===this.currentTab){let t=this.overlay.querySelector('.tab-btn[data-tab="console"]');t&&t.click()}})}setupSelfProtection(){if(this.protectInterval)return;let t=this;this.protectInterval=setInterval(()=>{window.thinConsole&&window.thinConsole.tC!==t&&(window.thinConsole.tC=t),(!this.host||!document.documentElement.contains(this.host)||!this.host.shadowRoot)&&(this.host=null,this.initShadow(),t.createButton(),t.createOverlayElement(),t.tabButtons=t.overlay.querySelectorAll(".tab-btn"),t.renderContent(),t.createStyles(),t.createNotificationElement());let e=this.shadowRoot.getElementById("thinConsole-btn");e&&e.isConnected?"flex"!==e.style.display&&(e.style.display="flex"):(t.btn=null,t.createButton());let s=this.shadowRoot.getElementById("consoleOverlay");s&&s.isConnected?"flex"!==s.style.display&&(s.style.display="flex"):(t.overlay=null,t.createOverlayElement(),t.createStyles());let i=this.shadowRoot.querySelector("style[tcstyle]");(!i||!i.innerHTML||i.innerHTML.length<100)&&t.createStyles();let n=this.shadowRoot.getElementById("notification");n&&n.isConnected?"block"!==n.style.display&&(n.style.display="block"):(t.notification=null,t.createNotificationElement());let o=t=>{if(!t||1!==t.nodeType)return;let e=t=>{"false"!==t.contentEditable&&(t.contentEditable="false",t.setAttribute("tc-lock",""),r.observe(t,{attributes:!0,attributeFilter:["contenteditable"]}))};e(t),t.querySelectorAll("*").forEach(e)},r=new MutationObserver(t=>{t.forEach(t=>{"attributes"===t.type&&"contentEditable"===t.attributeName&&"true"===t.target.contentEditable&&t.target.hasAttribute("tc-lock")&&(t.target.contentEditable="false")})});setTimeout(()=>{o(t.btn),o(t.overlay),o(t.notification),o(t.host)},0)},5e3)}disablePlugin(t){return this.disabledPlugins.includes(t)||this.disabledPlugins.push(t),this.destroyPlugin(t),this}enablePlugin(t){return this.disabledPlugins=this.disabledPlugins.filter(e=>e!==t),this.loadSinglePlugin(t),this}applyIcon(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new Error("applyIcon: object required");for(let s in e)if(e.hasOwnProperty(s)){if("string"!=typeof e[s]||-1===e[s].indexOf("|"))throw new Error("图标"+s+"格式错误,必须是viewBox|path.d格式");t[s]=e[s]}}setFilterIcon(e,s){let i=this.overlay.querySelector('[data-type="'+e+'"],[data-ls-type="'+e+'"],[data-orig="'+e+'"],[data-net-filter="'+e+'"]');if(!i)return!1;if(!t[s])throw new Error("图标"+s+"不存在");i.dataset.icon=s;let n=i.dataset.orig||i.dataset.type||i.dataset.lsType||i.dataset.netFilter||"",o=i.classList.contains("active");return i.innerHTML=this.icon(s)+" "+n+(o?" (0)":""),!0}createSandbox(t){let e=this;return new Proxy(t,{get(s,i){if("options"!==i&&"pluginOption"!==i){if("__isSandbox"===i)return!0;if("string"==typeof i&&i in s){let t=s[i];return"function"==typeof t?t.bind(e):t}return s[i]}},set:(t,s)=>("options"===s||"pluginOption"===s||console.warn(`[thinConsole] 插件沙箱阻止了修改属性: ${String(s)}`),!0),deleteProperty:(t,s)=>"options"!==s&&"pluginOption"!==s&&(delete t[s],!0)})}loadSinglePlugin(t){if(!this.disabledPlugins.includes(t)&&e.plugins[t]&&!this.plugins[t]){try{let i=new(0,e.plugins[t])(this.createSandbox(this));if(i.pluginOption="object"!=typeof this.options.pluginOption[t]||Array.isArray(this.options.pluginOption[t])||null===this.options.pluginOption[t]?{}:this.options.pluginOption[t],i.init(),this.plugins[t]=i,i.addTab){let e=i.addTab();this.createPluginTab(e),this.pluginTabs[t]={id:e.id,name:e.name,icon:e.icon||"plug",plugin:i}}this.triggerGlobalHook("pluginMount",t,i)}catch(e){console.error(`插件"${t}"加载失败:`,e)}return this}}applyCSS(e){let t=document.createElement("style");return t.textContent=e,this.shadowRoot.appendChild(t),t}createVirtualList(t,e){this.vsInit(t);let s=e.initialData||[],i=e.itemHeight,n=e.renderItem,o=e=>"string"==typeof e?e:e.outerHTML,r=t=>o(n(t)),h=e.emptyHTML||"",k=e.trackBy;return this.vsUpdate(t,s,r,i,{force:!0,emptyHTML:h,trackBy:k}),{update:(e,s)=>{this.vsUpdate(t,e||[],s?t=>o(s(t)):r,i,{emptyHTML:h,trackBy:k})},render:()=>this.vsRender(t),destroy:()=>{t._vs&&(t.removeEventListener("scroll",t._vs.scrollHandler),delete t._vs)}}}initPlugins(){return Object.keys(e.plugins).forEach(t=>{this.disabledPlugins.includes(t)||this.loadSinglePlugin(t)}),this}destroyPlugin(t){let e=this.plugins[t];if(!e)return;"function"==typeof e.destroy&&e.destroy();let s=this.pluginTabs[t]?.id;if(s){let t=this.overlay.querySelector(`.tab-btn[data-tab="${s}"]`);t?.remove();let e=this.pluginViewContainers[s];e?.remove(),delete this.pluginViewContainers[s]}return delete this.plugins[t],delete this.pluginTabs[t],this.triggerGlobalHook("pluginUnmount",t),this}triggerGlobalHook(t,...s){return e.hooks[t]&&e.hooks[t].forEach(e=>{try{e.call(this,...s)}catch(e){console.error(`钩子"${t}"执行错误:`,e)}}),this}destroy(){e.tC===this&&(Object.assign(console,this.originalConsole),Object.keys(this.plugins).forEach(t=>this.destroyPlugin(t)),clearInterval(this.protectInterval),this.mediaQuery&&this.themeChangeHandler&&this.mediaQuery.removeEventListener("change",this.themeChangeHandler),this.timerMap&&this.timerMap.forEach(t=>clearTimeout(t.timeoutId)),this.timerMap&&this.timerMap.clear(),this._elementObserver&&this.stopElementObserver(),this._updateFilterRaf&&cancelAnimationFrame(this._updateFilterRaf),this.overlay&&this.overlay.querySelectorAll("[data-filter-ro]").forEach(t=>{t._tcFilterRO&&t._tcFilterRO.disconnect(),t._tcFilterMO&&t._tcFilterMO.disconnect()}),this.btn?.remove(),this.shadowRoot?.querySelector("style[tcstyle]")?.remove(),this.host?.remove(),this.overlay?.remove(),this.notification?.remove(),document.removeEventListener("error",this.RSError,!0),window.removeEventListener("error",this.tCError),window.removeEventListener("unhandledrejection",this.tCUR),this.originalXHR&&(window.XMLHttpRequest=this.originalXHR),this.originalFetch&&(window.fetch=this.originalFetch),e.tC=null)}setOption(t){return this.destroy(),new e(t)}startElementObserver(){this._elementObserver||(this._elementObserver=new MutationObserver(e=>this._onElementMutation(e)),this._observeAllRoots())}stopElementObserver(){this._elementObserver&&(this._elementObserver.disconnect(),this._elementObserver=null),clearTimeout(this._elementRefreshTimer)}_observeAllRoots(){if(!this._elementObserver)return;let o={childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,characterData:!0};this._elementObserver.observe(document.documentElement,o),this.closedShadowRoots.forEach(e=>{try{this._elementObserver.observe(e.root,o)}catch{}})}_onElementMutation(t){let e=new Set;for(let s of t){let t=s.target;if(this.shadowRoot&&t.getRootNode()===this.shadowRoot)continue;let i=t;for(;i;){if(this.expandedElements.has(i)){e.add(i);break}i=i.parentNode||i.host||null}}e.size>0&&(clearTimeout(this._elementRefreshTimer),this._elementRefreshTimer=setTimeout(()=>{if("elements"!==this.currentTab)return;this._observeAllRoots();let t=this.elementsTree?this.elementsTree.scrollTop:0;this._refreshMutatedNodes(e),this.elementsTree&&(this.elementsTree.scrollTop=t)},300))}_renderElShadow(t,e,s){let i=this.getShadowRoot(t);if(!i)return"";let n=Array.from(i.root.childNodes).filter(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()||this.options.showComments&&8===t.nodeType);if(!n.length&&"closed"!==i.mode)return"";if(this.expandedElements.has(i.root)||0===e){let t=++this.elRefId;return this.elRefMap.set(t,i.root),this._treeShadowNode(!0,"data-el-id",t,i.mode,this.renderDomChildrenLazy(n,(t,e,s)=>this.renderElementTree(t,s),e,"element-shadow",{}),'data-shadow-host="'+s+'"')}return this.buildShadowLazy(i,"element",null,e,s)}_refreshMutatedNodes(e){let t=!1;for(let s of e){let i=-1;if(this.elRefMap)for(let[r,l]of this.elRefMap)if(l===s){i=r;break}if(i<0){t=!0;continue}let n=this.elementsTree?.querySelector('.tree-node[data-el-id="'+i+'"]');if(n?.classList.contains("expanded")){let r=n.querySelector(":scope > .tree-children");r&&(r.innerHTML=this.renderDomChildrenLazy(Array.from(s.childNodes).filter(t=>1===t.nodeType||3===t.nodeType&&t.textContent.trim()||this.options.showComments&&8===t.nodeType),(t,e,s)=>this.renderElementTree(t,s),parseInt(n.dataset.depth||0)+1,"element",{})+this._renderElShadow(s,parseInt(n.dataset.depth||0)+1,i))}else t=!0}if(!t&&this.selectedElement){let e=null;if(this.elRefMap)for(let[s,i]of this.elRefMap)if(i===this.selectedElement){e=s;break}if(null!==e){let s=this.elementsTree?.querySelector('.tree-node[data-el-id="'+e+'"]');s&&(this.elementsTree.querySelectorAll(".el-selected").forEach(e=>e.classList.remove("el-selected")),s.classList.add("el-selected"))}}t&&this.renderElementsView()}_applyCustomThemeCSS(){let t=this.shadowRoot?.querySelector("style[data-custom-theme]");t?.remove();let s=e.themes[this.currentTheme];if(!s)return;let i=this._getThemeVars("light"),n=Object.assign({},i,s.vars),o=".theme-"+this.currentTheme+"{";for(let t in n)o+=t+":"+n[t]+";";o+="}";let r=document.createElement("style");r.setAttribute("data-custom-theme",""),r.textContent=o,this.shadowRoot?.appendChild(r)}_getThemeVars(t){let s=this.shadowRoot?.querySelector("style[tcstyle]");if(!s)return{};let i=s.textContent,n=".theme-"+t+"{",o=i.indexOf(n);if(o<0)return{};o+=n.length;let r=i.indexOf("}",o),a=i.slice(o,r),l={};return a.split(";").forEach(e=>{let t=e.indexOf(":");t>0&&(l[e.slice(0,t).trim()]=e.slice(t+1).trim())}),l}_injectHeaderButtons(){if(!e.headerButtons.length)return;let t=this.overlay.querySelector(".header-actions");if(t)for(let s of e.headerButtons){let i=document.createElement("button");i.className="header-icon-btn tc-header-btn",i.innerHTML=this.icon(s.icon),i.title=s.icon,s.fn&&i.addEventListener("click",s.fn),t.insertBefore(i,this.searchToggleBtn)}}createNetRequest(t,e){return this._netReqId=this._netReqId||1,{id:++this._netReqId,url:e||"",method:(t||"GET").toUpperCase(),status:0,statusText:"",reqHeaders:{},reqBody:null,resHeaders:{},resBody:null,startTime:Date.now(),endTime:0,duration:0,error:null}}finalizeNetRequest(t,e,s,i,n,o){t.status=e,t.statusText=s||"",t.endTime=Date.now(),t.duration=t.endTime-t.startTime,i&&(t.resHeaders=i),null!=n&&(t.resBody=n),o&&(t.error=o),"network"===this.currentTab&&this.renderNetworkList(),this.netDetailId===t.id&&this.showNetDetail(t.id)}_fmtNetReq(e){let t=e.status>0?Math.floor(e.status/100)+"xx":"pending",s=e.status>0?e.status+" "+(e.statusText||""):e.error||"等待中...",i=e.duration>0?e.duration+"ms":"",n=i?s+" ("+i+")":s,o="";try{o=this.safeStringify(e.reqHeaders,2,!1)}catch(t){o=String(e.reqHeaders||"")}o=o.replace(/\\u000[23]/g,"");let r=!o||"{}"===o||"null"===o,l="";if(e.reqBody)try{l="string"==typeof e.reqBody?e.reqBody:this.safeStringify(e.reqBody,2,!1)}catch(t){l=String(e.reqBody)}l=l.replace(/\\u000[23]/g,"");let c=!l||"null"===l||"undefined"===l,d="";try{d=this.safeStringify(e.resHeaders,2,!1)}catch(t){d=String(e.resHeaders||"")}d=d.replace(/\\u000[23]/g,"");let p=!d||"{}"===d||"null"===d,u=e.resBody||"",f="";if(u)try{f=JSON.stringify(JSON.parse(u),null,2)}catch(t){f=u}let m=!f||"null"===f||"undefined"===f;return{sc:t,st:s,sf:n,rhs:o,rhe:r,rbs:l,rbe:c,shs:d,she:p,sbs:f,sbe:m,ct:"网址: "+e.url+"\n方法: "+e.method+"\n状态: "+n+(r?"":"\n\n请求头:\n"+o)+(c?"":"\n\n请求内容:\n"+l)+(p?"":"\n\n响应头:\n"+d)+(m?"":"\n\n响应内容:\n"+f)}}pushNetRequest(t){this.networkRequests.push(t),this.networkRequests.length>this.maxNetwork&&this.networkRequests.splice(0,this.networkRequests.length-this.maxNetwork),"network"===this.currentTab&&this.renderNetworkList()}_isNetDisabled(t){if(0===this.netDisabledTypes.size)return!1;let e=t.toLowerCase();return this.netDisabledTypes.has("all")||this.netDisabledTypes.has(e)}captureNetworkRequests(){this.originalXHR=this.originalXHR||window.XMLHttpRequest;let t=this,e=this.originalXHR;window.XMLHttpRequest=function(){let s=new e,i=t.createNetRequest("GET",""),n=s.open;s.open=function(t,e){return i.method=t.toUpperCase(),i.url=e,n.apply(s,arguments)};let o=s.send;s.send=function(e){if(t._isNetDisabled(i.method))return;i.reqBody=e,i.startTime=Date.now();let n={...i};return t.pushNetRequest(n),s.addEventListener("loadend",function(){let e={},i=null;try{s.getAllResponseHeaders().trim().split("\n").forEach(t=>{let s=t.indexOf(":");s>0&&(e[t.slice(0,s).trim()]=t.slice(s+1).trim())})}catch(t){}try{i=s.responseText}catch(t){}t.finalizeNetRequest(n,s.status,s.statusText,e,i,null)}),s.addEventListener("error",function(){t.finalizeNetRequest(n,0,"",null,null,"Network Error")}),s.addEventListener("abort",function(){t.finalizeNetRequest(n,0,"",null,null,"Aborted")}),o.apply(s,arguments)};let r=s.setRequestHeader;return s.setRequestHeader=function(t,e){return i.reqHeaders[t]=e,r.apply(s,arguments)},s},this.originalFetch=this.originalFetch||window.fetch;let s=this.originalFetch;window.fetch=function(e,i){let n="string"==typeof e?e:e.url,o=(i&&i.method||"GET").toUpperCase();if(t._isNetDisabled(o))return Promise.reject(new Error("Request disabled by thinConsole"));let r=t.createNetRequest(o,n);return i&&i.headers&&(i.headers instanceof Headers?i.headers.forEach((t,e)=>r.reqHeaders[e]=t):"object"==typeof i.headers&&Object.assign(r.reqHeaders,i.headers)),i&&i.body&&(r.reqBody=i.body),t.pushNetRequest(r),s.apply(window,arguments).then(e=>{let s={};return e.headers.forEach((t,e)=>s[e]=t),e.clone().text().then(i=>{t.finalizeNetRequest(r,e.status,e.statusText,s,i,null)}).catch(()=>{t.finalizeNetRequest(r,e.status,e.statusText,s,null,null)}).then(()=>e)}).catch(e=>{throw"AbortError"===e.name?t.finalizeNetRequest(r,0,"",null,null,"Aborted"):t.finalizeNetRequest(r,0,"",null,null,e.message),e})}}renderNetFilters(){this.netFiltersEl&&(this.netFiltersEl.innerHTML=[{id:"all",name:"全部",icon:"list"},{id:"get",name:"获取",icon:"download"},{id:"post",name:"提交",icon:"upload"},{id:"put",name:"更新",icon:"pen"},{id:"success",name:"成功",icon:"check-circle"},{id:"failed",name:"失败",icon:"times-circle"}].map(t=>`<button class="net-filter-btn ${this.activeNetFilter===t.id?"active":""}" data-net-filter="${t.id}" data-orig="${t.name}" data-icon="${t.icon}">${this.icon(t.icon)} ${t.name}</button>`).join(""),this.netFiltersEl.querySelectorAll(".net-filter-btn").forEach(t=>{t.addEventListener("click",()=>{this.netFiltersEl.querySelectorAll(".net-filter-btn").forEach(t=>t.classList.remove("active")),t.classList.add("active"),this.activeNetFilter=t.dataset.netFilter,this.renderNetworkList(),this.updateNetDisableBtn(),this.scrollFilterIntoView(this.netFiltersEl,t)})}),this.updateNetFilterCounts())}updateNetFilterCounts(){if(!this.netFiltersEl)return;let t=this.networkRequests,e={all:t.length,get:t.filter(t=>"get"===t.method.toLowerCase()).length,post:t.filter(t=>"post"===t.method.toLowerCase()).length,put:t.filter(t=>"put"===t.method.toLowerCase()).length,success:t.filter(t=>t.status>=200&&t.status<400).length,failed:t.filter(t=>0===t.status||t.status>=400||t.error).length};this._updateFilterBtns(this.netFiltersEl,e,"netFilter",(t,e,s)=>{let i=t.dataset.orig,n=t.dataset.icon||"",f=this._fmtCount(e,!0);return t.title=s?""+f.exactCount:"",this.icon(n)+" "+i+(s?" ("+f.filterCount+")":"")})}updateNetDisableBtn(){if(!this.netDisableBtn)return;let t=this.activeNetFilter,e="";"all"===t?e="全部":"get"===t?e="获取":"post"===t?e="提交":"put"===t?e="更新":"success"===t?e="成功(全部)":"failed"===t&&(e="失败(全部)");let s=this.netDisabledTypes.has(t);this.netDisableBtn.innerHTML=this.icon("ban"),this.netDisableBtn.title=s?`已禁用${e}请求`:`禁用${e}请求`,this.netDisableBtn.classList.toggle("disabled",s)}toggleNetDisable(){let t=this.activeNetFilter,e="";if("all"===t?e="全部":"get"===t?e="获取":"post"===t?e="提交":"put"===t?e="更新":"success"===t?e="成功(全部)":"failed"===t&&(e="失败(全部)"),this.netDisabledTypes.has(t)){this.netDisabledTypes.delete(t);var s=!1}else this.netDisabledTypes.add(t),s=!0;this.updateNetDisableBtn(),this.showNotification(s?`已禁用${e}请求`:`已恢复${e}请求`,s?"warning":"")}getFilteredNetRequests(){let t=this.networkRequests;if(!this.activeNetFilter||"all"===this.activeNetFilter)return t;let e=this.activeNetFilter;return"get"===e||"post"===e||"put"===e?t.filter(t=>t.method.toLowerCase()===e):"success"===e?t.filter(t=>t.status>=200&&t.status<400):"failed"===e?t.filter(t=>0===t.status||t.status>=400||t.error):t}renderNetworkList(){if("network"!==this.currentTab)return;if(!this.networkItems)return;let t=this.getFilteredNetRequests();if(this.searchQuery){let e=this.searchQuery.toLowerCase();t=t.filter(t=>{if(t.url.toLowerCase().includes(e))return!0;if(t.method.toLowerCase().includes(e))return!0;try{if(this.safeStringify(t.reqHeaders).toLowerCase().includes(e))return!0}catch(t){}try{if(("string"==typeof t.reqBody?t.reqBody:this.safeStringify(t.reqBody)).toLowerCase().includes(e))return!0}catch(t){}try{if(this.safeStringify(t.resHeaders).toLowerCase().includes(e))return!0}catch(t){}return!!(t.resBody||"").toLowerCase().includes(e)})}this.updateNetFilterCounts(),0!==t.length?this.vsUpdate(this.networkItems,t,t=>this.renderNetworkItem(t),100):this.vsUpdate(this.networkItems,[],null,0,{emptyHTML:'<div class="nolog">'+this.icon("wifi")+"暂无网络请求</div>"})}renderNetworkItem(t){let e=t.status>0?Math.floor(t.status/100)+"xx":"pending",s=t.error||t.status>=400?"net-failed":t.status>=200&&t.status<400?"net-success":"",i=t.status>0?String(t.status):t.error?"ERR":"...",n=t.duration>0?t.duration+"ms":"",o=n?i+" "+n:i,r="",u=this.escapeHtml(t.url);try{r=new Date(t.startTime).toLocaleTimeString()}catch(t){r=""}return`<div class="net-item ${s}" data-req-id="${t.id}"><div class="net-row1"><span class="net-method net-method-${t.method}">${t.method}</span><span class="net-time">${this.escapeHtml(r)}</span></div><div class="net-row2"><span class="net-url" title="${u}">${u}</span><span class="net-status net-status-${e}">${this.escapeHtml(o)}</span></div><div class="net-row3"><button class="net-copy-btn" data-action="copy" title="复制完整请求信息">${this.icon("copy")} 复制</button><button class="net-detail-btn" data-action="detail" title="查看详情">${this.icon("eye")} 详情</button></div></div>`}showNetDetail(t){let e=this.networkRequests.find(e=>e.id===t);if(!e)return;this.netDetailId=t;let n=this._fmtNetReq(e),s=n.sc,o=(n.st,n.sf),r=n.rhs,l=n.rhe,a=l?'<span class="net-detail-empty">无请求头</span>':this.renderJSONTree(r,"",0,0,"net-"+t+"-reqHeaders",0,!0),c=n.rbs,d=n.rbe,h=d?'<span class="net-detail-empty">无请求内容</span>':this.renderJSONTree(c,"",0,0,"net-"+t+"-reqBody",0,!0),p=n.shs,u=n.she,g=u?'<span class="net-detail-empty">无响应头</span>':this.renderJSONTree(p,"",0,0,"net-"+t+"-resHeaders",0,!0),m=n.sbs,b=n.sbe,y=b?'<span class="net-detail-empty">无响应内容</span>':this.renderJSONTree(m,"",0,0,"net-"+t+"-resBody",0,!0),v=(e.resBody,(t,e,s,i)=>`<div class="net-detail-section"><div class="net-detail-section-header"><div class="net-detail-label">${t}</div>${i?"":`<button class="net-detail-copy-section" data-copy-text="${this.escapeHtml(s)}" title="复制">${this.icon("copy")}</button>`}</div><div class="${i||e.indexOf("json-tree-container")>=0?"net-detail-value":"net-detail-value net-detail-code"}">${e}</div></div>`),x=`<div class="net-detail-section"><div class="net-detail-section-header"><div class="net-detail-label">网址</div><button class="net-detail-copy-section" data-copy-text="${this.escapeHtml(e.url)}" title="复制网址">${this.icon("copy")}</button></div><div class="net-detail-value net-detail-code">${this.escapeHtml(e.url)}</div></div>`,w=`<div class="net-detail-section"><div class="net-detail-section-header"><div class="net-detail-label">类型</div></div><span class="net-method net-method-${e.method}">${e.method}</span></div>`,k=`<div class="net-detail-section"><div class="net-detail-section-header"><div class="net-detail-label">状态</div></div><span class="net-status net-status-${s}">${this.escapeHtml(o)}</span></div>`,S=v("请求头",a,r,l),E=v("请求内容",h,c,d),C=v("响应头",g,p,u),L=v("响应内容",y,m,b);this.netDetailBody.innerHTML=x+w+k+S+E+C+L,this.netDetailBody.querySelectorAll(".net-detail-copy-section").forEach(t=>{t.addEventListener("click",()=>{let s=t.getAttribute("data-copy-text")||"";navigator.clipboard.writeText(s).then(()=>this.showNotification("已复制")).catch(()=>{})})});let T=this.overlay.querySelector("#netResendIconBtn");T&&T.addEventListener("click",()=>this.resendRequest(e));let B=this.overlay.querySelector("#netCopyIconBtn");B&&B.addEventListener("click",()=>{navigator.clipboard.writeText(n.ct).then(()=>this.showNotification("已复制完整请求信息")).catch(()=>{})}),this.netDetailOverlay.style.display="flex"}resendRequest(t){this.netDetailOverlay.style.display="none",this.netNewOverlay.style.display="flex",this.netNewUrl.value=t.url,this.netNewMethod.value=t.method;let e="";if(t.reqBody)try{e="string"==typeof t.reqBody?t.reqBody:JSON.stringify(t.reqBody,null,2)}catch(t){e=""}this.netNewBody.value=e||"";let s="";try{t.reqHeaders&&"object"==typeof t.reqHeaders&&(s=(Array.isArray(t.reqHeaders)?t.reqHeaders:Object.entries(t.reqHeaders)).map(t=>Array.isArray(t)?t[0]+": "+t[1]:t).join("\n"))}catch(t){}this.netNewHeaders.value=s||""}sendNewRequest(){if(this.editorState.visible){let t=this.editorState.mode;if("code"===t)return void this.showNotification("正在运行代码,无法发送请求","warning");if("ls"===t)return void this.showNotification("正在保存键值,无法发送请求","warning")}let t=this.netNewUrl.value.trim();if(!t)return void this.showNotification("请输入网址","warning");let e=this.netNewMethod.value,s=this.netNewBody.value.trim(),i=this.netNewHeaders.value.trim(),n={};i&&i.split("\n").forEach(t=>{let e=t.indexOf(":");e>0&&(n[t.slice(0,e).trim()]=t.slice(e+1).trim())});let o={method:e,headers:n};if(s&&"GET"!==e&&"HEAD"!==e)try{o.body=JSON.stringify(JSON.parse(s)),n["Content-Type"]||(n["Content-Type"]="application/json")}catch(t){o.body=s}this.netSending=!0,this.netNewVisible=!1,this.netNewOverlay.style.display="none",this.showNotification("正在发送请求...");let r={id:++this._netReqId,url:t,method:e,status:0,statusText:"",reqHeaders:n,reqBody:o.body||null,resHeaders:{},resBody:null,startTime:Date.now(),endTime:0,duration:0,error:null};this.networkRequests.push(r),(this.originalFetch||window.fetch).call(window,t,o).then(t=>{this.netSending=!1,r.status=t.status,r.statusText=t.statusText,r.endTime=Date.now(),r.duration=r.endTime-r.startTime,t.clone().text().then(t=>{r.resBody=t,this.netDetailId===r.id&&this.showNetDetail(r.id)}).catch(()=>{}),t.headers.forEach((t,e)=>r.resHeaders[e]=t),this.showNotification("请求完成: "+t.status,t.status>=400?"warning":""),"network"===this.currentTab&&this.renderNetworkList(),this.netNewUrl.value="",this.netNewBody.value="",this.netNewHeaders.value="",this.netNewMethod.value="GET"}).catch(t=>{this.netSending=!1,r.error=t.message,r.status=0,r.endTime=Date.now(),r.duration=r.endTime-r.startTime,this.netDetailId===r.id&&this.showNetDetail(r.id),this.showNotification("请求失败: "+t.message,"warning"),"network"===this.currentTab&&this.renderNetworkList(),this.netNewUrl.value="",this.netNewBody.value="",this.netNewHeaders.value="",this.netNewMethod.value="GET"})}renderNetworkPanel(){this.renderNetFilters(),this.updateNetDisableBtn(),this.renderNetworkList()}clearNetworkRequests(){let t=this.activeNetFilter||"all",e="";"all"===t?e="全部":"get"===t?e="获取":"post"===t?e="提交":"put"===t?e="更新":"success"===t?e="成功":"failed"===t&&(e="失败");this.getFilteredNetRequests();if(confirm("确定要清除所有"+e+"请求吗?此操作不可撤销。")){if("all"===t)this.networkRequests=[];else{let e="get"===t||"post"===t||"put"===t?e=>e.method.toLowerCase()!==t:"success"===t?t=>!(t.status>=200&&t.status<400):t=>!(0===t.status||t.status>=400||t.error);this.networkRequests=this.networkRequests.filter(e)}this.renderNetworkList(),this.showNotification("已清空"+e+"请求")}}switchTab(t){let e=Array.from(this.tabButtons).find(e=>e.dataset.tab===t);e&&e.click()}show(t="console"){return this.overlay||this.createOverlayElement(),this.switchTab(t),this.triggerGlobalHook("beforeOpen"),this.overlay.classList.add("active","theme-"+this.currentTheme),this.triggerGlobalHook("afterOpen"),this}hide(){return this.overlay&&(this.triggerGlobalHook("beforeClose"),this.overlay.classList.remove("active"),this.triggerGlobalHook("afterClose")),this}get storage(){let t=t=>{document.cookie=encodeURIComponent(t)+"=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/",document.cookie=encodeURIComponent(t)+"=;expires=Thu, 01 Jan 1970 00:00:00 GMT"},e=(t,e,s,i,n,o)=>({get:t,set:e,remove:s,clear:i,length:n,key:o});return{local:e(t=>localStorage.getItem(t),(t,e)=>localStorage.setItem(t,e),t=>localStorage.removeItem(t),()=>localStorage.clear(),()=>localStorage.length,t=>localStorage.key(t)),session:e(t=>sessionStorage.getItem(t),(t,e)=>sessionStorage.setItem(t,e),t=>sessionStorage.removeItem(t),()=>sessionStorage.clear(),()=>sessionStorage.length,t=>sessionStorage.key(t)),cookie:e(t=>{let e=encodeURIComponent(t),s=document.cookie.match(new RegExp("(?:^|;\\s)"+e.replace(/([.*+?^${}()|[\]\\])/g,"\\$1")+"=([^;]*)"));return s?decodeURIComponent(s[1]):null},(t,e,s)=>{let i=new Date;i.setTime(i.getTime()+864e5*(s||365)),document.cookie=encodeURIComponent(t)+"="+encodeURIComponent(e)+";expires="+i.toUTCString()+";path=/"},t,()=>{document.cookie.split(";").forEach(e=>{let s=e.split("=")[0].trim();s&&t(s)})},()=>document.cookie?document.cookie.split(";").filter(t=>t.trim()).length:0,t=>{let e=document.cookie?document.cookie.split(";").filter(t=>t.trim()):[];return e[t]?decodeURIComponent(e[t].split("=")[0]):null})}}icon(e,s){let i=String(e||"").trim();if(!i)return"";let n=t[i];if(!n)return"";let o=n.indexOf("|");return'<svg class="ico ico-'+i+(s?" "+s:"")+'" viewBox="'+n.slice(0,o)+'" aria-hidden="true"><path fill="currentColor" d="'+n.slice(o+1)+'"/></svg>'}treeToggleHtml(){return'<span class="tree-toggle">'+this.icon("angle-right")+this.icon("angle-down")+"</span>"}}e.plugins={},e.themes={},e.headerButtons=[],window.thinConsole=e,e.tC=null,e.hooks={beforeRender:[],afterRender:[],beforeLog:[],afterLog:[],beforeOpen:[],afterOpen:[],beforeClose:[],afterClose:[],beforeClear:[],afterClear:[],pluginMount:[],pluginUnmount:[]},e.addTheme=function(t,s,i){if("string"!=typeof t||!t)throw new Error("name must be string");if("string"!=typeof s)throw new Error("styles must be string");let n={};return s.split(";").forEach(e=>{let t=e.indexOf(":");t>0&&(t=e.slice(0,t).trim(),n[t]=e.slice(t+1).trim())}),e.themes[t]={vars:n,icons:i&&"object"==typeof i?i:{}},e.tC&&e.tC.overlay&&(e.tC._applyCustomThemeCSS(),e.tC.currentTheme===t&&e.tC._themeIconsApplied!==t&&(e.tC.applyIcon(e.themes[t].icons),e.tC._themeIconsApplied=t)),e},e.addHeader=function(t,s){if(e.headerButtons.length>=5)return e;if(e.headerButtons.push({icon:t,fn:s}),e.tC&&e.tC.overlay&&e.tC.searchToggleBtn){let i=e.tC.overlay.querySelector(".header-actions");if(i){let n=document.createElement("button");n.className="header-icon-btn tc-header-btn",n.innerHTML=e.tC.icon(t),n.title=t,s&&n.addEventListener("click",s),i.insertBefore(n,e.tC.searchToggleBtn)}}return e},e.setOption=function(t){return e.tC?e.tC.setOption(t):new e(t)},e.show=t=>(e.tC?.show(t),e),e.hide=()=>(e.tC?.hide(),e),e.destroy=()=>e.tC?.destroy(),e.log=(...t)=>(console.log(...t),e),e.info=(...t)=>(console.info(...t),e),e.warn=(...t)=>(console.warn(...t),e),e.error=(...t)=>(console.error(...t),e),e.addPlugin=function(t,i){if(e.tC){if(i.prototype instanceof s){if(e.plugins[t]=i,e.tC.disabledPlugins.includes(t))return;if(e.tC.pluginEnabled&&!e.tC.plugins[t])try{let s=new i(e.tC.createSandbox(e.tC));if(s.pluginOption="object"!=typeof e.tC.options.pluginOption[t]||Array.isArray(e.tC.options.pluginOption[t])||null===e.tC.options.pluginOption[t]?{}:e.tC.options.pluginOption[t],s.init(),e.tC.plugins[t]=s,s.addTab){let i=s.addTab();e.tC.pluginTabs[t]={id:i.id,name:i.name,icon:i.icon||"tool",plugin:s},e.tC.createPluginTab(i)}e.tC.triggerGlobalHook("pluginMount",t,s)}catch(i){console.error(`插件"${t}"动态加载失败:`,i)}}else{if("function"!=typeof i)throw new Error(`插件"${t}"必须是类或函数类型`);if(!e.tC.options.plugins||e.tC.disabledPlugins.includes(t))return;try{i.call(null,e.tC.createSandbox(e.tC)),e.tC.triggerGlobalHook("pluginMount",t,null)}catch(i){console.error(`函数插件"${t}"执行失败:`,i)}}return e}},e.addTabs=function(t){if(!e.tC)return e;Array.isArray(t)||(t=[t]);for(let s of t){if(e.tC.customTabCount>=5){console.warn("自定义Tab数量已达上限(5个)");break}if(!s.id||!s.name){console.warn("Tab必须包含id和name属性");continue}if(e.tC.pluginViewContainers[s.id]){console.warn("Tab ID '"+s.id+"'已存在");continue}e.tC.createPluginTab({id:s.id,name:s.name,icon:s.icon||"plug"});let t=e.tC.pluginViewContainers[s.id];t&&(t.innerHTML="","function"==typeof s.render?s.render(t):s.html&&(t.innerHTML=s.html),s.onShow&&(e.tC.pluginTabs[s.id]={id:s.id,name:s.name,icon:s.icon||"plug",onShow:s.onShow})),e.tC.customTabCount++}return e},e.addHook=function(t,s){return e.hooks[t]&&!e.hooks[t].includes(s)?e.hooks[t].push(s):console.warn(`未知钩子:${t}`),e},e.removeHook=function(t,s){return e.hooks[t]&&(e.hooks[t]=e.hooks[t].filter(t=>t!==s)),e},e.setFilterCounts=function(t){return e.tC&&e.tC._updateFilterCounts(e.tC.pluginViewContainers[e.tC.currentTab],"object"==typeof t?t:null,!0),e};class s{constructor(t){if(!(t instanceof e))throw new Error("plugin needs tC");this.tC=t,this.pluginOption={},this.id=this.constructor.name.toLowerCase()}init(){}iszh(){return!0}isen(){return!1}isMobile(){return/iPad|Android(?!.*Mobile)|Mobi|Android|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}render(t){}onShow(){}onHide(){}destroy(){}}return e.tCPlugin=s,"undefined"!=typeof window&&(window.tCPlugin=s),e});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):e.thinConsole=t()}("undefined"!=typeof self?self:this,function(){let e={"angle-down":"384|M169.4 374.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 306.7 54.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z","angle-right":"256|M247.1 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L179.2 256 41.9 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z","arrow-left":"512|M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.3 288H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H109.3l105.4-105.4c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z",ban:"512|M367.2 412.5 99.5 144.8C77.1 176.2 64 214.6 64 256c0 106 86 192 192 192 41.5 0 79.9-13.1 111.2-35.5m45.3-45.3C434.9 335.8 448 297.4 448 256c0-106-86-192-192-192-41.5 0-79.9 13.1-111.2 35.5zM0 256a256 256 0 1 1 512 0 256 256 0 1 1-512 0",check:"448|M434.8 70.1c14.3 10.4 17.5 30.4 7.1 44.7l-256 352c-5.5 7.6-14 12.3-23.4 13.1s-18.5-2.7-25.1-9.3l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l101.5 101.5 234-321.7c10.4-14.3 30.4-17.5 44.7-7.1z","check-circle":"512|M256 512a256 256 0 1 1 0-512 256 256 0 1 1 0 512m118-366.3c-10.7-7.8-25.7-5.4-33.5 5.3L221.1 315.2 169 263.1c-9.4-9.4-24.6-9.4-33.9 0s-9.4 24.6 0 33.9l72 72c5 5 11.8 7.5 18.8 7s13.4-4.1 17.5-9.8l135.9-187c7.8-10.7 5.4-25.7-5.3-33.5","chevron-down":"448|M201.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 338.7 54.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z","chevron-up":"448|M201.4 105.4c12.5-12.5 32.8-12.5 45.3 0l192 192c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L224 173.3 54.6 342.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l192-192z",code:"576|M360.8 1.2c-17-4.9-34.7 5-39.6 22l-128 448c-4.9 17 5 34.7 22 39.6s34.7-5 39.6-22l128-448c4.9-17-5-34.7-22-39.6m64.6 136.1c-12.5 12.5-12.5 32.8 0 45.3l73.4 73.4-73.4 73.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l96-96c12.5-12.5 12.5-32.8 0-45.3l-96-96c-12.5-12.5-32.8-12.5-45.3 0zm-274.7 0c-12.5-12.5-32.8-12.5-45.3 0l-96 96c-12.5 12.5-12.5 32.8 0 45.3l96 96c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256l73.3-73.4c12.5-12.5 12.5-32.8 0-45.3z",copy:"448|M192 0c-35.3 0-64 28.7-64 64v256c0 35.3 28.7 64 64 64h192c35.3 0 64-28.7 64-64V119.4c0-17.4-7.1-34.1-19.7-46.2l-57.7-55.4A64.1 64.1 0 0 0 326.3 0zM64 128c-35.3 0-64 28.7-64 64v256c0 35.3 28.7 64 64 64h192c35.3 0 64-28.7 64-64v-16h-64v16H64V192h16v-64z",database:"448|M448 205.8c-14.8 9.8-31.8 17.7-49.5 24-47 16.8-108.7 26.2-174.5 26.2s-127.6-9.5-174.5-26.2c-17.6-6.3-34.7-14.2-49.5-24V288c0 44.2 100.3 80 224 80s224-35.8 224-80zm0-77.8V80c0-44.2-100.3-80-224-80S0 35.8 0 80v48c0 44.2 100.3 80 224 80s224-35.8 224-80m-49.5 261.8C351.6 406.5 289.9 416 224 416s-127.6-9.5-174.5-26.2c-17.6-6.3-34.7-14.2-49.5-24V432c0 44.2 100.3 80 224 80s224-35.8 224-80v-66.2c-14.8 9.8-31.8 17.7-49.5 24",download:"448|M256 32c0-17.7-14.3-32-32-32s-32 14.3-32 32v210.7l-41.4-41.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l96 96c12.5 12.5 32.8 12.5 45.3 0l96-96c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 242.7zM64 320c-35.3 0-64 28.7-64 64v32c0 35.3 28.7 64 64 64h320c35.3 0 64-28.7 64-64v-32c0-35.3-28.7-64-64-64h-46.9l-56.6 56.6c-31.2 31.2-81.9 31.2-113.1 0L110.9 320zm304 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48",edit:"512|M471.6 21.7c-21.9-21.9-57.3-21.9-79.2 0L368 46.1l97.9 97.9 24.4-24.4c21.9-21.9 21.9-57.3 0-79.2zm-299.2 220c-6.1 6.1-10.8 13.6-13.5 21.9l-29.6 88.8c-2.9 8.6-.6 18.1 5.8 24.6s15.9 8.7 24.6 5.8l88.8-29.6c8.2-2.7 15.7-7.4 21.9-13.5L432 177.9 334.1 80zM96 64c-53 0-96 43-96 96v256c0 53 43 96 96 96h256c53 0 96-43 96-96v-96c0-17.7-14.3-32-32-32s-32 14.3-32 32v96c0 17.7-14.3 32-32 32H96c-17.7 0-32-14.3-32-32V160c0-17.7 14.3-32 32-32h96c17.7 0 32-14.3 32-32s-14.3-32-32-32z",exclamation:"0 0 128 512|M64 432c22.1 0 40 17.9 40 40s-17.9 40-40 40-40-17.9-40-40 17.9-40 40-40M64 0c26.5 0 48 21.5 48 48v1.7l-16 304c-.9 17-15 30.3-32 30.3s-31-13.3-32-30.3l-16-304V48C16 21.5 37.5 0 64 0","exclamation-triangle":"512|M256 0c14.7 0 28.2 8.1 35.2 21l216 400c6.7 12.4 6.4 27.4-.8 39.5S486.1 480 472 480H40c-14.1 0-27.2-7.4-34.4-19.5s-7.5-27.1-.8-39.5l216-400c7-12.9 20.5-21 35.2-21m0 352a32 32 0 1 0 0 64 32 32 0 1 0 0-64m0-192c-18.2 0-32.7 15.5-31.4 33.7l7.4 104c.9 12.5 11.4 22.3 23.9 22.3 12.6 0 23-9.7 23.9-22.3l7.4-104c1.3-18.2-13.1-33.7-31.4-33.7z",eye:"576|M288 32c-80.8 0-145.5 36.8-192.6 80.6-46.8 43.5-78.1 95.4-93 131.1-3.3 7.9-3.3 16.7 0 24.6 14.9 35.7 46.2 87.7 93 131.1C142.5 443.1 207.2 480 288 480s145.5-36.8 192.6-80.6c46.8-43.5 78.1-95.4 93-131.1 3.3-7.9 3.3-16.7 0-24.6-14.9-35.7-46.2-87.7-93-131.1C433.5 68.9 368.8 32 288 32M144 256a144 144 0 1 1 288 0 144 144 0 1 1-288 0m144-64c0 35.3-28.7 64-64 64-11.5 0-22.3-3-31.7-8.4-1 10.9-.1 22.1 2.9 33.2 13.7 51.2 66.4 81.6 117.6 67.9s81.6-66.4 67.9-117.6c-12.2-45.7-55.5-74.8-101.1-70.8 5.3 9.3 8.4 20.1 8.4 31.7",info:"192|M48 48a48 48 0 1 1 96 0 48 48 0 1 1-96 0M0 192c0-17.7 14.3-32 32-32h64c17.7 0 32 14.3 32 32v256h32c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32h32V224H32c-17.7 0-32-14.3-32-32","info-circle":"512|M256 512a256 256 0 1 0 0-512 256 256 0 1 0 0 512m-32-352a32 32 0 1 1 64 0 32 32 0 1 1-64 0m-8 64h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24h-80c-13.3 0-24-10.7-24-24s10.7-24 24-24h24v-64h-24c-13.3 0-24-10.7-24-24s10.7-24 24-24",list:"512|M40 48c-13.3 0-24 10.7-24 24v48c0 13.3 10.7 24 24 24h48c13.3 0 24-10.7 24-24V72c0-13.3-10.7-24-24-24zm152 16c-17.7 0-32 14.3-32 32s14.3 32 32 32h288c17.7 0 32-14.3 32-32s-14.3-32-32-32zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32h288c17.7 0 32-14.3 32-32s-14.3-32-32-32zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32h288c17.7 0 32-14.3 32-32s-14.3-32-32-32zM16 232v48c0 13.3 10.7 24 24 24h48c13.3 0 24-10.7 24-24v-48c0-13.3-10.7-24-24-24H40c-13.3 0-24 10.7-24 24m24 136c-13.3 0-24 10.7-24 24v48c0 13.3 10.7 24 24 24h48c13.3 0 24-10.7 24-24v-48c0-13.3-10.7-24-24-24z","mouse-pointer":"448|M77.3 2.5c8.1-4.1 17.9-3.2 25.1 2.3l320 239.9c8.3 6.2 11.6 17 8.4 26.8s-12.4 16.4-22.8 16.4H255.7l88.9 177.7c7.9 15.8 1.5 35-14.3 42.9s-35 1.5-42.9-14.3l-88.9-177.7-91.3 121.8c-6.2 8.3-17 11.6-26.8 8.4S64 434.3 64 424V24c0-9.1 5.1-17.4 13.3-21.5","paper-plane":"576|M536.4-26.3c9.8-3.5 20.6-1 28 6.3s9.8 18.2 6.3 28l-178 496.9c-5 13.9-18.1 23.1-32.8 23.1-14.2 0-27-8.6-32.3-21.7l-64.2-158c-4.5-11-2.5-23.6 5.2-32.6l94.5-112.4c5.1-6.1 4.7-15-.9-20.6s-14.6-6-20.6-.9l-112.4 94.3c-9.1 7.6-21.6 9.6-32.6 5.2L38.1 216.8c-13.1-5.3-21.7-18.1-21.7-32.3 0-14.7 9.2-27.8 23.1-32.8z",pen:"512|M352.9 21.2 308 66.1 445.9 204l44.9-44.9c13.6-13.5 21.2-31.9 21.2-51.1s-7.6-37.6-21.2-51.1l-35.7-35.7C441.6 7.6 423.2 0 404 0s-37.6 7.6-51.1 21.2M274.1 100 58.9 315.1c-10.7 10.7-18.5 24.1-22.6 38.7L.9 481.6c-2.3 8.3 0 17.3 6.2 23.4s15.1 8.5 23.4 6.2l127.8-35.5c14.6-4.1 27.9-11.8 38.7-22.6l215-215.2z",plug:"448|M128-32c17.7 0 32 14.3 32 32v96h128V0c0-17.7 14.3-32 32-32s32 14.3 32 32v96h64c17.7 0 32 14.3 32 32s-14.3 32-32 32v64c0 95.1-69.2 174.1-160 189.3V480c0 17.7-14.3 32-32 32s-32-14.3-32-32v-66.7C101.2 398.1 32 319.1 32 224v-64c-17.7 0-32-14.3-32-32s14.3-32 32-32h64V0c0-17.7 14.3-32 32-32",plus:"448|M256 64c0-17.7-14.3-32-32-32s-32 14.3-32 32v160H32c-17.7 0-32 14.3-32 32s14.3 32 32 32h160v160c0 17.7 14.3 32 32 32s32-14.3 32-32V288h160c17.7 0 32-14.3 32-32s-14.3-32-32-32H256z",redo:"512|M488 192H344c-9.7 0-18.5-5.8-22.2-14.8s-1.7-19.3 5.2-26.2l46.7-46.7C298.4 45.7 189.4 51 120.2 120.2c-75 75-75 196.5 0 271.5s196.5 75 271.5 0q12.3-12.3 21.9-26.1c10.1-14.5 30.1-18 44.6-7.9s18 30.1 7.9 44.6c-8.5 12.2-18.2 23.8-29.1 34.7-100 100-262.1 100-362 0S-25 175 75 75c94.3-94.3 243.7-99.6 344.3-16.2L471 7c6.9-6.9 17.2-8.9 26.2-5.2S512 14.3 512 24v144c0 13.3-10.7 24-24 24",search:"512|M416 208c0 45.9-14.9 88.3-40 122.7l126.6 126.7c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.1-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0s208 93.1 208 208M208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288",table:"448|M384 32c35.3 0 64 28.7 64 64v320c0 35.3-28.7 64-64 64H64l-6.5-.3C25.2 476.4 0 449.1 0 416V96c0-35.3 28.7-64 64-64zM64 320v96h128v-96zm192 0v96h128v-96zM64 256h128v-96H64zm192 0h128v-96H256z",terminal:"512|M9.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L146.7 256zM224 384h256c17.7 0 32 14.3 32 32s-14.3 32-32 32H224c-17.7 0-32-14.3-32-32s14.3-32 32-32",times:"384|M55.1 73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L147.2 256 9.9 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l137.3-137.4 137.4 137.3c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.8 256l137.3-137.4c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192.5 210.7z","times-circle":"512|M256 512a256 256 0 1 0 0-512 256 256 0 1 0 0 512m-89-345c9.4-9.4 24.6-9.4 33.9 0l55 55 55-55c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-55 55 55 55c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-55-55-55 55c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l55-55-55-55c-9.4-9.4-9.4-24.6 0-33.9",tool:"576|M70.8-6.7c5.4-5.4 13.8-6.2 20.2-2l118.9 79.2c8.9 5.9 14.2 15.9 14.2 26.6v49.6l90.8 90.8c33.3-15 73.9-8.9 101.2 18.5l126.1 126.1c18.7 18.7 18.7 49.1 0 67.9l-60.1 60.1c-18.7 18.7-49.1 18.7-67.9 0L288.1 384c-27.4-27.4-33.5-67.9-18.5-101.2L178.8 192h-49.6c-10.7 0-20.7-5.3-26.6-14.2L23.4 58.9c-4.2-6.3-3.4-14.8 2-20.2zm145 303.5c-6.3 36.9 2.3 75.9 26.2 107.2l-94.9 95c-28.1 28.1-73.7 28.1-101.8 0s-28.1-73.7 0-101.8l135.4-135.5 35.2 35.1zM384.1 0c20.1 0 39.4 3.7 57.1 10.5 10 3.8 11.8 16.5 4.3 24.1l-56.7 56.7c-3 3-4.7 7.1-4.7 11.3V144c0 8.8 7.2 16 16 16h41.4c4.2 0 8.3-1.7 11.3-4.7l56.7-56.7c7.6-7.5 20.3-5.7 24.1 4.3 6.8 17.7 10.5 37 10.5 57.1 0 43.2-17.2 82.3-45 111.1L450 222c-33.1-33-78.5-45.7-121.1-38.4l-56.8-56.8V97.1l-.2-5c-.8-12.4-4.4-24.3-10.5-34.9C290.8 22.2 334.8 0 384.1-.1z",trash:"448|M136.7 5.9 128 32H32C14.3 32 0 46.3 0 64s14.3 32 32 32h384c17.7 0 32-14.3 32-32s-14.3-32-32-32h-96l-8.7-26.1C306.9-7.2 294.7-16 280.9-16H167.1c-13.8 0-26 8.8-30.4 21.9M416 144H32l21.1 323.1C54.7 492.4 75.7 512 101 512h246c25.3 0 46.3-19.6 47.9-44.9z",upload:"448|M256 109.3V320c0 17.7-14.3 32-32 32s-32-14.3-32-32V109.3l-41.4 41.4c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l96-96c12.5-12.5 32.8-12.5 45.3 0l96 96c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0zM224 400c44.2 0 80-35.8 80-80h80c35.3 0 64 28.7 64 64v32c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64v-32c0-35.3 28.7-64 64-64h80c0 44.2 35.8 80 80 80m144 24a24 24 0 1 0 0-48 24 24 0 1 0 0 48",wifi:"576|M288 96c-90.9 0-173.2 36-233.7 94.6-12.7 12.3-33 12-45.2-.7s-12-33 .7-45.2C81.7 74.9 179.9 32 288 32s206.3 42.9 278.3 112.7c12.7 12.3 13 32.6.7 45.2s-32.6 13-45.2.7C461.2 132 378.9 96 288 96m-48 336a48 48 0 1 1 96 0 48 48 0 1 1-96 0m-72-105.8c-11.7 13.3-31.9 14.5-45.2 2.8s-14.5-31.9-2.8-45.2c41-46.4 101.1-75.8 168-75.8s127 29.4 168 75.8c11.7 13.3 10.4 33.5-2.8 45.2s-33.5 10.4-45.2-2.8c-29.4-33.3-72.2-54.2-120-54.2s-90.6 20.9-120 54.2","window-restore":"576|M512 96H160c0-35.3 28.7-64 64-64h288c35.3 0 64 28.7 64 64v192c0 35.3-28.7 64-64 64h-48v-64h48zM0 224c0-35.3 28.7-64 64-64h288c35.3 0 64 28.7 64 64v192c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64zm64 40c0 13.3 10.7 24 24 24h240c13.3 0 24-10.7 24-24s-10.7-24-24-24H88c-13.3 0-24 10.7-24 24","cookie-bite":"512|M257.5 27.6c-.8-5.4-4.9-9.8-10.3-10.6-22.1-3.1-44.6.9-64.4 11.4l-74 39.5c-19.7 10.5-35.6 27-45.4 47.1l-36.7 75.6c-9.8 20.1-13 42.9-9.1 64.9l14.5 82.8c3.9 22.1 14.6 42.3 30.7 57.9l60.3 58.4c16.1 15.6 36.6 25.6 58.7 28.7l83 11.7c22.1 3.1 44.6-.9 64.4-11.4l74-39.5c19.7-10.5 35.6-27 45.4-47.2l36.7-75.5c9.8-20.1 13-42.9 9.1-64.9-.9-5.3-5.3-9.3-10.6-10.1-51.5-8.2-92.8-47.1-104.5-97.4-1.8-7.6-8-13.4-15.7-14.6-54.6-8.7-97.7-52-106.2-106.8zM208 144a32 32 0 1 1 0 64 32 32 0 1 1 0-64m-64 192a32 32 0 1 1 64 0 32 32 0 1 1-64 0m224-64a32 32 0 1 1 0 64 32 32 0 1 1 0-64"};class t{constructor(e={}){if(t.tC)return console.warn("[thinConsole] thinConsole实例已存在"),t.tC;switch(t.tC=this,this.version="1.4.4",this.options=this.sanitizeOptions(e),this.options.theme){case"light":this.currentTheme="light";break;case"dark":this.currentTheme="dark";break;default:if(t.themes[this.options.theme])this.currentTheme=this.options.theme;else{let e=()=>window.matchMedia("(prefers-color-scheme:dark)").matches?"dark":"light";this.currentTheme=e(),this.mediaQuery=window.matchMedia("(prefers-color-scheme:dark)"),this.themeChangeHandler=e=>{this.currentTheme=e.matches?"dark":"light",this.overlay&&this.overlay.classList.contains("active")&&(this.overlay.className="overlay active theme-"+this.currentTheme)},this.mediaQuery.addEventListener("change",this.themeChangeHandler)}}this.currentTab="console",this.searchExpanded=!1,this.activeLSFilter="local",this.selectedElement=null,this.selectedShadowHostId=null,this.expandedElements=new WeakSet,this.mutedLogs=!1,this.mutedFilters={},this.netSending=!1,this.netNewVisible=!1,this.editorState={visible:!1,mode:"ls",key:"",oldKey:"",value:""},void 0===e.pos?.x&&void 0===e.pos?.y&&(this.options.pos=this.getSavedBtnPos()||{x:30,y:30}),this.pluginEnabled=this.options.plugins,this.disabledPlugins=this.options.disabledPlugins,this.plugins={},this.pluginTabs={},this.pluginViewContainers={},this.logs=[],this.lastLog=null,this.maxLog=this.options.maxLog,this.maxNetwork=this.options.maxNetwork,this.selectedLogId=null,this.customTabCount=0,this.treeNodeRegistry=new Map,this.treeNodeRegId=0,this.expandedTreePaths=new Set,this.timerMap=new Map,this.countMap=new Map,this.networkRequests=[],this._netReqId=0,this.activeNetFilter="all",this.netDisabled=!1,this.netDisabledTypes=new Set,this.netDetailId=null,this._id=null,this.ldIdx=0,this.originalXHR=null,this.originalFetch=null,this.closedShadowRoots=new Map,this.interceptShadowRoot(),this.initShadow(),this.createStyles(),this.createButton(),this.captureConsoleLogs(),this.createNotificationElement(),this.createOverlayElement(),this._applyCustomThemeCSS(),this._injectHeaderButtons(),t.themes[this.currentTheme]&&this.applyIcon(t.themes[this.currentTheme].icons),this.setupGlobalEventHandlers(),this.setupSelfProtection(),this.renderContent()}interceptShadowRoot(){if(window.__tcShadowIntercepted)return;window.__tcShadowIntercepted=!0;let e=this,t=Element.prototype.attachShadow;Element.prototype.attachShadow=function(s){let i=t.call(this,s);return e.closedShadowRoots.set(this,{root:i,mode:s.mode||"open"}),i}}initShadow(){this.host&&this.host.remove(),this.host=document.createElement("div"),this.host.id="_thinConsole",this.host.setAttribute("tc-lock",""),this.host.style.cssText="position:absolute;top:0;left:0;width:0;height:0;z-index:2147483647",this.shadowRoot=this.host.attachShadow({mode:"open"}),document.documentElement.appendChild(this.host)}getShadowRoot(e){return e.shadowRoot?{root:e.shadowRoot,mode:"open"}:this.closedShadowRoots.get(e)||null}getSavedBtnPos(){let e=localStorage.getItem("tC-Button-pos");if(!e)return this.saveBtnPos({x:30,y:30}),null;let t=e.match(/^x:(.+?)\,y:(.+)$/);if(!t)return this.saveBtnPos({x:30,y:30}),null;let s=Number(t[1]),i=Number(t[2]);return isNaN(s)||isNaN(i)?(this.saveBtnPos({x:30,y:30}),null):{x:s,y:i}}saveBtnPos({x:e,y:t}){e=isNaN(Number(e))?30:Number(e),t=isNaN(Number(t))?30:Number(t),localStorage.setItem("tC-Button-pos",`x:${e},y:${t}`)}sanitizeOptions(e){let t={text:"thinConsole",color:"#007aff",width:"auto",height:"auto",theme:"auto",plugins:!0,disabledPlugins:[],jsExecute:!0,pos:null,maxLog:1e5,maxNetwork:1e3,pluginOption:{},filters:null,showComments:!0};if(!e||"object"!=typeof e)return{...t};let s={...t},i=(e,t=200)=>"string"==typeof e&&e.length<=t&&!/[<>"&]/.test(e)?e:void 0;for(let n of Object.keys(e)){if(!(n in t))continue;let o=e[n];switch(n){case"text":case"color":case"width":case"height":case"theme":{let e=i(o);void 0!==e&&(s[n]=e);break}case"plugins":case"jsExecute":case"showComments":"boolean"==typeof o&&(s[n]=o);break;case"disabledPlugins":Array.isArray(o)&&o.every(e=>"string"==typeof e)&&(s[n]=o.slice(0,100));break;case"pos":o&&"object"==typeof o&&"number"==typeof o.x&&"number"==typeof o.y&&(s.pos={x:o.x,y:o.y});break;case"maxLog":{let t=Number(e[n]);!isNaN(t)&&t>0&&(s[n]=Math.floor(t));break}case"maxNetwork":{let t=Number(e[n]);!isNaN(t)&&t>0&&(s[n]=Math.floor(t));break}case"pluginOption":o&&"object"==typeof o&&(s[n]=o);break;case"filters":Array.isArray(o)&&o.every(e=>e&&"string"==typeof e.id&&"string"==typeof e.name)&&(s[n]=o)}}return s}createButton(){this.btn=document.createElement("button"),this.btn.id="thinConsole-btn",this.btn.className="floating-console-btn",this.btn.textContent=this.options.text.slice(0,11),this.btn.style.background=this.options.color,this.btn.style.width=this.options.width,this.btn.style.height=this.options.height,this.btn.style.bottom=(Number(this.options.pos.y)||30)+"px",this.btn.style.right=(Number(this.options.pos.x)||30)+"px",this.btn.title=this.options.text.slice(0,11),this.shadowRoot.append(this.btn),this.btn.style.transition="none",requestAnimationFrame(()=>requestAnimationFrame(()=>{this.btn.style.transition=""}));let e=!1,t=0,s=0,i=0,n=0,o=0,l=0,r=null,a=null,c=0,d=0,h=()=>{r&&(clearTimeout(r),r=null)},p=()=>{if(!e)return;let t=c-i,s=d-n;this.btn.style.transition="none",this.btn.style.transform=`translate3d(${t}px,${s}px,0)`,a=requestAnimationFrame(p)},u=r=>{if(!e)return;let a=r.touches?r.touches[0]:r,h=a.clientX-t,p=a.clientY-s;c=Math.max(o/2,Math.min(innerWidth-o/2,i+h)),d=Math.max(l/2,Math.min(innerHeight-l/2,n+p)),r.preventDefault()},f=()=>{if(h(),!e)return;e=!1,cancelAnimationFrame(a);let t=this.btn.getBoundingClientRect(),s=Math.round(innerWidth-t.right),i=Math.round(innerHeight-t.bottom);this.btn.style.right=Math.max(0,s)+"px",this.btn.style.bottom=Math.max(0,i)+"px",this.saveBtnPos({x:Math.max(0,s),y:Math.max(0,i)}),this.btn.style.transition="all 0.3s ease",this.btn.style.transform="",this.btn.dataset.right=Math.max(0,s),this.btn.dataset.bottom=Math.max(0,i),this.btn.removeEventListener("touchmove",u,{passive:!1}),this.btn.removeEventListener("touchend",f),this.btn.removeEventListener("mousemove",u),this.btn.removeEventListener("mouseup",f)},g=a=>{let h=a.touches?a.touches[0]:a;t=h.clientX,s=h.clientY;let g=this.btn.getBoundingClientRect();o=g.width,l=g.height,i=g.left+o/2,n=g.top+l/2,r=setTimeout(()=>{e=!0,c=i,d=n,p(),this.btn.addEventListener("touchmove",u,{passive:!1}),this.btn.addEventListener("touchend",f),this.btn.addEventListener("mousemove",u),this.btn.addEventListener("mouseup",f)},500)};this.btn.addEventListener("touchstart",g,{passive:!1}),this.btn.addEventListener("mousedown",g),this.btn.addEventListener("touchend",h),this.btn.addEventListener("mouseup",h),this.btn.addEventListener("mouseleave",h),this.btn.addEventListener("click",()=>{this.triggerGlobalHook("beforeOpen"),this.overlay.className="overlay active theme-"+this.currentTheme,this.renderContent(),this.triggerGlobalHook("afterOpen")})}createOverlayElement(){this.overlay=document.createElement("div"),this.overlay.id="consoleOverlay",this.overlay.className="overlay no-anim";let e=`<div class="splitter" id="splitter"></div><div class="console-container"><div class="console-header" id="consoleHeader"><div class="console-title" id="consoleTitle">${this.icon("terminal")}${this.options.text.slice(0,11)}</div><div class="header-actions"><button class="header-icon-btn el-header-btn" id="elementPickBtn" title="选择元素" style="display:none">${this.icon("mouse-pointer")}</button><button class="header-icon-btn el-header-btn" id="elCopyBtn" title="复制元素" style="display:none">${this.icon("copy")}</button><button class="header-icon-btn el-header-btn el-delete-btn" id="elDeleteBtn" title="删除元素" style="display:none">${this.icon("trash")}</button><button class="header-icon-btn ls-add-btn" id="lsAddBtn" title="新建" style="display:none">${this.icon("plus")}</button><button class="header-icon-btn" id="netNewBtn" title="新建请求" style="display:none">${this.icon("plus")}</button><button class="header-icon-btn" id="searchToggleBtn" title="搜索">${this.icon("search")}</button><button class="clear-all-btn" title="清除" id="clearLogsBtn">${this.icon("trash")}</button><button class="close-btn" title="关闭" id="closeConsoleBtn">${this.icon("times")}</button></div></div><div class="search-bar" id="searchBar" style="display:none"><div class="search-input-wrap">${this.icon("search","search-bar-icon")}<input type="text" id="searchInput" placeholder="搜索..."></div></div><div class="tabs" id="tabsContainer"></div><div class="console-content" id="contentArea"><div class="controls" id="consoleControls"><div class="filters" id="filtersContainer"></div><div class="filters ls-filters" id="lsFiltersContainer" style="display:none"><button class="filter-btn active" title="本地存储" data-ls-type="local" data-orig="本地存储" data-icon="database">${this.icon("database")}本地存储</button><button class="filter-btn" title="会话存储" data-ls-type="session" data-orig="会话存储" data-icon="window-restore">${this.icon("window-restore")}会话存储</button><button class="filter-btn" title="Cookies" data-ls-type="cookie" data-orig="Cookies" data-icon="cookie-bite">${this.icon("cookie-bite")}Cookies</button></div></div><div class="console-output" id="consoleOutput"></div><div class="localstorage-view" id="localstorageView" style="display:none"><div class="ls-items" id="lsItems"></div></div><div class="elements-view" id="elementsView" style="display:none"><div class="elements-tree" id="elementsTree"></div></div><div class="network-view" id="networkView" style="display:none"><div class="network-controls"><div class="network-filters" id="netFilters"></div><button class="net-disable-btn" id="netDisableBtn" title="禁用">${this.icon("ban")}</button></div><div class="network-items" id="networkItems"></div><div class="net-detail-overlay" id="netDetailOverlay"><div class="net-detail-header"><button class="net-back-btn" id="netBackBtn" title="返回">${this.icon("arrow-left")}</button><div class="net-detail-header-actions"><button class="net-copy-icon-btn" id="netCopyIconBtn" title="复制">${this.icon("copy")}</button><button class="net-resend-icon-btn" id="netResendIconBtn" title="重发">${this.icon("redo")}</button><button class="net-copy-icon-btn" id="netDetailSearchToggleBtn" title="搜索">${this.icon("search")}</button></div></div><div class="net-detail-header log-detail-search" id="netDetailSearchBar" style="display:none"><input id="netDetailSearchInput" placeholder="搜索请求/响应..."><span class="log-detail-count" id="netDetailSearchCount"></span><button class="net-back-btn log-detail-nav" id="netDetailSearchPrev">${this.icon("chevron-up")}</button><button class="net-back-btn log-detail-nav" id="netDetailSearchNext">${this.icon("chevron-down")}</button></div><div class="net-detail-body" id="netDetailBody"></div></div><div class="net-new-overlay" id="netNewOverlay"><div class="net-new-header"><button class="net-back-btn" id="netNewBackBtn">${this.icon("arrow-left")}</button><div class="net-new-title">新建请求</div></div><div class="net-new-body"><div class="net-form-group"><label class="net-form-label">网址</label><input type="text" class="net-form-input" id="netNewUrl" placeholder="https://..." spellcheck="false"></div><div class="net-form-group"><label class="net-form-label">类型</label><select class="net-form-select" id="netNewMethod"><option value="GET">GET</option><option value="POST">POST</option><option value="PUT">PUT</option><option value="PATCH">PATCH</option><option value="DELETE">DELETE</option><option value="HEAD">HEAD</option><option value="OPTIONS">OPTIONS</option></select></div><div class="net-form-group"><label class="net-form-label">请求内容 (可选)</label><textarea class="net-form-textarea" id="netNewBody" placeholder='{"key":"value"}' spellcheck="false"></textarea></div><div class="net-form-group"><label class="net-form-label">请求头 (可选, 每行一个)</label><textarea class="net-form-textarea" id="netNewHeaders" placeholder="Content-Type: application/json" spellcheck="false"></textarea></div><button class="net-send-btn" id="netSendBtn">${this.icon("paper-plane")} 发送请求</button></div></div></div><div class="net-detail-overlay log-detail-overlay" id="logDetailOverlay"><div class="net-detail-header"><button class="net-back-btn" id="logDetailBackBtn" title="返回">${this.icon("arrow-left")}</button><div class="net-detail-header-actions"><button class="net-copy-icon-btn" id="logDetailSearchToggleBtn" title="搜索">${this.icon("search")}</button><button class="net-copy-icon-btn" id="logDetailCopyBtn" title="复制">${this.icon("copy")}</button></div></div><div class="net-detail-header log-detail-search" id="logDetailSearchBar" style="display:none"><input id="logDetailSearchInput" placeholder="搜索单条日志..."><span class="log-detail-count" id="logDetailSearchCount"></span><button class="net-back-btn log-detail-nav" id="logDetailSearchPrev">${this.icon("chevron-up")}</button><button class="net-back-btn log-detail-nav" id="logDetailSearchNext">${this.icon("chevron-down")}</button></div><div class="net-detail-body log-detail-body" id="logDetailBody"></div></div><div class="ls-editor-overlay" id="lsEditorOverlay" style="display:none"><div class="ls-editor-header"><div class="ls-editor-header-row"><input type="text" class="ls-editor-key-input" id="lsEditorKeyInput" placeholder="键名..." spellcheck="false"><span class="ls-editor-title" id="lsEditorTitle"></span></div></div><div class="ls-editor-body"><textarea id="lsEditorInput" placeholder="输入值..." spellcheck="false"></textarea></div><div class="ls-editor-footer"><button class="ls-editor-btn cancel" id="lsEditorCancel">取消</button><button class="ls-editor-btn save" id="lsEditorSave">保存</button></div></div></div></div>`;this.overlay.innerHTML=e,this.shadowRoot.appendChild(this.overlay),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.overlay.classList.remove("no-anim")})});let t=this.overlay.querySelector.bind(this.overlay);this.tabButtonsContainer=t("#tabsContainer"),this.createBuiltinTabs(),this.closeConsoleBtn=t("#closeConsoleBtn"),this.consoleOutput=t("#consoleOutput"),this.title=t("#consoleTitle"),this.localstorageView=t("#localstorageView"),this.lsItems=t("#lsItems"),this.contentArea=t("#contentArea"),this.consoleContainer=t(".console-container"),this.renderFilters(),this.filterButtons=this.overlay.querySelectorAll("#filtersContainer .filter-btn"),this.searchInput=t("#searchInput"),this.clearLogsBtn=t("#clearLogsBtn"),this.tabButtons=this.overlay.querySelectorAll(".tab-btn"),this.consoleControls=t("#consoleControls"),this.searchToggleBtn=t("#searchToggleBtn"),this.searchBar=t("#searchBar"),this.consoleHeader=t("#consoleHeader"),this.lsEditorOverlay=t("#lsEditorOverlay"),this.lsEditorTitle=t("#lsEditorTitle"),this.lsEditorKeyInput=t("#lsEditorKeyInput"),this.lsEditorInput=t("#lsEditorInput"),this.lsEditorCancel=t("#lsEditorCancel"),this.lsEditorSave=t("#lsEditorSave"),this.lsFiltersContainer=t("#lsFiltersContainer"),this.lsAddBtn=t("#lsAddBtn"),this.elementsView=t("#elementsView"),this.elementsTree=t("#elementsTree"),this.networkView=t("#networkView"),this.networkItems=t("#networkItems"),this.netFiltersEl=t("#netFilters"),this.netDisableBtn=t("#netDisableBtn"),this.netDetailOverlay=t("#netDetailOverlay"),this.netDetailBody=t("#netDetailBody"),this.netNewOverlay=t("#netNewOverlay"),this.netNewUrl=t("#netNewUrl"),this.netNewMethod=t("#netNewMethod"),this.netNewBody=t("#netNewBody"),this.netNewHeaders=t("#netNewHeaders"),this.netSendBtn=t("#netSendBtn"),this.netBackBtn=t("#netBackBtn"),this.netNewBackBtn=t("#netNewBackBtn"),this._ov=t("#logDetailOverlay"),this._bk=t("#logDetailBackBtn"),this._bd=t("#logDetailBody"),this._st=t("#logDetailSearchToggleBtn"),this._lc=t("#logDetailCopyBtn"),this._sb=t("#logDetailSearchBar"),this._si=t("#logDetailSearchInput"),this._sc=t("#logDetailSearchCount"),this._sp=t("#logDetailSearchPrev"),this._sn=t("#logDetailSearchNext"),this._nst=t("#netDetailSearchToggleBtn"),this._nsb=t("#netDetailSearchBar"),this._nsi=t("#netDetailSearchInput"),this._nsc=t("#netDetailSearchCount"),this._nsp=t("#netDetailSearchPrev"),this._nsn=t("#netDetailSearchNext"),this.netNewBtn=t("#netNewBtn"),this.elementPickBtn=t("#elementPickBtn"),this.splitter=t("#splitter"),this.splitter&&this.setupSplitter(),this.elementPickBtn.addEventListener("click",()=>this.startElementPicker()),this.elCopyBtn=t("#elCopyBtn"),this.elCopyBtn.addEventListener("click",()=>{this.selectedElement?this.copyElementHTML(this.selectedElement):this.showNotification("请先选择一个元素","warning")}),this.elDeleteBtn=t("#elDeleteBtn"),this.elDeleteBtn.addEventListener("click",()=>{this.selectedElement?this.deleteElement(this.selectedElement):this.showNotification("请先选择一个元素","warning")}),this.netDisableBtn&&this.netDisableBtn.addEventListener("click",()=>this.toggleNetDisable()),this.netBackBtn&&this.netBackBtn.addEventListener("click",()=>{this.netDetailOverlay.style.display="none",this.netDetailId=null,this._ssv()}),this.netNewBackBtn&&this.netNewBackBtn.addEventListener("click",()=>{this.netNewVisible=!1,this.netNewOverlay.style.display="none",this._ssv()}),this.netNewBtn&&this.netNewBtn.addEventListener("click",()=>{if(this.editorState.visible){let e=this.editorState.mode;if("code"===e)return void this.showNotification("正在运行代码,无法发送请求","warning");if("ls"===e)return void this.showNotification("正在保存键值,无法发送请求","warning")}this.netNewVisible=!0,this.netNewOverlay.style.display="flex",this._ssv()}),this.netSendBtn&&this.netSendBtn.addEventListener("click",()=>this.sendNewRequest()),this.networkItems&&this.networkItems.addEventListener("click",e=>{let t=e.target.closest(".net-item");if(!t)return;let s=parseInt(t.dataset.reqId);if(e.target.closest("[data-action=copy]")){e.stopPropagation(),e.preventDefault();let t=this.networkRequests.find(e=>e.id===s);if(t){let e=this._fmtNetReq(t);navigator.clipboard.writeText(e.ct).then(()=>this.showNotification("已复制完整请求信息")).catch(()=>{})}return}return e.target.closest("[data-action=detail]")?(e.stopPropagation(),e.preventDefault(),void this.showNetDetail(s)):void 0}),this.captureNetworkRequests(),this.closeConsoleBtn.addEventListener("click",()=>{this.triggerGlobalHook("beforeClose"),this._ov.style.display="none",this.overlay.classList.remove("active"),this.triggerGlobalHook("afterClose")}),[this.consoleOutput,this.lsItems,this.networkItems].forEach(e=>this.vsInit(e)),[this.consoleOutput,this.networkItems].forEach(e=>this.injectScrollBtn(e)),this.lsItems.addEventListener("click",e=>{let t=e.target.closest(".ls-action-btn");if(!t)return;let s=t.dataset.action,i=t.dataset.key;switch(s){case"edit":this.openLSEditor(i);break;case"copy":this.copyLog(i,"",!0);break;case"remove":this.removeLSItem(i)}}),this.title.title="运行代码功能已被禁用",this.title.style.cursor="not-allowed",this.options.jsExecute&&(this.title.title="点击标题以输入代码执行",this.title.style.cursor="pointer",this.title.addEventListener("click",()=>this.onTitleClick())),this.overlay.addEventListener("click",e=>{let t=e.target.closest(".tree-load-more");t&&this.loadMoreTreeChildren(t);let s=e.target.closest(".elements-tree .tree-label");if(s){let e=s.closest(".tree-node[data-el-id]"),t=e?parseInt(e.dataset.elId):null,i=null!==t&&this.elRefMap?this.elRefMap.get(t):null;i&&(this.selectedElement=i,this.selectedShadowHostId=e.dataset.shadowHost?parseInt(e.dataset.shadowHost):null,this.elementsTree.querySelectorAll(".el-selected").forEach(e=>e.classList.remove("el-selected")),this.elementsTree.querySelectorAll(".el-highlight").forEach(e=>e.classList.remove("el-highlight")),e.classList.add("el-selected"),e.classList.add("el-highlight"),setTimeout(()=>e.classList.remove("el-highlight"),3e3),this.updateControlsVisibility())}else"elements"!==this.currentTab||e.target.closest(".tree-label")||e.target.closest(".tree-toggle")||e.target.closest(".el-header-btn")||e.target.closest(".close-btn")||e.target.closest(".header-icon-btn")||e.target.closest(".console-header")||e.target.closest(".tabs")||e.target.closest(".controls")||e.target.closest(".search-bar")||(this.selectedElement=null,this.selectedShadowHostId=null,this.elementsTree&&(this.elementsTree.querySelectorAll(".el-selected").forEach(e=>e.classList.remove("el-selected")),this.elementsTree.querySelectorAll(".el-highlight").forEach(e=>e.classList.remove("el-highlight"))),this.updateControlsVisibility());let i=e.target.closest(".tree-toggle")||("elements"===this.currentTab||e.target.closest(".tree-close")?null:e.target.closest(".tree-label")||e.target.closest(".json-key")||e.target.closest(".tree-node")&&!e.target.closest(".tree-node").classList.contains("expanded")?e.target.closest(".tree-node"):null);if(i){let e=i.closest(".tree-node");if(e){let t=e.dataset.elId,s=t&&this.elRefMap?this.elRefMap.get(parseInt(t)):null;if(e.classList.contains("collapsed")){e.classList.remove("collapsed"),e.classList.add("expanded");let t=e.dataset.treePath;t&&this.expandedTreePaths.add(t),s&&this.expandedElements.add(s);let i=e.querySelector(":scope > .tree-children");if(i&&i.dataset.lazyId){let e=parseInt(i.dataset.lazyId),t=this.treeNodeRegistry.get(e);if(t){let s="";if("html"===t.type)s=this.renderDomChildrenLazy(t.children,(e,s,i)=>this.renderHTMLTree(e,"",t.path+"."+s,i),t.depth||0,"html",{path:t.path}),t.shadow&&(s+=this.buildShadowLazy(t.shadow,"html",t.path,t.depth||0));else if("html-shadow"===t.type)s=this.renderDomChildrenLazy(t.children,(e,s,i)=>this.renderHTMLTree(e,"",t.path+".shadow."+s,i),t.depth||0,"html-shadow",{});else if("element"===t.type)s=this.renderDomChildrenLazy(t.children,(e,t,s)=>this.renderElementTree(e,s),t.depth||0,"element",{}),t.shadow&&(s+=this.buildShadowLazy(t.shadow,"element",null,t.depth||0,t.elId));else if("element-shadow"===t.type)s=this.renderDomChildrenLazy(t.children,(e,t,s)=>this.renderElementTree(e,s),t.depth||0,"element-shadow",{});else if(t.isJsonValue)s=this.renderJSONValueChildren(t.children);else{let e=new WeakSet;t.chain.forEach(t=>e.add(t)),e.add(t.obj);let i=t.children;if(i.length>200){let n=this.treeNodeRegId++;this.treeNodeRegistry.set(n,{children:i,chain:t.chain.concat([t.obj]),noProto:t.noProto}),s=this.renderTreeChildrenBatch(i,e,0,200,t.chain.concat([t.obj]),t.path||"",1,t.noProto)+'<div class="tree-load-more" data-reg-id="'+n+'" data-offset="200">'+this.icon("angle-down")+" 展开更多 (剩余 "+(i.length-200)+" 项)</div>"}else s=this.renderTreeChildrenBatch(i,e,0,i.length,t.chain.concat([t.obj]),t.path||"",1,t.noProto)}i.innerHTML=s,delete i.dataset.lazyId,this.treeNodeRegistry.delete(e)}}}else{e.classList.remove("expanded"),e.classList.add("collapsed");let t=e.dataset.treePath;t&&this.expandedTreePaths.delete(t),s&&this.expandedElements.delete(s)}let n=i.closest(".console-output, .ls-items");n&&this.vsRender(n)}}e.target===this.overlay&&window.innerWidth<=768&&(this.triggerGlobalHook("beforeClose"),this.overlay.classList.remove("active"),this.triggerGlobalHook("afterClose"))}),this.filterButtons.forEach(e=>{e.addEventListener("click",()=>{this.filterButtons.forEach(e=>e.classList.remove("active")),e.classList.add("active"),this.activeFilter=e.dataset.type,this.updateFilterCounts(),this.renderContent(),this.scrollFilterIntoView(this.filtersContainerEl,e)})}),this.lsFiltersContainer&&this.lsFiltersContainer.querySelectorAll(".filter-btn").forEach(e=>{e.addEventListener("click",()=>{this.lsFiltersContainer.querySelectorAll(".filter-btn").forEach(e=>e.classList.remove("active")),e.classList.add("active"),this.activeLSFilter=e.dataset.lsType,this.renderContent(),this.scrollFilterIntoView(this.lsFiltersContainer,e)})}),this.lsAddBtn&&this.lsAddBtn.addEventListener("click",()=>this.onAddLSClick()),this.o(this._bk,"click",()=>this.hideLogDetail()),this.o(this._st,"click",()=>this.toggleLDS()),this.o(this._lc,"click",()=>{this._id&&this.copyLog(this._id,!1)}),this.o(this._sp,"click",()=>this.stepLDS(-1)),this.o(this._sn,"click",()=>this.stepLDS(1)),this.o(this._si,"input",()=>{clearTimeout(this._ldT),this._ldT=setTimeout(()=>this.runLDS(this._si.value),250)}),this.o(this._si,"keydown",e=>{"Enter"===e.key?(e.preventDefault(),this.stepLDS(e.shiftKey?-1:1)):"Escape"===e.key&&(e.target.value="",this.runLDS(""))}),this.o(this._nst,"click",()=>this.toggleNDS()),this.o(this._nsp,"click",()=>this.stepLDS(-1,this.netDetailBody.querySelectorAll("mark"),this._nsc)),this.o(this._nsn,"click",()=>this.stepLDS(1,this.netDetailBody.querySelectorAll("mark"),this._nsc)),this.o(this._nsi,"input",()=>{clearTimeout(this._ndT),this._ndT=setTimeout(()=>{this._nsi.value.trim()&&this.expdAllNDS(),this.runLDS(this._nsi.value,this.netDetailBody,this._nsc)},250)}),this.o(this._nsi,"keydown",e=>{"Enter"===e.key?(e.preventDefault(),this.stepLDS(e.shiftKey?-1:1,this.netDetailBody.querySelectorAll("mark"),this._nsc)):"Escape"===e.key&&(e.target.value="",this.runLDS("",this.netDetailBody,this._nsc))}),this.o(this._bd,"click",e=>{let t=e.target.closest(".ld-copy,.ld-copy-fn");if(t){let e=this.logs.find(e=>e.id===this._id)?.args[+t.dataset.i],s="function"==typeof e?e+"":e instanceof HTMLElement?this.clr(e.outerHTML).replace(/(\s[\w:-]+)=""/g,"$1").replace(/>/g,">\n"):this.clr(this.safeStringify(e,2));return void(navigator.clipboard&&navigator.clipboard.writeText(s).then(()=>this.showNotification("已复制"),()=>{}))}let s=e.target.closest(".ld-fn-toggle");if(!s)return;let i=s.parentNode.querySelector(".ld-fn-body");if(!i)return;let n="none"===i.style.display;i.style.display=n?"block":"none",s.innerHTML=this.icon(n?"chevron-up":"chevron-down")+(n?"收起":"展开");let o=s.parentNode.querySelector("span.json-boolean");o&&(o.style.display=n?"none":"");let l=s.parentNode.querySelector(".ld-copy-fn");l&&(l.style.display=n?"flex":"none")}),this.o(this._ov,"touchstart",e=>e.stopPropagation()),this.consoleOutput&&this.consoleOutput.addEventListener("click",e=>{let t=e.target.closest(".log-item-eye");if(t){let e=t.closest(".log-item");return void(e&&this.showLogDetail(+e.getAttribute("tc-idx")))}let s=e.target.closest(".log-item-copy");if(s){let e=s.closest(".log-item");return void(e&&this.copyLog(+e.getAttribute("tc-idx"),!1))}if(e.target.closest(".expand-btn"))return;let i=e.target.closest(".log-item");if(!i)return this.selectedLogId=null,this.consoleOutput.querySelectorAll(".log-item.selected").forEach(e=>e.classList.remove("selected"));let n=+i.getAttribute("tc-idx");this.selectedLogId=n,this.consoleOutput.querySelectorAll(".log-item.selected").forEach(e=>e.classList.remove("selected")),i.classList.add("selected")}),this.searchInput.addEventListener("input",(e=>t=>{clearTimeout(e),e=setTimeout(()=>{this.searchQuery=this.searchInput.value,this.renderContent()},300)})(0)),this.clearLogsBtn.addEventListener("click",()=>this.clearAllLogs()),this.searchToggleBtn.addEventListener("click",()=>this.toggleSearch()),this.lsEditorCancel.addEventListener("click",()=>this.closeLSEditor()),this.lsEditorSave.addEventListener("click",()=>this.onEditorSave()),this.lsEditorInput.addEventListener("input",()=>{this.editorState.value=this.lsEditorInput.value}),this.lsEditorKeyInput&&this.lsEditorKeyInput.addEventListener("input",()=>{this.editorState.key=this.lsEditorKeyInput.value.trim()}),this.setupFilterShadow(this.filtersContainerEl),this.setupFilterShadow(this.lsFiltersContainer),this.setupFilterShadow(this.netFiltersEl),this.setupGestures(),this.tabButtons.forEach(e=>{e.addEventListener("click",()=>{this.tabButtons.forEach(e=>e.classList.remove("active")),e.classList.add("active"),this.currentTab=e.dataset.tab,this.renderContent()})})}renderFilters(){let e=this.overlay.querySelector("#filtersContainer");if(!e)return;this.filtersContainerEl=e;let t=this.options.filters;t&&t.length||(t=[{id:"all",name:"全部",icon:"list"},{id:"log",name:"日志",icon:"info"},{id:"info",name:"信息",icon:"info-circle"},{id:"warn",name:"警告",icon:"exclamation-triangle"},{id:"error",name:"错误",icon:"times-circle"}]),e.innerHTML=t.map((e,t)=>`<button class="filter-btn${0===t?" active":""}" title="${this.escapeHtml(e.name)}" data-type="${this.escapeHtml(e.id)}" data-icon="${this.escapeHtml(e.icon||"")}">${e.icon?this.icon(e.icon):""}${this.escapeHtml(e.name)}</button>`).join(""),e.querySelectorAll(".filter-btn").forEach(t=>{t.addEventListener("click",()=>{e.querySelectorAll(".filter-btn").forEach(e=>e.classList.remove("active")),t.classList.add("active"),this.activeFilter=t.dataset.type,this.updateFilterCounts(),this.renderContent()})})}createBuiltinTabs(){[{id:"console",name:"控制台",icon:"terminal"},{id:"network",name:"网络",icon:"wifi"},{id:"localstorage",name:"存储",icon:"database"},{id:"elements",name:"元素",icon:"code"}].forEach(e=>{let t=document.createElement("button");t.className="tab-btn",t.dataset.tab=e.id,t.title=e.name,t.innerHTML=this.icon(e.icon)+e.name,e.id===this.currentTab&&t.classList.add("active"),t.addEventListener("click",()=>{this.tabButtons=this.overlay.querySelectorAll(".tab-btn"),this.tabButtons.forEach(e=>e.classList.remove("active")),t.classList.add("active"),this.currentTab=e.id,this.renderContent()}),this.tabButtonsContainer.appendChild(t)})}createPluginTab(e){let t=document.createElement("button");t.className="tab-btn",t.dataset.tab=e.id?e.id:"newTab",e.title=e.name?e.name:"新的插件",t.innerHTML=this.icon(e.icon||"plug")+(e.name||"新的插件"),this.tabButtonsContainer.appendChild(t),t.addEventListener("click",()=>{this.tabButtons=this.overlay.querySelectorAll(".tab-btn"),this.tabButtons.forEach(e=>e.classList.remove("active")),t.classList.add("active"),this.currentTab=e.id,this.renderContent()});let s=document.createElement("div");s.id=e.id+"View",s.innerHTML="无插件视图",s.className="plug-view",s.style.display="none",this.contentArea.appendChild(s),this.pluginViewContainers[e.id]=s}createNotificationElement(){this.notification=document.createElement("div"),this.notification.id="notification",this.notification.className="notification",this.notification.style.display="none",this.shadowRoot.appendChild(this.notification)}createStyles(){let e=document.createElement("style");e.innerHTML=":host{all:initial}*{margin:0;padding:0;box-sizing:border-box}.floating-console-btn{position:fixed;z-index:99997;touch-action:none;will-change:transform;padding:15px 25px;backdrop-filter:blur(5px);border-radius:5px;border:none;background:#007aff;color:#fff;font-size:1rem;cursor:move;display:flex;align-items:center;gap:10px;font-weight:500;box-shadow:0 8px 20px rgba(0,0,0,.4);transition:all .3s ease;user-select:none}.floating-console-btn:active{transform:scale(.98)}.floating-console-btn .ico{font-size:1.2rem}.overlay{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.85);display:flex;align-items:center;justify-content:center;z-index:99998;opacity:0;visibility:hidden;transition:all .4s ease;backdrop-filter:blur(5px)}.overlay.active{opacity:1;visibility:visible}.theme-dark{--selected-bg:rgba(74,74,230,.15);--console-bg:#1e1e1e;--header-bg:#252526;--text-color:#d4d4d4;--controls-bg:#2d2d2d;--border-color:rgba(255,255,255,0.05);--log-bg:#191919;--log-border-light:3px solid;--filter-active:#4a4ae6;--search-bg:#3e3e42;--json-bg:rgba(40,40,40,0.7);--json-key:#6aaeff;--json-tag:#5dade2;--json-string:#98c379;--json-number:#d19a66;--json-boolean:#56b6c2;--json-null:#be5046;--json-cmt:#707070;--action-bg:rgba(106,174,255,0.3);--action-hover:rgba(106,174,255,0.5);--log-icon-info:#4a4ae6;--log-bg-warn:rgba(255,193,7,0.1);--log-icon-warn:#d9a40d;--log-icon-error:#ff3b30;--clear-btn-color:#ff6b6b;--clear-btn-hover:#ff5252;--tab-bg:#333;--tab-active:#444;--tab-color:#ddd}.theme-light{--selected-bg:rgba(30,107,184,.08);--console-bg:#ffffff;--header-bg:#f0f0f0;--text-color:#333;--controls-bg:#e0e0e0;--border-color:rgba(0,0,0,0.1);--log-bg:#f3f3f3;--log-border-light:3px solid;--filter-active:#4a4ae6;--search-bg:#f0f0f0;--json-bg:rgba(240,240,240,0.9);--json-key:#1e6bb8;--json-tag:#2980b9;--json-string:#22863a;--json-number:#d73a49;--json-boolean:#005cc5;--json-null:#6f42c1;--json-cmt:#707070;--action-bg:rgba(30,107,184,0.1);--action-hover:rgba(30,107,184,0.2);--log-bg-warn:rgba(255,243,205,0.75);--log-icon-info:#1e6bb8;--log-icon-warn:#e36209;--log-icon-error:#d73a49;--clear-btn-color:#ff5252;--clear-btn-hover:#ff3b30;--tab-bg:#e5e5e5;--tab-active:#ddd;--tab-color:#333}.console-container *{outline:0;-webkit-tap-highlight-color:transparent}.console-container{background:var(--console-bg);display:flex;flex-direction:column;box-shadow:0 15px 35px rgba(0,0,0,.3);position:fixed;z-index:99999;left:0;bottom:0;width:100%;height:90vh;transform:translateY(100%);transition:transform .4s cubic-bezier(.25,.8,.25,1)}.overlay.active .console-container{transform:translateY(0)}.overlay.no-anim .console-container{transition:none!important}.net-disable-btn{display:inline-flex;align-items:center;justify-content:center;border:none;background:0 0;color:var(--text-color);cursor:pointer;font-size:14px;padding:5px 10px;border-radius:5px;white-space:nowrap;transition:all .2s;opacity:.55;flex-shrink:0;margin-left:auto}.net-disable-btn:hover{opacity:1}.net-disable-btn.disabled{opacity:1;color:var(--text-color);filter:none}.network-items{flex:1;overflow-y:auto;padding:8px 12px}.net-item{padding:12px 14px;margin-bottom:8px;background:var(--log-bg);border-left:3px solid var(--json-boolean);border-radius:6px;cursor:default;transition:background .2s}.net-item:hover{background:var(--selected-bg)}.net-item.net-failed{border-left-color:#ff5252}.net-item.net-success{border-left-color:#98c379}.net-row1{display:flex;align-items:center;gap:8px;margin-bottom:4px}.net-row2{display:flex;align-items:center;gap:8px;margin-bottom:6px}.net-row3{display:flex;gap:8px;align-items:center}.net-copy-btn,.net-detail-btn{display:inline-flex;align-items:center;gap:4px;padding:4px 10px;border:none;border-radius:4px;font-size:11px;cursor:pointer;transition:all .2s}.net-copy-btn,.net-detail-btn,.net-detail-copy-section:hover,.net-resend-icon-btn:hover,.net-copy-icon-btn:hover{background:var(--action-bg);color:var(--json-key)}.net-copy-btn:hover,.net-detail-btn:hover,.log-action:hover,.ls-action-btn:hover,.ls-editor-btn.cancel:hover{background:var(--action-hover)}.net-method{font-size:10px;font-weight:700;padding:2px 6px;border-radius:3px;text-transform:uppercase}.net-method-GET,.net-status-3xx{background:rgba(106,174,255,.2);color:var(--json-key)}.net-method-POST{background:rgba(152,195,121,.2);color:var(--json-string)}.net-method-PUT{background:rgba(255,193,7,.2);color:#ffc107}.net-method-DELETE,.net-status-5xx{background:rgba(255,82,82,.2);color:#ff5252}.net-method-PATCH,.net-status-4xx{background:rgba(255,152,0,.2);color:#ff9800}.net-method-HEAD{background:rgba(190,80,70,.2);color:var(--json-null)}.net-method-OPTIONS,.net-status-pending{background:rgba(112,112,112,.2);color:var(--json-cmt)}.net-url{flex:1;font-size:12px;color:var(--text-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:100px}.net-status{font-size:11px;font-weight:700;padding:2px 6px;border-radius:3px}.net-status-2xx{background:rgba(152,195,121,.2);color:#98c379}.net-time{font-size:11px;color:var(--json-cmt);white-space:nowrap}.net-back-btn{background:0 0;border:none;color:var(--text-color);cursor:pointer;font-size:16px;padding:4px 8px;border-radius:4px}.net-back-btn:hover,.console-table tbody tr:hover{background:var(--action-bg)}.net-detail-overlay,.net-new-overlay{position:absolute;top:0;left:0;right:0;bottom:0;background:var(--console-bg);z-index:100;display:none;flex-direction:column}.log-item-copy,.log-item-eye{background:0;border:0;color:var(--json-cmt);cursor:pointer;font-size:13px;padding:0 6px;display:flex;align-items:center;opacity:0;transform:scale(.5);pointer-events:none;transition:.25s}.log-item-copy{margin-left:auto}.log-item.selected .log-item-copy,.log-item.selected .log-item-eye{opacity:1;transform:none;pointer-events:auto}.log-item.selected .log-item-copy:hover,.log-item.selected .log-item-eye:hover{color:var(--json-key)}.net-detail-body.log-detail-body{font-family:monospace;font-size:.85rem;color:var(--text-color);white-space:pre-wrap;word-break:break-word;padding:8px 10px}.log-detail-body .ld-meta{display:flex;align-items:center;gap:8px;padding-bottom:6px;margin-bottom:8px}.log-detail-body .ld-meta .ico,.log-detail-body .ld-time{color:var(--json-cmt)}.log-detail-body .ld-time{font-size:12px}.log-detail-body .json-tree-container,.log-detail-body .log-content,.log-detail-body .console-table-wrap{max-height:none!important;overflow:visible!important}.log-detail-body .ld-fn-body{position:relative;font-family:monospace;padding:30px 10px 10px;margin-top:5px;background:var(--json-bg);color:var(--json-boolean);border-radius:5px;white-space:pre;word-break:break-all;max-height:300px;overflow-y:auto;flex-basis:100%}.log-detail-body .ld-fn{position:relative;display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:4px 0}.log-detail-body .ld-fn-toggle{padding:3px 8px;font-size:11px;gap:3px}.log-detail-body .ld-copy,.log-detail-body .ld-copy-fn{position:absolute;top:2px;right:0;z-index:5;background:var(--header-bg);border:1px solid var(--border-color);color:var(--json-cmt);border-radius:4px;padding:2px 6px;font-size:11px;cursor:pointer;display:flex;align-items:center}.log-detail-body .ld-copy-fn{display:none}.log-detail-body .ld-viewer{position:relative;margin:4px 0;max-height:none;max-width:100%}.log-detail-body .ld-viewer-body{overflow-x:auto;padding-top:26px;min-width:100%;max-width:100%}.tc-scroll-bottom{position:sticky;bottom:6px;float:right;margin-top:-36px;z-index:9;width:30px;height:30px;border-radius:50%;background:var(--header-bg);border:1px solid var(--border-color);color:var(--json-cmt);cursor:pointer;display:flex;align-items:center;justify-content:center;opacity:0;pointer-events:none;transition:.25s;box-shadow:0 2px 6px rgba(0,0,0,.25)}.tc-scroll-bottom.show{opacity:1;pointer-events:auto}.tc-scroll-bottom svg{width:14px;height:14px}.log-detail-search{gap:6px;padding:6px 12px}.log-detail-search input{flex:1;background:var(--input-bg,var(--console-bg));border:1px solid var(--border-color);color:var(--text-color);padding:6px 10px;border-radius:5px;font-size:13px;outline:none}.log-detail-count{font-size:12px;color:var(--json-cmt);white-space:nowrap}.log-detail-nav{font-size:13px;padding:2px 6px}.log-detail-body mark,.net-detail-body mark{background:rgba(255,213,0,.45);color:inherit;padding:0 1px;border-radius:3px}.log-detail-body mark.on,.net-detail-body mark.on{background:rgba(255,140,0,.85);color:#fff;border-radius:3px}.net-detail-header,.net-new-header{display:flex;align-items:center;gap:8px;padding:3px 12px;background:var(--header-bg);border-bottom:1px solid var(--border-color)}.net-detail-body{flex:1;overflow-y:auto;padding:12px}.net-detail-section{margin-bottom:16px}.net-detail-label{font-size:11px;color:var(--json-cmt);text-transform:uppercase;margin-bottom:4px}.net-detail-value{font-size:13px;color:var(--text-color);word-break:break-all;background:var(--log-bg);padding:8px 10px;border-radius:4px;max-height:400px;overflow-y:auto}.net-detail-value textarea{width:100%;min-height:80px;background:var(--log-bg);border:1px solid var(--border-color);color:var(--text-color);border-radius:4px;padding:8px;font-size:12px;font-family:monospace;resize:vertical}.net-new-title{flex:1;font-size:14px;color:var(--text-color)}.net-new-body{flex:1;overflow-y:auto;padding:16px}.net-form-group{margin-bottom:14px}.net-form-label{font-size:12px;color:var(--json-cmt);margin-bottom:4px;display:block}.net-form-input,.net-form-select,.net-form-textarea{width:100%;background:var(--log-bg);border:1px solid var(--border-color);color:var(--text-color);border-radius:4px;padding:8px 10px;font-size:13px;font-family:monospace;outline:0;transition:border-color .2s}.net-form-input:focus,.net-form-select:focus,.net-form-textarea:focus,.ls-editor-key-input:focus,.ls-editor-body textarea:focus{border-color:var(--filter-active)}.net-form-textarea{min-height:100px;resize:none}.net-form-select{cursor:pointer}.net-send-btn{padding:8px 20px;border:none;background:var(--filter-active);color:#fff;cursor:pointer;border-radius:4px;font-size:13px;transition:all .2s;margin-left:auto;display:block}.net-send-btn:hover,.ls-editor-btn.save:hover,.ls-editor-btn.run:hover{opacity:.85}.nolog{text-align:center;font-size:18px;color:var(--json-cmt);padding:40px 0;display:flex;align-items:center;justify-content:center;gap:5px}.nolog>.ico{font-size:1em;flex-shrink:0}.net-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--json-cmt);font-size:18px;gap:5px}.net-detail-section-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:4px}.net-detail-copy-section{background:0 0;border:none;color:var(--json-cmt);cursor:pointer;font-size:13px;padding:2px 6px;border-radius:3px;transition:all .2s}.net-detail-empty{color:var(--json-cmt);opacity:.5;font-style:italic}.net-detail-value.net-detail-code{font-family:monospace;white-space:pre-wrap;word-break:break-all;overflow-x:auto;max-height:400px}.net-detail-header-actions{display:flex;align-items:center;gap:4px;margin-left:auto}.net-resend-icon-btn,.net-copy-icon-btn{background:0 0;border:none;color:var(--text-color);cursor:pointer;font-size:16px;padding:4px 8px;border-radius:4px;transition:all .2s}.filters,.network-filters,.plug-view .filters{display:flex;flex-wrap:nowrap;gap:2px;margin-left:0;overflow-x:auto;overflow-y:hidden;scrollbar-width:thin;position:relative;padding-bottom:2px;min-width:0;flex:0 1 auto;-webkit-overflow-scrolling:touch}.network-filters{flex:1 1 auto}.filter-btn,.net-filter-btn{position:relative;padding:5px 10px;border:none;background:0 0;color:var(--text-color);cursor:pointer;font-size:12px;display:flex;width:auto;white-space:nowrap;border-radius:4px;opacity:.55;transition:opacity .2s,background .2s;flex-shrink:0}.filter-btn>.ico,.net-filter-btn>.ico{margin-right:5px;margin-top:2px}.filter-btn:hover,.net-filter-btn:hover{opacity:1;background:rgba(127,127,127,.14)}.filter-btn.active,.net-filter-btn.active{opacity:1;font-weight:600;background:transparent}.filter-btn.active::after,.net-filter-btn.active::after{content:'';position:absolute;width:80%;left:10%;right:auto;top:auto;height:2px;bottom:0;border-radius:3px;background:var(--filter-active)}@media(min-width:769px){.overlay{flex-direction:row;align-items:stretch;justify-content:flex-end;background:transparent;backdrop-filter:none;opacity:1;pointer-events:none}.console-container{position:relative;left:auto;bottom:auto;width:50%;height:100%;transform:translateX(100%);flex-shrink:0;pointer-events:auto}.overlay.active .console-container,.overlay.active .splitter{transform:translateX(0)}.overlay::before{content:'';flex:1;cursor:default;pointer-events:none}.splitter{display:block;width:4px;background:var(--border-color);cursor:col-resize;flex-shrink:0;z-index:100001;position:relative;pointer-events:auto;transform:translateX(100%);transition:transform .4s cubic-bezier(.25,.8,.25,1)}.overlay.no-anim .splitter{transition:none!important}.splitter:hover,.splitter.dragging{background:var(--filter-active)}.console-header{padding:6px 15px}.console-title{font-size:16px}.header-icon-btn,.close-btn,.clear-all-btn{width:34px;height:34px;font-size:17px}.tabs{padding:2px 10px 0}.tab-btn{padding:8px 14px;font-size:14px}.controls,.network-controls{padding:4px 12px;flex-wrap:nowrap}}@media(max-width:768px){.splitter{display:none}}@media(max-width:768px){.overlay{flex-direction:column;align-items:center;justify-content:center}.console-container{transform:translateY(100%)!important}.overlay.active .console-container{transform:translateY(0)!important}}.console-header{display:flex;justify-content:space-between;align-items:center;padding:8px 25px;background:var(--header-bg);border-bottom:1px solid var(--border-color);position:relative}.console-title{color:var(--text-color);gap:10px;display:flex;align-items:center;font-size:18px}.header-actions{display:flex;align-items:center;gap:2px}.header-icon-btn{background:0 0;border:none;color:var(--text-color);font-size:18px;cursor:pointer;width:40px;height:40px;display:flex;align-items:center;justify-content:center;border-radius:5px;transition:all .3s}.header-icon-btn:hover{background:rgba(106,174,255,0.2);color:var(--json-key)}.close-btn,.clear-all-btn{background:0 0;border:none;color:var(--text-color);font-size:20px;cursor:pointer;width:40px;height:40px;display:flex;align-items:center;justify-content:center;border-radius:5px;transition:all .3s}.close-btn:hover{background:rgba(255,100,100,.2);color:#ff6464;transform:scale(1.1)}.clear-all-btn:hover,.clear-all-btn:active{background:rgba(255,100,100,.2);color:var(--clear-btn-hover)}.tabs{display:block;white-space:nowrap;overflow-x:auto;background:var(--tab-bg);padding:5px 10px 0;border-bottom:1px solid var(--border-color)}.tab-btn{padding:12px 20px;background:0 0;border-radius:5px 5px 0 0;border:none;color:var(--tab-color);cursor:pointer;position:relative;display:inline-flex;align-items:center;gap:8px}.tab-btn.active{color:var(--text-color);font-weight:600}.tab-btn.active::after{content:'';position:absolute;bottom:0;left:0;width:100%;height:2px;border-radius:3px;background:var(--filter-active)}.tab-btn:hover:not(.active){background:rgba(255,255,255,.05)}.controls{display:flex;padding:6px 15px;background:var(--controls-bg);gap:10px;flex-wrap:nowrap;border-bottom:1px solid var(--border-color);align-items:center;overflow-x:auto}.network-controls{display:flex;align-items:center;gap:8px;padding:6px 15px;background:var(--controls-bg);border-bottom:1px solid var(--border-color);flex-wrap:nowrap}.search-bar{display:flex;align-items:center;gap:8px;padding:10px 20px;background:var(--controls-bg);border-bottom:1px solid var(--border-color)}.search-input-wrap{display:flex;align-items:center;flex:1;position:relative}.search-bar-icon{position:absolute;left:10px;color:var(--text-color);opacity:.6;font-size:14px;pointer-events:none}.search-bar input{flex:1;padding:8px 10px 8px 35px;border-radius:5px;border:none;background:var(--search-bg);color:var(--text-color);transition:all .3s ease;font-size:14px;border:1px solid var(--border-color)}.search-bar input:focus{outline:0;border-color:#4a4ae6}.search-bar-close{background:0 0;border:none;color:var(--text-color);font-size:16px;cursor:pointer;padding:4px 8px;border-radius:5px;opacity:.6;transition:all .3s}.search-bar-close:hover{opacity:1;background:rgba(255,255,255,.1)}.console-content{flex:1;overflow:auto;display:flex;flex-direction:column;position:relative}.console-output{flex:1;overflow-y:auto;padding:20px;font-family:monospace;font-size:.95rem}.localstorage-view{flex:1;padding:20px;font-family:monospace;font-size:.95rem;position:relative;overflow:hidden}.ls-items{position:absolute;inset:0;overflow-y:auto;padding:20px}.log-item{padding:8px 12px;margin-bottom:6px;display:flex;flex-direction:column;border-left:3px solid #4a4ae6;background:var(--log-bg);border-radius:5px;cursor:pointer;transition:background .2s;color:var(--text-color);user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}.log-item .log-icon .ico{color:inherit}.log-item.selected{border-left-color:var(--json-key);background:var(--selected-bg)}.log-item.log{border-left-color:#4a4ae6}.log-item.info{border-left-color:var(--log-icon-info)}.log-item.warn{border-left-color:var(--log-icon-warn);background:var(--log-bg-warn)}.log-item.error{border-left-color:var(--log-icon-error);background:rgba(255,59,48,.15)}.log-item.warn.selected,.log-item.error.selected{border-left-color:var(--json-key);background:var(--selected-bg)}.log-count{background:#4a4ae6;color:#fff;border-radius:4px;min-width:20px;height:20px;display:inline-flex;align-items:center;justify-content:center;font-size:11px;margin-right:4px;padding:0 5px;flex-shrink:0}.log-icon{flex-shrink:0;display:flex;align-items:center;font-size:13px;margin-right:2px}.log-header{display:flex;align-items:center;gap:0;margin-bottom:2px}.log-content{width:100%;font-size:13px;max-height:300px;overflow-y:auto;margin-top:4px;word-break:break-word;line-height:1.5;user-select:text;-webkit-user-select:text}.timestamp{color:var(--json-cmt);font-size:11px;margin-left:4px;white-space:nowrap}.json-preview{font-family:monospace;padding:10px;margin-top:5px;background:var(--json-bg);border-radius:5px;white-space:pre!important;max-height:400px;overflow:auto}.json-tree-container{font-family:monospace;padding:2px 0;margin-top:2px;background:0 0;border-radius:0;max-height:300px;overflow:auto;font-size:12px;line-height:1.6}.tree-node{position:relative;cursor:pointer;-webkit-tap-highlight-color:transparent}.tree-node.collapsed>.tree-children{display:none}.tree-toggle{display:inline-block;width:9px;color:var(--json-cmt);text-align:center}.ico{display:inline-block;width:1em;height:1em;fill:currentColor;vertical-align:middle;flex-shrink:0}.tree-node.collapsed>.tree-toggle .ico-angle-down{display:none}.tree-node.expanded>.tree-toggle .ico-angle-right{display:none}.tree-spacer{display:inline-block;width:9px}.tree-leaf{white-space:pre}.tree-leaf-text{white-space:pre-wrap;word-break:break-all;max-height:8em;overflow-y:auto}.tree-label,.tree-brace,.tree-ellipsis,.json-cmt{color:var(--json-cmt)}.tree-children{margin-left:16px;padding-left:4px}.tree-load-more{color:var(--json-cmt);cursor:pointer;padding:4px 0;user-select:none;font-size:11px}.tree-node.collapsed>.tree-open{display:none}.tree-node.collapsed>.tree-close{display:none}.tree-node.expanded>.tree-close{display:block;padding-left:16px}.tree-node.expanded>.tree-collapsed{display:none}.tree-node.collapsed>.tree-ellipsis,.tree-node>.tree-close-tag{display:inline}.tree-node.expanded>.tree-ellipsis{display:none}.json-number{color:var(--json-number)}.json-boolean{color:var(--json-boolean)}.json-key{color:var(--json-key)}.json-tag{color:var(--json-tag)}.json-null{color:var(--json-null)}.json-string{color:var(--json-string)}.log-actions{margin-top:8px;display:flex;gap:10px;font-size:10px}.log-action{color:var(--json-key);cursor:pointer;padding:5px 10px;background:var(--action-bg);transition:all .2s;display:inline-flex;align-items:center;gap:5px;border-radius:5px}.error-stack{font-family:monospace;padding:10px;margin-top:10px;background:rgba(255,59,48,.2);border-radius:5px;white-space:nowrap;font-size:.85rem;overflow:auto;max-height:400px}.object-preview{font-family:monospace;padding:10px;margin-top:5px;background:var(--json-bg);color:var(--json-number);border-radius:5px;white-space:pre;max-height:600px;overflow:auto}.function-preview{font-family:monospace;padding:10px;margin-top:5px;background:var(--json-bg);color:var(--json-boolean);border-radius:5px;white-space:pre;word-break:break-all;overflow-x:auto}.ls-item{background:var(--log-bg);padding:15px;margin-bottom:15px;border-radius:8px}.ls-key-row{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;border-bottom:1px solid var(--border-color);padding-bottom:10px}.ls-key{color:var(--json-key);font-size:16px;max-width:60%;overflow-x:auto;white-space:nowrap}.ls-actions{display:flex;gap:8px}.ls-action-btn{background:var(--action-bg);border:none;color:var(--text-color);padding:5px 10px;border-radius:5px;cursor:pointer;transition:all .2s;display:flex;align-items:center;gap:5px}.ls-value{white-space:normal;word-break:break-all;padding:10px;background:var(--json-bg);border-radius:5px;font-family:monospace;max-height:200px;overflow-y:auto;color:var(--text-color);font-size:13px}.ls-value-type{font-size:8px;opacity:.7;margin-top:5px;color:var(--text-color)}.vs-spacer{width:100%;flex-shrink:0}.ls-editor-overlay{position:absolute;inset:0;z-index:100;display:flex;flex-direction:column;background:var(--console-bg)}.ls-editor-header{padding:12px 20px;background:var(--header-bg);border-bottom:1px solid var(--border-color)}.ls-editor-header-row{display:flex;align-items:center;gap:10px}.ls-editor-key-input{flex:1;padding:8px 12px;border:1px solid var(--border-color);border-radius:6px;background:var(--search-bg);color:var(--json-key);font-size:14px;font-family:monospace;outline:0;transition:border .2s}.ls-editor-title{color:var(--text-color);font-size:15px;font-weight:600;white-space:nowrap}.ls-editor-body{flex:1;padding:15px 20px;overflow:hidden;display:flex}.ls-editor-body textarea{flex:1;width:100%;padding:12px;background:var(--search-bg);border:1px solid var(--border-color);border-radius:8px;color:var(--text-color);font-family:monospace;font-size:14px;resize:none;outline:0;transition:border .2s;line-height:1.5}.ls-editor-footer{display:flex;gap:10px;justify-content:flex-end;padding:12px 20px;background:var(--header-bg);border-top:1px solid var(--border-color)}.ls-editor-btn{padding:8px 24px;border:none;border-radius:6px;font-size:14px;cursor:pointer;transition:all .2s;font-weight:500}.ls-editor-btn.cancel{background:var(--controls-bg);color:var(--text-color)}.ls-editor-btn.save{background:var(--filter-active);color:#fff}.ls-editor-btn.run{background:var(--filter-active);color:#fff}.console-table-wrap{overflow-x:auto;margin-top:5px;-webkit-overflow-scrolling:touch;border-radius:8px;border:1px solid rgba(128,128,128,0.25)}.console-table{border-collapse:separate;border-spacing:0;width:100%;font-size:12px;font-family:monospace;overflow:hidden}.console-table th{background:var(--controls-bg);color:var(--json-key);padding:6px 10px;text-align:left;border-bottom:1px solid rgba(128,128,128,0.25);border-right:1px solid rgba(128,128,128,0.25);white-space:nowrap;position:sticky;top:0}.console-table td{padding:5px 10px;border-bottom:1px solid rgba(128,128,128,0.25);border-right:1px solid rgba(128,128,128,0.25);color:var(--text-color);white-space:nowrap;max-width:200px;overflow:hidden;text-overflow:ellipsis}.console-table tbody tr:nth-child(even){background:var(--log-bg)}.console-table th:last-child,.console-table td:last-child{border-right:none}.console-table tbody tr:last-child td{border-bottom:none}.ls-add-btn{font-size:18px!important;opacity:1!important;width:40px!important;height:40px!important;padding:0!important;margin-left:0!important}.elements-view{flex:1;overflow-y:auto;padding:10px;font-family:monospace;font-size:12px;line-height:1.6}.elements-tree .tree-node{white-space:normal;word-break:break-all}.el-header-btn{width:40px!important;height:40px!important;font-size:18px!important}.el-header-btn.el-delete-btn:hover{color:var(--clear-btn-color);background:rgba(255,100,100,.15)}.tree-node.el-highlight>.tree-label{display:inline-block!important;background:var(--action-hover)!important;border-radius:3px;padding:1px 4px}.tree-node.el-selected>.tree-label{display:inline-block!important;background:rgba(106,174,255,0.4);border-radius:3px;padding:1px 4px}.element-picker-overlay{position:fixed;top:0;left:0;width:100%;height:100%;z-index:100000;cursor:crosshair;background:transparent;pointer-events:none}@media(max-width:768px){.controls{flex-direction:row;align-items:center;padding:5px 10px;overflow-x:auto;flex-wrap:nowrap}.log-item{flex-wrap:nowrap}.log-actions{flex-wrap:wrap}.floating-console-btn{padding:12px 20px;font-size:.9rem;right:20px;bottom:20px}.tab-btn{padding:8px 12px;font-size:14px}.elements-tree .tree-leaf-text{max-height:12em}.nolog{text-align:center;font-size:20px;color:var(--json-cmt);padding:40px 0;display:flex;align-items:center;justify-content:center;gap:5px}}.notification.show{transform:translateX(0)}.notification{position:fixed;top:20px;right:20px;padding:12px 20px;background:rgba(76,175,80,.6);backdrop-filter:blur(12px);color:#fff;border-radius:5px;box-shadow:0 2px 10px rgba(0,0,0,.2);z-index:99999;display:none;transform:translateX(150%);max-height:48px;max-width:calc(100vw - 40px);transition:transform .3s ease;font-size:15px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.notification.warning{background:rgba(255,152,0,.6);backdrop-filter:blur(12px)}.network-controls{padding:5px 10px}.overflow-scroll.overflow-start:not(.overflow-end){-webkit-mask-image:linear-gradient(to right,transparent,#000 40px);mask-image:linear-gradient(to right,transparent,#000 40px)}.overflow-scroll.overflow-end:not(.overflow-start){-webkit-mask-image:linear-gradient(to left,transparent,#000 40px);mask-image:linear-gradient(to left,transparent,#000 40px)}.overflow-scroll.overflow-start.overflow-end{-webkit-mask-image:linear-gradient(to right,transparent,#000 40px,#000 calc(100% - 40px),transparent);mask-image:linear-gradient(to right,transparent,#000 40px,#000 calc(100% - 40px),transparent)}.tree-toggle>.ico{font-size:10px;color:var(--json-cmt);transition:transform .2s;cursor:pointer;width:9px;height:9px;text-align:center;display:inline-block}.network-view{display:none;flex:1;overflow:hidden;flex-direction:column;position:relative}",e.setAttribute("tcstyle",""),e.setAttribute("tc-lock",""),this.shadowRoot.append(e)}setupSplitter(){let e=!1,t=0,s=0,i=()=>{e=!1,this.splitter.classList.remove("dragging"),document.body.style.cursor="",document.body.style.userSelect=""};this.splitter.addEventListener("mousedown",i=>{i.preventDefault(),e=!0,t=i.clientX,s=this.consoleContainer.offsetWidth||.5*window.innerWidth,this.splitter.classList.add("dragging"),document.body.style.cursor="col-resize",document.body.style.userSelect="none"}),document.addEventListener("mousemove",i=>{if(!e)return;let n=i.clientX,o=window.innerWidth-(s+(t-n));o=Math.max(200,Math.min(window.innerWidth-50,o)),this.consoleContainer&&(this.consoleContainer.style.width=o+"px",this.consoleContainer.style.flex="none")}),document.addEventListener("mouseup",i),this.splitter.addEventListener("touchstart",t=>{t.preventDefault(),e=!0,s=this.consoleContainer.offsetWidth||.5*window.innerWidth,t.touches[0],this.splitter.classList.add("dragging")}),document.addEventListener("touchmove",t=>{if(!e)return;let s=t.touches[0],i=window.innerWidth-s.clientX;i=Math.max(200,Math.min(window.innerWidth-50,i)),this.consoleContainer&&(this.consoleContainer.style.width=i+"px",this.consoleContainer.style.flex="none")}),document.addEventListener("touchend",i)}showNotification(e,t=""){let s=this._notifSeq=1+(0|this._notifSeq);this.notification.innerHTML='<span style="display:inline-block;vertical-align:middle;margin-right:8px">'+this.icon("warning"==t?"exclamation":"check")+"</span>"+e.replace(/</,"<").replace(/>/,">"),this.notification.className="notification","warning"===t&&this.notification.classList.add("warning"),this.notification.style.display="block",this.notification.offsetHeight,this.notification.classList.add("show"),clearTimeout(this._notifTimer),this._notifTimer=setTimeout(()=>{this.notification.classList.remove("show"),setTimeout(()=>{this._notifSeq===s&&(this.notification.style.display="none")},300)},3e3)}captureConsoleLogs(){this.originalConsole={log:console.log,info:console.info,warn:console.warn,error:console.error,debug:console.debug,time:console.time,timeEnd:console.timeEnd,count:console.count,countReset:console.countReset,assert:console.assert,trace:console.trace,group:console.group,groupEnd:console.groupEnd,clear:console.clear,table:console.table},console.log=(...e)=>(this.captureConsole("log",...e),console),console.info=(...e)=>(this.captureConsole("info",...e),console),console.warn=(...e)=>(this.captureConsole("warn",...e),console),console.error=(...e)=>(this.captureConsole("error",...e),console),console.debug=(...e)=>(this.captureConsole("log",...e),console),console.table=(e,t)=>(this._captureSubType="table",this._captureExtra={columns:t},this.captureConsole("log",e),this._captureSubType=null,this._captureExtra=null,console),console.time=(e="time")=>{e+="";let t=performance.now();this.timerMap.has(e)&&clearTimeout(this.timerMap.get(e).timeoutId);let s=setTimeout(()=>{if(!this.timerMap.has(e))return;let{start:t}=this.timerMap.get(e);this.timerMap.delete(e),console.info(`[time] "${e}"用时: ${(performance.now()-t).toFixed(1)}ms(已超时)`)},3e5);this.timerMap.set(e,{start:t,timeoutId:s})},console.timeEnd=(e="time")=>{e+="";let t=this.timerMap.get(e);if(!t)return void console.error(`[timeEnd] 标签"${e}"不存在`);t.timeoutId&&clearTimeout(t.timeoutId);let s=performance.now()-t.start;this.timerMap.delete(e),console.info(`[time] "${e}"用时: ${s.toFixed(1)}ms`)},console.count=(e="count")=>{e+="";let t=(this.countMap.get(e)||0)+1;this.countMap.set(e,t),console.info(`[count] 标签"${e}"被调用了${t}次`)},console.countReset=(e="count")=>{e+="",this.countMap.has(e)?this.countMap.delete(e):console.error(`[countReset] 标签"${e}"不存在`)},console.assert=(e,...t)=>{e||console.error("[assertion failed] ",...t)},console.trace=(...e)=>{let t=Error().stack.split("\n").slice(2).join("\n");console.warn("[trace] ",...e,"\n"+t)},console.group=e=>(this.captureConsole("log",`[Group ${e}]`),console),console.groupEnd=()=>(this.captureConsole("log","[GroupEnd]"),console),console.clear=()=>(this.clearAllLogs(!0),console)}isClass(e){return"function"==typeof e&&e.prototype&&e.prototype.constructor===e&&!1===Object.getOwnPropertyDescriptor(e,"prototype").writable}renderFunctionInline(e){let t=e.name||"anonymous",s=this.getParams(e);return'<span class="json-boolean">ƒ '+this.escapeHtml(t)+'</span><span class="json-cmt">('+this.escapeHtml(s)+")</span>"}renderFunctionCollapsed(e){let t=e.name||"anonymous",s=this.getParams(e);return'<span class="json-boolean">ƒ '+this.escapeHtml(t)+'</span><span class="json-cmt">('+this.escapeHtml(s)+")</span>"}safeStringify(e,s=2,i=!0){let n=new WeakSet,o=(e,t=new WeakSet)=>null===e||"object"!=typeof e?"bigint"==typeof e?""+e.toString()+"n":e:t.has(e)?"[循环引用]":(t.add(e),e instanceof RegExp?""+e.toString():e instanceof Date?""+e.toISOString():"function"==typeof e?this.isClass(e)?"[Class "+(e.name||"anonymous")+"]":"ƒ "+(e.name||"anonymous")+"("+this.getParams(e)+")":e instanceof Error?"[Error: "+e.message+"]":e instanceof ArrayBuffer?"[ArrayBuffer "+e.byteLength+" bytes]":e instanceof WeakMap?"[WeakMap]":e instanceof WeakSet?"[WeakSet]":e instanceof Map?"[Map "+e.size+"]":e instanceof Set?"[Set "+e.size+"]":Array.isArray(e)?e.map(e=>o(e,t)):(()=>{let s={};try{Reflect.ownKeys(e).forEach(i=>{let n=Object.getOwnPropertyDescriptor(e,i);if(n){let l="symbol"==typeof i?"["+i.toString()+"]":i+"";if("value"in n)s[l]=o(n.value,t);else if(n.get)try{s[l]=o(n.get.call(e),t)}catch{s[l]="[getter]"}}})}catch{}let n=Object.getPrototypeOf(e);return i&&n&&null!==n&&(s["[[Prototype]]"]=o(n,t)),s})());return e=o(e),JSON.stringify(e,function(e,s){if(void 0===s)return"undefined";if("number"==typeof s){if(Number.isNaN(s))return"NaN";if(!isFinite(s))return""+(s>0?"Infinity":"-Infinity")}if("object"==typeof s&&null!==s){if(n.has(s))return"[循环引用]";if(n.add(s),!Array.isArray(s)&&s.constructor===Object)return Object.keys(s).sort((e,t)=>{let s="[[Prototype]]"===e,i="[[Prototype]]"===t,n=e.endsWith("[[Prototype]]")&&"[[Prototype]]"!==e,o=t.endsWith("[[Prototype]]")&&"[[Prototype]]"!==t;if(s&&!i)return 1;if(!s&&i)return-1;if(n&&!o)return 1;if(!n&&o)return-1;let l=e.match(/^(_*)/)[0].length,r=t.match(/^(_*)/)[0].length;return l!==r?l-r:e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}).reduce((e,t)=>(e[t]=s[t],e),{});if(s instanceof Error)return{"名称":s.name,"信息":s.message,"堆栈":s.stack};if(s instanceof Date)return s.toISOString();if(s instanceof HTMLElement)return`<${s.tagName.toLowerCase()}>${s.tagName.toLowerCase()}元素</${s.tagName.toLowerCase()}>`}return"string"==typeof s?s.startsWith("")?s:""+s:"function"==typeof s?""+(t.tC.isClass(s)?`[Class ${s.name||"anonymous"}]`:`ƒ ${s.name||"anonymous"}(${t.tC.getParams(s)})`):s},s)}formatArgsForPlainText(e){return Array.from(e).map(e=>{if("function"==typeof e)return this.isClass(e)?`[Class ${e.name||"anonymous"}]`:`ƒ ${e.name||"anonymous"}(${this.getParams(e)})`;if("object"==typeof e&&null!==e)try{return this.clr(this.safeStringify(e))}catch{return"无法序列化]"}return e+""}).join(" ")}captureConsole(e,...t){if(this._capturing)this.originalConsole[e].apply(console,t);else{this._capturing=!0;try{this.triggerGlobalHook("beforeLog",e,...t);let s=!1;if(this.mutedFilters.console&&(this.mutedFilters.console.all||this.mutedFilters.console[e])&&(s=!0),this.mutedLogs||s)return void this.originalConsole[e].apply(console,t);let i=new Date,n=t.map(e=>{if("object"==typeof e&&null!==e)try{if(e instanceof HTMLElement)return`el:<${e.tagName.toLowerCase()}>`;if(e instanceof Date)return"d:"+e.getTime();if(e instanceof RegExp)return"re:"+e.toString();if(e instanceof Error)return"e:"+e.message;let t=Object.entries(e).reduce((e,[t,s])=>{if("then"===t&&"function"==typeof s)return e;if("object"==typeof s&&null!==s)try{e[t]=JSON.stringify(s)}catch{e[t]="NestedObject"}else e[t]=s;return e},{});return"o:"+JSON.stringify(t)}catch{return"u:"+Math.random().toString(36).substring(2,10)}return`${typeof e}:${e+""}`}).join("|");if(this.lastLog&&this.lastLog.type===e&&this.lastLog.contentSign===n&&(this.lastLog.subType||null)===(this._captureSubType||null)&&!t.some(e=>"object"==typeof e&&null!==e)){this.lastLog.args=[...t],this.lastLog.timestamp=new Date,this.lastLog.count++;let s=this.shadowRoot.querySelector(`[tc-idx="${this.lastLog.id}"]`);if(s){let e=s.querySelector(".log-count");if(e)e.textContent=this.lastLog.count;else{let e=s.querySelector(".log-header");if(e){let t=document.createElement("div");t.className="log-count",t.textContent=this.lastLog.count;let s=e.querySelector(".log-icon");s?e.insertBefore(t,s):e.appendChild(t)}}}return this.originalConsole[e].apply(console,t),void this.updateFilterCounts()}{let s={id:this.logs.length,type:e,args:[...t],content:this.formatArgsForPlainText(t),timestamp:i,count:1,expandedJson:!1,contentSign:n,hasObject:t.some(e=>"function"==typeof e),isError:"error"===e||t.some(e=>e instanceof Error),subType:this._captureSubType||null,subTypeData:this._captureExtra||null};this.logs.push(s),this.lastLog=s,this.triggerGlobalHook("afterLog",s)}this.originalConsole[e].apply(console,t),this.overlay?.classList.contains("active")&&"console"===this.currentTab&&(this.updateFilterCounts(),this.renderLogList(this.logs,!1)),this.logs.length>this.maxLog&&this.logs.splice(0,this.logs.length-this.maxLog)}finally{this._capturing=!1}}}formatArgs(e,t){let s=t||"x",i=Array.from(e),n=i.map(e=>"function"==typeof e?`<div class="function-preview">${this.escapeHtml(e.toString())}</div>`:e instanceof Error?`<div class="error-stack"><strong>${e.name}:</strong>${e.message}<div>${e.stack||"无堆栈信息"}</div></div>`:e instanceof HTMLElement?'<div class="json-tree-container">'+this.renderHTMLTree(e,"",s+":html")+"</div>":e instanceof Date?`<div class="json-preview"><span class="json-string">${e.toISOString()}</span></div>`:e instanceof RegExp?`<div class="json-preview"><span class="json-number">${e.toString()}</span></div>`:e instanceof Map?`<div class="json-preview"><span class="json-boolean">[Map ${e.size}]</span></div>`:e instanceof Set?`<div class="json-preview"><span class="json-boolean">[Set ${e.size}]</span></div>`:e instanceof WeakMap?'<div class="json-preview"><span class="json-boolean">[WeakMap]</span></div>':e instanceof WeakSet?'<div class="json-preview"><span class="json-boolean">[WeakSet]</span></div>':e instanceof ArrayBuffer?`<div class="json-preview"><span class="json-boolean">[ArrayBuffer ${e.byteLength} bytes]</span></div>`:this.fmtVal(e,s,0));return i.splice(0,1),n.join(" ")}fmtVal(e,t,s){return"bigint"==typeof e?`<span class="json-number">${e.toString()}n</span>`:e&&"object"==typeof e?'<div class="json-tree-container">'+this.renderJSONTree(e,"",null,null,t+(s?":r:":":"),0)+"</div>":"number"==typeof e?Number.isNaN(e)?'<span class="json-cmt">NaN</span>':isFinite(e)?`<span class="json-number">${e}</span>`:`<span class="json-cmt">${e>0?"Infinity":"-Infinity"}</span>`:"boolean"==typeof e?`<span class="json-boolean">${e}</span>`:(e+"").replace(/</g,"<").replace(/>/g,">").replace(/\n/g,"<br>")}highlightHTML(e){let t=e.outerHTML.replace(/</g,"<").replace(/>/g,">").replace(/<br>/g,"<br>"),s="",i=0;for(;i<t.length;)if(t.startsWith("<",i)){let e=t[i+4];if(e&&("/"===e||/[a-zA-Z]/.test(e))){let e=t.indexOf(">",i);if(-1!==e){let n=t.slice(i,e+4);n=n.replace(/([\w-]+)(=)("[^"]*")/g,'<span class="json-tag">$1</span><span class="json-boolean">$2</span><span class="json-string">$3</span>'),n=n.replace(/^(<\/?)([\w-]+)/,'<span class="json-tag">$1</span><span class="json-tag">$2</span>'),n=n.replace(/(>)$/,'<span class="json-tag">$1</span>'),s+=n,i=e+4;continue}}let n=t.indexOf("<",i+4);-1===n&&(n=t.length);let o=t.slice(i,n);s+=o.trim()?`<span class="json-cmt">${o}</span>`:o,i=n}else if(t.startsWith("<br>",i))s+="<br>",i+=4;else{let e=t.indexOf("<",i);-1===e&&(e=t.length);let n=t.slice(i,e);s+=n.trim()?`<span class="json-cmt">${n}</span>`:n,i=e}return s}highlightJson=e=>e&&e.replace(/("(?:\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(?:\s*:)?|\b(?:true|false|null)\b|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b|[\{\}\[\],.:])/g,e=>{let t="json-cmt";if("true"===e||"false"===e)t="json-boolean";else if("null"===e)t="json-null";else if(/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(e))t="json-number";else if(e.endsWith(":"))t="json-key";else if(e.startsWith('"')){let s=e.slice(1,-1);if(/^\\u0002\[/.test(s))return`<span class="json-string">"${s.slice(6)}"</span>`;if(/^\\u0003/.test(s)){let e=s.slice(6);if(/^-?\d+n$/.test(e))return`<span class="json-number">${e}</span>`;if(/^\u0192\s/.test(e)){let t=e.match(/^(\u0192\s+\S+)(\(.*\))$/);return t?`<span class="json-boolean">${t[1]}</span><span class="json-cmt">${t[2]}</span>`:`<span class="json-boolean">${e}</span>`}return/^\[(?:Class|ArrayBuffer|Map|Set|WeakMap|WeakSet|Error)/.test(e)?`<span class="json-boolean">${e}</span>`:/^\/.*\/[gimsuy]*$/.test(e)?`<span class="json-number">${e}</span>`:/^\d{4}-\d{2}-\d{2}T/.test(e)?`<span class="json-string">${e}</span>`:/^(?:undefined|NaN|Infinity|-Infinity)$/.test(e)?`<span class="json-null">${e}</span>`:`<span class="json-string">${e}</span>`}t="json-string"}return`<span class="${t}">${e}</span>`})||"";renderJSONValue(e,t){if(null===e)return'<span class="json-null">null</span>';if(void 0===e)return'<span class="json-null">undefined</span>';if("string"==typeof e)return'<span class="json-string">"'+this.escapeHtml(e)+'"</span>';if("number"==typeof e)return'<span class="json-number">'+e+"</span>";if("boolean"==typeof e)return'<span class="json-boolean">'+e+"</span>";if("function"==typeof e){if(this.isClass(e)){let t=e.name||"anonymous";return'<span class="json-boolean">[Class '+this.escapeHtml(t)+"]</span>"}return this.renderFunctionInline(e)}if(e instanceof HTMLElement){let t=e.tagName.toLowerCase();return'<span class="json-tag"><'+t+">...</"+t+"></span>"}let s=Array.isArray(e),i=s?"Array("+e.length+")":"Object",n=s?e.map((e,t)=>({name:t+"",value:e})):Object.keys(e).map(t=>({name:t,value:e[t]}));if(0===n.length)return'<span class="json-cmt">'+(t?this.escapeHtml(t)+": ":"")+(s?"[]":"{}")+"</span>";let o='<div class="tree-node collapsed">';o+=this.treeToggleHtml(),t&&(o+='<span class="json-key">'+this.escapeHtml(t)+":</span> "),o+='<span class="tree-label">'+this.escapeHtml(i)+"</span>",o+='<span class="tree-brace tree-open">{</span><span class="tree-brace tree-collapsed">{...}</span>';let l=++this.treeNodeRegId;return this.treeNodeRegistry.set(l,{obj:e,children:n,isJsonValue:!0}),o+='<div class="tree-children" data-lazy-id="'+l+'"></div>',o+='<span class="tree-brace tree-close">}</span>',o+="</div>",o}renderJSONValueChildren(e,t){let s="";for(let t of e){let e=t.value;s+=null===e||"object"!=typeof e?'<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-key">'+this.escapeHtml(t.name)+":</span> "+this.renderJSONValue(e,"")+"</div>":"<div>"+this.renderJSONValue(e,t.name)+"</div>"}return s}toggleExpandJson(e){let t=this.logs.find(t=>t.id===e);t&&(t.expandedJson=!t.expandedJson,this.updateLogItem(e,!1))}updateLogItem(e,t=!1){let s=this.logs.find(t=>t.id===e);if(!s)return;let i=this.shadowRoot.querySelector(`[tc-idx="${e}"]`);if(!i)return;let n={info:"info-circle",warn:"exclamation-triangle",error:"times-circle",log:"info"}[s.type]||"info",o=s.timestamp.toLocaleTimeString(),l=s.expandedJson?this.formatArgs(s.args,s.id):this.renderLogContent(s);i.innerHTML=`<div class="log-header">${s.count>1?`<div class="log-count">${s.count}</div>`:""}<div class="log-icon">${this.icon(n)}</div><div class="timestamp">${o}</div><button class=log-item-copy title=复制>${this.icon("copy")}</button><button class=log-item-eye title=查看详情>${this.icon("eye")}</button></div><div class="log-content">${l}</div>${s.hasObject?`<div class="log-actions"><div class="log-action expand-btn" title="${s.expandedJson?"收起":"展开"}" onclick="thinConsole.tC.toggleExpandJson(${s.id})">${this.icon(s.expandedJson?"chevron-up":"chevron-down")}${s.expandedJson?"收起":"展开"}</div></div>`:""}</div>`}updateControlsVisibility(){let e=this.currentTab,t="console"===e,s="localstorage"===e,i="network"===e,n="elements"===e,o=(e,t)=>{e&&(e.style.display=t)};o(this.consoleControls,t||s?"flex":"none"),o(this.filtersContainerEl,t?"flex":"none"),o(this.lsFiltersContainer,s?"flex":"none"),o(this.lsAddBtn,s?"flex":"none"),o(this.netNewBtn,i?"flex":"none"),o(this.elementPickBtn,n?"flex":"none"),o(this.elCopyBtn,n&&this.selectedElement?"flex":"none"),o(this.elDeleteBtn,n&&this.selectedElement?"flex":"none"),o(this.searchBar,n?"none":this.searchExpanded?"flex":"none"),o(this.searchToggleBtn,n?"none":"flex"),this.updateEditorVisibility()}updateEditorVisibility(){if(!this.lsEditorOverlay)return;let e=this.editorState.visible;if(e&&"ls"===this.editorState.mode&&"localstorage"!==this.currentTab&&(e=!1),this.lsEditorOverlay.style.display=e?"flex":"none",e){let e="code"===this.editorState.mode;this.lsEditorKeyInput&&(this.lsEditorKeyInput.style.display=e?"none":"block"),this.lsEditorTitle.textContent=e?"运行代码":"",this.lsEditorInput.placeholder=e?"输入要执行的代码...":"输入值...",this.lsEditorSave.textContent=e?"运行":"保存",this.lsEditorSave.className="ls-editor-btn "+(e?"run":"save"),this.lsEditorInput.value!==this.editorState.value&&(this.lsEditorInput.value=this.editorState.value),!e&&this.lsEditorKeyInput&&this.lsEditorKeyInput.value!==this.editorState.key&&(this.lsEditorKeyInput.value=this.editorState.key)}this._ssv()}vsInit(e){if(!e)return;e._vs={items:[],renderItem:null,afterRender:null,avgHeight:70,estHeight:70,heights:new Map,lastStart:-1,lastEnd:-1,rafId:null,isAtBottom:!0,contentEl:null,topSpacer:null,bottomSpacer:null,fakeEl:null,hasStructure:!1,topSpaceHeight:0,lastScrollTop:0,lastTimestamp:0,speedToleranceFactor:100,maxSpeedTolerance:2e3,minSpeedTolerance:100};let t=document.createElement("div");t.className="vs-spacer",t.style.cssText="width:100%;flex-shrink:0;height:0";let s=document.createElement("div");s.className="vs-content",s.style.cssText="width:100%";let i=document.createElement("div");i.className="vs-spacer",i.style.cssText="width:100%;flex-shrink:0;height:0";let n=document.createElement("div");n.style.cssText="position:absolute;visibility:hidden;left:0;top:0;width:100%;pointer-events:none",e.innerHTML="",e.appendChild(t),e.appendChild(s),e.appendChild(i),e.appendChild(n),e._vs.topSpacer=t,e._vs.contentEl=s,e._vs.bottomSpacer=i,e._vs.fakeEl=n,e._vs.hasStructure=!0,e._vs.scrollHandler=()=>{let t=e._vs;if(!t)return;let s=e.scrollHeight,i=e.clientHeight,n=e.scrollTop;t.isAtBottom=Math.abs(s-i-n)<2;let o=e.querySelector(".tc-scroll-bottom");o&&o.classList.toggle("show",!t.isAtBottom);let l,r,a=Date.now(),c=a-t.lastTimestamp,d=n-t.lastScrollTop,h=Math.abs(d/(c||1))*t.speedToleranceFactor;c>1e3&&(h=1e3),h>t.maxSpeedTolerance&&(h=t.maxSpeedTolerance),h<t.minSpeedTolerance&&(h=t.minSpeedTolerance),t.lastScrollTop=n,t.lastTimestamp=a,t.lastScrollTop<n?(l=t.minSpeedTolerance,r=h):(l=h,r=t.minSpeedTolerance),t.topSpaceHeight<n-l&&t.topSpaceHeight+t.contentEl.offsetHeight>n+i+r||t.rafId||(t.rafId=requestAnimationFrame(()=>{t.rafId=null,this.vsRender(e)}))},e.addEventListener("scroll",e._vs.scrollHandler,{passive:!0})}vsRender(e){let t=e._vs;if(!t||!t.contentEl)return;if(!t.items||!t.items.length)return;let s=t.contentEl.children;if(s.length>0){let e=0;for(let i=0;i<s.length;i++){let n=s[i].offsetHeight+10;t.heights.set(t.lastStart+i,n),e+=n}let i=e/s.length;i>20&&i<2e3&&(t.avgHeight=Math.round(.5*t.avgHeight+.5*i))}let i=e.clientHeight||400,n=e.scrollTop,o=t.avgHeight||70;o<10&&(o=70);let l=600,r=n-l,a=n+i+l,c=0,d=0,h=0,p=t.items.length,u=!1;for(let e=0;e<t.items.length;e++){let s=t.heights.get(e)||o;if(!u&&c+s>=r&&(h=e,u=!0),c>=a){p=e;break}c+=s}if(u){if(p===t.items.length){p=t.items.length;let e=p;for(;e>h&&d<i+l;)e--,d+=t.heights.get(e)||o;h=Math.max(0,Math.min(h,e))}}else h=0;let f=!1;for(let e=h;e<p;e++)if(!t.heights.has(e)){f=!0;break}if(f&&t.fakeEl){let s=t.fakeEl,i=e.clientWidth;i>0&&(s.style.width=i+"px");for(let e=h;e<p;e++)if(!t.heights.has(e)){s.innerHTML=t.renderItem(t.items[e],e);let i=0;s.firstChild&&(i=s.firstChild.offsetHeight+10),i<10&&(i=o),t.heights.set(e,i)}s.innerHTML=""}c=0,d=0,h=0,p=t.items.length,u=!1;for(let e=0;e<t.items.length;e++){let s=t.heights.get(e)||o;if(!u&&c+s>=r&&(h=e,u=!0),c>=a){p=e;break}c+=s}if(u){if(p===t.items.length){p=t.items.length;let e=p;for(;e>h&&d<i+l;)e--,d+=t.heights.get(e)||o;h=Math.max(0,Math.min(h,e))}}else h=0;if(h===t.lastStart&&p===t.lastEnd){let s=0;for(let e=0;e<h;e++)s+=t.heights.get(e)||o;let i=0;for(let e=p;e<t.items.length;e++)i+=t.heights.get(e)||o;return t.topSpacer.style.height=s+"px",t.bottomSpacer.style.height=i+"px",t.topSpaceHeight=s,void(0===i&&t.isAtBottom&&(e.scrollTop=1e7))}t.lastStart=h,t.lastEnd=p;let g=0;for(let e=0;e<h;e++)g+=t.heights.get(e)||o;let m=0;for(let e=p;e<t.items.length;e++)m+=t.heights.get(e)||o;let b=e.scrollTop;t.topSpacer.style.height=g+"px",t.bottomSpacer.style.height=m+"px",t.topSpaceHeight=g;let v=document.createDocumentFragment();for(let e=h;e<p;e++){let s=document.createElement("div");for(s.innerHTML=t.renderItem(t.items[e],e);s.firstChild;)v.appendChild(s.firstChild)}t.contentEl.replaceChildren?t.contentEl.replaceChildren(v):(t.contentEl.innerHTML="",t.contentEl.appendChild(v));let y=t.contentEl.children;if(y.length>=1){let e=0;for(let s=0;s<y.length;s++){let i=y[s].offsetHeight+10;e+=i,Math.abs(i-(t.heights.get(h+s)||o))>5&&t.heights.set(h+s,i)}let s=Math.round(e/y.length);s>20&&s<2e3&&(t.avgHeight=Math.round(.5*t.avgHeight+.5*s))}if(0===m&&y.length>0){let e=0;for(let t=0;t<y.length;t++)e+=y[t].offsetHeight+10;if(e<i&&h>0){let s=Math.max(0,h-(Math.ceil((i-e)/o)+2));if(s<h){h=s,t.lastStart=h;let e=0;for(let s=0;s<h;s++)e+=t.heights.get(s)||o;t.topSpacer.style.height=e+"px",t.topSpaceHeight=e;let i=document.createDocumentFragment();for(let e=h;e<p;e++){let s=document.createElement("div");for(s.innerHTML=t.renderItem(t.items[e],e);s.firstChild;)i.appendChild(s.firstChild)}t.contentEl.replaceChildren?t.contentEl.replaceChildren(i):(t.contentEl.innerHTML="",t.contentEl.appendChild(i));let n=t.contentEl.children;if(n.length>=1){let e=0;for(let s=0;s<n.length;s++){let i=n[s].offsetHeight+10;e+=i,Math.abs(i-(t.heights.get(h+s)||o))>5&&t.heights.set(h+s,i)}let s=Math.round(e/n.length);s>20&&s<2e3&&(t.avgHeight=Math.round(.5*t.avgHeight+.5*s))}}}}let w=0;for(let e=0;e<h;e++)w+=t.heights.get(e)||o;let x=0;for(let e=p;e<t.items.length;e++)x+=t.heights.get(e)||o;t.topSpacer.style.height=w+"px",t.bottomSpacer.style.height=x+"px",t.topSpaceHeight=w,t.isAtBottom||b===e.scrollTop||(e.scrollTop=b),t.afterRender&&t.afterRender()}vsUpdate(e,t,s,i,n){let o=e._vs;if(!o)return;o.rafId&&(cancelAnimationFrame(o.rafId),o.rafId=null);let l=n&&n.trackBy?o.trackBy=n.trackBy:o.trackBy||(e=>e.id);if(!t||!t.length)return o.items=[],o.heights=new Map,o.lastStart=-1,o.lastEnd=-1,void(o.contentEl?(o.topSpacer.style.height="0",o.bottomSpacer.style.height="0",o.topSpaceHeight=0,o.contentEl.innerHTML=n&&n.emptyHTML||"",!(n&&n.preserveScroll)&&(e.scrollTop=0),o.isAtBottom=!0):e.innerHTML=n&&n.emptyHTML||"");let r=(!n||!n.force&&!n.preserveScroll)&&(o.isAtBottom=Math.abs(e.scrollHeight-e.clientHeight-e.scrollTop)<2),a=o.items?o.items.length:0,c=a>0&&o.items[0]&&t[0]&&l(o.items[0])!==l(t[0]);if(o.items=t,o.renderItem=s,n&&n.force?(o.avgHeight=i||70,o.isAtBottom=!1):o.avgHeight<10&&(o.avgHeight=i||100),o.afterRender=null,r)o.heights=new Map,o.lastStart=-1,o.lastEnd=-1,this.vsRender(e),o.isAtBottom&&(e.scrollTop=e.scrollHeight);else if((!n||!n.force)&&a>0&&t.length>=a&&!c&&o.lastEnd>=0){let e=0;for(let s=o.lastEnd;s<t.length;s++)e+=o.heights.get(s)||o.avgHeight;o.bottomSpacer.style.height=e+"px"}else o.heights=new Map,o.lastStart=-1,o.lastEnd=-1,n&&n.force&&!(n&&n.preserveScroll)&&(e.scrollTop=0),this.vsRender(e)}renderSubTypeContent(e){let t=e.args&&e.args.length>0?e.args[0]:void 0;return"table"===e.subType?this.renderTableHTML(t,e.subTypeData?.columns):""}_treeNodeOpen(e,t,s,i){let n="tree-node "+(e?"expanded":"collapsed"),o=t+'="'+this.escapeHtml(s)+'"';return i&&(o+=" "+i),'<div class="'+n+'" '+o+">"}_treeNodeChildrenLazy(e,t){return this.treeNodeRegistry.set(e,t),'<div class="tree-children" data-lazy-id="'+e+'"></div>'}_treeShadowNode(e,t,s,i,n,o){let l="tree-node "+(e?"expanded":"collapsed"),r=t+'="'+this.escapeHtml(s+"")+'"';return o&&(r+=" "+o),'<div class="'+l+'" '+r+">"+this.treeToggleHtml()+'<span class="tree-label json-null">#shadow('+i+')</span><span class="tree-ellipsis">...</span><div class="tree-children">'+n+"</div></div>"}renderJSONTree(e,t,s,i,n,o,l){if("string"==typeof e&&!s)try{let t=JSON.parse(e);return null==t||"object"!=typeof t?this.highlightJson(this.escapeHtml(e)):'<div class="json-tree-container">'+this.renderJSONTree(t,"",0,0,n,0,!0)+"</div>"}catch{return'<span style="color:var(--json-cmt);white-space:pre-wrap;word-break:break-all">'+this.escapeHtml(e)+"</span>"}if(s||(s=new WeakSet),i||(i=[]),o=o||0,null===e)return'<span class="json-null">null</span>';if(void 0===e)return'<span class="json-null">undefined</span>';if("string"==typeof e)return'<span class="json-string">"'+this.escapeHtml(e)+'"</span>';if("number"==typeof e)return'<span class="json-number">'+e+"</span>";if("boolean"==typeof e)return'<span class="json-boolean">'+e+"</span>";if("bigint"==typeof e)return'<span class="json-number">'+e.toString()+"n</span>";if("symbol"==typeof e){let t=Object.create(Object.getPrototypeOf(Object(e)));Object.defineProperty(t,"value",{value:e.toString(),enumerable:!0,writable:!0,configurable:!0}),Object.defineProperty(t,"description",{value:e.description,enumerable:!0,writable:!0,configurable:!0}),e=t}if("function"==typeof e){if(this.isClass(e)){let t=e.name||"anonymous";return'<span class="json-boolean">[Class '+this.escapeHtml(t)+"]</span>"}return this.renderFunctionInline(e)}if(e instanceof Date)return'<span class="json-string">'+e.toISOString()+"</span>";if(e instanceof RegExp)return'<span class="json-number">'+e.toString()+"</span>";if(e instanceof Map)return'<span class="json-boolean">[Map '+e.size+"]</span>";if(e instanceof Set)return'<span class="json-boolean">[Set '+e.size+"]</span>";if(e instanceof WeakMap)return'<span class="json-boolean">[WeakMap]</span>';if(e instanceof WeakSet)return'<span class="json-boolean">[WeakSet]</span>';if(e instanceof ArrayBuffer)return'<span class="json-boolean">[ArrayBuffer '+e.byteLength+" bytes]</span>";if(e instanceof Error)return'<span class="json-boolean">[Error: '+this.escapeHtml(e.message)+"]</span>";if(e instanceof HTMLElement){let t=e.tagName.toLowerCase();return'<span class="json-tag"><'+t+">...</"+t+"></span>"}if(s.has(e))return'<span class="json-cmt">[循环引用]</span>';s.add(e);let r=i.concat([e]),a=Array.isArray(e),c=a?"Array("+e.length+")":e.constructor&&e.constructor.name?e.constructor.name:"Object",d=[];try{Reflect.ownKeys(e).forEach(t=>{let s=Object.getOwnPropertyDescriptor(e,t);s&&d.push({name:t+"",desc:s})})}catch(t){try{Object.keys(e).forEach(t=>{let s=Object.getOwnPropertyDescriptor(e,t);s&&d.push({name:t+"",desc:s})})}catch(t){return s.delete(e),'<span class="json-boolean">['+this.escapeHtml(c)+"]</span>"}}let h=Object.getPrototypeOf(e);if(!l&&h&&null!==h&&d.push({name:"[[Prototype]]",desc:{value:h,enumerable:!0,writable:!0,configurable:!0}}),0===d.length)return s.delete(e),a?'<span class="json-cmt">'+(t?this.escapeHtml(t)+": ":"")+"[]</span>":'<span class="json-cmt">'+(t?this.escapeHtml(t)+": ":"")+"{}</span>";a||d.sort((e,t)=>{if("[[Prototype]]"===e.name)return 1;if("[[Prototype]]"===t.name)return-1;let s=!(!e.desc.get&&!e.desc.set),i=!(!t.desc.get&&!t.desc.set);if(s&&!i)return 1;if(!s&&i)return-1;let n=(e.name.match(/^(_*)/)||[""])[0].length,o=(t.name.match(/^(_*)/)||[""])[0].length;if(n!==o)return n-o;let l=/^[A-Z]/.test(e.name),r=/^[A-Z]/.test(t.name);return l&&!r?1:!l&&r?-1:e.name.localeCompare(t.name,void 0,{numeric:!0,sensitivity:"base"})});let p=n||"",u=this.expandedTreePaths.has(p),f=this._treeNodeOpen(u,"data-tree-path",p);if(f+=this.treeToggleHtml(),t&&(f+='<span class="json-key">'+this.escapeHtml(t)+":</span> "),f+='<span class="tree-label">'+this.escapeHtml(c)+"</span>",f+='<span class="tree-brace tree-open">{</span><span class="tree-brace tree-collapsed">{...}</span>',u){f+='<div class="tree-children">';let e=200;if(d.length>e){let t=this.treeNodeRegId++;this.treeNodeRegistry.set(t,{children:d,chain:r,noProto:l}),f+=this.renderTreeChildrenBatch(d,s,0,e,r,p,o+1,l),f+='<div class="tree-load-more" data-reg-id="'+t+'" data-offset="'+e+'">'+this.icon("angle-down")+" 展开更多 (剩余 "+(d.length-e)+" 项)</div>"}else f+=this.renderTreeChildrenBatch(d,s,0,d.length,r,p,o+1,l);f+="</div>"}else{let t=this.treeNodeRegId++;f+=this._treeNodeChildrenLazy(t,{obj:e,children:d,chain:i,path:p,noProto:l})}return f+='<span class="tree-brace tree-close">}</span>',f+="</div>",s.delete(e),f}renderTreeChildrenBatch(e,t,s,i,n,o,l,r){l=l||0;let a="";for(let c=s;c<i&&c<e.length;c++){let s=e[c];if(s.desc.get||s.desc.set)s.desc.get&&(a+='<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-key">get '+this.escapeHtml(s.name)+":</span> "+this.renderJSONTree(s.desc.get,"",t,n,o+"."+s.name,l+1,r)+"</div>"),s.desc.set&&(a+='<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-key">set '+this.escapeHtml(s.name)+":</span> "+this.renderJSONTree(s.desc.set,"",t,n,o+"."+s.name,l+1,r)+"</div>");else{let e=s.desc.value;null===e||"object"!=typeof e||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof WeakMap||e instanceof WeakSet||e instanceof ArrayBuffer||e instanceof Error||e instanceof HTMLElement||"function"==typeof e?a+='<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-key">'+this.escapeHtml(s.name)+":</span> "+this.renderJSONTree(e,"",t,n,o+"."+s.name,l+1,r)+"</div>":t.has(e)?a+='<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-key">'+this.escapeHtml(s.name)+':</span> <span class="json-cmt">[循环引用]</span></div>':a+="<div>"+this.renderJSONTree(e,s.name,t,n,o+"."+s.name,l+1,r)+"</div>"}}return a}renderDomChild(e,t,s,i){return 1===e.nodeType?"<div>"+t(e,s,i)+"</div>":3===e.nodeType?'<div class="tree-leaf tree-leaf-text"><span class="tree-spacer"></span><span class="json-cmt">'+this.escapeHtml(e.textContent.trim())+"</span></div>":8===e.nodeType?'<div class="tree-leaf tree-leaf-text"><span class="tree-spacer"></span><span class="json-cmt"><!--'+this.escapeHtml(e.textContent)+"--></span></div>":""}renderDomChildrenLazy(e,t,s,i,n){let o="";if(e.length>200){let l=this.treeNodeRegId++;this.treeNodeRegistry.set(l,Object.assign({type:i,children:e,depth:s},n));for(let i=0;i<200;i++)o+=this.renderDomChild(e[i],t,i,s+1);o+='<div class="tree-load-more" data-reg-id="'+l+'" data-offset="200">'+this.icon("angle-down")+" 展开更多 ("+(e.length-200)+")</div>"}else{let i=0;for(let n of e)o+=this.renderDomChild(n,t,i,s+1),1===n.nodeType&&i++}return o}buildShadowLazy(e,t,s,i,n){let o='<div class="tree-node collapsed" ';if("element"===t){let t=++this.elRefId;this.elRefMap.set(t,e.root),o+='data-el-id="'+t+'" data-shadow-host="'+n+'"'}else o+='data-tree-path="'+this.escapeHtml(s+".shadow")+'" data-shadow-root="1"';o+=">"+this.treeToggleHtml()+'<span class="tree-label json-null">#shadow('+e.mode+")</span>";let l=Array.from(e.root.childNodes).filter(e=>this._vn(e));if(l.length>0){let n=this.treeNodeRegId++;this.treeNodeRegistry.set(n,{type:t+"-shadow",shadowInfo:e,path:s,depth:i,children:l}),o+='<span class="tree-ellipsis">...</span><div class="tree-children" data-lazy-id="'+n+'"></div>'}return o+"</div>"}loadMoreTreeChildren(e){let t=parseInt(e.dataset.regId),s=parseInt(e.dataset.offset),i=this.treeNodeRegistry.get(t);if(!i)return;let n=e.closest(".console-output, .ls-items, .elements-tree");if("html"===i.type){let t=Math.min(s+200,i.children.length),n="";for(let e=s;e<t;e++)n+=this.renderDomChild(i.children[e],(e,t)=>this.renderHTMLTree(e,"",i.path+"."+t,(i.depth||0)+1),e,0);e.insertAdjacentHTML("beforebegin",n)}else if("element"===i.type){let t=Math.min(s+200,i.children.length),n="";for(let e=s;e<t;e++)n+=this.renderDomChild(i.children[e],e=>this.renderElementTree(e,(i.depth||0)+1),e,0);e.insertAdjacentHTML("beforebegin",n)}else if("html-shadow"===i.type){let t=Math.min(s+200,i.children.length),n="";for(let e=s;e<t;e++)n+=this.renderDomChild(i.children[e],(e,t)=>this.renderHTMLTree(e,"",i.path+".shadow."+t,(i.depth||0)+1),e,0);e.insertAdjacentHTML("beforebegin",n)}else if("element-shadow"===i.type){let t=Math.min(s+200,i.children.length),n="";for(let e=s;e<t;e++)n+=this.renderDomChild(i.children[e],e=>this.renderElementTree(e,(i.depth||0)+1),e,0);e.insertAdjacentHTML("beforebegin",n)}else{let t=new WeakSet;i.chain.forEach(e=>t.add(e)),e.insertAdjacentHTML("beforebegin",this.renderTreeChildrenBatch(i.children,t,s,Math.min(s+200,i.children.length),i.chain,i.path||"",1,i.noProto))}let o=s+200;o<i.children.length?(e.dataset.offset=o,e.innerHTML=this.icon("angle-down")+" 展开更多 ("+(i.children.length-o)+")"):(e.remove(),this.treeNodeRegistry.delete(t)),n&&this.vsRender(n)}fmtAttrs(e){let t="";for(let s of e.attributes)t+=s.value?' <span class="json-tag">'+this.escapeHtml(s.name)+'</span><span class="json-boolean">=</span><span class="json-string">"'+this.escapeHtml(s.value)+'"</span>':' <span class="json-tag">'+this.escapeHtml(s.name)+"</span>";return t}renderHTMLTree(e,t,s,i){if((i=i||0)>30)return'<span class="json-cmt">[depth limit]</span>';s=s||"";let n=e.tagName.toLowerCase(),o="";o=this.fmtAttrs(e);let l=Array.from(e.childNodes),r=this.getShadowRoot(e),a=r&&Array.from(r.root.childNodes).some(e=>this._vn(e)),c=r&&(a||r.mode&&"closed"===r.mode),d=l.some(e=>this._vn(e))||!!c,h=this.expandedTreePaths.has(s),p=this._treeNodeOpen(h,"data-tree-path",s);if(p+=d?this.treeToggleHtml():'<span class="tree-spacer"></span>',t&&(p+='<span class="json-key">'+this.escapeHtml(t)+":</span> "),p+='<span class="tree-label json-boolean"><'+n+o+"></span>",d){if(p+='<span class="tree-ellipsis">...</span>',h){p+='<div class="tree-children">';let e=l.filter(e=>this._vn(e));if(p+=this.renderDomChildrenLazy(e,(e,t,i)=>this.renderHTMLTree(e,"",s+"."+t,i),i,"html",{path:s}),c)if(this.expandedTreePaths.has(s+".shadow")){let e=Array.from(r.root.childNodes).filter(e=>this._vn(e));p+=this._treeShadowNode(!0,"data-tree-path",s+".shadow",r.mode,this.renderDomChildrenLazy(e,(e,t,i)=>this.renderHTMLTree(e,"",s+".shadow."+t,i),i,"html-shadow",{shadowInfo:r,path:s}),'data-shadow-root="1"')}else p+=this.buildShadowLazy(r,"html",s,i);p+="</div>"}else{let e=l.filter(e=>this._vn(e)),t=this.treeNodeRegId++;p+=this._treeNodeChildrenLazy(t,{type:"html",children:e,path:s,depth:i,shadow:c?r:null})}p+='<span class="tree-label json-boolean tree-close-tag"></'+n+"></span>"}else p+='<span class="tree-label json-boolean tree-close-tag"></'+n+"></span>";return p+="</div>",p}renderElementsView(){if(!this.elementsTree)return;let e=document.documentElement;this.elRefMap=new Map,this.elRefId=0;let t=this.renderElementTree(e,0);this.elementsTree.innerHTML=t,this.pendingHighlight?this.expandToElement(this.pendingHighlight):this.selectedElement&&this.restoreElementSelection()}restoreElementSelection(){if(!this.selectedElement||!this.elementsTree)return;let e=null;for(let[t,s]of this.elRefMap)if(s===this.selectedElement){e=t;break}if(null===e)return;let t=this.elementsTree.querySelector('.tree-node[data-el-id="'+e+'"]');if(!t)return;let s=t;for(;s&&s!==this.elementsTree;)s.classList.contains("tree-node")&&(s.classList.remove("collapsed"),s.classList.add("expanded"),s.dataset.elId&&this.elRefMap&&this.elRefMap.get(parseInt(s.dataset.elId))&&this.expandedElements.add(this.elRefMap.get(parseInt(s.dataset.elId)))),s=s.parentElement;this.elementsTree.querySelectorAll(".el-selected").forEach(e=>e.classList.remove("el-selected")),t.classList.add("el-selected"),t.classList.add("el-highlight"),requestAnimationFrame(()=>{t.scrollIntoView({behavior:"auto",block:"center"}),setTimeout(()=>t.classList.remove("el-highlight"),3e3)})}renderElementTree(e,t){if(e.nodeType&&3===e.nodeType){let t=e.textContent.trim();return t?'<div class="tree-leaf"><span class="tree-spacer"></span><span class="json-cmt">'+this.escapeHtml(t)+"</span></div>":""}if(1!==e.nodeType)return"";let s=e.tagName.toLowerCase(),i="";i=this.fmtAttrs(e);let n=Array.from(e.childNodes).filter(e=>this._vn(e)),o=this.getShadowRoot(e),l=o&&Array.from(o.root.childNodes).some(e=>this._vn(e)),r=o&&(l||o.mode&&"closed"===o.mode),a=n.length>0||!!r,c=0===t||this.expandedElements.has(e),d=++this.elRefId;this.elRefMap.set(d,e);let h=this._treeNodeOpen(c,"data-el-id",d,'data-depth="'+t+'"');if(h+=a?this.treeToggleHtml():'<span class="tree-spacer"></span>',h+='<span class="tree-label json-boolean"><'+s+i+"></span>",a){if(h+='<span class="tree-ellipsis">...</span>',c){if(h+='<div class="tree-children">',h+=this.renderDomChildrenLazy(n,(e,t,s)=>this.renderElementTree(e,s),t,"element",{}),r)if(this.expandedElements.has(o.root)||0===t){let e=Array.from(o.root.childNodes).filter(e=>this._vn(e)),s=++this.elRefId;this.elRefMap.set(s,o.root),h+=this._treeShadowNode(!0,"data-el-id",s,o.mode,this.renderDomChildrenLazy(e,(e,t,s)=>this.renderElementTree(e,s),t,"element-shadow",{}),'data-shadow-host="'+d+'"')}else h+=this.buildShadowLazy(o,"element",null,t,d);h+="</div>"}else{let e=this.treeNodeRegId++;h+=this._treeNodeChildrenLazy(e,{type:"element",children:n,depth:t,shadow:r?o:null,elId:d})}h+='<span class="tree-label json-boolean tree-close-tag"></'+s+"></span>"}else h+='<span class="tree-label json-boolean tree-close-tag"></'+s+"></span>";return h+="</div>",h}startElementPicker(){this.elementPickBtn&&this.elementPickBtn.classList.add("active"),this.triggerGlobalHook("beforeClose"),this.overlay.classList.remove("active"),this.triggerGlobalHook("afterClose");let e=document.createElement("div");e.className="element-picker-overlay",e.style.pointerEvents="none";let t=!1,s=n=>{if(t)return;t=!0,n.preventDefault(),n.stopPropagation();let o=n.target;e.remove(),document.removeEventListener("click",s,!0),document.removeEventListener("keydown",i,!0),this.pendingHighlight=o,this.switchTab("elements"),this.triggerGlobalHook("beforeOpen"),this.overlay.classList.add("active","theme-"+this.currentTheme),this.triggerGlobalHook("afterOpen"),this.elementPickBtn&&this.elementPickBtn.classList.remove("active")},i=n=>{"Escape"!==n.key||t||(t=!0,e.remove(),document.removeEventListener("click",s,!0),document.removeEventListener("keydown",i,!0),this.triggerGlobalHook("beforeOpen"),this.overlay.classList.add("active","theme-"+this.currentTheme),this.triggerGlobalHook("afterOpen"),this.elementPickBtn&&this.elementPickBtn.classList.remove("active"))};document.body.appendChild(e),setTimeout(()=>{document.addEventListener("click",s,!0),document.addEventListener("keydown",i,!0)},200)}expandToElement(e){if(!e||!this.elementsTree)return;this.pendingHighlight=null,this.selectedElement=e;let t=[],s=e;for(;s&&s!==document.documentElement&&s!==document;)t.unshift(s),s=s.parentNode;for(let e of t){let t=null;for(let[s,i]of this.elRefMap)if(i===e){t=s;break}if(null===t)continue;let s=this.elementsTree.querySelector('.tree-node[data-el-id="'+t+'"]');if(!s||!s.classList.contains("collapsed"))continue;s.classList.remove("collapsed"),s.classList.add("expanded");let i=this.elRefMap.get(parseInt(s.dataset.elId));i&&this.expandedElements.add(i);let n=s.querySelector(":scope > .tree-children[data-lazy-id]");if(n){let e=parseInt(n.dataset.lazyId),t=this.treeNodeRegistry.get(e);if(t){let s="";"element"===t.type?(s=this.renderDomChildrenLazy(t.children,(e,t,s)=>this.renderElementTree(e,s),t.depth||0,"element",{}),t.shadow&&(s+=this.buildShadowLazy(t.shadow,"element",null,t.depth||0,t.elId))):"element-shadow"===t.type&&(s=this.renderDomChildrenLazy(t.children,(e,t,s)=>this.renderElementTree(e,s),t.depth||0,"element-shadow",{})),n.innerHTML=s,delete n.dataset.lazyId,this.treeNodeRegistry.delete(e)}}}let i=null;for(let[t,s]of this.elRefMap)if(s===e){i=t;break}if(null===i)return;let n=this.elementsTree.querySelector('.tree-node[data-el-id="'+i+'"]');n&&(this.elementsTree.querySelectorAll(".el-selected").forEach(e=>e.classList.remove("el-selected")),n.classList.add("el-selected"),n.classList.add("el-highlight"),requestAnimationFrame(()=>{n.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(()=>n.classList.remove("el-highlight"),3e3)}))}serializeNodeWithShadow(e){if(e instanceof ShadowRoot||e instanceof DocumentFragment)return Array.from(e.childNodes).map(e=>this.serializeNodeWithShadow(e)).join("");if(1===e.nodeType){let t=e.tagName.toLowerCase(),s="";for(let t of e.attributes)s+=null!=t.value&&void 0!==t.value?" "+t.name+'="'+this.escapeHtml(t.value)+'"':" "+t.name;let i=this.getShadowRoot(e),n="";return i&&(n+="\x3c!-- #shadow("+i.mode+") --\x3e",n+=Array.from(i.root.childNodes).map(e=>this.serializeNodeWithShadow(e)).join("")),n+=Array.from(e.childNodes).map(e=>this.serializeNodeWithShadow(e)).join(""),["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"].includes(t)?"<"+t+s+">":"<"+t+s+">"+n+"</"+t+">"}return 3===e.nodeType?e.textContent:8===e.nodeType?"\x3c!--"+e.textContent+"--\x3e":""}copyElementHTML(e){let t=this.serializeNodeWithShadow(e);navigator.clipboard?navigator.clipboard.writeText(t).then(()=>this.showNotification("已复制元素")).catch(()=>this.fallbackCopy(t)):this.fallbackCopy(t)}fallbackCopy(e){let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{document.execCommand("copy"),this.showNotification("已复制元素")}catch(t){this.showNotification("复制失败","warning")}t.remove()}deleteElement(e){if(e)if(null!==this.selectedShadowHostId){let e=this.elRefMap.get(this.selectedShadowHostId);if(e){let t=this.getShadowRoot(e);if(t){if("closed"===t.mode)return void this.showNotification("无法删除closed模式的ShadowDOM","warning");try{for(e.shadowRoot&&(e.shadowRoot.innerHTML="");t.root.firstChild;)t.root.removeChild(t.root.lastChild)}catch{}this.selectedElement=null,this.selectedShadowHostId=null,this.showNotification("ShadowDOM已删除"),this.renderElementsView()}else this.showNotification("ShadowDOM已不存在","warning")}else this.showNotification("无法删除此元素","warning")}else e.parentNode?(e.parentNode.removeChild(e),this.showNotification("元素已删除"),this.selectedElement===e&&(this.selectedElement=null),this.renderElementsView()):e.parentElement?(e.parentElement.removeChild(e),this.showNotification("元素已删除"),this.selectedElement===e&&(this.selectedElement=null),this.renderElementsView()):this.showNotification("无法删除此元素","warning")}renderTableHTML(e,t){if(!e||"object"!=typeof e)return`<div class="console-table-wrap"><span class="json-cmt">非表格数据: ${this.escapeHtml(e+"")}</span></div>`;let s,i;s=Array.isArray(e)?e.map((e,t)=>{let s={"(idx)":t};return e&&"object"==typeof e?Object.assign(s,e):s.value=e,s}):Object.entries(e).map(([e,t])=>{let s={"(idx)":e};return t&&"object"==typeof t?Object.assign(s,t):s.value=t,s});let n=new Set;s.forEach(e=>Object.keys(e).forEach(e=>n.add(e))),i=["(idx)",...Array.from(n).filter(e=>"(idx)"!==e)],t&&Array.isArray(t)&&t.length&&(i=["(idx)",...t.filter(e=>"(idx)"!==e)]);let o=e=>{if(void 0===e)return"";if(null===e)return'<span class="json-null">null</span>';if("string"==typeof e)return`<span class="json-string">"${this.escapeHtml(e.substring(0,100))}"</span>`;if("number"==typeof e)return`<span class="json-number">${e}</span>`;if("boolean"==typeof e)return`<span class="json-boolean">${e}</span>`;if("function"==typeof e)return this.isClass(e)?`<span class="json-boolean">[Class ${e.name||"anonymous"}]</span>`:`<span class="json-boolean">ƒ ${e.name||"anonymous"}</span>`;if("object"==typeof e)try{let t=this.safeStringify(e);return`<span class="json-cmt">${this.escapeHtml(t.length>50?t.substring(0,50)+"…":t)}</span>`}catch{return'<span class="json-cmt">{Object}</span>'}return this.escapeHtml(e+"")},l='<div class="console-table-wrap"><table class="console-table"><thead><tr>';return i.forEach(e=>l+=`<th>${this.escapeHtml(e+"")}</th>`),l+="</tr></thead><tbody>",s.forEach(e=>{l+="<tr>",i.forEach(t=>l+=`<td>${o(e[t])}</td>`),l+="</tr>"}),l+="</tbody></table></div>",l}renderLogItemHTML(e,t){if(e.subType){let t="table",s=e.timestamp.toLocaleTimeString(),i=this.renderSubTypeContent(e);return`<div class="log-item ${e.type}${this.selectedLogId===e.id?" selected":""}" tc-idx="${e.id}"><div class="log-header">${e.count>1?`<div class="log-count">${e.count}</div>`:""}<div class="log-icon">${this.icon(t)}</div><div class="timestamp">${s}</div><button class=log-item-copy title=复制>${this.icon("copy")}</button><button class=log-item-eye title=查看详情>${this.icon("eye")}</button></div><div class="log-content">${i}</div></div>`}let s;switch(e.type){case"info":s="info-circle";break;case"warn":s="exclamation-triangle";break;case"error":s="times-circle";break;default:s="info"}let i=e.timestamp.toLocaleTimeString(),n=e.expandedJson?this.formatArgs(e.args,e.id):this.renderLogContent(e);return`<div class="log-item ${e.type}${this.selectedLogId===e.id?" selected":""}" tc-idx="${e.id}"><div class="log-header">${e.count>1?`<div class="log-count">${e.count}</div>`:""}<div class="log-icon">${this.icon(s)}</div><div class="timestamp">${i}</div><button class=log-item-copy title=复制>${this.icon("copy")}</button><button class=log-item-eye title=查看详情>${this.icon("eye")}</button></div><div class="log-content">${n}</div>${e.hasObject?`<div class="log-actions"><div class="log-action expand-btn" title="${e.expandedJson?"收起":"展开"}" onclick="thinConsole.tC.toggleExpandJson(${e.id})">${this.icon(e.expandedJson?"chevron-up":"chevron-down")}${e.expandedJson?"收起":"展开"}</div></div>`:""}</div>`}renderLSItemHTML(e,t){let s=this.escapeHtml(e),{displayValue:i,valueType:n,isJSON:o}=this.parseAndTypeCheck(t),l=o?this.highlightJson(i):this.escapeHtml(i),r="";if(o){let e=JSON.parse(t);r=`<div class="ls-value json-tree-container">${this.renderJSONValue(e,"")}</div>`}else r=`<div class="ls-value" title="${this.escapeHtml(i)}"><span class="json-${n}">${"string"===n?'"':""}${l}${"string"===n?'"':""}</span></div>`;return`<div class="ls-item" data-key="${s}"><div class="ls-key-row"><div class="ls-key" title="${s}">${s}</div><div class="ls-actions"><button class="ls-action-btn" data-action="edit" data-key="${s}" title="编辑">${this.icon("edit")}</button><button class="ls-action-btn" data-action="copy" data-key="${s}" title="复制">${this.icon("copy")}</button><button class="ls-action-btn" data-action="remove" data-key="${s}" title="删除">${this.icon("trash")}</button></div></div>${r}<div class="ls-value-type" title="${n}">类型:${n}</div></div>`}toggleSearch(e){let t=void 0!==e?e:!this.searchExpanded;this.searchExpanded=t,this.searchBar&&(this.searchBar.style.display=t?"flex":"none"),t&&this.searchInput?this.searchInput.focus():t||(this.searchQuery="",this.searchInput&&(this.searchInput.value=""),this.renderContent())}onAddLSClick(){this.netSending=!1,this.netNewVisible=!1,this.editorState={visible:!0,mode:"ls",key:"",oldKey:"",value:""},this.updateEditorVisibility(),this.lsEditorKeyInput&&(this.lsEditorKeyInput.value="",this.lsEditorKeyInput.focus())}openLSEditor(e){if(this.netSending||this.netNewVisible)return void this.showNotification("正在发送请求,无法保存键值","warning");let t=this.activeLSFilter||"local",s=this.storage[t].get(e)||"";this.netSending=!1,this.netNewVisible=!1,this.editorState={visible:!0,mode:"ls",key:e,oldKey:e,value:s},this.updateEditorVisibility(),this.lsEditorInput&&this.lsEditorInput.focus()}closeLSEditor(){this.editorState.visible=!1,this.editorState.value="",this.updateEditorVisibility()}onEditorSave(){"code"===this.editorState.mode?this.runCode():this.saveLSFromEditor()}saveLSFromEditor(){if(this.netSending||this.netNewVisible)return void this.showNotification("正在发送请求,无法保存键值","warning");let e,t=this.lsEditorKeyInput?this.lsEditorKeyInput.value.trim():this.editorState.key,s=this.editorState.oldKey,i=this.lsEditorInput?this.lsEditorInput.value:this.editorState.value;if(!t)return void this.showNotification("键名不能为空","warning");try{e=JSON.stringify(JSON.parse(this.fixKeysOnly(i)))}catch{e=i}let n=this.activeLSFilter||"local",o=this.storage[n];if("cookie"===n)return o.set(t,e),this.closeLSEditor(),this.renderLocalStorage(),void this.showNotification('已保存Cookie"'+t+'"');if(s&&s!==t){if(null!==o.get(t))return void this.showNotification('键名"'+t+'"已存在!',"warning");o.remove(s)}else if(!s&&null!==o.get(t))return void this.showNotification('键名"'+t+'"已存在!',"warning");o.set(t,e),this.closeLSEditor(),this.renderLocalStorage(),this.showNotification('已保存键"'+t+'"')}onTitleClick(){this.netSending||this.netNewVisible?this.showNotification("正在发送请求,无法运行代码","warning"):this.editorState.visible&&"ls"===this.editorState.mode?this.showNotification("正在保存键值,无法运行代码","warning"):(this.editorState.visible=!0,this.editorState.mode="code",this.updateEditorVisibility(),this.lsEditorInput&&this.lsEditorInput.focus())}runCode(){let e=this.lsEditorInput?this.lsEditorInput.value:"";if(e.trim())try{let t=window.eval(e);console.log(e+"\n> ",t),this.showNotification("代码已执行"),this.closeLSEditor()}catch(t){console.error(e+"\n> 执行失败:"+t),this.showNotification("代码执行失败","warning"),this.closeLSEditor()}}setupGestures(){if(!this.contentArea||!this.consoleHeader)return;let e=this.contentArea,t=this.consoleHeader,s=null,i=0,n=0,o=0,l=0,r=!1,a=null,c=0,d=0,h=0,p=!1,u=()=>{let e=this.overlay.querySelectorAll(".tab-btn");return Array.from(e).map(e=>e.dataset.tab)},f=()=>{if("console"===this.currentTab)return["all","log","info","warn","error"];if("network"===this.currentTab)return["all","get","post","put","success","failed"];if("localstorage"===this.currentTab)return["local","session","cookie"];let e=this.pluginViewContainers[this.currentTab];return e&&e.querySelectorAll(".filter-btn").length>1?Array.from(e.querySelectorAll(".filter-btn")).map(e=>e.dataset.type||e.dataset.filter||e.textContent.trim()):null},g=e=>{let t=u(),s=t.indexOf(this.currentTab),i=f();if(i)if("localstorage"===this.currentTab){let t=i.indexOf(this.activeLSFilter||"local")+e;if(t>=0&&t<i.length){this.activeLSFilter=i[t],this.lsFiltersContainer&&this.lsFiltersContainer.querySelectorAll(".filter-btn").forEach(e=>e.classList.toggle("active",e.dataset.lsType===this.activeLSFilter)),this.renderContent();let e=this.lsFiltersContainer&&this.lsFiltersContainer.querySelector('.filter-btn[data-ls-type="'+this.activeLSFilter+'"]');return void this.scrollFilterIntoView(this.lsFiltersContainer,e)}}else if("console"===this.currentTab){let t=i.indexOf(this.activeFilter||"all")+e;if(t>=0&&t<i.length)return this.activeFilter=i[t],this.filterButtons.forEach(e=>e.classList.toggle("active",e.dataset.type===this.activeFilter)),this.updateFilterCounts(),this.renderContent(),void this.scrollFilterIntoView(this.filtersContainerEl,this.filterButtons[t])}else{if("network"!==this.currentTab){let t=this.pluginViewContainers[this.currentTab];if(t){this.enhanceFilterContainers(t);let s=t.querySelectorAll(".filter-btn");if(s.length>1){let t=-1;s.forEach((e,s)=>{e.classList.contains("active")&&(t=s)});let i=t+e;i>=0&&i<s.length&&(s.forEach(e=>e.classList.remove("active")),s[i].classList.add("active"),s[i].click(),this.scrollFilterIntoView(s[i].parentElement,s[i]))}}return}{let t=i.indexOf(this.activeNetFilter||"all")+e;if(t>=0&&t<i.length){this.activeNetFilter=i[t],this.netFiltersEl&&this.netFiltersEl.querySelectorAll(".net-filter-btn").forEach(e=>e.classList.toggle("active",e.dataset.netFilter===this.activeNetFilter)),this.renderNetworkList(),this.updateNetDisableBtn(),this.updateNetFilterCounts();let e=this.netFiltersEl&&this.netFiltersEl.querySelector('.net-filter-btn[data-net-filter="'+this.activeNetFilter+'"]');return void this.scrollFilterIntoView(this.netFiltersEl,e)}}}let n=s+e;if(n>=0&&n<t.length){let e=t[n];"console"===e?(this.activeFilter="all",this.filterButtons&&this.filterButtons.forEach(e=>e.classList.toggle("active","all"===e.dataset.type))):"localstorage"===e&&(this.activeLSFilter="local",this.lsFiltersContainer&&this.lsFiltersContainer.querySelectorAll(".filter-btn").forEach(e=>e.classList.toggle("active","local"===e.dataset.lsType)));let s=this.overlay.querySelector(`.tab-btn[data-tab="${e}"]`);s&&s.click()}};e.addEventListener("touchstart",e=>{if(1!==e.touches.length)return;if(this.editorState.visible)return;let t=e.target.closest(".json-tree-container,.json-preview,.log-content,.console-table-wrap,.system-log-content,.ls-value,.object-preview,.error-stack,.function-preview,.elements-tree,.filters,.network-filters");t&&(t.matches(".filters,.network-filters")||t.scrollWidth>t.clientWidth)?s=null:(s=e.touches[0],i=s.clientX,n=s.clientY,o=0,l=0,r=!1)},{passive:!0}),e.addEventListener("touchmove",e=>{if(!s||1!==e.touches.length)return;let t=e.touches[0];o=t.clientX-i,l=t.clientY-n,!r&&Math.abs(o)>15&&Math.abs(o)>1.5*Math.abs(l)&&(r=!0),r&&e.preventDefault()},{passive:!1}),e.addEventListener("touchend",()=>{if(s){if(r){let e=60;o<-e?g(1):o>e&&g(-1)}s=null,r=!1}}),t.addEventListener("touchstart",e=>{window.innerWidth>768||1===e.touches.length&&(a=e.touches[0],c=a.clientX,d=a.clientY,h=0,p=!1)},{passive:!0}),t.addEventListener("touchmove",e=>{if(window.innerWidth>768)return;if(!a||1!==e.touches.length)return;let t=e.touches[0];if(h=t.clientY-d,!p&&h>15&&h>1.5*Math.abs(t.clientX-c)&&(p=!0),p){e.preventDefault();let t=this.overlay.querySelector(".console-container");t&&(t.style.transition="none",t.style.transform=`translateY(${h}px)`)}},{passive:!1}),t.addEventListener("touchend",()=>{if(!(window.innerWidth>768)&&a){if(p){let e=this.overlay.querySelector(".console-container");h>80?(e&&(e.style.transition="transform .3s ease",e.style.transform="translateY(100%)"),setTimeout(()=>{this.triggerGlobalHook("beforeClose"),this.overlay.classList.remove("active"),e&&(e.style.transition="",e.style.transform=""),this.triggerGlobalHook("afterClose")},300)):e&&(e.style.transition="transform .25s ease",e.style.transform="")}a=null,p=!1}})}updateFilterShadow(e){if(!e)return;let t=e.scrollWidth-e.clientWidth>1;e.classList.toggle("overflow-start",t&&e.scrollLeft>1),e.classList.toggle("overflow-end",t&&e.scrollLeft+e.clientWidth<e.scrollWidth-1)}setupFilterShadow(e){if(!e||e._tcFilterShadow)return;e._tcFilterShadow=!0,e.classList.add("overflow-scroll");let t=()=>this.updateFilterShadow(e);if(e.addEventListener("scroll",t,{passive:!0}),window.ResizeObserver){let s=new ResizeObserver(t);s.observe(e),e._tcFilterRO=s,e.setAttribute("data-filter-ro","1")}if(window.MutationObserver){let s=new MutationObserver(t);s.observe(e,{childList:!0,subtree:!0}),e._tcFilterMO=s}t()}scrollFilterIntoView(e,t){if(!e||!t)return;if(e.scrollWidth<=e.clientWidth)return void this.updateFilterShadow(e);let s=t.offsetLeft-(e.clientWidth-t.offsetWidth)/2;s=Math.max(0,Math.min(s,e.scrollWidth-e.clientWidth));try{e.scrollTo({left:s,behavior:"smooth"})}catch(e){}e.scrollLeft!==s&&(e.scrollLeft=s),this.updateFilterShadow(e),setTimeout(()=>this.updateFilterShadow(e),300)}enhanceFilterContainers(e){if(!e)return;let t=new Map;e.querySelectorAll(".filter-btn").forEach(e=>{let s=e.parentElement;s&&!s.dataset.tcFilterEnhanced&&(t.has(s)||t.set(s,[]),t.get(s).push(e))}),t.forEach((e,t)=>{if(e.length>1){t.classList.contains("filters")||t.classList.contains("network-filters")||t.classList.add("filters"),t.dataset.tcFilterEnhanced="1",this.setupFilterShadow(t);let s=t;e.forEach(e=>{e.dataset.orig||(e.dataset.orig=e.textContent.trim()),e.addEventListener("click",()=>this.scrollFilterIntoView(s,e))})}})}_fmtCount(e,t){if(e<1e3)return{filterCount:e,exactCount:e};let s=e/1e3;if(e>=1e5)return{filterCount:Math.floor(s)+"K+",exactCount:e};let i=Math.round(10*s)/10;return{filterCount:(Number.isInteger(i)?i:i.toFixed(1))+"K"+(t?"+":""),exactCount:e}}_updateFilterBtns(e,t,s,i){e&&e.querySelectorAll(".filter-btn, .net-filter-btn").forEach(e=>{let n=e.dataset[s],o=t[n]||0,l=e.classList.contains("active");e.innerHTML=i(e,o,l)})}updateFilterCounts(){this.filterButtons&&(this._updateFilterRaf||(this._updateFilterRaf=requestAnimationFrame(()=>{this._updateFilterRaf=null;let e=[];"console"===this.currentTab&&(e=this.logs);let t=(e,t)=>e.reduce((e,s)=>s.type===t?e+(s.count||1):e,0),s={all:e.reduce((e,t)=>e+(t.count||1),0),log:t(e,"log"),info:t(e,"info"),warn:t(e,"warn"),error:t(e,"error")};this._updateFilterCounts(this.filterButtons,s,!1)})))}_updateFilterCounts(e,t,s){e&&(s?e.querySelectorAll(".filter-btn[data-orig]"):e).forEach(e=>{let i,n=s?e.dataset.orig:e.dataset.type,o=t[e.dataset.type||e.dataset.filter||n]||0,l=e.classList.contains("active");i="object"==typeof o&&null!==o?o:this._fmtCount(o,!1),s?e.innerHTML=(e.dataset.icon?this.icon(e.dataset.icon)+" ":"")+n+(l?" ("+i.filterCount+")":""):(e.dataset.originalHtml||(e.dataset.originalHtml=e.innerHTML),e.innerHTML=l?`${e.dataset.originalHtml} (${i.filterCount})`:e.dataset.originalHtml),e.title=l&&void 0!==i.exactCount?""+i.exactCount:""})}renderContent(){if(this.triggerGlobalHook("beforeRender",this.currentTab),this.updateControlsVisibility(),this.consoleOutput.style.display="none",this.localstorageView.style.display="none",this.elementsView.style.display="none",this.networkView&&(this.networkView.style.display="none"),this.netDetailOverlay&&(this.netDetailOverlay.style.display="none"),this._ov.style.display="none",this.netNewOverlay&&(this.netNewOverlay.style.display=this.netNewVisible?"flex":"none",this._ssv()),this.clearLogsBtn.style.display="none",this._elementObserver&&this.stopElementObserver&&this.stopElementObserver(),Object.values(this.pluginViewContainers).forEach(e=>{e.style.display="none"}),["console","network","localstorage","elements"].includes(this.currentTab))switch(this.clearLogsBtn.style.display="block",this.currentTab){case"console":this.consoleOutput.style.display="block",this.renderLogList(this.logs,!1),this.updateFilterCounts();break;case"network":this.clearLogsBtn.style.display="block",this.networkView&&(this.networkView.style.display="flex"),this.renderNetworkPanel();break;case"localstorage":this.localstorageView.style.display="block",this.renderLocalStorage();break;case"elements":this.clearLogsBtn.style.display="none",this.elementsView.style.display="block",this.renderElementsView(),this.startElementObserver()}else if(this.pluginViewContainers[this.currentTab]){this.consoleControls.style.display="none";let e=this.pluginViewContainers[this.currentTab];e.style.display="block";let t=Object.keys(this.pluginTabs).find(e=>this.pluginTabs[e].id===this.currentTab);if(t){let s=this.plugins[t];s&&"function"==typeof s.onShow&&s.onShow(),s&&"function"==typeof s.render&&s.render(e),this.enhanceFilterContainers(e)}else{let e=this.pluginTabs[this.currentTab];e&&"function"==typeof e.onShow&&e.onShow()}}this.triggerGlobalHook("afterRender",this.currentTab)}renderLogList(e,t){let s=this.consoleOutput,i="日志记录";if(!s)return;if(0===e.length)return void this.vsUpdate(s,[],null,0,{emptyHTML:`<div class="nolog">${this.icon("info-circle")}无${i}</div>`});let n=[...e];if(this.activeFilter&&"all"!==this.activeFilter&&(n=n.filter(e=>e.type===this.activeFilter)),this.searchQuery){let e,t=this.searchQuery.trim(),s=!1;if("#"===t[0]&&t.length>1)t=t.slice(1);else if(t.startsWith("/"))try{let i=t.indexOf("/",1),n=i>0?t.slice(1,i):t.slice(1);if(n){let o=i>0?t.slice(i+1):"";e=RegExp(n,o),s=!0}}catch{s=!1}let i=s?t:t.toLowerCase();n=n.filter(t=>t.args.some(t=>{let n;return n=t instanceof Error?"[error]":null==t?"null":void 0===t?"undefined":"object"==typeof t?'<span class="json-cmt">{Object}</span>':t+"",s&&e?e.test(n):n.toLowerCase().includes(i.toLowerCase())}))}0!==n.length?this.vsUpdate(s,n,e=>this.renderLogItemHTML(e,t),80):this.vsUpdate(s,[],null,0,{emptyHTML:`<div class="nolog">${this.icon("search")}无匹配的${i}</div>`})}getParams(e){let t=e.toString(),s=e=>{let t=e.indexOf("(");if(-1===t)return"";let s=1,i=t+1;for(;i<e.length;i++)if("("===e[i])s++;else if(")"===e[i]&&0===--s)break;return e.slice(t+1,i).replace(/\s+/g,"")};if(/^\s*(?:class|function|async\s+function)/.test(t))return s(t);let i=t.indexOf("=>"),n=t.indexOf("{");if(i>0&&(-1===n||i<n)){let e=t.slice(0,i).trim().replace(/^async\s+/,"");if(e.startsWith("(")){let t=1,s=1;for(;s<e.length&&t>0;s++)"("===e[s]?t++:")"===e[s]&&t--;return e.slice(1,s-1).replace(/\s+/g,"")}return e.replace(/\s+/g,"")}return t.indexOf("(")>0?s(t):""}renderLogContent(e){let t=[...e.args],s=e.id;if(!t.length)return"";let i=[],n=[],o=0,l=(e=>null===e?'<span class="json-null">null</span>':void 0===e?'<span class="json-null">undefined</span>':e instanceof HTMLElement?'<div class="json-tree-container">'+this.renderHTMLTree(e,"",s+":html")+"</div>":e instanceof Date?e.toISOString():e instanceof Error?`<strong>${e.name}:</strong>${e.message}`:e instanceof RegExp?`<span class="json-number">${e.toString()}</span>`:"function"==typeof e?this.isClass(e)?`<span class='json-boolean'>[Class ${e.name||"anonymous"}]</span>`:this.renderFunctionCollapsed(e):e instanceof Map?`<span class="json-boolean">[Map ${e.size}]</span>`:e instanceof Set?`<span class="json-boolean">[Set ${e.size}]</span>`:e instanceof WeakMap?'<span class="json-boolean">[WeakMap]</span>':e instanceof WeakSet?'<span class="json-boolean">[WeakSet]</span>':e instanceof ArrayBuffer?`<span class="json-boolean">[ArrayBuffer ${e.byteLength} bytes]</span>`:this.fmtVal(e,s,0))(t.length>0?t[0]:"").replace(/%%/g,"").replace(/%([dfsioO%])/g,(e,s)=>{if("%"===s)return"%";if("o"===s||"O"===s)return"";let n=t[++o];if(null==n)return e;let l="d"===s||"i"===s?parseInt(n,10)||0:"f"===s?parseFloat(n)||0:n+"";return i.push(l),`{{v${i.length-1}}}`}).replace(/%c/g,()=>(n.push((t[++o]||"")+""),`{{c${n.length-1}}}`)).replace(/\x01/g,"%");i.forEach((e,t)=>l=l.replace(`{{v${t}}}`,e));let r=l.split(/{{c\d+}}/);l=r.map((e,t)=>{if(!t)return e;let s=n[t-1].replace(/"/g,"").split(/\s*;\s*/).filter(e=>e.trim()&&!/\b(position|fixed|absolute|sticky|relative|static|z-index|transform|top|left|right|bottom)\s*:/i.test(e)).join("; ");return s?`<span style="${s}">${e}</span>`:e}).join("");let a=t.slice(o+1);return l+=(l?" ":"")+a.map(e=>null===e?'<span class="json-null">null</span>':void 0===e?'<span class="json-null">undefined</span>':"function"==typeof e?this.isClass(e)?`<span class='json-boolean'>[Class ${e.name||"anonymous"}]</span>`:this.renderFunctionCollapsed(e):e instanceof Error?`<strong>${e.name}:</strong>${e.message}`:e instanceof HTMLElement?'<div class="json-tree-container">'+this.renderHTMLTree(e,"",s+":r:html")+"</div>":e instanceof Date?`<span class="json-string">${e.toISOString()}</span>`:e instanceof RegExp?`<span class="json-number">${e.toString()}</span>`:e instanceof Map?`<span class="json-boolean">[Map ${e.size}]</span>`:e instanceof Set?`<span class="json-boolean">[Set ${e.size}]</span>`:e instanceof WeakMap?'<span class="json-boolean">[WeakMap]</span>':e instanceof WeakSet?'<span class="json-boolean">[WeakSet]</span>':e instanceof ArrayBuffer?`<span class="json-boolean">[ArrayBuffer ${e.byteLength} bytes]</span>`:this.fmtVal(e,s,1)).join("")}o(e,t,s,i){e.addEventListener(t,s,i)}r(e,t,s,i){e.removeEventListener(t,s,i)}_vn(e){return 1===e.nodeType||3===e.nodeType&&e.textContent.trim()||this.options.showComments&&8===e.nodeType}clr(e){return e.replace(/\\u000[23]|[\u0002\u0003]/g,"")}showLogDetail(e){let t=this.logs.find(t=>t.id===e);if(!t)return;this._id=e;let s="error"===t.type?"times-circle":"warn"===t.type?"exclamation-triangle":"info"===t.type?"info-circle":"info";this._bd.innerHTML="<div class=ld-meta>"+this.icon(s)+"<span class=ld-time>"+t.timestamp.toLocaleString()+"</span></div>"+this.renderDetailArgs(t),this._sb.style.display="none",this._si.value="",this._sc.textContent="",this.searchToggleBtn.style.display="none",this._ov.style.display="flex"}hideLogDetail(){this._ov.style.display="none",this._id=null,this.searchToggleBtn.style.display="flex"}toggleLDS(){let e="none"===this._sb.style.display;this._sb.style.display=e?"flex":"none",e?(this._si.focus(),this.runLDS(this._si.value)):this.runLDS("")}renderDetailArgs(e){let t=e.id,s=this.escapeHtml;return e.args.map((e,i)=>"<div class=ld-sec>"+(null==e?"<span class=json-null>"+e+"</span>":e instanceof Error?"<strong>"+s(e.name)+":</strong>"+s(e.message):e instanceof Date?s(e.toISOString()):e instanceof HTMLElement?this.wrapViewer(this.renderHTMLTree(e,"",t+":h"+i),i):"function"==typeof e?this.renderDetailFn(e,t,i):"object"!=typeof e||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof WeakMap||e instanceof WeakSet||e instanceof ArrayBuffer?this.fmtVal(e,t,i):this.wrapViewer(this.renderJSONTree(e,"",0,0,t+":o"+i,0),i))+"</div>").join("")}wrapViewer(e,t){return"<div class=ld-viewer><button class=ld-copy data-i="+t+" title=复制>"+this.icon("copy")+"</button><div class=ld-viewer-body>"+e+"</div></div>"}renderDetailFn(e,t,s){let i=this.isClass(e),n=e.name||"anonymous";return"<div class=ld-fn><button class=ld-copy-fn data-i="+s+" title=复制>"+this.icon("copy")+"</button><pre class=ld-fn-body style=display:none>"+this.escapeHtml(e+"")+"</pre><span class=json-boolean>"+(i?"[Class "+n+"]":"ƒ "+n+"("+this.getParams(e)+")")+'</span><div class="log-action expand-btn ld-fn-toggle" data-i="'+s+'">'+this.icon("chevron-down")+"展开</div></div>"}ban(e="all",t=!0){this._ban||(this._ban={all:!1,set:new Set}),"all"===e?this._ban.all=t:t?this._ban.set.add(e):this._ban.set.delete(e);let s=this.filtersContainerEl;return s&&(s.style.display=this._ban.all?"none":"console"===this.currentTab?"flex":"none"),this.filterButtons&&this.filterButtons.forEach(e=>{let t=e.dataset.type||e.dataset.orig;e.style.display=this._ban.all||this._ban.set.has(t)?"none":""}),this}_ssv(){let e=this.editorState&&this.editorState.visible||this.netNewVisible||this.netDetailOverlay&&"flex"===this.netDetailOverlay.style.display,t="elements"===this.currentTab;this.searchToggleBtn&&(this.searchToggleBtn.style.display=e||t?"none":"flex"),this.searchBar&&(this.searchBar.style.display=e||t?"none":this.searchExpanded?"flex":"none")}_onResize=()=>{if(window.innerWidth<=768&&this.consoleContainer&&(this.consoleContainer.style.flex||this.consoleContainer.style.width)){let e=Math.min(400,window.innerWidth);this.consoleContainer.style.width=e+"px",this.consoleContainer.style.flex="none"}};injectScrollBtn(e){if(!e||e._tcSB)return;e._tcSB=1,"static"===getComputedStyle(e).position&&(e.style.position="relative");let t=document.createElement("button");t.className="tc-scroll-bottom",t.title="返回",t.innerHTML=this.icon("chevron-down"),this.o(t,"click",()=>{let t=1,s=()=>{t&&(e.scrollTop=e.scrollHeight,requestAnimationFrame(s))};s(),setTimeout(()=>t=0,1e3),this.o(e,"wheel",()=>t=0,{once:1,passive:1})}),e.appendChild(t);let s=()=>{let s=e.scrollHeight-e.clientHeight-e.scrollTop;t.classList.toggle("show",s>24)};e.addEventListener("scroll",s,{passive:!0}),s()}runLDS(e,t=this._bd,s=this._sc){let i=t;if(e=(e||"").trim(),this.ldIdx=0,i.querySelectorAll("mark").forEach(e=>e.replaceWith(document.createTextNode(e.textContent))),i.normalize(),!e)return s.textContent="";let n=0;"#"===e[0]&&e.length>1&&(n=1,e=e.slice(1));let o=null;if(!n&&"/"===e[0]){let t=e.lastIndexOf("/");if(t>1){let s=e.slice(1,t),i=e.slice(t+1);if(s)try{o=RegExp(s,-1<i.indexOf("g")?i:i+"g")}catch(e){}}}let l,r=[],a=document.createTreeWalker(i,4,{acceptNode(e){let t=e.parentElement;return t&&(t.closest(".ld-meta")||t.closest(".net-detail-section")&&!t.closest(".nd-s"))?2:1}});for(;l=a.nextNode();){let t=l.nodeValue,s=0;if(o){o.lastIndex=0;for(let e;e=o.exec(t);)r.push([l,e.index,e[0].length]),e.index===o.lastIndex&&o.lastIndex++}else{let i=e.toLowerCase();for(;(s=t.toLowerCase().indexOf(i,s))>=0;)r.push([l,s,i.length]),s+=i.length}}if(!r.length)return s.textContent="无匹配";for(let e=r.length-1;e>=0;e--){let t=r[e],s=t[0],i=t[1],n=t[2];if(i+n>s.nodeValue.length)continue;let o=s.splitText(i);o.splitText(n),o.parentNode.insertBefore(document.createElement("mark"),o).appendChild(o)}this.stepLDS(0,i.querySelectorAll("mark"),s)}expdTree(e){e.classList.remove("collapsed"),e.classList.add("expanded");let t=e.dataset.treePath;t&&this.expandedTreePaths.add(t);let s=e.querySelector(".tree-children");if(s&&s.dataset.lazyId){let e=this.treeNodeRegistry.get(+s.dataset.lazyId);if(e){let t="";if("html"===e.type)t=this.renderDomChildrenLazy(e.children,(t,s,i)=>this.renderHTMLTree(t,"",e.path+"."+s,i),e.depth||0,"html",{path:e.path});else if("html-shadow"===e.type)t=this.renderDomChildrenLazy(e.children,(t,s,i)=>this.renderHTMLTree(t,"",e.path+".shadow."+s,i),e.depth||0,"html-shadow",{});else{let s=new WeakSet;e.chain.forEach(e=>s.add(e)),s.add(e.obj);let i=e.children;t=this.renderTreeChildrenBatch(i,s,0,i.length,e.chain.concat([e.obj]),e.path||"",1,e.noProto)}s.innerHTML=t,delete s.dataset.lazyId,this.treeNodeRegistry.delete(+s.dataset.lazyId)}}}stepLDS(e,t=this._bd.querySelectorAll("mark"),s=this._sc){if(!t.length)return;let i=this.ldIdx;t[i]?.classList.remove("on"),i=e>0?(i+1)%t.length:e<0?(i-1+t.length)%t.length:0,this.ldIdx=i;let n=t[i];if(n.classList.add("on"),e){let e=n.closest(".ld-fn");if(e){let t=e.querySelector(".ld-fn-body");if(t&&"none"===t.style.display){t.style.display="block";let s=e.querySelector(".ld-fn-toggle");s&&(s.innerHTML=this.icon("chevron-up")+"收起");let i=e.querySelector("span.json-boolean");i&&(i.style.display="none");let n=e.querySelector(".ld-copy-fn");n&&(n.style.display="flex")}}else{let e=n.closest(".tree-node");e&&e.classList.contains("collapsed")&&this.expdTree(e)}}n.scrollIntoView(),s.textContent=i+1+"/"+t.length+" 处"}toggleNDS(){let e="none"===this._nsb.style.display;this._nsb.style.display=e?"flex":"none",e?(this._nsi.focus(),this._nsi.value.trim()&&this.expdAllNDS(),this.runLDS(this._nsi.value,this.netDetailBody,this._nsc)):this.runLDS("",this.netDetailBody,this._nsc)}expdAllNDS(){let e=this.netDetailBody;for(let t,s=0;(t=e.querySelector(".nd-s .tree-node.collapsed"))&&s++<300;)this.expdTree(t)}copyLog(e,t=!1,s=!1){if(s){let t=this.activeLSFilter||"local",s=this.storage[t].get(e);if(s)return navigator.clipboard.writeText(s).then(()=>this.showNotification(`已复制"${e}"的值`)).catch(e=>console.error("复制失败:",e))}let i=this.logs.find(t=>t.id===e);if(!i)return;let n="";i.count>1&&(n+=`[重复${i.count}次] `),i.args.forEach((e,t)=>{t>0&&(n+=" ");try{e instanceof HTMLElement?n+=e.outerHTML.replace(/>/g,">\n"):n+=null!==e&&"object"==typeof e?this.clr(this.safeStringify(e)):"function"==typeof e?this.isClass(e)?`[Class ${e.name||"anonymous"}]`:`ƒ ${e.name||"anonymous"}(${this.getParams(e)})`:null===e?"null":void 0===e?"undefined":e+""}catch{n+="{object}"}}),navigator.clipboard.writeText(n).then(()=>this.showNotification("已复制到剪贴板")).catch(e=>console.error("复制失败:",e))}clearAllLogs(e=!1){if(this.triggerGlobalHook("beforeClear"),"network"!==this.currentTab){if(e)return this.logs=[],this.lastLog=null,this.renderContent(),void this.updateFilterCounts();if("localstorage"==this.currentTab){let e=this.activeLSFilter||"local";return void(confirm("确定要清除所有"+("local"===e?"本地存储":"session"===e?"会话存储":"Cookie")+"吗?此操作不可撤销。")&&(this.storage[e].clear(),this.renderLocalStorage()))}confirm("确定要清除所有日志吗?此操作不可撤销。")&&(this.logs=[],this.lastLog=null,this.renderContent(),this.updateFilterCounts(),this.showNotification("所有日志已清除","warning"),this.triggerGlobalHook("afterClear"))}else this.clearNetworkRequests()}updateLSFilterCounts(){if(!this.lsFiltersContainer)return;let e={local:this.storage.local.length(),session:this.storage.session.length(),cookie:this.storage.cookie.length()};this._updateFilterBtns(this.lsFiltersContainer,e,"lsType",(e,t,s)=>{let i=e.dataset.orig,n=e.dataset.icon||"",o=this._fmtCount(t,!0);return e.title=s?""+o.exactCount:"",this.icon(n)+i+(s?" ("+o.filterCount+")":"")})}renderLocalStorage(){this.updateLSFilterCounts();let e=this.activeLSFilter||"local",t=[],s="local"===e?"无本地存储":"session"===e?"无会话存储":"无Cookies",i=this.storage[e],n="local"===e?"database":"session"===e?"window-restore":"cookie-bite";if(i.length()){for(let e=0;e<i.length();e++){let s=i.key(e);null!==s&&t.push({key:s,value:i.get(s)||""})}if(t.sort((e,t)=>e.key.localeCompare(t.key,void 0,{numeric:!0,sensitivity:"base"})),this.searchQuery){let e=this.searchQuery;"#"===e[0]&&e.length>1&&(e=e.slice(1));let s=e.toLowerCase(),i=null;if("/"===e[0]){let t=e.lastIndexOf("/");if(t>1){let s=e.slice(1,t);if(s)try{i=RegExp(s,e.slice(t+1))}catch(e){}}}t=t.filter(e=>{let t=e.key,n=e.value||"";return i?i.test(t)||i.test(n):t.toLowerCase().includes(s)||n.toLowerCase().includes(s)})}this.vsUpdate(this.lsItems,t,e=>this.renderLSItemHTML(e.key,e.value),130,{force:!0,emptyHTML:'<div class="nolog">'+this.icon("search")+"无匹配的本地存储数据</div>"})}else this.vsUpdate(this.lsItems,[],null,0,{emptyHTML:'<div class="nolog">'+this.icon(n)+s+"</div>"})}addLSItemToDOM(e,t){this.renderLocalStorage()}parseAndTypeCheck(e){try{let t=JSON.parse(e);return"object"==typeof t&&null!==t?{displayValue:this.safeStringify(t,2).replace(/</g,"<").replace(/>/g,">"),valueType:Array.isArray(t)?"array":"object",isJSON:!0}:null==t?{displayValue:null,valueType:null,isJSON:!1}:{displayValue:e,valueType:typeof t,isJSON:!1}}catch{return{displayValue:e,valueType:"string",isJSON:!1}}}isLSEmpty(){let e=this.activeLSFilter||"local";return 0===this.storage[e].length()}escapeHtml(e){return(e+"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}editLSItem(e){this.openLSEditor(e)}fixKeysOnly(e){try{return JSON.parse(e),e}catch{return e.replace(/([{,])\s*([a-zA-Z_]\w*)\s*:/g,'$1"$2":').replace(/(":)\s*(?!true|false|null|\d+(\.\d+)?)([^\s,"{[}\]]+?)\s*(?=,|})/gs,'$1"$3"')}}removeLSItem(e){let t=this.activeLSFilter||"local";confirm("是否删除"+("local"===t?"本地存储":"session"===t?"会话存储":"Cookie")+'键名 "'+e+'"?')&&(this.storage[t].remove(e),this.renderLocalStorage(),this.showNotification('已删除"'+e+'"'))}findLSItem(e){return this.overlay.querySelector(`.ls-item[data-key="${e}"]`)}updateLSItemView(e){let t=this.findLSItem(e);if(!t)return;let s=this.activeLSFilter||"local",i=this.storage[s].get(e);if(null===i)return void t.remove();let{displayValue:n,valueType:o,isJSON:l}=this.parseAndTypeCheck(i),r=l?this.highlightJson(n):this.escapeHtml(n),a="";if(l){let e=JSON.parse(i);a=`<div class="ls-value json-tree-container">${this.renderJSONValue(e,"")}</div>`}else a=`<div class="ls-value" title="${this.escapeHtml(n)}"><span class="json-${o}">${"string"===o?'"':""}${r}${"string"===o?'"':""}</span></div>`;let c=this.escapeHtml(e);t.innerHTML=`<div class="ls-key-row"><div class="ls-key" title="${c}">${c}</div><div class="ls-actions"><button class="ls-action-btn" data-action="edit" data-key="${c}" title="编辑">${this.icon("edit")}</button><button class="ls-action-btn" data-action="copy" data-key="${c}" title="复制">${this.icon("copy")}</button><button class="ls-action-btn" data-action="remove" data-key="${c}" title="删除">${this.icon("trash")}</button></div></div>${a}<div class="ls-value-type" title="${o}">类型:${o}</div>`}setupGlobalEventHandlers(){this.activeFilter="all",this.searchQuery="",this.tCError=e=>{""!==e.filename||0!==e.lineno||0!==e.colno?(console.error(e.error.toString(),{"错误信息":e.message||"无信息","文件名":e.filename||"未知","位置":`${e.lineno}:${e.colno}`||"0:0","是否可信":e.isTrusted||!0,"类型":e.type||"error"}),e.preventDefault()):console.error("脚本错误")},this.tCUR=e=>{console.error("未处理的Promise异常",e.reason),e.preventDefault()},this.RSError=e=>{let t=new Set(["IMG","SCRIPT","LINK","VIDEO","AUDIO","SOURCE","TRACK"]),s=e.target;if(!t.has(s.tagName))return;let i=s.src||s.href||s.currentSrc||"[未知路径]";console.error(`[资源错误] <${s.tagName.toLowerCase()}>加载失败:${i}`)},this.o(document,"error",this.RSError,!0),this.o(window,"error",this.tCError),this.o(window,"unhandledrejection",this.tCUR),this.o(window,"resize",this._onResize=()=>{if(window.innerWidth<=768&&this.consoleContainer&&(this.consoleContainer.style.width="",this.consoleContainer.style.flex="",this.consoleContainer.style.transform="",this.consoleContainer.style.transition=""),window.innerWidth>768&&!window.matchMedia("(pointer:fine)").matches&&"network"===this.currentTab){let e=this.overlay.querySelector('.tab-btn[data-tab="console"]');e&&e.click()}})}setupSelfProtection(){if(this.protectInterval)return;let e=this;this.protectInterval=setInterval(()=>{window.thinConsole&&window.thinConsole.tC!==e&&(window.thinConsole.tC=e),(!this.host||!document.documentElement.contains(this.host)||!this.host.shadowRoot)&&(this.host=null,this.initShadow(),e.createButton(),e.createOverlayElement(),e.tabButtons=e.overlay.querySelectorAll(".tab-btn"),e.renderContent(),e.createStyles(),e.createNotificationElement());let t=this.shadowRoot.getElementById("thinConsole-btn");t&&t.isConnected?"flex"!==t.style.display&&(t.style.display="flex"):(e.btn=null,e.createButton());let s=this.shadowRoot.getElementById("consoleOverlay");s&&s.isConnected?"flex"!==s.style.display&&(s.style.display="flex"):(e.overlay=null,e.createOverlayElement(),e.createStyles());let i=this.shadowRoot.querySelector("style[tcstyle]");(!i||!i.innerHTML||i.innerHTML.length<100)&&e.createStyles();let n=this.shadowRoot.getElementById("notification");n&&n.isConnected||(e.notification=null,e.createNotificationElement());let o=e=>{if(!e||1!==e.nodeType)return;let t=e=>{"false"!==e.contentEditable&&(e.contentEditable="false",e.setAttribute("tc-lock",""),l.observe(e,{attributes:!0,attributeFilter:["contenteditable"]}))};t(e),e.querySelectorAll("*").forEach(t)},l=new MutationObserver(e=>{e.forEach(e=>{"attributes"===e.type&&"contentEditable"===e.attributeName&&"true"===e.target.contentEditable&&e.target.hasAttribute("tc-lock")&&(e.target.contentEditable="false")})});setTimeout(()=>{o(e.btn),o(e.overlay),o(e.notification),o(e.host)},0)},5e3)}disablePlugin(e){return this.disabledPlugins.includes(e)||this.disabledPlugins.push(e),this.destroyPlugin(e),this}enablePlugin(e){return this.disabledPlugins=this.disabledPlugins.filter(t=>t!==e),this.loadSinglePlugin(e),this}applyIcon(t){if("object"!=typeof t||null===t||Array.isArray(t))throw Error("applyIcon: object required");for(let s in t)if(t.hasOwnProperty(s)){if("string"!=typeof t[s]||-1===t[s].indexOf("|"))throw Error("图标"+s+"格式错误,必须是viewBox|path.d格式");e[s]=t[s]}}setFilterIcon(t,s){let i=this.overlay.querySelector('[data-type="'+t+'"],[data-ls-type="'+t+'"],[data-orig="'+t+'"],[data-net-filter="'+t+'"]');if(!i)return!1;if(!e[s])throw Error("图标"+s+"不存在");i.dataset.icon=s;let n=i.dataset.orig||i.dataset.type||i.dataset.lsType||i.dataset.netFilter||"",o=i.classList.contains("active");return i.innerHTML=this.icon(s)+" "+n+(o?" (0)":""),!0}createSandbox(e){let t=this;return new Proxy(e,{get(e,s){if("options"!==s&&"pluginOption"!==s){if("__isSandbox"===s)return!0;if("string"==typeof s&&s in e){let i=e[s];return"function"==typeof i?i.bind(t):i}return e[s]}},set:(e,t)=>("options"===t||"pluginOption"===t||console.warn("[thinConsole] 插件沙箱阻止了修改属性: "+t),!0),deleteProperty:(e,t)=>"options"!==t&&"pluginOption"!==t&&(delete e[t],!0)})}loadSinglePlugin(e){if(!this.disabledPlugins.includes(e)&&t.plugins[e]&&!this.plugins[e]){try{let s=new(0,t.plugins[e])(this.createSandbox(this));if(s.pluginOption="object"!=typeof this.options.pluginOption[e]||Array.isArray(this.options.pluginOption[e])||null===this.options.pluginOption[e]?{}:this.options.pluginOption[e],s.init(),this.plugins[e]=s,s.addTab){let t=s.addTab();this.createPluginTab(t),this.pluginTabs[e]={id:t.id,name:t.name,icon:t.icon||"plug",plugin:s}}this.triggerGlobalHook("pluginMount",e,s)}catch(t){console.error(`插件"${e}"加载失败:`,t)}return this}}applyCSS(e){let t=document.createElement("style");return t.textContent=e,this.shadowRoot.appendChild(t),t}createVirtualList(e,t){this.vsInit(e);let s=t.initialData||[],i=t.itemHeight,n=t.renderItem,o=e=>"string"==typeof e?e:e.outerHTML,l=e=>o(n(e)),r=t.emptyHTML||"",a=t.trackBy;return this.vsUpdate(e,s,l,i,{force:!0,emptyHTML:r,trackBy:a}),{update:(t,s)=>{this.vsUpdate(e,t||[],s?e=>o(s(e)):l,i,{emptyHTML:r,trackBy:a})},render:()=>this.vsRender(e),destroy:()=>{e._vs&&(e.removeEventListener("scroll",e._vs.scrollHandler),delete e._vs)}}}initPlugins(){return Object.keys(t.plugins).forEach(e=>{this.disabledPlugins.includes(e)||this.loadSinglePlugin(e)}),this}destroyPlugin(e){let t=this.plugins[e];if(!t)return;"function"==typeof t.destroy&&t.destroy();let s=this.pluginTabs[e]?.id;if(s){let e=this.overlay.querySelector(`.tab-btn[data-tab="${s}"]`);e?.remove();let t=this.pluginViewContainers[s];t?.remove(),delete this.pluginViewContainers[s]}return delete this.plugins[e],delete this.pluginTabs[e],this.triggerGlobalHook("pluginUnmount",e),this}triggerGlobalHook(e,...s){return t.hooks[e]&&t.hooks[e].forEach(t=>{try{t.call(this,...s)}catch(t){console.error(`钩子"${e}"执行错误:`,t)}}),this}destroy(){t.tC===this&&(Object.assign(console,this.originalConsole),Object.keys(this.plugins).forEach(e=>this.destroyPlugin(e)),clearInterval(this.protectInterval),this.mediaQuery&&this.themeChangeHandler&&this.mediaQuery.removeEventListener("change",this.themeChangeHandler),this.timerMap&&this.timerMap.forEach(e=>clearTimeout(e.timeoutId)),this.timerMap&&this.timerMap.clear(),this._elementObserver&&this.stopElementObserver(),this._updateFilterRaf&&cancelAnimationFrame(this._updateFilterRaf),this.overlay&&this.overlay.querySelectorAll("[data-filter-ro]").forEach(e=>{e._tcFilterRO&&e._tcFilterRO.disconnect(),e._tcFilterMO&&e._tcFilterMO.disconnect()}),this.btn?.remove(),this.shadowRoot?.querySelector("style[tcstyle]")?.remove(),this.host?.remove(),this.overlay?.remove(),this.notification?.remove(),this.r(document,"error",this.RSError,!0),this.r(window,"error",this.tCError),this.r(window,"unhandledrejection",this.tCUR),this.r(window,"resize",this._onResize),this.originalXHR&&(window.XMLHttpRequest=this.originalXHR),this.originalFetch&&(window.fetch=this.originalFetch),t.tC=null)}setOption(e){return this.destroy(),new t(e)}startElementObserver(){this._elementObserver||(this._elementObserver=new MutationObserver(e=>this._onElementMutation(e)),this._observeAllRoots())}stopElementObserver(){this._elementObserver&&(this._elementObserver.disconnect(),this._elementObserver=null),clearTimeout(this._elementRefreshTimer)}_observeAllRoots(){if(!this._elementObserver)return;let e={childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,characterData:!0};this._elementObserver.observe(document.documentElement,e),this.closedShadowRoots.forEach(t=>{try{this._elementObserver.observe(t.root,e)}catch{}})}_onElementMutation(e){let t=new Set;for(let s of e){let e=s.target;if(this.shadowRoot&&e.getRootNode()===this.shadowRoot)continue;let i=e;for(;i;){if(this.expandedElements.has(i)){t.add(i);break}i=i.parentNode||i.host||null}}t.size>0&&(clearTimeout(this._elementRefreshTimer),this._elementRefreshTimer=setTimeout(()=>{if("elements"!==this.currentTab)return;this._observeAllRoots();let e=this.elementsTree?this.elementsTree.scrollTop:0;this._refreshMutatedNodes(t),this.elementsTree&&(this.elementsTree.scrollTop=e)},300))}_renderElShadow(e,t,s){let i=this.getShadowRoot(e);if(!i)return"";let n=Array.from(i.root.childNodes).filter(e=>this._vn(e));if(!n.length&&"closed"!==i.mode)return"";if(this.expandedElements.has(i.root)||0===t){let e=++this.elRefId;return this.elRefMap.set(e,i.root),this._treeShadowNode(!0,"data-el-id",e,i.mode,this.renderDomChildrenLazy(n,(e,t,s)=>this.renderElementTree(e,s),t,"element-shadow",{}),'data-shadow-host="'+s+'"')}return this.buildShadowLazy(i,"element",null,t,s)}_refreshMutatedNodes(e){let t=!1;for(let s of e){let e=-1;if(this.elRefMap)for(let[t,i]of this.elRefMap)if(i===s){e=t;break}if(e<0){t=!0;continue}let i=this.elementsTree?.querySelector('.tree-node[data-el-id="'+e+'"]');if(i?.classList.contains("expanded")){let t=i.querySelector(":scope > .tree-children");t&&(t.innerHTML=this.renderDomChildrenLazy(Array.from(s.childNodes).filter(e=>this._vn(e)),(e,t,s)=>this.renderElementTree(e,s),parseInt(i.dataset.depth||0)+1,"element",{})+this._renderElShadow(s,parseInt(i.dataset.depth||0)+1,e))}else t=!0}if(!t&&this.selectedElement){let e=null;if(this.elRefMap)for(let[t,s]of this.elRefMap)if(s===this.selectedElement){e=t;break}if(null!==e){let t=this.elementsTree?.querySelector('.tree-node[data-el-id="'+e+'"]');t&&(this.elementsTree.querySelectorAll(".el-selected").forEach(e=>e.classList.remove("el-selected")),t.classList.add("el-selected"))}}t&&this.renderElementsView()}_applyCustomThemeCSS(){let e=this.shadowRoot?.querySelector("style[data-custom-theme]");e?.remove();let s=t.themes[this.currentTheme];if(!s)return;let i=this._getThemeVars("light"),n=Object.assign({},i,s.vars),o=".theme-"+this.currentTheme+"{";for(let e in n)o+=e+":"+n[e]+";";o+="}";let l=document.createElement("style");l.setAttribute("data-custom-theme",""),l.textContent=o,this.shadowRoot?.appendChild(l)}_getThemeVars(e){let t=this.shadowRoot?.querySelector("style[tcstyle]");if(!t)return{};let s=t.textContent,i=".theme-"+e+"{",n=s.indexOf(i);if(n<0)return{};n+=i.length;let o=s.indexOf("}",n),l=s.slice(n,o),r={};return l.split(";").forEach(e=>{let t=e.indexOf(":");t>0&&(r[e.slice(0,t).trim()]=e.slice(t+1).trim())}),r}_injectHeaderButtons(){if(!t.headerButtons.length)return;let e=this.overlay.querySelector(".header-actions");if(e)for(let s of t.headerButtons){let t=document.createElement("button");t.className="header-icon-btn tc-header-btn",t.innerHTML=this.icon(s.icon),t.title=s.icon,s.fn&&t.addEventListener("click",s.fn),e.insertBefore(t,this.searchToggleBtn)}}createNetRequest(e,t){return this._netReqId=this._netReqId||1,{id:++this._netReqId,url:t||"",method:(e||"GET").toUpperCase(),status:0,statusText:"",reqHeaders:{},reqBody:null,resHeaders:{},resBody:null,startTime:Date.now(),endTime:0,duration:0,error:null}}finalizeNetRequest(e,t,s,i,n,o){e.status=t,e.statusText=s||"",e.endTime=Date.now(),e.duration=e.endTime-e.startTime,i&&(e.resHeaders=i),null!=n&&(e.resBody=n),o&&(e.error=o),"network"===this.currentTab&&this.renderNetworkList(),this.netDetailId===e.id&&this.showNetDetail(e.id)}_fmtNetReq(e){let t=e.status>0?Math.floor(e.status/100)+"xx":"pending",s=e.status>0?e.status+" "+(e.statusText||""):e.error||"等待中...",i=e.duration>0?e.duration+"ms":"",n=i?s+" ("+i+")":s,o="";try{o=this.safeStringify(e.reqHeaders,2,!1)}catch(t){o=(e.reqHeaders||"")+""}o=this.clr(o);let l=!o||"{}"===o||"null"===o,r="";if(e.reqBody)try{r="string"==typeof e.reqBody?e.reqBody:this.safeStringify(e.reqBody,2,!1)}catch(t){r=e.reqBody+""}r=this.clr(r);let a=!r||"null"===r||"undefined"===r,c="";try{c=this.safeStringify(e.resHeaders,2,!1)}catch(t){c=(e.resHeaders||"")+""}c=this.clr(c);let d=!c||"{}"===c||"null"===c,h=e.resBody||"",p="";if(h)try{p=JSON.stringify(JSON.parse(h),null,2)}catch(t){p=h}let u=!p||"null"===p||"undefined"===p;return{sc:t,st:s,sf:n,rhs:o,rhe:l,rbs:r,rbe:a,shs:c,she:d,sbs:p,sbe:u,ct:"网址: "+e.url+"\n方法: "+e.method+"\n状态: "+n+(l?"":"\n\n请求头:\n"+o)+(a?"":"\n\n请求内容:\n"+r)+(d?"":"\n\n响应头:\n"+c)+(u?"":"\n\n响应内容:\n"+p)}}pushNetRequest(e){this.networkRequests.push(e),this.networkRequests.length>this.maxNetwork&&this.networkRequests.splice(0,this.networkRequests.length-this.maxNetwork),"network"===this.currentTab&&this.renderNetworkList()}_isNetDisabled(e){if(0===this.netDisabledTypes.size)return!1;let t=e.toLowerCase();return this.netDisabledTypes.has("all")||this.netDisabledTypes.has(t)}captureNetworkRequests(){this.originalXHR=this.originalXHR||window.XMLHttpRequest;let e=this,t=this.originalXHR;window.XMLHttpRequest=function(){let s=new t,i=e.createNetRequest("GET",""),n=s.open;s.open=function(e,t){return i.method=e.toUpperCase(),i.url=t,n.apply(s,arguments)};let o=s.send;s.send=function(t){if(e._isNetDisabled(i.method))return;i.reqBody=t,i.startTime=Date.now();let n={...i};return e.pushNetRequest(n),s.addEventListener("loadend",function(){let t={},i=null;try{s.getAllResponseHeaders().trim().split("\n").forEach(e=>{let s=e.indexOf(":");s>0&&(t[e.slice(0,s).trim()]=e.slice(s+1).trim())})}catch(e){}try{i=s.responseText}catch(e){}e.finalizeNetRequest(n,s.status,s.statusText,t,i,null)}),s.addEventListener("error",function(){e.finalizeNetRequest(n,0,"",null,null,"Network Error")}),s.addEventListener("abort",function(){e.finalizeNetRequest(n,0,"",null,null,"Aborted")}),o.apply(s,arguments)};let l=s.setRequestHeader;return s.setRequestHeader=function(e,t){return i.reqHeaders[e]=t,l.apply(s,arguments)},s},this.originalFetch=this.originalFetch||window.fetch;let s=this.originalFetch;window.fetch=function(t,i){let n="string"==typeof t?t:t.url,o=(i&&i.method||"GET").toUpperCase();if(e._isNetDisabled(o))return Promise.reject(Error("Request disabled by thinConsole"));let l=e.createNetRequest(o,n);return i&&i.headers&&(i.headers instanceof Headers?i.headers.forEach((e,t)=>l.reqHeaders[t]=e):"object"==typeof i.headers&&Object.assign(l.reqHeaders,i.headers)),i&&i.body&&(l.reqBody=i.body),e.pushNetRequest(l),s.apply(window,arguments).then(t=>{let s={};return t.headers.forEach((e,t)=>s[t]=e),t.clone().text().then(i=>{e.finalizeNetRequest(l,t.status,t.statusText,s,i,null)}).catch(()=>{e.finalizeNetRequest(l,t.status,t.statusText,s,null,null)}).then(()=>t)}).catch(t=>{throw"AbortError"===t.name?e.finalizeNetRequest(l,0,"",null,null,"Aborted"):e.finalizeNetRequest(l,0,"",null,null,t.message),t})}}renderNetFilters(){this.netFiltersEl&&(this.netFiltersEl.innerHTML=[{id:"all",name:"全部",icon:"list"},{id:"get",name:"获取",icon:"download"},{id:"post",name:"提交",icon:"upload"},{id:"put",name:"更新",icon:"pen"},{id:"success",name:"成功",icon:"check-circle"},{id:"failed",name:"失败",icon:"times-circle"}].map(e=>`<button class="net-filter-btn ${this.activeNetFilter===e.id?"active":""}" data-net-filter="${e.id}" data-orig="${e.name}" data-icon="${e.icon}">${this.icon(e.icon)} ${e.name}</button>`).join(""),this.netFiltersEl.querySelectorAll(".net-filter-btn").forEach(e=>{e.addEventListener("click",()=>{this.netFiltersEl.querySelectorAll(".net-filter-btn").forEach(e=>e.classList.remove("active")),e.classList.add("active"),this.activeNetFilter=e.dataset.netFilter,this.renderNetworkList(),this.updateNetDisableBtn(),this.scrollFilterIntoView(this.netFiltersEl,e)})}),this.updateNetFilterCounts())}updateNetFilterCounts(){if(!this.netFiltersEl)return;let e=this.networkRequests,t={all:e.length,get:e.filter(e=>"get"===e.method.toLowerCase()).length,post:e.filter(e=>"post"===e.method.toLowerCase()).length,put:e.filter(e=>"put"===e.method.toLowerCase()).length,success:e.filter(e=>e.status>=200&&e.status<400).length,failed:e.filter(e=>0===e.status||e.status>=400||e.error).length};this._updateFilterBtns(this.netFiltersEl,t,"netFilter",(e,t,s)=>{let i=e.dataset.orig,n=e.dataset.icon||"",o=this._fmtCount(t,!0);return e.title=s?""+o.exactCount:"",this.icon(n)+" "+i+(s?" ("+o.filterCount+")":"")})}updateNetDisableBtn(){if(!this.netDisableBtn)return;let e=this.activeNetFilter,t="";"all"===e?t="全部":"get"===e?t="获取":"post"===e?t="提交":"put"===e?t="更新":"success"===e?t="成功(全部)":"failed"===e&&(t="失败(全部)");let s=this.netDisabledTypes.has(e);this.netDisableBtn.innerHTML=this.icon("ban"),this.netDisableBtn.title=s?`已禁用${t}请求`:`禁用${t}请求`,this.netDisableBtn.classList.toggle("disabled",s)}toggleNetDisable(){let e=this.activeNetFilter,t="";if("all"===e?t="全部":"get"===e?t="获取":"post"===e?t="提交":"put"===e?t="更新":"success"===e?t="成功(全部)":"failed"===e&&(t="失败(全部)"),this.netDisabledTypes.has(e)){this.netDisabledTypes.delete(e);var s=!1}else this.netDisabledTypes.add(e),s=!0;this.updateNetDisableBtn(),this.showNotification(s?`已禁用${t}请求`:`已恢复${t}请求`,s?"warning":"")}getFilteredNetRequests(){let e=this.networkRequests;if(!this.activeNetFilter||"all"===this.activeNetFilter)return e;let t=this.activeNetFilter;return"get"===t||"post"===t||"put"===t?e.filter(e=>e.method.toLowerCase()===t):"success"===t?e.filter(e=>e.status>=200&&e.status<400):"failed"===t?e.filter(e=>0===e.status||e.status>=400||e.error):e}renderNetworkList(){if("network"!==this.currentTab)return;if(!this.networkItems)return;let e=this.getFilteredNetRequests();if(this.searchQuery){let t=this.searchQuery.toLowerCase();e=e.filter(e=>{if(e.url.toLowerCase().includes(t))return!0;if(e.method.toLowerCase().includes(t))return!0;try{if(this.safeStringify(e.reqHeaders).toLowerCase().includes(t))return!0}catch(e){}try{if(("string"==typeof e.reqBody?e.reqBody:this.safeStringify(e.reqBody)).toLowerCase().includes(t))return!0}catch(e){}try{if(this.safeStringify(e.resHeaders).toLowerCase().includes(t))return!0}catch(e){}return!!(e.resBody||"").toLowerCase().includes(t)})}this.updateNetFilterCounts(),0!==e.length?this.vsUpdate(this.networkItems,e,e=>this.renderNetworkItem(e),100):this.vsUpdate(this.networkItems,[],null,0,{emptyHTML:'<div class="nolog">'+this.icon("wifi")+"暂无网络请求</div>"})}renderNetworkItem(e){let t=e.status>0?Math.floor(e.status/100)+"xx":"pending",s=e.error||e.status>=400?"net-failed":e.status>=200&&e.status<400?"net-success":"",i=e.status>0?e.status+"":e.error?"ERR":"...",n=e.duration>0?e.duration+"ms":"",o=n?i+" "+n:i,l="",r=this.escapeHtml(e.url);try{l=new Date(e.startTime).toLocaleTimeString()}catch(e){l=""}return`<div class="net-item ${s}" data-req-id="${e.id}"><div class="net-row1"><span class="net-method net-method-${e.method}">${e.method}</span><span class="net-time">${this.escapeHtml(l)}</span></div><div class="net-row2"><span class="net-url" title="${r}">${r}</span><span class="net-status net-status-${t}">${this.escapeHtml(o)}</span></div><div class="net-row3"><button class="net-copy-btn" data-action="copy" title="复制完整请求信息">${this.icon("copy")} 复制</button><button class="net-detail-btn" data-action="detail" title="查看详情">${this.icon("eye")} 详情</button></div></div>`}showNetDetail(e){let t=this.networkRequests.find(t=>t.id===e);if(!t)return;this.netDetailId=e;let s=this._fmtNetReq(t),i=s.sc,n=(s.st,s.sf),o=s.rhs,l=s.rhe,r=l?'<span class="net-detail-empty">无请求头</span>':this.renderJSONTree(o,"",0,0,"net-"+e+"-reqHeaders",0,!0),a=s.rbs,c=s.rbe,d=c?'<span class="net-detail-empty">无请求内容</span>':this.renderJSONTree(a,"",0,0,"net-"+e+"-reqBody",0,!0),h=s.shs,p=s.she,u=p?'<span class="net-detail-empty">无响应头</span>':this.renderJSONTree(h,"",0,0,"net-"+e+"-resHeaders",0,!0),f=s.sbs,g=s.sbe,m=g?'<span class="net-detail-empty">无响应内容</span>':this.renderJSONTree(f,"",0,0,"net-"+e+"-resBody",0,!0),b=(t.resBody,(e,t,s,i)=>`<div class="net-detail-section nd-s"><div class="net-detail-section-header"><div class="net-detail-label">${e}</div>${i?"":`<button class="net-detail-copy-section" data-copy-text="${this.escapeHtml(s)}" title="复制">${this.icon("copy")}</button>`}</div><div class="${i||t.indexOf("json-tree-container")>=0?"net-detail-value":"net-detail-value net-detail-code"}">${t}</div></div>`),v=`<div class="net-detail-section nd-s"><div class="net-detail-section-header"><div class="net-detail-label">网址</div><button class="net-detail-copy-section" data-copy-text="${this.escapeHtml(t.url)}" title="复制网址">${this.icon("copy")}</button></div><div class="net-detail-value net-detail-code">${this.escapeHtml(t.url)}</div></div>`,y=`<div class="net-detail-section"><div class="net-detail-section-header"><div class="net-detail-label">类型</div></div><span class="net-method net-method-${t.method}">${t.method}</span></div>`,w=`<div class="net-detail-section"><div class="net-detail-section-header"><div class="net-detail-label">状态</div></div><span class="net-status net-status-${i}">${this.escapeHtml(n)}</span></div>`,x=b("请求头",r,o,l),k=b("请求内容",d,a,c),S=b("响应头",u,h,p),C=b("响应内容",m,f,g);this.netDetailBody.innerHTML=v+y+w+x+k+S+C,this.netDetailBody.querySelectorAll(".net-detail-copy-section").forEach(e=>{e.addEventListener("click",()=>{let t=e.getAttribute("data-copy-text")||"";navigator.clipboard.writeText(t).then(()=>this.showNotification("已复制")).catch(()=>{})})});let L=this.overlay.querySelector("#netResendIconBtn");L&&L.addEventListener("click",()=>this.resendRequest(t));let E=this.overlay.querySelector("#netCopyIconBtn");E&&E.addEventListener("click",()=>{navigator.clipboard.writeText(s.ct).then(()=>this.showNotification("已复制完整请求信息")).catch(()=>{})}),this._nsb.style.display="none",this._nsi.value="",this._nsc.textContent="",this.netDetailOverlay.style.display="flex",this._ssv()}resendRequest(e){this.netDetailOverlay.style.display="none",this.netNewVisible=!0,this.netNewOverlay.style.display="flex",this._ssv(),this.netNewUrl.value=e.url,this.netNewMethod.value=e.method;let t="";if(e.reqBody)try{t="string"==typeof e.reqBody?e.reqBody:JSON.stringify(e.reqBody,null,2)}catch(e){t=""}this.netNewBody.value=t||"";let s="";try{e.reqHeaders&&"object"==typeof e.reqHeaders&&(s=(Array.isArray(e.reqHeaders)?e.reqHeaders:Object.entries(e.reqHeaders)).map(e=>Array.isArray(e)?e[0]+": "+e[1]:e).join("\n"))}catch(e){}this.netNewHeaders.value=s||""}sendNewRequest(){if(this.editorState.visible){let e=this.editorState.mode;if("code"===e)return void this.showNotification("正在运行代码,无法发送请求","warning");if("ls"===e)return void this.showNotification("正在保存键值,无法发送请求","warning")}let e=this.netNewUrl.value.trim();if(!e)return void this.showNotification("请输入网址","warning");let t=this.netNewMethod.value,s=this.netNewBody.value.trim(),i=this.netNewHeaders.value.trim(),n={};i&&i.split("\n").forEach(e=>{let t=e.indexOf(":");t>0&&(n[e.slice(0,t).trim()]=e.slice(t+1).trim())});let o={method:t,headers:n};if(s&&"GET"!==t&&"HEAD"!==t)try{o.body=JSON.stringify(JSON.parse(s)),n["Content-Type"]||(n["Content-Type"]="application/json")}catch(e){o.body=s}this.netSending=!0,this.netNewVisible=!1,this.netNewOverlay.style.display="none",this._ssv(),this.netNewUrl.value="",this.netNewBody.value="",this.netNewHeaders.value="",this.netNewMethod.value="GET",this.showNotification("正在发送请求...");let l={id:++this._netReqId,url:e,method:t,status:0,statusText:"",reqHeaders:n,reqBody:o.body||null,resHeaders:{},resBody:null,startTime:Date.now(),endTime:0,duration:0,error:null};this.networkRequests.push(l),(this.originalFetch||window.fetch).call(window,e,o).then(e=>{this.netSending=!1,l.status=e.status,l.statusText=e.statusText,l.endTime=Date.now(),l.duration=l.endTime-l.startTime,e.clone().text().then(e=>{l.resBody=e,this.netDetailId===l.id&&this.showNetDetail(l.id)}).catch(()=>{}),e.headers.forEach((e,t)=>l.resHeaders[t]=e),this.showNotification("请求完成: "+e.status,e.status>=400?"warning":""),"network"===this.currentTab&&this.renderNetworkList()}).catch(e=>{this.netSending=!1,l.error=e.message,l.status=0,l.endTime=Date.now(),l.duration=l.endTime-l.startTime,this.netDetailId===l.id&&this.showNetDetail(l.id),this.showNotification("请求失败: "+e.message,"warning"),"network"===this.currentTab&&this.renderNetworkList(),this.netNewUrl.value="",this.netNewBody.value="",this.netNewHeaders.value="",this.netNewMethod.value="GET"})}renderNetworkPanel(){this.renderNetFilters(),this.updateNetDisableBtn(),this.renderNetworkList()}clearNetworkRequests(){let e=this.activeNetFilter||"all",t="";if("all"===e?t="全部":"get"===e?t="获取":"post"===e?t="提交":"put"===e?t="更新":"success"===e?t="成功":"failed"===e&&(t="失败"),this.getFilteredNetRequests(),confirm("确定要清除所有"+t+"请求吗?此操作不可撤销。")){if("all"===e)this.networkRequests=[];else{let t="get"===e||"post"===e||"put"===e?t=>t.method.toLowerCase()!==e:"success"===e?e=>!(e.status>=200&&e.status<400):e=>!(0===e.status||e.status>=400||e.error);this.networkRequests=this.networkRequests.filter(t)}this.renderNetworkList(),this.showNotification("已清空"+t+"请求")}}switchTab(e){let t=Array.from(this.tabButtons).find(t=>t.dataset.tab===e);t&&t.click()}show(e="console"){return this.overlay||this.createOverlayElement(),this.switchTab(e),this.triggerGlobalHook("beforeOpen"),this.overlay.classList.add("active","theme-"+this.currentTheme),this.triggerGlobalHook("afterOpen"),this}hide(){return this.overlay&&(this.triggerGlobalHook("beforeClose"),this.overlay.classList.remove("active"),this.triggerGlobalHook("afterClose")),this}get storage(){let e=e=>{document.cookie=encodeURIComponent(e)+"=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/",document.cookie=encodeURIComponent(e)+"=;expires=Thu, 01 Jan 1970 00:00:00 GMT"},t=(e,t,s,i,n,o)=>({get:e,set:t,remove:s,clear:i,length:n,key:o});return{local:t(e=>localStorage.getItem(e),(e,t)=>localStorage.setItem(e,t),e=>localStorage.removeItem(e),()=>localStorage.clear(),()=>localStorage.length,e=>localStorage.key(e)),session:t(e=>sessionStorage.getItem(e),(e,t)=>sessionStorage.setItem(e,t),e=>sessionStorage.removeItem(e),()=>sessionStorage.clear(),()=>sessionStorage.length,e=>sessionStorage.key(e)),cookie:t(e=>{let t=encodeURIComponent(e),s=document.cookie.match(RegExp("(?:^|;\\s)"+t.replace(/([.*+?^${}()|[\]\\])/g,"\\$1")+"=([^;]*)"));return s?decodeURIComponent(s[1]):null},(e,t,s)=>{let i=new Date;i.setTime(i.getTime()+864e5*(s||365)),document.cookie=encodeURIComponent(e)+"="+encodeURIComponent(t)+";expires="+i.toUTCString()+";path=/"},e,()=>{document.cookie.split(";").forEach(t=>{let s=t.split("=")[0].trim();s&&e(s)})},()=>document.cookie?document.cookie.split(";").filter(e=>e.trim()).length:0,e=>{let t=document.cookie?document.cookie.split(";").filter(e=>e.trim()):[];return t[e]?decodeURIComponent(t[e].split("=")[0]):null})}}icon(t,s){let i=((t||"")+"").trim();if(!i)return"";let n=e[i];if(!n)return"";let o=n.indexOf("|"),l=n.slice(0,o).trim().split(/\s+/),r=0,a=0,c=512,d=512;return 2===l.length?[r,a,c,d]=[0,0,+l[0],+l[1]]:3===l.length?[r,a,c,d]=[0,+l[0],+l[1],+l[2]]:4===l.length?[r,a,c,d]=[+l[0],+l[1],+l[2],+l[3]]:c=+l[0],'<svg class="ico ico-'+i+(s?" "+s:"")+'" viewBox="'+r+" "+a+" "+c+" "+d+'" aria-hidden="true"><path fill="currentColor" d="'+n.slice(o+1)+'"/></svg>'}treeToggleHtml(){return'<span class="tree-toggle">'+this.icon("angle-right")+this.icon("angle-down")+"</span>"}}t.plugins={},t.themes={},t.headerButtons=[],window.thinConsole=t,t.tC=null,t.hooks={beforeRender:[],afterRender:[],beforeLog:[],afterLog:[],beforeOpen:[],afterOpen:[],beforeClose:[],afterClose:[],beforeClear:[],afterClear:[],pluginMount:[],pluginUnmount:[]},t.addTheme=function(e,s,i){if("string"!=typeof e||!e)throw Error("name must be string");if("string"!=typeof s)throw Error("styles must be string");let n={};return s.split(";").forEach(e=>{let t=e.indexOf(":");t>0&&(t=e.slice(0,t).trim(),n[t]=e.slice(t+1).trim())}),t.themes[e]={vars:n,icons:i&&"object"==typeof i?i:{}},t.tC&&t.tC.overlay&&(t.tC._applyCustomThemeCSS(),t.tC.currentTheme===e&&t.tC._themeIconsApplied!==e&&(t.tC.applyIcon(t.themes[e].icons),t.tC._themeIconsApplied=e)),t},t.addHeader=function(e,s){if(t.headerButtons.length>=5)return t;if(t.headerButtons.push({icon:e,fn:s}),t.tC&&t.tC.overlay&&t.tC.searchToggleBtn){let i=t.tC.overlay.querySelector(".header-actions");if(i){let n=document.createElement("button");n.className="header-icon-btn tc-header-btn",n.innerHTML=t.tC.icon(e),n.title=e,s&&n.addEventListener("click",s),i.insertBefore(n,t.tC.searchToggleBtn)}}return t},t.setOption=function(e){return t.tC?t.tC.setOption(e):new t(e)},t.show=e=>(t.tC?.show(e),t),t.ban=function(e,s){return t.tC?(t.tC.ban(e,s),t):t},t.hide=()=>(t.tC?.hide(),t),t.destroy=()=>t.tC?.destroy(),t.log=(...e)=>(console.log(...e),t),t.info=(...e)=>(console.info(...e),t),t.warn=(...e)=>(console.warn(...e),t),t.error=(...e)=>(console.error(...e),t),t.addPlugin=function(e,i){if(t.tC){if(i.prototype instanceof s){if(t.plugins[e]=i,t.tC.disabledPlugins.includes(e))return;if(t.tC.pluginEnabled&&!t.tC.plugins[e])try{let s=new i(t.tC.createSandbox(t.tC));if(s.pluginOption="object"!=typeof t.tC.options.pluginOption[e]||Array.isArray(t.tC.options.pluginOption[e])||null===t.tC.options.pluginOption[e]?{}:t.tC.options.pluginOption[e],s.init(),t.tC.plugins[e]=s,s.addTab){let i=s.addTab();t.tC.pluginTabs[e]={id:i.id,name:i.name,icon:i.icon||"tool",plugin:s},t.tC.createPluginTab(i)}t.tC.triggerGlobalHook("pluginMount",e,s)}catch(i){console.error(`插件"${e}"动态加载失败:`,i)}}else{if("function"!=typeof i)throw Error(`插件"${e}"必须是类或函数类型`);if(!t.tC.options.plugins||t.tC.disabledPlugins.includes(e))return;try{i.call(null,t.tC.createSandbox(t.tC)),t.tC.triggerGlobalHook("pluginMount",e,null)}catch(i){console.error(`函数插件"${e}"执行失败:`,i)}}return t}},t.addTabs=function(e){if(!t.tC)return t;Array.isArray(e)||(e=[e]);for(let s of e){if(t.tC.customTabCount>=5){console.warn("自定义Tab数量已达上限(5个)");break}if(!s.id||!s.name){console.warn("Tab必须包含id和name属性");continue}if(t.tC.pluginViewContainers[s.id]){console.warn("Tab ID '"+s.id+"'已存在");continue}t.tC.createPluginTab({id:s.id,name:s.name,icon:s.icon||"plug"});let e=t.tC.pluginViewContainers[s.id];e&&(e.innerHTML="","function"==typeof s.render?s.render(e):s.html&&(e.innerHTML=s.html),s.onShow&&(t.tC.pluginTabs[s.id]={id:s.id,name:s.name,icon:s.icon||"plug",onShow:s.onShow})),t.tC.customTabCount++}return t},t.addHook=function(e,s){return t.hooks[e]&&!t.hooks[e].includes(s)?t.hooks[e].push(s):console.warn("未知钩子:"+e),t},t.removeHook=function(e,s){return t.hooks[e]&&(t.hooks[e]=t.hooks[e].filter(e=>e!==s)),t},t.setFilterCounts=function(e){return t.tC&&t.tC._updateFilterCounts(t.tC.pluginViewContainers[t.tC.currentTab],"object"==typeof e?e:null,!0),t};class s{constructor(e){if(!(e instanceof t))throw Error("plugin needs tC");this.tC=e,this.pluginOption={},this.id=this.constructor.name.toLowerCase()}init(){}iszh(){return!0}isen(){return!1}isMobile(){return/iPad|Android(?!.*Mobile)|Mobi|Android|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}render(e){}onShow(){}onHide(){}destroy(){}}return t.tCPlugin=s,"undefined"!=typeof window&&(window.tCPlugin=s),void 0!==console&&(console.ban=function(e,t){let s="undefined"!=typeof thinConsole?thinConsole:null;return s&&s.tC?(s.tC.ban(e,t),s.tC):s}),t});
|