opencami 1.0.1 → 1.2.0
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/README.md +20 -3
- package/dist/client/analytics-dashboard.html +509 -0
- package/dist/client/analytics.json +598 -0
- package/dist/client/assets/_sessionKey-xUqdePGW.js +97 -0
- package/dist/client/assets/agents-BiadNAEz.js +2 -0
- package/dist/client/assets/agents-screen-C5TPJbry.js +1 -0
- package/dist/client/assets/button-seqh98ae.js +1 -0
- package/dist/client/assets/{connect-BRasuRbB.js → connect-DlVsi-ya.js} +2 -2
- package/dist/client/assets/file-explorer-screen-B0hwrjdF.js +1 -0
- package/dist/client/assets/files-dkr2U72N.js +2 -0
- package/dist/client/assets/index-CwoJpeG1.js +153 -0
- package/dist/client/assets/{index-DHGnKfAU.js → index-D1Et4XlM.js} +1 -1
- package/dist/client/assets/keyboard-shortcuts-dialog-zdnAmDiH.js +1 -0
- package/dist/client/assets/{main-BAHT5yqU.js → main-DOBfHXDF.js} +12 -12
- package/dist/client/assets/opencami-logo-Bxp_4d3X.js +1 -0
- package/dist/client/assets/react-DD8SkMJn.js +1 -0
- package/dist/client/assets/search-dialog-Ck1AQreu.js +1 -0
- package/dist/client/assets/session-export-dialog-Bh3zH4nZ.js +1 -0
- package/dist/client/assets/settings-dialog-CvUsgnnZ.js +1 -0
- package/dist/client/assets/styles-DogPvrGY.css +1 -0
- package/dist/client/assets/switch-BoGcWcnr.js +1 -0
- package/dist/client/assets/use-file-explorer-state-B5JLNsSa.js +12 -0
- package/dist/client/assets/useButton-csSB2uQJ.js +9 -0
- package/dist/client/manifest.json +8 -2
- package/dist/server/assets/{_sessionKey-qlAPF_Ft.js → _sessionKey-DQwkBUS7.js} +981 -229
- package/dist/server/assets/_tanstack-start-manifest_v-cW8K1Mnv.js +4 -0
- package/dist/server/assets/agents-Dz_i76VW.js +11 -0
- package/dist/server/assets/agents-screen-CqQPJndp.js +587 -0
- package/dist/server/assets/{connect-BWI_6rCm.js → connect-CIDOw12K.js} +34 -2
- package/dist/server/assets/{file-explorer-screen-DJXPEG_J.js → file-explorer-screen-BzvgvV8m.js} +7 -58
- package/dist/server/assets/{files-CONoVTGD.js → files-BxvRDIWU.js} +1 -1
- package/dist/server/assets/{index-Bp8QskbI.js → index-BwD7ufHE.js} +4 -3
- package/dist/server/assets/{index-COu2idHm.js → index-CmbNTqa2.js} +105 -14
- package/dist/server/assets/{keyboard-shortcuts-dialog-D5hqVX2v.js → keyboard-shortcuts-dialog-7OEtXUlW.js} +2 -2
- package/dist/server/assets/opencami-logo-C-43FL3R.js +24 -0
- package/dist/server/assets/{router-DbxyvprK.js → router-5qObg5aX.js} +368 -74
- package/dist/server/assets/{search-dialog-JY8C3mqa.js → search-dialog-BE2ZBkj0.js} +44 -12
- package/dist/server/assets/{session-export-dialog-D87uafPD.js → session-export-dialog-DRVbC8Q-.js} +2 -2
- package/dist/server/assets/{settings-dialog-CBj7njLM.js → settings-dialog-BBQcU55J.js} +204 -41
- package/dist/server/assets/switch-DnX0MjGS.js +28 -0
- package/dist/server/assets/tooltip-gbV6rEVv.js +60 -0
- package/dist/server/assets/{menu-D6n4DB0U.js → use-file-explorer-state-DMHdtb7D.js} +56 -57
- package/dist/server/server.js +2 -2
- package/package.json +1 -1
- package/dist/client/assets/_sessionKey-B-MBYHgD.js +0 -95
- package/dist/client/assets/abap-BdImnpbu.js +0 -1
- package/dist/client/assets/actionscript-3-CfeIJUat.js +0 -1
- package/dist/client/assets/ada-bCR0ucgS.js +0 -1
- package/dist/client/assets/andromeeda-C-Jbm3Hp.js +0 -1
- package/dist/client/assets/angular-html-CU67Zn6k.js +0 -1
- package/dist/client/assets/angular-ts-BwZT4LLn.js +0 -1
- package/dist/client/assets/apache-Pmp26Uib.js +0 -1
- package/dist/client/assets/apex-D8_7TLub.js +0 -1
- package/dist/client/assets/apl-dKokRX4l.js +0 -1
- package/dist/client/assets/applescript-Co6uUVPk.js +0 -1
- package/dist/client/assets/ara-BRHolxvo.js +0 -1
- package/dist/client/assets/asciidoc-Dv7Oe6Be.js +0 -1
- package/dist/client/assets/asm-D_Q5rh1f.js +0 -1
- package/dist/client/assets/astro-CbQHKStN.js +0 -1
- package/dist/client/assets/aurora-x-D-2ljcwZ.js +0 -1
- package/dist/client/assets/awk-DMzUqQB5.js +0 -1
- package/dist/client/assets/ayu-dark-CmMr59Fi.js +0 -1
- package/dist/client/assets/ballerina-BFfxhgS-.js +0 -1
- package/dist/client/assets/bat-BkioyH1T.js +0 -1
- package/dist/client/assets/beancount-k_qm7-4y.js +0 -1
- package/dist/client/assets/berry-uYugtg8r.js +0 -1
- package/dist/client/assets/bibtex-CHM0blh-.js +0 -1
- package/dist/client/assets/bicep-Bmn6On1c.js +0 -1
- package/dist/client/assets/blade-D4QpJJKB.js +0 -1
- package/dist/client/assets/bsl-BO_Y6i37.js +0 -1
- package/dist/client/assets/button-D_9OBT_f.js +0 -1
- package/dist/client/assets/c-BIGW1oBm.js +0 -1
- package/dist/client/assets/c3-VCDPK7BO.js +0 -1
- package/dist/client/assets/cadence-Bv_4Rxtq.js +0 -1
- package/dist/client/assets/cairo-KRGpt6FW.js +0 -1
- package/dist/client/assets/catppuccin-frappe-DFWUc33u.js +0 -1
- package/dist/client/assets/catppuccin-latte-C9dUb6Cb.js +0 -1
- package/dist/client/assets/catppuccin-macchiato-DQyhUUbL.js +0 -1
- package/dist/client/assets/catppuccin-mocha-D87Tk5Gz.js +0 -1
- package/dist/client/assets/clarity-D53aC0YG.js +0 -1
- package/dist/client/assets/clojure-P80f7IUj.js +0 -1
- package/dist/client/assets/cmake-D1j8_8rp.js +0 -1
- package/dist/client/assets/cobol-nwyudZeR.js +0 -1
- package/dist/client/assets/codeowners-Bp6g37R7.js +0 -1
- package/dist/client/assets/codeql-DsOJ9woJ.js +0 -1
- package/dist/client/assets/coffee-Ch7k5sss.js +0 -1
- package/dist/client/assets/common-lisp-Cg-RD9OK.js +0 -1
- package/dist/client/assets/coq-DkFqJrB1.js +0 -1
- package/dist/client/assets/cpp-CofmeUqb.js +0 -1
- package/dist/client/assets/crystal-tKQVLTB8.js +0 -1
- package/dist/client/assets/csharp-K5feNrxe.js +0 -1
- package/dist/client/assets/css-DPfMkruS.js +0 -1
- package/dist/client/assets/csv-fuZLfV_i.js +0 -1
- package/dist/client/assets/cue-D82EKSYY.js +0 -1
- package/dist/client/assets/cypher-COkxafJQ.js +0 -1
- package/dist/client/assets/d-85-TOEBH.js +0 -1
- package/dist/client/assets/dark-plus-C3mMm8J8.js +0 -1
- package/dist/client/assets/dart-CF10PKvl.js +0 -1
- package/dist/client/assets/dax-CEL-wOlO.js +0 -1
- package/dist/client/assets/desktop-BmXAJ9_W.js +0 -1
- package/dist/client/assets/diff-D97Zzqfu.js +0 -1
- package/dist/client/assets/docker-BcOcwvcX.js +0 -1
- package/dist/client/assets/dotenv-Da5cRb03.js +0 -1
- package/dist/client/assets/dracula-BzJJZx-M.js +0 -1
- package/dist/client/assets/dracula-soft-BXkSAIEj.js +0 -1
- package/dist/client/assets/dream-maker-BtqSS_iP.js +0 -1
- package/dist/client/assets/edge-BkV0erSs.js +0 -1
- package/dist/client/assets/elixir-CDX3lj18.js +0 -1
- package/dist/client/assets/elm-DbKCFpqz.js +0 -1
- package/dist/client/assets/emacs-lisp-C9XAeP06.js +0 -1
- package/dist/client/assets/erb-BOJIQeun.js +0 -1
- package/dist/client/assets/erlang-DsQrWhSR.js +0 -1
- package/dist/client/assets/everforest-dark-BgDCqdQA.js +0 -1
- package/dist/client/assets/everforest-light-C8M2exoo.js +0 -1
- package/dist/client/assets/fennel-BYunw83y.js +0 -1
- package/dist/client/assets/file-explorer-screen-Daf4rIq9.js +0 -1
- package/dist/client/assets/files-ByeIMLfw.js +0 -2
- package/dist/client/assets/fish-BvzEVeQv.js +0 -1
- package/dist/client/assets/fluent-C4IJs8-o.js +0 -1
- package/dist/client/assets/fortran-fixed-form-CkoXwp7k.js +0 -1
- package/dist/client/assets/fortran-free-form-BxgE0vQu.js +0 -1
- package/dist/client/assets/fsharp-CXgrBDvD.js +0 -1
- package/dist/client/assets/gdresource-B7Tvp0Sc.js +0 -1
- package/dist/client/assets/gdscript-DTMYz4Jt.js +0 -1
- package/dist/client/assets/gdshader-DkwncUOv.js +0 -1
- package/dist/client/assets/genie-D0YGMca9.js +0 -1
- package/dist/client/assets/gherkin-DyxjwDmM.js +0 -1
- package/dist/client/assets/git-commit-F4YmCXRG.js +0 -1
- package/dist/client/assets/git-rebase-r7XF79zn.js +0 -1
- package/dist/client/assets/github-dark-DHJKELXO.js +0 -1
- package/dist/client/assets/github-dark-default-Cuk6v7N8.js +0 -1
- package/dist/client/assets/github-dark-dimmed-DH5Ifo-i.js +0 -1
- package/dist/client/assets/github-dark-high-contrast-E3gJ1_iC.js +0 -1
- package/dist/client/assets/github-light-DAi9KRSo.js +0 -1
- package/dist/client/assets/github-light-default-D7oLnXFd.js +0 -1
- package/dist/client/assets/github-light-high-contrast-BfjtVDDH.js +0 -1
- package/dist/client/assets/gleam-BspZqrRM.js +0 -1
- package/dist/client/assets/glimmer-js-Rg0-pVw9.js +0 -1
- package/dist/client/assets/glimmer-ts-U6CK756n.js +0 -1
- package/dist/client/assets/glsl-DplSGwfg.js +0 -1
- package/dist/client/assets/gn-n2N0HUVH.js +0 -1
- package/dist/client/assets/gnuplot-DdkO51Og.js +0 -1
- package/dist/client/assets/go-Dn2_MT6a.js +0 -1
- package/dist/client/assets/graphql-ChdNCCLP.js +0 -1
- package/dist/client/assets/groovy-gcz8RCvz.js +0 -1
- package/dist/client/assets/gruvbox-dark-hard-CFHQjOhq.js +0 -1
- package/dist/client/assets/gruvbox-dark-medium-GsRaNv29.js +0 -1
- package/dist/client/assets/gruvbox-dark-soft-CVdnzihN.js +0 -1
- package/dist/client/assets/gruvbox-light-hard-CH1njM8p.js +0 -1
- package/dist/client/assets/gruvbox-light-medium-DRw_LuNl.js +0 -1
- package/dist/client/assets/gruvbox-light-soft-hJgmCMqR.js +0 -1
- package/dist/client/assets/hack-CaT9iCJl.js +0 -1
- package/dist/client/assets/haml-B8DHNrY2.js +0 -1
- package/dist/client/assets/handlebars-BL8al0AC.js +0 -1
- package/dist/client/assets/haskell-Df6bDoY_.js +0 -1
- package/dist/client/assets/haxe-CzTSHFRz.js +0 -1
- package/dist/client/assets/hcl-BWvSN4gD.js +0 -1
- package/dist/client/assets/hjson-D5-asLiD.js +0 -1
- package/dist/client/assets/hlsl-D3lLCCz7.js +0 -1
- package/dist/client/assets/houston-DnULxvSX.js +0 -1
- package/dist/client/assets/html-GMplVEZG.js +0 -1
- package/dist/client/assets/html-derivative-BFtXZ54Q.js +0 -1
- package/dist/client/assets/http-jrhK8wxY.js +0 -1
- package/dist/client/assets/hurl-irOxFIW8.js +0 -1
- package/dist/client/assets/hxml-Bvhsp5Yf.js +0 -1
- package/dist/client/assets/hy-DFXneXwc.js +0 -1
- package/dist/client/assets/imba-DGztddWO.js +0 -1
- package/dist/client/assets/index-ByUDBI-n.js +0 -14
- package/dist/client/assets/ini-BEwlwnbL.js +0 -1
- package/dist/client/assets/java-CylS5w8V.js +0 -1
- package/dist/client/assets/javascript-wDzz0qaB.js +0 -1
- package/dist/client/assets/jinja-4LBKfQ-Z.js +0 -1
- package/dist/client/assets/jison-wvAkD_A8.js +0 -1
- package/dist/client/assets/json-Cp-IABpG.js +0 -1
- package/dist/client/assets/json5-C9tS-k6U.js +0 -1
- package/dist/client/assets/jsonc-Des-eS-w.js +0 -1
- package/dist/client/assets/jsonl-DcaNXYhu.js +0 -1
- package/dist/client/assets/jsonnet-DFQXde-d.js +0 -1
- package/dist/client/assets/jssm-C2t-YnRu.js +0 -1
- package/dist/client/assets/jsx-g9-lgVsj.js +0 -1
- package/dist/client/assets/julia-CxzCAyBv.js +0 -1
- package/dist/client/assets/kanagawa-dragon-CkXjmgJE.js +0 -1
- package/dist/client/assets/kanagawa-lotus-CfQXZHmo.js +0 -1
- package/dist/client/assets/kanagawa-wave-DWedfzmr.js +0 -1
- package/dist/client/assets/kdl-DV7GczEv.js +0 -1
- package/dist/client/assets/keyboard-shortcuts-dialog-agsWJ36q.js +0 -1
- package/dist/client/assets/kotlin-BdnUsdx6.js +0 -1
- package/dist/client/assets/kusto-DZf3V79B.js +0 -1
- package/dist/client/assets/laserwave-DUszq2jm.js +0 -1
- package/dist/client/assets/latex-B4uzh10-.js +0 -1
- package/dist/client/assets/lean-BZvkOJ9d.js +0 -1
- package/dist/client/assets/less-B1dDrJ26.js +0 -1
- package/dist/client/assets/light-plus-B7mTdjB0.js +0 -1
- package/dist/client/assets/liquid-DYVedYrR.js +0 -1
- package/dist/client/assets/llvm-BtvRca6l.js +0 -1
- package/dist/client/assets/log-2UxHyX5q.js +0 -1
- package/dist/client/assets/logo-BtOb2qkB.js +0 -1
- package/dist/client/assets/lua-BbnMAYS6.js +0 -1
- package/dist/client/assets/luau-C-HG3fhB.js +0 -1
- package/dist/client/assets/make-CHLpvVh8.js +0 -1
- package/dist/client/assets/markdown-Cvjx9yec.js +0 -1
- package/dist/client/assets/marko-DZsq8hO1.js +0 -1
- package/dist/client/assets/material-theme-D5KoaKCx.js +0 -1
- package/dist/client/assets/material-theme-darker-BfHTSMKl.js +0 -1
- package/dist/client/assets/material-theme-lighter-B0m2ddpp.js +0 -1
- package/dist/client/assets/material-theme-ocean-CyktbL80.js +0 -1
- package/dist/client/assets/material-theme-palenight-Csfq5Kiy.js +0 -1
- package/dist/client/assets/matlab-D7o27uSR.js +0 -1
- package/dist/client/assets/mdc-DUICxH0z.js +0 -1
- package/dist/client/assets/mdx-Cmh6b_Ma.js +0 -1
- package/dist/client/assets/menu-BhVaz8Ly.js +0 -20
- package/dist/client/assets/mermaid-mWjccvbQ.js +0 -1
- package/dist/client/assets/min-dark-CafNBF8u.js +0 -1
- package/dist/client/assets/min-light-CTRr51gU.js +0 -1
- package/dist/client/assets/mipsasm-CKIfxQSi.js +0 -1
- package/dist/client/assets/mojo-B93PlW-d.js +0 -1
- package/dist/client/assets/monokai-D4h5O-jR.js +0 -1
- package/dist/client/assets/moonbit-Ba13S78F.js +0 -1
- package/dist/client/assets/move-Bu9oaDYs.js +0 -1
- package/dist/client/assets/narrat-DRg8JJMk.js +0 -1
- package/dist/client/assets/nextflow-BrzmwbiE.js +0 -1
- package/dist/client/assets/nginx-DknmC5AR.js +0 -1
- package/dist/client/assets/night-owl-C39BiMTA.js +0 -1
- package/dist/client/assets/nim-CVrawwO9.js +0 -1
- package/dist/client/assets/nix-CwoSXNpI.js +0 -1
- package/dist/client/assets/nord-Ddv68eIx.js +0 -1
- package/dist/client/assets/nushell-C-sUppwS.js +0 -1
- package/dist/client/assets/objective-c-DXmwc3jG.js +0 -1
- package/dist/client/assets/objective-cpp-CLxacb5B.js +0 -1
- package/dist/client/assets/ocaml-C0hk2d4L.js +0 -1
- package/dist/client/assets/one-dark-pro-DVMEJ2y_.js +0 -1
- package/dist/client/assets/one-light-PoHY5YXO.js +0 -1
- package/dist/client/assets/openscad-C4EeE6gA.js +0 -1
- package/dist/client/assets/pascal-D93ZcfNL.js +0 -1
- package/dist/client/assets/perl-C0TMdlhV.js +0 -1
- package/dist/client/assets/php-CDn_0X-4.js +0 -1
- package/dist/client/assets/pkl-u5AG7uiY.js +0 -1
- package/dist/client/assets/plastic-3e1v2bzS.js +0 -1
- package/dist/client/assets/plsql-ChMvpjG-.js +0 -1
- package/dist/client/assets/po-BTJTHyun.js +0 -1
- package/dist/client/assets/poimandres-CS3Unz2-.js +0 -1
- package/dist/client/assets/polar-C0HS_06l.js +0 -1
- package/dist/client/assets/postcss-CXtECtnM.js +0 -1
- package/dist/client/assets/powerquery-CEu0bR-o.js +0 -1
- package/dist/client/assets/powershell-Dpen1YoG.js +0 -1
- package/dist/client/assets/prisma-Dd19v3D-.js +0 -1
- package/dist/client/assets/prolog-CbFg5uaA.js +0 -1
- package/dist/client/assets/proto-C7zT0LnQ.js +0 -1
- package/dist/client/assets/pug-CGlum2m_.js +0 -1
- package/dist/client/assets/puppet-BMWR74SV.js +0 -1
- package/dist/client/assets/purescript-CklMAg4u.js +0 -1
- package/dist/client/assets/python-B6aJPvgy.js +0 -1
- package/dist/client/assets/qml-3beO22l8.js +0 -1
- package/dist/client/assets/qmldir-C8lEn-DE.js +0 -1
- package/dist/client/assets/qss-IeuSbFQv.js +0 -1
- package/dist/client/assets/r-Dspwwk_N.js +0 -1
- package/dist/client/assets/racket-BqYA7rlc.js +0 -1
- package/dist/client/assets/raku-DXvB9xmW.js +0 -1
- package/dist/client/assets/razor-C1TweQQi.js +0 -1
- package/dist/client/assets/red-bN70gL4F.js +0 -1
- package/dist/client/assets/reg-C-SQnVFl.js +0 -1
- package/dist/client/assets/regexp-CDVJQ6XC.js +0 -1
- package/dist/client/assets/rel-C3B-1QV4.js +0 -1
- package/dist/client/assets/riscv-BM1_JUlF.js +0 -1
- package/dist/client/assets/rose-pine-dawn-DHQR4-dF.js +0 -1
- package/dist/client/assets/rose-pine-moon-D4_iv3hh.js +0 -1
- package/dist/client/assets/rose-pine-qdsjHGoJ.js +0 -1
- package/dist/client/assets/rosmsg-BJDFO7_C.js +0 -1
- package/dist/client/assets/rst-B0xPkSld.js +0 -1
- package/dist/client/assets/ruby-BvKwtOVI.js +0 -1
- package/dist/client/assets/rust-B1yitclQ.js +0 -1
- package/dist/client/assets/sas-cz2c8ADy.js +0 -1
- package/dist/client/assets/sass-Cj5Yp3dK.js +0 -1
- package/dist/client/assets/scala-C151Ov-r.js +0 -1
- package/dist/client/assets/scheme-C98Dy4si.js +0 -1
- package/dist/client/assets/scss-OYdSNvt2.js +0 -1
- package/dist/client/assets/sdbl-DVxCFoDh.js +0 -1
- package/dist/client/assets/search-dialog-CHwnOyPS.js +0 -1
- package/dist/client/assets/session-export-dialog-uOlDUzgX.js +0 -1
- package/dist/client/assets/settings-dialog-D0aYDkAM.js +0 -1
- package/dist/client/assets/shaderlab-Dg9Lc6iA.js +0 -1
- package/dist/client/assets/shellscript-Yzrsuije.js +0 -1
- package/dist/client/assets/shellsession-BADoaaVG.js +0 -1
- package/dist/client/assets/slack-dark-BthQWCQV.js +0 -1
- package/dist/client/assets/slack-ochin-DqwNpetd.js +0 -1
- package/dist/client/assets/smalltalk-BERRCDM3.js +0 -1
- package/dist/client/assets/snazzy-light-Bw305WKR.js +0 -1
- package/dist/client/assets/solarized-dark-DXbdFlpD.js +0 -1
- package/dist/client/assets/solarized-light-L9t79GZl.js +0 -1
- package/dist/client/assets/solidity-rGO070M0.js +0 -1
- package/dist/client/assets/soy-Brmx7dQM.js +0 -1
- package/dist/client/assets/sparql-rVzFXLq3.js +0 -1
- package/dist/client/assets/splunk-BtCnVYZw.js +0 -1
- package/dist/client/assets/sql-BLtJtn59.js +0 -1
- package/dist/client/assets/ssh-config-_ykCGR6B.js +0 -1
- package/dist/client/assets/stata-BH5u7GGu.js +0 -1
- package/dist/client/assets/styles-7aVSlb6l.css +0 -1
- package/dist/client/assets/stylus-BEDo0Tqx.js +0 -1
- package/dist/client/assets/svelte-zxCyuUbr.js +0 -1
- package/dist/client/assets/swift-Dg5xB15N.js +0 -1
- package/dist/client/assets/synthwave-84-CbfX1IO0.js +0 -1
- package/dist/client/assets/system-verilog-CnnmHF94.js +0 -1
- package/dist/client/assets/systemd-4A_iFExJ.js +0 -1
- package/dist/client/assets/talonscript-CkByrt1z.js +0 -1
- package/dist/client/assets/tasl-QIJgUcNo.js +0 -1
- package/dist/client/assets/tcl-dwOrl1Do.js +0 -1
- package/dist/client/assets/templ-W15q3VgB.js +0 -1
- package/dist/client/assets/terraform-BETggiCN.js +0 -1
- package/dist/client/assets/tex-CvyZ59Mk.js +0 -1
- package/dist/client/assets/tokyo-night-hegEt444.js +0 -1
- package/dist/client/assets/toml-vGWfd6FD.js +0 -1
- package/dist/client/assets/ts-tags-zn1MmPIZ.js +0 -1
- package/dist/client/assets/tsv-B_m7g4N7.js +0 -1
- package/dist/client/assets/tsx-COt5Ahok.js +0 -1
- package/dist/client/assets/turtle-BsS91CYL.js +0 -1
- package/dist/client/assets/twig-CO9l9SDP.js +0 -1
- package/dist/client/assets/typescript-BPQ3VLAy.js +0 -1
- package/dist/client/assets/typespec-BGHnOYBU.js +0 -1
- package/dist/client/assets/typst-DHCkPAjA.js +0 -1
- package/dist/client/assets/v-BcVCzyr7.js +0 -1
- package/dist/client/assets/vala-CsfeWuGM.js +0 -1
- package/dist/client/assets/vb-D17OF-Vu.js +0 -1
- package/dist/client/assets/verilog-BQ8w6xss.js +0 -1
- package/dist/client/assets/vesper-DU1UobuO.js +0 -1
- package/dist/client/assets/vhdl-CeAyd5Ju.js +0 -1
- package/dist/client/assets/viml-CJc9bBzg.js +0 -1
- package/dist/client/assets/vitesse-black-Bkuqu6BP.js +0 -1
- package/dist/client/assets/vitesse-dark-D0r3Knsf.js +0 -1
- package/dist/client/assets/vitesse-light-CVO1_9PV.js +0 -1
- package/dist/client/assets/vue-DN_0RTcg.js +0 -1
- package/dist/client/assets/vue-html-AaS7Mt5G.js +0 -1
- package/dist/client/assets/vue-vine-CQOfvN7w.js +0 -1
- package/dist/client/assets/vyper-CDx5xZoG.js +0 -1
- package/dist/client/assets/wasm-CG6Dc4jp.js +0 -1
- package/dist/client/assets/wasm-MzD3tlZU.js +0 -1
- package/dist/client/assets/wenyan-BV7otONQ.js +0 -1
- package/dist/client/assets/wgsl-Dx-B1_4e.js +0 -1
- package/dist/client/assets/wikitext-BhOHFoWU.js +0 -1
- package/dist/client/assets/wit-5i3qLPDT.js +0 -1
- package/dist/client/assets/wolfram-lXgVvXCa.js +0 -1
- package/dist/client/assets/xml-sdJ4AIDG.js +0 -1
- package/dist/client/assets/xsl-CtQFsRM5.js +0 -1
- package/dist/client/assets/yaml-Buea-lGh.js +0 -1
- package/dist/client/assets/zenscript-DVFEvuxE.js +0 -1
- package/dist/client/assets/zig-VOosw3JB.js +0 -1
- package/dist/server/assets/_tanstack-start-manifest_v-El8F-kd-.js +0 -4
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/settings-dialog-CvUsgnnZ.js","assets/main-DOBfHXDF.js","assets/button-seqh98ae.js","assets/use-file-explorer-state-B5JLNsSa.js","assets/useButton-csSB2uQJ.js","assets/react-DD8SkMJn.js","assets/switch-BoGcWcnr.js","assets/opencami-logo-Bxp_4d3X.js","assets/index-CwoJpeG1.js","assets/session-export-dialog-Bh3zH4nZ.js","assets/keyboard-shortcuts-dialog-zdnAmDiH.js","assets/search-dialog-Ck1AQreu.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{j as h,r as m,L as en,u as Ut,_ as _n,g as Fs,a as Ga,b as Qa,c as $s,d as Ja}from"./main-DOBfHXDF.js";import{u as Za,a as Bs,b as el,c as dt,d as Hs,t as tl,e as Qe,T as Ei,f as Us,g as nl,h as rl,A as Be,i as il,n as sl,j as ol,k as Sn,l as al,m as qs,o as ll,p as He,q as St,r as jt,s as At,v as It,w as Rt,x as Cn,y as pt,z as ul,B as Ti}from"./useButton-csSB2uQJ.js";import{B as Ce,u as cl,c as W,f as Or,a as gt,b as fl,H as re,J as Ws,V as On,d as hl,e as pl,g as dl,h as Ks,q as ml,i as gl,M as xl,l as Fr,j as Xn,I as yl,k as bl,P as kl,s as wl,A as Vs,m as Sl,n as Cl,X as Xs,x as vl,o as El,D as Ys,T as Tl,p as $r,r as Gs,Q as Yn,W as ji,t as jl,S as Al,v as Il,w as Rl}from"./button-seqh98ae.js";import{D as Qs,a as Js,b as Zs,c as Nl,d as eo,u as Dl,e as Ml,f as Ll,g as zl,h as Pl,i as _l,j as Ol,k as Fl,l as $l,m as to,M as Br,n as Hr,o as Ur,p as Et,q as no,r as Bl}from"./use-file-explorer-state-B5JLNsSa.js";import{u as Hl,O as Ul,a as ql}from"./opencami-logo-Bxp_4d3X.js";import{s as qr,h as Wl,w as Kl,f as Vl,a as Xl,b as Yl,c as Ai,r as Gl,u as Ql,C as ro,d as Jl,p as Zl}from"./index-CwoJpeG1.js";import{c as eu}from"./react-DD8SkMJn.js";const tu={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};function wr(e){if(!e)return"main";const t=e.trim();if(t.length===0)return"main";const n=t.split(":"),i=(n[n.length-1]??"").trim();return i.length>0?i:t}function Je(e){return(Array.isArray(e.content)?e.content:[]).map(n=>n.type==="text"?String(n.text??""):"").join("").trim()}function Tt(e){return(Array.isArray(e.content)?e.content:[]).filter(n=>n.type==="toolCall")}function nu(e){if(typeof e=="number"&&Number.isFinite(e))return e<1e12?e*1e3:e;if(typeof e=="string"){const t=Date.parse(e);if(!Number.isNaN(t))return t}return null}function Sr(e){const t=[e.createdAt,e.created_at,e.timestamp,e.time,e.ts];for(const n of t){const r=nu(n);if(r)return r}return Date.now()}const ru=["agent:main:main","main"];function Cr(e){return ru.includes(e)}const iu=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function su(e){if(e.includes(":subagent:")||e.startsWith("agent:codex:")||e.includes(":openai:"))return"subagent";if(e.startsWith("isolated:")||e.includes(":cron:"))return"cron";if(e.startsWith("agent:")&&!e.startsWith("agent:main:"))return"other";if(e.startsWith("agent:main:")){const t=e.slice(11);return iu.test(t)?"webchat":"chat"}return"other"}function ou(e){return Array.isArray(e)?e.map(t=>{const n=typeof t.key=="string"&&t.key.trim().length>0?t.key.trim():wr(t.friendlyId??t.key),r=typeof t.friendlyId=="string"&&t.friendlyId.trim().length>0?t.friendlyId.trim():wr(n),i=su(n),s=t,o=typeof s.totalTokens=="number"?s.totalTokens:void 0,a=typeof s.contextTokens=="number"?s.contextTokens:void 0,l=typeof s.status=="string"?s.status:void 0;return{key:n,friendlyId:r,title:typeof t.title=="string"?t.title:void 0,derivedTitle:typeof t.derivedTitle=="string"?t.derivedTitle:void 0,label:typeof t.label=="string"?t.label:void 0,updatedAt:typeof t.updatedAt=="number"?t.updatedAt:void 0,lastMessage:t.lastMessage??null,kind:i,status:l,totalTokens:o,contextTokens:a}}):[]}async function rt(e){try{const t=await e.json();return t?.error?String(t.error):t?.message?String(t.message):JSON.stringify(t)}catch{try{return await e.text()}catch{return e.statusText||"Request failed"}}}const au="Missing gateway auth. Set CLAWDBOT_GATEWAY_TOKEN (recommended) or CLAWDBOT_GATEWAY_PASSWORD in the server environment.";function Ii(e){return e.includes(au)}function Ri(e,t){const n=crypto.randomUUID(),r=`opt-${n}`,i=Date.now(),s=[];if(t&&t.length>0)for(const a of t)a.type==="image"&&a.base64&&s.push({type:"image",source:{type:"base64",media_type:a.file.type,data:a.base64}});return e.trim()?s.push({type:"text",text:e}):t&&t.length>0&&s.push({type:"text",text:""}),{clientId:n,optimisticId:r,optimisticMessage:{role:"user",content:s,__optimisticId:r,clientId:n,status:"sending",timestamp:i}}}const we={sessions:["chat","sessions"],history:function(t,n){return["chat","history",t,n]}};async function lu(){const e=await fetch("/api/sessions");if(!e.ok)throw new Error(await rt(e));const t=await e.json();return ou(t.sessions)}async function uu(e){const t=new URLSearchParams({limit:"200"});e.sessionKey&&t.set("sessionKey",e.sessionKey),e.friendlyId&&t.set("friendlyId",e.friendlyId);const n=await fetch(`/api/history?${t.toString()}`);if(!n.ok)throw new Error(await rt(n));return await n.json()}async function cu(){const e=new AbortController,t=window.setTimeout(()=>e.abort(),2500);try{const n=await fetch("/api/ping",{signal:e.signal});if(!n.ok)throw new Error(await rt(n));return await n.json()}catch(n){throw n instanceof DOMException&&n.name==="AbortError"?new Error("Gateway check timed out"):n}finally{window.clearTimeout(t)}}function Wr(e,t,n,r){const i=we.history(t,n);e.setQueryData(i,function(o){const a=o,l=Array.isArray(a?.messages)?a.messages:[],u=r(l);return{sessionKey:a?.sessionKey??n,sessionId:a?.sessionId,messages:u}})}function Gn(e,t,n,r){Wr(e,t,n,function(s){return[...s,r]})}function fu(e,t,n,r,i){const s=`opt-${r}`;Wr(e,t,n,function(a){return a.map(l=>l.clientId===r||l.__optimisticId===r||l.__optimisticId===s?i(l):l)})}function hu(e,t,n,r,i){Wr(e,t,n,function(o){return o.filter(a=>!(a.clientId===r||a.__optimisticId===r||i&&a.__optimisticId===i))})}function vr(e,t,n){const r=we.history(t,n);e.setQueryData(r,{sessionKey:n,messages:[]})}function pu(e,t,n,r,i){const s=we.history(t,n),o=we.history(r,i),a=e.getQueryData(s);if(!a)return;const l=Array.isArray(a.messages)?a.messages:[];e.setQueryData(o,{sessionKey:i,sessionId:a.sessionId,messages:l}),e.removeQueries({queryKey:s,exact:!0})}function du(e,t,n,r){e.setQueryData(we.sessions,function(s){return Array.isArray(s)?s.map(o=>o.key!==t&&o.friendlyId!==n?o:{...o,lastMessage:r}):s})}function mu(e,t,n){e.setQueryData(we.sessions,function(i){return Array.isArray(i)?i.filter(s=>s.key!==t&&s.friendlyId!==n):i}),e.removeQueries({queryKey:["chat","history",n],exact:!1}),t&&t!==n&&e.removeQueries({queryKey:["chat","history",t],exact:!1})}async function gu(e,t,n,r){e.setQueryData(we.sessions,function(s){return Array.isArray(s)?s.map(o=>o.key===t||o.friendlyId===n?{...o,label:r}:o):s});try{const i=await fetch("/api/sessions",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionKey:t,friendlyId:n,label:r})});if(!i.ok){const s=await rt(i);console.error("[updateSessionLabel] Failed to persist:",s)}}catch(i){console.error("[updateSessionLabel] Network error:",i)}}function io(e){return!e.content||!Array.isArray(e.content)?"":e.content.filter(t=>t.type==="text").map(t=>t.text||"").join(`
|
|
3
|
+
`)}function xu(e,t,n){const r=[];r.push(`# Conversation: ${e}`),r.push(`Date: ${n.toLocaleString()}`),r.push("");for(const i of t){const s=i.role||"unknown",o=io(i);if(o){const a=s==="user"?"User":"Assistant";r.push(`## ${a}`),r.push(""),r.push(o),r.push("")}}return r.join(`
|
|
4
|
+
`)}function yu(e,t,n){const r={title:e,exportDate:n.toISOString(),messages:t.map(i=>({role:i.role,content:i.content,timestamp:i.timestamp}))};return JSON.stringify(r,null,2)}function bu(e,t,n){const r=[];r.push(`Conversation: ${e}`),r.push(`Date: ${n.toLocaleString()}`),r.push("─".repeat(60)),r.push("");for(const i of t){const s=i.role||"unknown",o=io(i);if(o){const a=s==="user"?"User":"Assistant";r.push(`${a}:`),r.push(o),r.push("")}}return r.join(`
|
|
5
|
+
`)}function ku(e,t,n){const r=new Date;let i,s,o;switch(n){case"markdown":i=xu(e,t,r),s=`${Qn(e)}.md`,o="text/markdown";break;case"json":i=yu(e,t,r),s=`${Qn(e)}.json`,o="application/json";break;case"txt":i=bu(e,t,r),s=`${Qn(e)}.txt`,o="text/plain";break;default:throw new Error(`Unsupported format: ${n}`)}wu(i,s,o)}function Qn(e){return e.replace(/[^a-z0-9-_\s]/gi,"").replace(/\s+/g,"-").toLowerCase().slice(0,50)||"conversation"}function wu(e,t,n){const r=new Blob([e],{type:n}),i=URL.createObjectURL(r),s=document.createElement("a");s.href=i,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(i)}function Su({open:e,onOpenChange:t,sessionTitle:n,onSave:r,onCancel:i}){return h.jsx(Qs,{open:e,onOpenChange:t,children:h.jsx(Js,{children:h.jsxs("div",{className:"p-4",children:[h.jsx(Zs,{className:"mb-1",children:"Rename"}),h.jsx(Nl,{className:"mb-4",children:"Enter a new name for this session."}),h.jsx("input",{type:"text",defaultValue:n,onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),r(s.currentTarget.value))},className:"w-full rounded-lg border border-primary-200 bg-primary-50 px-3 py-2 text-sm text-primary-900 outline-none focus:border-primary-400",placeholder:"Session name",autoFocus:!0}),h.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[h.jsx(eo,{onClick:i,children:"Cancel"}),h.jsx(Ce,{onClick:s=>{const o=s.currentTarget.parentElement?.previousElementSibling;r(o.value)},children:"Save"})]})]})})})}function Cu(e){const{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:s,actionsRef:o,handle:a,triggerId:l,defaultTriggerId:u=null}=e,c=Dl(),f=!!c,d=cl(()=>a?.store??new Ml({open:n??r,activeTriggerId:l!==void 0?l:u,modal:!0,disablePointerDismissal:!0,nested:f,role:"alertdialog"})).current;d.useControlledProp("open",n,r),d.useControlledProp("activeTriggerId",l,u),d.useSyncedValue("nested",f),d.useContextCallback("onOpenChange",i),d.useContextCallback("onOpenChangeComplete",s);const p=d.useState("payload");Ll({store:d,actionsRef:o,parentContext:c?.store.context});const g=m.useMemo(()=>({store:d}),[d]);return h.jsx(zl.Provider,{value:g,children:typeof t=="function"?t({payload:p}):t})}function vu({children:e,...t}){return h.jsx(Cu,{...t,children:e})}function Eu({className:e,children:t}){return h.jsxs(Pl,{children:[h.jsx(_l,{className:"fixed inset-0 bg-primary-950/20 transition-all duration-150 data-[state=open]:opacity-100 data-[state=closed]:opacity-0"}),h.jsx(Ol,{className:W("fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2","w-[min(400px,92vw)] rounded-xl border border-primary-200 bg-primary-50 p-0 shadow-xl","transition-all duration-150","data-[state=open]:opacity-100 data-[state=closed]:opacity-0","data-[state=open]:scale-100 data-[state=closed]:scale-95",e),children:t})]})}function Tu({className:e,...t}){return h.jsx(Fl,{className:W("text-lg font-medium text-primary-900",e),...t})}function ju({className:e,...t}){return h.jsx($l,{className:W("text-sm text-primary-600",e),...t})}function Au({className:e,...t}){return h.jsx(to,{render:h.jsx(Ce,{variant:"outline",className:W(e)}),...t})}function Iu({className:e,...t}){return h.jsx(to,{render:h.jsx(Ce,{variant:"destructive",className:W(e)}),...t})}function Ru({open:e,onOpenChange:t,sessionTitle:n,onConfirm:r,onCancel:i}){return h.jsx(vu,{open:e,onOpenChange:t,children:h.jsx(Eu,{children:h.jsxs("div",{className:"p-4",children:[h.jsx(Tu,{className:"mb-1",children:"Delete Session"}),h.jsxs(ju,{className:"mb-4",children:['Are you sure you want to delete "',n,'"? This action cannot be undone.']}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx(Au,{onClick:i,children:"Cancel"}),h.jsx(Iu,{onClick:r,children:"Delete"})]})]})})})}function Nu(e){const{open:t,defaultOpen:n,onOpenChange:r,disabled:i}=e,s=t!==void 0,[o,a]=Hl({controlled:t,default:n,name:"Collapsible",state:"open"}),{mounted:l,setMounted:u,transitionStatus:c}=Za(o,!0,!0),[f,d]=m.useState(o),[{height:p,width:g},y]=m.useState({height:void 0,width:void 0}),w=Bs(),[k,C]=m.useState(),E=k??w,[N,M]=m.useState(!1),[S,O]=m.useState(!1),H=m.useRef(null),_=m.useRef(null),v=m.useRef(null),D=m.useRef(null),A=el(D,!1),F=dt(T=>{const j=!o,R=Hs(tl,T.nativeEvent);if(r(j,R),R.isCanceled)return;const $=D.current;_.current==="css-animation"&&$!=null&&$.style.removeProperty("animation-name"),!N&&!S&&(_.current!=null&&_.current!=="css-animation"&&!l&&j&&u(!0),_.current==="css-animation"&&(!f&&j&&d(!0),!l&&j&&u(!0))),a(j),_.current==="none"&&l&&!j&&u(!1)});return Qe(()=>{s&&_.current==="none"&&!S&&!o&&u(!1)},[s,S,o,t,u]),m.useMemo(()=>({abortControllerRef:H,animationTypeRef:_,disabled:i,handleTrigger:F,height:p,mounted:l,open:o,panelId:E,panelRef:D,runOnceAnimationsFinish:A,setDimensions:y,setHiddenUntilFound:M,setKeepMounted:O,setMounted:u,setOpen:a,setPanelIdState:C,setVisible:d,transitionDimensionRef:v,transitionStatus:c,visible:f,width:g}),[H,_,i,F,p,l,o,E,D,A,y,M,O,u,a,d,v,c,f,g])}const so=m.createContext(void 0);function oo(){const e=m.useContext(so);if(e===void 0)throw new Error(Or(15));return e}let tn=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=Ei.startingStyle]="startingStyle",e[e.endingStyle=Ei.endingStyle]="endingStyle",e})({}),Du=(function(e){return e.panelOpen="data-panel-open",e})({});const Mu={[tn.open]:""},Lu={[tn.closed]:""},zu={open(e){return e?{[Du.panelOpen]:""}:null}},Pu={open(e){return e?Mu:Lu}},ao={...Pu,...Us},_u=m.forwardRef(function(t,n){const{render:r,className:i,defaultOpen:s=!1,disabled:o=!1,onOpenChange:a,open:l,...u}=t,c=dt(a),f=Nu({open:l,defaultOpen:s,onOpenChange:c,disabled:o}),d=m.useMemo(()=>({open:f.open,disabled:f.disabled,transitionStatus:f.transitionStatus}),[f.open,f.disabled,f.transitionStatus]),p=m.useMemo(()=>({...f,onOpenChange:c,state:d}),[f,c,d]),g=gt("div",t,{state:d,ref:n,props:u,stateAttributesMapping:ao});return h.jsx(so.Provider,{value:p,children:g})}),Ou={...zu,...Us},Fu=m.forwardRef(function(t,n){const{panelId:r,open:i,handleTrigger:s,state:o,disabled:a}=oo(),{className:l,disabled:u=a,id:c,render:f,nativeButton:d=!0,...p}=t,{getButtonProps:g,buttonRef:y}=nl({disabled:u,focusableWhenDisabled:!0,native:d}),w=m.useMemo(()=>({"aria-controls":i?r:void 0,"aria-expanded":i,onClick:s}),[r,i,s]);return gt("button",t,{state:o,ref:[n,y],props:[w,p,g],stateAttributesMapping:Ou})});let $u=(function(e){return e.disabled="data-disabled",e.orientation="data-orientation",e})({});function Bu(e){const{abortControllerRef:t,animationTypeRef:n,externalRef:r,height:i,hiddenUntilFound:s,keepMounted:o,id:a,mounted:l,onOpenChange:u,open:c,panelRef:f,runOnceAnimationsFinish:d,setDimensions:p,setMounted:g,setOpen:y,setVisible:w,transitionDimensionRef:k,visible:C,width:E}=e,N=m.useRef(!1),M=m.useRef(null),S=m.useRef(c),O=m.useRef(c),H=rl(),_=m.useMemo(()=>n.current==="css-animation"?!C:!c&&!l,[c,l,C,n]),v=dt(A=>{if(!A)return;if(n.current==null||k.current==null){const j=getComputedStyle(A),R=j.animationName!=="none"&&j.animationName!=="",$=j.transitionDuration!=="0s"&&j.transitionDuration!=="";R&&$||(j.animationName==="none"&&j.transitionDuration!=="0s"?n.current="css-transition":j.animationName!=="none"&&j.transitionDuration==="0s"?n.current="css-animation":n.current="none"),A.getAttribute($u.orientation)==="horizontal"||j.transitionProperty.indexOf("width")>-1?k.current="width":k.current="height"}if(n.current!=="css-transition")return;(i===void 0||E===void 0)&&(p({height:A.scrollHeight,width:A.scrollWidth}),O.current&&A.style.setProperty("transition-duration","0s"));let F=-1,T=-1;return F=Be.request(()=>{O.current=!1,T=Be.request(()=>{setTimeout(()=>{A.style.removeProperty("transition-duration")})})}),()=>{Be.cancel(F),Be.cancel(T)}}),D=fl(r,f,v);return Qe(()=>{if(n.current!=="css-transition")return;const A=f.current;if(!A)return;let F=-1;if(t.current!=null&&(t.current.abort(),t.current=null),c){const T={"justify-content":A.style.justifyContent,"align-items":A.style.alignItems,"align-content":A.style.alignContent,"justify-items":A.style.justifyItems};Object.keys(T).forEach(j=>{A.style.setProperty(j,"initial","important")}),!O.current&&!o&&A.setAttribute(tn.startingStyle,""),p({height:A.scrollHeight,width:A.scrollWidth}),F=Be.request(()=>{Object.entries(T).forEach(([j,R])=>{R===""?A.style.removeProperty(j):A.style.setProperty(j,R)})})}else{if(A.scrollHeight===0&&A.scrollWidth===0)return;p({height:A.scrollHeight,width:A.scrollWidth});const T=new AbortController;t.current=T;const j=T.signal;let R=null;const $=tn.endingStyle;return R=new MutationObserver(U=>{U.some(x=>x.type==="attributes"&&x.attributeName===$)&&(R?.disconnect(),R=null,d(()=>{p({height:0,width:0}),A.style.removeProperty("content-visibility"),g(!1),t.current===T&&(t.current=null)},j))}),R.observe(A,{attributes:!0,attributeFilter:[$]}),()=>{R?.disconnect(),H.cancel(),t.current===T&&(T.abort(),t.current=null)}}return()=>{Be.cancel(F)}},[t,n,H,s,o,l,c,f,d,p,g]),Qe(()=>{if(n.current!=="css-animation")return;const A=f.current;A&&(M.current=A.style.animationName||M.current,A.style.setProperty("animation-name","none"),p({height:A.scrollHeight,width:A.scrollWidth}),!S.current&&!N.current&&A.style.removeProperty("animation-name"),c?(t.current!=null&&(t.current.abort(),t.current=null),g(!0),w(!0)):(t.current=new AbortController,d(()=>{g(!1),w(!1),t.current=null},t.current.signal)))},[t,n,c,f,d,p,g,w,C]),il(()=>{const A=Be.request(()=>{S.current=!1});return()=>Be.cancel(A)}),Qe(()=>{if(!s)return;const A=f.current;if(!A)return;let F=-1,T=-1;return c&&N.current&&(A.style.transitionDuration="0s",p({height:A.scrollHeight,width:A.scrollWidth}),F=Be.request(()=>{N.current=!1,T=Be.request(()=>{setTimeout(()=>{A.style.removeProperty("transition-duration")})})})),()=>{Be.cancel(F),Be.cancel(T)}},[s,c,f,p]),Qe(()=>{const A=f.current;A&&s&&_&&(A.setAttribute("hidden","until-found"),n.current==="css-transition"&&A.setAttribute(tn.startingStyle,""))},[s,_,n,f]),m.useEffect(function(){const F=f.current;if(!F)return;function T(j){N.current=!0,y(!0),u(!0,Hs(sl,j))}return F.addEventListener("beforematch",T),()=>{F.removeEventListener("beforematch",T)}},[u,f,y]),m.useMemo(()=>({props:{hidden:_,id:a,ref:D}}),[_,a,D])}let Ni=(function(e){return e.collapsiblePanelHeight="--collapsible-panel-height",e.collapsiblePanelWidth="--collapsible-panel-width",e})({});const Hu=m.forwardRef(function(t,n){const{className:r,hiddenUntilFound:i,keepMounted:s,render:o,id:a,...l}=t,{abortControllerRef:u,animationTypeRef:c,height:f,mounted:d,onOpenChange:p,open:g,panelId:y,panelRef:w,runOnceAnimationsFinish:k,setDimensions:C,setHiddenUntilFound:E,setKeepMounted:N,setMounted:M,setPanelIdState:S,setOpen:O,setVisible:H,state:_,transitionDimensionRef:v,visible:D,width:A,transitionStatus:F}=oo(),T=i??!1,j=s??!1;Qe(()=>{if(a)return S(a),()=>{S(void 0)}},[a,S]),Qe(()=>{E(T)},[E,T]),Qe(()=>{N(j)},[N,j]);const{props:R}=Bu({abortControllerRef:u,animationTypeRef:c,externalRef:n,height:f,hiddenUntilFound:T,id:y,keepMounted:j,mounted:d,onOpenChange:p,open:g,panelRef:w,runOnceAnimationsFinish:k,setDimensions:C,setMounted:M,setOpen:O,setVisible:H,transitionDimensionRef:v,visible:D,width:A});ol({open:g&&F==="idle",ref:w,onComplete(){g&&C({height:void 0,width:void 0})}});const $=m.useMemo(()=>({..._,transitionStatus:F}),[_,F]),U=gt("div",t,{state:$,ref:[n,w],props:[R,{style:{[Ni.collapsiblePanelHeight]:f===void 0?"auto":`${f}px`,[Ni.collapsiblePanelWidth]:A===void 0?"auto":`${A}px`}},l],stateAttributesMapping:ao});return j||T||!j&&d?U:null});function vn(e){return h.jsx(_u,{...e})}function En({className:e,...t}){return h.jsx(Fu,{className:W("group inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-left text-xs font-medium text-primary-500 transition-colors hover:bg-primary-100 hover:text-primary-700 data-panel-open:text-primary-700",e),...t})}function Tn({className:e,contentClassName:t,children:n,...r}){return h.jsx(Hu,{className:W('flex h-(--collapsible-panel-height) flex-col overflow-hidden text-sm transition-all duration-150 ease-out data-ending-style:h-0 data-starting-style:h-0 [&[hidden]:not([hidden="until-found"])]:hidden',e),...r,children:h.jsx("div",{className:W("pt-1",t),children:n})})}const lo=m.createContext(void 0);function Fn(){const e=m.useContext(lo);if(e===void 0)throw new Error(Or(53));return e}let jn=(function(e){return e.scrollAreaCornerHeight="--scroll-area-corner-height",e.scrollAreaCornerWidth="--scroll-area-corner-width",e})({});const hn=500,Di=16;function qe(e,t,n){if(!e)return 0;const r=getComputedStyle(e),i=n==="x"?"Inline":"Block";return n==="x"&&t==="margin"?parseFloat(r[`${t}InlineStart`])*2:parseFloat(r[`${t}${i}Start`])+parseFloat(r[`${t}${i}End`])}let Uu=(function(e){return e.orientation="data-orientation",e.hovering="data-hovering",e.scrolling="data-scrolling",e.hasOverflowX="data-has-overflow-x",e.hasOverflowY="data-has-overflow-y",e.overflowXStart="data-overflow-x-start",e.overflowXEnd="data-overflow-x-end",e.overflowYStart="data-overflow-y-start",e.overflowYEnd="data-overflow-y-end",e})({});const pn="base-ui-disable-scrollbar",uo={className:pn,getElement(e){return h.jsx("style",{nonce:e,href:pn,precedence:"base-ui:low",children:`.${pn}{scrollbar-width:none}.${pn}::-webkit-scrollbar{display:none}`})}};let zt=(function(e){return e.hasOverflowX="data-has-overflow-x",e.hasOverflowY="data-has-overflow-y",e.overflowXStart="data-overflow-x-start",e.overflowXEnd="data-overflow-x-end",e.overflowYStart="data-overflow-y-start",e.overflowYEnd="data-overflow-y-end",e})({});const Kr={hasOverflowX:e=>e?{[zt.hasOverflowX]:""}:null,hasOverflowY:e=>e?{[zt.hasOverflowY]:""}:null,overflowXStart:e=>e?{[zt.overflowXStart]:""}:null,overflowXEnd:e=>e?{[zt.overflowXEnd]:""}:null,overflowYStart:e=>e?{[zt.overflowYStart]:""}:null,overflowYEnd:e=>e?{[zt.overflowYEnd]:""}:null,cornerHidden:()=>null},qu=m.createContext(void 0),Wu={disableStyleElements:!1};function Ku(){return m.useContext(qu)??Wu}const Vu={x:0,y:0},Mi={width:0,height:0},Xu={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},Yu={x:!1,y:!1,corner:!1},Gu=m.forwardRef(function(t,n){const{render:r,className:i,overflowEdgeThreshold:s,...o}=t,a=Qu(s),l=Bs(),u=Sn(),c=Sn(),{nonce:f,disableStyleElements:d}=Ku(),[p,g]=m.useState(!1),[y,w]=m.useState(!1),[k,C]=m.useState(!1),[E,N]=m.useState(!1),[M,S]=m.useState(Mi),[O,H]=m.useState(Mi),[_,v]=m.useState(Xu),[D,A]=m.useState(Yu),F=m.useRef(null),T=m.useRef(null),j=m.useRef(null),R=m.useRef(null),$=m.useRef(null),U=m.useRef(null),L=m.useRef(null),x=m.useRef(!1),q=m.useRef(0),V=m.useRef(0),b=m.useRef(0),ee=m.useRef(0),Q=m.useRef("vertical"),G=m.useRef(Vu),de=dt(z=>{const ge=z.x-G.current.x,Z=z.y-G.current.y;G.current=z,Z!==0&&(C(!0),u.start(hn,()=>{C(!1)})),ge!==0&&(w(!0),c.start(hn,()=>{w(!1)}))}),he=dt(z=>{z.button===0&&(x.current=!0,q.current=z.clientY,V.current=z.clientX,Q.current=z.currentTarget.getAttribute(Uu.orientation),T.current&&(b.current=T.current.scrollTop,ee.current=T.current.scrollLeft),$.current&&Q.current==="vertical"&&$.current.setPointerCapture(z.pointerId),U.current&&Q.current==="horizontal"&&U.current.setPointerCapture(z.pointerId))}),se=dt(z=>{if(!x.current)return;const ge=z.clientY-q.current,Z=z.clientX-V.current;if(T.current){const be=T.current.scrollHeight,We=T.current.clientHeight,Se=T.current.scrollWidth,Ke=T.current.clientWidth;if($.current&&j.current&&Q.current==="vertical"){const et=qe(j.current,"padding","y"),st=qe($.current,"margin","y"),I=$.current.offsetHeight,P=j.current.offsetHeight-I-et-st,X=ge/P;T.current.scrollTop=b.current+X*(be-We),z.preventDefault(),C(!0),u.start(hn,()=>{C(!1)})}if(U.current&&R.current&&Q.current==="horizontal"){const et=qe(R.current,"padding","x"),st=qe(U.current,"margin","x"),I=U.current.offsetWidth,P=R.current.offsetWidth-I-et-st,X=Z/P;T.current.scrollLeft=ee.current+X*(Se-Ke),z.preventDefault(),w(!0),c.start(hn,()=>{w(!1)})}}}),oe=dt(z=>{x.current=!1,$.current&&Q.current==="vertical"&&$.current.releasePointerCapture(z.pointerId),U.current&&Q.current==="horizontal"&&U.current.releasePointerCapture(z.pointerId)});function me(z){N(z.pointerType==="touch")}function Te(z){if(me(z),z.pointerType!=="touch"){const ge=al(F.current,z.target);g(ge)}}const xe=m.useMemo(()=>({hasOverflowX:!D.x,hasOverflowY:!D.y,overflowXStart:_.xStart,overflowXEnd:_.xEnd,overflowYStart:_.yStart,overflowYEnd:_.yEnd,cornerHidden:D.corner}),[D.x,D.y,D.corner,_]),De={role:"presentation",onPointerEnter:Te,onPointerMove:Te,onPointerDown:me,onPointerLeave(){g(!1)},style:{position:"relative",[jn.scrollAreaCornerHeight]:`${M.height}px`,[jn.scrollAreaCornerWidth]:`${M.width}px`}},K=gt("div",t,{state:xe,ref:[n,F],props:[De,o],stateAttributesMapping:Kr}),te=m.useMemo(()=>({handlePointerDown:he,handlePointerMove:se,handlePointerUp:oe,handleScroll:de,cornerSize:M,setCornerSize:S,thumbSize:O,setThumbSize:H,touchModality:E,cornerRef:L,scrollingX:y,setScrollingX:w,scrollingY:k,setScrollingY:C,hovering:p,setHovering:g,viewportRef:T,rootRef:F,scrollbarYRef:j,scrollbarXRef:R,thumbYRef:$,thumbXRef:U,rootId:l,hiddenState:D,setHiddenState:A,overflowEdges:_,setOverflowEdges:v,viewportState:xe,overflowEdgeThreshold:a}),[he,se,oe,de,M,O,E,y,w,k,C,p,g,l,D,_,xe,a]);return h.jsxs(lo.Provider,{value:te,children:[!d&&uo.getElement(f),K]})});function Qu(e){if(typeof e=="number"){const t=Math.max(0,e);return{xStart:t,xEnd:t,yStart:t,yEnd:t}}return{xStart:Math.max(0,e?.xStart||0),xEnd:Math.max(0,e?.xEnd||0),yStart:Math.max(0,e?.yStart||0),yEnd:Math.max(0,e?.yEnd||0)}}const Ju=m.createContext(void 0);function at(e,t=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER){return Math.max(t,Math.min(e,n))}function Zu(e,t){if(typeof IntersectionObserver>"u")return()=>{};const n=new IntersectionObserver(r=>{r.forEach(i=>{i.intersectionRatio>0&&(t(),n.disconnect())})});return n.observe(e),()=>{n.disconnect()}}let mt=(function(e){return e.scrollAreaOverflowXStart="--scroll-area-overflow-x-start",e.scrollAreaOverflowXEnd="--scroll-area-overflow-x-end",e.scrollAreaOverflowYStart="--scroll-area-overflow-y-start",e.scrollAreaOverflowYEnd="--scroll-area-overflow-y-end",e})({}),Li=!1;function ec(){Li||ll||(typeof CSS<"u"&&"registerProperty"in CSS&&[mt.scrollAreaOverflowXStart,mt.scrollAreaOverflowXEnd,mt.scrollAreaOverflowYStart,mt.scrollAreaOverflowYEnd].forEach(e=>{try{CSS.registerProperty({name:e,syntax:"<length>",inherits:!1,initialValue:"0px"})}catch{}}),Li=!0)}const tc=m.forwardRef(function(t,n){const{render:r,className:i,...s}=t,{viewportRef:o,scrollbarYRef:a,scrollbarXRef:l,thumbYRef:u,thumbXRef:c,cornerRef:f,cornerSize:d,setCornerSize:p,setThumbSize:g,rootId:y,setHiddenState:w,hiddenState:k,handleScroll:C,setHovering:E,setOverflowEdges:N,overflowEdges:M,overflowEdgeThreshold:S}=Fn(),O=qs(),H=m.useRef(!0),_=Sn(),v=Sn(),D=dt(()=>{const $=o.current,U=a.current,L=l.current,x=u.current,q=c.current,V=f.current;if(!$)return;const b=$.scrollHeight,ee=$.scrollWidth,Q=$.clientHeight,G=$.clientWidth,de=$.scrollTop,he=$.scrollLeft;if(b===0||ee===0)return;const se=Q>=b,oe=G>=ee,me=G/ee,Te=Q/b,xe=Math.max(0,ee-G),De=Math.max(0,b-Q);let K=0,te=0;oe||(O==="rtl"?K=at(-he,0,xe):K=at(he,0,xe),te=xe-K);const z=se?0:at(de,0,De),ge=se?0:De-z,Z=oe?0:G,be=se?0:Q;let We=0,Se=0;!oe&&!se&&(We=U?.offsetWidth||0,Se=L?.offsetHeight||0);const Ke=d.width===0&&d.height===0,et=Ke?We:0,st=Ke?Se:0,I=qe(L,"padding","x"),P=qe(U,"padding","y"),X=qe(q,"margin","x"),ne=qe(x,"margin","y"),le=Z-I-X,ve=be-P-ne,Ve=L?Math.min(L.offsetWidth-et,le):le,ze=U?Math.min(U.offsetHeight-st,ve):ve,Fe=Math.max(Di,Ve*me),$e=Math.max(Di,ze*Te);if(g(ce=>ce.height===$e&&ce.width===Fe?ce:{width:Fe,height:$e}),U&&x){const ce=U.offsetHeight-$e-P-ne,Pe=b-Q,ot=Pe===0?0:de/Pe,kt=Math.min(ce,Math.max(0,ot*ce));x.style.transform=`translate3d(0,${kt}px,0)`}if(L&&q){const ce=L.offsetWidth-Fe-I-X,Pe=ee-G,ot=Pe===0?0:he/Pe,kt=O==="rtl"?at(ot*ce,-ce,0):at(ot*ce,0,ce);q.style.transform=`translate3d(${kt}px,0,0)`}const ye=at(K,0,xe),Xe=at(te,0,xe),Ee=at(z,0,De),yt=at(ge,0,De),Vn=[[mt.scrollAreaOverflowXStart,ye],[mt.scrollAreaOverflowXEnd,Xe],[mt.scrollAreaOverflowYStart,Ee],[mt.scrollAreaOverflowYEnd,yt]];for(const[ce,Pe]of Vn)$.style.setProperty(ce,`${Pe}px`);V&&(oe||se?p({width:0,height:0}):!oe&&!se&&p({width:We,height:Se})),w(ce=>{const Pe=se||oe;return ce.y===se&&ce.x===oe&&ce.corner===Pe?ce:{y:se,x:oe,corner:Pe}});const bt={xStart:!oe&&ye>S.xStart,xEnd:!oe&&Xe>S.xEnd,yStart:!se&&Ee>S.yStart,yEnd:!se&&yt>S.yEnd};N(ce=>ce.xStart===bt.xStart&&ce.xEnd===bt.xEnd&&ce.yStart===bt.yStart&&ce.yEnd===bt.yEnd?ce:bt)});Qe(()=>{if(!o.current)return;ec();let $=!1;return Zu(o.current,()=>{if(!$){$=!0;return}D()})},[D,o]),Qe(()=>{queueMicrotask(D)},[D,k,O]),Qe(()=>{o.current?.matches(":hover")&&E(!0)},[o,E]),m.useEffect(()=>{const $=o.current;if(typeof ResizeObserver>"u"||!$)return;let U=!1;const L=new ResizeObserver(()=>{if(!U){U=!0;return}D()});return L.observe($),v.start(0,()=>{const x=$.getAnimations({subtree:!0});x.length!==0&&Promise.all(x.map(q=>q.finished)).then(D).catch(()=>{})}),()=>{L.disconnect(),v.clear()}},[D,o,v]);function A(){H.current=!1}const F={role:"presentation",...y&&{"data-id":`${y}-viewport`},...(!k.x||!k.y)&&{tabIndex:0},className:uo.className,style:{overflow:"scroll"},onScroll(){o.current&&(D(),H.current||C({x:o.current.scrollLeft,y:o.current.scrollTop}),_.start(100,()=>{H.current=!0}))},onWheel:A,onTouchMove:A,onPointerMove:A,onPointerEnter:A,onKeyDown:A},T=m.useMemo(()=>({hasOverflowX:!k.x,hasOverflowY:!k.y,overflowXStart:M.xStart,overflowXEnd:M.xEnd,overflowYStart:M.yStart,overflowYEnd:M.yEnd,cornerHidden:k.corner}),[k.x,k.y,k.corner,M]),j=gt("div",t,{ref:[n,o],state:T,props:[F,s],stateAttributesMapping:Kr}),R=m.useMemo(()=>({computeThumbPosition:D}),[D]);return h.jsx(Ju.Provider,{value:R,children:j})}),co=m.createContext(void 0);function nc(){const e=m.useContext(co);if(e===void 0)throw new Error(Or(54));return e}let An=(function(e){return e.scrollAreaThumbHeight="--scroll-area-thumb-height",e.scrollAreaThumbWidth="--scroll-area-thumb-width",e})({});const rc=m.forwardRef(function(t,n){const{render:r,className:i,orientation:s="vertical",keepMounted:o=!1,...a}=t,{hovering:l,scrollingX:u,scrollingY:c,hiddenState:f,overflowEdges:d,scrollbarYRef:p,scrollbarXRef:g,viewportRef:y,thumbYRef:w,thumbXRef:k,handlePointerDown:C,handlePointerUp:E,rootId:N,thumbSize:M}=Fn(),S=m.useMemo(()=>({hovering:l,scrolling:{horizontal:u,vertical:c}[s],orientation:s,hasOverflowX:!f.x,hasOverflowY:!f.y,overflowXStart:d.xStart,overflowXEnd:d.xEnd,overflowYStart:d.yStart,overflowYEnd:d.yEnd,cornerHidden:f.corner}),[l,u,c,s,f,d]),O=qs();m.useEffect(()=>{const F=y.current,T=s==="vertical"?p.current:g.current;if(!T)return;function j(R){if(!(!F||!T||R.ctrlKey)){if(R.preventDefault(),s==="vertical"){if(F.scrollTop===0&&R.deltaY<0)return}else if(F.scrollLeft===0&&R.deltaX<0)return;if(s==="vertical"){if(F.scrollTop===F.scrollHeight-F.clientHeight&&R.deltaY>0)return}else if(F.scrollLeft===F.scrollWidth-F.clientWidth&&R.deltaX>0)return;s==="vertical"?F.scrollTop+=R.deltaY:F.scrollLeft+=R.deltaX}}return T.addEventListener("wheel",j,{passive:!1}),()=>{T.removeEventListener("wheel",j)}},[s,g,p,y]);const H={...N&&{"data-id":`${N}-scrollbar`},onPointerDown(F){if(F.button===0&&F.currentTarget===F.target&&y.current){if(w.current&&p.current&&s==="vertical"){const T=qe(w.current,"margin","y"),j=qe(p.current,"padding","y"),R=w.current.offsetHeight,$=p.current.getBoundingClientRect(),U=F.clientY-$.top-R/2-j+T/2,L=y.current.scrollHeight,x=y.current.clientHeight,q=p.current.offsetHeight-R-j-T,b=U/q*(L-x);y.current.scrollTop=b}if(k.current&&g.current&&s==="horizontal"){const T=qe(k.current,"margin","x"),j=qe(g.current,"padding","x"),R=k.current.offsetWidth,$=g.current.getBoundingClientRect(),U=F.clientX-$.left-R/2-j+T/2,L=y.current.scrollWidth,x=y.current.clientWidth,q=g.current.offsetWidth-R-j-T,V=U/q;let b;O==="rtl"?(b=(1-V)*(L-x),y.current.scrollLeft<=0&&(b=-b)):b=V*(L-x),y.current.scrollLeft=b}C(F)}},onPointerUp:E,style:{position:"absolute",touchAction:"none",WebkitUserSelect:"none",userSelect:"none",...s==="vertical"&&{top:0,bottom:`var(${jn.scrollAreaCornerHeight})`,insetInlineEnd:0,[An.scrollAreaThumbHeight]:`${M.height}px`},...s==="horizontal"&&{insetInlineStart:0,insetInlineEnd:`var(${jn.scrollAreaCornerWidth})`,bottom:0,[An.scrollAreaThumbWidth]:`${M.width}px`}}},_=gt("div",t,{ref:[n,s==="vertical"?p:g],state:S,props:[H,a],stateAttributesMapping:Kr}),v=m.useMemo(()=>({orientation:s}),[s]),D=s==="vertical"?f.y:f.x;return o||!D?h.jsx(co.Provider,{value:v,children:_}):null}),ic=m.forwardRef(function(t,n){const{render:r,className:i,...s}=t,{thumbYRef:o,thumbXRef:a,handlePointerDown:l,handlePointerMove:u,handlePointerUp:c,setScrollingX:f,setScrollingY:d}=Fn(),{orientation:p}=nc(),g=m.useMemo(()=>({orientation:p}),[p]);return gt("div",t,{ref:[n,p==="vertical"?o:a],state:g,props:[{onPointerDown:l,onPointerMove:u,onPointerUp(w){p==="vertical"&&d(!1),p==="horizontal"&&f(!1),c(w)},style:{...p==="vertical"&&{height:`var(${An.scrollAreaThumbHeight})`},...p==="horizontal"&&{width:`var(${An.scrollAreaThumbWidth})`}}},s]})}),sc=m.forwardRef(function(t,n){const{render:r,className:i,...s}=t,{cornerRef:o,cornerSize:a,hiddenState:l}=Fn(),u=gt("div",t,{ref:[n,o],props:[{style:{position:"absolute",bottom:0,insetInlineEnd:0,width:a.width,height:a.height}},s]});return l.corner?null:u});function fo({className:e,...t}){return h.jsx(Gu,{className:W("group/scroll-area relative outline-none focus-visible:outline-none",e),...t})}function ho({className:e,...t}){return h.jsx(tc,{className:W("h-full w-full outline-none focus-visible:outline-none",e),...t})}function po({className:e,...t}){return h.jsx(rc,{className:W("flex w-2 touch-none select-none p-0.5 outline-none focus-visible:outline-none","opacity-0 transition-opacity duration-150","data-hovering:opacity-100 data-scrolling:opacity-100 group-hover/scroll-area:opacity-100",e),...t})}function mo({className:e,...t}){return h.jsx(ic,{className:W("flex-1 rounded-full bg-primary-500 outline-none focus-visible:outline-none",e),...t})}function oc({className:e,...t}){return h.jsx(sc,{className:W("bg-primary-100 outline-none focus-visible:outline-none",e),...t})}function ac(e){return e==="subagent"?ml:e==="cron"?gl:xl}function lc(e){return!e||!Array.isArray(e.content)?"":e.content.map(n=>n.type==="text"?String(n.text??""):"").join(" ").replace(/\s+/g," ").trim()}function uc(e){if(typeof e=="number"&&Number.isFinite(e))return e<1e12?e*1e3:e;if(typeof e=="string"){const t=Date.parse(e);if(!Number.isNaN(t))return t}return null}function cc(e){if(!e)return null;const t=[e.createdAt,e.created_at,e.timestamp,e.time,e.ts];for(const n of t){const r=uc(n);if(r)return r}return null}function fc(e){const t=e-Date.now(),n=Math.abs(t),r=[["minute",6e4],["hour",36e5],["day",864e5]];let i="minute",s=6e4;n>=r[2][1]?[i,s]=r[2]:n>=r[1][1]&&([i,s]=r[1]);const o=Math.round(t/s);return new Intl.RelativeTimeFormat("en",{numeric:"auto"}).format(o,i)}function hc(e){const t=String(e??"").toLowerCase().trim();return t?t==="error"||t==="failed"?"error":t==="completed"||t==="ended"||t==="done"?"success":null:null}function pc({session:e,active:t,isGenerating:n=!1,isPinned:r,selectionMode:i=!1,selected:s=!1,onToggleSelect:o,onSelect:a,onTogglePin:l,onRename:u,onDelete:c,onExport:f}){const d=e.label||e.title||e.derivedTitle||e.friendlyId,p=ac(e.kind),g=e.kind==="subagent"&&(e.lastMessage?.role==="assistant"||e.lastMessage?.role==="toolResult")?lc(e.lastMessage):"",y=g.length>50?`${g.slice(0,50).trimEnd()}…`:g,w=e.kind==="subagent"?hc(e.status):null,k=e.kind==="cron"?cc(e.lastMessage):null;return h.jsxs(en,{to:"/chat/$sessionKey",params:{sessionKey:e.friendlyId},onClick:C=>{if(i){C.preventDefault(),C.stopPropagation(),o?.(e);return}a?.()},className:W("group inline-flex items-center justify-between","w-full text-left pl-1.5 pr-0.5 min-h-8 py-1 rounded-lg transition-colors duration-0","select-none",t?"bg-primary-200 text-primary-950":"bg-transparent text-primary-950 [&:hover:not(:has(button:hover))]:bg-primary-200"),children:[h.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[i?h.jsx("span",{"aria-hidden":"true",className:W("inline-flex items-center justify-center size-4 shrink-0 rounded border transition-colors",s?"bg-primary-700 border-primary-700 text-white":"border-primary-300 bg-surface"),children:s?h.jsx("svg",{viewBox:"0 0 12 12",className:"size-3",fill:"none",stroke:"currentColor",strokeWidth:2,children:h.jsx("path",{d:"M2.5 6l2.5 2.5 4.5-5"})}):null}):null,h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[h.jsx(re,{icon:p,size:12,strokeWidth:1.75,className:"text-primary-500/70 shrink-0"}),h.jsxs("div",{className:"text-sm font-[450] line-clamp-1 min-w-0",children:[r?h.jsx("span",{className:"mr-1 text-xs text-primary-700","aria-hidden":"true",children:"📌"}):null,d]}),e.kind==="subagent"?n?h.jsx("span",{"aria-label":"Session active",className:"size-1.5 rounded-full bg-green-500 shrink-0"}):w==="success"?h.jsx(re,{icon:Ws,size:12,strokeWidth:1.8,className:"text-green-600/80 shrink-0"}):w==="error"?h.jsx(re,{icon:On,size:12,strokeWidth:1.8,className:"text-red-600/80 shrink-0"}):null:null]}),y?h.jsx("div",{className:"text-[11px] text-primary-600/80 line-clamp-1 mt-0.5 pl-[18px]",children:y}):null,e.kind==="cron"&&k?h.jsx("div",{className:"text-[10px] text-primary-500/75 line-clamp-1 mt-0.5 pl-[18px] font-mono",children:fc(k)}):null]})]}),i?null:h.jsxs(Br,{children:[h.jsx(Hr,{type:"button",onClick:C=>{C.preventDefault(),C.stopPropagation()},className:W("ml-2 inline-flex size-7 items-center justify-center rounded-md text-primary-700","opacity-0 transition-opacity group-hover:opacity-100 hover:bg-primary-200","aria-expanded:opacity-100 aria-expanded:bg-primary-200"),children:h.jsx(re,{icon:hl,size:20,strokeWidth:1.5})}),h.jsxs(Ur,{side:"bottom",align:"end",children:[h.jsxs(Et,{onClick:C=>{C.preventDefault(),C.stopPropagation(),l(e)},className:"gap-2",children:[h.jsx("span",{className:"text-xs","aria-hidden":"true",children:"📌"})," ",r?"Unpin Session":"Pin Session"]}),h.jsxs(Et,{onClick:C=>{C.preventDefault(),C.stopPropagation(),u(e)},className:"gap-2",children:[h.jsx(re,{icon:pl,size:20,strokeWidth:1.5})," ","Rename"]}),h.jsxs(Et,{onClick:C=>{C.preventDefault(),C.stopPropagation(),f(e)},className:"gap-2",children:[h.jsx(re,{icon:dl,size:20,strokeWidth:1.5})," ","Export"]}),Cr(e.key)?null:h.jsxs(Et,{onClick:C=>{C.preventDefault(),C.stopPropagation(),c(e)},className:"text-red-700 gap-2 hover:bg-red-50/80 data-highlighted:bg-red-50/80",children:[h.jsx(re,{icon:Ks,size:20,strokeWidth:1.5})," ","Delete"]})]})]})]})}function dc(e,t){return e.active!==t.active||e.isGenerating!==t.isGenerating||e.isPinned!==t.isPinned||e.selectionMode!==t.selectionMode||e.selected!==t.selected||e.onToggleSelect!==t.onToggleSelect||e.onSelect!==t.onSelect||e.onTogglePin!==t.onTogglePin||e.onRename!==t.onRename||e.onDelete!==t.onDelete||e.onExport!==t.onExport?!1:e.session===t.session?!0:e.session.key===t.session.key&&e.session.friendlyId===t.session.friendlyId&&e.session.label===t.session.label&&e.session.title===t.session.title&&e.session.derivedTitle===t.session.derivedTitle&&e.session.updatedAt===t.session.updatedAt&&e.session.kind===t.session.kind&&e.session.status===t.session.status&&e.session.lastMessage===t.session.lastMessage}const Jn=m.memo(pc,dc),go="opencami-pinned-sessions",xo="opencami-sidebar-folders",ft={webchat:!1,subagent:!1,cron:!1,other:!1};async function mc(e){const t=new URLSearchParams;e&&t.set("sessionKey",e);const n=await fetch(`/api/sessions?${t.toString()}`,{method:"DELETE"});if(!n.ok)throw new Error(await rt(n))}async function gc(e,t,n){const r=[];let i=0;const s=Array.from({length:Math.min(t,e.length)},async function(){for(;i<e.length;){const a=i;i+=1;try{await n(e[a])}catch(l){r.push(l)}}});return await Promise.all(s),r}function xc(){if(typeof window>"u")return[];try{const e=localStorage.getItem(go);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}function yc(e){if(!(typeof window>"u"))try{const t=Array.from(new Set(e));localStorage.setItem(go,JSON.stringify(t))}catch{}}function bc(){if(typeof window>"u")return{...ft};try{const e=localStorage.getItem(xo);if(!e)return{...ft};const t=JSON.parse(e);return!t||typeof t!="object"?{...ft}:{webchat:typeof t.webchat=="boolean"?t.webchat:ft.webchat,subagent:typeof t.subagent=="boolean"?t.subagent:ft.subagent,cron:typeof t.cron=="boolean"?t.cron:ft.cron,other:typeof t.other=="boolean"?t.other:ft.other}}catch{return{...ft}}}function kc(e){if(!(typeof window>"u"))try{localStorage.setItem(xo,JSON.stringify(e))}catch{}}function bn(e,t,n){return n&&e.key?e.key===n:e.friendlyId===t}function wc(e){if(!e)return!1;const t=e.toLowerCase();return t.includes("running")||t.includes("active")||t.includes("stream")||t.includes("generat")}function Zn(e,t,n,r){return bn(e,t,n)&&r?!0:wc(e.status)}const Sc=m.memo(function({sessions:t,activeFriendlyId:n,activeSessionKey:r,isStreaming:i=!1,defaultOpen:s=!0,onSelect:o,onRename:a,onDelete:l,onExport:u}){const c=m.useDeferredValue(t),f=Ut(),[d,p]=m.useState(()=>xc()),[g,y]=m.useState(()=>bc()),[w,k]=m.useState(!1),[C,E]=m.useState(()=>new Set),N=m.useMemo(()=>new Set(d),[d]),M=c.filter(L=>N.has(L.key)),S=c.filter(L=>!N.has(L.key)),O=M.length>0&&S.length>0,H=m.useMemo(()=>{const L={chat:[],webchat:[],subagent:[],cron:[],other:[]};for(const x of S){const q=x.kind??"other";L[q].push(x)}return L},[S]),_=m.useMemo(()=>c.filter(L=>C.has(L.key)),[C,c]),v=_.length,D=m.useCallback(()=>{k(L=>(L&&E(new Set),!L))},[]),A=m.useCallback(L=>{Cr(L.key)||E(x=>{const q=new Set(x);return q.has(L.key)?q.delete(L.key):q.add(L.key),q})},[]),F=m.useCallback(()=>{E(new Set(c.filter(L=>!Cr(L.key)).map(L=>L.key)))},[c]),T=m.useCallback(()=>{k(!1),E(new Set)},[]),j=m.useCallback(async()=>{if(_.length===0||!window.confirm(`Delete ${_.length} sessions? This will archive them.`))return;const x=await gc(_.map(q=>q.key),10,mc);x.length>0&&console.error("[sidebar] Bulk delete failed for some sessions",x),k(!1),E(new Set),f.invalidateQueries({queryKey:we.sessions})},[f,_]),R=m.useCallback(L=>{p(x=>{const V=x.includes(L.key)?x.filter(b=>b!==L.key):[...x,L.key];return yc(V),V})},[]),$=m.useCallback((L,x)=>{y(q=>{const V={...q,[L]:x};return kc(V),V})},[]);function U(L,x,q){return q.length===0?null:h.jsxs(vn,{className:"flex flex-col",open:g[L],onOpenChange:V=>$(L,V),children:[h.jsxs(En,{className:W("w-full justify-between border-l-2 border-primary-200/70 px-2 py-1 text-[11px] font-medium text-primary-500/80 text-balance"),children:[h.jsx("span",{className:"truncate",children:x}),h.jsx("span",{className:W("rounded-full bg-primary-100 px-1.5 py-0.5 text-[10px] font-medium text-primary-700 tabular-nums"),children:q.length})]}),h.jsx(Tn,{contentClassName:"flex flex-col gap-px",children:q.map(V=>h.jsx(Jn,{session:V,active:bn(V,n,r),isGenerating:Zn(V,n,r,i),isPinned:!1,selectionMode:w,selected:C.has(V.key),onToggleSelect:A,onSelect:o,onTogglePin:R,onRename:a,onDelete:l,onExport:u},V.key))})]})}return h.jsxs(vn,{className:"flex h-full flex-col flex-1 min-h-0 w-full",defaultOpen:s,children:[h.jsxs("div",{className:"flex items-center justify-between pr-2 shrink-0",children:[h.jsxs(En,{className:"w-fit pl-1.5 text-balance",children:["Sessions",h.jsx("span",{className:"opacity-0 transition-opacity duration-150 group-hover:opacity-100",children:h.jsx(re,{icon:Fr,className:"size-3 transition-transform duration-150 group-data-panel-open:rotate-90"})})]}),h.jsx("button",{type:"button",onClick:D,className:W("text-[11px] font-medium px-1.5 py-0.5 rounded-md transition-colors",w?"text-primary-900 bg-primary-200":"text-primary-500 hover:text-primary-700 hover:bg-primary-100"),children:w?"Done":"Select"})]}),h.jsx(Tn,{className:"w-full flex-1 min-h-0 h-auto data-starting-style:h-0 data-ending-style:h-0",contentClassName:"flex flex-1 min-h-0 flex-col overflow-y-auto",children:h.jsxs(fo,{className:"flex-1 min-h-0",children:[h.jsx(ho,{className:"min-h-0",children:h.jsxs("div",{className:"flex flex-col gap-2 pl-2 pr-2",children:[M.length>0?h.jsx("div",{className:"flex flex-col gap-px",children:M.map(L=>h.jsx(Jn,{session:L,active:bn(L,n,r),isGenerating:Zn(L,n,r,i),isPinned:!0,selectionMode:w,selected:C.has(L.key),onToggleSelect:A,onSelect:o,onTogglePin:R,onRename:a,onDelete:l,onExport:u},L.key))}):null,O?h.jsx("div",{className:"my-1 border-t border-primary-200/80"}):null,H.chat.length>0?h.jsxs("div",{className:"flex flex-col gap-px",children:[h.jsx("div",{className:W("border-l-2 border-primary-200/70 px-2 py-1 text-[11px] font-medium text-primary-500/80 text-balance"),children:"💬 Chats"}),h.jsx("div",{className:"flex flex-col gap-px",children:H.chat.map(L=>h.jsx(Jn,{session:L,active:bn(L,n,r),isGenerating:Zn(L,n,r,i),isPinned:!1,selectionMode:w,selected:C.has(L.key),onToggleSelect:A,onSelect:o,onTogglePin:R,onRename:a,onDelete:l,onExport:u},L.key))})]}):null,U("webchat","🦎 OpenCami",H.webchat),U("subagent","🤖 Sub-agents",H.subagent),U("cron","⏰ Cron / Isolated",H.cron),U("other","📁 Other",H.other)]})}),h.jsx(po,{orientation:"vertical",children:h.jsx(mo,{})})]})}),w?h.jsxs("div",{className:"shrink-0 border-t border-primary-200 bg-surface px-2 py-2 flex flex-col gap-1.5",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("span",{className:"text-xs text-primary-600 font-medium",children:[v," selected"]}),h.jsx("button",{type:"button",onClick:F,className:"text-[11px] font-medium text-primary-600 hover:text-primary-800",children:"Select all"})]}),h.jsxs("div",{className:"flex gap-1.5",children:[h.jsxs("button",{type:"button",onClick:j,disabled:v===0,className:W("flex-1 inline-flex items-center justify-center gap-1.5 rounded-md px-2 py-1.5 text-xs font-medium transition-colors",v>0?"bg-red-100 text-red-700 hover:bg-red-200":"bg-primary-100 text-primary-400 cursor-not-allowed"),children:[h.jsx(re,{icon:Ks,size:14,strokeWidth:1.5}),"Delete"]}),h.jsx("button",{type:"button",onClick:T,className:"flex-1 inline-flex items-center justify-center rounded-md px-2 py-1.5 text-xs font-medium bg-primary-100 text-primary-700 hover:bg-primary-200 transition-colors",children:"Cancel"})]})]}):null]})},Cc);function Cc(e,t){if(e.activeFriendlyId!==t.activeFriendlyId||e.activeSessionKey!==t.activeSessionKey||e.isStreaming!==t.isStreaming||e.defaultOpen!==t.defaultOpen||e.onSelect!==t.onSelect||e.onRename!==t.onRename||e.onDelete!==t.onDelete||e.onExport!==t.onExport)return!1;if(e.sessions===t.sessions)return!0;if(e.sessions.length!==t.sessions.length)return!1;for(let n=0;n<e.sessions.length;n+=1){const r=e.sessions[n],i=t.sessions[n];if(r.key!==i.key||r.friendlyId!==i.friendlyId||r.label!==i.label||r.title!==i.title||r.derivedTitle!==i.derivedTitle||r.updatedAt!==i.updatedAt||r.kind!==i.kind||r.status!==i.status||r.lastMessage!==i.lastMessage)return!1}return!0}function vc(){const[e,t]=m.useState(!1),[n,r]=m.useState(!1),[i,s]=m.useState(null),[o,a]=m.useState(null),l=m.useCallback(async()=>{if(t(!0),s(null),!(n||o)){r(!0);try{const p=await fetch("/api/paths");if(!p.ok)throw new Error(await rt(p));const g=await p.json();a({agentId:String(g.agentId??"main"),stateDir:String(g.stateDir??""),sessionsDir:String(g.sessionsDir??""),storePath:String(g.storePath??"")})}catch(p){s(p instanceof Error?p.message:String(p))}finally{r(!1)}}},[o,n]),u=m.useCallback(()=>{l()},[l]),c=m.useCallback(()=>{t(!1)},[]),f=m.useCallback(()=>{if(o?.sessionsDir)try{navigator.clipboard.writeText(o.sessionsDir)}catch{}},[o]),d=m.useCallback(()=>{if(o?.storePath)try{navigator.clipboard.writeText(o.storePath)}catch{}},[o]);return{settingsOpen:e,setSettingsOpen:t,pathsLoading:n,pathsError:i,paths:o,handleOpenSettings:u,closeSettings:c,copySessionsDir:f,copyStorePath:d}}let _e=null,Vr=!1,kn=null;function Ec(e){_e=e}function er(){return _e!==null}function Kt(e){Vr=e}function tr(){return Vr}function In(){_e=null,Vr=!1}function Tc(e,t){if(_e){if(e&&_e.sessionKey===e){In();return}t&&_e.friendlyId===t&&In()}}function jc(e){kn={friendlyId:e,at:Date.now()}}function yo(e,t=15e3){return!(!kn||kn.friendlyId!==e||Date.now()-kn.at>t)}function Ac(e,t){if(!_e)return null;if(e&&_e.sessionKey===e){const n=_e;return _e=null,n}if(t&&_e.friendlyId===t){const n=_e;return _e=null,n}return null}const Ic=8e3,vt=new Map;function Rc(e){e&&vt.set(e,{id:e,expiresAt:Date.now()+Ic})}function Nc(e){e&&vt.delete(e)}function Dc(e){if(vt.size===0)return e;const t=Date.now();let n=!1;const r=e.filter(i=>{const s=vt.get(i.key),o=vt.get(i.friendlyId);return s&&s.expiresAt<=t||o&&o.expiresAt<=t?(s&&s.expiresAt<=t&&vt.delete(i.key),o&&o.expiresAt<=t&&vt.delete(i.friendlyId),!0):s||o?(n=!0,!1):!0});return n?r:e}function Mc(){const e=Ut(),[t,n]=m.useState(!1),[r,i]=m.useState(null),s=no({mutationFn:async function(l){const u=new URLSearchParams;l.sessionKey&&u.set("sessionKey",l.sessionKey),l.friendlyId&&u.set("friendlyId",l.friendlyId);const c=await fetch(`/api/sessions?${u.toString()}`,{method:"DELETE"});if(!c.ok)throw new Error(await rt(c));return l},onMutate:async function(l){i(null),Rc(l.sessionKey||l.friendlyId),Tc(l.sessionKey,l.friendlyId),await e.cancelQueries({queryKey:we.sessions});const u=e.getQueryData(we.sessions);return mu(e,l.sessionKey,l.friendlyId),l.isActive&&(l.sessionKey||l.friendlyId)&&vr(e,l.friendlyId||l.sessionKey,l.sessionKey||l.friendlyId),{previousSessions:u,isActive:l.isActive}},onError:function(l,u,c){c?.previousSessions&&e.setQueryData(we.sessions,c.previousSessions),Nc(u.sessionKey||u.friendlyId),i(l instanceof Error?l.message:String(l))},onSuccess:function(l){l.isActive&&In(),e.invalidateQueries({queryKey:we.sessions})},onSettled:function(){n(!1)}});return{deleteSession:m.useCallback(async(a,l,u)=>{!a&&!l||(n(!0),await s.mutateAsync({sessionKey:a,friendlyId:l,isActive:u}))},[s]),deleting:t,error:r}}function Lc(){const e=Ut(),[t,n]=m.useState(!1),[r,i]=m.useState(null),s=no({mutationFn:async function(l){const u=await fetch("/api/sessions",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({sessionKey:l.sessionKey,label:l.newTitle})});if(!u.ok)throw new Error(await rt(u));return l},onMutate:async function(l){i(null),await e.cancelQueries({queryKey:we.sessions});const u=e.getQueryData(we.sessions);return e.setQueryData(we.sessions,function(f){return Array.isArray(f)?f.map(d=>d.key!==l.sessionKey?d:{...d,label:l.newTitle,title:l.newTitle}):f}),{previousSessions:u}},onError:function(l,u,c){c?.previousSessions&&e.setQueryData(we.sessions,c.previousSessions),i(l instanceof Error?l.message:String(l))},onSuccess:function(){e.invalidateQueries({queryKey:we.sessions})},onSettled:function(){n(!1)}});return{renameSession:m.useCallback(async(a,l)=>{!a||!l.trim()||(n(!0),await s.mutateAsync({sessionKey:a,newTitle:l.trim()}))},[s]),renaming:t,error:r}}const zc=m.lazy(()=>_n(()=>import("./settings-dialog-CvUsgnnZ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(e=>({default:e.SettingsDialog}))),Pc=m.lazy(()=>_n(()=>import("./session-export-dialog-Bh3zH4nZ.js"),__vite__mapDeps([9,1,3,2,4,5])).then(e=>({default:e.SessionExportDialog})));function _c({sessions:e,activeFriendlyId:t,activeSessionKey:n,isStreaming:r=!1,creatingSession:i,onCreateSession:s,isCollapsed:o,onToggleCollapse:a,onSelectSession:l,onActiveSessionDelete:u,onOpenSearch:c}){const{settingsOpen:f,setSettingsOpen:d,pathsLoading:p,pathsError:g,paths:y,handleOpenSettings:w,closeSettings:k,copySessionsDir:C,copyStorePath:E}=vc(),{deleteSession:N}=Mc(),{renameSession:M}=Lc(),S={duration:.15,ease:o?"easeIn":"easeOut"},[O,H]=m.useState(!1),[_,v]=m.useState(null),[D,A]=m.useState(""),[F,T]=m.useState(!1),[j,R]=m.useState(null),[$,U]=m.useState(null),[L,x]=m.useState(""),[q,V]=m.useState(!1),[b,ee]=m.useState(null),[Q,G]=m.useState(null),[de,he]=m.useState(""),se=Ut();function oe(z){v(z.key),A(z.label||z.title||z.derivedTitle||""),H(!0)}function me(z){_&&M(_,z),H(!1),v(null)}function Te(z){R(z.key),U(z.friendlyId),x(z.label||z.title||z.derivedTitle||z.friendlyId),T(!0)}function xe(){if(j&&$){const z=$===t;z&&u&&u(),N(j,$,z)}T(!1),R(null),U(null)}function De(z){ee(z.key),G(z.friendlyId),he(z.label||z.title||z.derivedTitle||z.friendlyId),V(!0)}function K(z){if(b&&Q){const ge=we.history(Q,b),Z=se.getQueryData(ge);Z?.messages&&ku(de,Z.messages,z)}V(!1),ee(null),G(null)}const te={className:"border-r border-primary-200 h-full overflow-hidden bg-primary-100 flex flex-col"};return h.jsxs(He.aside,{initial:!1,animate:{width:o?48:300},transition:S,className:te.className,children:[h.jsxs(He.div,{layout:!0,transition:{layout:S},className:W("flex items-center h-12 px-2 justify-between"),children:[h.jsx(St,{initial:!1,children:o?null:h.jsx(He.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:S,children:h.jsxs(en,{to:"/new",className:W(Xn({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start"),children:[h.jsx(Ul,{className:"size-5"}),h.jsx(ql,{})]})})}),h.jsx(jt,{children:h.jsxs(At,{children:[h.jsx(It,{onClick:a,render:h.jsx(Ce,{size:"icon-sm",variant:"ghost",children:h.jsx(re,{icon:yl,size:20,strokeWidth:1.5})})}),h.jsx(Rt,{side:"right",children:o?"Open Sidebar":"Close Sidebar"})]})})]}),h.jsxs("div",{className:"px-2 mb-4 flex flex-col gap-1",children:[h.jsxs(He.div,{layout:!0,transition:{layout:S},className:"w-full space-y-2",children:[h.jsxs(Ce,{disabled:i,variant:"ghost",size:"sm",onClick:s,onMouseUp:l,className:"w-full pl-1.5 justify-start",children:[h.jsx(re,{icon:bl,size:20,strokeWidth:1.5,className:"min-w-5"}),h.jsx(St,{initial:!1,mode:"wait",children:!o&&h.jsx(He.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:S,className:"overflow-hidden whitespace-nowrap",children:"New Session"})})]}),h.jsx(jt,{children:h.jsxs(At,{children:[h.jsx(It,{asChild:!0,children:h.jsxs(en,{to:"/files",className:W(Xn({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start"),onClick:l,children:[h.jsx(re,{icon:kl,size:20,strokeWidth:1.5,className:"min-w-5"}),h.jsx(St,{initial:!1,mode:"wait",children:!o&&h.jsx(He.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:S,className:"overflow-hidden whitespace-nowrap",children:"Files"})})]})}),o&&h.jsx(Rt,{side:"right",children:"Files"})]})}),(()=>{try{return localStorage.getItem("opencami-agent-manager")==="true"}catch{return!1}})()&&h.jsx(jt,{children:h.jsxs(At,{children:[h.jsx(It,{asChild:!0,children:h.jsxs(en,{to:"/agents",className:W(Xn({variant:"ghost",size:"sm"}),"w-full pl-1.5 justify-start"),onClick:l,children:[h.jsx(re,{icon:wl,size:20,strokeWidth:1.5,className:"min-w-5"}),h.jsx(St,{initial:!1,mode:"wait",children:!o&&h.jsx(He.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:S,className:"overflow-hidden whitespace-nowrap",children:"Agents"})})]})}),o&&h.jsx(Rt,{side:"right",children:"Agents"})]})})]}),h.jsx(He.div,{layout:!0,transition:{layout:S},className:"w-full",children:h.jsxs(Ce,{variant:"ghost",size:"sm",onClick:c,className:"w-full pl-1.5 justify-start",children:[h.jsx(re,{icon:Vs,size:20,strokeWidth:1.5,className:"min-w-5"}),h.jsx(St,{initial:!1,mode:"wait",children:!o&&h.jsx(He.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:S,className:"overflow-hidden whitespace-nowrap",children:"Search"})})]})})]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:h.jsx(St,{initial:!1,children:!o&&h.jsx(He.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:S,className:"pt-0 flex flex-col w-full min-h-0 h-full",children:h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(Sc,{sessions:e,activeFriendlyId:t,activeSessionKey:n,isStreaming:r,onSelect:l,onRename:oe,onDelete:Te,onExport:De})})},"content")})}),h.jsx("div",{className:"px-2 py-3 border-t border-primary-200 bg-primary-100",children:h.jsx(He.div,{layout:!0,transition:{layout:S},className:"w-full",children:h.jsxs(Ce,{variant:"ghost",size:"sm",onClick:w,title:o?"Settings":void 0,className:"w-full justify-start pl-1.5",children:[h.jsx(re,{icon:Sl,size:20,strokeWidth:1.5,className:"min-w-5"}),h.jsx(St,{initial:!1,mode:"wait",children:!o&&h.jsx(He.span,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:S,className:"overflow-hidden whitespace-nowrap",children:"Settings"})})]})})}),f&&h.jsx(m.Suspense,{fallback:null,children:h.jsx(zc,{open:f,onOpenChange:d,pathsLoading:p,pathsError:g,paths:y,onClose:k,onCopySessionsDir:C,onCopyStorePath:E})}),h.jsx(Su,{open:O,onOpenChange:H,sessionTitle:D,onSave:me,onCancel:()=>H(!1)}),h.jsx(Ru,{open:F,onOpenChange:T,sessionTitle:L,onConfirm:xe,onCancel:()=>T(!1)}),q&&h.jsx(m.Suspense,{fallback:null,children:h.jsx(Pc,{open:q,onOpenChange:V,sessionTitle:de,onExport:K,onCancel:()=>V(!1)})})]})}function Oc(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){const r=e[n],i=t[n];if(r.key!==i.key||r.friendlyId!==i.friendlyId||r.label!==i.label||r.title!==i.title||r.derivedTitle!==i.derivedTitle||r.updatedAt!==i.updatedAt||r.kind!==i.kind||r.status!==i.status||r.lastMessage!==i.lastMessage)return!1}return!0}function Fc(e,t){return!(e.activeFriendlyId!==t.activeFriendlyId||e.activeSessionKey!==t.activeSessionKey||e.isStreaming!==t.isStreaming||e.creatingSession!==t.creatingSession||e.isCollapsed!==t.isCollapsed||!Oc(e.sessions,t.sessions))}const $c=m.memo(_c,Fc);function zi(e){if(e<=0)return"0";if(e>=1e6){const t=e/1e6,n=t.toFixed(1);return n.endsWith(".0")?`${Math.round(t)}M`:`${n}M`}if(e>=1e5)return`${Math.round(e/1e3)}K`;if(e>=1e4)return`${Math.round(e/1e3)}K`;if(e>=1e3){const t=e/1e3,n=t.toFixed(1);return n.endsWith(".0")?`${Math.round(t)}K`:`${n}K`}return String(Math.round(e))}function Pi(e){return e>=90?{bar:"bg-red-500",text:"text-red-600 dark:text-red-400"}:e>=70?{bar:"bg-yellow-500",text:"text-yellow-600 dark:text-yellow-400"}:{bar:"bg-emerald-500",text:"text-emerald-600 dark:text-emerald-400"}}function Bc({totalTokens:e,contextTokens:t,className:n}){const{percentage:r,usedStr:i,maxStr:s,colors:o,hasData:a,isNearlyFull:l}=m.useMemo(()=>{if(typeof t!="number"||t<=0)return{percentage:0,usedStr:"",maxStr:"",colors:Pi(0),hasData:!1,isNearlyFull:!1};const f=typeof e=="number"&&e>0?e:0,d=Math.min(100,Math.round(f/t*100));return{percentage:d,usedStr:zi(f),maxStr:zi(t),colors:Pi(d),hasData:!0,isNearlyFull:d>=95}},[e,t]);if(!a)return null;const u=typeof e=="number"&&e>0?e.toLocaleString():"0",c=typeof t=="number"?t.toLocaleString():"0";return h.jsxs("div",{className:W("group relative flex items-center gap-1.5",n),title:`Context: ${u} / ${c} tokens (${r}%)`,children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("div",{className:"w-12 h-1.5 rounded-full bg-primary-200 dark:bg-primary-700 overflow-hidden shrink-0 group-hover:h-2 transition-all",children:h.jsx("div",{className:W("h-full rounded-full transition-all duration-500 ease-out",o.bar,l&&"animate-pulse"),style:{width:`${r}%`}})}),h.jsx("span",{className:W("text-[10px] leading-none font-medium tabular-nums whitespace-nowrap",l?o.text:"text-primary-500 dark:text-primary-400"),children:i})]}),h.jsx("div",{className:W("absolute right-0 top-full mt-1 z-50","pointer-events-none opacity-0 scale-95","group-hover:pointer-events-auto group-hover:opacity-100 group-hover:scale-100","transition-all duration-150 origin-top-right"),children:h.jsxs("div",{className:W("rounded-md border border-primary-200 dark:border-primary-700","bg-surface shadow-lg px-3 py-2","text-xs whitespace-nowrap"),children:[h.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[h.jsx("span",{className:"text-primary-500 dark:text-primary-400",children:"Context window"}),h.jsxs("span",{className:W("font-semibold",o.text),children:[r,"%"]})]}),h.jsxs("div",{className:"flex items-center gap-1.5 text-primary-700 dark:text-primary-300",children:[h.jsx("span",{className:"font-medium",children:i}),h.jsx("span",{className:"text-primary-400",children:"/"}),h.jsx("span",{children:s}),h.jsx("span",{className:"text-primary-400",children:"tokens"})]}),h.jsx("div",{className:"w-full h-1.5 rounded-full bg-primary-200 dark:bg-primary-700 overflow-hidden mt-1.5",children:h.jsx("div",{className:W("h-full rounded-full transition-all duration-500 ease-out",o.bar),style:{width:`${r}%`}})}),l&&h.jsx("div",{className:"mt-1.5 text-[10px] text-red-500 dark:text-red-400 font-medium",children:"⚠ Context nearly full — consider /compact"})]})})]})}const Hc=m.memo(Bc);function Uc({activeTitle:e,wrapperRef:t,showSidebarButton:n=!1,onOpenSidebar:r,totalTokens:i,contextTokens:s}){return h.jsxs("div",{ref:t,className:"border-b border-primary-200 px-4 h-12 flex items-center bg-surface",children:[n?h.jsx(Ce,{size:"icon-sm",variant:"ghost",onClick:r,className:"mr-2 text-primary-800 hover:bg-primary-100","aria-label":"Open sidebar",children:h.jsx(re,{icon:Cl,size:18,strokeWidth:1.6})}):null,h.jsx("div",{className:"text-sm font-medium truncate flex-1 min-w-0",children:e}),h.jsx(Hc,{totalTokens:i,contextTokens:s,className:"ml-3 hidden sm:flex"})]})}const qc=m.memo(Uc);function Wc(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Kc(e){const t=new Date(e);return Wc(t,new Date)?new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit"}).format(t):new Intl.DateTimeFormat("en-GB",{day:"2-digit",month:"short"}).format(t)}function Vc(e){return new Intl.DateTimeFormat("en-GB",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date(e))}function Xc({timestamp:e}){const t=Kc(e),n=Vc(e);return h.jsx(jt,{children:h.jsxs(At,{children:[h.jsx(It,{className:"inline-flex items-center text-xs text-primary-600",children:t}),h.jsx(Rt,{side:"top",children:n})]})})}function Yc({text:e,align:t,timestamp:n,forceVisible:r=!1}){const[i,s]=m.useState(!1),[o,a]=m.useState("idle"),l=m.useRef(null),u=m.useRef(null),[c,f]=m.useState(()=>{if(typeof window>"u")return!0;try{const w=localStorage.getItem("opencami-tts-enabled");return w===null?!0:w==="true"}catch{return!0}});m.useEffect(()=>{function w(k){k.key==="opencami-tts-enabled"&&f(k.newValue===null?!0:k.newValue==="true")}return window.addEventListener("storage",w),()=>window.removeEventListener("storage",w)},[]),m.useEffect(()=>()=>{l.current&&(l.current.pause(),l.current=null),u.current&&(URL.revokeObjectURL(u.current),u.current=null)},[]);const d=async()=>{try{await navigator.clipboard.writeText(e),s(!0),window.setTimeout(()=>s(!1),1400)}catch{s(!1)}},p=async()=>{if(o==="playing"){l.current&&(l.current.pause(),l.current=null),u.current&&(URL.revokeObjectURL(u.current),u.current=null),a("idle");return}a("loading");try{const w=await fetch("/api/tts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:e})});if(!w.ok)throw new Error("TTS failed");const k=await w.blob(),C=URL.createObjectURL(k);u.current=C;const E=new Audio(C);l.current=E,E.onended=()=>{a("idle"),u.current&&(URL.revokeObjectURL(u.current),u.current=null),l.current=null},E.onerror=()=>{a("idle"),u.current&&(URL.revokeObjectURL(u.current),u.current=null),l.current=null},await E.play(),a("playing")}catch{a("idle"),u.current&&(URL.revokeObjectURL(u.current),u.current=null),l.current=null}},g=t==="end"?"justify-end":"justify-start",y=t==="start"&&c&&e.trim().length>0;return h.jsxs("div",{className:W("flex items-center gap-2 text-xs text-primary-600 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100 duration-100 ease-out",r?"opacity-100":"opacity-0",g),children:[h.jsx(jt,{children:h.jsxs(At,{children:[h.jsx(It,{type:"button",onClick:()=>{d().catch(()=>{})},className:"inline-flex items-center justify-center rounded border border-transparent bg-transparent p-1 text-primary-700 hover:text-primary-900 hover:bg-primary-100",children:h.jsx(re,{icon:i?Xs:vl,size:16,strokeWidth:1.6})}),h.jsx(Rt,{side:"top",children:"Copy"})]})}),y&&h.jsx(jt,{children:h.jsxs(At,{children:[h.jsx(It,{type:"button",onClick:()=>{p().catch(()=>{})},disabled:o==="loading",className:W("inline-flex items-center justify-center rounded border border-transparent bg-transparent p-1 text-primary-700 hover:text-primary-900 hover:bg-primary-100",o==="loading"&&"opacity-60 cursor-wait"),children:h.jsx(re,{icon:o==="loading"?El:o==="playing"?Ys:Tl,size:16,strokeWidth:1.6,className:W(o==="loading"&&"animate-spin")})}),h.jsx(Rt,{side:"top",children:o==="loading"?"Generating speech…":o==="playing"?"Stop":"Listen"})]})}),h.jsx(Xc,{timestamp:n})]})}function Xr(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Mt=Xr();function bo(e){Mt=e}var nn={exec:()=>null};function ue(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Ne.caret,"$1"),n=n.replace(i,o),r},getRegex:()=>new RegExp(n,t)};return r}var Gc=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Ne={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},Qc=/^(?:[ \t]*(?:\n|$))+/,Jc=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Zc=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,un=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ef=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Yr=/(?:[*+-]|\d{1,9}[.)])/,ko=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,wo=ue(ko).replace(/bull/g,Yr).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),tf=ue(ko).replace(/bull/g,Yr).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Gr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,nf=/^[^\n]+/,Qr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,rf=ue(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Qr).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),sf=ue(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Yr).getRegex(),$n="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Jr=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,of=ue("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Jr).replace("tag",$n).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),So=ue(Gr).replace("hr",un).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",$n).getRegex(),af=ue(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",So).getRegex(),Zr={blockquote:af,code:Jc,def:rf,fences:Zc,heading:ef,hr:un,html:of,lheading:wo,list:sf,newline:Qc,paragraph:So,table:nn,text:nf},_i=ue("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",un).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",$n).getRegex(),lf={...Zr,lheading:tf,table:_i,paragraph:ue(Gr).replace("hr",un).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",_i).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",$n).getRegex()},uf={...Zr,html:ue(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Jr).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:nn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ue(Gr).replace("hr",un).replace("heading",` *#{1,6} *[^
|
|
6
|
+
]`).replace("lheading",wo).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},cf=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ff=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Co=/^( {2,}|\\)\n(?!\s*$)/,hf=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Bn=/[\p{P}\p{S}]/u,ei=/[\s\p{P}\p{S}]/u,vo=/[^\s\p{P}\p{S}]/u,pf=ue(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ei).getRegex(),Eo=/(?!~)[\p{P}\p{S}]/u,df=/(?!~)[\s\p{P}\p{S}]/u,mf=/(?:[^\s\p{P}\p{S}]|~)/u,gf=ue(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Gc?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),To=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,xf=ue(To,"u").replace(/punct/g,Bn).getRegex(),yf=ue(To,"u").replace(/punct/g,Eo).getRegex(),jo="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",bf=ue(jo,"gu").replace(/notPunctSpace/g,vo).replace(/punctSpace/g,ei).replace(/punct/g,Bn).getRegex(),kf=ue(jo,"gu").replace(/notPunctSpace/g,mf).replace(/punctSpace/g,df).replace(/punct/g,Eo).getRegex(),wf=ue("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,vo).replace(/punctSpace/g,ei).replace(/punct/g,Bn).getRegex(),Sf=ue(/\\(punct)/,"gu").replace(/punct/g,Bn).getRegex(),Cf=ue(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),vf=ue(Jr).replace("(?:-->|$)","-->").getRegex(),Ef=ue("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",vf).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Rn=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Tf=ue(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Rn).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ao=ue(/^!?\[(label)\]\[(ref)\]/).replace("label",Rn).replace("ref",Qr).getRegex(),Io=ue(/^!?\[(ref)\](?:\[\])?/).replace("ref",Qr).getRegex(),jf=ue("reflink|nolink(?!\\()","g").replace("reflink",Ao).replace("nolink",Io).getRegex(),Oi=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ti={_backpedal:nn,anyPunctuation:Sf,autolink:Cf,blockSkip:gf,br:Co,code:ff,del:nn,emStrongLDelim:xf,emStrongRDelimAst:bf,emStrongRDelimUnd:wf,escape:cf,link:Tf,nolink:Io,punctuation:pf,reflink:Ao,reflinkSearch:jf,tag:Ef,text:hf,url:nn},Af={...ti,link:ue(/^!?\[(label)\]\((.*?)\)/).replace("label",Rn).getRegex(),reflink:ue(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Rn).getRegex()},Er={...ti,emStrongRDelimAst:kf,emStrongLDelim:yf,url:ue(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Oi).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:ue(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Oi).getRegex()},If={...Er,br:ue(Co).replace("{2,}","*").getRegex(),text:ue(Er.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},dn={normal:Zr,gfm:lf,pedantic:uf},Vt={normal:ti,gfm:Er,breaks:If,pedantic:Af},Rf={"&":"&","<":"<",">":">",'"':""","'":"'"},Fi=e=>Rf[e];function lt(e,t){if(t){if(Ne.escapeTest.test(e))return e.replace(Ne.escapeReplace,Fi)}else if(Ne.escapeTestNoEncode.test(e))return e.replace(Ne.escapeReplaceNoEncode,Fi);return e}function $i(e){try{e=encodeURI(e).replace(Ne.percentDecode,"%")}catch{return null}return e}function Bi(e,t){let n=e.replace(Ne.findPipe,(s,o,a)=>{let l=!1,u=o;for(;--u>=0&&a[u]==="\\";)l=!l;return l?"|":" |"}),r=n.split(Ne.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Ne.slashPipe,"|");return r}function Xt(e,t,n){let r=e.length;if(r===0)return"";let i=0;for(;i<r&&e.charAt(r-i-1)===t;)i++;return e.slice(0,r-i)}function Nf(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function Hi(e,t,n,r,i){let s=t.href,o=t.title||null,a=e[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:s,title:o,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,l}function Df(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
7
|
+
`).map(s=>{let o=s.match(n.other.beginningSpace);if(o===null)return s;let[a]=o;return a.length>=i.length?s.slice(i.length):s}).join(`
|
|
8
|
+
`)}var Nn=class{options;rules;lexer;constructor(e){this.options=e||Mt}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Xt(n,`
|
|
9
|
+
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=Df(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=Xt(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Xt(t[0],`
|
|
10
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Xt(t[0],`
|
|
11
|
+
`).split(`
|
|
12
|
+
`),r="",i="",s=[];for(;n.length>0;){let o=!1,a=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))a.push(n[l]),o=!0;else if(!o)a.push(n[l]);else break;n=n.slice(l);let u=a.join(`
|
|
13
|
+
`),c=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
14
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
15
|
+
${u}`:u,i=i?`${i}
|
|
16
|
+
${c}`:c;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,s,!0),this.lexer.state.top=f,n.length===0)break;let d=s.at(-1);if(d?.type==="code")break;if(d?.type==="blockquote"){let p=d,g=p.raw+`
|
|
17
|
+
`+n.join(`
|
|
18
|
+
`),y=this.blockquote(g);s[s.length-1]=y,r=r.substring(0,r.length-p.raw.length)+y.raw,i=i.substring(0,i.length-p.text.length)+y.text;break}else if(d?.type==="list"){let p=d,g=p.raw+`
|
|
19
|
+
`+n.join(`
|
|
20
|
+
`),y=this.list(g);s[s.length-1]=y,r=r.substring(0,r.length-d.raw.length)+y.raw,i=i.substring(0,i.length-p.raw.length)+y.raw,n=g.substring(s.at(-1).raw.length).split(`
|
|
21
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let s=this.rules.other.listItemRegex(n),o=!1;for(;e;){let l=!1,u="",c="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;u=t[0],e=e.substring(u.length);let f=t[2].split(`
|
|
22
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,y=>" ".repeat(3*y.length)),d=e.split(`
|
|
23
|
+
`,1)[0],p=!f.trim(),g=0;if(this.options.pedantic?(g=2,c=f.trimStart()):p?g=t[1].length+1:(g=t[2].search(this.rules.other.nonSpaceChar),g=g>4?1:g,c=f.slice(g),g+=t[1].length),p&&this.rules.other.blankLine.test(d)&&(u+=d+`
|
|
24
|
+
`,e=e.substring(d.length+1),l=!0),!l){let y=this.rules.other.nextBulletRegex(g),w=this.rules.other.hrRegex(g),k=this.rules.other.fencesBeginRegex(g),C=this.rules.other.headingBeginRegex(g),E=this.rules.other.htmlBeginRegex(g);for(;e;){let N=e.split(`
|
|
25
|
+
`,1)[0],M;if(d=N,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting," "),M=d):M=d.replace(this.rules.other.tabCharGlobal," "),k.test(d)||C.test(d)||E.test(d)||y.test(d)||w.test(d))break;if(M.search(this.rules.other.nonSpaceChar)>=g||!d.trim())c+=`
|
|
26
|
+
`+M.slice(g);else{if(p||f.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||k.test(f)||C.test(f)||w.test(f))break;c+=`
|
|
27
|
+
`+d}!p&&!d.trim()&&(p=!0),u+=N+`
|
|
28
|
+
`,e=e.substring(N.length+1),f=M.slice(g)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(u)&&(o=!0)),i.items.push({type:"list_item",raw:u,task:!!this.options.gfm&&this.rules.other.listIsTask.test(c),loose:!1,text:c,tokens:[]}),i.raw+=u}let a=i.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let l of i.items){if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),l.task){if(l.text=l.text.replace(this.rules.other.listReplaceTask,""),l.tokens[0]?.type==="text"||l.tokens[0]?.type==="paragraph"){l.tokens[0].raw=l.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),l.tokens[0].text=l.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let c=this.lexer.inlineQueue.length-1;c>=0;c--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[c].src)){this.lexer.inlineQueue[c].src=this.lexer.inlineQueue[c].src.replace(this.rules.other.listReplaceTask,"");break}}let u=this.rules.other.listTaskCheckbox.exec(l.raw);if(u){let c={type:"checkbox",raw:u[0]+" ",checked:u[0]!=="[ ]"};l.checked=c.checked,i.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=c.raw+l.tokens[0].raw,l.tokens[0].text=c.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(c)):l.tokens.unshift({type:"paragraph",raw:c.raw,text:c.raw,tokens:[c]}):l.tokens.unshift(c)}}if(!i.loose){let u=l.tokens.filter(f=>f.type==="space"),c=u.length>0&&u.some(f=>this.rules.other.anyLine.test(f.raw));i.loose=c}}if(i.loose)for(let l of i.items){l.loose=!0;for(let u of l.tokens)u.type==="text"&&(u.type="paragraph")}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:r,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Bi(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
29
|
+
`):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let o of r)this.rules.other.tableAlignRight.test(o)?s.align.push("right"):this.rules.other.tableAlignCenter.test(o)?s.align.push("center"):this.rules.other.tableAlignLeft.test(o)?s.align.push("left"):s.align.push(null);for(let o=0;o<n.length;o++)s.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:s.align[o]});for(let o of i)s.rows.push(Bi(o,s.header.length).map((a,l)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:s.align[l]})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
|
|
30
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let s=Xt(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{let s=Nf(t[2],"()");if(s===-2)return;if(s>-1){let o=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,o).trim(),t[3]=""}}let r=t[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3])}else i=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),Hi(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[r.toLowerCase()];if(!i){let s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return Hi(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,s,o,a=i,l=0,u=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,t=t.slice(-1*e.length+i);(r=u.exec(t))!=null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(o=[...s].length,r[3]||r[4]){a+=o;continue}else if((r[5]||r[6])&&i%3&&!((i+o)%3)){l+=o;continue}if(a-=o,a>0)continue;o=Math.min(o,o+a+l);let c=[...r[0]][0].length,f=e.slice(0,i+r.index+c+o);if(Math.min(i,o)%2){let p=f.slice(1,-1);return{type:"em",raw:f,text:p,tokens:this.lexer.inlineTokens(p)}}let d=f.slice(2,-2);return{type:"strong",raw:f,text:d,tokens:this.lexer.inlineTokens(d)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,r;if(t[2]==="@")n=t[0],r="mailto:"+n;else{let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0]}return{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},Ye=class Tr{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Mt,this.options.tokenizer=this.options.tokenizer||new Nn,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:Ne,block:dn.normal,inline:Vt.normal};this.options.pedantic?(n.block=dn.pedantic,n.inline=Vt.pedantic):this.options.gfm&&(n.block=dn.gfm,this.options.breaks?n.inline=Vt.breaks:n.inline=Vt.gfm),this.tokenizer.rules=n}static get rules(){return{block:dn,inline:Vt}}static lex(t,n){return new Tr(n).lex(t)}static lexInline(t,n){return new Tr(n).inlineTokens(t)}lex(t){t=t.replace(Ne.carriageReturn,`
|
|
31
|
+
`),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],r=!1){for(this.options.pedantic&&(t=t.replace(Ne.tabCharGlobal," ").replace(Ne.spaceLine,""));t;){let i;if(this.options.extensions?.block?.some(o=>(i=o.call({lexer:this},t,n))?(t=t.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.space(t)){t=t.substring(i.raw.length);let o=n.at(-1);i.raw.length===1&&o!==void 0?o.raw+=`
|
|
32
|
+
`:n.push(i);continue}if(i=this.tokenizer.code(t)){t=t.substring(i.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
33
|
+
`)?"":`
|
|
34
|
+
`)+i.raw,o.text+=`
|
|
35
|
+
`+i.text,this.inlineQueue.at(-1).src=o.text):n.push(i);continue}if(i=this.tokenizer.fences(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.heading(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.hr(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.blockquote(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.list(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.html(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.def(t)){t=t.substring(i.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
36
|
+
`)?"":`
|
|
37
|
+
`)+i.raw,o.text+=`
|
|
38
|
+
`+i.raw,this.inlineQueue.at(-1).src=o.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},n.push(i));continue}if(i=this.tokenizer.table(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.lheading(t)){t=t.substring(i.raw.length),n.push(i);continue}let s=t;if(this.options.extensions?.startBlock){let o=1/0,a=t.slice(1),l;this.options.extensions.startBlock.forEach(u=>{l=u.call({lexer:this},a),typeof l=="number"&&l>=0&&(o=Math.min(o,l))}),o<1/0&&o>=0&&(s=t.substring(0,o+1))}if(this.state.top&&(i=this.tokenizer.paragraph(s))){let o=n.at(-1);r&&o?.type==="paragraph"?(o.raw+=(o.raw.endsWith(`
|
|
39
|
+
`)?"":`
|
|
40
|
+
`)+i.raw,o.text+=`
|
|
41
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(i),r=s.length!==t.length,t=t.substring(i.raw.length);continue}if(i=this.tokenizer.text(t)){t=t.substring(i.raw.length);let o=n.at(-1);o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
42
|
+
`)?"":`
|
|
43
|
+
`)+i.raw,o.text+=`
|
|
44
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(i);continue}if(t){let o="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){let r=t,i=null;if(this.tokens.links){let l=Object.keys(this.tokens.links);if(l.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)l.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)s=i[2]?i[2].length:0,r=r.slice(0,i.index+s)+"["+"a".repeat(i[0].length-s-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let o=!1,a="";for(;t;){o||(a=""),o=!1;let l;if(this.options.extensions?.inline?.some(c=>(l=c.call({lexer:this},t,n))?(t=t.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.escape(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.tag(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.link(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(l.raw.length);let c=n.at(-1);l.type==="text"&&c?.type==="text"?(c.raw+=l.raw,c.text+=l.text):n.push(l);continue}if(l=this.tokenizer.emStrong(t,r,a)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.codespan(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.br(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.del(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.autolink(t)){t=t.substring(l.raw.length),n.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(t))){t=t.substring(l.raw.length),n.push(l);continue}let u=t;if(this.options.extensions?.startInline){let c=1/0,f=t.slice(1),d;this.options.extensions.startInline.forEach(p=>{d=p.call({lexer:this},f),typeof d=="number"&&d>=0&&(c=Math.min(c,d))}),c<1/0&&c>=0&&(u=t.substring(0,c+1))}if(l=this.tokenizer.inlineText(u)){t=t.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(a=l.raw.slice(-1)),o=!0;let c=n.at(-1);c?.type==="text"?(c.raw+=l.raw,c.text+=l.text):n.push(l);continue}if(t){let c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return n}},Dn=class{options;parser;constructor(e){this.options=e||Mt}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(Ne.notSpaceStart)?.[0],i=e.replace(Ne.endingNewline,"")+`
|
|
45
|
+
`;return r?'<pre><code class="language-'+lt(r)+'">'+(n?i:lt(i,!0))+`</code></pre>
|
|
46
|
+
`:"<pre><code>"+(n?i:lt(i,!0))+`</code></pre>
|
|
47
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
48
|
+
${this.parser.parse(e)}</blockquote>
|
|
49
|
+
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
50
|
+
`}hr(e){return`<hr>
|
|
51
|
+
`}list(e){let t=e.ordered,n=e.start,r="";for(let o=0;o<e.items.length;o++){let a=e.items[o];r+=this.listitem(a)}let i=t?"ol":"ul",s=t&&n!==1?' start="'+n+'"':"";return"<"+i+s+`>
|
|
52
|
+
`+r+"</"+i+`>
|
|
53
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
54
|
+
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
55
|
+
`}table(e){let t="",n="";for(let i=0;i<e.header.length;i++)n+=this.tablecell(e.header[i]);t+=this.tablerow({text:n});let r="";for(let i=0;i<e.rows.length;i++){let s=e.rows[i];n="";for(let o=0;o<s.length;o++)n+=this.tablecell(s[o]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
56
|
+
<thead>
|
|
57
|
+
`+t+`</thead>
|
|
58
|
+
`+r+`</table>
|
|
59
|
+
`}tablerow({text:e}){return`<tr>
|
|
60
|
+
${e}</tr>
|
|
61
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
62
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${lt(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=$i(e);if(i===null)return r;e=i;let s='<a href="'+e+'"';return t&&(s+=' title="'+lt(t)+'"'),s+=">"+r+"</a>",s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=$i(e);if(i===null)return lt(n);e=i;let s=`<img src="${e}" alt="${n}"`;return t&&(s+=` title="${lt(t)}"`),s+=">",s}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:lt(e.text)}},ni=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Ge=class jr{options;renderer;textRenderer;constructor(t){this.options=t||Mt,this.options.renderer=this.options.renderer||new Dn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ni}static parse(t,n){return new jr(n).parse(t)}static parseInline(t,n){return new jr(n).parseInline(t)}parse(t){let n="";for(let r=0;r<t.length;r++){let i=t[r];if(this.options.extensions?.renderers?.[i.type]){let o=i,a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){n+=a||"";continue}}let s=i;switch(s.type){case"space":{n+=this.renderer.space(s);break}case"hr":{n+=this.renderer.hr(s);break}case"heading":{n+=this.renderer.heading(s);break}case"code":{n+=this.renderer.code(s);break}case"table":{n+=this.renderer.table(s);break}case"blockquote":{n+=this.renderer.blockquote(s);break}case"list":{n+=this.renderer.list(s);break}case"checkbox":{n+=this.renderer.checkbox(s);break}case"html":{n+=this.renderer.html(s);break}case"def":{n+=this.renderer.def(s);break}case"paragraph":{n+=this.renderer.paragraph(s);break}case"text":{n+=this.renderer.text(s);break}default:{let o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(t,n=this.renderer){let r="";for(let i=0;i<t.length;i++){let s=t[i];if(this.options.extensions?.renderers?.[s.type]){let a=this.options.extensions.renderers[s.type].call({parser:this},s);if(a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){r+=a||"";continue}}let o=s;switch(o.type){case"escape":{r+=n.text(o);break}case"html":{r+=n.html(o);break}case"link":{r+=n.link(o);break}case"image":{r+=n.image(o);break}case"checkbox":{r+=n.checkbox(o);break}case"strong":{r+=n.strong(o);break}case"em":{r+=n.em(o);break}case"codespan":{r+=n.codespan(o);break}case"br":{r+=n.br(o);break}case"del":{r+=n.del(o);break}case"text":{r+=n.text(o);break}default:{let a='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return r}},Zt=class{options;block;constructor(e){this.options=e||Mt}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Ye.lex:Ye.lexInline}provideParser(){return this.block?Ge.parse:Ge.parseInline}},Mf=class{defaults=Xr();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ge;Renderer=Dn;TextRenderer=ni;Lexer=Ye;Tokenizer=Nn;Hooks=Zt;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let i=r;for(let s of i.header)n=n.concat(this.walkTokens(s.tokens,t));for(let s of i.rows)for(let o of s)n=n.concat(this.walkTokens(o.tokens,t));break}case"list":{let i=r;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(s=>{let o=i[s].flat(1/0);n=n.concat(this.walkTokens(o,t))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=t.renderers[i.name];s?t.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=s.apply(this,o)),a}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[i.level];s?s.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),r.extensions=t),n.renderer){let i=this.defaults.renderer||new Dn(this.defaults);for(let s in n.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=n.renderer[o],l=i[o];i[o]=(...u)=>{let c=a.apply(i,u);return c===!1&&(c=l.apply(i,u)),c||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new Nn(this.defaults);for(let s in n.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=n.tokenizer[o],l=i[o];i[o]=(...u)=>{let c=a.apply(i,u);return c===!1&&(c=l.apply(i,u)),c}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new Zt;for(let s in n.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=n.hooks[o],l=i[o];Zt.passThroughHooks.has(s)?i[o]=u=>{if(this.defaults.async&&Zt.passThroughHooksRespectAsync.has(s))return(async()=>{let f=await a.call(i,u);return l.call(i,f)})();let c=a.call(i,u);return l.call(i,c)}:i[o]=(...u)=>{if(this.defaults.async)return(async()=>{let f=await a.apply(i,u);return f===!1&&(f=await l.apply(i,u)),f})();let c=a.apply(i,u);return c===!1&&(c=l.apply(i,u)),c}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Ye.lex(e,t??this.defaults)}parser(e,t){return Ge.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(t):t,a=await(i.hooks?await i.hooks.provideLexer():e?Ye.lex:Ye.lexInline)(o,i),l=i.hooks?await i.hooks.processAllTokens(a):a;i.walkTokens&&await Promise.all(this.walkTokens(l,i.walkTokens));let u=await(i.hooks?await i.hooks.provideParser():e?Ge.parse:Ge.parseInline)(l,i);return i.hooks?await i.hooks.postprocess(u):u})().catch(s);try{i.hooks&&(t=i.hooks.preprocess(t));let o=(i.hooks?i.hooks.provideLexer():e?Ye.lex:Ye.lexInline)(t,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let a=(i.hooks?i.hooks.provideParser():e?Ge.parse:Ge.parseInline)(o,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(o){return s(o)}}}onError(e,t){return n=>{if(n.message+=`
|
|
63
|
+
Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+lt(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},Nt=new Mf;function fe(e,t){return Nt.parse(e,t)}fe.options=fe.setOptions=function(e){return Nt.setOptions(e),fe.defaults=Nt.defaults,bo(fe.defaults),fe};fe.getDefaults=Xr;fe.defaults=Mt;fe.use=function(...e){return Nt.use(...e),fe.defaults=Nt.defaults,bo(fe.defaults),fe};fe.walkTokens=function(e,t){return Nt.walkTokens(e,t)};fe.parseInline=Nt.parseInline;fe.Parser=Ge;fe.parser=Ge.parse;fe.Renderer=Dn;fe.TextRenderer=ni;fe.Lexer=Ye;fe.lexer=Ye.lex;fe.Tokenizer=Nn;fe.Hooks=Zt;fe.parse=fe;fe.options;fe.setOptions;fe.use;fe.walkTokens;fe.parseInline;Ge.parse;Ye.lex;const Lf=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,zf=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Pf={};function Ui(e,t){return(Pf.jsx?zf:Lf).test(e)}var Pt={},nr,qi;function _f(){if(qi)return nr;qi=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,a=/^\s+|\s+$/g,l=`
|
|
64
|
+
`,u="/",c="*",f="",d="comment",p="declaration";function g(w,k){if(typeof w!="string")throw new TypeError("First argument must be a string");if(!w)return[];k=k||{};var C=1,E=1;function N(T){var j=T.match(t);j&&(C+=j.length);var R=T.lastIndexOf(l);E=~R?T.length-R:E+T.length}function M(){var T={line:C,column:E};return function(j){return j.position=new S(T),_(),j}}function S(T){this.start=T,this.end={line:C,column:E},this.source=k.source}S.prototype.content=w;function O(T){var j=new Error(k.source+":"+C+":"+E+": "+T);if(j.reason=T,j.filename=k.source,j.line=C,j.column=E,j.source=w,!k.silent)throw j}function H(T){var j=T.exec(w);if(j){var R=j[0];return N(R),w=w.slice(R.length),j}}function _(){H(n)}function v(T){var j;for(T=T||[];j=D();)j!==!1&&T.push(j);return T}function D(){var T=M();if(!(u!=w.charAt(0)||c!=w.charAt(1))){for(var j=2;f!=w.charAt(j)&&(c!=w.charAt(j)||u!=w.charAt(j+1));)++j;if(j+=2,f===w.charAt(j-1))return O("End of comment missing");var R=w.slice(2,j-2);return E+=2,N(R),w=w.slice(j),E+=2,T({type:d,comment:R})}}function A(){var T=M(),j=H(r);if(j){if(D(),!H(i))return O("property missing ':'");var R=H(s),$=T({type:p,property:y(j[0].replace(e,f)),value:R?y(R[0].replace(e,f)):f});return H(o),$}}function F(){var T=[];v(T);for(var j;j=A();)j!==!1&&(T.push(j),v(T));return T}return _(),F()}function y(w){return w?w.replace(a,f):f}return nr=g,nr}var Wi;function Of(){if(Wi)return Pt;Wi=1;var e=Pt&&Pt.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.default=n;const t=e(_f());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const o=(0,t.default)(r),a=typeof i=="function";return o.forEach(l=>{if(l.type!=="declaration")return;const{property:u,value:c}=l;a?i(u,c,l):c&&(s=s||{},s[u]=c)}),s}return Pt}var Yt={},Ki;function Ff(){if(Ki)return Yt;Ki=1,Object.defineProperty(Yt,"__esModule",{value:!0}),Yt.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(u){return!u||n.test(u)||e.test(u)},o=function(u,c){return c.toUpperCase()},a=function(u,c){return"".concat(c,"-")},l=function(u,c){return c===void 0&&(c={}),s(u)?u:(u=u.toLowerCase(),c.reactCompat?u=u.replace(i,a):u=u.replace(r,a),u.replace(t,o))};return Yt.camelCase=l,Yt}var Gt,Vi;function $f(){if(Vi)return Gt;Vi=1;var e=Gt&&Gt.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Of()),n=Ff();function r(i,s){var o={};return!i||typeof i!="string"||(0,t.default)(i,function(a,l){a&&l&&(o[(0,n.camelCase)(a,s)]=l)}),o}return r.default=r,Gt=r,Gt}var Bf=$f();const Hf=Fs(Bf),Ro=No("end"),ri=No("start");function No(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Uf(e){const t=ri(e),n=Ro(e);if(t&&n)return{start:t,end:n}}function rn(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Xi(e.position):"start"in e||"end"in e?Xi(e):"line"in e||"column"in e?Ar(e):""}function Ar(e){return Yi(e&&e.line)+":"+Yi(e&&e.column)}function Xi(e){return Ar(e&&e.start)+"-"+Ar(e&&e.end)}function Yi(e){return e&&typeof e=="number"?e:1}class Ie extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=rn(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Ie.prototype.file="";Ie.prototype.name="";Ie.prototype.reason="";Ie.prototype.message="";Ie.prototype.stack="";Ie.prototype.column=void 0;Ie.prototype.line=void 0;Ie.prototype.ancestors=void 0;Ie.prototype.cause=void 0;Ie.prototype.fatal=void 0;Ie.prototype.place=void 0;Ie.prototype.ruleId=void 0;Ie.prototype.source=void 0;const ii={}.hasOwnProperty,qf=new Map,Wf=/[A-Z]/g,Kf=new Set(["table","tbody","thead","tfoot","tr"]),Vf=new Set(["td","th"]),Do="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Xf(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=nh(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=th(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?qr:Wl,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=Mo(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function Mo(e,t,n){if(t.type==="element")return Yf(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Gf(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Jf(e,t,n);if(t.type==="mdxjsEsm")return Qf(e,t);if(t.type==="root")return Zf(e,t,n);if(t.type==="text")return eh(e,t)}function Yf(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=qr,e.schema=i),e.ancestors.push(t);const s=zo(e,t.tagName,!1),o=rh(e,t);let a=oi(e,t);return Kf.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!Kl(l):!0})),Lo(e,o,s,t),si(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function Gf(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}an(e,t.position)}function Qf(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);an(e,t.position)}function Jf(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=qr,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:zo(e,t.name,!0),o=ih(e,t),a=oi(e,t);return Lo(e,o,s,t),si(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function Zf(e,t,n){const r={};return si(r,oi(e,t)),e.create(t,e.Fragment,r,n)}function eh(e,t){return t.value}function Lo(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function si(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function th(e,t,n){return r;function r(i,s,o,a){const u=Array.isArray(o.children)?n:t;return a?u(s,o,a):u(s,o)}}function nh(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=ri(r);return t(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function rh(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&ii.call(t.properties,i)){const s=sh(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&Vf.has(t.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function ih(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else an(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,s=e.evaluater.evaluateExpression(a.expression)}else an(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function oi(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:qf;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const u=i.get(l)||0;o=l+"-"+u,i.set(l,u+1)}}const a=Mo(e,s,o);a!==void 0&&n.push(a)}return n}function sh(e,t,n){const r=Vl(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Xl(n):Yl(n)),r.property==="style"){let i=typeof n=="object"?n:oh(e,String(n));return e.stylePropertyNameCase==="css"&&(i=ah(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?tu[r.property]||r.property:r.attribute,n]}}function oh(e,t){try{return Hf(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Ie("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=Do+"#cannot-parse-style-attribute",i}}function zo(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const a=Ui(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=Ui(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return ii.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);an(e)}function an(e,t){const n=new Ie("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Do+"#cannot-handle-mdx-estrees-without-createevaluater",n}function ah(e){const t={};let n;for(n in e)ii.call(e,n)&&(t[lh(n)]=e[n]);return t}function lh(e){let t=e.replace(Wf,uh);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function uh(e){return"-"+e.toLowerCase()}const rr={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},ch={};function ai(e,t){const n=ch,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Po(e,r,i)}function Po(e,t,n){if(fh(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Gi(e.children,t,n)}return Array.isArray(e)?Gi(e,t,n):""}function Gi(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=Po(e[i],t,n);return r.join("")}function fh(e){return!!(e&&typeof e=="object")}const Qi=document.createElement("i");function li(e){const t="&"+e+";";Qi.innerHTML=t;const n=Qi.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Oe(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function Ue(e,t){return e.length>0?(Oe(e,e.length,0,t),e):t}const Ji={}.hasOwnProperty;function _o(e){const t={};let n=-1;for(;++n<e.length;)hh(t,e[n]);return t}function hh(e,t){let n;for(n in t){const i=(Ji.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){Ji.call(i,o)||(i[o]=[]);const a=s[o];ph(i[o],Array.isArray(a)?a:a?[a]:[])}}}function ph(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Oe(e,0,0,r)}function Oo(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ze(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Re=xt(/[A-Za-z]/),Ae=xt(/[\dA-Za-z]/),dh=xt(/[#-'*+\--9=?A-Z^-~]/);function Mn(e){return e!==null&&(e<32||e===127)}const Ir=xt(/\d/),mh=xt(/[\dA-Fa-f]/),gh=xt(/[!-/:-@[-`{-~]/);function Y(e){return e!==null&&e<-2}function pe(e){return e!==null&&(e<0||e===32)}function ie(e){return e===-2||e===-1||e===32}const Hn=xt(new RegExp("\\p{P}|\\p{S}","u")),Dt=xt(/\s/);function xt(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function qt(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&Ae(e.charCodeAt(n+1))&&Ae(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function ae(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return ie(l)?(e.enter(n),a(l)):t(l)}function a(l){return ie(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const xh={tokenize:yh};function yh(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),ae(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),s(a)}function s(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return Y(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const bh={tokenize:kh},Zi={tokenize:wh};function kh(e){const t=this,n=[];let r=0,i,s,o;return a;function a(E){if(r<n.length){const N=n[r];return t.containerState=N[1],e.attempt(N[0].continuation,l,u)(E)}return u(E)}function l(E){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&C();const N=t.events.length;let M=N,S;for(;M--;)if(t.events[M][0]==="exit"&&t.events[M][1].type==="chunkFlow"){S=t.events[M][1].end;break}k(r);let O=N;for(;O<t.events.length;)t.events[O][1].end={...S},O++;return Oe(t.events,M+1,0,t.events.slice(N)),t.events.length=O,u(E)}return a(E)}function u(E){if(r===n.length){if(!i)return d(E);if(i.currentConstruct&&i.currentConstruct.concrete)return g(E);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Zi,c,f)(E)}function c(E){return i&&C(),k(r),d(E)}function f(E){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,g(E)}function d(E){return t.containerState={},e.attempt(Zi,p,g)(E)}function p(E){return r++,n.push([t.currentConstruct,t.containerState]),d(E)}function g(E){if(E===null){i&&C(),k(0),e.consume(E);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),y(E)}function y(E){if(E===null){w(e.exit("chunkFlow"),!0),k(0),e.consume(E);return}return Y(E)?(e.consume(E),w(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(E),y)}function w(E,N){const M=t.sliceStream(E);if(N&&M.push(null),E.previous=s,s&&(s.next=E),s=E,i.defineSkip(E.start),i.write(M),t.parser.lazy[E.start.line]){let S=i.events.length;for(;S--;)if(i.events[S][1].start.offset<o&&(!i.events[S][1].end||i.events[S][1].end.offset>o))return;const O=t.events.length;let H=O,_,v;for(;H--;)if(t.events[H][0]==="exit"&&t.events[H][1].type==="chunkFlow"){if(_){v=t.events[H][1].end;break}_=!0}for(k(r),S=O;S<t.events.length;)t.events[S][1].end={...v},S++;Oe(t.events,H+1,0,t.events.slice(O)),t.events.length=S}}function k(E){let N=n.length;for(;N-- >E;){const M=n[N];t.containerState=M[1],M[0].exit.call(t,e)}n.length=E}function C(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function wh(e,t,n){return ae(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ht(e){if(e===null||pe(e)||Dt(e))return 1;if(Hn(e))return 2}function Un(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const Rr={name:"attention",resolveAll:Sh,tokenize:Ch};function Sh(e,t){let n=-1,r,i,s,o,a,l,u,c;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},d={...e[n][1].start};es(f,-l),es(d,l),o={type:l>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:d},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Ue(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Ue(u,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),u=Ue(u,Un(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Ue(u,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(c=2,u=Ue(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):c=0,Oe(e,r-1,n-r+3,u),n=r+u.length-c-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Ch(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Ht(r);let s;return o;function o(l){return s=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===s)return e.consume(l),a;const u=e.exit("attentionSequence"),c=Ht(l),f=!c||c===2&&i||n.includes(l),d=!i||i===2&&c||n.includes(r);return u._open=!!(s===42?f:f&&(i||!d)),u._close=!!(s===42?d:d&&(c||!f)),t(l)}}function es(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const vh={name:"autolink",tokenize:Eh};function Eh(e,t,n){let r=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(p){return Re(p)?(e.consume(p),o):p===64?n(p):u(p)}function o(p){return p===43||p===45||p===46||Ae(p)?(r=1,a(p)):u(p)}function a(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||Ae(p))&&r++<32?(e.consume(p),a):(r=0,u(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||Mn(p)?n(p):(e.consume(p),l)}function u(p){return p===64?(e.consume(p),c):dh(p)?(e.consume(p),u):n(p)}function c(p){return Ae(p)?f(p):n(p)}function f(p){return p===46?(e.consume(p),r=0,c):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):d(p)}function d(p){if((p===45||Ae(p))&&r++<63){const g=p===45?d:f;return e.consume(p),g}return n(p)}}const cn={partial:!0,tokenize:Th};function Th(e,t,n){return r;function r(s){return ie(s)?ae(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||Y(s)?t(s):n(s)}}const Fo={continuation:{tokenize:Ah},exit:Ih,name:"blockQuote",tokenize:jh};function jh(e,t,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return ie(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function Ah(e,t,n){const r=this;return i;function i(o){return ie(o)?ae(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(Fo,t,n)(o)}}function Ih(e){e.exit("blockQuote")}const $o={name:"characterEscape",tokenize:Rh};function Rh(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return gh(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const Bo={name:"characterReference",tokenize:Nh};function Nh(e,t,n){const r=this;let i=0,s,o;return a;function a(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),l}function l(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),s=31,o=Ae,c(f))}function u(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=mh,c):(e.enter("characterReferenceValue"),s=7,o=Ir,c(f))}function c(f){if(f===59&&i){const d=e.exit("characterReferenceValue");return o===Ae&&!li(r.sliceSerialize(d))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(f)&&i++<s?(e.consume(f),c):n(f)}}const ts={partial:!0,tokenize:Mh},ns={concrete:!0,name:"codeFenced",tokenize:Dh};function Dh(e,t,n){const r=this,i={partial:!0,tokenize:M};let s=0,o=0,a;return l;function l(S){return u(S)}function u(S){const O=r.events[r.events.length-1];return s=O&&O[1].type==="linePrefix"?O[2].sliceSerialize(O[1],!0).length:0,a=S,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),c(S)}function c(S){return S===a?(o++,e.consume(S),c):o<3?n(S):(e.exit("codeFencedFenceSequence"),ie(S)?ae(e,f,"whitespace")(S):f(S))}function f(S){return S===null||Y(S)?(e.exit("codeFencedFence"),r.interrupt?t(S):e.check(ts,y,N)(S)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),d(S))}function d(S){return S===null||Y(S)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(S)):ie(S)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ae(e,p,"whitespace")(S)):S===96&&S===a?n(S):(e.consume(S),d)}function p(S){return S===null||Y(S)?f(S):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(S))}function g(S){return S===null||Y(S)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(S)):S===96&&S===a?n(S):(e.consume(S),g)}function y(S){return e.attempt(i,N,w)(S)}function w(S){return e.enter("lineEnding"),e.consume(S),e.exit("lineEnding"),k}function k(S){return s>0&&ie(S)?ae(e,C,"linePrefix",s+1)(S):C(S)}function C(S){return S===null||Y(S)?e.check(ts,y,N)(S):(e.enter("codeFlowValue"),E(S))}function E(S){return S===null||Y(S)?(e.exit("codeFlowValue"),C(S)):(e.consume(S),E)}function N(S){return e.exit("codeFenced"),t(S)}function M(S,O,H){let _=0;return v;function v(j){return S.enter("lineEnding"),S.consume(j),S.exit("lineEnding"),D}function D(j){return S.enter("codeFencedFence"),ie(j)?ae(S,A,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(j):A(j)}function A(j){return j===a?(S.enter("codeFencedFenceSequence"),F(j)):H(j)}function F(j){return j===a?(_++,S.consume(j),F):_>=o?(S.exit("codeFencedFenceSequence"),ie(j)?ae(S,T,"whitespace")(j):T(j)):H(j)}function T(j){return j===null||Y(j)?(S.exit("codeFencedFence"),O(j)):H(j)}}}function Mh(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const ir={name:"codeIndented",tokenize:zh},Lh={partial:!0,tokenize:Ph};function zh(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),ae(e,s,"linePrefix",5)(u)}function s(u){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?l(u):Y(u)?e.attempt(Lh,o,l)(u):(e.enter("codeFlowValue"),a(u))}function a(u){return u===null||Y(u)?(e.exit("codeFlowValue"),o(u)):(e.consume(u),a)}function l(u){return e.exit("codeIndented"),t(u)}}function Ph(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):Y(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):ae(e,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):Y(o)?i(o):n(o)}}const _h={name:"codeText",previous:Fh,resolve:Oh,tokenize:$h};function Oh(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Fh(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function $h(e,t,n){let r=0,i,s;return o;function o(f){return e.enter("codeText"),e.enter("codeTextSequence"),a(f)}function a(f){return f===96?(e.consume(f),r++,a):(e.exit("codeTextSequence"),l(f))}function l(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),l):f===96?(s=e.enter("codeTextSequence"),i=0,c(f)):Y(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),l):(e.enter("codeTextData"),u(f))}function u(f){return f===null||f===32||f===96||Y(f)?(e.exit("codeTextData"),l(f)):(e.consume(f),u)}function c(f){return f===96?(e.consume(f),i++,c):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(s.type="codeTextData",u(f))}}class Bh{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Qt(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Qt(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Qt(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Qt(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Qt(this.left,n.reverse())}}}function Qt(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Ho(e){const t={};let n=-1,r,i,s,o,a,l,u;const c=new Bh(e);for(;++n<c.length;){for(;n in t;)n=t[n];if(r=c.get(n),n&&r[1].type==="chunkFlow"&&c.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Hh(c,n)),n=t[n],u=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=c.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(c.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...c.get(i)[1].start},a=c.slice(i,n),a.unshift(r),c.splice(i,n-i+1,a))}}return Oe(e,0,Number.POSITIVE_INFINITY,c.slice(0)),!u}function Hh(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],u={};let c,f,d=-1,p=n,g=0,y=0;const w=[y];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(c=r.sliceStream(p),p.next||c.push(null),f&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(c),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),f=p,p=p.next}for(p=n;++d<a.length;)a[d][0]==="exit"&&a[d-1][0]==="enter"&&a[d][1].type===a[d-1][1].type&&a[d][1].start.line!==a[d][1].end.line&&(y=d+1,w.push(y),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):w.pop(),d=w.length;d--;){const k=a.slice(w[d],w[d+1]),C=s.pop();l.push([C,C+k.length-1]),e.splice(C,2,k)}for(l.reverse(),d=-1;++d<l.length;)u[g+l[d][0]]=g+l[d][1],g+=l[d][1]-l[d][0]-1;return u}const Uh={resolve:Wh,tokenize:Kh},qh={partial:!0,tokenize:Vh};function Wh(e){return Ho(e),e}function Kh(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):Y(a)?e.check(qh,o,s)(a):(e.consume(a),i)}function s(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function Vh(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),ae(e,s,"linePrefix")}function s(o){if(o===null||Y(o))return n(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function Uo(e,t,n,r,i,s,o,a,l){const u=l||Number.POSITIVE_INFINITY;let c=0;return f;function f(k){return k===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(k),e.exit(s),d):k===null||k===32||k===41||Mn(k)?n(k):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),y(k))}function d(k){return k===62?(e.enter(s),e.consume(k),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(k))}function p(k){return k===62?(e.exit("chunkString"),e.exit(a),d(k)):k===null||k===60||Y(k)?n(k):(e.consume(k),k===92?g:p)}function g(k){return k===60||k===62||k===92?(e.consume(k),p):p(k)}function y(k){return!c&&(k===null||k===41||pe(k))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(k)):c<u&&k===40?(e.consume(k),c++,y):k===41?(e.consume(k),c--,y):k===null||k===32||k===40||Mn(k)?n(k):(e.consume(k),k===92?w:y)}function w(k){return k===40||k===41||k===92?(e.consume(k),y):y(k)}}function qo(e,t,n,r,i,s){const o=this;let a=0,l;return u;function u(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(s),c}function c(p){return a>999||p===null||p===91||p===93&&!l||p===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):Y(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===null||p===91||p===93||Y(p)||a++>999?(e.exit("chunkString"),c(p)):(e.consume(p),l||(l=!ie(p)),p===92?d:f)}function d(p){return p===91||p===92||p===93?(e.consume(p),a++,f):f(p)}}function Wo(e,t,n,r,i,s){let o;return a;function a(d){return d===34||d===39||d===40?(e.enter(r),e.enter(i),e.consume(d),e.exit(i),o=d===40?41:d,l):n(d)}function l(d){return d===o?(e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):(e.enter(s),u(d))}function u(d){return d===o?(e.exit(s),l(o)):d===null?n(d):Y(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),ae(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(d))}function c(d){return d===o||d===null||Y(d)?(e.exit("chunkString"),u(d)):(e.consume(d),d===92?f:c)}function f(d){return d===o||d===92?(e.consume(d),c):c(d)}}function sn(e,t){let n;return r;function r(i){return Y(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):ie(i)?ae(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Xh={name:"definition",tokenize:Gh},Yh={partial:!0,tokenize:Qh};function Gh(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return qo.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=Ze(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return pe(p)?sn(e,u)(p):u(p)}function u(p){return Uo(e,c,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function c(p){return e.attempt(Yh,f,f)(p)}function f(p){return ie(p)?ae(e,d,"whitespace")(p):d(p)}function d(p){return p===null||Y(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function Qh(e,t,n){return r;function r(a){return pe(a)?sn(e,i)(a):n(a)}function i(a){return Wo(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return ie(a)?ae(e,o,"whitespace")(a):o(a)}function o(a){return a===null||Y(a)?t(a):n(a)}}const Jh={name:"hardBreakEscape",tokenize:Zh};function Zh(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return Y(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const ep={name:"headingAtx",resolve:tp,tokenize:np};function tp(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Oe(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function np(e,t,n){let r=0;return i;function i(c){return e.enter("atxHeading"),s(c)}function s(c){return e.enter("atxHeadingSequence"),o(c)}function o(c){return c===35&&r++<6?(e.consume(c),o):c===null||pe(c)?(e.exit("atxHeadingSequence"),a(c)):n(c)}function a(c){return c===35?(e.enter("atxHeadingSequence"),l(c)):c===null||Y(c)?(e.exit("atxHeading"),t(c)):ie(c)?ae(e,a,"whitespace")(c):(e.enter("atxHeadingText"),u(c))}function l(c){return c===35?(e.consume(c),l):(e.exit("atxHeadingSequence"),a(c))}function u(c){return c===null||c===35||pe(c)?(e.exit("atxHeadingText"),a(c)):(e.consume(c),u)}}const rp=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],rs=["pre","script","style","textarea"],ip={concrete:!0,name:"htmlFlow",resolveTo:ap,tokenize:lp},sp={partial:!0,tokenize:cp},op={partial:!0,tokenize:up};function ap(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function lp(e,t,n){const r=this;let i,s,o,a,l;return u;function u(b){return c(b)}function c(b){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(b),f}function f(b){return b===33?(e.consume(b),d):b===47?(e.consume(b),s=!0,y):b===63?(e.consume(b),i=3,r.interrupt?t:x):Re(b)?(e.consume(b),o=String.fromCharCode(b),w):n(b)}function d(b){return b===45?(e.consume(b),i=2,p):b===91?(e.consume(b),i=5,a=0,g):Re(b)?(e.consume(b),i=4,r.interrupt?t:x):n(b)}function p(b){return b===45?(e.consume(b),r.interrupt?t:x):n(b)}function g(b){const ee="CDATA[";return b===ee.charCodeAt(a++)?(e.consume(b),a===ee.length?r.interrupt?t:A:g):n(b)}function y(b){return Re(b)?(e.consume(b),o=String.fromCharCode(b),w):n(b)}function w(b){if(b===null||b===47||b===62||pe(b)){const ee=b===47,Q=o.toLowerCase();return!ee&&!s&&rs.includes(Q)?(i=1,r.interrupt?t(b):A(b)):rp.includes(o.toLowerCase())?(i=6,ee?(e.consume(b),k):r.interrupt?t(b):A(b)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(b):s?C(b):E(b))}return b===45||Ae(b)?(e.consume(b),o+=String.fromCharCode(b),w):n(b)}function k(b){return b===62?(e.consume(b),r.interrupt?t:A):n(b)}function C(b){return ie(b)?(e.consume(b),C):v(b)}function E(b){return b===47?(e.consume(b),v):b===58||b===95||Re(b)?(e.consume(b),N):ie(b)?(e.consume(b),E):v(b)}function N(b){return b===45||b===46||b===58||b===95||Ae(b)?(e.consume(b),N):M(b)}function M(b){return b===61?(e.consume(b),S):ie(b)?(e.consume(b),M):E(b)}function S(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(e.consume(b),l=b,O):ie(b)?(e.consume(b),S):H(b)}function O(b){return b===l?(e.consume(b),l=null,_):b===null||Y(b)?n(b):(e.consume(b),O)}function H(b){return b===null||b===34||b===39||b===47||b===60||b===61||b===62||b===96||pe(b)?M(b):(e.consume(b),H)}function _(b){return b===47||b===62||ie(b)?E(b):n(b)}function v(b){return b===62?(e.consume(b),D):n(b)}function D(b){return b===null||Y(b)?A(b):ie(b)?(e.consume(b),D):n(b)}function A(b){return b===45&&i===2?(e.consume(b),R):b===60&&i===1?(e.consume(b),$):b===62&&i===4?(e.consume(b),q):b===63&&i===3?(e.consume(b),x):b===93&&i===5?(e.consume(b),L):Y(b)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(sp,V,F)(b)):b===null||Y(b)?(e.exit("htmlFlowData"),F(b)):(e.consume(b),A)}function F(b){return e.check(op,T,V)(b)}function T(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),j}function j(b){return b===null||Y(b)?F(b):(e.enter("htmlFlowData"),A(b))}function R(b){return b===45?(e.consume(b),x):A(b)}function $(b){return b===47?(e.consume(b),o="",U):A(b)}function U(b){if(b===62){const ee=o.toLowerCase();return rs.includes(ee)?(e.consume(b),q):A(b)}return Re(b)&&o.length<8?(e.consume(b),o+=String.fromCharCode(b),U):A(b)}function L(b){return b===93?(e.consume(b),x):A(b)}function x(b){return b===62?(e.consume(b),q):b===45&&i===2?(e.consume(b),x):A(b)}function q(b){return b===null||Y(b)?(e.exit("htmlFlowData"),V(b)):(e.consume(b),q)}function V(b){return e.exit("htmlFlow"),t(b)}}function up(e,t,n){const r=this;return i;function i(o){return Y(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function cp(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(cn,t,n)}}const fp={name:"htmlText",tokenize:hp};function hp(e,t,n){const r=this;let i,s,o;return a;function a(x){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(x),l}function l(x){return x===33?(e.consume(x),u):x===47?(e.consume(x),M):x===63?(e.consume(x),E):Re(x)?(e.consume(x),H):n(x)}function u(x){return x===45?(e.consume(x),c):x===91?(e.consume(x),s=0,g):Re(x)?(e.consume(x),C):n(x)}function c(x){return x===45?(e.consume(x),p):n(x)}function f(x){return x===null?n(x):x===45?(e.consume(x),d):Y(x)?(o=f,$(x)):(e.consume(x),f)}function d(x){return x===45?(e.consume(x),p):f(x)}function p(x){return x===62?R(x):x===45?d(x):f(x)}function g(x){const q="CDATA[";return x===q.charCodeAt(s++)?(e.consume(x),s===q.length?y:g):n(x)}function y(x){return x===null?n(x):x===93?(e.consume(x),w):Y(x)?(o=y,$(x)):(e.consume(x),y)}function w(x){return x===93?(e.consume(x),k):y(x)}function k(x){return x===62?R(x):x===93?(e.consume(x),k):y(x)}function C(x){return x===null||x===62?R(x):Y(x)?(o=C,$(x)):(e.consume(x),C)}function E(x){return x===null?n(x):x===63?(e.consume(x),N):Y(x)?(o=E,$(x)):(e.consume(x),E)}function N(x){return x===62?R(x):E(x)}function M(x){return Re(x)?(e.consume(x),S):n(x)}function S(x){return x===45||Ae(x)?(e.consume(x),S):O(x)}function O(x){return Y(x)?(o=O,$(x)):ie(x)?(e.consume(x),O):R(x)}function H(x){return x===45||Ae(x)?(e.consume(x),H):x===47||x===62||pe(x)?_(x):n(x)}function _(x){return x===47?(e.consume(x),R):x===58||x===95||Re(x)?(e.consume(x),v):Y(x)?(o=_,$(x)):ie(x)?(e.consume(x),_):R(x)}function v(x){return x===45||x===46||x===58||x===95||Ae(x)?(e.consume(x),v):D(x)}function D(x){return x===61?(e.consume(x),A):Y(x)?(o=D,$(x)):ie(x)?(e.consume(x),D):_(x)}function A(x){return x===null||x===60||x===61||x===62||x===96?n(x):x===34||x===39?(e.consume(x),i=x,F):Y(x)?(o=A,$(x)):ie(x)?(e.consume(x),A):(e.consume(x),T)}function F(x){return x===i?(e.consume(x),i=void 0,j):x===null?n(x):Y(x)?(o=F,$(x)):(e.consume(x),F)}function T(x){return x===null||x===34||x===39||x===60||x===61||x===96?n(x):x===47||x===62||pe(x)?_(x):(e.consume(x),T)}function j(x){return x===47||x===62||pe(x)?_(x):n(x)}function R(x){return x===62?(e.consume(x),e.exit("htmlTextData"),e.exit("htmlText"),t):n(x)}function $(x){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),U}function U(x){return ie(x)?ae(e,L,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(x):L(x)}function L(x){return e.enter("htmlTextData"),o(x)}}const ui={name:"labelEnd",resolveAll:gp,resolveTo:xp,tokenize:yp},pp={tokenize:bp},dp={tokenize:kp},mp={tokenize:wp};function gp(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&Oe(e,0,e.length,n),e}function xp(e,t){let n=e.length,r=0,i,s,o,a;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},c={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",u,t]],a=Ue(a,e.slice(s+1,s+r+3)),a=Ue(a,[["enter",c,t]]),a=Ue(a,Un(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=Ue(a,[["exit",c,t],e[o-2],e[o-1],["exit",u,t]]),a=Ue(a,e.slice(o+1)),a=Ue(a,[["exit",l,t]]),Oe(e,s,e.length,a),e}function yp(e,t,n){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return a;function a(d){return s?s._inactive?f(d):(o=r.parser.defined.includes(Ze(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelEnd"),l):n(d)}function l(d){return d===40?e.attempt(pp,c,o?c:f)(d):d===91?e.attempt(dp,c,o?u:f)(d):o?c(d):f(d)}function u(d){return e.attempt(mp,c,f)(d)}function c(d){return t(d)}function f(d){return s._balanced=!0,n(d)}}function bp(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),i}function i(f){return pe(f)?sn(e,s)(f):s(f)}function s(f){return f===41?c(f):Uo(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function o(f){return pe(f)?sn(e,l)(f):c(f)}function a(f){return n(f)}function l(f){return f===34||f===39||f===40?Wo(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):c(f)}function u(f){return pe(f)?sn(e,c)(f):c(f)}function c(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function kp(e,t,n){const r=this;return i;function i(a){return qo.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Ze(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function wp(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const Sp={name:"labelStartImage",resolveAll:ui.resolveAll,tokenize:Cp};function Cp(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),s}function s(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const vp={name:"labelStartLink",resolveAll:ui.resolveAll,tokenize:Ep};function Ep(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const sr={name:"lineEnding",tokenize:Tp};function Tp(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),ae(e,t,"linePrefix")}}const wn={name:"thematicBreak",tokenize:jp};function jp(e,t,n){let r=0,i;return s;function s(u){return e.enter("thematicBreak"),o(u)}function o(u){return i=u,a(u)}function a(u){return u===i?(e.enter("thematicBreakSequence"),l(u)):r>=3&&(u===null||Y(u))?(e.exit("thematicBreak"),t(u)):n(u)}function l(u){return u===i?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),ie(u)?ae(e,a,"whitespace")(u):a(u))}}const Le={continuation:{tokenize:Np},exit:Mp,name:"list",tokenize:Rp},Ap={partial:!0,tokenize:Lp},Ip={partial:!0,tokenize:Dp};function Rp(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(p){const g=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:Ir(p)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(wn,n,u)(p):u(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return n(p)}function l(p){return Ir(p)&&++o<10?(e.consume(p),l):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),u(p)):n(p)}function u(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(cn,r.interrupt?n:c,e.attempt(Ap,d,f))}function c(p){return r.containerState.initialBlankLine=!0,s++,d(p)}function f(p){return ie(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),d):n(p)}function d(p){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function Np(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(cn,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ae(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!ie(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Ip,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,ae(e,e.attempt(Le,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function Dp(e,t,n){const r=this;return ae(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function Mp(e){e.exit(this.containerState.type)}function Lp(e,t,n){const r=this;return ae(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!ie(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const is={name:"setextUnderline",resolveTo:zp,tokenize:Pp};function zp(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function Pp(e,t,n){const r=this;let i;return s;function s(u){let c=r.events.length,f;for(;c--;)if(r.events[c][1].type!=="lineEnding"&&r.events[c][1].type!=="linePrefix"&&r.events[c][1].type!=="content"){f=r.events[c][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),i=u,o(u)):n(u)}function o(u){return e.enter("setextHeadingLineSequence"),a(u)}function a(u){return u===i?(e.consume(u),a):(e.exit("setextHeadingLineSequence"),ie(u)?ae(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||Y(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const _p={tokenize:Op};function Op(e){const t=this,n=e.attempt(cn,r,e.attempt(this.parser.constructs.flowInitial,i,ae(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Uh,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Fp={resolveAll:Vo()},$p=Ko("string"),Bp=Ko("text");function Ko(e){return{resolveAll:Vo(e==="text"?Hp:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,a);return o;function o(c){return u(c)?s(c):a(c)}function a(c){if(c===null){n.consume(c);return}return n.enter("data"),n.consume(c),l}function l(c){return u(c)?(n.exit("data"),s(c)):(n.consume(c),l)}function u(c){if(c===null)return!0;const f=i[c];let d=-1;if(f)for(;++d<f.length;){const p=f[d];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function Vo(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function Hp(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,o=-1,a=0,l;for(;s--;){const u=i[s];if(typeof u=="string"){for(o=u.length;u.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(u===-2)l=!0,a++;else if(u!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const u={type:n===e.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const Up={42:Le,43:Le,45:Le,48:Le,49:Le,50:Le,51:Le,52:Le,53:Le,54:Le,55:Le,56:Le,57:Le,62:Fo},qp={91:Xh},Wp={[-2]:ir,[-1]:ir,32:ir},Kp={35:ep,42:wn,45:[is,wn],60:ip,61:is,95:wn,96:ns,126:ns},Vp={38:Bo,92:$o},Xp={[-5]:sr,[-4]:sr,[-3]:sr,33:Sp,38:Bo,42:Rr,60:[vh,fp],91:vp,92:[Jh,$o],93:ui,95:Rr,96:_h},Yp={null:[Rr,Fp]},Gp={null:[42,95]},Qp={null:[]},Jp=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Gp,contentInitial:qp,disable:Qp,document:Up,flow:Kp,flowInitial:Wp,insideSpan:Yp,string:Vp,text:Xp},Symbol.toStringTag,{value:"Module"}));function Zp(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const l={attempt:O(M),check:O(S),consume:C,enter:E,exit:N,interrupt:O(S,{interrupt:!0})},u={code:null,containerState:{},defineSkip:y,events:[],now:g,parser:e,previous:null,sliceSerialize:d,sliceStream:p,write:f};let c=t.tokenize.call(u,l);return t.resolveAll&&s.push(t),u;function f(D){return o=Ue(o,D),w(),o[o.length-1]!==null?[]:(H(t,0),u.events=Un(s,u.events,u),u.events)}function d(D,A){return td(p(D),A)}function p(D){return ed(o,D)}function g(){const{_bufferIndex:D,_index:A,line:F,column:T,offset:j}=r;return{_bufferIndex:D,_index:A,line:F,column:T,offset:j}}function y(D){i[D.line]=D.column,v()}function w(){let D;for(;r._index<o.length;){const A=o[r._index];if(typeof A=="string")for(D=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===D&&r._bufferIndex<A.length;)k(A.charCodeAt(r._bufferIndex));else k(A)}}function k(D){c=c(D)}function C(D){Y(D)?(r.line++,r.column=1,r.offset+=D===-3?2:1,v()):D!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=D}function E(D,A){const F=A||{};return F.type=D,F.start=g(),u.events.push(["enter",F,u]),a.push(F),F}function N(D){const A=a.pop();return A.end=g(),u.events.push(["exit",A,u]),A}function M(D,A){H(D,A.from)}function S(D,A){A.restore()}function O(D,A){return F;function F(T,j,R){let $,U,L,x;return Array.isArray(T)?V(T):"tokenize"in T?V([T]):q(T);function q(G){return de;function de(he){const se=he!==null&&G[he],oe=he!==null&&G.null,me=[...Array.isArray(se)?se:se?[se]:[],...Array.isArray(oe)?oe:oe?[oe]:[]];return V(me)(he)}}function V(G){return $=G,U=0,G.length===0?R:b(G[U])}function b(G){return de;function de(he){return x=_(),L=G,G.partial||(u.currentConstruct=G),G.name&&u.parser.constructs.disable.null.includes(G.name)?Q():G.tokenize.call(A?Object.assign(Object.create(u),A):u,l,ee,Q)(he)}}function ee(G){return D(L,x),j}function Q(G){return x.restore(),++U<$.length?b($[U]):R}}}function H(D,A){D.resolveAll&&!s.includes(D)&&s.push(D),D.resolve&&Oe(u.events,A,u.events.length-A,D.resolve(u.events.slice(A),u)),D.resolveTo&&(u.events=D.resolveTo(u.events,u))}function _(){const D=g(),A=u.previous,F=u.currentConstruct,T=u.events.length,j=Array.from(a);return{from:T,restore:R};function R(){r=D,u.previous=A,u.currentConstruct=F,u.events.length=T,a=j,v()}}function v(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function ed(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,s)];else{if(o=e.slice(n,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function td(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
|
|
65
|
+
`;break}case-3:{o=`\r
|
|
66
|
+
`;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function nd(e){const r={constructs:_o([Jp,...(e||{}).extensions||[]]),content:i(xh),defined:[],document:i(bh),flow:i(_p),lazy:{},string:i($p),text:i(Bp)};return r;function i(s){return o;function o(a){return Zp(r,s,a)}}}function rd(e){for(;!Ho(e););return e}const ss=/[\0\t\n\r]/g;function id(){let e=1,t="",n=!0,r;return i;function i(s,o,a){const l=[];let u,c,f,d,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),f=0,t="",n&&(s.charCodeAt(0)===65279&&f++,n=void 0);f<s.length;){if(ss.lastIndex=f,u=ss.exec(s),d=u&&u.index!==void 0?u.index:s.length,p=s.charCodeAt(d),!u){t=s.slice(f);break}if(p===10&&f===d&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),f<d&&(l.push(s.slice(f,d)),e+=d-f),p){case 0:{l.push(65533),e++;break}case 9:{for(c=Math.ceil(e/4)*4,l.push(-2);e++<c;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}f=d+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const sd=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function od(e){return e.replace(sd,ad)}function ad(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return Oo(n.slice(s?2:1),s?16:10)}return li(n)||e}const Xo={}.hasOwnProperty;function ld(e,t,n){return typeof t!="string"&&(n=t,t=void 0),ud(n)(rd(nd(n).document().write(id()(e,t,!0))))}function ud(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(Z),autolinkProtocol:_,autolinkEmail:_,atxHeading:s(K),blockQuote:s(oe),characterEscape:_,characterReference:_,codeFenced:s(me),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(me,o),codeText:s(Te,o),codeTextData:_,data:_,codeFlowValue:_,definition:s(xe),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(De),hardBreakEscape:s(te),hardBreakTrailing:s(te),htmlFlow:s(z,o),htmlFlowData:_,htmlText:s(z,o),htmlTextData:_,image:s(ge),label:o,link:s(Z),listItem:s(We),listItemValue:d,listOrdered:s(be,f),listUnordered:s(be),paragraph:s(Se),reference:b,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(K),strong:s(Ke),thematicBreak:s(st)},exit:{atxHeading:l(),atxHeadingSequence:M,autolink:l(),autolinkEmail:se,autolinkProtocol:he,blockQuote:l(),characterEscapeValue:v,characterReferenceMarkerHexadecimal:Q,characterReferenceMarkerNumeric:Q,characterReferenceValue:G,characterReference:de,codeFenced:l(w),codeFencedFence:y,codeFencedFenceInfo:p,codeFencedFenceMeta:g,codeFlowValue:v,codeIndented:l(k),codeText:l(j),codeTextData:v,data:v,definition:l(),definitionDestinationString:N,definitionLabelString:C,definitionTitleString:E,emphasis:l(),hardBreakEscape:l(A),hardBreakTrailing:l(A),htmlFlow:l(F),htmlFlowData:v,htmlText:l(T),htmlTextData:v,image:l($),label:L,labelText:U,lineEnding:D,link:l(R),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ee,resourceDestinationString:x,resourceTitleString:q,resource:V,setextHeading:l(H),setextHeadingLineSequence:O,setextHeadingText:S,strong:l(),thematicBreak:l()}};Yo(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(I){let P={type:"root",children:[]};const X={stack:[P],tokenStack:[],config:t,enter:a,exit:u,buffer:o,resume:c,data:n},ne=[];let le=-1;for(;++le<I.length;)if(I[le][1].type==="listOrdered"||I[le][1].type==="listUnordered")if(I[le][0]==="enter")ne.push(le);else{const ve=ne.pop();le=i(I,ve,le)}for(le=-1;++le<I.length;){const ve=t[I[le][0]];Xo.call(ve,I[le][1].type)&&ve[I[le][1].type].call(Object.assign({sliceSerialize:I[le][2].sliceSerialize},X),I[le][1])}if(X.tokenStack.length>0){const ve=X.tokenStack[X.tokenStack.length-1];(ve[1]||os).call(X,void 0,ve[0])}for(P.position={start:ht(I.length>0?I[0][1].start:{line:1,column:1,offset:0}),end:ht(I.length>0?I[I.length-2][1].end:{line:1,column:1,offset:0})},le=-1;++le<t.transforms.length;)P=t.transforms[le](P)||P;return P}function i(I,P,X){let ne=P-1,le=-1,ve=!1,Ve,ze,Fe,$e;for(;++ne<=X;){const ye=I[ne];switch(ye[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ye[0]==="enter"?le++:le--,$e=void 0;break}case"lineEndingBlank":{ye[0]==="enter"&&(Ve&&!$e&&!le&&!Fe&&(Fe=ne),$e=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:$e=void 0}if(!le&&ye[0]==="enter"&&ye[1].type==="listItemPrefix"||le===-1&&ye[0]==="exit"&&(ye[1].type==="listUnordered"||ye[1].type==="listOrdered")){if(Ve){let Xe=ne;for(ze=void 0;Xe--;){const Ee=I[Xe];if(Ee[1].type==="lineEnding"||Ee[1].type==="lineEndingBlank"){if(Ee[0]==="exit")continue;ze&&(I[ze][1].type="lineEndingBlank",ve=!0),Ee[1].type="lineEnding",ze=Xe}else if(!(Ee[1].type==="linePrefix"||Ee[1].type==="blockQuotePrefix"||Ee[1].type==="blockQuotePrefixWhitespace"||Ee[1].type==="blockQuoteMarker"||Ee[1].type==="listItemIndent"))break}Fe&&(!ze||Fe<ze)&&(Ve._spread=!0),Ve.end=Object.assign({},ze?I[ze][1].start:ye[1].end),I.splice(ze||ne,0,["exit",Ve,ye[2]]),ne++,X++}if(ye[1].type==="listItemPrefix"){const Xe={type:"listItem",_spread:!1,start:Object.assign({},ye[1].start),end:void 0};Ve=Xe,I.splice(ne,0,["enter",Xe,ye[2]]),ne++,X++,Fe=void 0,$e=!0}}}return I[P][1]._spread=ve,X}function s(I,P){return X;function X(ne){a.call(this,I(ne),ne),P&&P.call(this,ne)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(I,P,X){this.stack[this.stack.length-1].children.push(I),this.stack.push(I),this.tokenStack.push([P,X||void 0]),I.position={start:ht(P.start),end:void 0}}function l(I){return P;function P(X){I&&I.call(this,X),u.call(this,X)}}function u(I,P){const X=this.stack.pop(),ne=this.tokenStack.pop();if(ne)ne[0].type!==I.type&&(P?P.call(this,I,ne[0]):(ne[1]||os).call(this,I,ne[0]));else throw new Error("Cannot close `"+I.type+"` ("+rn({start:I.start,end:I.end})+"): it’s not open");X.position.end=ht(I.end)}function c(){return ai(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function d(I){if(this.data.expectingFirstListItemValue){const P=this.stack[this.stack.length-2];P.start=Number.parseInt(this.sliceSerialize(I),10),this.data.expectingFirstListItemValue=void 0}}function p(){const I=this.resume(),P=this.stack[this.stack.length-1];P.lang=I}function g(){const I=this.resume(),P=this.stack[this.stack.length-1];P.meta=I}function y(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const I=this.resume(),P=this.stack[this.stack.length-1];P.value=I.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function k(){const I=this.resume(),P=this.stack[this.stack.length-1];P.value=I.replace(/(\r?\n|\r)$/g,"")}function C(I){const P=this.resume(),X=this.stack[this.stack.length-1];X.label=P,X.identifier=Ze(this.sliceSerialize(I)).toLowerCase()}function E(){const I=this.resume(),P=this.stack[this.stack.length-1];P.title=I}function N(){const I=this.resume(),P=this.stack[this.stack.length-1];P.url=I}function M(I){const P=this.stack[this.stack.length-1];if(!P.depth){const X=this.sliceSerialize(I).length;P.depth=X}}function S(){this.data.setextHeadingSlurpLineEnding=!0}function O(I){const P=this.stack[this.stack.length-1];P.depth=this.sliceSerialize(I).codePointAt(0)===61?1:2}function H(){this.data.setextHeadingSlurpLineEnding=void 0}function _(I){const X=this.stack[this.stack.length-1].children;let ne=X[X.length-1];(!ne||ne.type!=="text")&&(ne=et(),ne.position={start:ht(I.start),end:void 0},X.push(ne)),this.stack.push(ne)}function v(I){const P=this.stack.pop();P.value+=this.sliceSerialize(I),P.position.end=ht(I.end)}function D(I){const P=this.stack[this.stack.length-1];if(this.data.atHardBreak){const X=P.children[P.children.length-1];X.position.end=ht(I.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(P.type)&&(_.call(this,I),v.call(this,I))}function A(){this.data.atHardBreak=!0}function F(){const I=this.resume(),P=this.stack[this.stack.length-1];P.value=I}function T(){const I=this.resume(),P=this.stack[this.stack.length-1];P.value=I}function j(){const I=this.resume(),P=this.stack[this.stack.length-1];P.value=I}function R(){const I=this.stack[this.stack.length-1];if(this.data.inReference){const P=this.data.referenceType||"shortcut";I.type+="Reference",I.referenceType=P,delete I.url,delete I.title}else delete I.identifier,delete I.label;this.data.referenceType=void 0}function $(){const I=this.stack[this.stack.length-1];if(this.data.inReference){const P=this.data.referenceType||"shortcut";I.type+="Reference",I.referenceType=P,delete I.url,delete I.title}else delete I.identifier,delete I.label;this.data.referenceType=void 0}function U(I){const P=this.sliceSerialize(I),X=this.stack[this.stack.length-2];X.label=od(P),X.identifier=Ze(P).toLowerCase()}function L(){const I=this.stack[this.stack.length-1],P=this.resume(),X=this.stack[this.stack.length-1];if(this.data.inReference=!0,X.type==="link"){const ne=I.children;X.children=ne}else X.alt=P}function x(){const I=this.resume(),P=this.stack[this.stack.length-1];P.url=I}function q(){const I=this.resume(),P=this.stack[this.stack.length-1];P.title=I}function V(){this.data.inReference=void 0}function b(){this.data.referenceType="collapsed"}function ee(I){const P=this.resume(),X=this.stack[this.stack.length-1];X.label=P,X.identifier=Ze(this.sliceSerialize(I)).toLowerCase(),this.data.referenceType="full"}function Q(I){this.data.characterReferenceType=I.type}function G(I){const P=this.sliceSerialize(I),X=this.data.characterReferenceType;let ne;X?(ne=Oo(P,X==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ne=li(P);const le=this.stack[this.stack.length-1];le.value+=ne}function de(I){const P=this.stack.pop();P.position.end=ht(I.end)}function he(I){v.call(this,I);const P=this.stack[this.stack.length-1];P.url=this.sliceSerialize(I)}function se(I){v.call(this,I);const P=this.stack[this.stack.length-1];P.url="mailto:"+this.sliceSerialize(I)}function oe(){return{type:"blockquote",children:[]}}function me(){return{type:"code",lang:null,meta:null,value:""}}function Te(){return{type:"inlineCode",value:""}}function xe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function De(){return{type:"emphasis",children:[]}}function K(){return{type:"heading",depth:0,children:[]}}function te(){return{type:"break"}}function z(){return{type:"html",value:""}}function ge(){return{type:"image",title:null,url:"",alt:null}}function Z(){return{type:"link",title:null,url:"",children:[]}}function be(I){return{type:"list",ordered:I.type==="listOrdered",start:null,spread:I._spread,children:[]}}function We(I){return{type:"listItem",spread:I._spread,checked:null,children:[]}}function Se(){return{type:"paragraph",children:[]}}function Ke(){return{type:"strong",children:[]}}function et(){return{type:"text",value:""}}function st(){return{type:"thematicBreak"}}}function ht(e){return{line:e.line,column:e.column,offset:e.offset}}function Yo(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Yo(e,r):cd(e,r)}}function cd(e,t){let n;for(n in t)if(Xo.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function os(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+rn({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+rn({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+rn({start:t.start,end:t.end})+") is still open")}function fd(e){const t=this;t.parser=n;function n(r){return ld(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function hd(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function pd(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
67
|
+
`}]}function dd(e,t){const n=t.value?t.value+`
|
|
68
|
+
`:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function md(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function gd(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function xd(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=qt(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let o,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=s+1,a+=1,e.footnoteCounts.set(r,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,l);const u={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,u),e.applyData(t,u)}function yd(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function bd(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Go(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function kd(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Go(e,t);const i={src:qt(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function wd(e,t){const n={src:qt(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function Sd(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function Cd(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Go(e,t);const i={href:qt(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function vd(e,t){const n={href:qt(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Ed(e,t,n){const r=e.all(t),i=n?Td(n):Qo(t),s={},o=[];if(typeof t.checked=="boolean"){const c=r[0];let f;c&&c.type==="element"&&c.tagName==="p"?f=c:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const c=r[a];(i||a!==0||c.type!=="element"||c.tagName!=="p")&&o.push({type:"text",value:`
|
|
69
|
+
`}),c.type==="element"&&c.tagName==="p"&&!i?o.push(...c.children):o.push(c)}const l=r[r.length-1];l&&(i||l.type!=="element"||l.tagName!=="p")&&o.push({type:"text",value:`
|
|
70
|
+
`});const u={type:"element",tagName:"li",properties:s,children:o};return e.patch(t,u),e.applyData(t,u)}function Td(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=Qo(n[r])}return t}function Qo(e){const t=e.spread;return t??e.children.length>1}function jd(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const o=r[i];if(o.type==="element"&&o.tagName==="li"&&o.properties&&Array.isArray(o.properties.className)&&o.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)}function Ad(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Id(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function Rd(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Nd(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const o={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],o),i.push(o)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=ri(t.children[1]),l=Ro(t.children[t.children.length-1]);a&&l&&(o.position={start:a,end:l}),i.push(o)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function Dd(e,t,n){const r=n?n.children:void 0,s=(r?r.indexOf(t):1)===0?"th":"td",o=n&&n.type==="table"?n.align:void 0,a=o?o.length:t.children.length;let l=-1;const u=[];for(;++l<a;){const f=t.children[l],d={},p=o?o[l]:void 0;p&&(d.align=p);let g={type:"element",tagName:s,properties:d,children:[]};f&&(g.children=e.all(f),e.patch(f,g),g=e.applyData(f,g)),u.push(g)}const c={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,c),e.applyData(t,c)}function Md(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const as=9,ls=32;function Ld(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const s=[];for(;r;)s.push(us(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return s.push(us(t.slice(i),i>0,!1)),s.join("")}function us(e,t,n){let r=0,i=e.length;if(t){let s=e.codePointAt(r);for(;s===as||s===ls;)r++,s=e.codePointAt(r)}if(n){let s=e.codePointAt(i-1);for(;s===as||s===ls;)i--,s=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function zd(e,t){const n={type:"text",value:Ld(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Pd(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const _d={blockquote:hd,break:pd,code:dd,delete:md,emphasis:gd,footnoteReference:xd,heading:yd,html:bd,imageReference:kd,image:wd,inlineCode:Sd,linkReference:Cd,link:vd,listItem:Ed,list:jd,paragraph:Ad,root:Id,strong:Rd,table:Nd,tableCell:Md,tableRow:Dd,text:zd,thematicBreak:Pd,toml:mn,yaml:mn,definition:mn,footnoteDefinition:mn};function mn(){}const Jo=-1,qn=0,on=1,Ln=2,ci=3,fi=4,hi=5,pi=6,Zo=7,ea=8,cs=typeof self=="object"?self:globalThis,Od=(e,t)=>{const n=(i,s)=>(e.set(s,i),i),r=i=>{if(e.has(i))return e.get(i);const[s,o]=t[i];switch(s){case qn:case Jo:return n(o,i);case on:{const a=n([],i);for(const l of o)a.push(r(l));return a}case Ln:{const a=n({},i);for(const[l,u]of o)a[r(l)]=r(u);return a}case ci:return n(new Date(o),i);case fi:{const{source:a,flags:l}=o;return n(new RegExp(a,l),i)}case hi:{const a=n(new Map,i);for(const[l,u]of o)a.set(r(l),r(u));return a}case pi:{const a=n(new Set,i);for(const l of o)a.add(r(l));return a}case Zo:{const{name:a,message:l}=o;return n(new cs[a](l),i)}case ea:return n(BigInt(o),i);case"BigInt":return n(Object(BigInt(o)),i);case"ArrayBuffer":return n(new Uint8Array(o).buffer,o);case"DataView":{const{buffer:a}=new Uint8Array(o);return n(new DataView(a),o)}}return n(new cs[s](o),i)};return r},fs=e=>Od(new Map,e)(0),_t="",{toString:Fd}={},{keys:$d}=Object,Jt=e=>{const t=typeof e;if(t!=="object"||!e)return[qn,t];const n=Fd.call(e).slice(8,-1);switch(n){case"Array":return[on,_t];case"Object":return[Ln,_t];case"Date":return[ci,_t];case"RegExp":return[fi,_t];case"Map":return[hi,_t];case"Set":return[pi,_t];case"DataView":return[on,n]}return n.includes("Array")?[on,n]:n.includes("Error")?[Zo,n]:[Ln,n]},gn=([e,t])=>e===qn&&(t==="function"||t==="symbol"),Bd=(e,t,n,r)=>{const i=(o,a)=>{const l=r.push(o)-1;return n.set(a,l),l},s=o=>{if(n.has(o))return n.get(o);let[a,l]=Jt(o);switch(a){case qn:{let c=o;switch(l){case"bigint":a=ea,c=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);c=null;break;case"undefined":return i([Jo],o)}return i([a,c],o)}case on:{if(l){let d=o;return l==="DataView"?d=new Uint8Array(o.buffer):l==="ArrayBuffer"&&(d=new Uint8Array(o)),i([l,[...d]],o)}const c=[],f=i([a,c],o);for(const d of o)c.push(s(d));return f}case Ln:{if(l)switch(l){case"BigInt":return i([l,o.toString()],o);case"Boolean":case"Number":case"String":return i([l,o.valueOf()],o)}if(t&&"toJSON"in o)return s(o.toJSON());const c=[],f=i([a,c],o);for(const d of $d(o))(e||!gn(Jt(o[d])))&&c.push([s(d),s(o[d])]);return f}case ci:return i([a,o.toISOString()],o);case fi:{const{source:c,flags:f}=o;return i([a,{source:c,flags:f}],o)}case hi:{const c=[],f=i([a,c],o);for(const[d,p]of o)(e||!(gn(Jt(d))||gn(Jt(p))))&&c.push([s(d),s(p)]);return f}case pi:{const c=[],f=i([a,c],o);for(const d of o)(e||!gn(Jt(d)))&&c.push(s(d));return f}}const{message:u}=o;return i([a,{name:l,message:u}],o)};return s},hs=(e,{json:t,lossy:n}={})=>{const r=[];return Bd(!(t||n),!!t,new Map,r)(e),r},zn=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?fs(hs(e,t)):structuredClone(e):(e,t)=>fs(hs(e,t));function Hd(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function Ud(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function qd(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Hd,r=e.options.footnoteBackLabel||Ud,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",o=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let l=-1;for(;++l<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[l]);if(!u)continue;const c=e.all(u),f=String(u.identifier).toUpperCase(),d=qt(f.toLowerCase());let p=0;const g=[],y=e.footnoteCounts.get(f);for(;y!==void 0&&++p<=y;){g.length>0&&g.push({type:"text",value:" "});let C=typeof n=="string"?n:n(l,p);typeof C=="string"&&(C={type:"text",value:C}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+d+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,p),className:["data-footnote-backref"]},children:Array.isArray(C)?C:[C]})}const w=c[c.length-1];if(w&&w.type==="element"&&w.tagName==="p"){const C=w.children[w.children.length-1];C&&C.type==="text"?C.value+=" ":w.children.push({type:"text",value:" "}),w.children.push(...g)}else c.push(...g);const k={type:"element",tagName:"li",properties:{id:t+"fn-"+d},children:e.wrap(c,!0)};e.patch(u,k),a.push(k)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...zn(o),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
|
|
71
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:`
|
|
72
|
+
`}]}}const Wn=(function(e){if(e==null)return Xd;if(typeof e=="function")return Kn(e);if(typeof e=="object")return Array.isArray(e)?Wd(e):Kd(e);if(typeof e=="string")return Vd(e);throw new Error("Expected function, string, or object as test")});function Wd(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Wn(e[n]);return Kn(r);function r(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function Kd(e){const t=e;return Kn(n);function n(r){const i=r;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function Vd(e){return Kn(t);function t(n){return n&&n.type===e}}function Kn(e){return t;function t(n,r,i){return!!(Yd(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function Xd(){return!0}function Yd(e){return e!==null&&typeof e=="object"&&"type"in e}const ta=[],Gd=!0,Nr=!1,Qd="skip";function na(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const s=Wn(i),o=r?-1:1;a(e,void 0,[])();function a(l,u,c){const f=l&&typeof l=="object"?l:{};if(typeof f.type=="string"){const p=typeof f.tagName=="string"?f.tagName:typeof f.name=="string"?f.name:void 0;Object.defineProperty(d,"name",{value:"node ("+(l.type+(p?"<"+p+">":""))+")"})}return d;function d(){let p=ta,g,y,w;if((!t||s(l,u,c[c.length-1]||void 0))&&(p=Jd(n(l,c)),p[0]===Nr))return p;if("children"in l&&l.children){const k=l;if(k.children&&p[0]!==Qd)for(y=(r?k.children.length:-1)+o,w=c.concat(k);y>-1&&y<k.children.length;){const C=k.children[y];if(g=a(C,y,w)(),g[0]===Nr)return g;y=typeof g[1]=="number"?g[1]:y+o}}return p}}}function Jd(e){return Array.isArray(e)?e:typeof e=="number"?[Gd,e]:e==null?ta:[e]}function di(e,t,n,r){let i,s,o;typeof t=="function"&&typeof n!="function"?(s=void 0,o=t,i=n):(s=t,o=n,i=r),na(e,s,a,i);function a(l,u){const c=u[u.length-1],f=c?c.children.indexOf(l):void 0;return o(l,f,c)}}const Dr={}.hasOwnProperty,Zd={};function em(e,t){const n=t||Zd,r=new Map,i=new Map,s=new Map,o={..._d,...n.handlers},a={all:u,applyData:nm,definitionById:r,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:o,one:l,options:n,patch:tm,wrap:im};return di(e,function(c){if(c.type==="definition"||c.type==="footnoteDefinition"){const f=c.type==="definition"?r:i,d=String(c.identifier).toUpperCase();f.has(d)||f.set(d,c)}}),a;function l(c,f){const d=c.type,p=a.handlers[d];if(Dr.call(a.handlers,d)&&p)return p(a,c,f);if(a.options.passThrough&&a.options.passThrough.includes(d)){if("children"in c){const{children:y,...w}=c,k=zn(w);return k.children=a.all(c),k}return zn(c)}return(a.options.unknownHandler||rm)(a,c,f)}function u(c){const f=[];if("children"in c){const d=c.children;let p=-1;for(;++p<d.length;){const g=a.one(d[p],c);if(g){if(p&&d[p-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=ps(g.value)),!Array.isArray(g)&&g.type==="element")){const y=g.children[0];y&&y.type==="text"&&(y.value=ps(y.value))}Array.isArray(g)?f.push(...g):f.push(g)}}}return f}}function tm(e,t){e.position&&(t.position=Uf(e))}function nm(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,s=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const o="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:o}}n.type==="element"&&s&&Object.assign(n.properties,zn(s)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function rm(e,t){const n=t.data||{},r="value"in t&&!(Dr.call(n,"hProperties")||Dr.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function im(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
|
|
73
|
+
`});++r<e.length;)r&&n.push({type:"text",value:`
|
|
74
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
|
|
75
|
+
`}),n}function ps(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function ds(e,t){const n=em(e,t),r=n.one(e,void 0),i=qd(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
|
|
76
|
+
`},i),s}function sm(e,t){return e&&"run"in e?async function(n,r){const i=ds(n,{file:r,...t});await e.run(i,r)}:function(n,r){return ds(n,{file:r,...e||t})}}function ms(e){if(e)throw e}var or,gs;function om(){if(gs)return or;gs=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):t.call(u)==="[object Array]"},s=function(u){if(!u||t.call(u)!=="[object Object]")return!1;var c=e.call(u,"constructor"),f=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!c&&!f)return!1;var d;for(d in u);return typeof d>"u"||e.call(u,d)},o=function(u,c){n&&c.name==="__proto__"?n(u,c.name,{enumerable:!0,configurable:!0,value:c.newValue,writable:!0}):u[c.name]=c.newValue},a=function(u,c){if(c==="__proto__")if(e.call(u,c)){if(r)return r(u,c).value}else return;return u[c]};return or=function l(){var u,c,f,d,p,g,y=arguments[0],w=1,k=arguments.length,C=!1;for(typeof y=="boolean"&&(C=y,y=arguments[1]||{},w=2),(y==null||typeof y!="object"&&typeof y!="function")&&(y={});w<k;++w)if(u=arguments[w],u!=null)for(c in u)f=a(y,c),d=a(u,c),y!==d&&(C&&d&&(s(d)||(p=i(d)))?(p?(p=!1,g=f&&i(f)?f:[]):g=f&&s(f)?f:{},o(y,{name:c,newValue:l(C,g,d)})):typeof d<"u"&&o(y,{name:c,newValue:d}));return y},or}var am=om();const ar=Fs(am);function Mr(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function lm(){const e=[],t={run:n,use:r};return t;function n(...i){let s=-1;const o=i.pop();if(typeof o!="function")throw new TypeError("Expected function as last argument, not "+o);a(null,...i);function a(l,...u){const c=e[++s];let f=-1;if(l){o(l);return}for(;++f<i.length;)(u[f]===null||u[f]===void 0)&&(u[f]=i[f]);i=u,c?um(c,a)(...u):o(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function um(e,t){let n;return r;function r(...o){const a=e.length>o.length;let l;a&&o.push(i);try{l=e.apply(this,o)}catch(u){const c=u;if(a&&n)throw c;return i(c)}a||(l&&l.then&&typeof l.then=="function"?l.then(s,i):l instanceof Error?i(l):s(l))}function i(o,...a){n||(n=!0,t(o,...a))}function s(o){i(null,o)}}const nt={basename:cm,dirname:fm,extname:hm,join:pm,sep:"/"};function cm(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');fn(e);let n=0,r=-1,i=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else r<0&&(s=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let o=-1,a=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){n=i+1;break}}else o<0&&(s=!0,o=i+1),a>-1&&(e.codePointAt(i)===t.codePointAt(a--)?a<0&&(r=i):(a=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function fm(e){if(fn(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function hm(e){fn(e);let t=e.length,n=-1,r=0,i=-1,s=0,o;for(;t--;){const a=e.codePointAt(t);if(a===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),a===46?i<0?i=t:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||n<0||s===0||s===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function pm(...e){let t=-1,n;for(;++t<e.length;)fn(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":dm(n)}function dm(e){fn(e);const t=e.codePointAt(0)===47;let n=mm(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function mm(e,t){let n="",r=0,i=-1,s=0,o=-1,a,l;for(;++o<=e.length;){if(o<e.length)a=e.codePointAt(o);else{if(a===47)break;a=47}if(a===47){if(!(i===o-1||s===1))if(i!==o-1&&s===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),i=o,s=0;continue}}else if(n.length>0){n="",r=0,i=o,s=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,s=0}else a===46&&s>-1?s++:s=-1}return n}function fn(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const gm={cwd:xm};function xm(){return"/"}function Lr(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function ym(e){if(typeof e=="string")e=new URL(e);else if(!Lr(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return bm(e)}function bm(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const lr=["history","path","basename","stem","extname","dirname"];class ra{constructor(t){let n;t?Lr(t)?n={path:t}:typeof t=="string"||km(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":gm.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<lr.length;){const s=lr[r];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s])}let i;for(i in n)lr.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?nt.basename(this.path):void 0}set basename(t){cr(t,"basename"),ur(t,"basename"),this.path=nt.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?nt.dirname(this.path):void 0}set dirname(t){xs(this.basename,"dirname"),this.path=nt.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?nt.extname(this.path):void 0}set extname(t){if(ur(t,"extname"),xs(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=nt.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Lr(t)&&(t=ym(t)),cr(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?nt.basename(this.path,this.extname):void 0}set stem(t){cr(t,"stem"),ur(t,"stem"),this.path=nt.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new Ie(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function ur(e,t){if(e&&e.includes(nt.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+nt.sep+"`")}function cr(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function xs(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function km(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const wm=(function(e){const r=this.constructor.prototype,i=r[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,r),s}),Sm={}.hasOwnProperty;class mi extends wm{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=lm()}copy(){const t=new mi;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(ar(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(pr("data",this.frozen),this.namespace[t]=n,this):Sm.call(this.namespace,t)&&this.namespace[t]||void 0:t?(pr("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=xn(t),r=this.parser||this.Parser;return fr("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),fr("process",this.parser||this.Parser),hr("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(s,o){const a=xn(t),l=r.parse(a);r.run(l,a,function(c,f,d){if(c||!f||!d)return u(c);const p=f,g=r.stringify(p,d);Em(g)?d.value=g:d.result=g,u(c,d)});function u(c,f){c||!f?o(c):s?s(f):n(void 0,f)}}}processSync(t){let n=!1,r;return this.freeze(),fr("processSync",this.parser||this.Parser),hr("processSync",this.compiler||this.Compiler),this.process(t,i),bs("processSync","process",n),r;function i(s,o){n=!0,ms(s),r=o}}run(t,n,r){ys(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?s(void 0,r):new Promise(s);function s(o,a){const l=xn(n);i.run(t,l,u);function u(c,f,d){const p=f||t;c?a(c):o?o(p):r(void 0,p,d)}}}runSync(t,n){let r=!1,i;return this.run(t,n,s),bs("runSync","run",r),i;function s(o,a){ms(o),i=a,r=!0}}stringify(t,n){this.freeze();const r=xn(n),i=this.compiler||this.Compiler;return hr("stringify",i),ys(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(pr("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?a(t):o(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(u){if(typeof u=="function")l(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[c,...f]=u;l(c,f)}else o(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function o(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(u.plugins),u.settings&&(i.settings=ar(!0,i.settings,u.settings))}function a(u){let c=-1;if(u!=null)if(Array.isArray(u))for(;++c<u.length;){const f=u[c];s(f)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function l(u,c){let f=-1,d=-1;for(;++f<r.length;)if(r[f][0]===u){d=f;break}if(d===-1)r.push([u,...c]);else if(c.length>0){let[p,...g]=c;const y=r[d][1];Mr(y)&&Mr(p)&&(p=ar(!0,y,p)),r[d]=[u,p,...g]}}}}const Cm=new mi().freeze();function fr(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function hr(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function pr(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function ys(e){if(!Mr(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function bs(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function xn(e){return vm(e)?e:new ra(e)}function vm(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Em(e){return typeof e=="string"||Tm(e)}function Tm(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const jm="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",ks=[],ws={allowDangerousHtml:!0},Am=/^(https?|ircs?|mailto|xmpp)$/i,Im=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Rm(e){const t=Nm(e),n=Dm(e);return Mm(t.runSync(t.parse(n),n),e)}function Nm(e){const t=e.rehypePlugins||ks,n=e.remarkPlugins||ks,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...ws}:ws;return Cm().use(fd).use(n).use(sm,r).use(t)}function Dm(e){const t=e.children||"",n=new ra;return typeof t=="string"&&(n.value=t),n}function Mm(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,s=t.disallowedElements,o=t.skipHtml,a=t.unwrapDisallowed,l=t.urlTransform||Lm;for(const c of Im)Object.hasOwn(t,c.from)&&(""+c.from+(c.to?"use `"+c.to+"` instead":"remove it")+jm+c.id,void 0);return di(e,u),Xf(e,{Fragment:h.Fragment,components:i,ignoreInvalidStyle:!0,jsx:h.jsx,jsxs:h.jsxs,passKeys:!0,passNode:!0});function u(c,f,d){if(c.type==="raw"&&d&&typeof f=="number")return o?d.children.splice(f,1):d.children[f]={type:"text",value:c.value},f;if(c.type==="element"){let p;for(p in rr)if(Object.hasOwn(rr,p)&&Object.hasOwn(c.properties,p)){const g=c.properties[p],y=rr[p];(y===null||y.includes(c.tagName))&&(c.properties[p]=l(String(g||""),p,c))}}if(c.type==="element"){let p=n?!n.includes(c.tagName):s?s.includes(c.tagName):!1;if(!p&&r&&typeof f=="number"&&(p=!r(c,f,d)),p&&d&&typeof f=="number")return a&&c.children?d.children.splice(f,1,...c.children):d.children.splice(f,1),f}}}function Lm(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||Am.test(e.slice(0,t))?e:""}function zm(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function ia(e,t,n){const i=Wn((n||{}).ignore||[]),s=Pm(t);let o=-1;for(;++o<s.length;)na(e,"text",a);function a(u,c){let f=-1,d;for(;++f<c.length;){const p=c[f],g=d?d.children:void 0;if(i(p,g?g.indexOf(p):void 0,d))return;d=p}if(d)return l(u,c)}function l(u,c){const f=c[c.length-1],d=s[o][0],p=s[o][1];let g=0;const w=f.children.indexOf(u);let k=!1,C=[];d.lastIndex=0;let E=d.exec(u.value);for(;E;){const N=E.index,M={index:E.index,input:E.input,stack:[...c,u]};let S=p(...E,M);if(typeof S=="string"&&(S=S.length>0?{type:"text",value:S}:void 0),S===!1?d.lastIndex=N+1:(g!==N&&C.push({type:"text",value:u.value.slice(g,N)}),Array.isArray(S)?C.push(...S):S&&C.push(S),g=N+E[0].length,k=!0),!d.global)break;E=d.exec(u.value)}return k?(g<u.value.length&&C.push({type:"text",value:u.value.slice(g)}),f.children.splice(w,1,...C)):C=[u],w+C.length}}function Pm(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const i=n[r];t.push([_m(i[0]),Om(i[1])])}return t}function _m(e){return typeof e=="string"?new RegExp(zm(e),"g"):e}function Om(e){return typeof e=="function"?e:function(){return e}}function Fm(e){ia(e,[/\r?\n|\r/g,$m])}function $m(){return{type:"break"}}function Bm(){return function(e){Fm(e)}}const dr="phrasing",mr=["autolink","link","image","label"];function Hm(){return{transforms:[Ym],enter:{literalAutolink:qm,literalAutolinkEmail:gr,literalAutolinkHttp:gr,literalAutolinkWww:gr},exit:{literalAutolink:Xm,literalAutolinkEmail:Vm,literalAutolinkHttp:Wm,literalAutolinkWww:Km}}}function Um(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:dr,notInConstruct:mr},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:dr,notInConstruct:mr},{character:":",before:"[ps]",after:"\\/",inConstruct:dr,notInConstruct:mr}]}}function qm(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function gr(e){this.config.enter.autolinkProtocol.call(this,e)}function Wm(e){this.config.exit.autolinkProtocol.call(this,e)}function Km(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function Vm(e){this.config.exit.autolinkEmail.call(this,e)}function Xm(e){this.exit(e)}function Ym(e){ia(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Gm],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Qm]],{ignore:["link","linkReference"]})}function Gm(e,t,n,r,i){let s="";if(!sa(i)||(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!Jm(n)))return!1;const o=Zm(n+r);if(!o[0])return!1;const a={type:"link",title:null,url:s+t+o[0],children:[{type:"text",value:t+o[0]}]};return o[1]?[a,{type:"text",value:o[1]}]:a}function Qm(e,t,n,r){return!sa(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Jm(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function Zm(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const i=Ai(e,"(");let s=Ai(e,")");for(;r!==-1&&i>s;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),s++;return[e,n]}function sa(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Dt(n)||Hn(n))&&(!t||n!==47)}oa.peek=lg;function eg(){this.buffer()}function tg(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function ng(){this.buffer()}function rg(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function ig(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ze(this.sliceSerialize(e)).toLowerCase(),n.label=t}function sg(e){this.exit(e)}function og(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Ze(this.sliceSerialize(e)).toLowerCase(),n.label=t}function ag(e){this.exit(e)}function lg(){return"["}function oa(e,t,n,r){const i=n.createTracker(r);let s=i.move("[^");const o=n.enter("footnoteReference"),a=n.enter("reference");return s+=i.move(n.safe(n.associationId(e),{after:"]",before:s})),a(),o(),s+=i.move("]"),s}function ug(){return{enter:{gfmFootnoteCallString:eg,gfmFootnoteCall:tg,gfmFootnoteDefinitionLabelString:ng,gfmFootnoteDefinition:rg},exit:{gfmFootnoteCallString:ig,gfmFootnoteCall:sg,gfmFootnoteDefinitionLabelString:og,gfmFootnoteDefinition:ag}}}function cg(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:oa},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,i,s,o){const a=s.createTracker(o);let l=a.move("[^");const u=s.enter("footnoteDefinition"),c=s.enter("label");return l+=a.move(s.safe(s.associationId(r),{before:l,after:"]"})),c(),l+=a.move("]:"),r.children&&r.children.length>0&&(a.shift(4),l+=a.move((t?`
|
|
77
|
+
`:" ")+s.indentLines(s.containerFlow(r,a.current()),t?aa:fg))),u(),l}}function fg(e,t,n){return t===0?e:aa(e,t,n)}function aa(e,t,n){return(n?"":" ")+e}const hg=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];la.peek=xg;function pg(){return{canContainEols:["delete"],enter:{strikethrough:mg},exit:{strikethrough:gg}}}function dg(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:hg}],handlers:{delete:la}}}function mg(e){this.enter({type:"delete",children:[]},e)}function gg(e){this.exit(e)}function la(e,t,n,r){const i=n.createTracker(r),s=n.enter("strikethrough");let o=i.move("~~");return o+=n.containerPhrasing(e,{...i.current(),before:o,after:"~"}),o+=i.move("~~"),s(),o}function xg(){return"~"}function yg(e){return e.length}function bg(e,t){const n=t||{},r=(n.align||[]).concat(),i=n.stringLength||yg,s=[],o=[],a=[],l=[];let u=0,c=-1;for(;++c<e.length;){const y=[],w=[];let k=-1;for(e[c].length>u&&(u=e[c].length);++k<e[c].length;){const C=kg(e[c][k]);if(n.alignDelimiters!==!1){const E=i(C);w[k]=E,(l[k]===void 0||E>l[k])&&(l[k]=E)}y.push(C)}o[c]=y,a[c]=w}let f=-1;if(typeof r=="object"&&"length"in r)for(;++f<u;)s[f]=Ss(r[f]);else{const y=Ss(r);for(;++f<u;)s[f]=y}f=-1;const d=[],p=[];for(;++f<u;){const y=s[f];let w="",k="";y===99?(w=":",k=":"):y===108?w=":":y===114&&(k=":");let C=n.alignDelimiters===!1?1:Math.max(1,l[f]-w.length-k.length);const E=w+"-".repeat(C)+k;n.alignDelimiters!==!1&&(C=w.length+C+k.length,C>l[f]&&(l[f]=C),p[f]=C),d[f]=E}o.splice(1,0,d),a.splice(1,0,p),c=-1;const g=[];for(;++c<o.length;){const y=o[c],w=a[c];f=-1;const k=[];for(;++f<u;){const C=y[f]||"";let E="",N="";if(n.alignDelimiters!==!1){const M=l[f]-(w[f]||0),S=s[f];S===114?E=" ".repeat(M):S===99?M%2?(E=" ".repeat(M/2+.5),N=" ".repeat(M/2-.5)):(E=" ".repeat(M/2),N=E):N=" ".repeat(M)}n.delimiterStart!==!1&&!f&&k.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&C==="")&&(n.delimiterStart!==!1||f)&&k.push(" "),n.alignDelimiters!==!1&&k.push(E),k.push(C),n.alignDelimiters!==!1&&k.push(N),n.padding!==!1&&k.push(" "),(n.delimiterEnd!==!1||f!==u-1)&&k.push("|")}g.push(n.delimiterEnd===!1?k.join("").replace(/ +$/,""):k.join(""))}return g.join(`
|
|
78
|
+
`)}function kg(e){return e==null?"":String(e)}function Ss(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function wg(e,t,n,r){const i=n.enter("blockquote"),s=n.createTracker(r);s.move("> "),s.shift(2);const o=n.indentLines(n.containerFlow(e,s.current()),Sg);return i(),o}function Sg(e,t,n){return">"+(n?"":" ")+e}function Cg(e,t){return Cs(e,t.inConstruct,!0)&&!Cs(e,t.notInConstruct,!1)}function Cs(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function vs(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
79
|
+
`&&Cg(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?"":" ";return`\\
|
|
80
|
+
`}function vg(e,t){const n=String(e);let r=n.indexOf(t),i=r,s=0,o=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===i?++s>o&&(o=s):s=1,i=r+t.length,r=n.indexOf(t,i);return o}function Eg(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function Tg(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function jg(e,t,n,r){const i=Tg(n),s=e.value||"",o=i==="`"?"GraveAccent":"Tilde";if(Eg(e,n)){const f=n.enter("codeIndented"),d=n.indentLines(s,Ag);return f(),d}const a=n.createTracker(r),l=i.repeat(Math.max(vg(s,i)+1,3)),u=n.enter("codeFenced");let c=a.move(l);if(e.lang){const f=n.enter(`codeFencedLang${o}`);c+=a.move(n.safe(e.lang,{before:c,after:" ",encode:["`"],...a.current()})),f()}if(e.lang&&e.meta){const f=n.enter(`codeFencedMeta${o}`);c+=a.move(" "),c+=a.move(n.safe(e.meta,{before:c,after:`
|
|
81
|
+
`,encode:["`"],...a.current()})),f()}return c+=a.move(`
|
|
82
|
+
`),s&&(c+=a.move(s+`
|
|
83
|
+
`)),c+=a.move(l),u(),c}function Ag(e,t,n){return(n?"":" ")+e}function gi(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Ig(e,t,n,r){const i=gi(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("definition");let a=n.enter("label");const l=n.createTracker(r);let u=l.move("[");return u+=l.move(n.safe(n.associationId(e),{before:u,after:"]",...l.current()})),u+=l.move("]: "),a(),!e.url||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(n.safe(e.url,{before:u,after:">",...l.current()})),u+=l.move(">")):(a=n.enter("destinationRaw"),u+=l.move(n.safe(e.url,{before:u,after:e.title?" ":`
|
|
84
|
+
`,...l.current()}))),a(),e.title&&(a=n.enter(`title${s}`),u+=l.move(" "+i),u+=l.move(n.safe(e.title,{before:u,after:i,...l.current()})),u+=l.move(i),a()),o(),u}function Rg(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function ln(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Pn(e,t,n){const r=Ht(e),i=Ht(t);return r===void 0?i===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}ua.peek=Ng;function ua(e,t,n,r){const i=Rg(n),s=n.enter("emphasis"),o=n.createTracker(r),a=o.move(i);let l=o.move(n.containerPhrasing(e,{after:i,before:a,...o.current()}));const u=l.charCodeAt(0),c=Pn(r.before.charCodeAt(r.before.length-1),u,i);c.inside&&(l=ln(u)+l.slice(1));const f=l.charCodeAt(l.length-1),d=Pn(r.after.charCodeAt(0),f,i);d.inside&&(l=l.slice(0,-1)+ln(f));const p=o.move(i);return s(),n.attentionEncodeSurroundingInfo={after:d.outside,before:c.outside},a+l+p}function Ng(e,t,n){return n.options.emphasis||"*"}function Dg(e,t){let n=!1;return di(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,Nr}),!!((!e.depth||e.depth<3)&&ai(e)&&(t.options.setext||n))}function Mg(e,t,n,r){const i=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(r);if(Dg(e,n)){const c=n.enter("headingSetext"),f=n.enter("phrasing"),d=n.containerPhrasing(e,{...s.current(),before:`
|
|
85
|
+
`,after:`
|
|
86
|
+
`});return f(),c(),d+`
|
|
87
|
+
`+(i===1?"=":"-").repeat(d.length-(Math.max(d.lastIndexOf("\r"),d.lastIndexOf(`
|
|
88
|
+
`))+1))}const o="#".repeat(i),a=n.enter("headingAtx"),l=n.enter("phrasing");s.move(o+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
|
|
89
|
+
`,...s.current()});return/^[\t ]/.test(u)&&(u=ln(u.charCodeAt(0))+u.slice(1)),u=u?o+" "+u:o,n.options.closeAtx&&(u+=" "+o),l(),a(),u}ca.peek=Lg;function ca(e){return e.value||""}function Lg(){return"<"}fa.peek=zg;function fa(e,t,n,r){const i=gi(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let a=n.enter("label");const l=n.createTracker(r);let u=l.move("![");return u+=l.move(n.safe(e.alt,{before:u,after:"]",...l.current()})),u+=l.move("]("),a(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(a=n.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(n.safe(e.url,{before:u,after:">",...l.current()})),u+=l.move(">")):(a=n.enter("destinationRaw"),u+=l.move(n.safe(e.url,{before:u,after:e.title?" ":")",...l.current()}))),a(),e.title&&(a=n.enter(`title${s}`),u+=l.move(" "+i),u+=l.move(n.safe(e.title,{before:u,after:i,...l.current()})),u+=l.move(i),a()),u+=l.move(")"),o(),u}function zg(){return"!"}ha.peek=Pg;function ha(e,t,n,r){const i=e.referenceType,s=n.enter("imageReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("![");const u=n.safe(e.alt,{before:l,after:"]",...a.current()});l+=a.move(u+"]["),o();const c=n.stack;n.stack=[],o=n.enter("reference");const f=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=c,s(),i==="full"||!u||u!==f?l+=a.move(f+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function Pg(){return"!"}pa.peek=_g;function pa(e,t,n){let r=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const o=n.unsafe[s],a=n.compilePattern(o);let l;if(o.atBreak)for(;l=a.exec(r);){let u=l.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(l.index+1)}}return i+r+i}function _g(){return"`"}function da(e,t){const n=ai(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}ma.peek=Og;function ma(e,t,n,r){const i=gi(n),s=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let a,l;if(da(e,n)){const c=n.stack;n.stack=[],a=n.enter("autolink");let f=o.move("<");return f+=o.move(n.containerPhrasing(e,{before:f,after:">",...o.current()})),f+=o.move(">"),a(),n.stack=c,f}a=n.enter("link"),l=n.enter("label");let u=o.move("[");return u+=o.move(n.containerPhrasing(e,{before:u,after:"](",...o.current()})),u+=o.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=o.move("<"),u+=o.move(n.safe(e.url,{before:u,after:">",...o.current()})),u+=o.move(">")):(l=n.enter("destinationRaw"),u+=o.move(n.safe(e.url,{before:u,after:e.title?" ":")",...o.current()}))),l(),e.title&&(l=n.enter(`title${s}`),u+=o.move(" "+i),u+=o.move(n.safe(e.title,{before:u,after:i,...o.current()})),u+=o.move(i),l()),u+=o.move(")"),a(),u}function Og(e,t,n){return da(e,n)?"<":"["}ga.peek=Fg;function ga(e,t,n,r){const i=e.referenceType,s=n.enter("linkReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("[");const u=n.containerPhrasing(e,{before:l,after:"]",...a.current()});l+=a.move(u+"]["),o();const c=n.stack;n.stack=[],o=n.enter("reference");const f=n.safe(n.associationId(e),{before:l,after:"]",...a.current()});return o(),n.stack=c,s(),i==="full"||!u||u!==f?l+=a.move(f+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function Fg(){return"["}function xi(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function $g(e){const t=xi(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Bg(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function xa(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Hg(e,t,n,r){const i=n.enter("list"),s=n.bulletCurrent;let o=e.ordered?Bg(n):xi(n);const a=e.ordered?o==="."?")":".":$g(n);let l=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){const c=e.children?e.children[0]:void 0;if((o==="*"||o==="-")&&c&&(!c.children||!c.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),xa(n)===o&&c){let f=-1;for(;++f<e.children.length;){const d=e.children[f];if(d&&d.type==="listItem"&&d.children&&d.children[0]&&d.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(o=a),n.bulletCurrent=o;const u=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=s,i(),u}function Ug(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function qg(e,t,n,r){const i=Ug(n);let s=n.bulletCurrent||xi(n);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let o=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);const a=n.createTracker(r);a.move(s+" ".repeat(o-s.length)),a.shift(o);const l=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,a.current()),c);return l(),u;function c(f,d,p){return d?(p?"":" ".repeat(o))+f:(p?s:s+" ".repeat(o-s.length))+f}}function Wg(e,t,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),o=n.containerPhrasing(e,r);return s(),i(),o}const Kg=Wn(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Vg(e,t,n,r){return(e.children.some(function(o){return Kg(o)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function Xg(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}ya.peek=Yg;function ya(e,t,n,r){const i=Xg(n),s=n.enter("strong"),o=n.createTracker(r),a=o.move(i+i);let l=o.move(n.containerPhrasing(e,{after:i,before:a,...o.current()}));const u=l.charCodeAt(0),c=Pn(r.before.charCodeAt(r.before.length-1),u,i);c.inside&&(l=ln(u)+l.slice(1));const f=l.charCodeAt(l.length-1),d=Pn(r.after.charCodeAt(0),f,i);d.inside&&(l=l.slice(0,-1)+ln(f));const p=o.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:d.outside,before:c.outside},a+l+p}function Yg(e,t,n){return n.options.strong||"*"}function Gg(e,t,n,r){return n.safe(e.value,r)}function Qg(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Jg(e,t,n){const r=(xa(n)+(n.options.ruleSpaces?" ":"")).repeat(Qg(n));return n.options.ruleSpaces?r.slice(0,-1):r}const ba={blockquote:wg,break:vs,code:jg,definition:Ig,emphasis:ua,hardBreak:vs,heading:Mg,html:ca,image:fa,imageReference:ha,inlineCode:pa,link:ma,linkReference:ga,list:Hg,listItem:qg,paragraph:Wg,root:Vg,strong:ya,text:Gg,thematicBreak:Jg};function Zg(){return{enter:{table:ex,tableData:Es,tableHeader:Es,tableRow:nx},exit:{codeText:rx,table:tx,tableData:xr,tableHeader:xr,tableRow:xr}}}function ex(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function tx(e){this.exit(e),this.data.inTable=void 0}function nx(e){this.enter({type:"tableRow",children:[]},e)}function xr(e){this.exit(e)}function Es(e){this.enter({type:"tableCell",children:[]},e)}function rx(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,ix));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function ix(e,t){return t==="|"?t:e}function sx(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
90
|
+
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:d,table:o,tableCell:l,tableRow:a}};function o(p,g,y,w){return u(c(p,y,w),p.align)}function a(p,g,y,w){const k=f(p,y,w),C=u([k]);return C.slice(0,C.indexOf(`
|
|
91
|
+
`))}function l(p,g,y,w){const k=y.enter("tableCell"),C=y.enter("phrasing"),E=y.containerPhrasing(p,{...w,before:s,after:s});return C(),k(),E}function u(p,g){return bg(p,{align:g,alignDelimiters:r,padding:n,stringLength:i})}function c(p,g,y){const w=p.children;let k=-1;const C=[],E=g.enter("table");for(;++k<w.length;)C[k]=f(w[k],g,y);return E(),C}function f(p,g,y){const w=p.children;let k=-1;const C=[],E=g.enter("tableRow");for(;++k<w.length;)C[k]=l(w[k],p,g,y);return E(),C}function d(p,g,y){let w=ba.inlineCode(p,g,y);return y.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function ox(){return{exit:{taskListCheckValueChecked:Ts,taskListCheckValueUnchecked:Ts,paragraph:lx}}}function ax(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:ux}}}function Ts(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function lx(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function ux(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let l=ba.listItem(e,t,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),l;function u(c){return c+o}}function cx(){return[Hm(),ug(),pg(),Zg(),ox()]}function fx(e){return{extensions:[Um(),cg(e),dg(),sx(e),ax()]}}const hx={tokenize:yx,partial:!0},ka={tokenize:bx,partial:!0},wa={tokenize:kx,partial:!0},Sa={tokenize:wx,partial:!0},px={tokenize:Sx,partial:!0},Ca={name:"wwwAutolink",tokenize:gx,previous:Ea},va={name:"protocolAutolink",tokenize:xx,previous:Ta},ut={name:"emailAutolink",tokenize:mx,previous:ja},it={};function dx(){return{text:it}}let Ct=48;for(;Ct<123;)it[Ct]=ut,Ct++,Ct===58?Ct=65:Ct===91&&(Ct=97);it[43]=ut;it[45]=ut;it[46]=ut;it[95]=ut;it[72]=[ut,va];it[104]=[ut,va];it[87]=[ut,Ca];it[119]=[ut,Ca];function mx(e,t,n){const r=this;let i,s;return o;function o(f){return!zr(f)||!ja.call(r,r.previous)||yi(r.events)?n(f):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(f))}function a(f){return zr(f)?(e.consume(f),a):f===64?(e.consume(f),l):n(f)}function l(f){return f===46?e.check(px,c,u)(f):f===45||f===95||Ae(f)?(s=!0,e.consume(f),l):c(f)}function u(f){return e.consume(f),i=!0,l}function c(f){return s&&i&&Re(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(f)):n(f)}}function gx(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!Ea.call(r,r.previous)||yi(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(hx,e.attempt(ka,e.attempt(wa,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function xx(e,t,n){const r=this;let i="",s=!1;return o;function o(f){return(f===72||f===104)&&Ta.call(r,r.previous)&&!yi(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(f),e.consume(f),a):n(f)}function a(f){if(Re(f)&&i.length<5)return i+=String.fromCodePoint(f),e.consume(f),a;if(f===58){const d=i.toLowerCase();if(d==="http"||d==="https")return e.consume(f),l}return n(f)}function l(f){return f===47?(e.consume(f),s?u:(s=!0,l)):n(f)}function u(f){return f===null||Mn(f)||pe(f)||Dt(f)||Hn(f)?n(f):e.attempt(ka,e.attempt(wa,c),n)(f)}function c(f){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(f)}}function yx(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),s):n(o)}function s(o){return o===null?n(o):t(o)}}function bx(e,t,n){let r,i,s;return o;function o(u){return u===46||u===95?e.check(Sa,l,a)(u):u===null||pe(u)||Dt(u)||u!==45&&Hn(u)?l(u):(s=!0,e.consume(u),o)}function a(u){return u===95?r=!0:(i=r,r=void 0),e.consume(u),o}function l(u){return i||r||!s?n(u):t(u)}}function kx(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Sa,t,s)(o):o===null||pe(o)||Dt(o)?t(o):(e.consume(o),i)}function s(o){return o===41&&r++,e.consume(o),i}}function wx(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),i):a===60||a===null||pe(a)||Dt(a)?t(a):n(a)}function i(a){return a===null||a===40||a===91||pe(a)||Dt(a)?t(a):r(a)}function s(a){return Re(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):Re(a)?(e.consume(a),o):n(a)}}function Sx(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return Ae(s)?n(s):t(s)}}function Ea(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||pe(e)}function Ta(e){return!Re(e)}function ja(e){return!(e===47||zr(e))}function zr(e){return e===43||e===45||e===46||e===95||Ae(e)}function yi(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Cx={tokenize:Nx,partial:!0};function vx(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Ax,continuation:{tokenize:Ix},exit:Rx}},text:{91:{name:"gfmFootnoteCall",tokenize:jx},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Ex,resolveTo:Tx}}}}function Ex(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const u=Ze(r.sliceSerialize({start:o.end,end:r.now()}));return u.codePointAt(0)!==94||!s.includes(u.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function Tx(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function jx(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),l}function l(f){return f!==94?n(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(f){if(s>999||f===93&&!o||f===null||f===91||pe(f))return n(f);if(f===93){e.exit("chunkString");const d=e.exit("gfmFootnoteCallString");return i.includes(Ze(r.sliceSerialize(d)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return pe(f)||(o=!0),s++,e.consume(f),f===92?c:u}function c(f){return f===91||f===92||f===93?(e.consume(f),s++,u):u(f)}}function Ax(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return l;function l(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):n(g)}function c(g){if(o>999||g===93&&!a||g===null||g===91||pe(g))return n(g);if(g===93){e.exit("chunkString");const y=e.exit("gfmFootnoteDefinitionLabelString");return s=Ze(r.sliceSerialize(y)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),d}return pe(g)||(a=!0),o++,e.consume(g),g===92?f:c}function f(g){return g===91||g===92||g===93?(e.consume(g),o++,c):c(g)}function d(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),i.includes(s)||i.push(s),ae(e,p,"gfmFootnoteDefinitionWhitespace")):n(g)}function p(g){return t(g)}}function Ix(e,t,n){return e.check(cn,t,e.attempt(Cx,t,n))}function Rx(e){e.exit("gfmFootnoteDefinition")}function Nx(e,t,n){const r=this;return ae(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(s):n(s)}}function Dx(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let u=l;for(;u--;)if(o[u][0]==="exit"&&o[u][1].type==="strikethroughSequenceTemporary"&&o[u][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[u][1].end.offset-o[u][1].start.offset){o[l][1].type="strikethroughSequence",o[u][1].type="strikethroughSequence";const c={type:"strikethrough",start:Object.assign({},o[u][1].start),end:Object.assign({},o[l][1].end)},f={type:"strikethroughText",start:Object.assign({},o[u][1].end),end:Object.assign({},o[l][1].start)},d=[["enter",c,a],["enter",o[u][1],a],["exit",o[u][1],a],["enter",f,a]],p=a.parser.constructs.insideSpan.null;p&&Oe(d,d.length,0,Un(p,o.slice(u+1,l),a)),Oe(d,d.length,0,[["exit",f,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",c,a]]),Oe(o,u-1,l-u+3,d),l=u+d.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){const u=this.previous,c=this.events;let f=0;return d;function d(g){return u===126&&c[c.length-1][1].type!=="characterEscape"?l(g):(o.enter("strikethroughSequenceTemporary"),p(g))}function p(g){const y=Ht(u);if(g===126)return f>1?l(g):(o.consume(g),f++,p);if(f<2&&!n)return l(g);const w=o.exit("strikethroughSequenceTemporary"),k=Ht(g);return w._open=!k||k===2&&!!y,w._close=!y||y===2&&!!k,a(g)}}}class Mx{constructor(){this.map=[]}add(t,n,r){Lx(this,t,n,r)}consume(t){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function Lx(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function zx(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function Px(){return{flow:{null:{name:"table",tokenize:_x,resolveAll:Ox}}}}function _x(e,t,n){const r=this;let i=0,s=0,o;return a;function a(v){let D=r.events.length-1;for(;D>-1;){const T=r.events[D][1].type;if(T==="lineEnding"||T==="linePrefix")D--;else break}const A=D>-1?r.events[D][1].type:null,F=A==="tableHead"||A==="tableRow"?S:l;return F===S&&r.parser.lazy[r.now().line]?n(v):F(v)}function l(v){return e.enter("tableHead"),e.enter("tableRow"),u(v)}function u(v){return v===124||(o=!0,s+=1),c(v)}function c(v){return v===null?n(v):Y(v)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),p):n(v):ie(v)?ae(e,c,"whitespace")(v):(s+=1,o&&(o=!1,i+=1),v===124?(e.enter("tableCellDivider"),e.consume(v),e.exit("tableCellDivider"),o=!0,c):(e.enter("data"),f(v)))}function f(v){return v===null||v===124||pe(v)?(e.exit("data"),c(v)):(e.consume(v),v===92?d:f)}function d(v){return v===92||v===124?(e.consume(v),f):f(v)}function p(v){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(v):(e.enter("tableDelimiterRow"),o=!1,ie(v)?ae(e,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(v):g(v))}function g(v){return v===45||v===58?w(v):v===124?(o=!0,e.enter("tableCellDivider"),e.consume(v),e.exit("tableCellDivider"),y):M(v)}function y(v){return ie(v)?ae(e,w,"whitespace")(v):w(v)}function w(v){return v===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(v),e.exit("tableDelimiterMarker"),k):v===45?(s+=1,k(v)):v===null||Y(v)?N(v):M(v)}function k(v){return v===45?(e.enter("tableDelimiterFiller"),C(v)):M(v)}function C(v){return v===45?(e.consume(v),C):v===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(v),e.exit("tableDelimiterMarker"),E):(e.exit("tableDelimiterFiller"),E(v))}function E(v){return ie(v)?ae(e,N,"whitespace")(v):N(v)}function N(v){return v===124?g(v):v===null||Y(v)?!o||i!==s?M(v):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(v)):M(v)}function M(v){return n(v)}function S(v){return e.enter("tableRow"),O(v)}function O(v){return v===124?(e.enter("tableCellDivider"),e.consume(v),e.exit("tableCellDivider"),O):v===null||Y(v)?(e.exit("tableRow"),t(v)):ie(v)?ae(e,O,"whitespace")(v):(e.enter("data"),H(v))}function H(v){return v===null||v===124||pe(v)?(e.exit("data"),O(v)):(e.consume(v),v===92?_:H)}function _(v){return v===92||v===124?(e.consume(v),H):H(v)}}function Ox(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,u,c,f;const d=new Mx;for(;++n<e.length;){const p=e[n],g=p[1];p[0]==="enter"?g.type==="tableHead"?(a=!1,l!==0&&(js(d,t,l,u,c),c=void 0,l=0),u={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},d.add(n,0,[["enter",u,t]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,f=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,c={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},d.add(n,0,[["enter",c,t]])),i=g.type==="tableDelimiterRow"?2:c?3:1):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],f=yn(d,t,s,i,void 0,f),s=[0,0,0,0]),o[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],f=yn(d,t,s,i,void 0,f)),s=o,o=[s[1],n,0,0])):g.type==="tableHead"?(a=!0,l=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],f=yn(d,t,s,i,n,f)):o[1]!==0&&(f=yn(d,t,o,i,n,f)),i=0):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&js(d,t,l,u,c),d.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=zx(t.events,n))}return e}function yn(e,t,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},Ft(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Ft(t.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const u=Ft(t.events,n[2]),c=Ft(t.events,n[3]),f={type:a,start:Object.assign({},u),end:Object.assign({},c)};if(e.add(n[2],0,[["enter",f,t]]),r!==2){const d=t.events[n[2]],p=t.events[n[3]];if(d[1].end=Object.assign({},p[1].end),d[1].type="chunkText",d[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,y=n[3]-n[2]-1;e.add(g,y,[])}}e.add(n[3]+1,0,[["exit",f,t]])}return i!==void 0&&(s.end=Object.assign({},Ft(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function js(e,t,n,r,i){const s=[],o=Ft(t.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,t])),r.end=Object.assign({},o),s.push(["exit",r,t]),e.add(n+1,0,s)}function Ft(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const Fx={name:"tasklistCheck",tokenize:Bx};function $x(){return{text:{91:Fx}}}function Bx(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return pe(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return Y(l)?t(l):ie(l)?e.check({tokenize:Hx},t,n)(l):n(l)}}function Hx(e,t,n){return ae(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function Ux(e){return _o([dx(),vx(),Dx(e),Px(),$x()])}const qx={};function Wx(e){const t=this,n=e||qx,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Ux(n)),s.push(cx()),o.push(fx(n))}function Kx(e){if(!e?.startsWith("openclaw-file://"))return null;try{return decodeURIComponent(e.slice(16))}catch{return null}}const Vx={py:"python",ts:"typescript",js:"javascript",jsx:"jsx",tsx:"tsx",json:"json",md:"markdown",yml:"yaml",yaml:"yaml",sh:"bash",bash:"bash",zsh:"bash",html:"html",css:"css",sql:"sql",xml:"xml",toml:"toml",rs:"rust",go:"go",java:"java",c:"c",cpp:"cpp",cs:"csharp",php:"php",rb:"ruby",graphql:"graphql",diff:"diff",patch:"diff",env:"text"};function Xx(e){if(!e)return"text";const n=(e.split("/").pop()||"").toLowerCase();if(n==="dockerfile")return"dockerfile";if(n==="makefile")return"text";const r=n.split("."),i=r.length>1&&r.pop()||"",s=Vx[i]||i||"text";return Gl(s)}const Yx=100*1024;function Gx(e){return fe.lexer(e).map(n=>n.raw)}function Qx(e){if(!e)return"text";const t=e.match(/language-(\w+)/);return t?t[1]:"text"}const Jx={code:function({className:t,children:n}){if(!t?.includes("language-"))return h.jsx("code",{className:"rounded bg-primary-100 px-1.5 py-1 text-sm font-mono text-primary-900 border border-primary-200",children:n});const i=Qx(t);return h.jsx(ro,{content:String(n??""),language:i,className:"w-full"})},pre:function({children:t}){return h.jsx(h.Fragment,{children:t})},h1:function({children:t}){return h.jsx("h1",{className:"text-xl font-medium text-primary-950",children:t})},h2:function({children:t}){return h.jsx("h2",{className:"text-lg font-medium text-primary-900",children:t})},h3:function({children:t}){return h.jsx("h3",{className:"font-medium text-primary-900",children:t})},p:function({children:t}){return h.jsx("p",{className:"text-primary-950 text-pretty leading-relaxed",children:t})},ul:function({children:t}){return h.jsx("ul",{className:"ml-4 list-disc text-primary-950 marker:text-primary-400",children:t})},ol:function({children:t}){return h.jsx("ol",{className:"ml-4 list-decimal text-primary-950 marker:text-primary-500",children:t})},li:function({children:t}){return h.jsx("li",{className:"leading-relaxed",children:t})},blockquote:function({children:t}){return h.jsx("blockquote",{className:"border-l-2 border-primary-300 pl-4 text-primary-900 italic",children:t})},strong:function({children:t}){return h.jsx("strong",{className:"font-medium text-primary-950",children:t})},em:function({children:t}){return h.jsx("em",{className:"italic text-primary-950",children:t})},hr:function(){return h.jsx("hr",{className:"my-3 border-primary-200"})},table:function({children:t}){return h.jsx("div",{className:"overflow-x-auto",children:h.jsx("table",{className:"w-full border-collapse text-sm",children:t})})},thead:function({children:t}){return h.jsx("thead",{className:"border-b border-primary-200 bg-primary-50",children:t})},tbody:function({children:t}){return h.jsx("tbody",{className:"divide-y divide-primary-100",children:t})},tr:function({children:t}){return h.jsx("tr",{className:"transition-colors hover:bg-primary-50/50",children:t})},th:function({children:t}){return h.jsx("th",{className:"px-3 py-2 text-left font-medium text-primary-950",children:t})},td:function({children:t}){return h.jsx("td",{className:"px-3 py-2 text-primary-950",children:t})}};function Zx(e,t){const n=/^(?:~\/[\w.\-\/]+|\/(?:[\w.\-]+\/)+[\w.\-]+)$/;return{...Jx,a:function({children:i,href:s}){const o=Kx(s);return t&&o?h.jsx("button",{type:"button",onClick:()=>e(o),className:"font-mono text-primary-900 underline decoration-primary-300 underline-offset-4 hover:decoration-primary-600 cursor-pointer",children:i}):h.jsx("a",{href:s,className:"text-primary-950 underline decoration-primary-300 underline-offset-4 transition-colors hover:text-primary-950 hover:decoration-primary-500",target:"_blank",rel:"noopener noreferrer",children:i})},code:function({children:i,className:s}){if(s)return h.jsx("code",{className:s,children:i});const o=typeof i=="string"?i:Array.isArray(i)?i.filter(a=>typeof a=="string").join(""):String(i??"");return t&&o&&n.test(o)?h.jsx("button",{type:"button",onClick:()=>e(o),className:"font-mono text-sm bg-primary-100 rounded px-1.5 py-0.5 text-primary-900 underline decoration-primary-300 underline-offset-4 hover:decoration-primary-600 cursor-pointer",children:i}):h.jsx("code",{className:"font-mono text-sm bg-primary-100 rounded px-1.5 py-0.5 text-primary-900",children:i})}}}const Aa=m.memo(function({content:t,components:n}){return h.jsx(Rm,{remarkPlugins:[Wx,Bm],components:n,children:t})},function(t,n){return t.content===n.content});Aa.displayName="MemoizedMarkdownBlock";function ey(e,t){return t==="NOT_FOUND"||e===404?"File not found":t==="UNSUPPORTED_TYPE"?"Binary file":t==="FILE_TOO_LARGE"||e===413?"File too large":"Failed to load file preview"}function ty({children:e,id:t,className:n,components:r}){const i=m.useId(),s=t??i,o=m.useMemo(()=>Gx(e),[e]),[a,l]=m.useState({status:"idle"}),u=Ql(p=>p.settings.inlineFilePreview),c=m.useMemo(()=>Zx(p=>l({status:"loading",path:p}),u),[u]),f=m.useMemo(()=>({...c,...r||{}}),[c,r]);m.useEffect(()=>{if(a.status!=="loading")return;const p=a.path,g=new AbortController;return fetch(`/api/files/read?path=${encodeURIComponent(p)}`,{signal:g.signal}).then(async y=>{const w=await y.json().catch(()=>({}));if(!y.ok){const E=ey(y.status,w.code);l({status:"error",path:p,message:E});return}if(Number(w.size??0)>Yx){l({status:"error",path:p,message:"File too large"});return}const C=String(w.content??"");l({status:"success",path:p,content:C,language:Xx(p)})}).catch(()=>{g.signal.aborted||l({status:"error",path:p,message:"Failed to load file preview"})}),()=>g.abort()},[a]);const d=a.status!=="idle";return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:W("flex flex-col gap-2",n),children:o.map((p,g)=>h.jsx(Aa,{content:p,components:f},`${s}-block-${g}`))}),h.jsx(Qs,{open:d,onOpenChange:p=>{p||l({status:"idle"})},children:h.jsxs(Js,{className:"w-[min(1000px,95vw)] max-h-[88vh] overflow-hidden p-0",children:[h.jsxs("div",{className:"border-b border-primary-200 px-4 py-3 flex items-start justify-between gap-3",children:[h.jsxs("div",{className:"min-w-0",children:[h.jsx(Zs,{className:"text-base",children:"File Preview"}),a.status!=="idle"&&h.jsx("p",{className:"text-xs text-primary-600 font-mono truncate",children:a.path})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[a.status!=="idle"&&h.jsx(Ce,{variant:"ghost",size:"sm",asChild:!0,children:h.jsx(en,{to:"/files",onClick:()=>{let p=a.status!=="idle"?a.path:"";if(p){const g=["/root/clawd/","/root/"];for(const w of g)if(p.startsWith(w)){p="/"+p.slice(w.length);break}const y=p.includes("/")&&p.slice(0,p.lastIndexOf("/"))||"/";Bl.getState().navigateTo(y)}l({status:"idle"})},children:"Open in File Explorer"})}),h.jsx(eo,{children:"Close"})]})]}),h.jsxs("div",{className:"p-4 overflow-auto max-h-[calc(88vh-72px)]",children:[a.status==="loading"&&h.jsx("p",{className:"text-sm text-primary-600",children:"Loading preview…"}),a.status==="error"&&h.jsx("p",{className:"text-sm text-red-600",children:a.message}),a.status==="success"&&h.jsx(ro,{content:a.content,language:a.language,className:"w-full"})]})]})})]})}const Ia=m.memo(ty);Ia.displayName="Markdown";function Ra({children:e,className:t,...n}){return h.jsx("div",{className:W("flex gap-3 w-full",t),...n,children:e})}function ny({children:e,markdown:t=!1,className:n,...r}){const i=W("rounded-[12px] break-words whitespace-normal min-w-0",n);return t?h.jsx(Ia,{className:i,...r,children:e}):h.jsx("div",{className:i,...r,children:e})}function ry(){const[e,t]=m.useState(()=>typeof window<"u"?window.innerWidth<768:!1);return m.useEffect(()=>{if(typeof window>"u")return;const n=window.matchMedia("(max-width: 767px)"),r=i=>t(i.matches);return n.addEventListener("change",r),t(n.matches),()=>n.removeEventListener("change",r)},[]),e}function iy({content:e}){const t=ry();return h.jsx("div",{className:"inline-flex flex-col",children:h.jsxs(vn,{defaultOpen:!t,children:[h.jsxs(En,{render:h.jsx(Ce,{variant:"ghost",className:"h-auto gap-1.5 px-1.5 py-0.5 -mx-2"}),children:[h.jsx("span",{className:"text-sm font-medium text-primary-900",children:"Thinking"}),h.jsx(re,{icon:$r,size:14,strokeWidth:1.5,className:"text-primary-900 transition-transform duration-150 group-data-panel-open:rotate-180"})]}),h.jsx(Tn,{children:h.jsx("div",{className:"pt-1 mb-3",children:h.jsx("p",{className:"text-sm text-primary-700 whitespace-pre-wrap",children:e})})})]})})}function sy({toolPart:e,defaultOpen:t=!1}){const{state:n,input:r,output:i,toolCallId:s}=e,o=(u,c=3200)=>{const f=u===void 0?"undefined":u;let d;if(typeof f=="string")try{d=JSON.stringify(JSON.parse(f),null,2)}catch{d=f}else d=JSON.stringify(f,null,2);return d.length<=c?d:`${d.slice(0,c).trimEnd()}
|
|
92
|
+
…[truncated]`},a=n==="output-error"?On:n==="output-available"?Ws:Gs,l=n==="output-error"?"text-red-600/80":n==="output-available"?"text-green-600/80":"text-primary-500/80";return h.jsx("div",{className:"inline-flex flex-col w-full",children:h.jsxs(vn,{defaultOpen:t,children:[h.jsxs(En,{render:h.jsx(Ce,{variant:"ghost",className:"h-auto w-full justify-start gap-1.5 rounded-md px-1.5 py-1"}),children:[h.jsx(re,{icon:a,size:12,strokeWidth:1.7,className:l}),h.jsx("span",{className:"text-sm font-medium text-primary-900",children:e.type}),h.jsx(re,{icon:$r,size:14,strokeWidth:1.5,className:"ml-auto text-primary-700/80 transition-transform duration-150 group-data-panel-open:rotate-180"})]}),h.jsx(Tn,{className:"mt-1",children:h.jsxs("div",{className:"space-y-2 rounded-md border border-primary-200 bg-primary-100/70 p-2",children:[h.jsxs("div",{className:"rounded border border-primary-200 bg-primary-50 px-2 py-1.5",children:[h.jsx("div",{className:"text-[11px] font-medium text-primary-600",children:"Tool"}),h.jsx("div",{className:"font-mono text-xs text-primary-800 break-all",children:e.type})]}),r&&Object.keys(r).length>0&&h.jsxs("div",{className:"rounded border border-primary-200 bg-primary-50 px-2 py-1.5",children:[h.jsx("h4",{className:"mb-1 text-[11px] font-medium text-primary-600",children:"Input"}),h.jsx("pre",{className:"max-h-44 overflow-auto whitespace-pre-wrap break-all font-mono text-xs leading-relaxed text-primary-800",children:o(r)})]}),i!=null&&h.jsxs("div",{className:"rounded border border-primary-200 bg-primary-50 px-2 py-1.5",children:[h.jsx("h4",{className:"mb-1 text-[11px] font-medium text-primary-600",children:"Output"}),h.jsx("pre",{className:"max-h-44 overflow-auto whitespace-pre-wrap break-all font-mono text-xs leading-relaxed text-primary-800",children:o(i)})]}),n==="output-error"&&e.errorText&&h.jsxs("div",{className:"rounded border border-red-200 bg-red-50 px-2 py-1.5",children:[h.jsx("h4",{className:"mb-1 text-[11px] font-medium text-red-600",children:"Error"}),h.jsx("div",{className:"text-xs text-red-700",children:e.errorText})]}),s&&h.jsxs("div",{className:"text-[11px] text-primary-500/80 font-mono tabular-nums",children:["ID: ",s.slice(0,16),"..."]})]})})]})})}function As(e){try{return new URL(e).hostname.replace("www.","")}catch{return e}}function Is({domain:e}){return h.jsx("div",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-white dark:bg-zinc-800 border border-cyan-500/20 overflow-hidden",title:e,children:h.jsx("img",{src:`https://www.google.com/s2/favicons?domain=${e}&sz=32`,alt:"",className:"w-4 h-4 object-contain",loading:"lazy",onError:t=>{const n=t.target;n.style.display="none";const r=n.parentElement;r&&(r.textContent=e.charAt(0).toUpperCase(),r.classList.add("text-[10px]","font-medium","text-cyan-400"))}})})}function oy({sources:e}){const[t,n]=m.useState(!1);if(!e.length)return null;const r=[...new Set(e.map(i=>As(i.url)))];return h.jsxs("div",{className:"mt-2 w-full",children:[h.jsxs("button",{onClick:()=>n(!t),className:W("inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs","bg-cyan-500/10 hover:bg-cyan-500/20 border border-cyan-500/30","text-cyan-300 transition-colors"),children:[h.jsx(re,{icon:Vs,size:14}),h.jsx("span",{className:"font-medium",children:"Sources"}),h.jsx("span",{className:"px-1.5 py-0.5 rounded-full bg-cyan-500/20 text-cyan-400 font-semibold",children:e.length}),h.jsxs("div",{className:"flex items-center gap-0.5 ml-1",children:[r.slice(0,3).map(i=>h.jsx(Is,{domain:i},i)),r.length>3&&h.jsxs("span",{className:"text-cyan-500/70 text-[10px] ml-0.5",children:["+",r.length-3]})]}),h.jsx(re,{icon:Fr,size:12,className:W("transition-transform",t&&"rotate-90")})]}),t&&h.jsx("div",{className:"mt-2 rounded-lg border border-cyan-500/20 bg-cyan-500/5 max-h-80 overflow-y-auto",children:e.map((i,s)=>{const o=As(i.url);return h.jsxs("a",{href:i.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-start gap-2 p-2.5 border-b border-cyan-500/10 last:border-b-0 hover:bg-cyan-500/5 transition-colors",children:[h.jsx(Is,{domain:o}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"text-sm font-medium text-primary-900 hover:underline line-clamp-1",children:i.title||o}),h.jsx("div",{className:"text-xs text-muted-foreground",children:o}),i.snippet&&h.jsx("p",{className:"text-xs text-muted-foreground/80 line-clamp-2 mt-0.5",children:i.snippet})]})]},`${i.url}-${s}`)})})]})}function ay(e,t){const n=t!==void 0,r=t?.isError??!1;let i;n?r?i="output-error":i="output-available":i="input-available";let s;r&&t?.content?.[0]?.type==="text"&&(s=t.content[0].text||"Unknown error");const o=t?.content?.map(l=>l.type==="text"?String(l.text??""):"").join("").trim(),a=t?.details??(o&&o.length>0?o:void 0);return{type:e.name||"unknown",state:i,input:e.arguments,output:a,toolCallId:e.id,errorText:s}}function Rs(e){return Tt(e).map(n=>{const r=n.id??"",i=n.name??"",s=n.partialJson??"",o=n.arguments?JSON.stringify(n.arguments):"";return`${r}|${i}|${s}|${o}`}).join("||")}function ly(e){if(!e)return"missing";const n=(Array.isArray(e.content)?e.content:[]).map(i=>i.type==="text"?String(i.text??""):"").join("").trim(),r=e.details?JSON.stringify(e.details):"";return`${e.toolCallId??""}|${e.toolName??""}|${e.isError?"1":"0"}|${n}|${r}`}function Ns(e,t){if(!t)return"";const n=Tt(e);return n.length===0?"":n.map(r=>r.id?ly(t.get(r.id)):"missing").join("||")}function uy(e){if(typeof e=="number"&&Number.isFinite(e))return e<1e12?e*1e3:e;if(typeof e=="string"){const t=Date.parse(e);if(!Number.isNaN(t))return t}return null}function Ds(e){const t=[e.createdAt,e.created_at,e.timestamp,e.time,e.ts];for(const n of t){const r=uy(n);if(r)return r}return null}function Pr(e){const n=(Array.isArray(e.content)?e.content:[]).find(r=>r.type==="thinking");return n&&"thinking"in n?String(n.thinking??""):null}function cy(e){const t=Array.isArray(e.content)?e.content:[],n=[];for(const r of t)r.type==="image"&&"source"in r&&typeof r.source?.data=="string"&&n.push(r);return n}function fy({message:e,toolResultsByCallId:t,forceActionsVisible:n=!1,isStreaming:r=!1,isLastAssistant:i=!1,aggregatedSearchSources:s,wrapperRef:o,wrapperClassName:a,wrapperScrollMarginTop:l}){const{settings:u}=Jl(),c=e.role||"assistant",f=Je(e),d=Pr(e),p=cy(e),g=c==="user",y=Sr(e),w=c==="assistant"?Tt(e):[],k=w.length>0,C=i&&!r&&u.showSearchSources&&s?s:[];return h.jsxs("div",{ref:o,style:{contentVisibility:"auto",containIntrinsicSize:"auto 120px",...typeof l=="number"?{scrollMarginTop:`${l}px`}:void 0},className:W("group flex flex-col gap-1",a,g?"items-end":"items-start"),children:[d&&u.showReasoningBlocks&&h.jsx("div",{className:"w-full max-w-[900px]",children:h.jsx(iy,{content:d})}),p.length>0&&h.jsx("div",{className:W("flex flex-wrap gap-2 mb-2",g?"justify-end":"justify-start"),children:p.map((E,N)=>h.jsx("img",{src:`data:${E.source.media_type};base64,${E.source.data}`,alt:`Attachment ${N+1}`,loading:"lazy",decoding:"async",className:"max-w-[300px] max-h-[300px] rounded-lg object-cover"},N))}),h.jsx(Ra,{className:W(g?"flex-row-reverse":""),children:h.jsx(ny,{markdown:!g,className:W("text-primary-900 opencami-text-size",g?"bg-primary-100 px-4 py-2.5 max-w-[85%]":"bg-transparent w-full",!g&&r&&"stream-fade-in"),children:f})}),k&&u.showToolMessages&&h.jsx("div",{className:"w-full max-w-[900px] mt-2 flex flex-col gap-3",children:w.map(E=>{const N=E.id?t?.get(E.id):void 0,M=ay(E,N);return h.jsx(sy,{toolPart:M,defaultOpen:!1},E.id||E.name)})}),C.length>0&&h.jsx("div",{className:"w-full max-w-[900px]",children:h.jsx(oy,{sources:C})}),!k&&h.jsx(Yc,{text:f,timestamp:y,align:g?"end":"start",forceVisible:n})]})}function hy(e,t){return!(e.forceActionsVisible!==t.forceActionsVisible||e.isStreaming!==t.isStreaming||e.isLastAssistant!==t.isLastAssistant||e.aggregatedSearchSources!==t.aggregatedSearchSources||e.wrapperClassName!==t.wrapperClassName||e.wrapperRef!==t.wrapperRef||e.wrapperScrollMarginTop!==t.wrapperScrollMarginTop||(e.message.role||"assistant")!==(t.message.role||"assistant")||Je(e.message)!==Je(t.message)||Pr(e.message)!==Pr(t.message)||Rs(e.message)!==Rs(t.message)||Ns(e.message,e.toolResultsByCallId)!==Ns(t.message,t.toolResultsByCallId)||Ds(e.message)!==Ds(t.message))}const yr=m.memo(fy,hy),py=[/```[\s\S]*?```/g,/`[^`]+`/g,/\b(function|const|let|var|class|import|export|return|async|await)\b/g];function dy(e){const t=[],n=e.match(/"([^"]+)"|'([^']+)'/g);n&&t.push(...n.map(s=>s.replace(/['"]/g,"")));const r=e.match(/\b[A-Z][a-z]+(?:\s+[A-Z][a-z]+)*\b/g);r&&t.push(...r.filter(s=>!["I","The","A","An","This"].includes(s)));const i=e.match(/`([^`]+)`/g);return i&&t.push(...i.map(s=>s.replace(/`/g,""))),[...new Set(t)].slice(0,5)}function my(e){return py.some(t=>t.test(e))}function gy(e){return/^[\s]*[-*•\d]+[.)\s]/m.test(e)||/\b(first|second|third|1\.|2\.|3\.)/i.test(e)}function xy(e){return/\b(alternatively|another|other option|could also|you might|consider)\b/i.test(e)}function yy(e){return/\b(because|since|due to|reason|why|how|what|when|where)\b/i.test(e)}function by(e){return/\b(however|but|note|warning|caution|careful|important|keep in mind|be aware)\b/i.test(e)}function ky(e){const t=[],n=dy(e);if(my(e)&&(t.push({text:"Can you explain this code step by step?",type:"clarify"}),t.push({text:"How would I modify this for my use case?",type:"actionable"})),gy(e)&&(t.push({text:"Can you elaborate on the first point?",type:"expand"}),t.push({text:"Which of these is most important to start with?",type:"actionable"})),xy(e)&&(t.push({text:"What are the pros and cons of each approach?",type:"alternative"}),t.push({text:"Which option would you recommend and why?",type:"clarify"})),yy(e)&&t.length<3&&t.push({text:"Can you give me a practical example?",type:"example"}),by(e)&&t.length<3&&t.push({text:"What potential issues should I watch out for?",type:"clarify"}),n.length>0&&t.length<3){const s=n[0];t.push({text:`Tell me more about ${s}`,type:"expand"})}const r=[{text:"Can you give me a concrete example?",type:"example"},{text:"What would be the next steps?",type:"actionable"},{text:"How does this work in practice?",type:"expand"},{text:"Are there any common mistakes to avoid?",type:"clarify"},{text:"Can you simplify this explanation?",type:"clarify"}],i=new Set(t.map(s=>s.type));for(const s of r){if(t.length>=3)break;i.has(s.type)||(t.push(s),i.add(s.type))}for(const s of r){if(t.length>=3)break;t.some(o=>o.text===s.text)||t.push(s)}return t.slice(0,3)}function Ms(e){return ky(e).map(t=>t.text)}const $t=eu()(Zl(e=>({settings:{useLlmTitles:!1,useLlmFollowUps:!1,openaiApiKey:""},updateSettings:t=>e(n=>({settings:{...n.settings,...t}})),clearApiKey:()=>e(t=>({settings:{...t.settings,openaiApiKey:""}}))}),{name:"llm-settings"}));function Fb(){const e=$t(o=>o.settings),t=$t(o=>o.updateSettings),n=$t(o=>o.clearApiKey),[r,i]=m.useState({hasEnvKey:!1,hasUserKey:!!e.openaiApiKey,isAvailable:!!e.openaiApiKey,isLoading:!0,error:null});m.useEffect(()=>{let o=!1;async function a(){try{const l=await fetch("/api/llm-features");if(!l.ok)throw new Error("Failed to check LLM status");const u=await l.json();if(o)return;const c=!!e.openaiApiKey;i({hasEnvKey:u.hasEnvKey,hasUserKey:c,isAvailable:u.hasEnvKey||c,isLoading:!1,error:null})}catch(l){if(o)return;i(u=>({...u,isLoading:!1,error:l instanceof Error?l.message:"Failed to check status"}))}}return a(),()=>{o=!0}},[e.openaiApiKey]);const s=m.useCallback(async o=>{try{const l=await(await fetch("/api/llm-features",{method:"POST",headers:{"Content-Type":"application/json","X-OpenAI-API-Key":o},body:JSON.stringify({action:"test"})})).json();return l.ok?{valid:l.valid??!1,error:l.error}:{valid:!1,error:l.error||"Test failed"}}catch(a){return{valid:!1,error:a instanceof Error?a.message:"Network error"}}},[]);return{settings:e,updateSettings:t,clearApiKey:n,status:r,testApiKey:s}}async function wy(e,t,n){const r={"Content-Type":"application/json"};t&&(r["X-OpenAI-API-Key"]=t);const i=await fetch("/api/llm-features",{method:"POST",headers:r,body:JSON.stringify({action:"followups",conversationContext:e}),signal:n});if(!i.ok)throw new Error(`API error: ${i.status}`);const s=await i.json();return s.ok&&Array.isArray(s.suggestions)&&s.suggestions.length>0?s.suggestions:[]}function Sy(e,t,n){const r=$t(N=>N.settings),i=r.useLlmFollowUps,s=r.openaiApiKey,{minResponseLength:o=50,timeoutMs:a=8e3,heuristicsOnly:l}=n??{},u=l??!i,[c,f]=m.useState([]),[d,p]=m.useState(!1),[g,y]=m.useState(null),[w,k]=m.useState(null),C=m.useRef(""),E=m.useRef(null);return m.useEffect(()=>{if(!e||e.trim().length<o){f([]),k(null),p(!1),y(null);return}const N=e.slice(0,200)+e.length;if(N===C.current)return;if(C.current=N,E.current&&E.current.abort(),u){const H=Ms(e);f(H),k("heuristic"),p(!1),y(null);return}const M=new AbortController;E.current=M,p(!0),y(null);const S=Ms(e);f(S),k("heuristic");const O=t?`Context: ${t}
|
|
93
|
+
|
|
94
|
+
Assistant's response:
|
|
95
|
+
${e.slice(0,2e3)}`:`Assistant's response:
|
|
96
|
+
${e.slice(0,2e3)}`;return wy(O,s,M.signal).then(H=>{M.signal.aborted||(H.length>0&&(f(H),k("llm")),p(!1))}).catch(H=>{M.signal.aborted||(y(H instanceof Error?H.message:String(H)),p(!1))}),()=>{}},[e,t,o,a,u,s]),{suggestions:c,isLoading:d,error:g,source:w}}function Cy({responseText:e,contextSummary:t,onSuggestionClick:n,disabled:r=!1,className:i}){const{suggestions:s,isLoading:o,source:a}=Sy(e,t,{minResponseLength:50,timeoutMs:8e3});return s.length===0&&!o?null:h.jsxs("div",{className:W("flex flex-col gap-2 mt-3",i),children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-primary-500",children:[h.jsx("span",{className:"text-primary-400",children:"✨"}),h.jsx("span",{children:o?h.jsxs("span",{className:"flex items-center gap-1",children:["Thinking of follow-ups",h.jsx(re,{icon:Gs,size:12,strokeWidth:2,className:"animate-spin text-primary-400"})]}):a==="llm"?"AI suggestions":"Follow-up suggestions"})]}),h.jsx("div",{className:"flex flex-wrap gap-2",children:s.map((l,u)=>h.jsxs("button",{type:"button",disabled:r,onClick:()=>n(l),className:W("group inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full","text-sm text-primary-700 bg-primary-50 border border-primary-200","hover:bg-primary-100 hover:border-primary-300 hover:text-primary-900","focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus:ring-offset-1","transition-all duration-150 cursor-pointer","disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-primary-50 disabled:hover:border-primary-200",o&&"opacity-75"),children:[h.jsx("span",{children:l}),h.jsx(re,{icon:Fr,size:14,strokeWidth:2,className:"text-primary-400 group-hover:text-primary-600 group-hover:translate-x-0.5 transition-all duration-150"})]},`${u}-${l.slice(0,20)}`))})]})}const Ls=m.memo(Cy);function vy({className:e,variant:t="outline",scrollRef:n,...r}){const[i,s]=m.useState(!0),[o,a]=m.useState(!1),l=m.useRef(0),u=m.useCallback(()=>{const c=n.current;if(!c)return;const f=Math.abs(c.scrollHeight-c.scrollTop-c.clientHeight)<100;s(f)},[n]);return m.useLayoutEffect(()=>{const c=n.current;if(!c)return;const f=()=>{l.current=c.scrollTop,u()},d=new MutationObserver(()=>{c&&(c.scrollTop!==l.current&&(l.current=c.scrollTop),u())});return u(),c.addEventListener("scroll",f),d.observe(c,{childList:!0,subtree:!0}),()=>{c.removeEventListener("scroll",f),d.disconnect()}},[u,n]),m.useLayoutEffect(()=>{if(i){a(!1);return}const c=window.setTimeout(()=>{a(!0)},200);return()=>window.clearTimeout(c)},[i]),h.jsx(Ce,{variant:"secondary",size:"icon-sm",className:W("pointer-events-auto rounded-full shadow-md","transition-all duration-100 ease-in-out",!i&&o?"translate-y-0 scale-100 opacity-100":"pointer-events-none translate-y-4 scale-98 opacity-0",e),onClick:()=>{const c=n.current;c&&(c.scrollTop=c.scrollHeight,s(!0))},...r,children:h.jsx(re,{icon:$r,size:18,strokeWidth:1.8})})}function Ey({className:e,viewportRef:t,scrollRef:n,viewportProps:r}){return h.jsxs(fo,{className:W("relative flex flex-1 min-h-0 flex-col",e),children:[h.jsx(ho,{className:"relative will-change-transform",ref:t,...r}),h.jsx("div",{className:"relative mx-auto w-full max-w-full px-5 sm:max-w-[768px] sm:min-w-[400px] ",children:h.jsx("div",{className:"pointer-events-none absolute bottom-10 right-10 z-50",children:h.jsx(vy,{scrollRef:n})})}),h.jsx(po,{orientation:"vertical",children:h.jsx(mo,{})}),h.jsx(oc,{})]})}function Ty(e,t){if(e===t)return!0;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n)if(e[i]!==t[i])return!1;return!0}function jy(e,t){return!(e.className!==t.className||e.viewportRef!==t.viewportRef||e.scrollRef!==t.scrollRef||!Ty(e.viewportProps,t.viewportProps))}const Ay=m.memo(Ey,jy);function Iy({viewportNode:e,children:t}){return e?Ga.createPortal(h.jsx("div",{className:"relative flex w-full flex-col",children:t}),e):null}function Ry({children:e,className:t,onUserScroll:n,...r}){const i=m.useRef(null),[s,o]=m.useState(null),a=m.useCallback(function(u){i.current=u,o(u)},[]);return m.useLayoutEffect(()=>{const l=i.current;if(!l)return;const u=()=>{n?.(l.scrollTop)};return l.addEventListener("scroll",u),()=>l.removeEventListener("scroll",u)},[n]),h.jsxs(h.Fragment,{children:[h.jsx(Ay,{className:t,viewportRef:a,scrollRef:i,viewportProps:r}),h.jsx(Iy,{viewportNode:s,children:e})]})}const Ny=m.memo(Ry);function Dy({children:e,className:t,...n}){return h.jsx("div",{className:W("flex w-full flex-col min-h-full",t),...n,children:h.jsx("div",{className:"mx-auto w-full max-w-full px-2 md:px-5 sm:max-w-[768px] sm:min-w-[400px] flex flex-col flex-1 min-h-full",children:h.jsx("div",{className:"flex flex-col space-y-3 md:space-y-6",children:e})})})}function My({...e}){return h.jsx("div",{className:"h-px w-full shrink-0 scroll-mt-4 pt-6","aria-hidden":"true",...e})}function Ly({as:e="span",className:t,duration:n=4,spread:r=20,children:i,...s}){const o=Math.min(Math.max(r,5),45),a=e;return h.jsx(a,{className:W("bg-size-[200%_auto] bg-clip-text font-medium text-transparent","animate-[shimmer_4s_infinite_linear]",t),style:{backgroundImage:`linear-gradient(to right, var(--color-primary-600) ${50-o}%, var(--color-primary-950) 50%, var(--color-primary-600) ${50+o}%)`,animationDuration:`${n}s`},...s,children:i})}function zy({className:e}){return h.jsxs("div",{className:W("flex items-center gap-2",e),children:[h.jsxs("div",{className:"relative flex h-1.5 w-1.5",children:[h.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-primary-400 opacity-75"}),h.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-size-[200%_auto] animate-[shimmer_2s_infinite_linear]",style:{backgroundImage:"linear-gradient(to right, var(--color-primary-600) 0%, var(--color-primary-950) 50%, var(--color-primary-600) 100%)"}})]}),h.jsx(Ly,{className:"text-sm",duration:2,children:"Generating..."})]})}function Py({messages:e,loading:t,empty:n,emptyState:r,notice:i,noticePosition:s="start",waitingForResponse:o,isStreaming:a=!1,sessionKey:l,pinToTop:u,pinGroupMinHeight:c,headerHeight:f,contentStyle:d,onFollowUpClick:p}){const g=m.useRef(null),y=m.useRef(null),w=m.useRef(!1),k=m.useRef(u),C=m.useRef(void 0),E=m.useMemo(()=>e.filter(T=>T.role!=="toolResult"),[e]),N=m.useMemo(()=>{const T=new Map;for(const j of e){if(j.role!=="toolResult")continue;const R=j.toolCallId;typeof R=="string"&&R.trim().length>0&&T.set(R,j)}return T},[e]),M=m.useMemo(()=>{const T=U=>U?U.replace(/SECURITY NOTICE:[\s\S]*?<<<EXTERNAL_UNTRUSTED_CONTENT>>>/g,"").replace(/<<<\/?EXTERNAL_UNTRUSTED_CONTENT>>>/g,"").replace(/<<<\/?END_EXTERNAL_UNTRUSTED_CONTENT>>>/g,"").replace(/Source: Web (?:Search|Fetch)\n---/g,"").replace(/\n{2,}/g,`
|
|
97
|
+
`).trim():"",j=(U,L,x)=>{try{const q=JSON.parse(U),V=Array.isArray(q)?q:q?.results??q?.web?.results??[];if(!Array.isArray(V))return!1;let b=!1;for(const ee of V)ee?.url&&ee?.title&&!x.has(ee.url)&&(x.add(ee.url),L.push({title:T(ee.title),url:ee.url,snippet:T(ee.description||ee.snippet||ee.content||"")}),b=!0);return b}catch{return!1}},R=[],$=new Set;for(const U of E){if(U.role!=="assistant")continue;const L=Tt(U);for(const x of L){if(!x.id)continue;const q=x.name==="web_search",V=x.name==="web_fetch",b=x.name==="exec";if(!q&&!V&&!b)continue;const ee=N.get(x.id);if(!ee)continue;const Q=ee.content?.map(G=>G.type==="text"?String(G.text??""):"").join("").trim();if(Q){if(q||b){if(b&&(!Q.includes('"results"')||!Q.includes('"url"')))continue;let G=Q;const de=Q.indexOf("{");de>0&&(G=Q.slice(de));const he=G.lastIndexOf("}");he>0&&(G=G.slice(0,he+1)),j(G,R,$)}else if(V){const G=x.arguments?.url;if(G&&!$.has(G)){$.add(G);let de;try{de=new URL(G).hostname}catch{de=G}R.push({title:de,url:G})}}}}}return R},[E,N]),S=E.map((T,j)=>({message:T,index:j})).filter(({message:T})=>T.role!=="user").map(({index:T})=>T).pop(),O=E.map((T,j)=>({message:T,index:j})).filter(({message:T})=>T.role==="user").map(({index:T})=>T).pop(),H=o&&(typeof O!="number"||typeof S!="number"||S<O),_=typeof O=="number"?O:-1,v=u&&_>=0,D=typeof S=="number"?E[S]:void 0,A=D?Je(D):"",F=!o&&!a&&A.length>0&&p!==void 0&&(typeof O!="number"||typeof S!="number"||S>O);return m.useLayoutEffect(()=>{if(!t){if(u){const T=!k.current||C.current!==O;k.current=!0,C.current=O,T&&y.current&&(w.current=!0,y.current.scrollIntoView({behavior:"auto",block:"start"}),window.setTimeout(()=>{w.current=!1},0));return}k.current=!1,C.current=O,g.current&&(w.current=!0,g.current.scrollIntoView({behavior:"auto",block:"end"}),window.setTimeout(()=>{w.current=!1},0))}},[t,E.length,l,u,O]),h.jsx(Ny,{className:"flex-1 min-h-0 -mb-4",children:h.jsxs(Dy,{className:"pt-6",style:d,children:[i&&s==="start"?i:null,n&&!i?r??h.jsx("div",{"aria-hidden":!0}):v?h.jsxs(h.Fragment,{children:[E.slice(0,_).map((T,j)=>{const R=j,$=typeof S=="number"&&j===S,U=typeof S=="number"&&j===S,L=T.role==="assistant"&&Tt(T).length>0;return h.jsx(yr,{message:T,toolResultsByCallId:L?N:void 0,forceActionsVisible:$,isStreaming:U&&a,isLastAssistant:U,aggregatedSearchSources:U?M:void 0},R)}),h.jsxs("div",{className:"flex flex-col space-y-3 md:space-y-6",style:{minHeight:`${Math.max(0,c-24)}px`},children:[E.slice(_).map((T,j)=>{const R=_+j,$=R,U=typeof S=="number"&&R===S,L=typeof S=="number"&&R===S,x=R===O?y:void 0,q=R===O?"scroll-mt-0":void 0,V=R===O?f:void 0,b=T.role==="assistant"&&Tt(T).length>0;return h.jsx(yr,{message:T,toolResultsByCallId:b?N:void 0,forceActionsVisible:U,isStreaming:L&&a,isLastAssistant:L,aggregatedSearchSources:L?M:void 0,wrapperRef:x,wrapperClassName:q,wrapperScrollMarginTop:V},$)}),H?h.jsx("div",{className:"py-2",children:h.jsx(zy,{})}):null,F&&p?h.jsx(Ls,{responseText:A,onSuggestionClick:p,disabled:o}):null]})]}):h.jsxs(h.Fragment,{children:[E.map((T,j)=>{const R=j,$=typeof S=="number"&&j===S,U=typeof S=="number"&&j===S,L=T.role==="assistant"&&Tt(T).length>0;return h.jsx(yr,{message:T,toolResultsByCallId:L?N:void 0,forceActionsVisible:$,isStreaming:U&&a,isLastAssistant:U,aggregatedSearchSources:U?M:void 0},R)}),F&&p?h.jsx(Ls,{responseText:A,onSuggestionClick:p,disabled:o}):null]}),i&&s==="end"?i:null,h.jsx(My,{ref:g})]})})}function _y(e,t){return e.messages===t.messages&&e.loading===t.loading&&e.empty===t.empty&&e.emptyState===t.emptyState&&e.notice===t.notice&&e.noticePosition===t.noticePosition&&e.waitingForResponse===t.waitingForResponse&&e.isStreaming===t.isStreaming&&e.sessionKey===t.sessionKey&&e.pinToTop===t.pinToTop&&e.pinGroupMinHeight===t.pinGroupMinHeight&&e.headerHeight===t.headerHeight&&e.contentStyle===t.contentStyle&&e.onFollowUpClick===t.onFollowUpClick}const Oy=m.memo(Py,_y),Na=m.createContext({isLoading:!1,value:"",setValue:()=>{},maxHeight:240,onSubmit:void 0,disabled:!1,textareaRef:Qa.createRef()});let Bt=null,zs=!1;function Fy(){zs||typeof window>"u"||(zs=!0,window.addEventListener("keydown",e=>{if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.altKey)return;const t=e.target;if(!t)return;const n=t.tagName.toLowerCase();if(n==="input"||n==="textarea"||n==="select"||t.isContentEditable)return;const r=e.key.length===1,i=e.key==="Backspace";!r&&!i||!Bt||Bt.disabled||Bt.focus()}))}function Da(){return m.useContext(Na)}function $y({className:e,isLoading:t=!1,maxHeight:n=240,value:r,onValueChange:i,onSubmit:s,children:o,disabled:a=!1,onClick:l,...u}){const[c,f]=m.useState(r||""),d=m.useRef(null);Fy();function p(y){f(y),i?.(y)}function g(y){a||d.current?.focus(),l?.(y)}return h.jsx(jt,{children:h.jsx(Na.Provider,{value:{isLoading:t,value:r??c,setValue:i??p,maxHeight:n,onSubmit:s,disabled:a,textareaRef:d},children:h.jsx("div",{onClick:g,className:W("bg-surface cursor-text rounded-[22px] outline outline-ink/10 shadow-[0px_12px_32px_0px_rgba(0,0,0,0.05)] py-3 gap-3 flex flex-col",a&&"cursor-not-allowed opacity-60",e),...u,children:o})})})}function By({className:e,onKeyDown:t,disableAutosize:n=!1,inputRef:r,...i}){const{value:s,setValue:o,maxHeight:a,onSubmit:l,disabled:u,textareaRef:c}=Da();function f(y){!y||n||(y.style.height="auto",typeof a=="number"?y.style.height=`${Math.min(y.scrollHeight,a)}px`:y.style.height=`min(${y.scrollHeight}px, ${a})`)}function d(y){c.current=y,typeof r=="function"?r(y):r&&"current"in r&&(r.current=y),y?Bt=y:Bt===y&&(Bt=null),f(y)}m.useLayoutEffect(()=>{if(!c.current||n)return;const y=c.current;y.style.height="auto",typeof a=="number"?y.style.height=`${Math.min(y.scrollHeight,a)}px`:y.style.height=`min(${y.scrollHeight}px, ${a})`},[s,a,n]);function p(y){f(y.target),o(y.target.value)}function g(y){y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),l?.()),t?.(y)}return h.jsx("textarea",{ref:d,value:s,onChange:p,onKeyDown:g,className:W("text-primary-950 opencami-text-size min-h-[28px] w-full resize-none border-none bg-transparent shadow-none outline-none focus-visible:ring-0 pl-4 pr-1 placeholder:text-primary-500",e),rows:1,readOnly:u,"aria-disabled":u,...i})}function Hy({children:e,className:t,...n}){return h.jsx("div",{className:W("flex items-center gap-2",t),...n,children:e})}function br({tooltip:e,children:t,className:n,side:r="top",...i}){const{disabled:s}=Da();return h.jsxs(At,{...i,children:[h.jsx(It,{disabled:s,onClick:o=>o.stopPropagation(),children:t}),h.jsx(Rt,{side:r,className:n,children:e})]})}const Ma="opencami-selected-model";function Uy(){if(typeof window>"u")return null;try{return localStorage.getItem(Ma)}catch{return null}}function qy(e){if(!(typeof window>"u"))try{localStorage.setItem(Ma,e)}catch{}}function Wy({className:e,onModelChange:t}){const[n,r]=m.useState([]),[i,s]=m.useState(""),[o,a]=m.useState(!0),[l,u]=m.useState(null);m.useEffect(()=>{let g=!0;async function y(){try{a(!0),u(null);const w=await fetch("/api/models");if(!w.ok)throw new Error("Failed to fetch models");const k=await w.json();if(!g)return;if(k.ok&&k.models.length>0){r(k.models);const C=Uy(),E=C&&k.models.some(N=>N.id===C)?C:k.defaultModel;s(E),t?.(E)}else throw new Error("No models available")}catch(w){if(!g)return;console.error("[model-selector] Error fetching models:",w),u(w instanceof Error?w.message:"Failed to load models"),r([{id:"default",name:"Default Model"}]),s("default")}finally{g&&a(!1)}}return y(),()=>{g=!1}},[t]);function c(g){s(g),qy(g),t?.(g)}if(o)return h.jsxs("div",{className:W("flex items-center gap-2 text-xs text-primary-500",e),children:[h.jsx(re,{icon:Yn,size:14}),h.jsx("span",{children:"Loading..."})]});if(l||n.length===0)return null;const f=n.find(g=>g.id===i),d=f?.name||"Select Model",p=(()=>{if(!f?.name)return d;const y=f.name.replace(/\s*\([^)]*\)\s*$/,"").trim(),w=y.split(/\s+/);return w.length>3?w.slice(0,3).join(" "):y})();return n.length===1?h.jsxs("div",{className:W("flex items-center gap-2 text-xs text-primary-500",e),children:[h.jsx(re,{icon:Yn,size:14}),h.jsx("span",{className:"font-[450] md:hidden",children:p}),h.jsx("span",{className:"font-[450] hidden md:inline",children:d})]}):h.jsxs(Br,{children:[h.jsxs(Hr,{className:W("inline-flex h-7 items-center gap-2 rounded-md px-2 text-xs font-[450] text-primary-600 hover:text-primary-900 hover:bg-primary-100",e),children:[h.jsx(re,{icon:Yn,size:14}),h.jsx("span",{className:"md:hidden",children:p}),h.jsx("span",{className:"hidden md:inline",children:d})]}),h.jsx(Ur,{side:"top",align:"start",children:n.map(g=>h.jsxs(Et,{onClick:()=>c(g.id),className:"justify-between min-w-[180px]",children:[h.jsx("span",{children:g.name}),i===g.id&&h.jsx(re,{icon:Xs,size:14,className:"text-primary-600"})]},g.id))})]})}const La="opencami-personas-enabled",_r="opencami-active-persona";function Ky(){if(typeof window>"u")return!0;try{const e=localStorage.getItem(La);return e===null?!0:e==="true"}catch{return!0}}function Vy(){if(typeof window>"u")return null;try{const e=localStorage.getItem(_r);return e?JSON.parse(e):null}catch{return null}}function Ps(e){if(!(typeof window>"u"))try{e?localStorage.setItem(_r,JSON.stringify(e)):localStorage.removeItem(_r)}catch{}}const Xy={core:"Core",creative:"Creative",curator:"Curator",learning:"Learning",lifestyle:"Lifestyle",professional:"Professional"};function Yy({className:e,onSelect:t}){const[n,r]=m.useState({}),[i,s]=m.useState(null),[o,a]=m.useState(!0),[l,u]=m.useState(!1),[c,f]=m.useState(Ky);m.useEffect(()=>{const y=w=>{w.key===La&&f(w.newValue===null?!0:w.newValue==="true")};return window.addEventListener("storage",y),()=>window.removeEventListener("storage",y)},[]),m.useEffect(()=>{let y=!0;async function w(){try{a(!0);const k=await fetch("/api/personas");if(!k.ok){u(!1);return}const C=await k.json();if(!y)return;C.ok&&C.available?(r(C.personas),u(!0),s(Vy())):u(!1)}catch{if(!y)return;u(!1)}finally{y&&a(!1)}}return w(),()=>{y=!1}},[]);const d=m.useCallback(y=>{s(y),Ps(y),t(`/persona ${y.id}`)},[t]),p=m.useCallback(()=>{s(null),Ps(null),t("/persona exit")},[t]);if(o||!l||!c)return null;const g=Object.entries(n);return g.length===0?null:h.jsxs(Br,{children:[h.jsxs(Hr,{className:W("inline-flex h-7 items-center gap-1.5 rounded-md px-2 text-xs font-[450] text-primary-600 hover:text-primary-900 hover:bg-primary-100",e),children:[h.jsx("span",{className:"text-sm","aria-hidden":"true",children:"🎭"}),i?h.jsxs("span",{className:"flex items-center gap-1",children:[h.jsx("span",{children:i.emoji}),h.jsx("span",{children:i.name})]}):h.jsx("span",{children:"Persona"})]}),h.jsxs(Ur,{side:"top",align:"start",className:"w-[300px] max-h-[360px] overflow-y-auto",children:[i&&h.jsxs(h.Fragment,{children:[h.jsxs(Et,{onClick:p,className:"text-red-600 hover:bg-red-50",children:[h.jsx("span",{className:"text-sm",children:"✕"}),h.jsx("span",{children:"Exit Persona"}),h.jsxs("span",{className:"ml-auto text-[10px] text-primary-400",children:[i.emoji," ",i.name]})]}),h.jsx("div",{className:"my-1 h-px bg-primary-200"})]}),g.map(([y,w])=>h.jsxs("div",{children:[h.jsx("div",{className:"px-2 pb-0.5 pt-2 text-[10px] font-semibold uppercase tracking-wider text-primary-400",children:Xy[y]??y}),w.map(k=>h.jsxs(Et,{onClick:()=>d(k),className:"justify-between",children:[h.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[h.jsx("span",{className:"text-sm flex-shrink-0",children:k.emoji}),h.jsx("span",{className:"truncate",children:k.name})]}),h.jsx("span",{className:"text-[11px] text-primary-400 truncate ml-2 max-w-[140px]",children:k.description})]},k.id))]},y))]})]})}const Gy=[{command:"/new",description:"Start a new conversation",usage:"/new"},{command:"/reset",description:"Reset conversation context",usage:"/reset"},{command:"/abort",description:"Abort current generation",usage:"/abort"},{command:"/status",description:"Show session status card",usage:"/status"},{command:"/usage",description:"Show token usage",usage:"/usage [off|tokens|full]"},{command:"/models",description:"List available models",usage:"/models"},{command:"/agents",description:"List available agents",usage:"/agents"},{command:"/sessions",description:"List active sessions",usage:"/sessions"},{command:"/model",description:"Switch model for this session",usage:"/model <alias>"},{command:"/reasoning",description:"Toggle reasoning mode",usage:"/reasoning [on|off|stream]"},{command:"/think",description:"Set thinking budget",usage:"/think [off|minimal|low|medium|high]"},{command:"/verbose",description:"Toggle verbose output",usage:"/verbose [on|full|off]"},{command:"/tts",description:"Text-to-speech controls",usage:"/tts [status|off|always]"},{command:"/settings",description:"Show current settings",usage:"/settings"},{command:"/help",description:"Show help",usage:"/help"}];function Qy({className:e,onCommandSelect:t}){const[n,r]=m.useState(!1);function i(s){t?.(s),r(!1)}return h.jsxs(h.Fragment,{children:[h.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>r(!0),className:W("h-7 w-7 p-0",e),title:"Show commands (Ctrl+/)",children:h.jsx(re,{icon:ji,size:16,className:"text-primary-500"})}),n&&h.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:h.jsxs("div",{className:"bg-white dark:bg-neutral-900 border border-primary-200 dark:border-neutral-700 rounded-xl shadow-2xl w-full max-w-lg max-h-[80vh] overflow-hidden",children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-primary-200 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-800",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(re,{icon:ji,size:18,className:"text-primary-600 dark:text-primary-400"}),h.jsx("h2",{className:"font-semibold text-primary-900 dark:text-white",children:"Slash Commands"})]}),h.jsx(Ce,{variant:"ghost",size:"sm",onClick:()=>r(!1),className:"h-7 w-7 p-0",children:h.jsx(re,{icon:On,size:16})})]}),h.jsxs("div",{className:"overflow-y-auto max-h-[60vh] p-2 bg-white dark:bg-neutral-900",children:[h.jsx("div",{className:"text-xs text-primary-500 dark:text-neutral-400 px-2 py-1 mb-2",children:"Type these commands in the chat input"}),Gy.map(s=>h.jsxs("button",{onClick:()=>i(s.command),className:"w-full flex items-start gap-3 px-3 py-2 rounded-lg hover:bg-primary-100 dark:hover:bg-neutral-800 transition-colors text-left",children:[h.jsx("code",{className:"text-sm font-mono font-medium text-primary-700 dark:text-primary-300 bg-primary-100 dark:bg-neutral-800 px-1.5 py-0.5 rounded min-w-[80px]",children:s.command}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"text-sm text-primary-900 dark:text-neutral-100",children:s.description}),s.usage&&s.usage!==s.command&&h.jsx("div",{className:"text-xs text-primary-500 dark:text-neutral-500 font-mono mt-0.5",children:s.usage})]})]},s.command))]}),h.jsx("div",{className:"px-4 py-2 border-t border-primary-200 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-800",children:h.jsxs("div",{className:"text-xs text-primary-500 dark:text-neutral-400",children:["Press ",h.jsx("kbd",{className:"px-1 py-0.5 bg-primary-200 dark:bg-neutral-700 rounded text-primary-700 dark:text-neutral-300",children:"Esc"})," to close"]})})]})})]})}const Jy=10*1024*1024,Ot=1280,Zy=.75,eb=300*1024,tb=["image/png","image/jpeg","image/gif","image/webp"],nb=".png,.jpg,.jpeg,.gif,.webp";function rb(){if(typeof document>"u")return!1;try{const e=document.createElement("canvas");return!!(e.getContext&&e.getContext("2d"))}catch{return!1}}async function ib(e){if(!rb())throw new Error("Image compression not available in this browser");return new Promise((t,n)=>{const r=new Image,i=URL.createObjectURL(e),s=()=>{URL.revokeObjectURL(i)};r.onload=()=>{try{let o=r.width,a=r.height;(o>Ot||a>Ot)&&(o>a?(a=Math.round(a*Ot/o),o=Ot):(o=Math.round(o*Ot/a),a=Ot));const l=document.createElement("canvas");l.width=o,l.height=a;const u=l.getContext("2d");if(!u){s(),n(new Error("Failed to get canvas context"));return}u.drawImage(r,0,0,o,a);const c=e.type==="image/png"?"image/png":"image/jpeg";let f=Zy,d=l.toDataURL(c,f);if(c==="image/jpeg"){const g=eb*1.37;for(;d.length>g&&f>.3;)f-=.1,d=l.toDataURL(c,f)}const p=d.split(",")[1];if(!p){s(),n(new Error("Failed to encode image"));return}s(),t(p)}catch(o){s(),n(o instanceof Error?o:new Error("Image compression failed"))}},r.onerror=()=>{s(),n(new Error("Failed to load image"))},r.src=i})}function za(e){return tb.includes(e.type)}async function Pa(e){const t=crypto.randomUUID();if(!za(e))return{id:t,file:e,preview:null,type:"image",base64:null,error:"Unsupported file type. Please use PNG, JPG, GIF, or WebP images."};if(e.size>Jy)return{id:t,file:e,preview:null,type:"image",base64:null,error:"Image is too large. Maximum size is 10MB."};try{const n=await ib(e),r=URL.createObjectURL(e);return{id:t,file:e,preview:r,type:"image",base64:n}}catch(n){return{id:t,file:e,preview:null,type:"image",base64:null,error:n instanceof Error?n.message:"Failed to process image"}}}function sb({onFileSelect:e,disabled:t=!1,className:n}){const r=m.useRef(null),i=m.useCallback(()=>{r.current?.click()},[]),s=m.useCallback(async o=>{const a=o.target.files?.[0];if(!a)return;o.target.value="";const l=await Pa(a);e(l)},[e]);return h.jsxs(h.Fragment,{children:[h.jsx("input",{ref:r,type:"file",accept:nb,onChange:s,className:"hidden","aria-hidden":"true"}),h.jsx(Ce,{variant:"ghost",size:"icon-sm",onClick:i,disabled:t,className:n,"aria-label":"Attach image",type:"button",children:h.jsx(re,{icon:jl,size:18,strokeWidth:1.8})})]})}function ob(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ab(e){const t=e.split(".");return t.length>1&&t.pop()?.toUpperCase()||""}function lb({attachment:e,onRemove:t,className:n}){m.useEffect(()=>()=>{e.preview&&URL.revokeObjectURL(e.preview)},[e.preview]);const r=!!e.error;return h.jsxs("div",{className:W("relative flex items-center gap-3 rounded-xl border p-2 pr-3",r?"border-red-300 bg-red-50":"border-primary-200 bg-primary-50",n),children:[h.jsx("div",{className:"relative shrink-0",children:e.type==="image"&&e.preview?h.jsx("img",{src:e.preview,alt:e.file.name,className:"h-12 w-12 rounded-lg object-cover"}):h.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-lg bg-primary-100",children:h.jsx(re,{icon:Al,size:24,className:"text-primary-500"})})}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsx("p",{className:"truncate text-sm font-medium text-primary-900",children:e.file.name}),r?h.jsx("p",{className:"text-xs text-red-600",children:e.error}):h.jsxs("p",{className:"text-xs text-primary-500",children:[ab(e.file.name)," •"," ",ob(e.file.size)]})]}),h.jsx(Ce,{variant:"ghost",size:"icon-sm",onClick:()=>t(e.id),className:"h-6 w-6 shrink-0 rounded-full hover:bg-primary-200","aria-label":"Remove attachment",type:"button",children:h.jsx(re,{icon:On,size:14})})]})}function ub({attachments:e,onRemove:t,className:n}){return e.length===0?null:h.jsx("div",{className:W("flex flex-col gap-2 px-4",n),children:e.map(r=>h.jsx(lb,{attachment:r,onRemove:t},r.id))})}function cb({commands:e,selectedIndex:t,onSelect:n,className:r}){return e.length===0?null:h.jsx("div",{className:W("absolute left-2 right-2 md:left-5 md:right-5 bottom-full mb-2 z-20 rounded-xl border border-white/10 bg-neutral-900/95 shadow-2xl backdrop-blur-sm overflow-hidden",r),role:"listbox","aria-label":"Slash commands",children:h.jsx("div",{className:"max-h-56 overflow-y-auto p-1",children:e.map((i,s)=>{const o=s===t;return h.jsx("button",{type:"button",role:"option","aria-selected":o,onMouseDown:a=>{a.preventDefault(),n(i)},className:W("w-full rounded-md px-3 py-2 text-left transition-colors",o?"bg-neutral-800":"hover:bg-neutral-800/80"),children:h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("code",{className:"min-w-[90px] font-mono text-xs text-primary-300",children:i.command}),h.jsx("span",{className:"text-xs text-neutral-300",children:i.description})]})},i.command)})})})}const fb=m.memo(cb),_s=[{command:"/haiku",description:"Switch to Claude Haiku 4.5"},{command:"/sonnet",description:"Switch to Claude Sonnet 4.5"},{command:"/opus",description:"Switch to Claude Opus 4.5"},{command:"/opus46",description:"Switch to Claude Opus 4.6"},{command:"/codex",description:"Switch to GPT 5.3 Codex"},{command:"/glm",description:"Switch to GLM 4.7"},{command:"/kimi",description:"Switch to Kimi K2.5"},{command:"/minimax",description:"Switch to MiniMax M2.1"},{command:"/grok",description:"Switch to Grok 4.1 Fast"},{command:"/model",description:"Show model picker or switch model"},{command:"/new",description:"New chat (optional: /new model)"},{command:"/reset",description:"Reset session"},{command:"/stop",description:"Stop current generation"},{command:"/compact",description:"Compact conversation context"},{command:"/help",description:"Show available commands"},{command:"/commands",description:"List all commands"},{command:"/status",description:"Show session status & usage"},{command:"/whoami",description:"Show your sender ID"},{command:"/context",description:"Show context window details"},{command:"/usage",description:"Toggle usage footer (off/tokens/full/cost)"},{command:"/think",description:"Set thinking level (off/low/medium/high)"},{command:"/reasoning",description:"Toggle reasoning (on/off/stream)"},{command:"/verbose",description:"Toggle verbose mode (on/full/off)"},{command:"/elevated",description:"Toggle elevated permissions (on/off/ask)"},{command:"/exec",description:"Configure exec settings"},{command:"/queue",description:"Show/configure message queue"},{command:"/tts",description:"Text-to-speech (off/always/tagged/status)"},{command:"/subagents",description:"List/stop/log sub-agent runs"},{command:"/followups",description:"Show follow-up suggestions"},{command:"/skill",description:"Run a skill by name"},{command:"/allowlist",description:"List/add/remove allowlist entries"},{command:"/approve",description:"Resolve exec approval (allow/deny)"},{command:"/config",description:"Show/get/set config (owner-only)"},{command:"/debug",description:"Runtime overrides (owner-only)"},{command:"/send",description:"Toggle message sending (on/off)"},{command:"/restart",description:"Restart gateway"},{command:"/activation",description:"Set activation mode (mention/always)"},{command:"/dock-telegram",description:"Switch replies to Telegram"},{command:"/dock-discord",description:"Switch replies to Discord"},{command:"/bash",description:"Run host shell command"}];function hb({onSubmit:e,isLoading:t,disabled:n,wrapperRef:r,inputRef:i}){const[s,o]=m.useState(""),[a,l]=m.useState(""),[u,c]=m.useState([]),[f,d]=m.useState(0),[p,g]=m.useState(!1),[y,w]=m.useState(!1),[k,C]=m.useState(!1),[E,N]=m.useState(0),[M,S]=m.useState(!1),O=m.useRef(null),H=m.useRef([]),_=m.useRef(null),v=m.useRef(null),D=m.useRef(null),A=m.useMemo(()=>/^\/\S*$/.test(s)&&!p,[s,p]),F=m.useMemo(()=>A?s.slice(1).toLowerCase():"",[A,s]),T=m.useMemo(()=>A?F?_s.filter(K=>K.command.slice(1).toLowerCase().startsWith(F)):_s:[],[A,F]),j=m.useCallback(K=>{D.current=K,i&&(typeof i=="function"?i(K):i.current=K)},[i]),R=m.useCallback(()=>{typeof window>"u"||window.requestAnimationFrame(()=>{D.current?.focus()})},[]),$=m.useCallback(()=>{o(""),c([]),d(0),g(!1),R()},[R]),U=m.useCallback(K=>{c(te=>[...te,K])},[]),L=m.useCallback(K=>{c(te=>te.filter(z=>z.id!==K))},[]),x=m.useCallback(K=>{Array.from(K.dataTransfer.types).includes("Files")&&(K.preventDefault(),K.dataTransfer.dropEffect="copy",w(!0))},[]),q=m.useCallback(K=>{K.preventDefault();const te=K.relatedTarget;te&&K.currentTarget.contains(te)||w(!1)},[]),V=m.useCallback(async K=>{K.preventDefault(),w(!1);const te=Array.from(K.dataTransfer.files??[]);if(te.length===0)return;const z=te.filter(Z=>za(Z));if(z.length===0)return;const ge=await Promise.all(z.map(Z=>Pa(Z)));c(Z=>[...Z,...ge]),R()},[R]),b=m.useCallback(K=>{o(K),d(0),g(!1),R()},[R]),ee=m.useCallback(K=>{o(K),d(0),g(!1)},[]),Q=m.useCallback(K=>{o(`${K.command} `),d(0),g(!1),R()},[R]),G=m.useCallback(()=>{if(n)return;if(A&&T.length>0){const z=Math.min(f,T.length-1);Q(T[z]);return}const K=s.trim(),te=u.filter(z=>!z.error&&z.base64);K.length===0&&te.length===0||(e(K,{reset:$,setValue:b,model:a||void 0,attachments:te}),R())},[n,A,T,f,Q,s,u,e,$,b,a,R]),de=m.useCallback(K=>{e(K,{reset:$,setValue:b,model:a||void 0,attachments:[]}),R()},[R,e,$,b,a]),he=m.useCallback(K=>{if(A){if(K.key==="Escape"){K.preventDefault(),g(!0),d(0);return}if(T.length!==0){if(K.key==="ArrowDown"){K.preventDefault(),d(te=>(te+1)%T.length);return}if(K.key==="ArrowUp"){K.preventDefault(),d(te=>(te-1+T.length)%T.length);return}if(K.key==="Tab"){K.preventDefault();const te=Math.min(f,T.length-1);Q(T[te])}}}},[A,T,f,Q]);m.useEffect(()=>()=>{_.current&&clearInterval(_.current),O.current&&O.current.state!=="inactive"&&O.current.stop(),v.current&&v.current.abort()},[]);const se=m.useCallback(()=>{if(typeof window>"u")return"auto";try{return localStorage.getItem("opencami-stt-provider")||"auto"}catch{return"auto"}},[]),oe=m.useCallback(()=>{O.current&&O.current.state!=="inactive"&&O.current.stop(),v.current&&v.current.stop(),_.current&&(clearInterval(_.current),_.current=null),C(!1),N(0)},[]),me=m.useCallback(async()=>{const K=se();if(K==="browser"){const te=window.SpeechRecognition||window.webkitSpeechRecognition;if(!te){alert("Web Speech API is not supported in this browser.");return}const z=new te;z.continuous=!0,z.interimResults=!1,z.lang=navigator.language||"en-US",v.current=z,C(!0),N(0),_.current=setInterval(()=>{N(Z=>Z>=119?(oe(),0):Z+1)},1e3);let ge="";z.onresult=Z=>{for(let be=Z.resultIndex;be<Z.results.length;be++)Z.results[be].isFinal&&(ge+=Z.results[be][0].transcript)},z.onend=()=>{C(!1),N(0),_.current&&clearInterval(_.current),ge.trim()&&(o(Z=>Z+(Z?" ":"")+ge.trim()),R())},z.onerror=()=>{C(!1),N(0),_.current&&clearInterval(_.current)},z.start();return}try{const te=await navigator.mediaDevices.getUserMedia({audio:!0}),z=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",ge=new MediaRecorder(te,{mimeType:z});O.current=ge,H.current=[],ge.ondataavailable=Z=>{Z.data.size>0&&H.current.push(Z.data)},ge.onstop=async()=>{te.getTracks().forEach(be=>be.stop());const Z=new Blob(H.current,{type:z});if(Z.size!==0){S(!0);try{const be=new FormData;be.append("audio",Z,`recording.${z==="audio/webm"?"webm":"mp4"}`),K!=="auto"&&be.append("provider",K);const Se=await(await fetch("/api/stt",{method:"POST",body:be})).json();Se.ok&&Se.text?(o(Ke=>Ke+(Ke?" ":"")+Se.text),R()):Se.ok||(console.warn("STT failed:",Se.error),alert(Se.error||"Speech-to-text failed. Try the Browser provider in Settings."))}catch(be){console.warn("STT request failed:",be),alert("Could not reach speech-to-text service.")}finally{S(!1)}}},C(!0),N(0),_.current=setInterval(()=>{N(Z=>Z>=119?(oe(),0):Z+1)},1e3),ge.start()}catch(te){const z=te instanceof Error?te.message:String(te);if(z.includes("NotAllowedError")||z.includes("Permission"))try{(await navigator.permissions.query({name:"microphone"})).state==="denied"?alert("Microphone access is blocked. Please enable it in your browser/app settings."):alert("Microphone permission was not granted. Please try again and allow access when prompted.")}catch{alert("Could not access microphone. Please check your browser settings and allow microphone access for this site.")}else alert("Could not access microphone: "+z)}},[se,oe,R]),Te=m.useCallback(()=>{k?oe():me()},[k,oe,me]),xe=u.filter(K=>!K.error&&K.base64),De=n||s.trim().length===0&&xe.length===0;return h.jsxs("div",{className:"mx-auto w-full max-w-full px-2 md:px-5 sm:max-w-[768px] sm:min-w-[400px] relative pb-1 md:pb-3",ref:r,onDragOver:x,onDragLeave:q,onDrop:V,children:[y&&h.jsx("div",{className:"pointer-events-none absolute inset-2 z-20 flex items-center justify-center rounded-2xl border-2 border-dashed border-primary-400 bg-primary-50/90 text-sm font-medium text-primary-700",children:"Drop image here"}),h.jsxs($y,{value:s,onValueChange:ee,onSubmit:G,isLoading:t,disabled:n,children:[h.jsx(ub,{attachments:u,onRemove:L}),A&&T.length>0&&h.jsx(fb,{commands:T,selectedIndex:Math.min(f,T.length-1),onSelect:Q}),h.jsx(By,{placeholder:"Type a message…",inputRef:j,onKeyDown:he}),h.jsxs(Hy,{className:"justify-between px-3",children:[h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(Wy,{onModelChange:l}),h.jsx(Yy,{onSelect:de}),h.jsx(Qy,{onCommandSelect:K=>ee(K+" ")})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx(br,{tooltip:"Attach file",children:h.jsx(sb,{onFileSelect:U,disabled:n})}),h.jsx(br,{tooltip:k?"Stop recording":"Voice input",children:h.jsx(Ce,{onClick:Te,disabled:n||M,size:"icon-sm",variant:k?"destructive":"ghost",className:`rounded-full ${k?"animate-pulse":""}`,"aria-label":k?"Stop recording":"Voice input",children:M?h.jsx("span",{className:"size-4 animate-spin rounded-full border-2 border-current border-t-transparent"}):k?h.jsxs("span",{className:"flex items-center gap-1",children:[h.jsx("span",{className:"size-2 rounded-full bg-red-500"}),h.jsxs("span",{className:"text-xs tabular-nums",children:[Math.floor(E/60),":",String(E%60).padStart(2,"0")]}),h.jsx(re,{icon:Ys,size:14,strokeWidth:2})]}):h.jsx(re,{icon:Il,size:18,strokeWidth:2})})}),h.jsx(br,{tooltip:"Send message",children:h.jsx(Ce,{onClick:G,disabled:De,size:"icon-sm",className:"rounded-full","aria-label":"Send message",children:h.jsx(re,{icon:Rl,size:18,strokeWidth:2})})})]})]})]})]})}const pb=m.memo(hb);function db({title:e,description:t,detail:n,actionLabel:r,onAction:i,className:s}){return h.jsx("div",{className:W("w-full max-w-[900px]",s),children:h.jsx(Ra,{children:h.jsxs("div",{className:"w-full rounded-xl border border-primary-200 bg-primary-50 p-4 text-primary-900",children:[h.jsx("div",{className:"text-balance font-medium",children:e}),h.jsx("div",{className:"mt-2 text-pretty text-primary-700",children:t}),n?h.jsx("div",{className:"mt-2 text-xs text-primary-600",children:n}):null,r&&i?h.jsx("div",{className:"mt-3",children:h.jsx(Ce,{size:"sm",variant:"outline",onClick:i,children:r})}):null]})})})}function mb({state:e,error:t,onRetry:n,className:r}){const i=e==="checking",s=i?"Checking gateway connection...":"OpenClaw gateway is unreachable",o=i?"This dashboard needs access to the OpenClaw gateway configured by your server environment variables.":"";return h.jsx(db,{title:s,description:i?o:h.jsxs(h.Fragment,{children:["We could not reach the gateway from the dashboard server. Start the gateway and confirm your server environment has"," ",h.jsx("span",{className:"font-mono",children:"CLAWDBOT_GATEWAY_URL"})," plus"," ",h.jsx("span",{className:"font-mono",children:"CLAWDBOT_GATEWAY_TOKEN"})," (or"," ",h.jsx("span",{className:"font-mono",children:"CLAWDBOT_GATEWAY_PASSWORD"}),")."]}),detail:i?null:t,actionLabel:i?void 0:"Retry",onAction:i?void 0:n,className:r})}function gb(){const e=m.useRef(null),t=m.useRef(null),n=m.useRef(null),[r,i]=m.useState(0),[s,o]=m.useState(0);return m.useLayoutEffect(()=>{const a=e.current,l=t.current,u=n.current;if(!u)return;const c=()=>{const d=a?.offsetHeight??0,p=l?.offsetHeight??0,g=u.clientHeight;u.style.setProperty("--chat-header-height",`${Math.max(0,d)}px`),u.style.setProperty("--chat-composer-height",`${Math.max(0,p)}px`),o(d),i(Math.max(0,g-d-p))};c();const f=new ResizeObserver(()=>c());return a&&f.observe(a),l&&f.observe(l),()=>f.disconnect()},[]),{headerRef:e,composerRef:t,mainRef:n,pinGroupMinHeight:r,headerHeight:s}}function xb({activeFriendlyId:e,activeSessionKey:t,forcedSessionKey:n,isNewChat:r,isRedirecting:i,activeExists:s,sessionsReady:o,queryClient:a}){const l=n||t||e,u=we.history(e,l),c=Cn({queryKey:u,queryFn:async function(){const C=a.getQueryData(u),E=Array.isArray(C?.messages)?C.messages.filter(S=>S.status==="sending"||S.__optimisticId?!0:!!S.clientId):[],N=await uu({sessionKey:l,friendlyId:e});if(!E.length)return N;const M=yb(N.messages,E);return{...N,messages:M}},enabled:!r&&!!e&&!i&&(!o||s),placeholderData:function(){return a.getQueryData(u)},gcTime:1e3*60*10}),f=m.useRef(""),d=m.useRef([]),p=m.useMemo(()=>{const k=Array.isArray(c.data?.messages)?c.data.messages:[],C=k[k.length-1],E=C&&typeof C.id=="string"?C.id:"",N=`${k.length}:${C?.role??""}:${E}:${Je(C??{content:[]}).slice(-32)}`;return N===f.current?d.current:(f.current=N,d.current=k,k)},[c.data?.messages]),g=c.error instanceof Error?c.error.message:null,y=m.useMemo(()=>{if(n)return n;const k=c.data?.sessionKey;return typeof k=="string"&&k.trim().length>0?k.trim():t},[t,n,c.data?.sessionKey]);return{historyQuery:c,historyMessages:p,displayMessages:p,historyError:g,resolvedSessionKey:y,activeCanonicalKey:r?"new":y||e,sessionKeyForHistory:l}}function yb(e,t){if(!t.length)return e;const n=[...e];for(const r of t)e.some(s=>{if(r.clientId&&s.clientId&&r.clientId===s.clientId||r.__optimisticId&&s.__optimisticId&&r.__optimisticId===s.__optimisticId)return!0;if(r.role&&s.role&&r.role!==s.role)return!1;const o=Je(r);if(!o||o!==Je(s))return!1;const a=Sr(r),l=Sr(s);return Math.abs(a-l)<=1e4})||n.push(r);return n}function bb(e){const[t,n]=m.useState(!1);return m.useLayoutEffect(()=>{const r=window.matchMedia("(max-width: 768px)"),i=()=>n(r.matches);return i(),r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[]),m.useLayoutEffect(()=>{t&&pt(e,function(i){return{...i,isSidebarCollapsed:!0}})},[t,e]),{isMobile:t}}function kb({activeFriendlyId:e,isNewChat:t,forcedSessionKey:n}){const r=Cn({queryKey:we.sessions,queryFn:lu,refetchInterval:3e4}),i=m.useMemo(()=>{const f=r.data??[];return Dc(f)},[r.data]),s=m.useMemo(()=>i.find(f=>f.friendlyId===e),[i,e]),o=m.useMemo(()=>t||n||yo(e)?!0:i.some(f=>f.friendlyId===e),[e,n,t,i]),a=s?.key??"",l=m.useMemo(()=>s?s.label||s.title||s.derivedTitle||s.friendlyId:e,[e,s]),u=r.error instanceof Error?r.error.message:null,c=m.useMemo(()=>({totalTokens:s?.totalTokens,contextTokens:s?.contextTokens}),[s?.totalTokens,s?.contextTokens]);return{sessionsQuery:r,sessions:i,activeSession:s,activeExists:o,activeSessionKey:a,activeTitle:l,activeTokens:c,sessionsError:u}}function wb(){const e=$t(u=>u.settings),[t,n]=m.useState(!1),[r,i]=m.useState(null),[s,o]=m.useState(null),a=m.useRef(null);return{generateTitle:m.useCallback(async u=>{a.current&&a.current.abort();const c=new AbortController;a.current=c,n(!0);try{const f={"Content-Type":"application/json"};e.openaiApiKey&&(f["X-OpenAI-API-Key"]=e.openaiApiKey);const d=await fetch("/api/llm-features",{method:"POST",headers:f,body:JSON.stringify({action:"title",message:u}),signal:c.signal});if(!d.ok)throw new Error(`API error: ${d.status}`);const p=await d.json();if(c.signal.aborted)throw new Error("Aborted");const g=p.title||u.slice(0,50),y=p.source||"heuristic";return i(g),o(y),{title:g,source:y,error:p.error}}catch(f){if(f instanceof Error&&f.name==="AbortError")throw f;const d=Sb(u);return i(d),o("heuristic"),{title:d,source:"heuristic",error:f instanceof Error?f.message:"Unknown error"}}finally{n(!1),a.current===c&&(a.current=null)}},[e.openaiApiKey]),isGenerating:t,lastTitle:r,lastSource:s}}function Sb(e){let t=e.replace(/```[\s\S]*?```/g," ");t=t.replace(/`[^`]+`/g," "),t=t.replace(/https?:\/\/[^\s]+/g," "),t=t.replace(/[^\w\s.,!?'-]/g," "),t=t.replace(/\s+/g," ").trim();let i=t.split(/\s+/).filter(s=>{if(s.length<=2){const o=s.toUpperCase();return["AI","ML","UI","UX","API","CSS","JS"].includes(o)}return!0}).slice(0,6).join(" ");return i=i.replace(/[.,!?]+$/,""),i.length>60&&(i=i.slice(0,57)+"..."),i||e.slice(0,50)}function Cb(){return $t(e=>e.settings.useLlmTitles)}const kr={active:!1,text:"",tools:[],sessionKey:null};function vb(e){const[t,n]=m.useState(kr),r=m.useRef(null),i=m.useRef(e.onDone),s=m.useRef(e.onError);i.current=e.onDone,s.current=e.onError;const o=m.useCallback(l=>{if(r.current&&(r.current.close(),r.current=null),l?.preserveState){n(u=>({...u,active:!1}));return}n(kr)},[]),a=m.useCallback(l=>{r.current&&(r.current.close(),r.current=null),n({active:!0,text:"",tools:[],sessionKey:l});const u=new EventSource(`/api/stream?sessionKey=${encodeURIComponent(l)}`);r.current=u,u.addEventListener("delta",c=>{try{const f=JSON.parse(c.data);n(d=>({...d,text:d.text+f.text}))}catch{}}),u.addEventListener("tool",c=>{try{const f=JSON.parse(c.data);n(d=>{const p=d.tools.findIndex(y=>y.id===f.id),g=[...d.tools];return p>=0?g[p]={name:f.name,status:f.status,id:f.id}:g.push({name:f.name,status:f.status,id:f.id}),{...d,tools:g}})}catch{}}),u.addEventListener("done",c=>{try{const f=JSON.parse(c.data);u.close(),r.current=null,n(d=>({...d,active:!1})),i.current(f.sessionKey)}catch{}}),u.onerror=()=>{u.readyState===EventSource.CLOSED&&(u.close(),r.current=null,n(kr),s.current?.("Stream connection lost"))}},[]);return{streaming:t,startStream:a,stopStream:o}}function Eb(e){const t=m.useCallback(n=>{const r=n.target,i=r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable;if(n.key==="Escape"){e.onEscape?.();return}if(n.key==="?"&&!i&&!n.metaKey&&!n.ctrlKey){n.preventDefault(),e.onShowHelp?.();return}if(i)return;const o=navigator.platform.toUpperCase().indexOf("MAC")>=0?n.metaKey:n.ctrlKey;if(o&&n.key==="k"&&!n.shiftKey){n.preventDefault(),e.onNewChat?.();return}if(o&&n.key==="/"){n.preventDefault(),e.onFocusInput?.();return}if(o&&n.shiftKey&&n.key==="C"){n.preventDefault(),e.onCopyLastResponse?.();return}if(o&&n.key==="f"&&!n.shiftKey){n.preventDefault(),e.onSearch?.();return}if(o&&n.shiftKey&&n.key==="F"){n.preventDefault(),e.onSearchGlobal?.();return}},[e]);m.useEffect(()=>(window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t)}),[t])}function Os(e){const{threshold:t=50,edgeWidth:n,onMove:r,onSwipe:i,onCancel:s,direction:o,enabled:a=!0}=e,l=m.useRef({startX:0,startY:0,tracking:!1,directionLocked:!1}),u=m.useCallback(d=>{if(!a)return;const p=d.touches[0];p&&(n!==void 0&&p.clientX>n||(l.current={startX:p.clientX,startY:p.clientY,tracking:!0,directionLocked:!1}))},[a,n]),c=m.useCallback(d=>{const p=l.current;if(!p.tracking)return;const g=d.touches[0];if(!g)return;const y=g.clientX-p.startX,w=g.clientY-p.startY,k=Math.abs(y),C=Math.abs(w);if(!p.directionLocked){if(k<5&&C<5)return;if(C>k){p.tracking=!1,s?.();return}p.directionLocked=!0}o==="left"&&y>0||o==="right"&&y<0||(d.preventDefault(),r?.(y))},[o,r,s]),f=m.useCallback(d=>{const p=l.current;if(!p.tracking)return;p.tracking=!1;const g=d.changedTouches[0];if(!g){s?.();return}const y=g.clientX-p.startX,w=Math.abs(y);if(!p.directionLocked||w<t){s?.();return}const k=y>0?"right":"left";if(o&&k!==o){s?.();return}i(k)},[o,s,i,t]);return{onTouchStart:u,onTouchMove:c,onTouchEnd:f}}const Tb=m.lazy(()=>_n(()=>import("./keyboard-shortcuts-dialog-zdnAmDiH.js"),__vite__mapDeps([10,1,3,2,4,5])).then(e=>({default:e.KeyboardShortcutsDialog}))),jb=m.lazy(()=>_n(()=>import("./search-dialog-Ck1AQreu.js"),__vite__mapDeps([11,1,2,3,4,5,7,8])).then(e=>({default:e.SearchDialog})));function Ab({activeFriendlyId:e,isNewChat:t=!1,onSessionResolved:n,forcedSessionKey:r}){const i=$s(),s=Ut(),[o,a]=m.useState(!1),[l,u]=m.useState(!1),[c,f]=m.useState(null),[d,p]=m.useState(!1),{headerRef:g,composerRef:y,mainRef:w,pinGroupMinHeight:k,headerHeight:C}=gb(),[E,N]=m.useState(()=>er()||tr()),[M,S]=m.useState(()=>er()||tr()),[O,H]=m.useState(!1),[_,v]=m.useState(!1),[D,A]=m.useState("global"),[F,T]=m.useState(!1),j=m.useRef(null),R=m.useRef(null),$=m.useRef(null),U=m.useRef(""),L=m.useRef(()=>{}),x=m.useRef(!1),{isMobile:q}=bb(s),{sessionsQuery:V,sessions:b,activeExists:ee,activeSessionKey:Q,activeTitle:G,activeTokens:de,sessionsError:he}=kb({activeFriendlyId:e,isNewChat:t,forcedSessionKey:r}),{historyQuery:se,historyMessages:oe,displayMessages:me,historyError:Te,resolvedSessionKey:xe,activeCanonicalKey:De,sessionKeyForHistory:K}=xb({activeFriendlyId:e,activeSessionKey:Q,forcedSessionKey:r,isNewChat:t,isRedirecting:d,activeExists:ee,sessionsReady:V.isSuccess,queryClient:s}),te=Cn({queryKey:ul,queryFn:function(){return Ti(s)},initialData:function(){return Ti(s)},staleTime:1/0}),z=Cn({queryKey:["gateway","status"],queryFn:cu,retry:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:"always"}),ge=m.useRef(Date.now()),Z=z.error instanceof Error?z.error.message:z.data&&!z.data.ok?z.data.error||"Gateway unavailable":null,be=Z??he??Te,We=m.useCallback(()=>{z.refetch()},[z]),Se=te.data?.isSidebarCollapsed??!1,Ke=Os({enabled:q&&Se,edgeWidth:40,threshold:50,direction:"right",onSwipe:()=>{pt(s,B=>({...B,isSidebarCollapsed:!1}))}}),et=Os({enabled:q&&!Se,threshold:50,direction:"left",onSwipe:()=>{pt(s,B=>({...B,isSidebarCollapsed:!0}))}}),st=m.useCallback(()=>{f(null),p(!0),i({to:"/new",replace:!0})},[i]),I=m.useCallback(()=>{R.current&&(window.clearInterval(R.current),R.current=null),$.current&&(window.clearTimeout($.current),$.current=null)},[]),P=m.useCallback(()=>{I(),Kt(!1),N(!1),T(!1)},[I]),X=Cb(),{generateTitle:ne}=wb(),le=m.useRef(new Set),ve=150,Ve=600,ze=m.useCallback(()=>{!e||t||(R.current&&window.clearInterval(R.current),T(!0),R.current=window.setInterval(()=>{L.current()},ve))},[e,t]),Fe=m.useRef(()=>{}),$e=m.useRef(()=>{}),{streaming:ye,startStream:Xe,stopStream:Ee}=vb({onDone:B=>Fe.current(B),onError:B=>$e.current(B)});Fe.current=m.useCallback(async B=>{await se.refetch(),Ee({preserveState:!0}),P(),s.invalidateQueries({queryKey:we.sessions})},[se,s,Ee,P]),$e.current=m.useCallback(B=>{console.warn("[stream] SSE error, falling back to polling")},[]);const yt=m.useMemo(()=>{if(!ye.text)return null;const B=[];for(const J of ye.tools)B.push({type:"toolCall",name:J.name,id:J.id});return B.push({type:"text",text:ye.text}),{role:"assistant",content:B,id:"__streaming__",__streaming:!0,timestamp:Date.now()}},[ye.text,ye.tools]),Vn=m.useMemo(()=>{if(!yt)return me;const B=me[me.length-1];if(B?.role==="assistant"){if(Je(B).length>=ye.text.length)return me;const ke=[...me];return ke[ke.length-1]=yt,ke}return[...me,yt]},[me,yt,ye.text]),bt=m.useMemo(()=>({}),[]);L.current=function(){se.refetch()},m.useEffect(()=>{if(d){c&&f(null);return}if(ce){c&&f(null);return}if(V.isSuccess&&!ee){c&&f(null);return}const B=he??Te??Z;if(!B){c?.startsWith("Failed to load")&&f(null);return}Ii(B)&&i({to:"/connect",replace:!0});const J=he?`Failed to load sessions. ${he}`:Te?`Failed to load history. ${Te}`:Z?`Gateway unavailable. ${Z}`:null;J&&f(J)},[c,Z,Te,d,i,he]);const ce=!t&&!r&&!yo(e)&&V.isSuccess&&b.length>0&&!b.some(B=>B.friendlyId===e)&&!se.isFetching&&!se.isSuccess;m.useEffect(()=>{if(d){if(t){p(!1);return}!ce&&V.isSuccess&&p(!1)}},[t,d,V.isSuccess,ce]),m.useEffect(()=>{t||V.isSuccess&&b.length!==0&&ce&&(In(),vr(s,e,K),i({to:"/new",replace:!0}))},[e,se.isFetching,se.isSuccess,t,i,s,K,b,V.isSuccess,ce]);const Pe=ce||d,ot=m.useRef("fast");m.useEffect(()=>{const B=oe[oe.length-1];if(!B||B.role!=="assistant")return;const J=`${oe.length}:${Je(B).slice(-64)}`;J!==U.current&&(U.current=J,ot.current!=="fast"&&R.current&&(window.clearInterval(R.current),R.current=window.setInterval(()=>{L.current()},ve),ot.current="fast"),$.current&&window.clearTimeout($.current),$.current=window.setTimeout(()=>{R.current&&(window.clearInterval(R.current),R.current=window.setInterval(()=>{L.current()},Ve),ot.current="slow"),$.current=window.setTimeout(()=>{P(),ot.current="fast"},3e3)},1500))},[oe,P]),m.useEffect(()=>{if(!X||t||d)return;const B=r||xe||Q;if(!B||le.current.has(B))return;const J=oe.filter(Me=>Me.role==="user"),ke=oe.filter(Me=>Me.role==="assistant");if(J.length===0||ke.length===0||J.length!==1)return;const tt=Je(J[0]);!tt||tt.length<5||(le.current.add(B),(async()=>{try{const Me=await ne(tt);Me.title&&await gu(s,B,e,Me.title)}catch(Me){console.error("[smart-title] Error generating title:",Me)}})())},[X,t,d,r,xe,Q,e,oe,ne,s]),m.useEffect(()=>{if(t||e){if(x.current){x.current=!1;return}if(er()||tr()){N(!0),S(!0);return}I(),Ee(),U.current="",N(!1),S(!1),T(!1)}},[e,t,I,Ee]),m.useLayoutEffect(()=>{if(t)return;const B=Ac(r||xe||Q,e);if(!B)return;x.current=!0;const J=we.history(B.friendlyId,B.sessionKey),ke=s.getQueryData(J);(Array.isArray(ke?.messages)?ke.messages:[]).some(wt=>!!(B.optimisticMessage.clientId&&(wt.clientId===B.optimisticMessage.clientId||wt.__optimisticId===B.optimisticMessage.clientId)||B.optimisticMessage.__optimisticId&&wt.__optimisticId===B.optimisticMessage.__optimisticId))||Gn(s,B.friendlyId,B.sessionKey,B.optimisticMessage),N(!0),S(!0),kt(B.sessionKey,B.friendlyId,B.message,!0,B.attachments)},[e,Q,r,t,s,xe]);function kt(B,J,ke,tt=!1,Me,wt){let Lt="";if(!tt){const{clientId:je,optimisticMessage:Wt}=Ri(ke,Me);Lt=je,Gn(s,J,B,Wt),du(s,B,J,Wt)}Kt(!0),a(!0),f(null),N(!0),S(!0);const ct=Me?.map(je=>({mimeType:je.file.type,content:je.base64}));Xe(B),ze(),fetch("/api/send",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({sessionKey:B,friendlyId:J,message:ke,thinking:"low",idempotencyKey:crypto.randomUUID(),attachments:ct,model:wt||void 0})}).then(async je=>{if(!je.ok)throw new Error(await rt(je))}).catch(je=>{const Wt=je instanceof Error?je.message:String(je);if(Ii(Wt)){i({to:"/connect",replace:!0});return}Lt&&fu(s,J,B,Lt,function(Ya){return{...Ya,status:"error"}}),f(`Failed to send message. ${Wt}`),Kt(!1),N(!1),S(!1)}).finally(()=>{a(!1)})}const bi=m.useCallback(async()=>{u(!0);try{const B=await fetch("/api/sessions",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({})});if(!B.ok)throw new Error(await rt(B));const J=await B.json(),ke=typeof J.sessionKey=="string"?J.sessionKey:"",tt=typeof J.friendlyId=="string"&&J.friendlyId.trim().length>0?J.friendlyId.trim():wr(ke);if(!ke||!tt)throw new Error("Invalid session response");return s.invalidateQueries({queryKey:we.sessions}),{sessionKey:ke,friendlyId:tt}}finally{u(!1)}},[s]),_a=m.useCallback((B,J)=>{const ke=J.attachments;if(B.length===0&&(!ke||ke.length===0))return;if(J.reset(),t){const{clientId:Me,optimisticId:wt,optimisticMessage:Lt}=Ri(B,ke);Gn(s,"new","new",Lt),Kt(!0),a(!0),N(!0),S(!0),bi().then(({sessionKey:ct,friendlyId:je})=>{if(jc(je),Ec({sessionKey:ct,friendlyId:je,message:B,optimisticMessage:Lt,attachments:ke}),n){n({sessionKey:ct,friendlyId:je});return}i({to:"/chat/$sessionKey",params:{sessionKey:je},replace:!0})}).catch(ct=>{hu(s,"new","new",Me,wt),J.setValue(B),f(`Failed to create session. ${ct instanceof Error?ct.message:String(ct)}`),Kt(!1),N(!1),S(!1),a(!1)});return}kt(r||xe||Q,e,B,!1,ke,J.model)},[e,Q,bi,r,t,i,n,s,xe]),ki=m.useCallback(()=>{N(!1),S(!1),vr(s,"new","new"),i({to:"/new"}),q&&pt(s,function(J){return{...J,isSidebarCollapsed:!0}})},[q,i,s]),Oa=m.useCallback(()=>{pt(s,function(J){return{...J,isSidebarCollapsed:!J.isSidebarCollapsed}})},[s]),Fa=m.useCallback(()=>{q&&pt(s,function(J){return{...J,isSidebarCollapsed:!0}})},[q,s]),$a=m.useCallback(()=>{pt(s,function(J){return{...J,isSidebarCollapsed:!1}})},[s]),Ba=m.useCallback(B=>{if(t||!B.trim())return;const J=r||xe||Q;J&&kt(J,e,B.trim())},[e,Q,r,t,xe]),Ha=m.useCallback(()=>{j.current?.focus()},[]),Ua=m.useCallback(()=>{if(O){H(!1);return}document.activeElement instanceof HTMLElement&&document.activeElement.blur()},[O]),qa=m.useCallback(()=>{const B=[...me].reverse().find(ke=>ke.role==="assistant");if(!B)return;const J=Je(B);J&&navigator.clipboard.writeText(J).catch(()=>{})},[me]),Wa=m.useCallback(()=>{H(!0)},[]),Ka=m.useCallback(()=>{A(t?"global":"current"),v(!0)},[t]),wi=m.useCallback(()=>{A("global"),v(!0)},[]);Eb({onNewChat:ki,onFocusInput:Ha,onEscape:Ua,onCopyLastResponse:qa,onShowHelp:Wa,onSearch:Ka,onSearchGlobal:wi});const Si=se.isLoading&&!se.data||d,Ci=!!Z&&z.errorUpdatedAt>ge.current,Va=!Si&&me.length===0,Xa=m.useMemo(()=>!Ci||!be?null:h.jsx(mb,{state:"error",error:be,onRetry:We}),[be,We,Ci]),vi=h.jsx($c,{sessions:b,activeFriendlyId:e,activeSessionKey:K,creatingSession:l,onCreateSession:ki,isCollapsed:q?!1:Se,onToggleCollapse:Oa,onSelectSession:Fa,onActiveSessionDelete:st,onOpenSearch:wi});return h.jsxs("div",{className:"h-screen bg-surface text-primary-900",children:[h.jsxs("div",{className:W("h-full overflow-hidden",q?"relative":"grid grid-cols-[auto_1fr]"),children:[Pe?null:q?h.jsxs(h.Fragment,{children:[!Se&&h.jsx("div",{className:"fixed inset-0 z-40 bg-black/40 transition-opacity duration-200",onClick:()=>pt(s,B=>({...B,isSidebarCollapsed:!0})),...et}),h.jsx("div",{className:W("fixed inset-y-0 left-0 z-50 w-[300px] transition-transform duration-150 safe-area-top",Se?"-translate-x-full":"translate-x-0"),...et,children:vi})]}):vi,h.jsxs("main",{className:"flex flex-col h-full min-h-0",ref:w,...Ke,children:[h.jsx(qc,{activeTitle:G,wrapperRef:g,showSidebarButton:q,onOpenSidebar:$a,totalTokens:de.totalTokens,contextTokens:de.contextTokens}),Pe?null:h.jsxs(h.Fragment,{children:[h.jsx(Oy,{messages:Vn,loading:Si,empty:Va,notice:Xa,noticePosition:"end",waitingForResponse:E,isStreaming:F,sessionKey:De,pinToTop:M,pinGroupMinHeight:k,headerHeight:C,contentStyle:bt,onFollowUpClick:Ba}),h.jsx(pb,{onSubmit:_a,isLoading:o,disabled:o,wrapperRef:y,inputRef:j})]})]})]}),O&&h.jsx(m.Suspense,{fallback:null,children:h.jsx(Tb,{open:O,onOpenChange:H})}),_&&h.jsx(m.Suspense,{fallback:null,children:h.jsx(jb,{open:_,onOpenChange:v,sessions:b,currentFriendlyId:e,currentSessionKey:Q,mode:D,onJumpToMessage:B=>{v(!1),B.friendlyId&&i({to:"/chat/$sessionKey",params:{sessionKey:B.friendlyId}})}})})]})}function Ib(){const e=Ut(),t=$s(),[n,r]=m.useState(null),i=Ja.useParams(),s=typeof i.sessionKey=="string"?i.sessionKey:"main",o=s==="new",a=n?.friendlyId===s?n.sessionKey:void 0,l=m.useCallback(function(c){pu(e,"new","new",c.friendlyId,c.sessionKey),r({friendlyId:c.friendlyId,sessionKey:c.sessionKey}),t({to:"/chat/$sessionKey",params:{sessionKey:c.friendlyId},replace:!0})},[t,e]);return h.jsx(Ab,{activeFriendlyId:s,isNewChat:o,forcedSessionKey:a,onSessionResolved:o?l:void 0})}const $b=Object.freeze(Object.defineProperty({__proto__:null,component:Ib},Symbol.toStringTag,{value:"Module"}));export{$b as $,Fb as a,we as c,Ku as u};
|